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 on75e769a9, 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 (65ee8c65cplus 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/main65ee8c65c: "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>
Subsystem design references
These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.
| Subsystem | Reference |
|---|---|
| Built-in subscriptions moving to plugins | Provider and plugin ownership |
| Built-in plugins: registry, lifecycle, plugins.yml, presets, settings schemas, the window's kernel (slots, error boundary, kit) | Plugin runtime |
| Plugins that run on the gateway's requests and replies | Gateway middleware |
| Tools that plugins give, offered to every agent as an MCP server | Plugin tools |
| Plugins that await context recall and observe completed replies | Asynchronous gateway request hooks |
| Claude subscription turns across Claude Code runs | Claude subscription bridge |
| How the gateway picks a provider, key or account, and falls back | Gateway routing and fallback |
| Gateway Session Aggregation | Gateway Session Aggregation |
| Connecting an agent's config to the gateway, drift, disconnect, WSL twins | Agent wiring |
| Providers, keys, subscription accounts, refresh and allowance | Providers and accounts |
| Instructions, MCP servers, skills and RTK written into agents | Library |
Tray, panel, window, magpie web and the page's JSON API |
GUI app shell |
| Encrypted backups and setup synchronization over WebDAV, S3 or GitHub | Sync and backup |
A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.
Maintain a reference
Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.
Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.
For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.
Describe a PR's semantic changes
For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.
For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.
This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.
Review a change
- Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
- Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
- Check that changed contracts appear in the owning reference and that source links still resolve.
- Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.
A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.