leokon on Discord (#help): the Library's MCP section listed only the Windows Pi, never a Pi installed in WSL. wslTargetOf left pi@wsl's MCP out because its version wasn't known, and Pi's MCP file depends on the version: 0.99+ reads mcp.json itself; before that, pi-mcp-adapter 3 reads mcp-adapter.json and 2 reads mcp.json. - The WSL probe now asks the distro's pi for --version (wslKind version: true). The answer is stored as the agent's wslVersion, and InstalledVersion returns it for an agent in WSL. - pi@wsl:<distro> gets piMCP. The file is chosen as on this computer, with the distro's npm roots for the adapter (~/.npm-global, /usr/local/lib and /usr/lib node_modules): wslPiRoots, piDetectIn. - Siblings: every agent with a local MCP target and no WSL one now has one, in its own file under the distro's home. These are Gemini CLI, Antigravity CLI, Crush, Cline, CodeBuddy Code, Kimi Code and Goose. - Every WSL MCP file is marked WSL with its distro, so a Windows program (C:\...\npx.cmd) is refused, as for claude/codex@wsl. - Not fixed: Kimi Code's and Goose's skills in WSL. On this computer they get the shared ~/.agents/skills, but the distro's needs that folder's sharing rule (#3966). Run (atd8c70504d+ this commit; rebased ond50f84c9f, two mover mins): - go test -tags nogui ./internal/agent ./internal/library on mote: ok. - GOOS=windows and GOOS=linux go vet ./internal/agent ./internal/library: ok. - gofmt -l: clean. - New tests: - TestWSLPiMCP covers three fake distros: Pi 1.2 gets mcp.json (native); Pi 0.98 with no extension gets mcp-adapter.json; Pi 0.98 with adapter 2 in ~/.npm-global gets mcp.json (fmtPi). Each is in the page's view, and is written to its distro and not this computer's Pi. A Windows program is refused. - TestWSLMCPSiblings covers the 7 siblings: path, WSL mark, writes, and refusal. The OS switch is forced with agent.FakeWSL. - GUI, on mote: library-*.test.cjs, wsl-agents-setting and i18n-keys (Chromium and WebKit, every language): 769 of 770 pass. The red is i18n-keys "a plugin's words are its own" ("Runs as" in claude_code_cli.go), red on main since7f827b3b0, #3897. - Full suite on mote (go test -tags nogui -timeout 45m ./...) atd8c70504d+ this change: 76 packages ok, no FAIL, exit 0. - Real run, on the Windows box: magpie built on Windows, run in a sandbox USERPROFILE. `magpie library mcp add wslfetch uvx mcp-server-fetch agents=pi@wsl:magpie-desktop` wrote the server into magpie-desktop's ~/.pi/agent/mcp-adapter.json. The distro has pi 0.73.0 from npm, which the probe asked; it is before 0.99 and has no extension. A C:\Program Files\nodejs\npx.cmd server was refused for pi@wsl. Both files were then removed. Broken by hand, each turned the new tests red: 1. pi@wsl with no MCP: TestWSLPiMCP. 2. The version not passed: Debian got mcp.json. 3. No distro roots: Arch got mcp-adapter.json. 4. No WSL mark on the file: the Windows program was written. 5. The gemini case removed: TestWSLMCPSiblings. Not tried: - A real Pi 1.x in WSL. magpie-desktop's own pi is 0.73 and was left as it is. The 1.x choice (mcp.json) is covered by the test only. @earendil-works/pi-coding-agent 1.4.0 answered `--version` with "1.4.0" on the box. - The seven siblings with real installs in WSL. - A distro that is stopped. Its saved probe from before this release has no pi version, so the file is chosen as for an unknown version (mcp.json), until the distro is probed while it runs. - The GUI on Windows. Its MCP list shows any agent whose view has an MCP file, unchanged.
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.