Files
magpie/docs/subsystems/library.md
T
yetone 2a1111cbab library: an agent's profiles are one chip on a row, picked in the app menu (Yanzhongixuy on X)
With several Hermes profiles the Library listed each as its own icon on every
skill/MCP row (~20 identical glyphs). Profiles of one agent family
(hermes#, omp#, claude#, qwenpaw#, WSL variants too) now collapse into one chip
with a count; a click opens the app menu (openProtoMenu, multi-tick, live) to
pick profiles one by one. All still toggles every profile. Rows only; the
By agent view is unchanged. Other multi-profile agents (omp, claude, qwenpaw)
had the same problem and go through the same code.

Run on mote at the branch head: library-profile-chip.test.cjs (new, 12 cases,
chromium + webkit, en/zh/zh-TW/ja/de), red 12 of 12 with profileChip broken by
hand; library-*, group-skill-chips, skill-*, mcp-*, i18n-*, hermes-*, omp-*,
project-* GUI files: all green except library-loading (Claude plugins tab,
already #6204) and one webkit billion-context card case that passed alone
(load flake).
Not tried: a real Hermes install with 20 profiles, Linux WebKitGTK.
2026-11-12 17:57:13 +08:00

126 KiB
Raw Blame History

Library: instructions, MCP servers, skills, hooks, subagents, RTK and billion-context

The library keeps what every agent should know in one place: the instructions each agent reads before a conversation, the MCP servers it can call, the skills it can load, the hooks it runs at points of its turn, and the subagents it can hand a task to. magpie writes these into each agent's own files in that agent's format, and takes back only what it wrote. Everything else in those files stays as it was. Package internal/library also gives agents RTK, a CLI that cuts shell output down before the model reads it, and billion-context's plugin, which folds a long session's older turns into summaries the model can open again, and lists, switches and copies each Pi's extensions and packages.

Responsibilities and sources of truth

Part Responsibility Source
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
A Remote magpie's skills and prompts A Remote magpie provider's editor has a switch, Use its skills and prompts (borrowOn in library.json, SetBorrow; KoiLx0 on X: manage them once on the remote machine). The remote serves its Library at GET /v1/magpie/library (gateway.SharedLibrary = library.Shared, to local or sharedWith callers; a held key is refused; no MCP servers, which the MCP switch covers; borrowed items are never passed on). keepBorrowed (10 minutes, and once on switching on) fetches it with the provider's key (provider.RemoteLibrary) and Borrow adds each skill and each instruction set as remote-<id>-<name>, recording a hash of what it wrote (Borrowed). It only ever changes what still matches that hash: a skill or set of the user's by the same name, one the user edited, and one the user removed after it was taken stay as they are (Kept, shown under the switch); an update or a drop moves the old copy to the backups; switching off takes out what is unchanged. The first set becomes the active one only when nothing is active. Collect/Put (sync backups) still carry borrowed items as ordinary ones. borrow.go, remote_library.go, TestBorrowRemoteLibrary
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
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. On a row, an agent's profiles (hermes#name, omp#name, claude#name, qwenpaw#id, WSL ones included) are one chip with a count, when an agent has more than one (profileChip in plugins/library/client.js, Yanzhongixuy on X: about twenty identical Hermes glyphs on every skill row); a click opens the app menu to pick profiles singly, and All still means every profile (library-profile-chip.test.cjs). 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. Every built-in agent is a target or is in noLibrary with why: OpenBot was added with neither and was in no picker (SSNQT on X), so TestEveryAgentInLibrary fails a new agent until it gets one (34 were in no picker when it landed, listed there under #5897). 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, targets.go, 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 (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
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, Cline and DeepSeek Harness (which reads it, and .dsh/skills, at the nearest folder up with a .git, else where it runs: a project folder inside a repository but not at its root doesn't reach it, #5172). 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, DeepSeek Harness's MCP, whose servers are rows in its profiles' patch layers with no project layer) 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. Nothing of magpie's goes into the project's git: what it placed is listed in the repository's own info/exclude (writeExclude, one block per project between excludeBegin(dir) and ignoreEnd, read by every worktree, never committed), and the project's .gitignore is left as it is (a block an older magpie wrote there is taken out, TestProjectKeptOutOfGitByExclude). A folder outside git gets no ignore file; once it is git inited, treesChanged sees no block and the next KeepLinked writes it (TestProjectOutsideGit). A project is the global set ± its own (WhyULose0 on X): ServersOff and SkillsOff turn a global server or skill off in the project for some agents (ProjectServerOff, ProjectSkillsOff; POST /api/library/projects/server-off and skill-off with dir, name/names, agents; none gives it back). Each is done the way the agent reads it for a folder (project_scope.go): Claude Code's record of the project in ~/.claude.json (projects[<main worktree's top>], claudeRoot) gets the name in disabledMcpServers, where magpie takes out only names it added (Claude.Off); Codex gets [mcp_servers.<name>] enabled = false in the project's .codex/config.toml, only for a server in its own config (CodexOff); a skill is skillOverrides.<name> = "off" in the project's .claude/settings.local.json (Overrides), a value the user set there is theirs (TestProjectServerOff, TestProjectSkillOff). Only those (ProjectOffAgents, ProjectSkillOffAgents) can take an off, and a skill an agent reaches through the skill router can't; the card shows a global agent that can't as always on, with why. With the MCP router on, a project that adds or turns off a server the router serves gives Claude Code and Codex their own hub entry, <agent>~<projectKey> (projectHubs): Claude Code's in its record's mcpServers (local scope), Codex's in the project's .codex/config.toml; the server added isn't written into .mcp.json then (TestProjectSetThroughRouter). Claude Code keys its record by the repository's main top folder, so a project in a subfolder turns its offs on for the whole repository. A git worktree of the project's repository follows the project (treeDirs, Trees): the project's folder in each worktree gets the same skills, servers and offs, and is let go when the worktree is removed; KeepLinked checks for new ones (keepProjectTrees, TestProjectWorktreeFollows). magpie library project … (#5193, library_project_cli.go) adds and removes a project and its skills through the same calls as the page (AddProject, RemoveProject, ProjectSkills, ProjectSkill, ProjectCopy); a skill added with no agents= goes to the agents the page's Skills menu picks (those the project's skills are for already, else every agent here with a project skills folder), and one not placed exits 1 with why (TestLibraryProjectCmd). A project card's Skills menu lists the skills by source as the Library does (skillGroups(true), whatever sort the list has; one group is the flat list), a heading over each that ticks or unticks the whole group (group in openProtoMenu, half-ticked while some are in; Elorynth on X, project-skills-groups.test.cjs). projects.go, project_mcp.go, project_scope.go, project_git.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). MiniMax Code reads AGENTS.md in its data folder ($MINIMAX_DATA_DIR, else ~/.minimax) before every conversation, so its target is that file (TestMiniMaxCodeInstructions). WorkBuddy and WorkBuddy AI keep theirs as a string in a JSON file: personalization.customPrompt in app/app-config.json of their folder, the Custom Instructions of the app's Personalization settings (Target.Field, instr_field.go). magpie's part goes into that string between the same marker lines, after the user's own prompt, and a Field write goes through edit.SetJSON, so every other key, its order and its indentation stay as the app wrote them; taking the part back leaves the file as it was, the field (and a personalization object nothing else is in) going out when it holds nothing. A file that is not JSON, or a field that holds something other than text, is unknown: it is reported and written over by nothing (TestWorkBuddyInstructionsAreAJSONField, TestWorkBuddyInstructionsFromNothing, TestWorkBuddyInstructionsUnreadFileIsLeftAlone, TestWorkBuddyInstructionsImport). The app's config service loads the file as it starts and writes it whole on a save (AppConfigService, 5.5.6's app.asar), so a change made while it runs may need a restart of the app, and may be lost to its next save of any setting; this has not been tried against a running app. 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/<name>), 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/<name> (#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:<port>/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). The editor's command is a box that wraps, so a long line is read whole, and Enter still saves it (hema_17384 on Discord). Its Form JSON switch shows the server as JSON in Claude Code's .mcp.json shape, the one Copy config… gives for it (jsonOf in plugins/library/client.js), with ${NAME} references as written. An edit there is read as a paste is (serversIn) and becomes the form's at once. JSON that isn't one server's keeps the dialog from saving or going back to the form, and counts as unsaved. The note, the agents and sync stay in the form (library-mcp-json.test.cjs). A server's and a skill's Note (youyo.p_10001 on Discord) is the user's own word on what it is for: one line of at most maxNote (200) characters, whitespace run together (checkNote), as a hook's description is. The row shows it in place of the command or description, and its tooltip still gives that line. The skills' filter reads it too. A sync carries it (a server whole, a skill as CarriedSkill.Note), and no agent is given it, through the MCP router or not (TestNoteNeverGiven, TestNoteCarried). A skill's is set by itself (SkillNote, skills/note) from the skill's reader. 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 <package> args (a registry package, no other npx flag) is given to an agent on this machine as node <the package's bin> 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). A remote server holds several accounts (Elorynth on X), one in use that every agent is given: sets of headers are Server.Accounts with Server.Account the one in use ("" is the server's own Headers), laid over Headers by live in through, remoteHeaders and hubKey, so a switch rewrites each agent's file (TestServerAccountsSwitchEveryAgent); a save from the editor, which doesn't send them, keeps them, and a backup carries no account's key (TestServerAccountKeysAreSecrets). magpie's OAuth sign-ins are mcpauth records, the one in use at m[name] and the others in Spare (Use, RemoveAccount, StartAccount), which the gateway's /mcp/<name> sends from its next request on; an agent's existing upstream Mcp-Session-Id isn't reset by a switch. API /api/library/mcp-account; GUI headerAccounts and acctList (mcp-accounts.test.cjs).
MCP server on/off ServerOn (POST /api/library/servers/on with name and on, `magpie library mcp off on ) turns a server off for everyone without removing it (swang20201 on X, Docker gateway mode, where a server ticked for no agent is still given to every app at the MCP router's address). Off, it is Hiddenwith its agents kept inPausedandAgents empty, as a plugin's server hidden from agents is (PluginServerOn, [Plugin tools](plugin-tools.md)): no agent's file has it, no project's (syncProjectMCP skips it, keeping the project's own agents for it), no subagent names it (renderSubagent), the router lists and calls it for nobody, and a process the router held for it ends, since HiddenandPausedare part of itshubKey. Its command, URL, env, headers, sign-in, DisabledToolsand note stay in library.json. On, the agents inPaused get it back (none when it had none, so the router gives it to other apps again), as before it was turned off; giving it agents (ServerAgents, the CLI's mcp agents) turns it on with those (save), while Turn all on (EveryServerAgents with every agent) leaves it off. The row's switch sits after its agent chips (serverSwitch in plugins/library/client.js); off, the row is dimmed, its chips take no click, and it is health-checked only on a click (TestServerOnKeepsAndRestores, TestLibraryMCPOffOn, library-mcp-on.test.cjs`).
MCP router With MCPHub on, syncMCP gives each agent that can take it one entry, magpie, at the gateway's /mcp/magpie/hub/<agent>, in place of the servers ticked for it; magpie runs those servers itself, once for every agent. MCP router, mcp_hub.go
MCP market MarketServers lists the featured servers that match a search, then the MCP Registry's; a search that is an address (a repository, a page, an endpoint, a package; market_addr.go) finds the ones at it, and CustomAt offers one to fill in by hand when none is. The registry lists no server by a repository's folder, so a GitHub address naming one (#subdirectory=, /tree/<ref>/…, parseRepoAt) is read first: the folder's pyproject.toml names the program, and the README's "env": {…} examples the keys, offered as uvx --from git+https://github.com/o/r#subdirectory=p <program> (fromRepo, CyberCaius on Discord: volcengine/mcp-server's askecho search). A bare repository is read so only when the registry has nothing at it, and a PyPI page, or a one-word search naming mcp the registry lists nothing by, asks PyPI (fromPyPI, uvx <package>). Of several README keys none is required, since a README often has the user pick one way to sign in (envInputs; TestMarketServerInRepoFolder). Only Python projects are read from a folder; a Node one there still gets the blank form. A registry package is started the way its entry says (launchLine): its runtimeArguments are the runner's options (uvx -p 3.13, npx --package, docker's mounts) and the program's own words (Serena's start-mcp-server), then its packageArguments; an executable not named after the package is reached with uvx --from <pkg> <bin> or npx --package <pkg> <bin>. The shipped crawl keeps each package's executables (bins, from npm's bin and the wheel's console scripts); a package with none, several with none standing out (pickBin), or a required option magpie can't fill isn't offered. A server installed from the market before, still on the line magpie gave it then, is given the new one on load (healMarketLines; fwxkogaia on X, TestRegistryLaunchLines, TestInstalledMarketLineHealed). market.go, market_launch.go, market_repo.go
Skills A skill is a folder with a SKILL.md. It goes by the name its front matter gives, made fit for a file name (ASCII letters, digits, _ and -); a name that would lose a letter or digit that way (one in another script, CTF•密码学) or none goes by its folder's name instead, and a skill at a repository's top by the repository's (nameFor, srcFolder). A front matter setting disable-model-invocation: true marks it "Manual only" in the page, in the library and in the agents' own (meta.Manual, SkillView.Manual, FoundSkill.Manual; sunset3279 on Discord): Claude Code runs such a skill only on the user's /name. A front matter that doesn't parse, or a value that isn't a bool, is not known to be, and gets no mark (TestSkillManualFromFrontMatter, skill-manual.test.cjs). Two skills a probe names alike are listed once (unhiddenFirst), so names that fell to CTF, Strix and nothing listed asdfgh1445/ctf-super-hub's 35 skills as 16 (tnt1223 on Discord, TestSkillsNamedInAnotherScriptAllListed). It comes from GitHub, from any other git repository, from a folder on this machine (linked, so editing the folder edits the skill) or from the market. A git repository (kind: git, sunset on Discord: GitLab, a company's own GitLab) is any https, http, ssh or file:// address, git@host:group/repo.git, a bare host.name/group/repo, or a GitLab or Gitea page of a folder (/-/tree/<ref>/<path>, /-/blob/…, /src/branch/…; a branch with a / in its name is read as its first segment) (gitSource). It is fetched by the user's own git (proc.FindTool), so their credential helpers and SSH keys reach an intranet host: git init, then fetch --depth 1 --no-tags -- <url> <ref> and checkout FETCH_HEAD into a magpie-skill-* folder, then its .git is removed (fetchGit). What the user typed is data: an address starting with - and a transport:: address (ext::, fd::, file::) are refused before git runs, the address follows --, git runs with protocol.ext.allow=never and core.symlinks=false, no shell, GIT_TERMINAL_PROMPT=0 and (unless the user set an SSH command) ssh -o BatchMode=yes, so a sign-in it can't make fails instead of waiting. An address with a password or token in it is refused: library.json is shown and backed up. Git missing, a sign-in refused, a host key unknown, a branch missing and a host unreachable each say so (gitError; TestGitSourceReads, TestInstallFromGitRepo, TestGitTreeURLInstallsFolder, TestGitMissingSaysSo, TestGitSignInRefusedSaysSo, TestGitRefusesOptionsAndTransports, TestGitErrorsSaid). Each agent gets a link or a marked copy (#896, SkillHow). An agent in a WSL distro gets a link too, to the distro's one copy of the skill, magpie's, in ~/.local/share/magpie/skills (Target.Store, storeSkill; cutemmuu on X): the distro can't follow a link to the library's folder on Windows, and a link Windows makes through \\wsl.localhost is an empty folder in the distro, which in turn shows Windows its own links as entries it can't read, follow or remove, so the link is made, read and taken away in the distro by wsl.exe (agent.WSLSymlink, WSLReadlink, WSLRemoveLink; TestWSLLinksLive and TestWSLSkillsLinkedLive on a real distro with MAGPIE_WSL_TEST_DISTRO). An edit made through the link is in the distro's copy, which takeEdits reads as any copy of magpie's (TestWSLEditThroughLinkReachesTheLibrary); a copy no agent there links to or is given any more goes, to the backups when edited (sweepWSLStores, TestWSLStoreSweepKeepsEdits); a folder there that isn't magpie's is never touched, and each agent it is in the way of says so. The copy isn't put in the distro's ~/.agents/skills, since every agent there reading that folder would get each skill, ticked for it or not. An agent set to copies gets one of its own, as does one whose skills folder or the store is on a Windows drive (#4502), where the distro's link is one Windows can't read. A copy an agent there was given before is made a link on the next sync, its edit taken first and a losing edit set aside (wslRelink, TestWSLOldCopiesBecomeLinks). A copy's mark keeps the hash of what was copied, so a sync knows a copy unchanged since then is current without reading its files (copyIsFresh, #1031); other copies are hashed. A skill of the user's own is made with CreateSkill (POST /api/library/skills/create, Skills > New skill; josephBenchap on X): a name (checkName, and not one the library or an agent has, compared without case, nor a folder in the way) and a one-line description of at most 1024 characters make skills/<name>/SKILL.md with name and description front matter, listed with no source and given to the agents picked; the page then opens it in the reader (TestCreateSkill, library-new-skill.test.cjs). A skill an agent has of its own (foundSkills, the page's "In your agents") is brought in with ImportSkill, or taken out of every agent that has it with RemoveFoundSkill (#1303): its folders and copies of the very same files, its shared ~/.agents/skills entry and a folder of it in the library's own folder go to the backups, its links are taken away, and a folder elsewhere it only links to, or another skill by that name, stays. Several go at once with RemoveFoundSkills (POST /api/library/skills/remove-found-some, wongxy on Discord): the "In your agents" heading's own Select picks them, and Remove… asks once, naming the count, before one change takes each out as RemoveFoundSkill would. A name that can't be taken out is left as it was, in Result.Unremoved, and stays picked with its error in its row's place (foundErrs); when none can go the change fails and nothing is touched. This Select and the library's are never on together: while one is on the other is dimmed, saying why, so neither click takes the other's bar away from above the pointer (TestRemoveFoundSkills, found-skill-pick-remove.test.cjs). A repository is fetched as one tarball of at most maxFetch (200 MB); a bigger one is fetched file by file from its tree (fetchSkillFiles), only as far as the caller reads: a link to a folder and an update ask GitHub for that folder's own list (treeUnder, git's ref:path; the whole list when that fails), the market fetches only the skills whose folder is the one it installs (#2794, sickn33/agentic-awesome-skills' 8,589 skills are 287 MB together), and a fetcher keeps such a part apart from another skill's of the same repository, which would otherwise read as removed (fetcher.get, TestMarketSkillFromAHugeRepository). GitHub's list is read up to maxTree (64 MB; that repository's is 11 MB) and an answer over the cap a caller gives apiGet, or one cut off, is an error saying so, never a body cut short for JSON to trip on (ye4241's TestRepoTreeBigList, TestApiGetWholeAnswer); a list GitHub truncated itself is too big (TestTruncatedListIsTooBig). And a skill over 200 MB on its own is left out rather than failing the rest: the probe lists the others and names it in Probe.Left, under the list in the page and in the TUI's flash. Only when every skill is too big does the fetch fail (#2062, mikubaka88/CCFA-Skills' 297 MB ccf-paper-writer; TestOneSkillTooBigLeavesTheOthers, skill-too-big.test.cjs). A probe keeps its download for the install from it for 15 minutes (keepProbe, probeLife), and removes it when it is probed again or that time is up, not at the next probe, which may never come. A download a magpie that quit left in the temp dir goes at the next probe once it is an hour old (sweepStaleDownloads). The package's TestMain gives the tests a temp dir of their own and fails a run that leaves a magpie-skill-* in it (#2321, TestProbeDownloadEndsWithIt, TestStaleDownloadsSwept). skilltree.go, skills.go, skillgit.go, skill_how.go, skill_edits.go, skill_from.go, skill_beside.go
Skills market MarketSkills lists skills.sh's most installed and what its search finds. magpie's own skills (featuredSkills), in magpie-community/plugins, go first, marked official: magpie-setup has an agent set magpie up as the user asks through its commands (providers, accounts, agents, routing groups and rules, gateway keys and limits, models, the library), and magpie-quota lets an agent read magpie quota --json and wait with magpie quota wait. Their commands live in magpie's CLI, so a change to a command either uses gets the skill updated in that repository. Until skills.sh lists one it has no count of installs and no skills.sh link (featured). InstallMarketSkill installs any of them from its repository. market.go
Skills a repository or folder added A check for updates (CheckSkills) also asks, for each GitHub repository and ref the library has skills from, GitHub's list of its files (repoTree, one API request, free when the ETag still matches). Only when that list has a skill folder beside the installed ones (under newBase, their deepest common folder) that the library doesn't have and hasn't offered does findNew fetch the repository for the skills' names and descriptions. SeenSkills records per repo@ref the paths the install picker showed and the ones set aside, so they aren't offered again. The finds live in memory (newFound) and reach the page as View.NewSkills; AddNewSkills gives each to the agents that have its repository's other skills, and IgnoreNewSkills sets it aside (/api/library/skills/{add-new,ignore-new}). A git repository on another host has no such list: when git ls-remote gives its ref a head, findNewGit reads the fetch the check shares (fetcher), once per head while its finds are kept (gitLooked), and offers the skills under newBase with the address as the library has it, .git and all, so an Add keeps the same repo@ref. A folder the user added linked skills from is kept as folder:<path> in SeenSkills (offered, at install), which is also how the library knows which folder to look in again: findNewFolder reads it as Add from folder does and offers a skill folder there the library doesn't link, hasn't offered, and has no skill by that name of; a folder that can't be read keeps what was found. View.CheckFolders (addedFromFolders, which reads no folder) puts Check for updates on the page with only linked skills, and makes checkDue true. A check never adds or writes a skill: each is offered, and one the user removed or set aside isn't offered again. A folder added before this kept no folder: key and is looked in only once the user adds from it again (refeccd on Discord; TestCheckSkillsFindsNewInGitRepo, TestCheckSkillsFindsNewInFolder, skill-new-in-repo.test.cjs). skillnew.go, skillcheck.go
Skill groups The page groups skills by SkillView.Repo, the repository each came from (tracer.repoOf): its GitHub source, CC Switch's Origin, From, the skills CLI's lock or the git checkout a linked folder is in. That checkout is the one git finds (provider.GitAt in gitRepoOf): an empty .git between the skill and its checkout is passed over, as git passes it over, and a .git file that names no repository (a worktree left behind) is none (#3675, TestSkillRepoTraced). A lock entry of sourceType: well-known (a site's kit at its /.well-known/agent-skills/) is grouped by its sourceBaseUrl as host/path (wellKnownBase), not by each skill's own sourceUrl: Feishu's lark-* skills are one group and Fish Audio's another, while two kits under one host with different base URLs stay apart. An older entry with no base URL takes the part of its sourceUrl before /.well-known/, and one with neither is grouped by its sourceUrl as before. Such a kit is never fetched from GitHub by Group again, even when it reads like owner/repo (a GitHub owner has no dot), and its heading's link opens the site (#1862, TestWellKnownKitGrouped). From is written when a repository is probed (installing from it again, noteFrom): for a skill with the very same SKILL.md, and for one traced to nowhere by a name the repository has when the library has others from there, since a pack added a while ago is mostly older copies edited there since (White Immortal on Discord: 20 of mattpocock/skills' 38). Group again (RegroupSkills, POST /api/library/skills/regroup) fetches each GitHub repository the skills are traced to and does the same; it fails only when none could be fetched. A skill traced to another repository is never moved. A group's (or part's, or the Select bar's) agent chips count, give and take only the skills magpie decides for each agent: one kept in ~/.agents/skills is in SkillView.Always for the agents that read that folder themselves, so a chip's agents-some for such an agent leaves it out, its tooltip and the status after a click say how many it still reads itself, and an agent that reads every one of them itself has a lit, locked chip as the row's is, which sends nothing (groupChips in plugins/library/client.js). The heading says how many of its skills are in ~/.agents/skills. A row's locked chip is lit with a lock on its corner, not greyed like a chip that can't be given the skill (#1862, skill-group-shared.test.cjs). Collapse all / Expand all, beside the sort, folds or opens every group the list shows at once (foldAllButton): without a filter it sets each group's kept fold (magpie.libSkillFolds), as a click on each heading would; while filtering, only the groups the filter shows, till the filter changes (unfiltered), leaving the kept folds alone. It reads Collapse all while any shown group is open, is hidden with fewer than two groups (A→Z, or a filter one group matches), leaves a part's own fold as it is and sends nothing (#1862, skill-fold-all.test.cjs). skill_from.go, plugins/library/client.js
Skill updates A skill from GitHub (kind: github, a market install among them) keeps the commit it was fetched at and Hash, the hash of its files as fetched. CheckSkills asks GitHub for each one's last commit and keeps the result in memory; View.CheckDue says none was checked since magpie started, or not for checkEvery (12 hours), and the page then checks by itself as the skills open (#1449). editState says a skill was changed here when the library's folder no longer hashes to Hash (.DS_Store aside), or an agent's copy was edited since its mark and not yet taken in; the view's edited says so. What installing a skill's dependencies or running it writes in its folder is no change (fromInstall: node_modules, .venv, venv, __pycache__, .pytest_cache, .mypy_cache, .ruff_cache folders, *.pyc/*.pyo, and package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lock, bun.lockb, uv.lock written again; ggbr on Discord): Own is the hash of the files as fetched leaving those aside (ownHash), and onlyInstalled compares the folder with it, or for a skill fetched before Own was kept with Hash (so a lock file the install wrote again still reads as changed until its next update). An update carries those entries over to the version fetched where it has none of its own (carryInstalled), so they aren't installed again. UpdateSkill refuses such a skill with *EditedError unless told to replace it (the page's own Update asks first; the CLI takes --replace-edits), and UpdateSkills/UpdateSomeSkills leave it as it is, in Unupdated. A replaced version that was changed, or that can't be told (no Hash), is moved to the backups (keepReplaced). Skills the skills CLI manages (npx skills, ~/.agents/.skill-lock.json, or $XDG_STATE_HOME/skills/.skill-lock.json when that is set, both read with the XDG one winning) are only grouped: the CLI updates them (npx skills update). A linked folder, a skill imported from an agent and a From-only skill have no remote to check; one CC Switch installed (Origin) can be updated by hand but isn't checked. A skill from another git repository (kind: git) keeps the repository's head commit it was fetched at in Commit, and Hash. A check runs git ls-remote for the ref (gitRemoteHead): the same head is current; another one is fetched shallowly, once per repository and ref in a check, and the skill's folder hashed, so a commit that left the skill as it was is current and its head is kept as Commit (checkGitSkill). Its *EditedError and the page's Changed here, Update and the question before replacing a change name that repository, not GitHub (editedError, skill-git-source.test.cjs). New skills in such a repository are found from its fetch (findNewGit, above); Group again, icons and the market are GitHub's only. A skill whose source was read whole and no longer has its folder or SKILL.md was removed there (goneFrom; スライム on Discord): UpdateSkill returns *GoneError, UpdateSkills/UpdateSomeSkills list it in Result.Gone, not Unupdated, and a check gives it status gone. Each records Skill.Gone (the view's gone), cleared when a check or an update finds it there again. A fetch that failed, a skill left out of a fetch as too big (leftOutAt) and a folder that can't be read are unknown, never gone. Nothing is taken out by itself: RemoveGoneSkills (POST /api/library/skills/remove-gone, magpie library skill rm --gone [--yes], the TUI's d on the row) takes the ones named, or every one marked, as RemoveSkills does, folders to the backups, and keeps one found in its source again. The page tags such a row Removed upstream with no Update, says them apart from failures after Update all, and offers Clean up N in the group's heading (in the bar with one group), which asks first, naming each one and which was changed here (confirmRemoveGone, skill-gone.test.cjs). skill_changed.go, skillcheck.go, skillgit.go, skills.go
Hooks A Hook (#1790) is a command, an event, an optional matcher, a timeout and the agents ticked for it. Its optional Description (#2011) says what it is for in any language, since its name is letters, digits, - and _: one line of at most maxHookDescription (200) characters, shown under the name; only library.json keeps it, and no agent is given it. Its event is portable (HookEvents: turn-end, after-tool, before-tool, prompt, session-start, each under the agent's own name) or an agent's own ("codex:PermissionRequest"), which only that agent is given. A portable tool event can be narrowed to shell or edit tools, each agent's own tool names for them. A session-start hook can be narrowed to some starts (#5604, NEKO-CwC: re-inject a file after compaction alone), one or more of HookStarts (startup, resume, clear, compact, fork, Claude Code's words) joined by ` ; startMatcherwrites each agent's own matcher for them. Claude Code and Codex take the starts as written (Codex reads a
Variables An EnvVar (paopao_baobao on X) is a name, a value and the agents ticked for it (internal/library/env.go). Claude Code gets it in settings.json's env, Codex in config.toml's [shell_environment_policy.set] (envFile, writeEnv); an agent with no such setting is greyed on the tab, saying why. syncEnv records what it wrote in Applied.Env and never overrides the user: a name the file already sets to another value is left as it is and reported as a problem on the row (env:<name>), and a recorded value the user changed in the file is theirs from then on (the record is dropped, a removal or a turn-off leaves it). Turning an agent off or removing the variable takes out only the recorded, unchanged value. Codex's spelling is respected: a set sub-table or an inline set = {…} is edited, a dotted spelling is refused with left as it is. An unreadable or wrongly typed file is an error, never empty, and nothing is written. Names are [A-Za-z_][A-Za-z0-9_]*, at most 128, values at most 8192 bytes. Variables are carried with the library (see below). Tests: TestEnvWrittenAndTakenOut, TestEnvNeverOverridesTheUsers, TestEnvValueChanged, TestEnvCodexInlineSet, TestEnvUnreadableFileLeftAlone, TestEnvChecked, library-env.test.cjs.
Subagents A Subagent (#2283) is a name (lowercase letters, digits and -), a one-line description, a prompt, and the library's skills and MCP servers it uses, given to the agents ticked for it. syncSubagents writes it as a file of its own in each agent's user-level folder, in that agent's format (subagentSpecOf): Markdown with YAML front matter in ~/.claude/agents (with skills and mcpServers), ~/.factory/droids (with mcpServers), ~/.config/opencode/agents (mode: subagent), ~/.gemini/agents, ~/.qwen/agents, ~/.grok/agents, ~/.cursor/agents and ~/.copilot/agents (<name>.agent.md); a TOML role (name, description, model when set, developer_instructions) in $CODEX_HOME/agents. Skills and servers are named only where the agent's file can name them, and only those the library has. A subagent's optional Model (a model or routing group of Codex's list, subagentModels in /api/library) is written only into Codex's role (luckymanjc on Discord): the role file is a config layer, and Codex lays its model over the one its lead names in spawn_agent (apply_spawn_agent_role after apply_requested_spawn_agent_model_overrides in codex-rs core/src/agent/child_config.rs), so the subagent's requests carry it and the gateway routes them as any other. Codex's subagent model on the Agents page (CodexSubagentModel), when set, still rewrites every subagent's request, and the editor says so. Without one, a Codex subagent runs on the model its lead names, else the lead's own. The page lists, per agent, whether it binds skills, servers and a model (SubagentAgentView), names the agents that run a subagent on their own pick, and greys out an agent that takes none. subagents.go
Claude plugins A Plugin (FakeshadowzZ on X) is a Claude Code plugin kept as one item: .claude-plugin/plugin.json, skills/<name>/SKILL.md, agents/*.md, hooks/hooks.json and .mcp.json, from a folder, a git address or a marketplace.json (ProbePlugins, InstallPlugins; a marketplace entry with a relative path, or a github/url/git source, is fetched when installed). Its files are copied to <library>/plugins/<name>; ${CLAUDE_PLUGIN_ROOT} is that folder and ${CLAUDE_PLUGIN_DATA} is <library>/plugin-data/<name>, which an update keeps. Its parts are ordinary library skills, MCP servers, hooks and subagents, each tagged Bundle: <plugin>, so every agent gets them through the code of its kind and the old tabs go on working; the plugin holds the names, its agents and Off. PluginAgents sets every part's agents, PluginOn clears them (kept in Agents for turning it on again) or gives them back, RemovePlugin removes the parts, and UpdatePlugin reads the source again. A hook whose Claude event and matcher have a portable event becomes it (Stop turn-end, PostToolUse after-tool, PreToolUse before-tool, UserPromptSubmit prompt, SessionStart session-start; Bash is shell, Edit/Write/MultiEdit is edit); any other event is claude:<Event>, for Claude Code only. Subagents go to the agents in SubagentAgents. A part whose name the library has gets the prefix <plugin>-: the user's own item is never written over or removed. Slash commands, LSP servers and hooks that aren't a command are listed in Left and shown, not carried. A backup file carries the parts but not the plugin record or its folder, so on another computer they are ordinary items whose ${CLAUDE_PLUGIN_ROOT} paths don't exist (TestPluginImportCarryOnOffRemove, TestPluginNameClashKeepsTheUsersOwn, TestPluginMarketplaceAndUpdate, TestPluginRefusesWhatIsNone, library-plugins.test.cjs). plugin.go, plugins/library/client.js
Backups Before a change first writes an agent file, backups copies it to BackupDir, one folder per change. The last keepBackups (30) changes are kept. The Backups button at the top of every tab, beside Library folder, opens that folder (libHead; Dade on Discord found it at the foot of a long page). backup.go
RTK SetRTK runs rtk's own installer (rtk init -g …) for an agent being switched on. For one being switched off, it removes exactly what the installer wrote, using magpie's own code, which works even with rtk gone. An rtk.exe in one of winget's folders that winget has no record of (winget list says so, or its records name another folder; netube99 on X, 0x8A150014) is upgraded from rtk's own Windows release over the file a WinGet\Links link points to, not by winget upgrade. ReadRTK reads each agent's files to say which have the hook. An agent gone for its CLI (CLIMissing, #2254) isn't offered rtk, but one that still has the hook is listed so it can be taken out. rtkSpec.blocked stops the installer where it would break an agent. rtkSpec.env tells the installer the agent's folder where rtk would pick another: Hermes Agent's is appdir.HermesHome (%LOCALAPPDATA%\hermes on Windows), which rtk is given as HERMES_HOME, since rtk 0.51 knows only $HERMES_HOME and ~/.hermes. Antigravity CLI (agy, #2202) gets rtk 0.51's own plugin for Antigravity, plugins/rtk in its global customization folder ~/.gemini/config (plugin.json, hooks.json with PreToolUse → rtk hook antigravity, rules/AGENTS.md), which agy plugin list lists; switching it off takes that one folder out. rtk 0.50 knows Antigravity only per project and fails rtk init -g --agent antigravity, so an older rtk is blocked (agyBlocked) and the row says to update RTK. OpenCode 2 loads only the plugin rtk 0.52 on writes (one default object with id and setup(), rtk-ai/rtk#4187); an older rtk's plugin is for OpenCode 1 and OpenCode 2 refuses it, so with an OpenCode 2 here an older rtk is blocked (openCodeBlocked) and the row says to update RTK (#2295). Under OpenCode 2, an old plugin left from before an rtk update counts as off once the rtk here can write the new one (openCodeHas), so switching it on writes the new one over it; with an older rtk it counts as on, so it can be switched off. Factory's Droid (lml0664 on Discord) gets rtk's own rtk init -g --agent droid, given Droid's folder as FACTORY_HOME_OVERRIDE; rtk puts its Execute group (rtk hook droid) in the root hooks.json, or in settings.json's hooks.PreToolUse where Droid's hooks already are, so droidHookFiles reads and switches off all three places rtk 1.1.0 may use (hooks.json, hooks/hooks.json, settings.json), leaving the user's own hooks. rtk before 0.44 has no Droid agent, so it is blocked (droidBlocked). A detected agent RTK has no hook for at all is still listed, from rtkNoHook, with the reason and a switch that can't be turned on (dsh: its hooks can allow or deny a command but not rewrite it, and rtk init has no --agent dsh; Grok Build and Grok App: rtk init has no Grok or Grok App agent, so both are listed with the switch off; Qoder and Qoder CN: rtk 1.1.0 has no Qoder agent; Cline and Kimi Code: `rtk init --agent cline kimiwrites only one project's.clinerulesorAGENTS.md, instructions with no hook, and Kimi's refuses -g). RTK 1.1.0's Trae, Windsurf, Kilo Code and Mistral Vibe have no magpie agent. The page's No RTK hook tag gives each agent's own reason and rtk-ai/rtk issue (rtkNoHookWhyin plugins/library/client.js: dsh #3847, Grok Build and Grok App #2136, Qoder and Qoder CN #1327, Cline #3841), and an agent with no entry gets no link;TestRTKNoHookIssuesAreEachAgentsfails when the page andrtkNoHookcite different issues, or two agents cite the same ones without a reason insharedRTKIssues`.
RTK in WSL An agent in a WSL distro (claude@wsl:Ubuntu) is listed by its kind (rtkKind), and its hook runs in the distro, where Windows' rtk.exe is no command, so it gets the distro's own rtk (lex on Discord). rtkDistroOf asks the distro with wsl.exe -d <distro> -e sh -lc where rtk is (a login or interactive shell's PATH; else ~/.local/bin or ~/.cargo/bin, offPath), kept 15s; ReadRTK lists one RTKDistro for each distro its agents are in. Install RTK in WSL <distro> (InstallRTKIn, POST /api/library/rtk/install with distro, magpie library rtk install <distro>) runs RTK's own Linux installer in the distro (curl -fsSL …/install.sh | sh, wget where there's no curl). Switching an agent on runs the distro's rtk there (rtkInstallWSL: rtk init -g … with its folder on PATH, Claude Code pointed at a folder of its own for the OpenCode and Cursor installers), and reads and edits its files under the distro's home as magpie opens it (rtkClaudeDir, rtkCodexDir, rtkHome). A distro that isn't running is never started (#3896): rtkWSLLive and rtkDistroOf check agent.WSLRunning first, its agents are listed asleep with the switch off, and switching or installing says to start it (TestRTKWSLAsleep). The page gives each distro a card (rtkDistroCard in plugins/library/client.js; library-rtk-wsl.test.cjs). rtk_wsl.go
billion-context SetBili runs bili's own bili plugin install <agent> for an agent switched on and bili plugin remove <agent> for one switched off; ReadBili reads bili plugin list (the agent column, then the status; installed… is on, not installed off, anything else shown as it is). InstallBili runs its README's npm install -g billion-context --prefix=~/.local (npm install -g billion-context on Windows), and biliPath finds bili there when it isn't on PATH. Offered only where bili's plugin works with magpie in front (biliLanes): Pi, omp and OpenCode load it in process and still send to magpie, and Claude Code goes through bili's proxy, which forwards to the gateway (ANTHROPIC_BASE_URL …/bili/<magpie's address>). Codex's lane is an MCP server only, ZCode's routes only its own provider, Kimi Code's renames default_model to bili-kimi at every start and dsh's install failed through dsh's pnpm, so none of those is offered; neither is an agent in WSL. bili's remove doesn't restore a file: it leaves "packages": [] in Pi's settings and extensions: in omp's config, and after magpie rewrote Claude Code's settings.json it deleted ANTHROPIC_BASE_URL (Claude Code then went to Anthropic) and put back its own DISABLE_AUTO_COMPACT. So switching on keeps each file it writes as it was before and after (bili-plugins.json in magpie's config folder), and biliRestore after the remove writes the file before back byte for byte when nothing changed it since, else merges JSON (biliMergeJSON): what the install changed and is still as installed goes back, a value changed since stays, and what the remove changed beyond the install is put back. Without a record (bili installed outside magpie), only a Claude Code ANTHROPIC_BASE_URL the remove took out goes back to the address bili forwarded to. The .bili-bak and .bili-last files bili leaves beside each file go with it. bili's Claude Code install also writes DISABLE_AUTO_COMPACT "1" into the shared settings.json, so a session bili doesn't fold (the Claude desktop app's Code tab, which sets its own ANTHROPIC_BASE_URL, bili's #2290, or a window larger than the one magpie serves) has no compaction left and Claude Code answers every message with "Prompt is too long" without sending it. biliKeepCompact writes "0" in its place after the install (bili's own reinstall keeps a value that isn't "1"), unless the file had a DISABLE_AUTO_COMPACT of the user's own before; keepBiliCompact, from KeepLinked at start, does the same for a plugin installed before and has the record say "0", so switching off still takes it away. Zed has no plugin of bili's; bili's README lists it through the launcher (bili zed, Linux only, which leaves a provider on loopback direct, so it never passes magpie's gateway) and, on every system, the /bili/ prefix its docs give for a client whose model address can be edited. So Zed is a URL lane (biliURLLanes, bili_url.go): switched on, biliServe has bili start --port 8787 answer (GET /__bili/health says {"ok":true}; one the user runs is used as it is, else magpie runs its own under KeepLinked's context, logging to bili-start.log), then agent.ZedThrough puts the magpie provider's api_url at http://127.0.0.1:8787/bili/<gateway>/v1 and saves the key for that address in the system's credential store, where Zed looks it up by the address. Zed must be on magpie first. A pick and a sync keep the prefix while magpie answers through it (zedReach, the proxy recognition of #1985); switched off, api_url goes back to the gateway and magpie's bili start ends when no agent goes through the prefix. keepBiliServe, from KeepLinked, starts it again at magpie's start while Zed is on. TestBiliZedThroughPrefix, TestZedThroughBili. Hermes is a URL lane too: bili's Hermes plugin (bili plugin install hermes, hermes-plugin/__init__.py apply_env) routes Hermes by setting HTTPS_PROXY in its process and nothing else, so magpie's provider at http://127.0.0.1 never passes it and nothing would fold. Switched on, agent.HermesThrough puts the base_url of magpie's entries (magpie, magpie-anthropic) behind the prefix in the connected config and every profile that has them; hermesEntries keeps a prefix on loopback with a path (hermesPrefix) across a pick and a sync, and wiringOff takes it as magpie's (reachesMagpie). A profile that gets magpie's entries later goes to the gateway until Hermes is switched on again. TestBiliHermesThroughPrefix, TestHermesThroughBili. dsh is a URL lane too, for the same reason (dsh plugin add billion-context rides dsh's process proxy settings, which a route at http://127.0.0.1 never takes): agent.DshThrough runs dshSyncFresh with the gateway's address behind the prefix, so magpie's route in every profile and the home layer has its baseURL there, and dshReach reads the prefix back from the profiles' routes (a loopback path before the gateway's address) so a sync, a pick, Check and the serving round (dshWiredWith) keep it. A profile dsh makes later gets it with its route. TestDshThroughBili, TestBiliDshThroughPrefix. What bili saved is its own count (bili_saved.go): bili 0.1.213 has no command that prints it, and its running proxy serves its dashboard's numbers at GET /__bili/overview, summed over every session in its one store for every agent and lane. readBiliSaved asks the bilis registered in <state>/instances/<id>.json ($XDG_STATE_HOME or ~/.local/state, then billion-context, on every system), newest startedAt first, loopback http origins only, within 3s in all; a file a crashed bili left behind just fails. The first answer is BiliView.Saved (netSavedTotal as net, only with hasFoldData; grossSavedTotal, which bili calls an upper bound; foldsTotal, sessions, requests) and is kept in bili-saved.json in magpie's config folder, shown with live: false and its time when no bili answers. magpie never starts a bili to ask (it would auto-update and start watchers). TestBiliSavedFromRunningBili (the literal overview in testdata/bili), TestBiliSavedNoFolds, TestBiliSavedNoneYet, TestBiliSavedOnThePage, TestBiliLoopback. TestBiliClaudeKeepsAutoCompact, TestBiliOnOffExact, TestBiliClaudeKeepsMagpiesRoute, TestBiliOffWithoutRecord; the page's tab is renderBili (library-bili.test.cjs). bili.go
Pi extensions Each Pi here, this computer's and each WSL distro's (piPlaces), with the extensions and packages it loads, read by Pi's own rules (@earendil-works/pi-coding-agent 1.4: resolveExtensionEntries, isEnabledByOverrides, applyPatterns). An extension is a .ts/.js file or a folder (package.json pi.extensions, else index.ts, else index.js) in <agentDir>/extensions, or a path its settings.json extensions lists; a package is an entry of settings.json packages. Built-in extensions (builtin:mcp and the rest) aren't listed: builtin:mcp carries the MCP servers magpie gives Pi. SetPiExtension writes what pi config writes (-path off; the - taken out and +path only where still excluded, on); SetPiPackage sets a package's four filters to [] (off) or takes them out (on), and refuses an entry that already picks some parts (filtered, changed in pi config). CopyPi gives a package to another Pi as its settings.json entry, which Pi installs itself when it next starts (npm into <agentDir>/npm, git into <agentDir>/git), never as copied files; it refuses a local package, and one the other Pi has already by Pi's identity (npm name, git host/path). An extension is copied as its file or folder into the other's extensions, leaving out node_modules, .git and symlinks, never over one of the same name, and the page says to run npm install there when it has dependencies (leokon3 on Discord). A settings.json that can't be parsed lists nothing and is never written; a stopped distro is never started (asleep); every write is backed up first. GET/POST /api/library/pi, POST /api/library/pi/copy; the Library's Pi packages tab, shown while a Pi is here (renderPi in plugins/library/client.js; library-pi-extensions.test.cjs). piext.go
Pi market MarketPiPackages lists npm's packages with the keyword pi-package, the way pi.dev's gallery finds them: the 500 most downloaded (two pages of npm's search, sorted by last month's downloads), cached 6h in memory and on disk, else the bundled market_pi.json; a search of two or more characters adds npm's own keywords:pi-package <q> search, and a search npm doesn't answer keeps the popular matches with a SearchError (the page says so). Every name is held to npm's rules (piNameRe), and a repository link is https only. InstallPiPackage runs pi install npm:<name> with PI_CODING_AGENT_DIR set to that Pi's folder (piRun), then checks settings.json lists it; RemovePiPackage runs pi remove <source>, which drops every entry of the same identity and uninstalls it. A Pi with no pi here (a WSL distro's, or this computer's with no CLI on PATH) gets the settings.json entry written, or taken out, instead, and Pi installs it when it next starts (pending). Both refuse an unreadable settings.json, install refuses a package the Pi has by Pi's identity, and each write is backed up first. GET /api/library/market/pi, POST /api/library/pi/install, POST /api/library/pi/remove; Discover under the Pi packages tab (piCard, installPi, confirmRemovePi in plugins/library/client.js; library-pi-market.test.cjs) marks a package every running Pi has Installed, and Install asks which Pi when several lack it (nineruiing on X). pimarket.go

Runtime path

  1. Edit. The Library page or magpie library calls an exported function such as SaveServer, ServerAgents, InstallSkills, SkillAgents or SetSkillHow. The skills and servers pages each have Select, Turn all on, Turn all off and Remove all; the heading shows Select (and a busy Checking…, Grouping… or Updating…) and keeps the rest under its ⋯, the app's row menu (barMore in plugins/library/client.js). Select's bar calls SomeSkillsAgents or SomeServersAgents (/api/library/{skills,servers}/agents-some), Turn all on or off calls EverySkillAgents or EveryServerAgents for the agents shown, and Remove all calls RemoveSkills or RemoveServers. The hooks page has Select and Remove all too (SomeHooksAgents, RemoveHooks). Each of these is one change that takes every item out as a single removal would (#1027). Select's bar also has Remove… (#1852), which asks first, naming the count, and sends only the picked names to RemoveSkills, RemoveServers or RemoveHooks; ticking a group's or part's header picks all of it. A name that wasn't removed stays picked, with its error in its row's place (pickErrs), and the status names it; when every name fails the endpoint answers 400 and the sheet stays open. A row's agent chips start with All (allChip in plugins/library/client.js), which gives the item to every agent shown that can take it, or takes it from them all; the pickers that choose the agents before an item is added (installing skills from a repository or the market, adding, bringing in or installing a server) have the same All: most start with every agent lit, and one agent alone took a click on each of the others (#1531).
  2. Change. change edits library.json under the lock and calls sync.
  3. Write. For each target, syncInstructions, syncMCP, syncHooks and syncSubagents write magpie's part in the agent's format and record it in Applied. Skills are linked or copied into the agent's skills folder. A copy edited since it was made is taken into the library first.
  4. Result. The Result lists the agents changed, a Problem for each thing that couldn't be given, and the backup folder. Each change's folder is its own (freshBackup): named by the millisecond, with -2, -3… after it when another change took that millisecond, so a change's copy is never another's (TestBackupsInOneMillisecond).

Constraints and failure behavior

  • magpie takes away only what Applied or its mark says it wrote. A folder of the user's with a skill's name is never touched. The user's own fields in an MCP entry are kept.
  • A library with no instructions to give (no agent ticked, or no shared text) has lost them, as far as an automatic write knows. Sync (each start, and beside a change) then leaves every agent's part where it is and logs a line per agent, naming a record whose last write hashes empty; only the page's own write (changeInstructions) takes parts back. An automatic write never removes a whole instructions file: it empties one in place. A set's or an agent's extra text that is there but can't be read is a Problem, never an empty text (#5709: an emptied Library wiped nine agents' AGENTS.md at start, four deleted whole; TestEmptyLibraryApplyLeavesAgentsFilesAlone, TestUntickedLibraryApplyLeavesFilesAlone, TestUnreadableTextLeavesFilesAlone).
  • An edit never silently loses. When an agent's copy of a skill and the library both changed, the newest edit wins, and the losing one is kept with the backups.
  • An update from GitHub or a git repository never silently replaces a skill changed here. It is refused, or skipped in an update of several, until the user says to replace it, and the version replaced goes to the backups.
  • A copy's mark establishes that it is unchanged only after its whole folder was scanned. If a subtree or its metadata can't be read, the copy stays in place and the sync reports a Problem; it isn't replaced, relinked or removed. A later sync tries again once it can be read. The same scan failure stops replacing a project's or Claude Desktop's copy.
  • A failure for one agent is a Problem in the result. It doesn't stop the others.
  • LiveAgent (zero2sin on Discord) keeps its MCP servers in K-brain's config.json.live-mcp.json beside its config.json, in the folder agent.liveAgentDir finds: a list of servers by id, each enabled and stdio or http (streamable HTTP only, so SSE is refused). Until that file is there K-brain reads config.json's mcp object, so magpie's first write carries those servers over. A non-empty selected is the only servers LiveAgent uses, so magpie adds its server there and takes it out again, never the last one. The app holds the list in memory once started, so a change is seen at its next start. Its skills folder takes copies, as K-brain refuses a link, and a skill there is used only once picked in skills-settings.json: syncLiveAgentPicks picks each copy magpie makes once (Applied.Picked), so one the user unpicks stays unpicked, and unpicks it when the copy goes. A name K-brain refuses (lowercase letters, digits and single hyphens, up to 64) is copied but never picked. Its built-in skills-creator and skills-installer are not offered to bring in (liveagent.go, TestLiveAgentMCP, TestLiveAgentSkills).
  • An MCP OAuth sign-in canceled or timed out before its callback commits never saves a late token or changes an existing sign-in. The callback's write and the flow's ending share a lock (flow.keep in mcpauth.go); if the write wins first, it completes and tells the agents before saying done. A cancellation is not a sign-out of credentials already committed.
  • A server an agent can't reach is not written there, and mcpFile.supports says why. For example, Claude Desktop takes no remote server, and Codex, Goose, dsh, Grok, Command Code and Zed take no SSE.
  • A server's headers (remote) or environment (command) can name a variable as ${NAME} (#1250). library.json keeps the placeholder, and refsOf gives each MCP format the agent's own syntax, with the agent's source cited beside it: ${NAME} for most, {env:NAME} for OpenCode and MiMo, ${env:NAME} for Cursor, and Codex's own keys (bearer_token_env_var, env_http_headers, env_vars). Goose gets ${NAME} plus env_keys. dsh (DeepSeek Harness) gets a !!js expression it evaluates as it loads the server (#1435): a whole ${NAME} is !!js process.env.NAME, and a value mixing text and variables is the text as JSON string literals joined with (process.env.NAME ?? ""), so the user's text is never run as code and an unset variable inside it is empty. A whole variable that isn't set makes dsh leave the server out as invalid. magpie reads only those forms back as ${NAME}; any other !!js keeps the entry the user's. An agent with no syntax (Claude Desktop, Antigravity, Kimi, Cline, ZCode, Zed, Devin, Alma, Pi with pi-mcp-extension) is never written the value: refsProblem makes supports refuse the server, a magpie entry already there is taken out, and AgentView.NoEnvRefs greys its chip with the reason. Codex and Goose's extra keys are magpie's only while the server names a variable there (refKeys), so the user's own env_vars or env_keys are kept. CheckServers, the router (dialHub) and Codex's run through the gateway (specOf) expand the variable in memory (expandAll): from magpie's own environment, else from what a terminal opened now has (proc.LoginVars: what the login shell, or fish or nushell, exports, kept a minute; the registry's user then machine variables on Windows), since a magpie opened from the Finder has none of the profile's variables and a server whose token was exported in .zshrc showed no tools (Cyrus on Discord, TestEnvRefsFromLoginShell, TestLoginVars). The value is never set in magpie's environment, written to library.json or an agent's file, or logged. One set nowhere is novar, naming it. The page paints that as not checked (a ring, lib-health unknown), not red: it says nothing of the server, which the agent may start with the variable set, as Codex does its host-only codex_app (#2308). It starts a command server in home, with PWD set to it (not on Windows), as an agent started from home would, never in magpie's own working folder: a magpie started from the Windows Start menu has C:\Windows\system32, where a server that writes into . exits before it answers (#1727, TestCheckStdio).
  • A command server's command and args can name a variable as $NAME or ${NAME}, or start with ~ (math_milian on Discord: $HOME/bin/x on a Mac and on Linux). library.json keeps them as written; withCmdVars (cmdvars.go) makes the copy each agent is written, after runVia, in sync and in a project's files. An agent that expands a reference in a command and its args itself (cmdRefs: Claude Code, CodeBuddy and WorkBuddy, Grok, Gemini, omp/Qoder/AtomCode, OpenCode as {env:NAME}, Cursor as ${env:NAME}) is given the reference in its syntax, $NAME written ${NAME}, so a token in an arg stays out of its file. Every other agent (Droid by NoCmdRefs, though it shares Claude Code's format; Codex, Kiro, Crush, Copilot, Goose, Pi, Hermes, dsh and those reading none) starts the command as written, with no shell, so it is given the values: HOME as its own home, the rest from magpie's environment or a terminal's (lookCmdVar); one in WSL gets the distro's home (mcpFile.Home) and no variable of magpie's. A ~ is put in for every agent. A variable nothing has is left as written. The comparison a sync makes is against that copy, so a second sync rewrites nothing (TestCmdVarsSync). magpie starting the command itself does the same (launchCmd): the check and the router (startServer, a distro's home asked of its login shell, distroHome) and Codex's run through the gateway (specOf) (TestCmdVarsLaunch).
  • A command server is checked where the agents given it run (loong on Discord: a WSL program, given only to agents in WSL, was checked on Windows and "exited (1)"). checkSides reads each agent id's @wsl:<distro>: with none, or off Windows, or a Windows path for the command (windowsPath, magpie's own image server among them), or Settings' Detect agents in WSL off, it is this computer as before. Otherwise each distro is a side, after this computer when an agent here has it too. In a distro the command is found as the agents' shell finds it (wslrun.In: a login shell, then an interactive one for nvm's node, the probe wslrun.Find uses) and started through wslrun.Tool.Command (wsl.exe -d D --exec /usr/bin/env PATH=… <path> args), its env passed by WSLENV. A distro that isn't running is never started for a check: it is wsldown, naming the distro, painted as not checked like novar; beside a side that was checked it is left out. ServerHealth.Checked lists where it started, "" for this computer; the first failure ends the check and is the last place's, which the row names (" · WSL Ubuntu") and the tooltip says (TestCheckWSLOnlyServerInItsDistro, TestCheckWindowsServerHere, TestCheckMixedServerEachSide, library-mcp-health-wsl.test.cjs). Agents moved between sides is a check anew (healthKey, both sides). In a distro the command runs in the folder wsl.exe gives it (the Windows home under /mnt), not the Linux home.
  • A server's tools turned off on the page (nf1qaz2w on Discord) are kept by their names as the server gives them, in Server.DisabledTools, and written only to the agents that read a setting for it (toolsOffOf), each in its own form, checked against its source:
    • Codex: disabled_tools in the server's table in config.toml (codex-rs/config/src/mcp_types.rs, applied by ToolFilter in codex-rs/codex-mcp/src/tools.rs, openai/codex cc7ba336).
    • Gemini CLI: excludeTools in the server's entry (docs/tools/mcp-server.md; mcp-client.ts drops a tool by its own name, google-gemini/gemini-cli 9b6e0265).
    • Crush: disabled_tools in the server's entry (MCPConfig in internal/config/config.go, filterTools, charmbracelet/crush df5b024a).
    • Hermes Agent: tools.exclude in the server's entry, the original names (tools/mcp_tool_registration.py, mcp-config-reference.md, NousResearch/hermes-agent c5733167). tools.include, prompts and resources beside it are the user's.
    • Claude Code: a rule mcp__<server>__<tool> in permissions.deny of its settings.json (Target.Settings, beside .claude.json; for a WSL distro the distro's). A bare tool name in deny takes the tool out of Claude's context (code.claude.com/docs/en/permissions). Both names are spelt as Claude Code 2.1.296 spells them, each character but a letter, a digit, _ and - an _.
    • OpenCode: "<server>_<tool>": false in the top-level tools of opencode.json (opencode.ai/docs/mcp-servers, "Manage"), the names spelt as name() in packages/core/src/tool/mcp.ts does; migrateTools in packages/core/src/config/normalize.ts makes each a deny rule (sst/opencode 0d61729b).
    • Every other agent (Cursor, Copilot and Goose, whose lists are allow-lists only, Zed, Kimi, Pi, Grok, Devin, Antigravity, Alma, dsh, omp, ZCode, Command Code, Cline, WorkBuddy, CodeBuddy, Droid, Claude Desktop, MiMo Code, DevEco Code, a plugin's agent) gets the server whole. AgentView.ToolsOff is false for it, and the open list of tools names those given the server as unable to turn off single tools. A project's file and Copy config… carry no tools turned off either. magpie records what it added (Applied.ToolsOff per server for a list in an entry, Applied.ToolRules for Claude Code's rules and OpenCode's keys) and takes back only that (offList): a name, rule or key the user had already is theirs and stays when the tool is turned on again, and an OpenCode key the user set to true is never written over. A list or permissions.deny that isn't a list of names is a problem, never taken as empty, and the file is left as it is. The key, and Claude Code's permissions or OpenCode's tools, goes when magpie's were the last in it. The editor's save sends no tools, so SaveServer keeps those turned off.
  • With the MCP router on (MCPHub), an agent that takes a Streamable HTTP server is given magpie's one magpie entry in place of the Library servers ticked for it, and each server's own entry again when it is turned off. One that can't, or has an entry called magpie of its own, or whose library has a server called magpie, keeps each server's own entry, and the page says why (MCP router).
  • A gateway key held to some MCP servers and tools (wakaka on Discord) reaches through the router only those: the gateway holds each hub tool to the Library server behind it (see gateway routing). The key editor lists every Library server, the hub's or not, with the tools it last listed (KeyMCPServers, from the router's cards); a server that never listed shows no tools and can still be given whole.
  • magpie's own MCP servers (magpie-image, magpie-browser, magpie-web-search, magpie-vision, and any mcp … run by a program named magpie) run this computer's magpie (#1439). InstallServer gives it magpie by full path (update.Program: the AppImage, not its mount; Homebrew's opt link, not the Cellar), and that path is right only on this computer. When the library is read, and after every change, heal points such a server whose program isn't on this computer (another system's path, a magpie moved out of Downloads, a bare magpie) at this magpie, so the agents and CheckServers get it; a magpie program that is here (another build) and a server run by any other program stay as they are. A carried library (Collect, for a backup or a WebDAV or S3 sync) names it as plain magpie, so two computers carry the same bundle and a sync doesn't write one's path over the other's; Put then reads it as that computer's magpie. self_here.go
  • Magpie Web Search (magpie-web-search, searchServer in market.go) is the featured, opt-in server for magpie's web search: magpie mcp search (RunSearch in browsermcp.go) passes each stdio message to the gateway's /mcp/magpie/web-search, as magpie mcp browser does to its own path, with no browser session. Its sheet says each search goes where Settings › Models › Web search sends it. That page's MCP server row (#searchMcpRow) keeps the address to copy, and under its words Give agents Magpie Web Search… opens the sheet in the Library (magpie.call("library", "server", "magpie-web-search")), Turn on the Library when the Library is off, and nothing in gateway mode, as Settings › Models › Images does for Magpie Image (lutra_fs on Discord: the search was in Settings and not in the Library; search-mcp-library.test.cjs). Each agent is given a 120-second tool timeout for it (selfTimeout). An agent in WSL is not given it directly, as with Magpie Browser; the MCP router serves it there.
  • Magpie Browser (magpie-browser) is opt-in, added with no agents, so the router offers it to none until one is ticked (an agent asked to use the browser reached for AppleScript instead). While its extension is connected (GET /api/library/browser, read again every 3 seconds while the row is shown) and no agent has it, its row in the MCP list asks which agents may use it, on a line of its own under the row's name, command and chips (from the name's left edge to the row's right one, the row's lib-asking), a button per agent whose chip can be clicked; a button clicks that chip, so the choice goes through servers/agents as a chip's does, and the row asks nothing more (browserAsk in client.js; library-browser-ask.test.cjs).
  • A page whose browser can't reach magpie's folders (magpie in a container, gateway.InContainer, or a page from another computer) is told so (browserJSON.Away), and the sheet's button is Download the extension: POST /api/library/browser/extension with the page's origin answers a zip of the extension (browserext.Zip) pointed at that origin, with the secret of the On gateway key named Magpie Browser, made by the first download (browserKey). It is a POST so a cross-site link can't mint a key. The zip lands in Downloads, so the key is a browser key (access.Key.Browser): it opens the extension's socket and nothing else, no model, MCP server or stat (readOnlyGuard, see gateway routing; Gateway → Gateway keys tags it Browser only and offers no access to change). One a magpie from before made with full access is held so with the same secret as the gateway starts and on the next download (ScopeOwnBrowserKey, access.ScopeBrowser), so the extension keeps connecting. A browser connecting from elsewhere with a key belongs to it: the gateway's relay gives it only to sessions tagged key:<id>/ (browserOwner, keyedSession in browser.go), which is what a remote caller's session is forced to. The key the page makes is recorded as this magpie's own browser's (SetOwnBrowserKey, a file in the settings folder), and a browser connecting with it serves this computer's sessions too when it connects from this computer (browserConn.own: the key and local, so not through a proxy or the page port; serves). From another computer, the Docker bridge's 172.17.0.1 included, the key proves nothing: a copy of the zip could connect a browser there, and this computer's agents' calls would go to it, so it serves only its key's sessions (#5529). A record that can't be read names no key. A keyed connection lasts while its key does: watchKey looks every 5 seconds and closes the socket once the key is turned off, removed, expired or rotated (access.Current), and a call looks first too (TestBrowserIsItsKeys; TestOwnBrowserKeyIsThisComputers; TestBrowserKeyOffClosesItsBrowser; TestBrowserExtensionDownload; library-browser-away.test.cjs; gateway-key-readonly.test.cjs).
  • Magpie Image Recognition (magpie-vision, visionServer in market.go) is the featured, opt-in server for image recognition, beside Magpie Image and Magpie Web Search (matrix0487 on Discord: Discover had two of magpie's three): magpie mcp vision (RunVision in browsermcp.go) passes each stdio message to the gateway's /mcp/magpie/vision, and makes analyze_image's relative image path one in the agent's own folder on the way (imageFrom), since the gateway can't know where the agent runs; an absolute path, ~, a URL or a drive goes as written. Its sheet says each image goes to Settings › Models › Images › Image recognition's model. That row has Give agents Magpie Image Recognition… (libWay in app.js, shared with Images' and Web search's links), Turn on the Library with the Library off, and nothing with recognition off or in gateway mode (vision-mcp-library.test.cjs). It gets the same 120-second tool timeout and the same WSL rule as Magpie Web Search.
  • Discover's featured list is the same with nothing set up: one of magpie's own whose model or search isn't there yet, or which Settings turned off, carries unready (gateway.OwnUnready, set by the GUI's /api/library/market/servers), shown as a Not set up yet badge on its card and the full reason in its sheet. It can still be added, since it answers once that is set up, and until then its tools answer with the same reason, so no agent is given a tool that fails without a word.
  • A carried library (Collect) has every file of each skill, its templates and other binaries included, up to maxCarried (16 MiB) a file and maxCarriedAll (32 MiB) in all, chosen smallest first across the skills (readSkills), so every skill's text goes before any big file. The total keeps a sealed backup under the 64 MiB a sync reads: the files are base64 twice in it. What is left out is named in Left, and Put keeps this computer's copy of such a file in the skill it puts (keepLeft). carry.go
  • A skill can be turned off on this computer alone (OffHere, SkillHere; the row's power button, magpie library skill off-here <name> and on-here; hanslin1666 on Discord). No agent here gets it, whatever its Agents say (gives, which every reader of Agents for giving goes through: syncSkills, desktop_skills.go, skill_changed.go, skill_edits.go, behind, Targets). Agents stays what a sync carries, and the page leaves its chips as they are, faded. Collect never carries OffHere, so turning it off changes no part a sync uploads, and Put keeps this computer's OffHere for a skill it puts, so a sync from a computer that has it on, or gives it to more agents, never turns it on here. A library.json from before has no offHere and every skill stays on. Not covered: a project's skills; a library skill kept in ~/.agents/skills, which agents read in place, until it is handed over (below); and a skill another computer removes, which takes the flag with it. skills.go, carry.go
  • An MCP server can be kept to this computer (Server.Local; the editor's "Sync to your other computers" switch, off for a local one (it said "This computer only", which bin.90 on Discord read as sharing), the row tagged "Not synced", magpie library mcp add --local, magpie library mcp local <name> 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, carry.go
  • The CLI sets a server's headers, env and startup timeout (#6111, Abandon332 on X): magpie library mcp add <name> <url|command args…> header=K=V env=K=V timeout=SECS agents=…, mcp set <name> header=K=V|header-=K|env=K=V|env-=K|timeout=SECS (the rest of the server kept) and mcp show <name> (JSON). SplitServerWords takes those words out of the line before --; words after -- are the program's own, and a word that looks like a setting magpie doesn't know (headers=, envs=) is refused rather than passed on as an argument. header= on a command or env= on a URL is an error. (TestSplitServerWords, TestLibraryMCPHeadersEnvTimeout) mcp_options.go
  • A skill brought in from a link into a folder an app keeps per version (ego lite's framework Versions/<v>, #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/<old>, 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/<v> 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). The app's own steady link can be left naming the version its update deleted (ego's active_version_dir still at 0.6.2.5 with only 0.6.2.7 on disk, tjhhhh again): the app's links are its own and never written to. When the library's link dangles and its target isn't in a version folder, the links on the way are followed as far as they are there (linkedEnd) and movedVersion is asked of where they end; the library links to the folder found, and keeps the steady link as Source.Via. Once the steady link leads to a SKILL.md again, the library links through it once more and Via is cleared (TestSteadyLinkLeftOnDeletedVersion, TestSteadyLinkLeftOnDeletedVersionNoOther). 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 <name…>|--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 <name>, 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
  • 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, ZCode 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). A user's own skill in ~/.agents/skills by the library skill's name (another installer's, such as the skills CLI's, or copied by hand: not magpie's link or marked copy, not the library's own folder) counts too, under that folder name or another whose SKILL.md gives the name (readSharedOwn, sharedOwn.rival), since Pi 1.4.0 knows a skill by that name and drops one read twice only when both paths are one file (realPathSet in dist/core/skills.js): it warned of a collision for the two trees. Such a reader gets nothing in its own folder, and magpie's link or marked copy there, an older magpie's too, goes on the next sync. When it holds the library's very files (sameTree) the reader has the library's already. When it holds other files the reader has a skill of its own by that name, an Own problem settled as one in its own folder: Keep {agent}'s unticks it, Use the library's sets the shared entry aside with the backups (every other reader of the folder loses it too) and gives the library's (math_milian on Discord; TestSharedCopyNotGivenTwice, TestSharedCopyOtherFolderName, TestSharedOwnSettled). The user's entry is otherwise never touched. Not covered: a library skill that is a link to the agent's own folder (brought in from there) beside such a copy keeps both, since that folder is the library's; OpenCode reads Claude Code's folder and the shared one into one map by name, so it finds Claude Code's link and the user's copy as one skill; and a Pi or omp of unknown version is given its own as before.
  • 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, unless they read the folder themselves (sharedOwn.rival, above). 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
  • A skill's files are read and edited in the page (refeccd on Discord: skills handed over from ~/.agents/skills had nowhere else to be edited). GET /api/library/skill?name=&file= answers ReadSkillFile: the file (SKILL.md when none is named), its text, the skill's folder and files, its text files (skillTextFiles: UTF-8 with no NUL, up to 1 MB each and 200 in all, SKILL.md first, leaving out links, hidden folders, skipInSkill's entries and what installing writes, fromInstall). SaveSkillFile (POST /api/library/skills/save with name, file, text and was) goes through change: it writes only a regular file already in the skill's folder, never through a link or out of the folder (skillFilePath), refuses when the file no longer holds was, the text the page opened, keeps a file's CRLF line ends, and writes with edit.WriteAtomic. It writes the library's folder, so a linked agent reads it at once and the sync that follows copies it again into each copy; a copy edited in an agent before it is older than the save, so takeEdits keeps that edit aside with the backups. A skill from GitHub or git saved here reads as changed here (editState), so an update asks before it replaces the edit. The page (viewSkill, rendered in plugins/library/client.js) draws a Markdown file with the Plugins page's renderer (window.mdRender, markdown in plugins.js) and its front matter as rows, any other file as its text; Edit swaps in a text box, ⌘S or Save sends it, and the skill's other files are the app's menu under its name (TestSavedSkillFileReachesEveryAgent, TestSkillFileSaveRefusesAChangedFile, TestSkillFileStaysInTheSkill, TestSkillFileKeepsLineEnds, skill-edit.test.cjs). Not covered: the TUI and CLI have no editor; a new file can't be made, and a file can't be renamed or removed, here. skill_file.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.<Event>]] 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.
  • Zed's servers go in context_servers of the settings.json magpie sets its model in (agent.zed: ~/.config/zed on macOS, $XDG_CONFIG_HOME/zed on Linux, %APPDATA%\Zed on Windows, or $MAGPIE_ZED_CONFIG_DIR), as command/args/env or url/headers (ContextServerSettingsContent, zed-industries/zed 2c99f547). The file is JSONC: it is edited in place, so the user's comments, other settings and own servers stay, and enabled, remote, timeout and oauth in magpie's entry are the user's. Zed speaks streamable HTTP only (its http.rs only POSTs), so no SSE. An entry Zed's extensions configure (settings and no command or url) is never written over: a server by that name is refused for Zed (mcpFile.foreign), and asks for another name. Zed reloads the file as it changes.
  • An agent with no place for an item is refused by Takes, never recorded as given it. The refusal lists the agents here that take that item (takenBy), and says where it goes instead (noPlace): OpenChamber reads OpenCode's global AGENTS.md, skills folder and opencode.json (its server's shared.js), so it gets them from OpenCode; Claude Desktop's chat keeps its instructions in its own settings, with the Claude account, and its Code tab reads Claude Code's. A plugin's agent is refused an item its agent.library names no place for, and the refusal names the key its plugin would set.
  • Removing RTK never uses rtk init --uninstall. That command deletes Gemini's GEMINI.md whole and removes Claude Code, OpenCode and Cursor together.
  • A hook is recorded entry by entry, as written (Applied.Hooks, compared as canonical JSON). magpie takes out only an entry still exactly as it wrote it; one the user edited is theirs from then on, and the user's own hooks beside it stay. A hooks file that doesn't parse is a problem and is never written. Codex keeps each hook's trust in config.toml as [hooks.state."<path>:<event>:<group>:<handler>"], keyed by position, so when magpie takes a group out codexRekey moves the user's trust for the groups after it to their new place.
  • A carried library (backup, WebDAV, S3) carries the hooks (Bundle.Hooks: name, description, event, matcher, command, timeout, agents ticked; VincentChan on Discord), never Applied.Hooks: each computer writes them into its own agents at the sync Put runs, beside the user's own hooks there, and records its own entries, so an entry the user edited there stays theirs as above. Put replaces the hooks with the bundle's, so one taken out on one computer goes from the others; a bundle without the field, from a magpie before it, keeps the ones here. The event and agents are carried as they come: an event this magpie doesn't know is a problem on the agent it is given to, not a refused library; a hook with no name or command, or named twice, refuses the bundle. An empty list hashes as before the field (TestCarryHooks, TestCarryOldBundleKeepsHooks, TestCarryNewerHooks, TestBackupFileCarriesHooks, TestSyncHooks, TestNoHooksHashAsBefore). Not carried, as this computer's own: projects (folders here), skill groups, CopySkills/SkillHow, SharedSkills and MCPHub.
  • A carried library (backup, WebDAV, S3) carries the variables (Bundle.Env: name, value, agents ticked; onducoder on X: a skill's key set once, on every computer), never Applied.Env. Nil in a bundle from a magpie before they were carried, and Put then keeps this computer's. A copy without keys keeps the names and empties every value, whatever the name (WithoutSecrets; a variable's name says nothing of its value), and WithSecrets fills them from this computer's. syncEnv writes nothing for a variable with no value. A backup with keys is sealed under its passphrase, as the servers' tokens are. TestEnvIsCarried.
  • A subagent file is recorded by the hash of what magpie wrote (Applied.Subagents). magpie writes over or takes away only a file still exactly as it wrote it; one the user edited is theirs from then on, and the page says so. A file of the user's own by the same name is never written over: the agent gets a problem instead. A file of magpie's the user deleted is written again on the next sync. Cursor's ~/.cursor/agents is read by the Cursor app only; the cursor-agent CLI reads only a project's .cursor/agents. An agent in a WSL distro gets no subagents, nor do agents with no user-level subagent folder (Kimi, Goose, Crush, Qoder, CodeBuddy, iFlow, Kiro). A carried library carries the subagents (Bundle.Subagents: name, description, prompt, skills and servers named, agents ticked; xixi_Sean_ on X), never Applied.Subagents: each computer writes them into its own agents at the sync Put runs and records its own files, so a file the user edited there, or one of theirs by the name, stays theirs as above. Put replaces the subagents with the bundle's, so one taken out on one computer goes from the others; a bundle without the field, from a magpie before it, is unknown and keeps the ones here (nil, where Collect always carries a list). Agent ids are carried as they come, one a newer magpie gives subagents to included; a name that isn't one refuses the bundle. An empty list hashes as before the field, so a computer with none sees no change to sync (TestCarrySubagents, TestCarryOldBundleKeepsSubagents, TestCarrySubagentKeepsUsersFiles, TestCarryNewerSubagents, TestBackupFileCarriesSubagents, TestSyncSubagents, TestNoSubagentsHashAsBefore).
  • CC Switch's own skills folder is only ever read.
  • Reading the page never waits on reading skills through (#541). Read compares an agent's own skill with the same name in another agent (sameTree) and hashes each library skill given as a copy (hashFiles, for behind). Both are kept against a stamp of the folders (each file's and link's path, type, size and mtime, stamper in treememo.go), taken by the same walk that compares or hashes them, before a file is opened; a later read walks the folder without opening a file, and while the stamps match reuses the answer. Only an answer from a whole read of folders untouched for settleFor (3s) is kept: a folder that couldn't be walked or read, or was written a moment ago, is read again next time, never taken as unchanged. A rewrite that keeps a file's size and mtime isn't seen. Glance (GET /api/library?glance=1) is the page without those two, marked partial; the page draws it first, then the whole read, which runs behind and foundSkills after the library's lock is let go, so a change doesn't wait on them either.
  • A read of the page (Read, Glance) follows the links on the way to a few hundred paths, most of them many times over: each agent's skills folder for each skill, CC Switch's and the shared folder for each source. While the read holds the lock, resolve looks at each entry on the way once (lookPart in linkmemo.go): one Lstat, and a Readlink for a link. Nothing is kept past the read, so a link made or moved on disk between two visits shows on the second. An entry that couldn't be looked at for another reason than its not being there is unknown and looked at again. One read had taken ~10,000 looks; on oxyuan's Windows machine that was ~1.3s a visit (#1771).
  • Skills installed together (InstallSkills, InstallMarketSkill, AddNewSkills, through installFrom and installChange) install each on its own. One the library lists from the same source, or a folder in the library's own skills folder holding exactly that skill's files (left by an install that stopped before the library was saved), is had already and goes in Result.Had. Its files are never written, so the user's edits stay. Another skill by that name, listed or only in the folder, is left as it is. One from GitHub or another git repository then goes in beside it under a name of its own (mora1n on Discord: anthropics/skills' and openai/skills' skill-creator are two skills): the name with its source's owner added (skill-creator-openai), then owner and repository, the repository, then a number, at most 64 bytes (freeSkillName in skill_beside.go). The library's copy of its SKILL.md gives that name too (nameSkill, only the front matter's top-level name: line), so an agent never sees two skills by one name; Skill.Called keeps the name its SKILL.md gave. Its hash is of the renamed copy, and a check or update compares what it fetches named the same way (fetchedHash), so it reads as unchanged and an update keeps the name. Being had is decided by source, not name (hadSkill): the same source under any name here, or a skill with no source (taken in from an agent's folder) by that name holding the very same files. A probe's candidate says which (Candidate.Have, Candidate.As), the page and the TUI show "in the library as …" or "adds as …", the market's had check matches by name only a skill with no repository (haveSkill), and the new-skills check no longer drops a skill because its name is taken. A skill already in the library keeps its name, folder and links; nothing is renamed after the fact. A folder of the user's own is linked as it is, so its SKILL.md can't be named apart: one by a taken name, or a folder that can't be read, goes in Result.Skipped with why (TestSameNameFromAnotherSourceGoesInBeside, TestSameFilesByNameAreHad, TestInstallSetPutsAnotherByTheSameNameBeside, TestAddFromLibraryFolderKeepsIt). The rest are installed and named in Result.Installed. Only when nothing was installed or had does the change fail, with the first reason.
  • A skill the library has from a folder of the user's, or took in from an agent's folder, has nothing to update from, though it often came from GitHub (biubiu8802 on X: downloaded from there, then added from its folder). Installing that skill from GitHub links the two when it is that skill: traced to that repository, or traced nowhere with the same description in its SKILL.md (followsHere, linkSkill in skill_link.go): the library's skill keeps its name, agents and links, takes GitHub's files and GitHub as its Source (skillUpdate.apply with adopt, as an update of a CC Switch skill does), and a check and an update cover it from then on. The library's link to a folder elsewhere is all that goes; that folder stays as it is. A copy of the library's own whose files aren't GitHub's goes to the backups (keepReplaced), as UpdateSkill with replace keeps an edited one. One whose files are GitHub's to the file only takes the source, and so does one had by the very same files (hadSkill). The install names it in Result.Linked, and in Result.LinkedKept when its files were kept; a probe's candidate says so first (Candidate.Links), and the page tags the row "links to GitHub" and says both after the install (skill-install-link.test.cjs), the TUI likewise. A skill traced to another repository (tracer.repoOf: From, CC Switch's record, the skills CLI's lock, a git checkout) and an untraced one that describes something else are other skills by that name, and the GitHub one goes in beside them as above (TestInstallSetPutsAnotherByTheSameNameBeside); a skill from GitHub or git is never taken over (TestFolderSkillFollowsGitHub, TestOwnSkillFollowsGitHubKeepsItsFiles, TestSkillFromElsewhereIsNotLinked). The market's had check is unchanged: it still counts such a skill as had by its name.

Verification

go test -tags nogui ./internal/library -run 'TestPlugin|TestGit|TestInstallFromGitRepo|TestReadLooksAtEachFolderOnce|TestLinkChangedBetweenVisitsShows|TestUnreadablePartIsLookedAtAgain|TestCheckSkillsFindsNewOnes|TestNewBase|TestUpdateKeeps|TestCheckDue|TestCheckSkillsMarksItDone|TestTargets|TestWSLPiMCP|TestWSLMCPSiblings|TestServer|TestHub|TestImportServer|TestCheck|TestInstructions|TestInstructionsSetLinkedToAgentsFile|TestInstructionSets|TestTakesAlma|TestAlma|TestLinkedSet|TestLinkRefused|TestSkill|TestRemoveFoundSkill|TestInstallSet|TestInstallLists|TestEverySkillAgents|TestEveryServerAgents|TestSomeServersAgents|TestRemoveServers|TestRTK|TestEnvRefs|TestDshRefRoundTrip|TestDshImportKeepsJS|TestAgentMCPFiles|TestCodeBuddyMCPFile|TestZedMCP|TestOwnServerFromElsewhereRunsThisMagpie|TestUsersOwnServerStaysAsItIs|TestCarriedOwnServerIsEachComputersMagpie|TestCarry|TestPageReadDoesntReadUnchangedSkillsAgain|TestJustWrittenSkillIsReadAgain|TestUnreadableSkillIsntRememberedAsDifferent|TestGlanceLeavesOutTheAgentsSkills|TestPluginAgent|TestPluginMCPFormatsAreWritten|TestToolsOff|TestOffList|TestHooks|TestSubagent|TestCheckRenewsMagpiesSignIn|TestCheckWSLOnlyServerInItsDistro|TestCheckWindowsServerHere|TestCheckMixedServerEachSide|TestCheckSaysSignInRanOut|TestCheckNamesAgentsSignedInThemselves|TestSignInAsTheUsersOwnApp|TestOAuthAppChecked|TestOAuthAppSecretCarried|TestGoneAgentListedToTakeOut|TestUpdateFindsSkillsRemovedUpstream|TestGoneFromNeedsTheSourceRead'
go test -tags nogui ./internal/library -run 'TestSkillOffHere|TestLocalServerNotCarried|TestPutKeepsLocalServer|TestPutSameNameAsLocal'
go test -tags nogui ./internal/backup -run 'TestRestoreKeepsLocalServer|TestBackupFileCarriesSubagents|TestBackupFileCarriesHooks'
go test -tags nogui ./internal/library -run 'TestHandOver|TestSharedUnderAnotherName|TestSharedAgentsSkills'
go test -tags nogui ./internal/davsync -run 'TestSkillOffHereThroughSync|TestLocalServerThroughSync|TestSyncSubagents|TestNoSubagentsHashAsBefore|TestSyncHooks|TestNoHooksHashAsBefore'
go test -tags nogui ./internal/cli -run 'TestLibrarySkillRm|TestLibrarySkillHandOver'
go test -race ./internal/mcpauth
go test -tags nogui ./internal/library
go test -tags nogui ./internal/library -run 'TestWSLStopped'
go test -tags nogui ./internal/library -run 'TestRTKWSL'
go test -tags nogui ./internal/library -run 'TestBili|TestParseBiliList'
go test -tags nogui ./internal/library -run 'TestPi'
node --test internal/gui/tests/library-pi-extensions.test.cjs internal/gui/tests/library-pi-market.test.cjs
node --test internal/gui/tests/library-rtk-wsl.test.cjs
node --test internal/gui/tests/library-wsl-asleep.test.cjs
node --test internal/gui/tests/skill-off-here.test.cjs internal/gui/tests/mcp-local-server.test.cjs internal/gui/tests/skill-handover.test.cjs
node --test internal/gui/tests/mcp-accounts.test.cjs internal/gui/tests/library-items.test.cjs internal/gui/tests/library-mcp-hub.test.cjs internal/gui/tests/library-alma-profile.test.cjs internal/gui/tests/library-rtk-gain.test.cjs internal/gui/tests/library-rtk-nohook.test.cjs internal/gui/tests/library-servers-bulk.test.cjs internal/gui/tests/library-pick-remove.test.cjs internal/gui/tests/library-env-refs.test.cjs internal/gui/tests/library-zed-mcp.test.cjs internal/gui/tests/library-workbuddy-trust.test.cjs internal/gui/tests/skill-new-in-repo.test.cjs internal/gui/tests/skill-update-edited.test.cjs internal/gui/tests/skill-gone.test.cjs internal/gui/tests/skill-git-source.test.cjs internal/gui/tests/remove-found-skill.test.cjs internal/gui/tests/found-skill-pick-remove.test.cjs internal/gui/tests/library-loading.test.cjs internal/gui/tests/library-mcp-tools.test.cjs internal/gui/tests/library-mcp-tool-switch.test.cjs internal/gui/tests/library-hooks.test.cjs internal/gui/tests/library-subagents.test.cjs internal/gui/tests/library-plugins.test.cjs internal/gui/tests/library-mcp-health.test.cjs internal/gui/tests/library-mcp-health-wsl.test.cjs internal/gui/tests/mcp-signin-health.test.cjs internal/gui/tests/mcp-signin.test.cjs internal/gui/tests/mcp-editor-cancel.test.cjs internal/gui/tests/mcp-oauth-app.test.cjs internal/gui/tests/library-ime-scroll.test.cjs

The package's TestMain runs in a home of its own (testenv), never the user's real agent files.