wsl: a distro's agent folder that is a link is opened where it leads (#4502)

On Windows, adding a skill or switching RTK on for an agent in WSL failed
with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file
when that file already exists` (linusxiong). In the distro ~/.codex is a
link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't
follow a link the distro has: a mkdir of it says it exists, and nothing
below it can be made, written, read or listed. ggbdpq found and explained
the link (thanks); their patch, which takes that EEXIST as "there", wasn't
used: the writes below the link fail next (its test passed because a
symlink here is followed).

The fix, for every agent folder and every writer through \\wsl.localhost:
- The WSL probe asks `readlink -f` in the distro where each agent folder,
  its skills folder and the folders beside them lead (wslLinkPaths ->
  distro.Links; a $HOME that is itself through a link is left alone), and
  which drive each Windows mount is (win:/mnt/c C: -> distro.Drives).
- distro.open opens a path at or below a link where it leads: on a Windows
  drive, the drive's own path (C:\Users\<user>\.codex); elsewhere in the
  distro, through \\wsl.localhost again. native spells it back through
  the link, so the agent is told its own path.
- A link readlink couldn't resolve is never guessed at: distro.open
  errors, and the agent is unreached (Agent.Unreached: its notice says
  why; every field Set and Sync returns it).
- Writers: the agents' own files (place.join/place.open, every
  filepath.Join(at.home, ...) in internal/agent), the library's WSL
  targets (wslOpen/wslOpened; one "wsl" problem per agent and nothing
  written), RTK (rtkAt, rtkInstall checks agent.WSLOpen before its mkdir),
  the Sessions page's WSL reads (sessions.WSLHome.Open) and the Copilot
  CLI sign-in read (provider.CopilotWSLHomes -> CopilotWSLDirs).
- Not changed: magpie's image MCP server opens arbitrary paths an agent
  in WSL gives it the same way; filed as #4578. Links deeper than the
  probed paths (other than <agent dir>/skills) aren't resolved. A distro
  probed by an older magpie has no Links until probed again (each run).

Run:
- Real Windows box (xiaomi-gpu, distro magpie-desktop, sandbox
  /tmp/x4502/home with .codex -> /mnt/c/Users/yeton/runs/x4502-target/.codex,
  .claude -> /tmp/x4502/data/claude, .pi -> a missing folder), a throwaway
  Windows test running the real probe with that HOME: probe said
  link:.codex /mnt/c/..., link:.claude /tmp/x4502/data/claude, link:.pi,
  win:/mnt/c C:, win:/mnt/d D:. The old way, MkdirAll(\\wsl.localhost\
  magpie-desktop\tmp\x4502\home\.codex\skills\pdf) = "Cannot create a file
  when that file already exists" (the report's error). distro.open wrote
  SKILL.md to C:\Users\yeton\runs\x4502-target\.codex\skills\pdf and to
  \\wsl.localhost\magpie-desktop\tmp\x4502\data\claude\skills\pdf, both
  read back with cat in the distro through the links; .pi said "~/.pi in
  WSL magpie-desktop is a link magpie couldn't follow". Sandbox and target
  removed after.
- New tests with a fake distro whose ~/.codex and ~/.claude are links to
  /mnt/c/... that don't exist here, so, as through \\wsl.localhost,
  nothing below them can be made: TestWSLFolderIsALinkToC,
  TestWSLFolderLinkUnresolved, TestRTKWSLFolderIsALink,
  TestRTKWSLFolderLinkUnresolved (library); TestWSLProbeLinks (runs the
  probe script), TestWSLOpenThroughLinks, TestWSLAgentFolderIsALink
  (config and a Claude session read on C:), TestWSLAgentFolderLinkUnresolved
  (agent).
- Broken by hand: the library tests on the base (with a no-op
  FakeWSLDrives) fail with "mkdir .../home/me/.codex: file exists", the
  report's error; with ggbdpq's patch applied they still fail (the skill
  mkdir, and RTK's hook not written).
- mote: go build ./...; go vet of agent, library, sessions, provider for
  darwin, GOOS=windows (and linux for agent, library); gofmt -l clean;
  go test -timeout 45m ./internal/agent ./internal/library
  ./internal/sessions ./internal/provider: all ok.
- Windows (win-run): the same four packages. The new tests pass (the
  RTK ones skip: the fake distro runs sh). 32 tests are red, all already
  red at the base c63c2136b run on the same box, and filed (#4115, #2808:
  Hermes profiles, Codex keychain, Agy, desktop entries, ...); the Hermes
  ones fail alike on base and branch with -count=3.

- Rebased on origin/main 3ecc02b78 (it changed internal/agent): at this
  head on mote, go build ./..., go vet of the four packages for darwin,
  windows and linux, gofmt -l, go test ./internal/agent ./internal/library:
  ok.

Not tried: the full ./... suite; the GUI (no GUI change; the unreached
notice uses the existing Notice); a real Codex/Claude Code run against
the moved files in the distro.
This commit is contained in:
yetone
2026-10-31 21:29:22 +08:00
parent 3ecc02b78b
commit 73a12e8bf6
51 changed files with 801 additions and 114 deletions
+1
View File
@@ -27,6 +27,7 @@ something else shows up as drift.
| Codex: DeepSeek models | A DeepSeek model's entry (`codexcat.deepSeek`: deepseek-v4*, -flash, -pro, -chat, -reasoner after any provider or relay prefix; not a routing group, not a distill) takes what DeepSeek's own Codex setup (cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh, its models.json) says of its models: `shell_type` `shell_command` (Codex 0.165 reads it as `unified_exec`, its only shell; older Codex had a one-shot `shell_command` tool), `support_verbosity` with `default_verbosity` low, `default_reasoning_summary` none (no `reasoning.summary` sent), `multi_agent_version` v2, and `supports_image_detail_original` on a model whose entry takes images. Not taken: its `base_instructions`/`model_messages` (magpie never rewrites a Codex prompt), its `auto_compact_token_limit` null (magpie's 272K default stays, from e950eb080's DeepSeek latency report; Full window or the model's Compact at gives the whole window), `supports_search_tool` false on v4-pro (#258), its reasoning levels (the provider's). `default_reasoning_summary` is tagged `keep:"unset"`, so a value the user put in another model's entry stays (`Keep`). Other vendors' entries are unchanged. `TestCodexCatalogDeepSeekAsDeepSeekSays`, `TestCodexCatalogKeepsUsersSummary`. | [`codexcat.go`](../../internal/codexcat/codexcat.go) |
| Named omp profiles | omp keeps a profile's settings under `~/.omp/profiles/<name>` (or under `PI_CONFIG_DIR`), each with its own `config.yml` and `models.yml`. Every such profile is an agent of its own — `omp#<name>` on Windows, `omp#<name>@wsl:<distro>` in a distro — so each can be connected, drifted and disconnected on its own. They share omp's model lists (`ListsFor`), and the default `omp` row is the folder `ompDir`/`ompIn` already pick, so an `OMP_PROFILE` that row is already pointed at is not listed twice. A name omp refuses is not a row: `default`, a trailing dot, or a Windows reserved device name (`aux`, `nul`, `com1`, `lpt9.x`, `con.work`), on every platform (`ompProfileOK`). A distro's profile names come from its probe and are kept in `wsl.json`; a stopped distro is never started to list them, its profile rows showing what was last seen (`asleep`). | [`omp.go`](../../internal/agent/omp.go), [`wsl.go`](../../internal/agent/wsl.go) |
| WSL twins | On Windows each running distro is probed once, without starting a stopped one. The `wslKinds` agents found there become agents of their own, `<id>@wsl:<distro>`, edited through `\\wsl.localhost\<distro>`. A kind is found by its folder under the distro's home or by its command there (not one on a Windows drive). Where another tool shares one of them, the kind leaves it out: Gemini CLI is found by its command alone, because Antigravity keeps `~/.gemini` too. Antigravity CLI is found by its own `~/.gemini/antigravity-cli` or its `agy` command (mimi001234 on Discord). Goose is found by its folder alone, because a `goose` command can be pressly's migration tool. Reasonix also needs the version its command gives (`accept`), because the old npm client is named `reasonix` too. The gateway address and key follow the distro's networking: mirrored or NAT (`place`, `keyAt`). Under NAT the key is the gateway's WSL key (`gateway.WSLKey`, `-<agent>` after it where the agent's key names it), sharing on or off; the gateway listens at that address itself (gateway-routing's WSL under NAT). `ListsFor` keeps a twin's model picks under the Windows twin's id (#927). | [`wsl.go`](../../internal/agent/wsl.go), [`gatewaykey.go`](../../internal/agent/gatewaykey.go) |
| WSL folders that are links | Through `\\wsl.localhost` Windows can't follow a link the distro has: with `~/.codex` a link to `/mnt/c/Users/<user>/.codex`, a mkdir of it says it exists and nothing below it can be made, written, read or listed (#4502, linusxiong). The probe asks `readlink -f` there where each agent folder, its `skills` and the folders beside them lead (`wslLinkPaths`, `distro.Links`; a `$HOME` that is itself through a link is left as it was) and which drive each Windows mount is (`distro.Drives`). `distro.open` opens a path at or below a link where it leads: on a Windows drive the drive's own path (`C:\Users\<user>\.codex`), elsewhere in the distro through its root again; `native` spells such a path back through the link for the agent. A link `readlink -f` couldn't resolve is never guessed at: its agent is unreached (`Agent.Unreached`), says why in its notice and refuses each change and sync. Every writer goes through it: the agents' own files (`place.join`, `place.open`), the library's targets (`wslOpen`, a `wsl` problem per agent), RTK (`rtkAt`, `agent.WSLOpen`), the Sessions page's reads (`sessions.WSLHome.Open`) and the Copilot CLI's sign-in (`provider.CopilotWSLDirs`). Links deeper than the probed paths aren't resolved (`TestWSLOpenThroughLinks`, `TestWSLAgentFolderIsALink`, `TestWSLAgentFolderLinkUnresolved`, `TestWSLProbeLinks`, `TestWSLFolderIsALinkToC`, `TestRTKWSLFolderIsALink`). | [`wsl.go`](../../internal/agent/wsl.go), [`targets.go`](../../internal/library/targets.go), [`rtk_wsl.go`](../../internal/library/rtk_wsl.go) |
| Settings tuned from use | Usage › Context's "Tuned for you" advises, per agent, the settings that would have spent the fewest tokens on the user's own calls of the range, and puts one in on a click. Package `tune` replays the calls `sessions.Calls` reads from the agents' session files under each candidate value (`Compact`, `CacheTTL`); `tuneOf` picks the agents and models (Claude Code per model, Codex pooled). `TuneRead`, `TuneApply` and `TuneUndo` know where each setting lives: Claude Code's `modelSettings.<model>.autoCompactWindow` (where its `/autocompact` saves), `promptCacheTtl` and `subagentPromptCacheTtl` in `~/.claude/settings.json`. Where Codex compacts, and Claude Code wherever magpie's own window is what it runs at, is one value with Long conversations in the agents' settings sheet (`settings.CompactAt`/`FullContext`, source `long`; 7eleven on Discord): the card reads it, Use sets it through `provider.SetCompactAt`, and Sync writes it into each agent's config as it does for the sheet; the note says it is Long conversations, shared by Codex and Claude Code (`compact-one-value.test.cjs`). The advice is weighed by tokens alone: it is labelled "Fewest tokens", and a compaction window it would change says it doesn't measure how well the agent keeps the task after a compaction, and that a lower window compacts more often (#1854, `context-tune.test.cjs`). A compaction row's "Other window…" opens the app menu with every value of the curve, each with its estimated extra tokens over the fewest and about how many compactions it would have made (`Point.compacts`, from the same replay), and puts the one picked in like Use (#1860). An agent whose files time its compactions also has their wait weighed (HirotaNagai on X): Claude Code's `compact_boundary` line says `compactMetadata.durationMs`, which `sessions` puts on the first call after it, and Codex compacts by a call of its own (the record a `compacted` line names, in rollouts since 2026-09), whose time is the compaction's (`Call.Compact`; an older rollout's compaction has no call and stays untimed). With 3 or more timed for a model (`minTimed`), `Facts.took` is their median seconds, each window says its wait (`Point.wait`, its compactions × `took`), and the row says what a compaction took, the wait at the advice against the window now, and the cheaper window the advice passed over for waiting longer (`Compaction.cheapest`, `wait_cheapest`) when it saves 3% or more; the advice is labelled "Tokens + wait", its caveat says tokens and waiting only, and the picker says each window's wait with "Fewest tokens" on the cheapest (`context-tune.test.cjs`). An agent or model with fewer timed reads and is advised as before. | [`internal/tune`](../../internal/tune/tune.go), [`tune.go`](../../internal/agent/tune.go), [`internal/gui/tune.go`](../../internal/gui/tune.go) |
| Agents a plugin adds | A plugin's `magpie.agent` module (or a `*.agent.js` file) says where an agent magpie has no setup of its own keeps its model (`config`, `format`, `model`, `prefix`), and its `connect` returns the other keys to write. One with no `model` is connect only (#2374): its one field is `provider`, magpie or nothing, as an app whose one setting is magpie as its provider; `connect` is called without a model, must return keys, and is called again on a catalog change (`Sync`); `ListsModels` is set, so its list is the models picked for it. `agentplug` compiles each in moejs (via `jsmod`, as gateway middleware is), reloads it when plugins.json or the file changes, and keeps why one didn't load. `plugged` makes each an `Agent` with `Plugin` set, listed after magpie's own; an id one of magpie's own agents has is refused (`PluginErrors`). `connect` is given each model as `magpieModels` builds it, with `/v1/models`' `native_endpoints` (`provider.NativeEndpoints`, carried as `catalog.Model.Endpoints`) and `pricing` (`catalog.OpenRouterPricing` of the same `EntryPricer` price), each left out when not known ([`plugged_connect_facts_test.go`](../../internal/agent/plugged_connect_facts_test.go)). | [`agentplug.go`](../../internal/agentplug/agentplug.go), [`plugged.go`](../../internal/agent/plugged.go) |
| Environment-only agents | Agents that read the gateway only from the environment get a `Launch` command. Antigravity CLI (agy) also gets a function `agy` in each shell's profile while it is on one of magpie's models, so typing `agy` in a new terminal starts it on magpie (bestony on Discord). The function runs `magpie agy run`, which starts the agy on PATH with `GEMINI_API_KEY`, `GOOGLE_GEMINI_BASE_URL` and `--model` (no `--model` when the user gives one) while settings.json's model is still magpie's, and unchanged otherwise. PowerShell's asks `magpie agy env` for them, since the Windows app is a GUI program PowerShell doesn't wait for. `Typed` says the function is there; the row then says plain `agy` works in a new terminal, and the `Launch` command is for a terminal open before. agy has no settings-only route: 1.4.7 refuses to start without `GEMINI_API_KEY` in the environment even with a key on the custom model. Cursor Private Inference instead gets user-level variables (`cursorLocalOn`, `KeepCursorLocalEnv`), and magpie writes none of Cursor's own files. It is found by its product.json in the apps folders, in the folder Windows' list of installed programs names (`cursorLocalInstalls`, any folder picked in its installer), or as its Linux AppImage (`Cursor_Private_Inference-…AppImage`) in the folders downloads are kept in (#1254). Its effort field is kept in magpie (`provider.AgentEffort`) and asked by the gateway, its levels those of the models it lists (`cursorLocalEfforts`, #1003). | [`cursorlocal.go`](../../internal/agent/cursorlocal.go) |
+1 -1
View File
@@ -15,7 +15,7 @@ agents RTK, a CLI that cuts shell output down before the model reads it.
| --- | --- | --- |
| library.json | `Library` holds the instruction sets, the MCP servers, the skills, the projects, skill groups and copy settings. `Applied` records what magpie last wrote into each agent, so it only ever takes away its own. The instruction texts and skill folders live under `Dir` (`library/` in magpie's config folder). | [`library.go`](../../internal/library/library.go) |
| One change | `change` locks the library, loads it, applies one edit, saves, syncs every agent and saves again. Every exported mutation (`SaveServer`, `InstallSkills`, `SetSkillHow` and the rest) goes through it. One change runs at a time, whether from the page or the CLI. | [`library.go`](../../internal/library/library.go) |
| Targets | `Targets` lists the detected agents (`agent.Detected`), a folder an agent shares with its vendor's other app when only that app is here (`agent.SharedHere`: the Cursor editor's `~/.cursor`, whose `mcp.json` and skills it reads, listed as Cursor; `TestCursorEditorAloneKeepsItsLibraryRow`), plus apps like Claude Desktop, with where each keeps its instructions file (and an `Override` it reads instead), its MCP file and its skills folder. An agent whose CLI is gone (`CLIMissing`: an uninstall that left the folder behind, #2177, #2254) is no target: it is given nothing it can't read. One that isn't a target but still has skills, servers or hooks magpie gave it (in `Applied`, or listed in an item's `Agents`) is held (`held`, a `Target` with `Gone`): a sync takes edits from its copies and then only takes out of it (`syncSkills`, `syncMCP` and `syncHooks` give a gone target nothing new), and `Read` lists it with `gone: true` while it has any. The page shows a gone agent's chip only on the rows of what it has, lit, so a click takes it out (`withGone` in plugins/library/client.js), leaves it out of All, the per-agent How sheet and every picker, and lists it in By agent as Not installed here with Turn all on off (@jiahao_jayden on X: an uninstalled WorkBuddy was on every skill's row; `TestGoneAgentListedToTakeOut`, `library-gone-agents.test.cjs`). On a Mac WorkBuddy and WorkBuddy AI are detected by their apps' bundle ids (`com.tencent.workbuddy.mac`, `com.workbuddy.workbuddy-ai`, `macBundle`), not by `~/.workbuddy`, which an uninstall leaves and magpie itself writes into (`TestWorkBuddyOnMacIsItsApp`); off a Mac the folder still counts. `everyTarget` keeps it for the guards that refuse an agent's own places: a project folder whose skills folder or MCP file is the agent's, and an instruction set kept in its instructions file. An agent in a running WSL distro has its places under the distro's home (`wslTargetOf`): Claude Code, Codex, Pi, OmO, Gemini CLI, Antigravity CLI, Crush, Cline, CodeBuddy Code, Kimi Code and Goose each by its own rule, never reading this machine's variables (Kimi Code's and Goose's shared `~/.agents/skills` there isn't given), Pi's MCP file chosen by `piMCP` as on this machine from the version the distro's `pi --version` gave its probe (`InstalledVersion`) and the distro's npm folders (`wslPiRoots`; leokon on Discord: only the Windows Pi was offered MCP servers, `TestWSLPiMCP`, `TestWSLMCPSiblings`), and every agent that keeps all of them in its own folder (Hermes Agent, omp, OpenCode, Droid and the rest of `ownFolder`, #1323) by the same rule as on this machine, its MCP file marked as WSL's so a Windows program isn't given to it. An agent a plugin adds (`a.Plugin`) has the places its plugin's `agent.library` names (`pluginTarget`): an instructions file, an MCP file in one of `agentplug.MCPFormats` (each the `mcpFormat` of the agent it is named for, `pluginMCP`) and a skills folder, `~` and `$VAR` expanded as its config is; one that names none is no target. Before, a plugin's agent got models and keys only. | [`targets.go`](../../internal/library/targets.go) |
| Targets | `Targets` lists the detected agents (`agent.Detected`), a folder an agent shares with its vendor's other app when only that app is here (`agent.SharedHere`: the Cursor editor's `~/.cursor`, whose `mcp.json` and skills it reads, listed as Cursor; `TestCursorEditorAloneKeepsItsLibraryRow`), plus apps like Claude Desktop, with where each keeps its instructions file (and an `Override` it reads instead), its MCP file and its skills folder. An agent whose CLI is gone (`CLIMissing`: an uninstall that left the folder behind, #2177, #2254) is no target: it is given nothing it can't read. One that isn't a target but still has skills, servers or hooks magpie gave it (in `Applied`, or listed in an item's `Agents`) is held (`held`, a `Target` with `Gone`): a sync takes edits from its copies and then only takes out of it (`syncSkills`, `syncMCP` and `syncHooks` give a gone target nothing new), and `Read` lists it with `gone: true` while it has any. The page shows a gone agent's chip only on the rows of what it has, lit, so a click takes it out (`withGone` in plugins/library/client.js), leaves it out of All, the per-agent How sheet and every picker, and lists it in By agent as Not installed here with Turn all on off (@jiahao_jayden on X: an uninstalled WorkBuddy was on every skill's row; `TestGoneAgentListedToTakeOut`, `library-gone-agents.test.cjs`). On a Mac WorkBuddy and WorkBuddy AI are detected by their apps' bundle ids (`com.tencent.workbuddy.mac`, `com.workbuddy.workbuddy-ai`, `macBundle`), not by `~/.workbuddy`, which an uninstall leaves and magpie itself writes into (`TestWorkBuddyOnMacIsItsApp`); off a Mac the folder still counts. `everyTarget` keeps it for the guards that refuse an agent's own places: a project folder whose skills folder or MCP file is the agent's, and an instruction set kept in its instructions file. An agent in a running WSL distro has its places under the distro's home (`wslTargetOf`): Claude Code, Codex, Pi, OmO, Gemini CLI, Antigravity CLI, Crush, Cline, CodeBuddy Code, Kimi Code and Goose each by its own rule, never reading this machine's variables (Kimi Code's and Goose's shared `~/.agents/skills` there isn't given), Pi's MCP file chosen by `piMCP` as on this machine from the version the distro's `pi --version` gave its probe (`InstalledVersion`) and the distro's npm folders (`wslPiRoots`; leokon on Discord: only the Windows Pi was offered MCP servers, `TestWSLPiMCP`, `TestWSLMCPSiblings`), and every agent that keeps all of them in its own folder (Hermes Agent, omp, OpenCode, Droid and the rest of `ownFolder`, #1323) by the same rule as on this machine, its MCP file marked as WSL's so a Windows program isn't given to it. A place below a folder the distro has as a link is opened where the link leads (`wslOpen`, agent-wiring's WSL folders that are links, #4502); a link the distro couldn't resolve gives that agent one `wsl` problem and nothing is written to it (`TestWSLFolderIsALinkToC`, `TestWSLFolderLinkUnresolved`). An agent a plugin adds (`a.Plugin`) has the places its plugin's `agent.library` names (`pluginTarget`): an instructions file, an MCP file in one of `agentplug.MCPFormats` (each the `mcpFormat` of the agent it is named for, `pluginMCP`) and a skills folder, `~` and `$VAR` expanded as its config is; one that names none is no target. Before, a plugin's agent got models and keys only. | [`targets.go`](../../internal/library/targets.go) |
| Stopped WSL distro | A stopped distro's agents are no targets: opening their files would start the distro, or the read fails (#3896). While a distro runs, `keepShape` keeps each agent's places and what its MCP file takes in `wsl.json` (`agent.WSLKeep`, key `library:<kind>`). While it is stopped, `Read` lists its agents from that (`asleepView`, `asleep: <distro>`), ticks as library.json has them; one magpie never saw there is listed only on the rows that name it, as `unseen`, its ticks not shown (cybercaius on Discord: the MCP page knew a distro's agents only once WSL had started). A tick on a stopped agent is kept in library.json as any is (`Takes` accepts one with a known shape; `serversAgents` judges it by `shape.reaches`), nothing is written and nothing in the distro runs; `Woken`, from `KeepLinked`'s loop (and the app's start-up sync), syncs when a distro the library names is seen go from stopped to running (`wsl.exe -l --running`, which starts nothing). The page greys a stopped agent's chip, says so in its tooltip and in one line per distro (`.lib-asleep`); an unseen chip is `aria-disabled` and kept by every click on its row (`keptOf`). The CLI says the same on stderr (`AsleepIn`). Queued, not a start button: a start costs the memory #3896 is about, and All or a bulk tick would start every distro. The Instructions page lists them too (`asleepInstructions`, #4182), at the instructions file the shape keeps, switched on as library.json has them, with what each gets besides (magpie's own folder) and nothing read from the file: its own lines and edits aren't counted then, and its path is plain text, not a reveal, which would open the distro. One switched on whose file magpie never saw is listed as `unseen`, its switch greyed out and kept by every other switch; before, a switch on the page sent the agents without the stopped distro's and took them off. A switch on one is written by `Woken`, which watches a distro named in `Instructions.Agents`, or whose agent still has magpie's part (`Applied.Instructions`), so one switched off has it taken out. The Hooks page lists the stopped agents with a shape as it does while the distro runs (`hooksView`, #4237): greyed, since magpie gives no agent in WSL hooks yet (`wslNoHooks`), and a hook given one says so; there is nothing for `Woken` to write. So does the Subagents page for the kinds it lists (`subagentsView`, `wslNoSubagents`, #4238). | [`wsl_asleep.go`](../../internal/library/wsl_asleep.go), [`targets.go`](../../internal/library/targets.go), [`plugins/library/client.js`](../../internal/gui/assets/plugins/library/client.js) |
| Sync | `sync` writes each target's instructions and MCP servers. It then takes edits made in agents' skill copies into the library (`takeEdits`) and links or copies the skills. `~/.agents/skills` goes first, so an agent that reads it gets no second link. Then it syncs projects' skills. | [`sync.go`](../../internal/library/sync.go) |
| Projects | A project (`Project`) is a folder given some of the library's skills and MCP servers, each for some agents. A skill is linked (or copied) into the folder the agent reads a project's skills from (`projectSkillsDirs`): `.claude/skills` for Claude Code, `.qoder/skills` for Qoder and Qoder CN, `.codebuddy/skills` for CodeBuddy Code, `.commandcode/skills` for Command Code, and `.agents/skills` for Codex, Gemini CLI, OpenCode, Pi, Cursor, Copilot CLI, Antigravity, Kimi, Goose, Grok, Droid and Cline. A server is written into the file the agent reads a project's servers from (`projectMCPFiles`), in the shape its user-wide file has: `.mcp.json` for Claude Code and CodeBuddy Code (CodeBuddy's `mcp.json` when the project has that and no `.mcp.json`, since it reads only the first of the two), `.codex/config.toml`, `.gemini/settings.json`, `.cursor/mcp.json`, `opencode.json`, `.zcode/config.json`, `.pi/mcp.json`, `.qoder/settings.json`'s `mcpServers` for Qoder and Qoder CN, and `.factory/mcp.json` for Droid. Claude Code, Qoder and CodeBuddy ask the user to approve a project's server before using it. Only targets whose vendor source or docs name them are listed (each map's comment cites them); an agent with none (Copilot CLI's MCP, Zed, WorkBuddy, Command Code's MCP, whose `.mcp.json` has its own `transport` shape) can't be picked for a project (eirc on Discord). `Placed`, `Wrote`, `Made` and `MadeFiles` record what magpie put there, the only things it takes away, and what it made is listed in the project's `.gitignore`. | [`projects.go`](../../internal/library/projects.go), [`project_mcp.go`](../../internal/library/project_mcp.go) |
+3
View File
@@ -314,6 +314,9 @@ type Agent struct {
// wslVersion is an agent in a WSL distro's CLI's version, as the
// distro's probe asked it (wslKind.version); "" when not asked
wslVersion string
// unreached, for an agent in a WSL distro, is why its folder there
// can't be opened: a link the distro couldn't resolve (distro.open)
unreached error
// move, when set, points the agent's config at to where it names the
// gateway at from: an address of WSL's that changed (#1013).
move func(from, to string) error
+7 -7
View File
@@ -46,7 +46,7 @@ func init() {
return agy(home).Launch()
}
// a Copilot CLI signed in inside a running distro (#723)
provider.CopilotWSLHomes = copilotWSLHomes
provider.CopilotWSLDirs = copilotWSLDirs
// the Codex app's app-server is restarted when magpie becomes Codex's
// provider for its used-up ChatGPT account, and when it stops being it;
// and when Codex is connected or disconnected, or its route otherwise
@@ -1109,7 +1109,7 @@ func opencode(home, cfg string) *Agent {
// distro's variables, aren't read; OpenChamber, a Windows app, isn't there.
func opencodeIn(at place) *Agent {
return openCodeLike(at, "opencode", "OpenCode", "opencode", "opencode",
filepath.Join(at.home, ".config", "opencode"), filepath.Join(at.home, ".local", "share", "opencode", "auth.json"),
at.join(".config", "opencode"), at.join(".local", "share", "opencode", "auth.json"),
[]string{"opencode"}, "oc")
}
@@ -1117,7 +1117,7 @@ func opencodeIn(at place) *Agent {
// MIMOCODE_HOME isn't read there.
func mimocodeIn(at place) *Agent {
return openCodeLike(at, "mimocode", "MiMo Code", "mimocode", "mimo",
filepath.Join(at.home, ".config", "mimocode"), filepath.Join(at.home, ".local", "share", "mimocode", "auth.json"),
at.join(".config", "mimocode"), at.join(".local", "share", "mimocode", "auth.json"),
[]string{"mimocode"}, "mimo")
}
@@ -1194,7 +1194,7 @@ func piDir(at place) string {
return d
}
}
return filepath.Join(at.home, ".pi", "agent")
return at.join(".pi", "agent")
}
// homeDir is the folder an agent's variable names, "~" and "~/…" expanded
@@ -1435,7 +1435,7 @@ func goose(home, cfg string) *Agent { return gooseIn(here(home), cfg) }
// layout and its custom provider names the gateway as the distro reaches
// it, with the key it takes from there.
func gooseIn(at place, cfg string) *Agent {
path := filepath.Join(cfg, "goose", "config.yaml")
path := filepath.Join(at.open(filepath.Join(cfg, "goose")), "config.yaml")
if runtime.GOOS == "windows" && at.spell == nil {
if app := appdir.Getenv("APPDATA"); app != "" {
path = filepath.Join(app, "Block", "goose", "config", "config.yaml")
@@ -1671,8 +1671,8 @@ func crush(home, cfg string) *Agent {
// place for it.
func crushIn(at place) *Agent {
// Crush's data file is in Linux's place there too
return crushAt(at, filepath.Join(at.home, ".config", "crush", "crush.json"),
filepath.Join(at.home, ".local", "share", "crush", "crush.json"))
return crushAt(at, at.join(".config", "crush", "crush.json"),
at.join(".local", "share", "crush", "crush.json"))
}
// crushAt is Crush with its config at path and its data file at data,
+4 -4
View File
@@ -128,10 +128,10 @@ func agyFunction(kind, prog string) string {
// distro's ZDOTDIR and XDG_CONFIG_HOME aren't read.
func agyDistroProfiles(at place) []update.ShellProfile {
login := distroLoginShell(at)
fish := filepath.Join(at.home, ".config", "fish", "config.fish")
fish := at.join(".config", "fish", "config.fish")
return []update.ShellProfile{
{Kind: "posix", Path: filepath.Join(at.home, ".bashrc"), Create: login == "bash"},
{Kind: "posix", Path: filepath.Join(at.home, ".zshrc"), Create: login == "zsh"},
{Kind: "posix", Path: at.join(".bashrc"), Create: login == "bash"},
{Kind: "posix", Path: at.join(".zshrc"), Create: login == "zsh"},
{Kind: "fish", Path: fish, Create: login == "fish" || at.isDir(filepath.Dir(fish))},
}
}
@@ -208,7 +208,7 @@ func agy(home string) *Agent { return agyIn(here(home)) }
// shells get a function of their own (agyDistroFunction).
func agyIn(at place) *Agent {
home := at.home
dir := filepath.Join(home, ".gemini", "antigravity-cli")
dir := at.open(filepath.Join(home, ".gemini", "antigravity-cli"))
path := filepath.Join(dir, "settings.json")
get := jsonGet(path, "model")
provider := jsonGet(path, "modelProvider")
+1 -1
View File
@@ -81,7 +81,7 @@ func anteDir(at place) string {
if d := strings.TrimSpace(at.getenv("ANTE_HOME")); d != "" {
return d
}
return filepath.Join(at.home, ".ante")
return at.join(".ante")
}
func ante(home string) *Agent { return anteAt(here(home)) }
+1 -2
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"path/filepath"
"time"
"github.com/yetone/magpie/internal/proc"
@@ -14,7 +13,7 @@ func aside(home string) *Agent { return asideIn(here(home)) }
func asideIn(at place) *Agent {
c := newAsideConnection(at)
a := &Agent{ID: "aside", Name: "Aside", Icon: "aside", Bin: "aside", Path: c.path, Spelled: prefixed, Dir: filepath.Join(at.home, ".aside"), Sync: c.sync}
a := &Agent{ID: "aside", Name: "Aside", Icon: "aside", Bin: "aside", Path: c.path, Spelled: prefixed, Dir: at.join(".aside"), Sync: c.sync}
a.Native = &NativeConnection{Read: c.state, Connect: c.connect, Apply: c.apply, Stage: c.stage, Disconnect: c.plan, Execute: c.execute, ExecuteOffline: c.executeOffline}
a.Check = func() string {
status, detail := c.provider()
+2 -2
View File
@@ -63,7 +63,7 @@ func asideID(raw json.RawMessage) (int, bool) {
// ok is false when the file can't be read or parsed, or names no active
// account: unknown, not empty.
func asideAccounts(at place) (current int, list []asideAccountInfo, ok bool) {
b, err := os.ReadFile(filepath.Join(at.home, ".aside", "accounts.json"))
b, err := os.ReadFile(at.join(".aside", "accounts.json"))
if err != nil {
return 0, nil, false
}
@@ -90,7 +90,7 @@ func asideAccounts(at place) (current int, list []asideAccountInfo, ok bool) {
}
func asideAccountDir(at place, id int) string {
return filepath.Join(at.home, ".aside", "u", strconv.Itoa(id))
return at.join(".aside", "u", strconv.Itoa(id))
}
func asideAccountName(id int) string { return "u" + strconv.Itoa(id) }
+2 -2
View File
@@ -92,7 +92,7 @@ func astrbotRoot(at place) string {
if d := strings.TrimSpace(at.getenv("ASTRBOT_ROOT")); d != "" {
return d
}
desktop := filepath.Join(at.home, ".astrbot")
desktop := at.join(".astrbot")
if isFile(filepath.Join(desktop, "data", "cmd_config.json")) {
return desktop
}
@@ -100,7 +100,7 @@ func astrbotRoot(at place) string {
return at.home
}
for _, d := range []string{"astrbot", "AstrBot"} {
root := filepath.Join(at.home, d)
root := at.join(d)
if isFile(filepath.Join(root, "data", "cmd_config.json")) || isFile(filepath.Join(root, ".astrbot")) {
return root
}
+1 -1
View File
@@ -55,7 +55,7 @@ func atomcode(home string) *Agent { return atomcodeIn(here(home)) }
// (see wsl.go), where ATOMCODE_HOME isn't read and its account names the
// gateway as the distro reaches it, with the key it takes from there.
func atomcodeIn(at place) *Agent {
dir := filepath.Join(at.home, ".atomcode")
dir := at.join(".atomcode")
if h := at.getenv("ATOMCODE_HOME"); filepath.IsAbs(h) {
dir = filepath.Clean(h)
}
+2 -2
View File
@@ -136,8 +136,8 @@ func claudeCloud(at place, path string) string {
}
dir := filepath.Dir(path)
global := filepath.Join(dir, ".claude.json")
if dir == filepath.Join(at.home, ".claude") {
global = filepath.Join(at.home, ".claude.json")
if dir == at.join(".claude") {
global = at.join(".claude.json")
}
for _, k := range agentenv.ClaudeProviders {
set := false
+1 -1
View File
@@ -61,7 +61,7 @@ func cline(home string) *Agent { return clineIn(here(home)) }
func clineIn(at place) *Agent {
dir := at.getenv("CLINE_DIR")
if dir == "" {
dir = filepath.Join(at.home, ".cline")
dir = at.join(".cline")
}
data := at.getenv("CLINE_DATA_DIR")
if data == "" {
+1 -1
View File
@@ -45,7 +45,7 @@ func codebuddy(home string) *Agent { return codebuddyIn(here(home)) }
func codebuddyIn(at place) *Agent {
dir := at.getenv("CODEBUDDY_CONFIG_DIR")
if dir == "" {
dir = filepath.Join(at.home, ".codebuddy")
dir = at.join(".codebuddy")
}
path := filepath.Join(dir, "models.json")
write := func(on bool) error { return buddyWriteAt(path, "codebuddy", on, at) }
+1 -1
View File
@@ -28,7 +28,7 @@ func commandCode(home string) *Agent { return commandCodeIn(here(home)) }
// reaches it.
func commandCodeIn(at place) *Agent {
ccProviderJSON := func() any { return ccProviderJSONAt(at.v1()) }
dir := filepath.Join(at.home, ".commandcode")
dir := at.join(".commandcode")
path := filepath.Join(dir, "settings.json")
providers := filepath.Join(dir, "providers.json")
get := func(k string) string { v, _ := edit.GetJSON(path, k); return v }
+1 -1
View File
@@ -283,7 +283,7 @@ func droidIn(at place) *Agent {
home = h
}
droidEntries := func() []droidEntry { return droidEntriesAt(at.gw()) }
dir := filepath.Join(home, ".factory")
dir := at.open(filepath.Join(home, ".factory"))
path := filepath.Join(dir, "settings.json")
legacy := filepath.Join(dir, "config.json")
key := "droid:" + path + ":" + droidModel
+1 -1
View File
@@ -91,7 +91,7 @@ func dshAt(at place) *Agent {
gw := at.gw
dir := at.getenv("DSH_HOME")
if dir == "" {
dir = filepath.Join(at.home, ".dsh")
dir = at.join(".dsh")
}
// DeepSeek Harness Desktop, on this machine (a distro has none)
desktop := func() bool { return at.spell == nil && (&Agent{ID: "dsh"}).HasApp() }
+1 -1
View File
@@ -39,7 +39,7 @@ func empryoIn(at place) *Agent { return empryoAt(at) }
// does.
func empryoAt(at place) *Agent {
gatewayV1 := at.v1
dir := filepath.Join(at.home, ".empryo")
dir := at.join(".empryo")
path := filepath.Join(dir, "config.json")
keyModel := "empryo:" + path + ":" + empryoModel
// keyNew marks a file magpie made, which goes again once magpie's
+1 -1
View File
@@ -30,7 +30,7 @@ func fx(home string) *Agent { return fxIn(here(home)) }
// fxIn is fx at a place: this machine's home, or a WSL distro's (see
// wsl.go), its provider naming the gateway as the distro reaches it.
func fxIn(at place) *Agent {
dir := filepath.Join(at.home, ".fx")
dir := at.join(".fx")
path := filepath.Join(dir, "settings.json")
// magpie's provider, with what the user set on it in fx kept
fxProvider := func(cur string) any { return fxKept(path, fxProviderAt(cur, at.v1())) }
+1 -1
View File
@@ -26,7 +26,7 @@ func gemini(home string) *Agent { return geminiIn(here(home)) }
// distro's (see wsl.go), whose .env names the gateway as the distro
// reaches it, with the key it takes from there.
func geminiIn(at place) *Agent {
dir := filepath.Join(at.home, ".gemini")
dir := at.join(".gemini")
path := filepath.Join(dir, "settings.json")
envPath := filepath.Join(dir, ".env")
auth := jsonGet(path, "security.auth.selectedType")
+1 -1
View File
@@ -168,7 +168,7 @@ func grok(home string) *Agent { return grokIn(here(home)) }
func grokIn(at place) *Agent {
dir := at.getenv("GROK_HOME")
if dir == "" {
dir = filepath.Join(at.home, ".grok")
dir = at.join(".grok")
}
path := filepath.Join(dir, "config.toml")
get := func(k string) (string, error) {
+1 -1
View File
@@ -50,7 +50,7 @@ func jcodeDir(at place) string {
if d := strings.TrimSpace(at.getenv("JCODE_HOME")); d != "" {
return d
}
return filepath.Join(at.home, ".jcode")
return at.join(".jcode")
}
// jcodeModel is one [[providers.<name>.models]] entry, as jcode's
+2 -2
View File
@@ -45,14 +45,14 @@ func kimiDir(at place) (dir string, legacy bool) {
if d := at.getenv("KIMI_CODE_HOME"); d != "" {
return d, false
}
code := filepath.Join(at.home, ".kimi-code")
code := at.join(".kimi-code")
if at.isDir(code) {
return code, false
}
if d := at.getenv("KIMI_SHARE_DIR"); d != "" {
return d, true
}
if d := filepath.Join(at.home, ".kimi"); at.isDir(d) {
if d := at.join(".kimi"); at.isDir(d) {
return d, true
}
return code, false
+1 -1
View File
@@ -84,7 +84,7 @@ func miniMax(home string) *Agent { return miniMaxAt(here(home), MiniMaxDir(home)
// miniMaxIn is MiniMax Code's mcode in a WSL distro (see wsl.go): ~/.minimax,
// as MINIMAX_DATA_DIR there isn't read.
func miniMaxIn(at place) *Agent { return miniMaxAt(at, filepath.Join(at.home, ".minimax")) }
func miniMaxIn(at place) *Agent { return miniMaxAt(at, at.join(".minimax")) }
// miniMaxAt is MiniMax Code with its data folder at dir, reaching the
// gateway as at does.
+1 -1
View File
@@ -36,7 +36,7 @@ func morph(home string) *Agent { return morphIn(here(home)) }
// morphIn is Mister Morph at a place: this machine's home, or a WSL distro's
// (see wsl.go), where MISTER_MORPH_CONFIG isn't read.
func morphIn(at place) *Agent {
dir := filepath.Join(at.home, ".morph")
dir := at.join(".morph")
path := at.getenv("MISTER_MORPH_CONFIG")
if path == "" {
path = filepath.Join(dir, "config.yaml")
+2 -2
View File
@@ -156,9 +156,9 @@ func mothxDir(at place) string {
if app := appdir.Getenv("APPDATA"); app != "" {
return filepath.Join(app, "mothx")
}
return filepath.Join(at.home, "AppData", "Roaming", "mothx")
return at.join("AppData", "Roaming", "mothx")
}
return filepath.Join(at.home, ".mothx")
return at.join(".mothx")
}
// mothxBlockKept is theirsKept for magpie's provider in MothX's
+2 -2
View File
@@ -34,13 +34,13 @@ func muse(cfg string) *Agent { return museAt(here(""), cfg) }
// museIn is Muse Code in a WSL distro (see wsl.go): ~/.config/muse, as
// XDG_CONFIG_HOME there isn't read.
func museIn(at place) *Agent { return museAt(at, filepath.Join(at.home, ".config")) }
func museIn(at place) *Agent { return museAt(at, at.join(".config")) }
// museAt is Muse Code with its config under cfg, reaching the gateway as
// at does.
func museAt(at place, cfg string) *Agent {
gatewayV1 := at.v1
dir := filepath.Join(cfg, "muse")
dir := at.open(filepath.Join(cfg, "muse"))
path := filepath.Join(dir, "settings.json")
keyTransport := "muse:" + path + ":" + museTransport
keyModel := "muse:" + path + ":" + museModel
+1 -1
View File
@@ -36,5 +36,5 @@ func omoDir(at place) string {
}
}
}
return filepath.Join(at.home, ".omo", "agent")
return at.join(".omo", "agent")
}
+1 -1
View File
@@ -193,7 +193,7 @@ func ompProfiles(home string) []*Agent {
// known), and without one its models offer xhigh rather than a max an older
// omp would refuse.
func ompIn(at place) *Agent {
return ompAt(at, filepath.Join(at.home, ".omp", "agent"), func() ompProviderEntry { return ompProviderAt(at.gw(), at.version) })
return ompAt(at, at.join(".omp", "agent"), func() ompProviderEntry { return ompProviderAt(at.gw(), at.version) })
}
// ompAt is omp with its agent folder at dir, magpie's entry in its
+1 -1
View File
@@ -103,7 +103,7 @@ func penguinRoot(at place) string {
if d := at.getenv("PENGUIN_HOME"); d != "" {
return d
}
return filepath.Join(at.home, ".penguin", "data")
return at.join(".penguin", "data")
}
// penguinProject is the Project the CLI works in: $PENGUIN_PROJECT_ID,
+1 -3
View File
@@ -19,8 +19,6 @@ package agent
// subagentDefaultModel.
import (
"path/filepath"
"github.com/yetone/magpie/internal/appdir"
)
@@ -42,5 +40,5 @@ func primeAgentDir(at place) string {
return d
}
}
return filepath.Join(at.home, ".prime", "agent")
return at.join(".prime", "agent")
}
+1 -1
View File
@@ -71,7 +71,7 @@ func qoderSite(home string, b qoderBuild) *Agent { return qoderAt(here(home), b)
func qoderAt(at place, b qoderBuild) *Agent {
dir := at.getenv(b.env)
if dir == "" {
dir = filepath.Join(at.home, b.dir)
dir = at.join(b.dir)
}
path := filepath.Join(dir, "settings.json")
key := b.id + ":" + path + ":"
+1 -1
View File
@@ -153,7 +153,7 @@ func qwen(home string) *Agent { return qwenIn(here(home)) }
// (see wsl.go), whose entries name the gateway as the distro reaches it,
// with the key it takes from there.
func qwenIn(at place) *Agent {
dir := filepath.Join(at.home, ".qwen")
dir := at.join(".qwen")
if d := at.getenv("QWEN_HOME"); d != "" {
dir = d
}
+1 -1
View File
@@ -88,7 +88,7 @@ func reasonixIn(at place) *Agent {
if at.spell != nil {
goos, getenv = "linux", func(string) string { return "" }
}
dir := reasonixHome(goos, at.home, getenv)
dir := at.open(reasonixHome(goos, at.home, getenv))
gwKey := func() string { return agentKeyAt("reasonix", at.gw()) }
if absolute, err := filepath.Abs(dir); err == nil {
dir = absolute
+1 -1
View File
@@ -59,7 +59,7 @@ func snow(home string) *Agent { return snowIn(here(home)) }
// wsl.go), whose profile names the gateway as the distro reaches it, with
// the key it takes from there.
func snowIn(at place) *Agent {
dir := filepath.Join(at.home, ".snow")
dir := at.join(".snow")
if d := strings.TrimSpace(at.getenv("SNOW_CONFIG_DIR")); filepath.IsAbs(d) {
dir = filepath.Clean(d)
}
+1 -1
View File
@@ -36,7 +36,7 @@ func stepcodeDir(at place) string {
name = custom
}
}
return filepath.Join(at.home, name)
return at.join(name)
}
func stepcodeProvider(at place) any {
+243 -20
View File
@@ -58,10 +58,39 @@ type place struct {
// version is the agent's CLI's there, as the probe found it; "" when
// not known (one on this machine is asked itself)
version string
// reach is a path under home as magpie can open it (distro.open): one
// below a link the distro has is opened where the link leads; nil: as
// is. unreached keeps the first path it couldn't tell the way to.
reach func(string) (string, error)
unreached *error
}
func here(home string) place { return place{home: home} }
// open is path, a path under the place's home, where magpie can open it:
// in a WSL distro, a folder that is a link there (~/.codex ->
// /mnt/c/Users/me/.codex, #4502) is opened where it leads, as nothing
// below it can be opened through \\wsl.localhost. A link the distro
// couldn't resolve leaves path as it is, and the place unreached.
func (p place) open(path string) string {
if p.reach == nil {
return path
}
o, err := p.reach(path)
if err != nil {
if p.unreached != nil && *p.unreached == nil {
*p.unreached = err
}
return path
}
return o
}
// join is filepath.Join(home, elem...), opened where magpie can (open).
func (p place) join(elem ...string) string {
return p.open(filepath.Join(append([]string{p.home}, elem...)...))
}
// getenv is this machine's variable for this machine's agent; "" for one
// in a distro, whose variables magpie can't read.
func (p place) getenv(k string) string {
@@ -76,7 +105,7 @@ func (p place) getenv(k string) string {
// read.
func (p place) codexHome() string {
if p.spell != nil {
return filepath.Join(p.home, ".codex")
return p.join(".codex")
}
return appdir.CodexHomeIn(p.home)
}
@@ -86,7 +115,7 @@ func (p place) codexHome() string {
// magpie can't read.
func (p place) claudeDir() string {
if p.spell != nil {
return filepath.Join(p.home, ".claude")
return p.join(".claude")
}
return appdir.ClaudeDirIn(p.home)
}
@@ -97,7 +126,7 @@ func (p place) claudeDir() string {
// variables magpie can't read.
func (p place) hermesHome() string {
if p.spell != nil {
return filepath.Join(p.home, ".hermes")
return p.join(".hermes")
}
return appdir.HermesHomeIn(p.home)
}
@@ -106,7 +135,7 @@ func (p place) hermesHome() string {
// HERMES_HOME says: the root of its profiles.
func (p place) hermesDefault() string {
if p.spell != nil {
return filepath.Join(p.home, ".hermes")
return p.join(".hermes")
}
return appdir.HermesDefaultIn(p.home)
}
@@ -188,6 +217,13 @@ type distro struct {
// ~/.omp/profiles there: each is an agent of its own (omp#<name>).
// Kept so a stopped distro lists them without being started.
OmpProfiles []string `json:"ompProfiles,omitempty"`
// Links are the agents' folders (and files) under $HOME that lead
// elsewhere, by their path under it (".codex"): where readlink -f
// there says they lead, "" where it couldn't say (#4502)
Links map[string]string `json:"links,omitempty"`
// Drives are where Windows' drives are mounted in it, by mount point:
// "/mnt/c" is "C:"
Drives map[string]string `json:"drives,omitempty"`
// Mirrored is whether the distro's 127.0.0.1 is Windows' (mirror): in
// mirrored networking, or in consomme
Mirrored bool `json:"-"`
@@ -214,8 +250,22 @@ func (d distro) local(linux string) string {
return d.Root + strings.ReplaceAll(linux, "/", string(filepath.Separator))
}
// native is a path magpie opens as the distro spells it.
// native is a path magpie opens as the distro spells it: one open moved
// to where a link leads is spelt through the link, as the agent knows it.
func (d distro) native(local string) string {
best, spelt := "", ""
for rel, to := range d.Links {
if to == "" {
continue
}
at := d.where(to)
if r, ok := below(local, at); ok && len(at) > len(best) {
best, spelt = at, strings.TrimRight(d.Home, "/")+"/"+rel+strings.ReplaceAll(r, string(filepath.Separator), "/")
}
}
if best != "" {
return spelt
}
rel := local
if len(local) >= len(d.Root) && strings.EqualFold(local[:len(d.Root)], d.Root) {
rel = local[len(d.Root):]
@@ -227,6 +277,78 @@ func (d distro) native(local string) string {
return rel
}
// open is local, a path in the distro as magpie opens it, where magpie can
// open it. Through \\wsl.localhost Windows can't follow a link the
// distro has: a path below ~/.codex, when that leads to
// /mnt/c/Users/me/.codex, can be neither made, written, read nor listed,
// and a mkdir of ~/.codex itself says it exists (linusxiong's #4502). So a
// path at or below one of Links is opened where the link leads: on one of
// Windows' drives, there itself (C:\Users\me\.codex); elsewhere in the
// distro, through \\wsl.localhost again. A link the distro couldn't
// resolve is an error: where it leads isn't guessed.
func (d distro) open(local string) (string, error) {
h := d.local(d.Home)
best, rest := "", ""
for rel := range d.Links {
at := filepath.Join(h, filepath.FromSlash(rel))
r, ok := below(local, at)
if ok && len(rel) > len(best) {
best, rest = rel, r
}
}
if best == "" {
return local, nil
}
to := d.Links[best]
if to == "" {
return "", fmt.Errorf("~/%s in WSL %s is a link magpie couldn't follow (readlink -f there failed), so nothing is written through it; check where it points from a shell there", best, d.Name)
}
return d.where(to) + rest, nil
}
// where is linux, a path in the distro, as magpie opens it: on one of
// Windows' drives, the drive's own path; anywhere else, through the
// distro's root.
func (d distro) where(linux string) string {
drives := d.Drives
if len(drives) == 0 {
// a probe before Drives: WSL's default mounts, /mnt/<letter>
if rest, ok := strings.CutPrefix(linux, "/mnt/"); ok && len(rest) >= 1 && (len(rest) == 1 || rest[1] == '/') && isLetter(rest[0]) {
drives = map[string]string{"/mnt/" + rest[:1]: strings.ToUpper(rest[:1]) + ":"}
}
}
best := ""
for m := range drives {
if (linux == m || strings.HasPrefix(linux, m+"/")) && len(m) > len(best) {
best = m
}
}
if best == "" {
return d.local(linux)
}
return wslDrive(drives[best]) + strings.ReplaceAll(strings.TrimPrefix(linux[len(best):], "/"), "/", string(filepath.Separator))
}
// wslDrive is the root of a Windows drive ("C:") as magpie opens it; a var
// for tests.
var wslDrive = func(drive string) string { return drive + `\` }
func isLetter(c byte) bool { return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' }
// below is what path has below dir (with its leading separator, "" for
// dir itself), and whether it is dir or under it; Windows' paths compared
// without case.
func below(path, dir string) (string, bool) {
if len(path) < len(dir) || !strings.EqualFold(path[:len(dir)], dir) {
return "", false
}
rest := path[len(dir):]
if rest != "" && rest[0] != filepath.Separator {
return "", false
}
return rest, true
}
// mirror settles Mirrored from what wslinfo said at the probe, or, when it
// couldn't, from cfg (.wslconfig) saying mirrored: a WSL without wslinfo
// predates consomme, so .wslconfig's consomme isn't taken for one. Under
@@ -264,7 +386,8 @@ func (d distro) place(id string) place {
if k, _, ok := strings.Cut(kind, "#"); ok {
kind = k
}
return place{home: d.local(d.Home), id: id, spell: d.native, sys: d.local, base: d.base, cold: !d.Running, version: d.Versions[kind]}
return place{home: d.local(d.Home), id: id, spell: d.native, sys: d.local, base: d.base, cold: !d.Running, version: d.Versions[kind],
reach: d.open, unreached: new(error)}
}
// wslKind is an agent magpie looks for in a distro: what the probe finds
@@ -601,7 +724,7 @@ var wslKinds = []wslKind{
}},
// Block's goose, by its folder alone: a goose command may be pressly's
// database migration tool
{id: "goose", name: "Goose", dir: ".config/goose", in: func(at place) *Agent { return gooseIn(at, filepath.Join(at.home, ".config")) },
{id: "goose", name: "Goose", dir: ".config/goose", in: func(at place) *Agent { return gooseIn(at, at.join(".config")) },
restart: newNotice("{agent} in WSL {distro} loads its providers at start-up — restart open goose sessions to use magpie's models."),
asleep: wslOwnAsleep("goose", "model")},
// Reasonix's native CLI (1.39 on), by its command and the version it
@@ -771,6 +894,12 @@ func wslAgent(k wslKind, d distro) *Agent {
if !d.Running {
return asleep(a, k, d)
}
if k.dir != "" {
at.join(filepath.FromSlash(k.dir))
}
if err := *at.unreached; err != nil {
return unreached(a, err)
}
if reached := a.Reached; reached != nil {
a.Reached = func(since time.Time) (time.Time, string, bool) {
if !d.live() {
@@ -846,6 +975,48 @@ func wslAgent(k wslKind, d distro) *Agent {
return a
}
// unreached is an agent in a distro whose folder is a link the distro
// couldn't resolve (distro.open): nothing of it is written, and each
// change, and its notice, says why.
func unreached(a *Agent, err error) *Agent {
a.unreached = err
a.Notice = func() string { return err.Error() }
for i := range a.Fields {
if a.Fields[i].Set != nil {
a.Fields[i].Set = func(string) error { return err }
}
}
if a.Sync != nil {
a.Sync = func() error { return err }
}
return a
}
// Unreached is why magpie can't open the folder of a, an agent in a WSL
// distro: a link there the distro couldn't resolve; nil for any other.
func (a *Agent) Unreached() error { return a.unreached }
// WSLOpen is path, under the home of a, an agent in a WSL distro, where
// magpie can open it (distro.open): below a link of the distro's, where
// the link leads. The error says a link there couldn't be resolved. Any
// other agent's path is as it is.
func WSLOpen(a *Agent, path string) (string, error) {
if a == nil || a.WSL == "" {
return path, nil
}
wsl.Lock()
d := wsl.seen[a.WSL]
var c distro
if d != nil {
c = *d
}
wsl.Unlock()
if d == nil || c.Root == "" {
return path, nil
}
return c.open(path)
}
// asleep is a stopped distro's agent: its fields read what magpie last
// saw, their options come from magpie alone, and it has no files to check,
// sync or migrate (Path and Dir are empty); setting a field goes to the
@@ -929,7 +1100,7 @@ func wslAgentsOf(ds []distro) []*Agent {
k := wslKindOf("omp")
k.id, k.name = "omp#"+name, "omp · "+name
k.in = func(at place) *Agent {
return ompAt(at, filepath.Join(at.home, ".omp", "profiles", name, "agent"),
return ompAt(at, at.join(".omp", "profiles", name, "agent"),
func() ompProviderEntry { return ompProviderAt(at.gw(), at.version) })
}
out = append(out, wslAgent(k, d))
@@ -951,25 +1122,31 @@ func wslHomes() []sessions.WSLHome {
if d.Root == "" || d.Home == "" {
continue
}
out = append(out, sessions.WSLHome{Distro: d.Name, Home: d.local(d.Home), Running: d.Running})
open := func(path string) string {
if to, err := d.open(path); err == nil {
return to
}
return path
}
out = append(out, sessions.WSLHome{Distro: d.Name, Home: d.local(d.Home), Running: d.Running, Open: open})
}
return out
}
// wslCopilotDir is the Copilot CLI's folder under a distro's $HOME: not an
// agent magpie sets up, but a sign-in it uses (provider.CopilotWSLHomes),
// agent magpie sets up, but a sign-in it uses (provider.CopilotWSLDirs),
// so a distro that has only it is kept as one agents are found in (#723).
const wslCopilotDir = ".copilot"
// copilotWSLHomes are the homes, as magpie opens them, of the running
// distros the Copilot CLI's folder was found in, for provider to read its
// sign-in in; none off Windows. A stopped distro is left out: reading it
// would start it.
func copilotWSLHomes() []string {
// copilotWSLDirs are the Copilot CLI's folders, as magpie opens them (where
// a link leads, #4502), in the running distros it was found in, for
// provider to read its sign-in in; none off Windows. A stopped distro is
// left out: reading it would start it.
func copilotWSLDirs() []string {
var out []string
for _, h := range wslHomes() {
if h.Running && wslHasCopilot(h.Distro) {
out = append(out, h.Home)
out = append(out, h.Open(filepath.Join(h.Home, wslCopilotDir)))
}
}
return out
@@ -1450,8 +1627,15 @@ var wslProbeScript = func() string {
}
}
s += `[ -d "$HOME/` + wslCopilotDir + `" ] && echo dir:` + wslCopilotDir + `; `
// a drive's source in /proc/mounts is C:\ (written C:\134), under any automount root
s += `awk '$1 ~ /^[A-Za-z]:/ {print "win:" $2}' /proc/mounts 2>/dev/null; `
// where each agent folder that leads elsewhere leads (distro.open):
// "link:.codex /mnt/c/Users/me/.codex", or "link:.codex" alone where
// readlink -f couldn't say
// (a $HOME that is itself through a link is left as it is)
s += `h=$(readlink -f -- "$HOME" 2>/dev/null); for r in ` + strings.Join(wslLinkPaths(), " ") + `; do p="$HOME/$r"; { [ -e "$p" ] || [ -L "$p" ]; } || continue; ` +
`if t=$(readlink -f -- "$p" 2>/dev/null) && [ -n "$t" ]; then [ "$t" = "$p" ] || [ "$t" = "$h/$r" ] || echo "link:$r $t"; else echo "link:$r"; fi; done; `
// a drive's source in /proc/mounts is C:\ (written C:\134), under any
// automount root: its mount point, and the drive
s += `awk '$1 ~ /^[A-Za-z]:/ {print "win:" $2 " " toupper(substr($1,1,1)) ":"}' /proc/mounts 2>/dev/null; `
// named omp profiles: the probe runs only in a distro that is running,
// so this never starts a stopped one to find them
s += `for d in "$HOME"/.omp/profiles/*; do [ -d "$d" ] && echo "profile:omp:$(basename "$d")"; done; `
@@ -1460,6 +1644,20 @@ var wslProbeScript = func() string {
`command -v wslinfo >/dev/null 2>&1 && echo "net:$(wslinfo --networking-mode 2>/dev/null)"; true`
}()
// wslLinkPaths are the paths under a distro's $HOME the probe asks where
// they lead (distro.Links): each agent's folder and its skills, and the
// folders and files the agents keep beside theirs.
func wslLinkPaths() []string {
out := []string{".config", ".local", ".local/share", ".agents", ".agents/skills", ".gemini", ".gemini/config", ".gemini/skills", ".kimi", ".reasonix", ".claude.json", ".slock", ".kimi-code/sessions", wslCopilotDir}
for _, k := range wslKinds {
if k.dir != "" {
out = append(out, k.dir, k.dir+"/skills")
}
}
slices.Sort(out)
return slices.Compact(out)
}
func wslProbe(name string) *distro {
b, err := wslRun(30*time.Second, "-d", name, "-e", "sh", "-lc", wslProbeScript)
if err != nil {
@@ -1504,9 +1702,34 @@ func parseProbe(name, out string) *distro {
bin, path, _ := strings.Cut(v, " ")
bins[bin] = strings.TrimSpace(path)
case "win":
if v = strings.TrimRight(v, "/"); strings.HasPrefix(v, "/") {
win = append(win, v+"/")
// win:/mnt/c C: (a probe before it said only /mnt/c)
f := strings.Fields(v)
if len(f) == 0 {
continue
}
if m := strings.TrimRight(f[0], "/"); strings.HasPrefix(m, "/") {
win = append(win, m+"/")
if len(f) > 1 && len(f[1]) == 2 && f[1][1] == ':' && isLetter(f[1][0]) {
if d.Drives == nil {
d.Drives = map[string]string{}
}
d.Drives[m] = strings.ToUpper(f[1])
}
}
case "link":
// link:.codex /mnt/c/Users/me/.codex; link:.codex alone where
// it couldn't be resolved
rel, to, _ := strings.Cut(v, " ")
if !slices.Contains(wslLinkPaths(), rel) {
continue
}
if to = strings.TrimSpace(to); !strings.HasPrefix(to, "/") {
to = ""
}
if d.Links == nil {
d.Links = map[string]string{}
}
d.Links[rel] = strings.TrimRight(to, "/")
case "route":
// default via 172.20.0.1 dev eth0 …
if f := strings.Fields(v); len(f) >= 3 && f[1] == "via" && net.ParseIP(f[2]) != nil {
+3 -3
View File
@@ -22,15 +22,15 @@ func TestWSLCopilotHome(t *testing.T) {
map[string]string{"Ubuntu": "home:/home/jia\ndir:.copilot\n", "Debian": "home:/home/me\n"},
map[string]string{"Ubuntu": root, "Debian": t.TempDir()}))
want := filepath.Join(root, "home", "jia")
if got := provider.CopilotWSLHomes(); !slices.Equal(got, []string{want}) {
want := filepath.Join(root, "home", "jia", ".copilot")
if got := provider.CopilotWSLDirs(); !slices.Equal(got, []string{want}) {
t.Fatalf("homes %q, want %q", got, want)
}
if len(wslAgents()) != 0 {
t.Fatalf("the Copilot CLI's folder made an agent row: %v", wslAgents())
}
StopFakeWSL("Ubuntu")
if got := provider.CopilotWSLHomes(); len(got) != 0 {
if got := provider.CopilotWSLDirs(); len(got) != 0 {
t.Fatalf("a stopped distro is read: %q", got)
}
}
+15
View File
@@ -2,6 +2,7 @@ package agent
import (
"errors"
"path/filepath"
"strings"
"sync"
"time"
@@ -101,3 +102,17 @@ func FakeWSLRuns(name string) int {
defer fakeCalls.Unlock()
return fakeCalls.in[name]
}
// FakeWSLDrives, for other packages' tests, has Windows' drives ("C:")
// opened at roots' folder for each, where a link in a FakeWSL distro to
// /mnt/c leads (distro.open); the returned func puts it back.
func FakeWSLDrives(roots map[string]string) func() {
was := wslDrive
wslDrive = func(drive string) string {
if r, ok := roots[drive]; ok {
return r + string(filepath.Separator)
}
return was(drive)
}
return func() { wslDrive = was }
}
+201
View File
@@ -0,0 +1,201 @@
package agent
import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
"github.com/yetone/magpie/internal/sessions"
)
// The probe asks the distro where each agent folder that is a link leads
// (#4502), with readlink -f there, and where Windows' drives are mounted:
// a folder that isn't a link isn't listed.
func TestWSLProbeLinks(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("the probe is a shell script")
}
home := filepath.Join(t.TempDir(), "home", "me")
to := filepath.Join(t.TempDir(), "Users", "me", ".codex")
for _, d := range []string{to, filepath.Join(home, ".claude")} {
if err := os.MkdirAll(d, 0o755); err != nil {
t.Fatal(err)
}
}
if err := os.Symlink(to, filepath.Join(home, ".codex")); err != nil {
t.Fatal(err)
}
cmd := exec.Command("/bin/sh", "-c", wslProbeScript)
cmd.Env = []string{"HOME=" + home, "PATH=/usr/bin:/bin"}
out, _ := cmd.Output()
d := parseProbe("U", string(out))
real, _ := filepath.EvalSymlinks(to)
if d == nil || d.Links[".codex"] != real {
t.Fatalf("the probe said:\n%s\nread as %+v", out, d)
}
if _, ok := d.Links[".claude"]; ok {
t.Fatalf("a folder that isn't a link is listed: %v", d.Links)
}
}
// What the probe says of links and drives, and where magpie opens a path
// below each: a link to Windows' C: on C: itself, one elsewhere in the
// distro through its root, and one it couldn't resolve not at all. The
// agent is told the path through the link, as it knows it.
func TestWSLOpenThroughLinks(t *testing.T) {
d := parseProbe("U", "home:/home/me\ndir:.codex\n"+
"link:.codex /mnt/c/Users/me/.codex\nlink:.claude /data/claude/\nlink:.pi\nlink:.bashrc /etc/bashrc\n"+
"win:/mnt/c C:\nwin:/mnt/wsl/d d:\nwin:/mnt/e\n")
if d == nil {
t.Fatal("no distro")
}
if _, ok := d.Links[".bashrc"]; ok {
t.Errorf("a path the probe doesn't ask is taken: %v", d.Links)
}
if d.Links[".claude"] != "/data/claude" || d.Links[".pi"] != "" || d.Drives["/mnt/c"] != "C:" || d.Drives["/mnt/wsl/d"] != "D:" || len(d.Drives) != 2 {
t.Fatalf("links %q, drives %q", d.Links, d.Drives)
}
sep := string(filepath.Separator)
d.Root = filepath.Join(t.TempDir(), "U")
t.Cleanup(FakeWSLDrives(map[string]string{"C:": filepath.Join(t.TempDir(), "C")}))
c := wslDrive("C:")
h := d.local(d.Home)
for _, tc := range []struct{ in, want, err string }{
{filepath.Join(h, ".codex"), c + filepath.Join("Users", "me", ".codex"), ""},
{filepath.Join(h, ".codex", "skills", "pdf"), c + filepath.Join("Users", "me", ".codex", "skills", "pdf"), ""},
{filepath.Join(h, ".claude", "settings.json"), d.local("/data/claude/settings.json"), ""},
{filepath.Join(h, ".codexx", "a"), filepath.Join(h, ".codexx", "a"), ""},
{filepath.Join(h, ".omo", "agent"), filepath.Join(h, ".omo", "agent"), ""},
{filepath.Join(h, ".pi", "agent", "x"), "", "~/.pi in WSL U is a link magpie couldn't follow"},
} {
got, err := d.open(tc.in)
if tc.err != "" {
if err == nil || !strings.Contains(err.Error(), tc.err) {
t.Errorf("open %s: %q %v", tc.in, got, err)
}
continue
}
if err != nil || got != tc.want {
t.Errorf("open %s: %q %v, want %q", tc.in, got, err, tc.want)
}
if n := d.native(got); n != d.native(tc.in) && !strings.HasPrefix(tc.in, filepath.Join(h, ".codexx")) {
t.Errorf("native %s: %q, want %q", got, n, d.native(tc.in))
}
}
if n := d.native(c + "Users" + sep + "me" + sep + ".codex" + sep + "AGENTS.md"); n != "/home/me/.codex/AGENTS.md" {
t.Errorf("the agent is told %q", n)
}
// a probe before Drives: WSL's own /mnt/<letter>
d.Drives = nil
if got, _ := d.open(filepath.Join(h, ".codex", "x")); got != c+filepath.Join("Users", "me", ".codex", "x") {
t.Errorf("no drives probed: %q", got)
}
}
// linkedDistro is a running distro whose ~/.codex and ~/.claude are links
// to /mnt/c/Users/me/… that, as through \\wsl.localhost, can't be followed
// here: nothing below them can be made or read. C: has the real folders,
// with Claude Code's session.
func linkedDistro(t *testing.T, links string) (home, c string) {
t.Helper()
syncHome(t)
root, drive := t.TempDir(), t.TempDir()
home = filepath.Join(root, "home", "me")
c = filepath.Join(drive, "Users", "me")
if err := os.MkdirAll(home, 0o755); err != nil {
t.Fatal(err)
}
for _, d := range []string{".codex", ".claude"} {
if err := os.MkdirAll(filepath.Join(c, d), 0o755); err != nil {
t.Fatal(err)
}
if err := os.Symlink("/mnt/c/Users/me/"+d, filepath.Join(home, d)); err != nil {
t.Skip("no symlinks here:", err)
}
}
t.Cleanup(FakeWSL(map[string]string{"Ubuntu": "home:/home/me\ndir:.codex\ndir:.claude\n" + links + "win:/mnt/c C:\n"},
map[string]string{"Ubuntu": root}))
t.Cleanup(FakeWSLDrives(map[string]string{"C:": drive}))
return home, c
}
func wslAgentByID(t *testing.T, id string) *Agent {
t.Helper()
for _, a := range wslAgents() {
if a.ID == id {
return a
}
}
t.Fatalf("no %s in %v", id, wslAgents())
return nil
}
// Codex in a distro whose ~/.codex leads to C: (#4502) is set up there:
// its config is read and written on C:, and its sessions are listed from
// it; Claude Code's sessions too.
func TestWSLAgentFolderIsALink(t *testing.T) {
_, c := linkedDistro(t, "link:.codex /mnt/c/Users/me/.codex\nlink:.claude /mnt/c/Users/me/.claude\n")
a := wslAgentByID(t, "codex@wsl:Ubuntu")
if a.Unreached() != nil || a.Path != filepath.Join(c, ".codex", "config.toml") {
t.Fatalf("Codex: path %q, unreached %v", a.Path, a.Unreached())
}
if err := a.Fields[0].Set("fake/m1"); err != nil {
t.Fatal(err)
}
cfg, err := os.ReadFile(filepath.Join(c, ".codex", "config.toml"))
if err != nil || !strings.Contains(string(cfg), `model = "fake/m1"`) {
t.Fatalf("Codex's config on C: (%v):\n%s", err, cfg)
}
id := "44444444-2222-3333-4444-555555555555"
project := filepath.Join(c, ".claude", "projects", "-home-me-app")
if err := os.MkdirAll(project, 0o755); err != nil {
t.Fatal(err)
}
line := `{"type":"user","message":{"role":"user","content":"Tidy the README"},"uuid":"u1","timestamp":"2026-09-20T10:00:01.000Z","cwd":"/home/me/app","sessionId":"` + id + `"}` + "\n"
if err := os.WriteFile(filepath.Join(project, id+".jsonl"), []byte(line), 0o644); err != nil {
t.Fatal(err)
}
sessions.Reset()
t.Cleanup(sessions.Reset)
found := false
for _, s := range sessions.List(0) {
found = found || s.ID == id && s.WSL == "Ubuntu"
}
if !found {
t.Fatal("the session on C: behind ~/.claude isn't listed")
}
}
// A link the distro couldn't resolve: the agent behind it says why, and
// no change of it is written anywhere.
func TestWSLAgentFolderLinkUnresolved(t *testing.T) {
_, c := linkedDistro(t, "link:.codex\nlink:.claude /mnt/c/Users/me/.claude\n")
a := wslAgentByID(t, "codex@wsl:Ubuntu")
const why = "~/.codex in WSL Ubuntu is a link magpie couldn't follow"
if err := a.Unreached(); err == nil || !strings.Contains(err.Error(), why) || a.Notice == nil || !strings.Contains(a.Notice(), why) {
t.Fatalf("Codex behind a link not resolved: %v", err)
}
if a.Sync == nil {
t.Fatal("no Sync")
}
if err := a.Sync(); err == nil || !strings.Contains(err.Error(), why) {
t.Fatalf("Sync: %v", err)
}
for _, f := range a.Fields {
if f.Set != nil {
if err := f.Set("x"); err == nil || !strings.Contains(err.Error(), why) {
t.Fatalf("%s set: %v", f.Key, err)
}
}
}
if es, _ := os.ReadDir(filepath.Join(c, ".codex")); len(es) != 0 {
t.Fatalf("written where the link was guessed to lead: %v", es)
}
if b := wslAgentByID(t, "claude@wsl:Ubuntu"); b.Unreached() != nil {
t.Fatalf("Claude Code beside it: %v", b.Unreached())
}
}
+3
View File
@@ -229,6 +229,9 @@ func hash(s string) string {
// the user edited in the file is left alone until the library's text for
// that agent changes; then it is replaced, the file kept aside first.
func (l *Library) syncInstructions(t *Target, b *backups, res *Result) {
if res.unreached(t) {
return
}
if t.Instructions == "" {
return
}
+3
View File
@@ -233,6 +233,9 @@ func toolRule(how toolsOffHow, server, tool string) string {
// tools turned off of the servers the agent has (given): Claude Code's
// permissions.deny, OpenCode's tools map.
func (l *Library) syncToolRules(t *Target, how toolsOffHow, given []string, b *backups, res *Result) {
if res.unreached(t) {
return
}
id := t.Agent.ID
a := l.applied(id)
var want []string
+23 -15
View File
@@ -132,21 +132,21 @@ var rtkSpecs = map[string]rtkSpec{
// over the user's
flags: []string{"--gemini", "--hook-only"}, patch: true,
has: func(a *agent.Agent) bool {
return contains(filepath.Join(rtkHome(a), ".gemini", "settings.json"), "rtk-hook-gemini")
return contains(rtkAt(a, ".gemini", "settings.json"), "rtk-hook-gemini")
},
files: func(a *agent.Agent) []string {
d := filepath.Join(rtkHome(a), ".gemini")
d := rtkAt(a, ".gemini")
return []string{filepath.Join(d, "settings.json"), filepath.Join(d, "hooks", "rtk-hook-gemini.sh"), filepath.Join(d, "hooks", ".rtk-hook.sha256")}
},
remove: func(a *agent.Agent) error {
d := filepath.Join(rtkHome(a), ".gemini")
d := rtkAt(a, ".gemini")
err := errors.Join(
dropHook(filepath.Join(d, "settings.json"), "hooks.BeforeTool", "rtk-hook-gemini"),
rm(filepath.Join(d, "hooks", "rtk-hook-gemini.sh"), filepath.Join(d, "hooks", ".rtk-hook.sha256")))
os.Remove(filepath.Join(d, "hooks")) // when nothing else is in it
return err
},
dir: func(a *agent.Agent) string { return filepath.Join(rtkHome(a), ".gemini") },
dir: func(a *agent.Agent) string { return rtkAt(a, ".gemini") },
},
"opencode": {
flags: []string{"--opencode"}, patch: true, withClaude: true, blocked: openCodeBlocked,
@@ -158,30 +158,30 @@ var rtkSpecs = map[string]rtkSpec{
"cursor": {
flags: []string{"--agent", "cursor"}, patch: true, withClaude: true,
has: func(a *agent.Agent) bool {
return contains(filepath.Join(rtkHome(a), ".cursor", "hooks.json"), "rtk hook cursor")
return contains(rtkAt(a, ".cursor", "hooks.json"), "rtk hook cursor")
},
files: func(a *agent.Agent) []string { return []string{filepath.Join(rtkHome(a), ".cursor", "hooks.json")} },
files: func(a *agent.Agent) []string { return []string{rtkAt(a, ".cursor", "hooks.json")} },
remove: func(a *agent.Agent) error {
return dropHook(filepath.Join(rtkHome(a), ".cursor", "hooks.json"), "hooks.preToolUse", "rtk hook cursor")
return dropHook(rtkAt(a, ".cursor", "hooks.json"), "hooks.preToolUse", "rtk hook cursor")
},
dir: func(a *agent.Agent) string { return filepath.Join(rtkHome(a), ".cursor") },
dir: func(a *agent.Agent) string { return rtkAt(a, ".cursor") },
},
"copilot": {
flags: []string{"--copilot"}, patch: true,
has: func(a *agent.Agent) bool {
return exists(filepath.Join(rtkHome(a), ".copilot", "hooks", "rtk-rewrite.json"))
return exists(rtkAt(a, ".copilot", "hooks", "rtk-rewrite.json"))
},
files: func(a *agent.Agent) []string {
d := filepath.Join(rtkHome(a), ".copilot")
d := rtkAt(a, ".copilot")
return []string{filepath.Join(d, "hooks", "rtk-rewrite.json"), filepath.Join(d, "copilot-instructions.md")}
},
remove: func(a *agent.Agent) error {
d := filepath.Join(rtkHome(a), ".copilot")
d := rtkAt(a, ".copilot")
return errors.Join(
rm(filepath.Join(d, "hooks", "rtk-rewrite.json")),
dropBlock(filepath.Join(d, "copilot-instructions.md"), "<!-- rtk-instructions", "<!-- /rtk-instructions -->"))
},
dir: func(a *agent.Agent) string { return filepath.Join(rtkHome(a), ".copilot") },
dir: func(a *agent.Agent) string { return rtkAt(a, ".copilot") },
},
// Antigravity CLI (agy): rtk 0.51 on writes a plugin of its own into
// Antigravity's global customization folder, ~/.gemini/config, shared
@@ -391,7 +391,7 @@ func codexBlocked(a *agent.Agent) string {
// agyPlugin is the folder rtk's installer writes its Antigravity plugin to.
func agyPlugin(a *agent.Agent) string {
return filepath.Join(rtkHome(a), ".gemini", "config", "plugins", "rtk")
return rtkAt(a, ".gemini", "config", "plugins", "rtk")
}
// agyBlocked: rtk installs for Antigravity globally from 0.51.0 on; 0.50
@@ -469,13 +469,13 @@ func hermesPlugin(a *agent.Agent) string { return filepath.Join(a.Dir, "plugins"
// extensionSpec is pi's and omp's: an extension of rtk's own, and nothing else.
func extensionSpec(id string) rtkSpec {
ext := func(a *agent.Agent) string { return filepath.Join(rtkHome(a), "."+id, "agent", "extensions", "rtk.ts") }
ext := func(a *agent.Agent) string { return rtkAt(a, "."+id, "agent", "extensions", "rtk.ts") }
return rtkSpec{
flags: []string{"--agent", id}, patch: true,
has: func(a *agent.Agent) bool { return exists(ext(a)) },
files: func(a *agent.Agent) []string { return []string{ext(a)} },
remove: func(a *agent.Agent) error { return rm(ext(a)) },
dir: func(a *agent.Agent) string { return filepath.Join(rtkHome(a), "."+id, "agent") },
dir: func(a *agent.Agent) string { return rtkAt(a, "."+id, "agent") },
}
}
@@ -1063,6 +1063,14 @@ func SetRTK(id string, on bool) (*RTKView, error) {
func rtkInstall(bin string, a *agent.Agent) error {
sp := rtkSpecs[rtkKind(a.ID)]
// a folder in a WSL distro that is a link it couldn't resolve isn't
// written through (#4502)
if err := a.Unreached(); err != nil {
return err
}
if _, err := agent.WSLOpen(a, sp.dir(a)); err != nil {
return err
}
if err := os.MkdirAll(sp.dir(a), 0o755); err != nil {
return err
}
+17 -2
View File
@@ -53,11 +53,26 @@ func rtkHome(a *agent.Agent) string {
return home()
}
// rtkAt is a path under rtkHome(a): in a distro, opened where a link
// there leads (agent.WSLOpen, #4502), as nothing below one can be opened
// through \\wsl.localhost; as it is when the link couldn't be resolved,
// which rtkInstall says.
func rtkAt(a *agent.Agent, elem ...string) string {
p := filepath.Join(append([]string{rtkHome(a)}, elem...)...)
if a == nil || a.WSL == "" {
return p
}
if o, err := agent.WSLOpen(a, p); err == nil {
return o
}
return p
}
// rtkClaudeDir is Claude Code's folder for a: ~/.claude in a distro, whose
// CLAUDE_CONFIG_DIR magpie can't read (as wslTargetOf).
func rtkClaudeDir(a *agent.Agent) string {
if a != nil && a.WSL != "" {
return filepath.Join(a.Home, ".claude")
return rtkAt(a, ".claude")
}
return claudeDir()
}
@@ -65,7 +80,7 @@ func rtkClaudeDir(a *agent.Agent) string {
// rtkCodexDir is Codex's folder for a: ~/.codex in a distro.
func rtkCodexDir(a *agent.Agent) string {
if a != nil && a.WSL != "" {
return filepath.Join(a.Home, ".codex")
return rtkAt(a, ".codex")
}
return codexDir()
}
+1 -1
View File
@@ -44,7 +44,7 @@ func (l *Library) takeEdits(targets []*Target, res *Result) {
var edits []edit
seen := map[string]bool{}
for _, t := range targets {
if t.Skills == "" || t.Desktop != nil || !s.gives(t.Agent.ID) {
if t.Skills == "" || t.Desktop != nil || t.Unreached != nil || !s.gives(t.Agent.ID) {
continue
}
p := filepath.Join(t.Skills, s.Name)
+3
View File
@@ -539,6 +539,9 @@ func within(p, dir string) bool {
}
func (l *Library) syncSkills(t *Target, res *Result, all []*Target) {
if res.unreached(t) {
return
}
if t.Skills == "" {
return
}
+3
View File
@@ -191,6 +191,9 @@ func Sync() (*Result, error) {
}
func (l *Library) syncMCP(t *Target, b *backups, res *Result) {
if res.unreached(t) {
return
}
if t.MCP == nil {
return
}
+67 -7
View File
@@ -56,6 +56,25 @@ type Target struct {
// after the user's, but never moves the user's own lines out of it
// (ImportInstructions), as the agent reads who its owner is there.
Profile bool
// Unreached, for an agent in a WSL distro, is why its folder there
// can't be opened (agent.WSLOpen): a link the distro couldn't
// resolve. Nothing is written to it; each sync says so.
Unreached error
}
// unreached says whether t's folder can't be opened, and, once in res,
// why.
func (r *Result) unreached(t *Target) bool {
if t.Unreached == nil {
return false
}
for _, p := range r.Problems {
if p.Agent == t.Agent.ID && p.What == "wsl" {
return true
}
}
r.fail(t.Agent.ID, "wsl", t.Unreached)
return true
}
func home() string { h, _ := os.UserHomeDir(); return h }
@@ -598,16 +617,18 @@ func wslTargetOf(a *agent.Agent) *Target {
return nil
}
t := &Target{Agent: a, Copy: true}
// a folder there that is a link is opened where it leads (#4502)
j := func(elem ...string) string { return wslOpen(t, filepath.Join(elem...)) }
id, _, _ := strings.Cut(a.ID, "@")
switch id {
case "claude":
d := filepath.Join(h, ".claude")
d := j(h, ".claude")
t.Instructions = filepath.Join(d, "CLAUDE.md")
t.MCP = &mcpFile{Path: filepath.Join(h, ".claude.json"), Format: fmtClaude}
t.MCP = &mcpFile{Path: j(h, ".claude.json"), Format: fmtClaude}
t.Skills = filepath.Join(d, "skills")
t.Settings = filepath.Join(d, "settings.json")
case "codex":
d := filepath.Join(h, ".codex")
d := j(h, ".codex")
t.Instructions = filepath.Join(d, "AGENTS.md")
t.Override = filepath.Join(d, "AGENTS.override.md")
t.MCP = &mcpFile{Path: filepath.Join(d, "config.toml"), Format: fmtCodex}
@@ -618,25 +639,25 @@ func wslTargetOf(a *agent.Agent) *Target {
// at the probe, and its extensions are those its settings.json and
// the distro's npm folders have (leokon on Discord: only the
// Windows Pi was offered MCP servers)
d := filepath.Join(h, ".pi", "agent")
d := j(h, ".pi", "agent")
t.Instructions = firstThere(d, "AGENTS.md", "AGENTS.MD", "CLAUDE.md", "CLAUDE.MD")
t.Override = filepath.Join(d, "AGENTS.override.md")
t.MCP, t.MCPVia = piMCP(h, d, piVersion(a), wslPiRoots(h))
t.Skills = filepath.Join(d, "skills")
case "omo":
d := filepath.Join(h, ".omo", "agent")
d := j(h, ".omo", "agent")
t.Instructions = firstThere(d, "AGENTS.md", "AGENTS.MD", "CLAUDE.md", "CLAUDE.MD")
t.Override = filepath.Join(d, "AGENTS.override.md")
t.MCP = &mcpFile{Path: filepath.Join(d, "mcp.json"), Format: fmtPiNative}
t.Skills = filepath.Join(d, "skills")
case "gemini":
// as targetOf's, under the distro's home
d := filepath.Join(h, ".gemini")
d := j(h, ".gemini")
t.Instructions = filepath.Join(d, "GEMINI.md")
t.MCP = &mcpFile{Path: filepath.Join(d, "settings.json"), Format: fmtGemini}
t.Skills = filepath.Join(d, "skills")
case "agy":
d := filepath.Join(h, ".gemini", "config")
d := j(h, ".gemini", "config")
t.Instructions = filepath.Join(d, "GEMINI.md")
t.MCP = &mcpFile{Path: filepath.Join(d, "mcp_config.json"), Format: fmtAntigravity}
t.Skills = filepath.Join(d, "skills")
@@ -674,6 +695,7 @@ func wslTargetOf(a *agent.Agent) *Target {
default:
return wslOwnFolder(a)
}
wslOpened(t)
if t.MCP != nil {
// a Windows program isn't given to it (mcpFile.side)
t.MCP.WSL, t.MCP.Distro, t.MCP.Home = true, a.WSL, linuxHome(h)
@@ -681,6 +703,43 @@ func wslTargetOf(a *agent.Agent) *Target {
return t
}
// wslOpen is path, one of t's in a WSL distro, where magpie can open it
// (agent.WSLOpen): below a link the distro has, where the link leads,
// since nothing below one can be opened through \\wsl.localhost. A link
// that couldn't be resolved leaves path as it is and t unreached.
func wslOpen(t *Target, path string) string {
if path == "" {
return ""
}
if err := t.Agent.Unreached(); err != nil && t.Unreached == nil {
t.Unreached = err
}
o, err := agent.WSLOpen(t.Agent, path)
if err != nil {
if t.Unreached == nil {
t.Unreached = err
}
return path
}
return o
}
// wslOpened opens each of t's paths where magpie can (wslOpen): a link
// below the agent's folder, its skills folder one, as well as the folder.
func wslOpened(t *Target) {
for _, p := range []*string{&t.Instructions, &t.Override, &t.Skills, &t.Settings} {
*p = wslOpen(t, *p)
}
if t.MCP != nil {
t.MCP.Path = wslOpen(t, t.MCP.Path)
for _, ps := range [][]string{t.MCP.Also, t.MCP.Extra} {
for i := range ps {
ps[i] = wslOpen(t, ps[i])
}
}
}
}
// ownFolder are the agents that keep all the library gives them in their
// own folder (a.Dir, or beside a.Path), read from no variable of this
// machine's and from nothing under its home: one magpie found in a distro
@@ -706,6 +765,7 @@ func wslOwnFolder(a *agent.Agent) *Target {
return nil
}
t.Agent, t.Copy = a, true
wslOpened(t)
if t.MCP != nil {
t.MCP.WSL, t.MCP.Distro, t.MCP.Home = true, a.WSL, linuxHome(a.Home)
}
+142
View File
@@ -0,0 +1,142 @@
package library
import (
"os"
"path/filepath"
"runtime"
"strings"
"testing"
"github.com/yetone/magpie/internal/agent"
)
// wslLinked is sandbox with a running WSL distro, Ubuntu-24.04, whose
// ~/.codex and ~/.claude are links to /mnt/c/Users/me/… (#4502), as
// \\wsl.localhost shows them to Windows: a link nothing can be followed
// through. In the fake distro's root each is a link to /mnt/c/…, which
// isn't there, so — as through \\wsl.localhost — nothing below it can be
// made, written or read, and a mkdir of it says it exists. Windows' C: is
// a folder of its own, with the agents' real folders. probe is what the
// distro answers of the links; it gives back the home as magpie opens it
// and C:\Users\me.
func wslLinked(t *testing.T, links string) (home, c string) {
t.Helper()
sandbox(t)
root, drive := t.TempDir(), t.TempDir()
home = filepath.Join(root, "home", "me")
c = filepath.Join(drive, "Users", "me")
write(t, filepath.Join(c, ".codex", "config.toml"), "model = \"gpt-5.5\"\n")
write(t, filepath.Join(c, ".claude", "settings.json"), "{}\n")
if err := os.MkdirAll(home, 0o755); err != nil {
t.Fatal(err)
}
for _, d := range []string{".codex", ".claude"} {
if err := os.Symlink("/mnt/c/Users/me/"+d, filepath.Join(home, d)); err != nil {
t.Skip("no symlinks here:", err)
}
}
t.Cleanup(agent.FakeWSL(map[string]string{
"Ubuntu-24.04": "home:/home/me\ndir:.codex\ndir:.claude\n" + links + "win:/mnt/c C:\nwin:/mnt/d D:\n",
}, map[string]string{"Ubuntu-24.04": root}))
t.Cleanup(agent.FakeWSLDrives(map[string]string{"C:": drive}))
return home, c
}
// A skill added to Codex and Claude Code in a distro whose ~/.codex and
// ~/.claude lead to Windows' C: lands where they lead (#4502:
// linusxiong's mkdir \\wsl.localhost\…\.codex "Cannot create a file when
// that file already exists"), and so do their instructions; what the
// agents are told is the distro's own path, through the link.
func TestWSLFolderIsALinkToC(t *testing.T) {
h, c := wslLinked(t, "link:.codex /mnt/c/Users/me/.codex\nlink:.claude /mnt/c/Users/me/.claude/\n")
src := filepath.Join(home(), "src", "skills")
skill(t, filepath.Join(src, "pdf"), "pdf", "Read PDFs")
ok(t)(InstallSkills(src, []string{"pdf"}, []string{wslCodex, wslClaude}))
for _, d := range []string{".codex", ".claude"} {
if _, err := os.Stat(filepath.Join(c, d, "skills", "pdf", "SKILL.md")); err != nil {
t.Errorf("the skill isn't in C:'s %s, where the distro's link leads: %v", d, err)
}
}
if tg := targetByID(wslCodex); tg == nil || tg.Instructions != filepath.Join(c, ".codex", "AGENTS.md") || tg.Skills != filepath.Join(c, ".codex", "skills") {
t.Fatalf("Codex's target: %+v", tg)
}
if fi, err := os.Lstat(filepath.Join(h, ".codex")); err != nil || fi.Mode()&os.ModeSymlink == 0 {
t.Fatalf("the distro's link was replaced: %v %v", fi, err)
}
}
// A link the distro couldn't resolve is written through by nothing: each
// agent behind one says why, once, and the others are written as ever.
func TestWSLFolderLinkUnresolved(t *testing.T) {
_, c := wslLinked(t, "link:.codex\nlink:.claude /mnt/c/Users/me/.claude\n")
src := filepath.Join(home(), "src", "skills")
skill(t, filepath.Join(src, "pdf"), "pdf", "Read PDFs")
r, err := InstallSkills(src, []string{"pdf"}, []string{wslCodex, wslClaude})
if err != nil {
t.Fatal(err)
}
var got []Problem
for _, p := range r.Problems {
if p.Agent == wslCodex {
got = append(got, p)
}
}
if len(got) != 1 || got[0].What != "wsl" || !strings.Contains(got[0].Error, "~/.codex in WSL Ubuntu-24.04 is a link magpie couldn't follow") {
t.Fatalf("Codex behind a link not resolved: %+v", r.Problems)
}
if _, err := os.Stat(filepath.Join(c, ".claude", "skills", "pdf", "SKILL.md")); err != nil {
t.Errorf("Claude Code's skill, beside it: %v", err)
}
if _, err := os.Stat(filepath.Join(c, ".codex", "skills")); err == nil {
t.Error("written to where the link was guessed to lead")
}
}
// RTK for Claude Code in a distro whose ~/.claude leads to C: (#4502's
// second report): switched on, its folder is made where the link leads,
// and the hook rtk writes there (in the distro, where the link is
// followed) is read back from C:. A link not resolved fails with why.
func TestRTKWSLFolderIsALink(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("the fake distro runs sh")
}
_, c := wslLinked(t, "link:.claude /mnt/c/Users/me/.claude\n")
// in the distro the link is followed: rtk runs in a home whose
// ~/.claude is C:'s
inside := filepath.Join(t.TempDir(), "home", "me")
if err := os.MkdirAll(inside, 0o755); err != nil {
t.Fatal(err)
}
if err := os.Symlink(filepath.Join(c, ".claude"), filepath.Join(inside, ".claude")); err != nil {
t.Fatal(err)
}
fakeDistroRTK(t, inside)
if _, err := InstallRTKIn("Ubuntu-24.04"); err != nil {
t.Fatal(err)
}
if _, err := SetRTK(wslClaude, true); err != nil {
t.Fatalf("RTK for Claude Code behind a link: %v", err)
}
b, _ := os.ReadFile(filepath.Join(c, ".claude", "settings.json"))
if !strings.Contains(string(b), "rtk hook claude") {
t.Fatalf("no hook in C:'s .claude/settings.json: %s", b)
}
if a := rtkRow(t, ReadRTK(), wslClaude); !a.On {
t.Fatalf("switched on, yet the row is off: %+v", a)
}
}
func TestRTKWSLFolderLinkUnresolved(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("the fake distro runs sh")
}
wslLinked(t, "link:.claude\n")
fakeDistroRTK(t, t.TempDir())
if _, err := InstallRTKIn("Ubuntu-24.04"); err != nil {
t.Fatal(err)
}
_, err := SetRTK(wslClaude, true)
if err == nil || !strings.Contains(err.Error(), "~/.claude in WSL Ubuntu-24.04 is a link magpie couldn't follow") {
t.Fatalf("RTK behind a link not resolved: %v", err)
}
}
+10 -8
View File
@@ -54,11 +54,13 @@ func copilotCLIHome() string {
return filepath.Join(home, ".copilot")
}
// CopilotWSLHomes, set by internal/agent, are the homes, as magpie opens
// them, of the WSL distros that run now: magpie on Windows finds a Copilot
// CLI signed in inside one (#723, jia2). nil, or none, off Windows. A
// stopped distro isn't in it: reading its files would start it.
var CopilotWSLHomes func() []string
// CopilotWSLDirs, set by internal/agent, are the Copilot CLI's folders
// (~/.copilot), as magpie opens them, in the WSL distros that run now:
// magpie on Windows finds a Copilot CLI signed in inside one (#723,
// jia2). Where ~/.copilot is a link the folder is where it leads (#4502).
// nil, or none, off Windows. A stopped distro isn't in it: reading its
// files would start it.
var CopilotWSLDirs func() []string
// copilotWSLAge is how long a WSL distro's Copilot CLI sign-in is kept as
// read: its files are read over WSL's file share, slower than a disk's.
@@ -83,7 +85,7 @@ func copilotCLILogin() (copilotApp, bool) {
if app, ok := copilotCLILoginIn(copilotCLIHome(), copilotCLISecret); ok {
return app, true
}
if CopilotWSLHomes == nil {
if CopilotWSLDirs == nil {
return copilotApp{}, false
}
c := &copilotWSL
@@ -93,8 +95,8 @@ func copilotCLILogin() (copilotApp, bool) {
return c.app, c.ok
}
c.app, c.ok = copilotApp{}, false
for _, home := range CopilotWSLHomes() {
if app, ok := copilotCLILoginIn(filepath.Join(home, ".copilot"), nil); ok {
for _, dir := range CopilotWSLDirs() {
if app, ok := copilotCLILoginIn(dir, nil); ok {
c.app, c.ok = app, true
break
}
+4 -4
View File
@@ -133,12 +133,12 @@ func TestCopilotCLIInWSL(t *testing.T) {
"loggedInUsers": [{"host": "https://github.com", "login": "jia2"}],
"copilotTokens": {"https://github.com:jia2": "gho_wsl"}
}`), 0o600)
oldHomes := CopilotWSLHomes
homes := []string{filepath.Join(t.TempDir(), "other"), distro}
CopilotWSLHomes = func() []string { return homes }
oldDirs := CopilotWSLDirs
homes := []string{filepath.Join(t.TempDir(), "other", ".copilot"), filepath.Join(distro, ".copilot")}
CopilotWSLDirs = func() []string { return homes }
copilotWSL.at = time.Time{}
defer func() {
copilotCLISecret, CopilotWSLHomes = oldSecret, oldHomes
copilotCLISecret, CopilotWSLDirs = oldSecret, oldDirs
copilotWSL.at = time.Time{}
}()
+11 -3
View File
@@ -36,6 +36,11 @@ type WSLHome struct {
Distro string
Home string
Running bool
// Open maps a path under Home to where it can be read from Windows:
// a folder that is a link in the distro (~/.codex → /mnt/c/…) can't
// be followed through \\wsl.localhost (#4502), so what is below it is
// read where the link leads. nil reads every path as it is.
Open func(string) string
}
// WSLHomes are the WSL distros to read sessions in; nil (none) unless
@@ -74,10 +79,13 @@ var wslAgents = []struct{ agent, dir string }{
}
// wslScan lists the session files under a distro's home.
func wslScan(home string) []file {
func wslScan(h WSLHome) []file {
var out []file
for _, a := range wslAgents {
dir := filepath.Join(home, a.dir)
dir := filepath.Join(h.Home, a.dir)
if h.Open != nil {
dir = h.Open(dir)
}
switch a.agent {
case "claude":
out = append(out, ccFiles("claude", dir)...)
@@ -228,7 +236,7 @@ func wslList(gen uint64, done chan struct{}) {
continue
}
l := &wslListing{Home: h.Home, Running: true, Files: []wslEntry{}}
for _, f := range wslScan(h.Home) {
for _, f := range wslScan(h) {
l.Files = append(l.Files, wslEntry{Agent: f.agent, Key: f.key, Path: f.path, Main: f.main, Size: f.size, Mod: f.mod})
}
lists[h.Distro] = l