Commit Graph
4 Commits
Author SHA1 Message Date
yetoneandye4241 33ccc61884 library: one market skill from a huge repository installs alone; GitHub's file list is never cut (#2794)
Adding clean-code from sickn33/agentic-awesome-skills in the market
failed with "GitHub's list of sickn33/agentic-awesome-skills's files
wasn't understood: unexpected end of JSON input" (CaiusLuo; stablyai/
orca the same, ye4241). The repository's download is over 200 MB, so
its skills are fetched file by file from GitHub's list of its files
(#1941), and that list is 11.3 MB: apiGet cut every answer at 8 MB and
dropped the read's error, so JSON was handed a cut-off body.

From ye4241's patch on the issue (made on 75e769a9, applied as is):
apiGet takes the most its caller reads and reads one byte past it; a
200 over it is an error naming the cap, a read that breaks is a read
error, a rate limit is told from the status and headers before either,
and only answers up to 8 MB are kept for a 304. The file list's cap is
64 MB (maxTree), lastCommit keeps 8 MB.

That alone wasn't enough for the reporter's case: the 8,589 skills of
that repository come to 287 MB together, over maxFetch, so the install
would then fail as "too big to install". On top of the patch:
- fetchSkillFiles fetches only what the caller reads: the skills under
  src.Path, and for the market only the folders named as the skill it
  installs (InstallMarketSkill -> cachedProbeFor/probeSkills; such a
  probe is kept under its own key so a whole probe never takes it).
  When no folder has that name every skill under the path is fetched,
  as before.
- with a path (a link to a folder, an update, a check for new skills
  under newBase) the list asked for is that folder's own, git's
  ref:path (treeUnder; a few KB instead of 11 MB, and small enough to
  be kept for a 304). When it can't be had (404, a ref git can't read
  that way, cut off) the whole list is read, which says for sure what
  is there, so goneFrom never trusts a 404. A rate limit is said at once.
- the fetcher kept one fetch per repository and ref for every skill of
  it. A fetch narrowed to one skill's folder is now kept to that folder
  (fetcher.get): another skill of the same repository gets a fetch of
  its own, where it was read as removed upstream (broken by hand below).
- a CC Switch skill being adopted looks in the whole repository, since
  its Path is only the folder's name.
- a probe of a folder whose skills are all too big lists it empty and
  names them, as before; the whole repository's still fails.
- GitHub's own truncated list is errTooBig, by path or not
  (TestTruncatedListIsTooBig).
- apiGet's client waits 2 minutes, not 20s, for an answer over 8 MB.

docs/subsystems/library.md says how far a big repository is fetched.

Tests (no network; fake codeload, API and raw):
- TestMarketSkillFromAHugeRepository: an 11 MB list, a download over
  the limit and skills over it together. The market installs one, raw
  is asked only for its files, and UpdateSkills of two of its skills
  updates both, each asking for its own folder's list.
- TestRepoTreeBigList, TestApiGetWholeAnswer: ye4241's.
- the fake trees in skilltree_test and skillnew_test answer git's
  ref:path as GitHub does (checked against api.github.com: HEAD:skills/
  clean-code lists that folder, HEAD:nonexist is 404).

Broken by hand, each red, then restored:
- apiGet back to the 8 MB cut with the error dropped: both
  TestRepoTreeBigList and TestMarketSkillFromAHugeRepository fail with
  "unexpected end of JSON input".
- no name narrowing: "the skills in vectorize-io/hindsight are too big
  to install".
- the fetcher sharing a narrowed fetch: Gone:[hindsight-docs].
- no ref:path list: the update listed ["HEAD" "HEAD"].

Run at this tree (65ee8c65c plus this change):
- gofmt -l internal: clean
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: clean
- go test -count=1 -timeout 45m ./internal/library/: ok 131s
- real: a throwaway realnet test in a sandbox HOME, no GitHub token,
  InstallMarketSkill("sickn33/agentic-awesome-skills", "clean-code"):
  installed in 15s, SKILL.md 5,202 bytes, Path skills/clean-code;
  UpdateSkill then took 0.6s through its folder's list. The same test
  at origin/main 65ee8c65c: "unexpected end of JSON input".

