diff --git a/docs/subsystems/library.md b/docs/subsystems/library.md index 35b28a83c..6021aaa25 100644 --- a/docs/subsystems/library.md +++ b/docs/subsystems/library.md @@ -17,7 +17,7 @@ agents RTK, a CLI that cuts shell output down before the model reads it. | 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. 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:`). While it is stopped, `Read` lists its agents from that (`asleepView`, `asleep: `), 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) | +| 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 (`sweepShared`, then `syncShared` for the Put skills in setting), 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) | | Instructions | magpie's part of an agent's instructions file sits between two marker lines. The rest of the file is the user's. Several named sets can be switched between (#106). A set can be kept in a file of the user's own instead of `instruction-sets/` (`InstrSet.File`, 新v学员 on Discord): `~/.agents/AGENTS.md`, which Droid and omp read too. `textPath` reads it, `putText` keeps it aside and writes it but never removes it, removing the set lets go of it, and `linkable` refuses a file magpie writes into (an agent's own instructions, a file with the marker line), the library's own and another set's. The app's `KeepLinked` looks at the file every 30 s and writes a change into the agents (`SyncLinked`). A set's text is read without magpie's part (`setText`), and an agent whose instructions file is, links followed, the file the set on is kept in (`isSetFile`: `instructions.md` linked to `~/.claude/CLAUDE.md`, or both linked to one dotfile) gets no part written into it, and one written before is taken out with every part nested in it: read with its part, each sync wrote the whole file into that part again and it doubled, to gigabytes (#2349, `TestInstructionsSetLinkedToAgentsFile`). `Collect` carries the set's text, not where its file is; `Put` keeps this computer's file for the set and never empties it for a text not carried. Alma's file is `~/.config/alma/USER.md`, which its main chat reads into its system prompt as its owner's profile (0.4.164's `out/main/index.js`; a workspace's `USER.md` is read instead), and whose leading front matter (`name`, `telegram_id`, `discord_id`) is who its bots answer to (#2315, Jie211). The target is a `Profile`: magpie's part goes after the user's, so the front matter stays first, and `ImportInstructions` refuses it, as moving it out would take that front matter out of the file and into every agent's (`TestAlmaInstructionsKeepTheProfile`, `TestAlmaProfileIsNotImported`, `library-alma-profile.test.cjs`). | [`instructions.go`](../../internal/library/instructions.go) | | MCP servers | A `Server` is a command or a URL (`http`, `sse`). `mcpFile` encodes it in each agent's own format (one `mcpFormat` per agent family) and merges it with the user's own fields for that entry. A server's `StartupTimeout` (#3168) goes to Codex alone, as `startup_timeout_sec` in seconds (`RawMcpServerConfig` in codex-rs/config's mcp_types.rs; 0 leaves Codex's own 30s), in the user-wide config.toml and a project's alike. magpie keeps the value it wrote (`Applied.Startup`, `Project.Startup`): one in the entry other than that, or a `startup_timeout_ms`, is the user's and stays as it is (`startupTheirs`), and once it is taken out magpie's goes in again. The editor shows the field only when an agent that takes it is here (`AgentView.Startup`, `mcp_startup_test.go`, `mcp-startup-timeout.test.cjs`). `Also` files get the same servers; `Extra` files are only read when importing. `CheckServers` connects as an agent would and keeps the result in memory only: with each tool's name and the first paragraph of its description (`ToolList`, at most `maxToolList`, a description cut at `maxToolDesc` runes), which the page lists when the server's "N tools" is clicked, following tools/list's `nextCursor` up to `maxToolPages` pages (`listTools`). Each step (initialize, notifications/initialized, tools/list; connect for SSE) has its own budget, 60s for a URL and 30s for a command (`remoteStep`, `stdioStep`), and a timeout names its `Step` and how long it `Waited`; a timeout isn't kept, so the next look asks again (#1467). A command named bare that magpie's PATH lacks is started from where `proc.FindTool` finds it (fnm's Nodes on Windows among the folders), with that folder on the check's PATH, since npx's package runs the node beside it by name (`stdioProgram`, #2685, `TestStdioProgramFindsWhatPathLacks`). The page asks once a session for the servers some agent or project has (`inUse` in plugins/library/client.js); one no agent has shows "not checked" and is checked only when its status is clicked (#1597, `library-mcp-health.test.cjs`). A server checked once is checked again when it changes, its sign-in included, so a server signed in to after a click's "needs sign-in" isn't left showing both (新v学员 on Discord, `mcp-signin-health.test.cjs`). The check sends magpie's sign-in as the gateway does: on a 401 it renews the token once and asks again, and a server that refuses even the renewed token has the sign-in marked run out (`mcpauth.Rejected`, also from the gateway's `/mcp/`), which `ServerHealth.SignIn` carries back so the row's tag says "Sign-in ran out" rather than "Signed in" beside "needs sign-in". A server that refuses the check (401 or 403) but that an agent signed in to on its own is named so (`ServerHealth.AgentSignIn`, `readOwnSignIns` in `mcp_agent_signin.go`): each Claude Code target's `.credentials.json` beside its settings.json, a WSL distro's under the distro's home, is read for a `mcpOAuth` entry of the server's name and URL with a token, and each Codex target's `.credentials.json` beside its config.toml for a flattened entry of them, the file codex-rs falls back to when its config's `mcp_oauth_credentials_store` is `file` or the keyring is missing, whose executor's own entries are no `codex mcp login` (#3508); and the row says "signed in in Claude Code (Ubuntu)" — or Codex — instead of "needs sign-in" (CyberCaius on Discord: signed in to with Claude Code's /mcp in WSL). The tokens are never sent or kept; a file that can't be read or parsed names nobody, a stopped distro isn't started for it, and on a Mac only the file is read, never the Keychain Claude Code keeps them in nor Codex's keyring store. They are part of the check's key, so a sign-in in the agent since is checked anew (`TestCheckNamesAgentsSignedInThemselves`, `library-mcp-health-wsl.test.cjs`). A server that needs OAuth is signed in once in magpie, and agents reach it through the gateway's `/mcp/` (#615). The editor's Sign in saves the form first only when the sign-in is to another server than the saved one (a new server, a name or URL changed), and its button then reads "Save and sign in"; anything else edited (headers, env, arguments) stays unsaved until Save, so Cancel leaves the server as it was (新v学员 on Discord, `mcp-editor-cancel.test.cjs`). A server whose authorization server refuses magpie's dynamic client registration with 401 or 403 admits only the clients it lists (Figma's, #1619): the sign-in fails with `mcpauth.ErrClientRefused`, which says so and that each agent signs in itself, and the agents keep the server's own address. A server whose authorization server has no registration endpoint at all (GitHub's remote server, 新v学员 on Discord) fails with `mcpauth.ErrNoRegistration`, which says to make an OAuth app with the vendor and give it in the editor; the editor then opens its "OAuth app" fields. The app is the server's `oauth` (`OAuthApp`: `clientId`, `clientSecret`, `callbackPort`, Claude Code's names for `--client-id`, `--client-secret` and `--callback-port`), checked on save (HTTP only, a client ID, a port from 1 to 65535), and `SignInServer` signs in as it through `mcpauth.StartWith` without registering. The callback is Claude Code's, `http://localhost:/callback` (its docs' "Use pre-configured OAuth credentials"; 2.1.296 builds it so), listened for on 127.0.0.1 alone as Claude Code does, so an app made for Claude Code signs magpie in as it is; a server that matches the registered URL exactly refuses another host, which is why Claude Code's 2.1.231 went back to `localhost` from 2.1.229's `127.0.0.1` (`TestAppMadeForClaudeCode`). Without a `callbackPort` the port is any free one, which a loopback callback registered without a port takes (GitHub's, RFC 8252); a fixed `callbackPort` is for a vendor that matches the port too. magpie's own registration, when a server has one, still names `127.0.0.1`. The client secret is kept in library.json, as a header's or env's value is: a backup without keys leaves it out, and `WithSecrets` puts back this computer's secret only for the same client ID; no agent is given the app, and the TUI's editor, which doesn't show it, keeps it. GitHub answers a token request's error with a 200 and `error` in the body (`bad_refresh_token`, `incorrect_client_credentials`), which `tokenRequest` reads as the error it is, and a dead refresh token marks the sign-in run out (`github_app_test.go`, `mcp-oauth-app.test.cjs`). magpie never registers under another client's name; one that reaches the gateway from another machine (a WSL distro under NAT) is given it with the LAN sharing key as its `Authorization` (`agent.KeyAt`), as its models are, which the gateway takes in place of a sign-in and never passes on; turning sharing on or off, or a new key (`access.LANChanged`), writes such entries again. `ConfigOfServers` is the servers picked as an agent's project file (`projectMCPFiles`) would hold them, written by the same code into a folder of its own and read back, with those the agent can't take there named; the page's Copy config… puts it on the clipboard for a project magpie doesn't keep (#1478). Each listed tool has a switch: the tools turned off are the server's `DisabledTools`, set by `ServerTools`, and written into each agent given the server that can leave out a single tool (see the constraint below). A server run as `npx -y args` (a registry package, no other npx flag) is given to an agent on this machine as `node args` (`npxDirect`): magpie installs the package with npm into a folder of its own under `mcp-npm` in the background, the next sync writes the node form, and until then, or when npm fails (tried again after an hour), the agent keeps npx. npx otherwise stays as the server's parent for its whole life, a node and two cmd.exe beside each instance on Windows (#3885). An unpinned spec is installed again after a day, as npx would fetch the newer one; an install no library server runs goes a day after its last. The library, a server's check, Copy config… and agents in WSL keep npx (`TestNpxServerRunsByNode`, `TestReadNpx`). | [`mcp.go`](../../internal/library/mcp.go), [`mcp_npx.go`](../../internal/library/mcp_npx.go), [`mcp_check.go`](../../internal/library/mcp_check.go), [`mcp_signin.go`](../../internal/library/mcp_signin.go), [`mcp_agent_signin.go`](../../internal/library/mcp_agent_signin.go), [`mcp_copy.go`](../../internal/library/mcp_copy.go), [`mcp_tools_off.go`](../../internal/library/mcp_tools_off.go) | @@ -72,6 +72,8 @@ agents RTK, a CLI that cuts shell output down before the model reads it. - An MCP server can be kept to this computer (`Server.Local`; the editor's "This computer only" switch, `magpie library mcp add --local`, `magpie library mcp local on|off`; huhuy72219405 on X). `Collect` never carries it (`carriedServers`), so a sync or a backup file never takes it to another computer, and turning a shared server local takes it out of what is carried: the other computers drop it at their next sync. `Put` (sync, join, Restore, Undo, a backup file) keeps every local server here, with its agents, and clears `Local` on what comes in (`putServers`). Another computer's server by the name of a local one doesn't take its place: it goes to `Library.Away`, given to no agent, not in the router, not checked, and carried on as it came, so a push from here never takes it from the computers that have it. `settleAway` runs on every change: while the name is local here the away copy stays; once no server of that name is left here (removed or renamed) it comes in as a sync would bring it; once a shared server has the name (local turned off) this computer's is the one carried. The router serves local servers like any other, since it runs on this computer. A carried subagent names its servers, a local one too; a computer without that server leaves it out of the agents' files, as any server the library hasn't. The TUI keeps the flag on edit and marks the row. (`TestLocalServerNotCarried`, `TestPutKeepsLocalServer`, `TestPutSameNameAsLocal`, `TestRestoreKeepsLocalServer`, `TestLocalServerThroughSync`, `mcp-local-server.test.cjs`) [`mcp_local.go`](../../internal/library/mcp_local.go), [`carry.go`](../../internal/library/carry.go) - A skill brought in from a link into a folder an app keeps per version (ego lite's framework `Versions/`, #2635) is linked through the app's own steady link, or through `Versions/Current` when Current is that version (`linkVia`, `currentVersion`; `TestImportedSkillFollowsAppUpdate`, `TestImportedSkillThroughVersionsCurrent`). One brought in before that links straight to `Versions/`, which the app's update deletes (tjhhhh on Discord). Every read of the page (looking at each link once, `readParts`, and starting that over when a link was mended) and the first step of every sync mend such links (`followMovedSkills`): a library skill that is a link, whose target isn't there, and whose first missing part is named like a version (`versionName`) is linked to the same place under that folder's `Current`, `current` or `latest` link, else under the highest version beside it that has a `SKILL.md` there (`movedVersion`, `versionLess`); one whose target is in `Versions/` while the bundle's `Versions/Current` is a link to another version with the same skill is linked through Current (`laterCurrent`). `Source.Dir` follows. Only the library's link is replaced (`os.Remove` of the link, then `dirLink`; put back as it was when the new link can't be made). A folder of the library's own, a link to a folder the user deleted that isn't a version (shown missing as before) and the app's old version folder are left as they are (`TestOldImportFollowsDeletedVersion`, `TestOldImportFollowsVersionsCurrent`, `TestOldImportFollowsHighestVersion`, `TestMovedSkillsLeaveTheRest`). [`skill_moved.go`](../../internal/library/skill_moved.go) - A skill kept in `~/.agents/skills` is handed over to the library on the user's click (`HandOverSkills`, `POST /api/library/skills/hand-over` with `names`; the row's Manage in magpie in its source line, Manage {n} in magpie in the skills' heading, each asking first; `magpie library skill hand-over |--all`; tnt1223 on Discord). "Kept there" is `sharedEntry`: the entry in that folder that is the library skill's own folder, by its name or, for a library link into it under another folder's name, by that folder's (`SkillView.Shared`; `SharedElsewhere` when the entry only links to a folder kept elsewhere). Every reader of `sharedHas`/`sharedEntry` follows: `Always`, `syncSkills`' `inShared`, and the shared folder's own target (Goose, Kimi Code, Cindy), which is given no second link beside such an entry (`TestSharedUnderAnotherName`). Handed over, a folder in `~/.agents/skills` moves into the library's skills folder (`moveIn`: renamed, or copied, read back the same with `sameTree` and only then set aside with the backups; a failure leaves it where it was and the library's link as it was, `TestHandOverFailureKeepsOriginal`), and an entry that only links elsewhere is taken away while the library links past it to that folder. The user's own links to it in agents' folders, which would point at nothing, go too. Every agent here that read it (`readsSharedHere`, and the agent of each such link) is ticked, so each keeps it, now from the library, till it is unticked or turned off here. A skill found there and not in the library yet is brought in first. One that can't be handed over is left as it was, in `Result.Unmoved`, and the others are handed over all the same. `HandBackSkill` (`magpie library skill hand-back `, CLI only; the sheet names it) moves the folder back and links the library to it, its ticks as they are. Not covered: another computer whose skill is still in its own `~/.agents/skills` gets the library's copy from a sync beside its own, until it is handed over there too; and the skills CLI's lock (`npx skills update`) may put the entry back (`TestHandOverSharedFolder`, `TestHandOverSharedLink`, `TestHandOverFound`, `TestHandOverWithGoose`, `TestLibrarySkillHandOver`, `skill-handover.test.cjs`). [`skill_handover.go`](../../internal/library/skill_handover.go) +- The agents that read `~/.agents/skills` themselves are `readsShared` (Codex, Gemini CLI, OpenCode, DevEco Code, Crush, dsh, Command Code, Devin, Droid, Cline, Grok Build, Grok App, fx, Alma, Kimi Code and OmO) and, from the version that started to, `Target.SharedToo`: Pi from 0.54.0 (its CHANGELOG; `userAgentsSkillsDir` in package-manager.js) and omp from 11.0.0 (`discovery/agents.ts`; 10.6.2 doesn't). OmO runs on senpi, whose oldest version on npm (0.74.0) already reads it. A Pi or omp whose version isn't known is taken as older, as before. Every reader goes through `Target.readsSharedDir`: `Always` (the row's lock), `syncSkills`' `inShared` (no second link in its own folder) and `readsSharedHere` for a handover (usrname1833 on Discord; `TestPiReadsSharedSkillsFromItsVersion`). +- Put skills in (`Library.SharedSkills`; `SetSkillsWhere`, `POST /api/library/skills/where` with `how` `agents` or `shared`; `magpie library skill where agents|shared`; the Skills tab's bar under How, `skillWhereBar` in plugins/library/client.js; usrname1833 on Discord). Off, the default and what a library.json from before reads as, each agent gets the skills ticked for it in its own folder. On, every library skill on here (`keepsShared`: not `OffHere`, its folder there) also gets magpie's link in `~/.agents/skills` (`syncShared`, run after `sweepShared`), so every agent and tool that reads that folder has it, ticked or not, and is in its `Always`. The files stay in the library, so updates, checks, edit tracking and Off here work as before, and nothing is moved when it is turned on: existing skills just get links. An entry of the user's own by a skill's name is left alone, silently, and the agents ticked for the library's skill still get it in their own folders. A sync leaves an existing link as it is. A skill given to the folder's own agent (Kimi Code, Goose, Cindy) is that agent's sync's. Turned off, `sweepShared` takes out magpie's links there and nothing else, and each agent's own links come back. It is this computer's: `Collect` never carries it (`TestSkillsWhereShared`, `TestSkillsWhereSharedWithKimi`, `skill-where.test.cjs`). Not covered: on Windows without the right to make links the entry is a marked copy; a stale one is set aside and copied again, but `takeEdits` doesn't take edits made in that copy into the library, so they go to the backups when the setting is turned off or the skill changes (#4958). [`skills_shared.go`](../../internal/library/skills_shared.go) - WorkBuddy's servers go in `$WORKBUDDY_CONFIG_DIR/mcp.json` (default `~/.workbuddy`; WorkBuddy AI, the international build, keeps its own in `~/.workbuddy-ai`, #1494), and CodeBuddy Code's go in the first of `.mcp.json`, `mcp.json` and `~/.codebuddy.json` that exists, as `resolveMcpFilePath` reads them (#1266). WorkBuddy connects a server only after the user has switched it on once in its own MCP settings. It keeps that approval in `mcp-approvals.json`, keyed by the command, args and env names or the URL's origin, so changing those asks again. magpie never writes the approval, and the servers page says so, by the build's name, when a server is given to WorkBuddy or WorkBuddy AI. - Alma's servers go in `~/.config/alma/mcp.json` on every system (its home, not its data folder), as its own MCP settings write them: `command`/`args`/`env`, or `url`/`headers` with `transport: "sse"` only for SSE (#1292). Alma reads the file as it starts and when its MCP settings refresh, so a server given to it while it runs reaches it after one of those. - Grok App's independent home (Use on a custom provider, `GROK_HOME` at `agent-home` under its data folder) gets instructions in `AGENTS.md`, MCP servers in `[mcp_servers]` of the same `config.toml` magpie's channel is in, skills in `skills/`, and hooks as `[[hooks.]]` tables in that config, and it also reads `~/.agents/skills`. Shared mode stays on Grok Build's `~/.grok` row. RTK lists Grok App, and Grok Build, with the switch off: `rtk init` has no Grok agent. diff --git a/internal/cli/library_cli.go b/internal/cli/library_cli.go index 3ccb5de66..2ed16eebc 100644 --- a/internal/cli/library_cli.go +++ b/internal/cli/library_cli.go @@ -40,6 +40,7 @@ const libraryUsage = `magpie library what the library gives (one changed here is left as it is; update it by name with --replace-edits) magpie library skill how link|copy [agent] give skills as links to the library's or as copies: every agent's way, or one agent's magpie library skill how default the agent goes the library's way again + magpie library skill where agents|shared skills go to the agents ticked, or also into ~/.agents/skills for every agent and tool that reads it magpie library skill use-library an agent's own skill by that name is in the way: set it aside, link the library's magpie library skill keep-own …or keep the agent's, and take the agent off the library's magpie library rtk which agents run their shell commands through RTK (rtk-ai.app), to save tokens @@ -209,6 +210,8 @@ func libraryCmd(args []string) error { how = "" } res, err = library.SetSkillHow(agent, how) + case len(rest) == 2 && rest[0] == "where" && (rest[1] == library.SkillsInAgents || rest[1] == library.SkillsInShared): + res, err = library.SetSkillsWhere(rest[1]) default: return fmt.Errorf("usage:\n %s", libraryUsage) } diff --git a/internal/gui/assets/plugins/library/client.js b/internal/gui/assets/plugins/library/client.js index 1b990ae0f..1c974eba5 100644 --- a/internal/gui/assets/plugins/library/client.js +++ b/internal/gui/assets/plugins/library/client.js @@ -3406,7 +3406,7 @@ magpie.plugin("library", (ctx) => { drawSkills(box, all); body.append(box); // under the list, so the skills stay where they were above it - if (all.length) body.append(skillHowBar()); + if (all.length) body.append(skillHowBar(), skillWhereBar()); if (picking) body.append(pickBar(all)); } if (lib.newSkills?.length) renderNewSkills(body); @@ -4744,6 +4744,23 @@ magpie.plugin("library", (ctx) => { return bar; } + // Where the skills go (usrname1833): to the agents each is ticked for, + // in their own folders, or also into ~/.agents/skills, which many agents + // and tools read, so each of them has every skill. The files stay in the + // library's folder either way; ~/.agents/skills gets links to them. + function skillWhereBar() { + const bar = el("div", "lib-skillhow lib-skillwhere"); + bar.id = "lib-skillwhere"; + const where = lib.sharedSkills ? "shared" : "agents"; + bar.append(el("span", "label", t("Put skills in")), segs([["agents", t("Each agent's own folder")], ["shared", "~/.agents/skills"]], where, (w) => { + if (w !== where) change("skills/where", { how: w }, w === "shared" ? t("Every skill is in ~/.agents/skills now") : t("Skills go to the agents they're ticked for now")); + })); + bar.append(el("span", "note", where === "shared" + ? t("Every skill on here is linked into ~/.agents/skills too: each agent that reads that folder has every skill, whatever is ticked. The files stay in the library.") + : t("Each agent gets the skills ticked for it, in its own folder."))); + return bar; + } + function openSkillHow() { const ed = el("div", "editor lib-editor lib-byagent-sheet lib-howsheet"); const head = el("div", "ehead"); diff --git a/internal/gui/assets/plugins/library/i18n.js b/internal/gui/assets/plugins/library/i18n.js index c2ef91807..964c5fefe 100644 --- a/internal/gui/assets/plugins/library/i18n.js +++ b/internal/gui/assets/plugins/library/i18n.js @@ -119,6 +119,12 @@ magpie.strings({ "By agent ({n})": "按 Agent({n})", "Give an agent its skills its own way": "给某个 Agent 单独设定启用方式", "Each agent gets a folder of its own, made again when the library's skill changes; edits made in a copy are replaced.": "每个 Agent 拿到一份独立的文件夹,资源库里的 Skill 变了就重新复制;在副本里做的修改会被覆盖。", + "Put skills in": "Skills 放在", + "Each agent's own folder": "各 Agent 自己的目录", + "Every skill is in ~/.agents/skills now": "所有 Skill 现在都在 ~/.agents/skills 里了", + "Skills go to the agents they're ticked for now": "Skill 现在只给勾选的 Agent", + "Every skill on here is linked into ~/.agents/skills too: each agent that reads that folder has every skill, whatever is ticked. The files stay in the library.": "这台电脑上启用的每个 Skill 也会链接到 ~/.agents/skills:读这个目录的 Agent 都会拿到全部 Skill,不管勾没勾选。文件仍保存在资源库里。", + "Each agent gets the skills ticked for it, in its own folder.": "每个 Agent 只拿到勾选给它的 Skill,放在它自己的目录里。", "Links follow the library's skill: an update reaches the agents at once.": "符号链接跟着资源库里的 Skill 走:一更新,各 Agent 立刻就用上。", "How each agent gets its skills": "各 Agent 的 Skills 启用方式", "An agent can have its own way; the others get copies, as the library gives them.": "可以给某个 Agent 单独设定;其余的按资源库的方式,拿副本。", @@ -877,6 +883,12 @@ magpie.strings({ "By agent ({n})": "按 Agent({n})", "Give an agent its skills its own way": "給某個 Agent 單獨設定啟用方式", "Each agent gets a folder of its own, made again when the library's skill changes; edits made in a copy are replaced.": "每個 Agent 拿到一份獨立的資料夾,資源庫裡的 Skill 變了就重新複製;在副本里做的修改會被覆蓋。", + "Put skills in": "Skills 放在", + "Each agent's own folder": "各 Agent 自己的目錄", + "Every skill is in ~/.agents/skills now": "所有 Skill 現在都在 ~/.agents/skills 裡了", + "Skills go to the agents they're ticked for now": "Skill 現在只給勾選的 Agent", + "Every skill on here is linked into ~/.agents/skills too: each agent that reads that folder has every skill, whatever is ticked. The files stay in the library.": "這台電腦上啟用的每個 Skill 也會連結到 ~/.agents/skills:讀這個目錄的 Agent 都會拿到全部 Skill,不管勾沒勾選。檔案仍保存在資源庫裡。", + "Each agent gets the skills ticked for it, in its own folder.": "每個 Agent 只拿到勾選給它的 Skill,放在它自己的目錄裡。", "Links follow the library's skill: an update reaches the agents at once.": "符號連結跟著資源庫裡的 Skill 走:一更新,各 Agent 立刻就用上。", "How each agent gets its skills": "各 Agent 的 Skills 啟用方式", "An agent can have its own way; the others get copies, as the library gives them.": "可以給某個 Agent 單獨設定;其餘的按資源庫的方式,拿副本。", @@ -1631,6 +1643,12 @@ magpie.strings({ "By agent ({n})": "エージェント別({n})", "Give an agent its skills its own way": "エージェントごとに渡し方を決める", "Each agent gets a folder of its own, made again when the library's skill changes; edits made in a copy are replaced.": "各エージェントに独立したフォルダを渡し、ライブラリのスキルが変わると作り直します。コピーへの編集は上書きされます。", + "Put skills in": "スキルの置き場所", + "Each agent's own folder": "各エージェントのフォルダ", + "Every skill is in ~/.agents/skills now": "すべてのスキルが ~/.agents/skills に入りました", + "Skills go to the agents they're ticked for now": "スキルはチェックしたエージェントにだけ渡るようになりました", + "Every skill on here is linked into ~/.agents/skills too: each agent that reads that folder has every skill, whatever is ticked. The files stay in the library.": "このコンピュータで有効なスキルはすべて ~/.agents/skills にもリンクされます。このフォルダを読むエージェントは、チェックに関係なくすべてのスキルを使えます。ファイルはライブラリに残ります。", + "Each agent gets the skills ticked for it, in its own folder.": "各エージェントには、チェックしたスキルだけがそのエージェントのフォルダに渡ります。", "Links follow the library's skill: an update reaches the agents at once.": "リンクはライブラリのスキルに従います。更新はすぐにエージェントに届きます。", "How each agent gets its skills": "エージェントごとのスキルの渡し方", "An agent can have its own way; the others get copies, as the library gives them.": "エージェントごとに決められます。ほかはライブラリの設定どおりコピーを受け取ります。", @@ -2387,6 +2405,12 @@ magpie.strings({ "By agent ({n})": "Nach Agenten ({n})", "Give an agent its skills its own way": "Einem Agenten seine Skills auf eigene Art geben", "Each agent gets a folder of its own, made again when the library's skill changes; edits made in a copy are replaced.": "Jeder Agent bekommt einen eigenen Ordner, der neu angelegt wird, wenn sich der Skill der Bibliothek ändert; Änderungen an einer Kopie werden ersetzt.", + "Put skills in": "Skills ablegen in", + "Each agent's own folder": "Ordner jedes Agenten", + "Every skill is in ~/.agents/skills now": "Jeder Skill liegt jetzt in ~/.agents/skills", + "Skills go to the agents they're ticked for now": "Skills gehen jetzt an die Agenten, für die sie angehakt sind", + "Every skill on here is linked into ~/.agents/skills too: each agent that reads that folder has every skill, whatever is ticked. The files stay in the library.": "Jeder hier aktive Skill wird auch nach ~/.agents/skills verlinkt: Jeder Agent, der diesen Ordner liest, hat jeden Skill, egal was angehakt ist. Die Dateien bleiben in der Bibliothek.", + "Each agent gets the skills ticked for it, in its own folder.": "Jeder Agent bekommt die für ihn angehakten Skills in seinem eigenen Ordner.", "Links follow the library's skill: an update reaches the agents at once.": "Links folgen dem Skill der Bibliothek: Ein Update erreicht die Agenten sofort.", "How each agent gets its skills": "Wie jeder Agent seine Skills bekommt", "An agent can have its own way; the others get copies, as the library gives them.": "Ein Agent kann seine eigene Art haben; die anderen bekommen Kopien, wie die Bibliothek sie gibt.", diff --git a/internal/gui/library.go b/internal/gui/library.go index 7bfa3cb49..692f26886 100644 --- a/internal/gui/library.go +++ b/internal/gui/library.go @@ -583,6 +583,9 @@ func libraryRoutes(mux *http.ServeMux, w Windows) { res, err = library.UseLibrarySkills(oneOrMore(in.Name, in.Names), in.Agent) case "skills/how": res, err = library.SetSkillHow(in.Agent, in.How) + case "skills/where": + // each agent's own folder, or ~/.agents/skills too (skills_shared.go) + res, err = library.SetSkillsWhere(in.How) case "skills/keep-own": res, err = library.KeepAgentSkills(oneOrMore(in.Name, in.Names), in.Agent) case "market/server": diff --git a/internal/gui/tests/skill-where.test.cjs b/internal/gui/tests/skill-where.test.cjs new file mode 100644 index 000000000..52c36bb8f --- /dev/null +++ b/internal/gui/tests/skill-where.test.cjs @@ -0,0 +1,179 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// usrname1833: the Skills tab says where the library's skills go, each +// agent's own folder (the default) or ~/.agents/skills too, and a switch +// posts it. With them there, the agents that read that folder (Pi from +// 0.54, Codex) have every skill: their chips are locked on. No select, no +// scroll, no left border, nothing wider than the window, in every +// language and at a phone's width. No backend: the API is faked here. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); + +const assets = path.resolve(__dirname, "../assets"); +const HOME = "/Users/ada"; + +function server(lang, posts) { + const st = { shared: false }; + const agent = (id, name) => ({ id, name, icon: "", skills: `${HOME}/.${id}/skills`, how: "link" }); + const readers = () => (st.shared ? ["codex", "pi"] : []); + const lib = () => ({ + dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME, copySkills: false, + sharedSkills: st.shared, sharedDir: `${HOME}/.agents/skills`, + agents: [agent("claude", "Claude Code"), agent("codex", "Codex"), agent("pi", "Pi")], + instructions: { agents: [] }, servers: [], foundServers: [], projects: [], foundSkills: [], + skills: [ + { name: "pdf", description: "Read PDFs", kind: "", agents: ["claude"], always: readers().length ? readers() : undefined }, + { name: "tdd", description: "Tests first", kind: "", agents: ["claude", "pi"], always: readers().length ? readers() : undefined }, + ], + }); + return async (route) => { + const req = route.request(), url = new URL(req.url()); + if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` }); + if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); + if (url.pathname === "/api/state") return route.fulfill({ json: { agents: [], profiles: [], settings: { lang, theme: "light" } } }); + if (url.pathname === "/api/library") return route.fulfill({ json: lib() }); + if (url.pathname === "/api/library/skills/where") { + const b = req.postDataJSON(); + posts.push(b); + st.shared = b.how === "shared"; + return route.fulfill({ json: { ...lib(), result: { changed: ["codex", "pi"], problems: [] } } }); + } + if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } }); + if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] }); + if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } }); + if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], gateway: { running: true } } }); + if (url.pathname.startsWith("/api/")) return route.fulfill({ json: {} }); + const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); + const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)]; + await route.fulfill({ body: await fs.readFile(file), contentType }); + }; +} + +// where the bar's label is on screen: a switch leaves it where it was (a +// pixel's give, for a page scrolled to its foot whose note changed length) +const labelAt = (page) => page.locator("#lib-skillwhere .label").evaluate((e) => Math.round(e.getBoundingClientRect().top)); +const press = async (page, loc) => { + const b = await loc.boundingBox(); + await page.mouse.click(b.x + b.width / 2, b.y + b.height / 2); +}; +const leftBorders = (page, sel) => page.evaluate((sel) => [...document.querySelectorAll(sel)].flatMap((e) => [e, ...e.querySelectorAll("*")]) + .filter((e) => parseFloat(getComputedStyle(e).borderLeftWidth) > 0 && getComputedStyle(e).borderLeftColor !== getComputedStyle(e).borderTopColor) + .map((e) => e.className), sel); +// what of the bar reaches past the window's right edge +const pastEdge = (page) => page.evaluate(() => [...document.querySelectorAll("#lib-skillwhere, #lib-skillwhere *")] + .filter((e) => e.getBoundingClientRect().right > document.documentElement.clientWidth + 0.5).map((e) => e.className || e.tagName)); + +const SHARED = "~/.agents/skills"; +const words = { + en: { + label: "Put skills in", agents: "Each agent's own folder", + agentsNote: "Each agent gets the skills ticked for it, in its own folder.", + sharedNote: "Every skill on here is linked into ~/.agents/skills too: each agent that reads that folder has every skill, whatever is ticked. The files stay in the library.", + toShared: "Every skill is in ~/.agents/skills now", toAgents: "Skills go to the agents they're ticked for now", + }, + zh: { + label: "Skills 放在", agents: "各 Agent 自己的目录", + agentsNote: "每个 Agent 只拿到勾选给它的 Skill,放在它自己的目录里。", + sharedNote: "这台电脑上启用的每个 Skill 也会链接到 ~/.agents/skills:读这个目录的 Agent 都会拿到全部 Skill,不管勾没勾选。文件仍保存在资源库里。", + toShared: "所有 Skill 现在都在 ~/.agents/skills 里了", toAgents: "Skill 现在只给勾选的 Agent", + }, + "zh-TW": { + label: "Skills 放在", agents: "各 Agent 自己的目錄", + agentsNote: "每個 Agent 只拿到勾選給它的 Skill,放在它自己的目錄裡。", + sharedNote: "這台電腦上啟用的每個 Skill 也會連結到 ~/.agents/skills:讀這個目錄的 Agent 都會拿到全部 Skill,不管勾沒勾選。檔案仍保存在資源庫裡。", + toShared: "所有 Skill 現在都在 ~/.agents/skills 裡了", toAgents: "Skill 現在只給勾選的 Agent", + }, + ja: { + label: "スキルの置き場所", agents: "各エージェントのフォルダ", + agentsNote: "各エージェントには、チェックしたスキルだけがそのエージェントのフォルダに渡ります。", + sharedNote: "このコンピュータで有効なスキルはすべて ~/.agents/skills にもリンクされます。このフォルダを読むエージェントは、チェックに関係なくすべてのスキルを使えます。ファイルはライブラリに残ります。", + toShared: "すべてのスキルが ~/.agents/skills に入りました", toAgents: "スキルはチェックしたエージェントにだけ渡るようになりました", + }, + de: { + label: "Skills ablegen in", agents: "Ordner jedes Agenten", + agentsNote: "Jeder Agent bekommt die für ihn angehakten Skills in seinem eigenen Ordner.", + sharedNote: "Jeder hier aktive Skill wird auch nach ~/.agents/skills verlinkt: Jeder Agent, der diesen Ordner liest, hat jeden Skill, egal was angehakt ist. Die Dateien bleiben in der Bibliothek.", + toShared: "Jeder Skill liegt jetzt in ~/.agents/skills", toAgents: "Skills gehen jetzt an die Agenten, für die sie angehakt sind", + }, +}; + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + test(engine + ": where the library's skills go (usrname1833)", async (t) => { + assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit"); + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + const errors = []; + t.after(async () => { + if (errors.length) console.log(errors); + await browser.close(); + }); + const open = async (lang, width, posts) => { + const ctx = await browser.newContext({ viewport: { width, height: 760 } }); + await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "skills"); } catch {} }); + const page = await ctx.newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + page.on("pageerror", (e) => errors.push(e.message)); + page.on("dialog", (d) => { errors.push("a browser dialog: " + d.message()); d.dismiss(); }); + await page.route("**/*", server(lang, posts)); + await page.goto("http://magpie.test/"); + await page.locator('button[data-view="library"]').click(); + await page.locator("#view-library .lib-body:not(.lib-skel) .lib-row").first().waitFor(); + return page; + }; + const locked = (page, skill) => page.locator("#view-library .lib-skill", { hasText: skill }).locator(".lib-ag.always") + .evaluateAll((cs) => cs.map((c) => c.dataset.agent).sort()); + + for (const lang of Object.keys(words)) { + for (const width of [900, 400]) { + await t.test(`${lang} at ${width}px`, async () => { + const w = words[lang], posts = []; + const page = await open(lang, width, posts); + const bar = page.locator("#lib-skillwhere"); + assert.equal((await bar.locator(".label").textContent()).trim(), w.label); + const segs = bar.locator(".segs .opt"); + assert.deepEqual((await segs.allTextContents()).map((s) => s.trim()), [w.agents, SHARED]); + assert.equal((await bar.locator(".segs .opt.on").textContent()).trim(), w.agents, "each agent's folder is the default"); + assert.equal((await bar.locator(".note").textContent()).trim(), w.agentsNote); + assert.deepEqual(await locked(page, "pdf"), []); + assert.deepEqual(await pastEdge(page), [], "nothing past the window's edge"); + // at a phone's width the bar is below the fold: scrolled to as a + // reader does, with the wheel, till its note is in view + await page.mouse.move(width / 2, 500); + for (let i = 0; i < 10; i++) { + const b = await bar.locator(".note").boundingBox(); + if (b.y + b.height <= 740) break; + await page.mouse.wheel(0, 200); + await page.waitForTimeout(150); + } + const before = await labelAt(page); + + await press(page, segs.nth(1)); + await bar.locator(".segs .opt.on", { hasText: SHARED }).waitFor(); + assert.deepEqual(posts, [{ how: "shared" }]); + assert.equal((await page.locator("#status").textContent()).trim(), w.toShared); + const now = page.locator("#lib-skillwhere"); + assert.equal((await now.locator(".note").textContent()).trim(), w.sharedNote); + // Codex and Pi read ~/.agents/skills: every skill, locked on + assert.deepEqual(await locked(page, "pdf"), ["codex", "pi"]); + assert.deepEqual(await locked(page, "tdd"), ["codex", "pi"]); + assert(Math.abs(await labelAt(page) - before) <= 2, "the switch scrolls nothing"); + assert.deepEqual(await pastEdge(page), [], "nothing past the window's edge"); + + await press(page, now.locator(".segs .opt").nth(0)); + await page.locator("#lib-skillwhere .segs .opt.on", { hasText: w.agents }).waitFor(); + assert.deepEqual(posts[1], { how: "agents" }); + assert.equal((await page.locator("#status").textContent()).trim(), w.toAgents); + assert.deepEqual(await locked(page, "pdf"), []); + + assert.equal(await page.locator("select").count(), 0, "no native select"); + assert.deepEqual(await leftBorders(page, "#lib-skillwhere"), []); + await page.context().close(); + }); + } + } + + assert.deepEqual(errors, []); + }); +} diff --git a/internal/library/library.go b/internal/library/library.go index e4260c5ce..364aca6e9 100644 --- a/internal/library/library.go +++ b/internal/library/library.go @@ -51,6 +51,11 @@ type Library struct { // copy (#896, skill_how.go) CopySkills bool `json:"copySkills,omitempty"` SkillHow map[string]string `json:"skillHow,omitempty"` + // SharedSkills puts every skill on here in ~/.agents/skills too, as + // magpie's link to the library's folder, for every agent and tool + // that reads it (usrname1833, skills_shared.go). This computer's + // own: Collect doesn't carry it + SharedSkills bool `json:"sharedSkills,omitempty"` // MCPHub gives each agent that can reach it magpie's one MCP server, // which hands each call on to the library's servers ticked for it, in // place of their own entries (#2679, mcp_hub.go) diff --git a/internal/library/skill_handover.go b/internal/library/skill_handover.go index 28f485a5f..66a2bd3ad 100644 --- a/internal/library/skill_handover.go +++ b/internal/library/skill_handover.go @@ -81,7 +81,7 @@ func readsSharedHere(ts []*Target) []string { sh := realDir(sharedSkillsDir()) var out []string for _, t := range ts { - if t.Skills != "" && !t.Gone && t.Desktop == nil && (slices.Contains(readsShared, t.Agent.ID) || realDir(t.Skills) == sh) { + if t.Skills != "" && !t.Gone && t.Desktop == nil && (t.readsSharedDir() || realDir(t.Skills) == sh) { out = append(out, t.Agent.ID) } } diff --git a/internal/library/skills.go b/internal/library/skills.go index 189ae9364..f67707ce3 100644 --- a/internal/library/skills.go +++ b/internal/library/skills.go @@ -564,6 +564,11 @@ func (l *Library) syncSkills(t *Target, res *Result, all []*Target) { if s == nil { return false } + // the folder is ~/.agents/skills itself: what the setting puts + // there (skills_shared.go) stays + if l.keepsShared(s) && realDir(t.Skills) == realDir(sharedSkillsDir()) { + return true + } return s.gives(id) || slices.ContainsFunc(sharers, s.gives) } // an agent that reads ~/.agents/skills as well as its own folder finds @@ -572,12 +577,12 @@ func (l *Library) syncSkills(t *Target, res *Result, all []*Target) { shared := realDir(sharedSkillsDir()) isShared := realDir(t.Skills) == shared inShared := func(s *Skill) bool { - if s == nil || !slices.Contains(readsShared, id) || realDir(t.Skills) == shared { + if s == nil || !t.readsSharedDir() || realDir(t.Skills) == shared { return false } // the library's skill is kept in the shared folder itself (brought // in from there): every agent reading it has it, ticked or not (#595) - if sharedHas(s.Name) { + if sharedHas(s.Name) || l.inSharedHere(s) { return true } p := filepath.Join(sharedSkillsDir(), s.Name) @@ -739,7 +744,8 @@ func (l *Library) sweepShared(all []*Target, res *Result) { continue } s := l.skill(name) - if slices.ContainsFunc(holders, func(o *Target) bool { return s.gives(o.Agent.ID) }) { + // one the setting keeps there stays (skills_shared.go) + if l.keepsShared(s) || slices.ContainsFunc(holders, func(o *Target) bool { return s.gives(o.Agent.ID) }) { continue } if err := unlink(p); err != nil { diff --git a/internal/library/skills_shared.go b/internal/library/skills_shared.go new file mode 100644 index 000000000..6989ff3d0 --- /dev/null +++ b/internal/library/skills_shared.go @@ -0,0 +1,123 @@ +package library + +// Where the library's skills go (usrname1833 on Discord): to the agents +// each is ticked for, in each agent's own folder (the default), or also +// into ~/.agents/skills, the folder many agents and tools read besides +// their own (readsShared, Target.SharedToo), so every one of them finds +// every skill, ticked or not, as it finds one the user keeps there. +// +// The skill's files stay in the library's folder and ~/.agents/skills +// gets magpie's link to it, as it does for an agent whose folder it is +// (Goose, Kimi Code, Cindy): an update, a check, an edit, a sync and +// turning one off on this computer work as for any skill, and turning +// the setting off takes out magpie's links there and nothing else. An +// entry of the user's own by a skill's name is never written over. +// +// It is this computer's setting: Collect never carries it. + +import ( + "fmt" + "os" + "path/filepath" + "slices" +) + +// The places SetSkillsWhere takes. +const ( + SkillsInAgents = "agents" // each agent's own folder, as ticked + SkillsInShared = "shared" // ~/.agents/skills too, every skill +) + +// SetSkillsWhere sets where the library's skills go: SkillsInAgents or +// SkillsInShared. Every skill is put in ~/.agents/skills, or taken out of +// it, at the sync it runs. +func SetSkillsWhere(where string) (*Result, error) { + if where != SkillsInAgents && where != SkillsInShared { + return nil, fmt.Errorf("skills go in %s or %s, not %q", SkillsInAgents, SkillsInShared, where) + } + return change(func(l *Library) error { + l.SharedSkills = where == SkillsInShared + return nil + }) +} + +// keepsShared is whether the library puts its skill s in ~/.agents/skills: +// the setting is on, the skill is on here and its folder is there. +func (l *Library) keepsShared(s *Skill) bool { + if !l.SharedSkills || s == nil || s.OffHere { + return false + } + _, err := os.Stat(filepath.Join(skillDir(s.Name), "SKILL.md")) + return err == nil +} + +// inSharedHere is whether ~/.agents/skills has the library's skill s by +// the setting: magpie's link (or copy) there. +func (l *Library) inSharedHere(s *Skill) bool { + return l.keepsShared(s) && ours(filepath.Join(sharedSkillsDir(), s.Name), s.Name) +} + +// syncShared puts each skill the setting keeps there into ~/.agents/skills, +// before the agents that read it are synced (they then get no second +// link). One given to an agent whose folder that is (Kimi Code) is that +// agent's sync's, which puts it there its own way; sweepShared takes out +// what the setting no longer keeps. +func (l *Library) syncShared(all []*Target, res *Result) { + if !l.SharedSkills { + return + } + shared := realDir(sharedSkillsDir()) + var holders []*Target + for _, o := range all { + if o.Skills != "" && !o.Gone && realDir(o.Skills) == shared { + holders = append(holders, o) + } + } + for _, s := range l.Skills { + if !l.keepsShared(s) || sharedEntry(s.Name) != "" || slices.ContainsFunc(holders, func(o *Target) bool { return s.gives(o.Agent.ID) }) { + continue + } + p := filepath.Join(sharedSkillsDir(), s.Name) + if l.blockedSkills[realDir(p)] { + continue + } + if ours(p, s.Name) { + if linked(p) { + continue + } + // a copy, where no link could be made (Windows without the + // right to): a link once one can be, else made again when the + // library's skill has changed, an edited copy kept aside + if ok, err := relink("agents", p, s.Name); err != nil || ok { + if err != nil { + res.fail("agents", "skill:"+s.Name, err) + } + continue + } + if h := l.libHash(s.Name); h != "" { + fresh, err := copyIsFresh(p, h, false) + if err == nil && !fresh { + _, err = setAside("agents", p) + if err == nil { + err = link(p, s.Name) + } + } + if err != nil { + res.fail("agents", "skill:"+s.Name, err) + } + } + continue + } + if _, err := os.Lstat(p); err == nil { + // the user's own by that name stays theirs, and is what the + // agents reading the folder find; the agents ticked for the + // library's still get it in their own folders (inSharedHere + // is false for it). Said at no sync: every change would carry + // it as a failure + continue + } + if err := link(p, s.Name); err != nil { + res.fail("agents", "skill:"+s.Name, err) + } + } +} diff --git a/internal/library/skills_shared_test.go b/internal/library/skills_shared_test.go new file mode 100644 index 000000000..8363c83ae --- /dev/null +++ b/internal/library/skills_shared_test.go @@ -0,0 +1,247 @@ +package library + +import ( + "os" + "path/filepath" + "slices" + "strings" + "testing" + + "github.com/yetone/magpie/internal/agent" +) + +func setOmpVersion(t *testing.T, v string) { + t.Helper() + was := ompVersion + ompVersion = func(*agent.Agent) string { return v } + t.Cleanup(func() { ompVersion = was }) +} + +func alwaysOf(t *testing.T, name string) []string { + t.Helper() + v, err := Read(nil) + if err != nil { + t.Fatal(err) + } + for _, s := range v.Skills { + if s.Name == name { + return s.Always + } + } + t.Fatalf("no skill %s in the view", name) + return nil +} + +// usrname1833: Pi reads ~/.agents/skills itself, from 0.54.0 (its +// CHANGELOG, package-manager.js userAgentsSkillsDir), omp from 11.0.0 +// (discovery/agents.ts) and OmO's senpi in every version on npm. A skill +// kept there is theirs whatever is ticked (the lock), and no second link +// is made in their own folders; an older or unknown one is as before. +func TestPiReadsSharedSkillsFromItsVersion(t *testing.T) { + h := sandbox(t) + os.RemoveAll(filepath.Join(h, ".config/goose")) + os.Remove(filepath.Join(h, "bin/goose")) + os.Remove(filepath.Join(h, "bin/goose.exe")) + write(t, filepath.Join(h, ".omp/agent/mcp.json"), "{}") + holdCLI(t, h, "omp") + write(t, filepath.Join(h, ".omo/agent/settings.json"), "{}") + holdCLI(t, h, "omo") + shared := filepath.Join(h, ".agents/skills") + skill(t, filepath.Join(shared, "orch"), "orch", "Orchestrate") + own := map[string]string{ + "pi": filepath.Join(h, ".pi/agent/skills/orch"), + "omp": filepath.Join(h, ".omp/agent/skills/orch"), + "omo": filepath.Join(h, ".omo/agent/skills/orch"), + } + + setPiVersion(t, "0.53.0") + setOmpVersion(t, "10.6.2") + ok(t)(ImportSkill("orch")) + ok(t)(SkillAgents("orch", []string{"claude", "pi", "omp", "omo"})) + for _, id := range []string{"pi", "omp"} { + if !ours(own[id], "orch") { + t.Errorf("%s before it read ~/.agents/skills hasn't its own link", id) + } + } + if _, err := os.Lstat(own["omo"]); !os.IsNotExist(err) { + t.Errorf("omo reads ~/.agents/skills, yet got a second link: %v", err) + } + a := alwaysOf(t, "orch") + if slices.Contains(a, "pi") || slices.Contains(a, "omp") || !slices.Contains(a, "omo") || !slices.Contains(a, "codex") { + t.Errorf("always before: %v", a) + } + + setPiVersion(t, "0.54.0") + setOmpVersion(t, "11.0.0") + ok(t)(Sync()) + for _, id := range []string{"pi", "omp"} { + if _, err := os.Lstat(own[id]); !os.IsNotExist(err) { + t.Errorf("%s reads ~/.agents/skills now, yet keeps a second link: %v", id, err) + } + } + a = alwaysOf(t, "orch") + for _, id := range []string{"pi", "omp", "omo", "codex"} { + if !slices.Contains(a, id) { + t.Errorf("%s isn't said to have it always: %v", id, a) + } + } + if slices.Contains(a, "claude") { + t.Errorf("claude reads no ~/.agents/skills: %v", a) + } + + // a version not known is taken as an older one, as before + setPiVersion(t, "") + ok(t)(Sync()) + if !ours(own["pi"], "orch") || slices.Contains(alwaysOf(t, "orch"), "pi") { + t.Error("a pi of no known version isn't as before") + } +} + +// usrname1833: the library's skills can go into ~/.agents/skills too, as +// magpie's links to the library's folders, so every agent and tool that +// reads that folder has every skill. Off (the default) is as before; +// turning it off takes out magpie's links there and nothing else. +func TestSkillsWhereShared(t *testing.T) { + h := sandbox(t) + os.RemoveAll(filepath.Join(h, ".config/goose")) + os.Remove(filepath.Join(h, "bin/goose")) + os.Remove(filepath.Join(h, "bin/goose.exe")) + setPiVersion(t, "0.70.0") + src := filepath.Join(h, "src/skills") + skill(t, filepath.Join(src, "pdf"), "pdf", "Read PDFs") + skill(t, filepath.Join(src, "mine"), "mine", "Mine") + shared := filepath.Join(h, ".agents/skills") + // the user's own skills there: one magpie has no skill by, and one by + // a name the library has, with other files + skill(t, filepath.Join(shared, "theirs"), "theirs", "Theirs") + write(t, filepath.Join(shared, "mine", "SKILL.md"), "---\nname: mine\ndescription: Not the library's\n---\n") + pdf := filepath.Join(shared, "pdf") + pi, cl := filepath.Join(h, ".pi/agent/skills/pdf"), filepath.Join(h, ".claude/skills/pdf") + + ok(t)(InstallSkills(src, []string{"pdf"}, []string{"claude", "pi"})) + if _, err := os.Lstat(pdf); !os.IsNotExist(err) { + t.Fatalf("the default put pdf in ~/.agents/skills: %v", err) + } + if !ours(pi, "pdf") { + t.Fatal("pi hasn't pdf") + } + if v, _ := Read(nil); v.SharedSkills || v.SharedDir != shared { + t.Errorf("view: shared %v at %q", v.SharedSkills, v.SharedDir) + } + + if _, err := SetSkillsWhere("everywhere"); err == nil { + t.Error("a place it doesn't know was taken") + } + ok(t)(SetSkillsWhere(SkillsInShared)) + if !ours(pdf, "pdf") || !linked(pdf) { + t.Fatal("pdf isn't magpie's link in ~/.agents/skills") + } + // a sync leaves the link as it is, not taken out and made again, + // which a reader of the folder would find missing in between + was, _ := os.Lstat(pdf) + ok(t)(Sync()) + if now, err := os.Lstat(pdf); err != nil || !os.SameFile(was, now) { + t.Errorf("a sync made the link again: %v", err) + } + // pi reads that folder: no second link; claude doesn't: its stays + if _, err := os.Lstat(pi); !os.IsNotExist(err) { + t.Errorf("pi keeps a second link: %v", err) + } + if !ours(cl, "pdf") { + t.Error("claude lost its link") + } + a := alwaysOf(t, "pdf") + for _, id := range []string{"pi", "codex", "gemini"} { + if !slices.Contains(a, id) { + t.Errorf("%s isn't said to have it always: %v", id, a) + } + } + if slices.Contains(a, "claude") { + t.Errorf("claude: %v", a) + } + if v, _ := Read(nil); !v.SharedSkills { + t.Error("the view doesn't say skills go to ~/.agents/skills") + } + // the user's own are as they were + if _, err := os.Stat(filepath.Join(shared, "theirs", "SKILL.md")); err != nil { + t.Error("the user's own skill went") + } + + // a library skill by a name the user has there with other files: + // theirs stays, and the agents ticked for the library's get it in + // their own folders + ok(t)(InstallSkills(src, []string{"mine"}, []string{"claude", "pi"})) + if !ours(filepath.Join(h, ".pi/agent/skills/mine"), "mine") { + t.Error("pi hasn't the library's mine") + } + if ours(filepath.Join(shared, "mine"), "mine") || !strings.Contains(read(t, filepath.Join(shared, "mine", "SKILL.md")), "Not the library's") { + t.Error("the user's own mine was written over") + } + + // off on this computer: out of ~/.agents/skills, and pi's own is back + ok(t)(SkillHere("pdf", false)) + if _, err := os.Lstat(pdf); !os.IsNotExist(err) { + t.Errorf("a skill off here stays in ~/.agents/skills: %v", err) + } + ok(t)(SkillHere("pdf", true)) + if !ours(pdf, "pdf") { + t.Error("on again, pdf isn't back") + } + + // a skill unticked everywhere is still in the shared folder + ok(t)(SkillAgents("pdf", nil)) + if !ours(pdf, "pdf") { + t.Error("unticked, pdf left ~/.agents/skills") + } + + // back to each agent's folder: magpie's links there go, nothing else + ok(t)(SkillAgents("pdf", []string{"claude", "pi"})) + r, err := SetSkillsWhere(SkillsInAgents) + if err != nil { + t.Fatal(err) + } + if len(r.Problems) != 0 { + t.Errorf("problems: %+v", r.Problems) + } + if _, err := os.Lstat(pdf); !os.IsNotExist(err) { + t.Errorf("pdf stays in ~/.agents/skills: %v", err) + } + if !ours(pi, "pdf") { + t.Error("pi hasn't its own link back") + } + if slices.Contains(alwaysOf(t, "pdf"), "pi") { + t.Error("pi still said to have it always") + } + for _, n := range []string{"theirs", "mine"} { + if _, err := os.Stat(filepath.Join(shared, n, "SKILL.md")); err != nil { + t.Errorf("the user's own %s went", n) + } + } + if _, err := os.Stat(filepath.Join(skillDir("pdf"), "SKILL.md")); err != nil { + t.Error("the library's pdf went") + } +} + +// A skill ticked for Kimi Code, whose folder ~/.agents/skills is, and then +// unticked for it stays there while the setting keeps it there. +func TestSkillsWhereSharedWithKimi(t *testing.T) { + h := sandbox(t) + write(t, filepath.Join(h, ".kimi/config.toml"), "") + src := filepath.Join(h, "src/skills") + skill(t, filepath.Join(src, "pdf"), "pdf", "Read PDFs") + pdf := filepath.Join(h, ".agents/skills/pdf") + ok(t)(InstallSkills(src, []string{"pdf"}, []string{"kimi"})) + ok(t)(SetSkillsWhere(SkillsInShared)) + ok(t)(SkillAgents("pdf", []string{"claude"})) + if !ours(pdf, "pdf") { + t.Fatal("unticked for Kimi Code, pdf left ~/.agents/skills") + } + ok(t)(Sync()) + if !ours(pdf, "pdf") { + t.Fatal("a second sync took pdf out") + } + ok(t)(SetSkillsWhere(SkillsInAgents)) + if _, err := os.Lstat(pdf); !os.IsNotExist(err) { + t.Errorf("pdf stays: %v", err) + } +} diff --git a/internal/library/sync.go b/internal/library/sync.go index 3a7294764..43bd3fa35 100644 --- a/internal/library/sync.go +++ b/internal/library/sync.go @@ -120,6 +120,7 @@ func syncSteps(all, gone []*Target, b *backups, res *Result) []func(*Library) { // link to what is there already shared := realDir(sharedSkillsDir()) steps = append(steps, func(l *Library) { l.sweepShared(append(slices.Clone(all), gone...), res) }) + steps = append(steps, func(l *Library) { l.syncShared(all, res) }) for _, first := range []bool{true, false} { for _, t := range all { switch { @@ -498,6 +499,10 @@ type View struct { Backups string `json:"backups"` SkillGroups []SkillGroup `json:"skillGroups"` CopySkills bool `json:"copySkills"` // the library gives skills as copies (#896) + // SharedSkills: every skill on here is in ~/.agents/skills too + // (skills_shared.go), at SharedDir + SharedSkills bool `json:"sharedSkills"` + SharedDir string `json:"sharedDir"` // MCPHub: the agents are given magpie's one MCP server in place of // the library's (#2679), at HubPath on the gateway MCPHub bool `json:"mcpHub"` @@ -569,7 +574,7 @@ func readView(problems []Problem, glance bool) (*View, error) { // the agents are found once for the whole read: finding them looks // through every agent's folders, in WSL too (#1624) targets, asleep := targetsAsleep(false) - v := &View{Agents: []AgentView{}, Servers: []ServerView{}, Skills: []SkillView{}, FoundSkills: []FoundSkill{}, Instructions: l.instructionsView(targets, asleep), Dir: Dir(), Backups: BackupDir(), CopySkills: l.CopySkills, MCPHub: l.MCPHub, HubPath: gateway.HubMCPPath, HubNote: settings.Shared().RouterNote, HubName: gateway.HostName(), Partial: glance} + v := &View{Agents: []AgentView{}, Servers: []ServerView{}, Skills: []SkillView{}, FoundSkills: []FoundSkill{}, Instructions: l.instructionsView(targets, asleep), Dir: Dir(), Backups: BackupDir(), CopySkills: l.CopySkills, SharedSkills: l.SharedSkills, SharedDir: sharedSkillsDir(), MCPHub: l.MCPHub, HubPath: gateway.HubMCPPath, HubNote: settings.Shared().RouterNote, HubName: gateway.HostName(), Partial: glance} for _, t := range targets { av := AgentView{ID: t.Agent.ID, Name: t.Agent.Name, Icon: t.Agent.Icon, Instructions: t.Instructions, Skills: t.Skills, SkillsAlso: t.SkillsAlso, Note: t.Note, MCPVia: t.MCPVia, ProjectSkills: ProjectSkillsDir(t.Agent.ID), ProjectMCP: ProjectMCPFile(t.Agent.ID), @@ -675,10 +680,15 @@ func readView(problems []Problem, glance bool) (*View, error) { } else if _, err := os.Lstat(p); err == nil && sv.Kind == "folder" { sv.Kind, sv.Source = "", "" } - if sv.Shared = sharedEntry(s.Name); sv.Shared != "" { + // kept in ~/.agents/skills by the user, or put there by the + // setting: every agent reading that folder has it + sv.Shared = sharedEntry(s.Name) + if sv.Shared != "" { sv.SharedElsewhere = !within(realDir(skillDir(s.Name)), realDir(sharedSkillsDir())) + } + if sv.Shared != "" || l.inSharedHere(s) { for _, t := range targets { - if t.Skills != "" && (slices.Contains(readsShared, t.Agent.ID) || realDir(t.Skills) == realDir(sharedSkillsDir())) { + if t.Skills != "" && (t.readsSharedDir() || realDir(t.Skills) == realDir(sharedSkillsDir())) { sv.Always = append(sv.Always, t.Agent.ID) } } diff --git a/internal/library/targets.go b/internal/library/targets.go index 9b1218cbf..b9de6c031 100644 --- a/internal/library/targets.go +++ b/internal/library/targets.go @@ -52,6 +52,10 @@ type Target struct { // gave it (held): a sync only takes things out of it, as they are // unticked, and gives it nothing. Gone bool + // SharedToo is an agent that reads ~/.agents/skills besides its own + // folder only from some version on (Pi, omp: sharedSince), with that + // version here; the others that always do are in readsShared + SharedToo bool // Profile says the instructions file is the user's profile to the // agent, not instructions alone (Alma's USER.md): magpie adds its part // after the user's, but never moves the user's own lines out of it @@ -201,8 +205,10 @@ func targetOf(a *agent.Agent) *Target { // Pi 0.99 reads MCP servers itself, from its mcp.json; before it, // and while an MCP extension replaces its own (pi-mcp-adapter, // pi-mcp-extension), each extension reads its own file (pimcp.go) - t.MCP, t.MCPVia = piMCP(h, d, piVersion(a), piGlobalRoots()) + v := piVersion(a) + t.MCP, t.MCPVia = piMCP(h, d, v, piGlobalRoots()) t.Skills = filepath.Join(d, "skills") + t.SharedToo = since(v, piSharedSince) case "dsh": // DeepSeek Harness reads $DSH_HOME/AGENTS.md and $DSH_HOME/skills; // its MCP servers are @deepseek-ai/dsh-mcp-client rows its patch @@ -220,6 +226,7 @@ func targetOf(a *agent.Agent) *Target { // (discovery/builtin.ts), type choosing the transport t.MCP = &mcpFile{Path: filepath.Join(d, "mcp.json"), Format: fmtOmp} t.Skills = filepath.Join(d, "skills") + t.SharedToo = since(ompVersion(a), ompSharedSince) case "omo": // OmO's engine (senpi, a fork of Pi) reads its agent folder's // AGENTS.md, skills and mcp.json — mcpServers in the shape Pi 0.99's @@ -933,8 +940,37 @@ func (l *Library) held(have []*Target) []*Target { // readsShared are the agents that read ~/.agents/skills as well as their // own folder (each one's docs or source): Kimi Code's own is -// ~/.kimi-code/skills besides it (#4379). -var readsShared = []string{"codex", "gemini", "opencode", "deveco", "crush", "dsh", "commandcode", "devin", "droid", "cline", "grok", "grok-app", "fx", "alma", "kimi"} +// ~/.kimi-code/skills besides it (#4379). OmO's engine, senpi, a fork of +// Pi from after Pi 0.54 (its oldest on npm is 0.74.0), reads it as Pi +// does (core/package-manager.js, userAgentsSkillsDir, @code-yeongyu/senpi +// 2026.5.13). +var readsShared = []string{"codex", "gemini", "opencode", "deveco", "crush", "dsh", "commandcode", "devin", "droid", "cline", "grok", "grok-app", "fx", "alma", "kimi", "omo"} + +// Pi reads ~/.agents/skills from 0.54.0 (2026-02-19, its CHANGELOG: "Added +// default skill auto-discovery for .agents/skills locations … global +// skills from ~/.agents/skills"; userAgentsSkillsDir in +// dist/core/package-manager.js, @earendil-works/pi-coding-agent 1.5.0), +// and omp from 11.0.0 (src/discovery/agents.ts, "Load skills from +// ~/.agents/skills"; 10.6.2 has no such provider). A Pi or omp whose +// version isn't known is taken for one before, as magpie took every Pi: +// it is given its own link, which a Pi from 0.68 reads once with the +// shared folder's (it dedupes skills by their real path). +const ( + piSharedSince = "0.54.0" + ompSharedSince = "11.0.0" +) + +// ompVersion is the version of the omp on PATH, "" when not known. +var ompVersion = func(a *agent.Agent) string { return a.InstalledVersion() } + +// since is whether version v, when known, is at or after first. +func since(v, first string) bool { return v != "" && !agent.Newer(first, v) } + +// readsSharedDir is whether the agent reads ~/.agents/skills besides its +// own folder, so a skill kept there reaches it whatever is ticked. +func (t *Target) readsSharedDir() bool { + return t.SharedToo || slices.Contains(readsShared, t.Agent.ID) +} // readsWith adds to each agent's SkillsAlso the agents whose folder it // reads skills from too: one that is the very same folder (Kimi Code's, @@ -954,7 +990,7 @@ func readsWith(ts []*Target) { if i == j || real[i] == "" || real[j] == "" || slices.Contains(t.SkillsAlso, o.Agent.ID) { continue } - if real[j] == real[i] || real[j] == shared && slices.Contains(readsShared, t.Agent.ID) { + if real[j] == real[i] || real[j] == shared && t.readsSharedDir() { t.SkillsAlso = append(t.SkillsAlso, o.Agent.ID) } }