Not tried: the full ./... suite (only internal/library changed, other
sessions' suites were running); Windows and Linux runs (vet only); the
GUI (no GUI text changed); stablyai/orca for real.

Co-authored-by: ye4241 <ye4241@users.noreply.github.com>
2026-10-27 09:31:57 +08:00
yetone aa6a0d6b20 library: one skill over 200 MB is left out, not the whole repository (#2062)
mikubaka88/CCFA-Skills couldn't be installed at all: "the skills in ... are
too big to install (over 200 MB)". The repository is over the 200 MB
tarball cap, so fetchSkillFiles fetched it file by file, and that refused
the whole repository once the files summed past 200 MB. One skill,
ccf-paper-writer, is 297 MB on its own (exemplar paper PDFs, llava-4d.pdf
alone 46.8 MB); the other 16 are small.

The 200 MB limit per skill stays: a skill is copied into every agent that
gets one as a copy, and treeOf stops comparing at 256 MB, so a 297 MB skill
can't be told current or edited. What changes is that one such skill no
longer blocks the rest:
- fetchSkillFiles sums each skill's files (the deepest skill folder a file
  is under) and leaves out a skill over maxFetch; its files are never
  asked for. Only when every skill is over it does it fail as before.
- The left-out skills reach ProbeSkills as Probe.Left (path, size), kept
  per temp folder and taken once (tookLeftOut).
- The GUI's probe names each under the list ("{name} is too big to
  install: 283 MB, over the 200 MB a skill may be"), or in place of "No
  skills there" when nothing else is left; zh, zh-TW, ja, de. The TUI says
  it in its flash.
- docs/subsystems/library.md says how a big repository is fetched.

Run:
- Real: probe of mikubaka88/CCFA-Skills under a sandbox HOME lists 16
  skills and leaves out ccf-paper-writer (296736735 bytes). Not installed
  into a real agent.
- gofmt -l internal/: clean. go vet ./internal/gateway ./internal/library
  ./internal/tui on darwin, GOOS=linux -tags nogui, GOOS=windows (set -o
  pipefail): clean.
- go test -count=1 ./internal/library ./internal/tui: ok.
- TestOneSkillTooBigLeavesTheOthers (new): fails with the per-skill
  leave-out turned off by hand, passes with it.
  TestTooBigRepositoryChecksWhatArrives now makes every skill too big.
- skill-too-big.test.cjs (new), chromium and webkit, en 980 and zh,
  zh-TW, ja 440, de 420, plus every-skill-too-big: 14/14; red (0/7 in
  chromium) with client.js at origin/main. skill-*.test.cjs 190/190 and
  library-*.test.cjs 484/484 in both engines.
2026-10-14 09:32:21 +08:00
yetone 776c255f56 library: a market skill kept only in a repository's .claude/skills installs (#1964, UFO404)
The market lists ui-ux-pro-max from nextlevelbuilder/ui-ux-pro-max-skill,
whose SKILL.md is only at .claude/skills/ui-ux-pro-max. candidates()
skipped every hidden folder, so the install said "has no skill
ui-ux-pro-max any more".

candidates() now looks into a hidden folder only for its skills folder
(.claude/skills, .agents/skills, .codex/skills ...), the same agent
folders the skills CLI behind skills.sh reads. A skill found there that
the repository also has outside hidden folders (that repo keeps brand,
design, slides... in both .claude/skills and cli/assets/skills) is listed
once, as the one outside, as the skills CLI does by name. skillDirsIn,
which the new-skills check reads from GitHub's tree, follows the same
rule, so the two paths agree. A hidden folder that isn't an agent's
skills folder (skills/.hidden, .claude-plugin/x) is still skipped.

TestSkillsFromATooBigRepository (#1941) expected hindsight's own
.claude/skills/ship-it to be left out; it is listed now, as the skills
CLI lists it.

Run:
- TestMarketInstallsASkillKeptInClaudesFolder, with the repository's
  real paths. On the old code it fails with "has no skill ui-ux-pro-max
  any more". Turning off the de-duplication and the skills-folder rule by
  hand each turns it red.
- A throwaway test (not committed) installing ui-ux-pro-max from the
  real GitHub repository in a sandbox HOME: installed, candidates are the
  six cli/assets skills plus .claude/skills/ui-ux-pro-max.
- go test ./internal/library (nogui), gofmt -l, go vet for darwin, linux
  and windows.
Not tried: the GUI Market page itself.
2026-10-13 16:49:07 +08:00
yetone 4794de398e library: a skill installs from a repository too big to download whole, by fetching only its skills' folders (#1941, Goalonez)
What changed: fetch still downloads a repository as one codeload
tarball first. When its files pass the 200 MB limit (untar's errTooBig),
it now falls back to fetchSkillFiles: one request to GitHub's API for
the repository's file list (git/trees?recursive=1), then every file in
a folder with a SKILL.md, from raw.githubusercontent.com, each checked
against the git hash the list gives. The repository's folders are made
empty, so candidates, origin, a probe of a subfolder and an update check
read the result as they read a whole download. The 200 MB limit now
applies to what is actually fetched: skills that are themselves over it
still say so. A private repository's files come from the API's
git/blobs with the Settings token (it never goes to raw). A repository
found too big is remembered for the run, so the install after its probe,
and update checks, don't download 150 MB again before falling back.
gitTree's entries gained mode, sha and size (named gitEntry).

Why: vectorize-io/hindsight keeps its skills (a few hundred KB) beside
an app; its tarball is 188 MB gzipped, 253 MB unpacked, so any skill
in it failed with "the repository is too big to install skills from".

What was run:
- Real repo, sandbox HOME, no token: on the old code ProbeSkills
  ("https://github.com/vectorize-io/hindsight") fails with "too big"
  after 34s. With the fix it lists all 15 skills (skills/*, the
  integrations' skills; .claude/skills hidden as before) in 32s, and
  installing skills/hindsight-docs writes its 160 files, the same count
  GitHub's tree lists.
- New TestSkillsFromATooBigRepository and
  TestTooBigRepositoryChecksWhatArrives (httptest stand-ins for codeload,
  the API and raw, laid out as hindsight is, paths and tree entries
  from its real listing). With the fallback taken out both fail with
  "the repository is too big to install skills from (over 200 MB)".
  They check raw is never asked for a file outside a skill, codeload
  is asked once across two probes, a file that doesn't match its hash
  is refused, and skills over the limit themselves still error.
- go test -tags nogui ./internal/library (ok, 141s); -race -count=10
  -run TooBig (ok); gofmt -l clean; go vet, GOOS=linux and
  GOOS=windows go vet -tags nogui ./internal/library clean.
Not tried: a private repository over the limit against real GitHub
(covered only by reading: raw 404 -> git/blobs with the token).
2026-10-13 14:53:42 +08:00