Commit Graph
80 Commits
Author SHA1 Message Date
yetoneandggbdpq 3480f822c5 library: an apply over a library that lost its instructions leaves the agents' parts alone (#5709)
Starting v0.1.3327 applied the Library at launch while it was empty, and
the apply wrote that over nine agents' instruction files: zcode's lost
magpie's part, and codex's, kimi's, opencode's and dsh's AGENTS.md were
deleted whole, with nothing asked or logged. library.json then recorded
hash("") for every agent. syncInstructions fell through to
withBlock(file, "") and, for a file with nothing of the user's outside
the part, edit.Remove.

Now:
- An automatic write (Sync: at a start, and beside a change) that would
  write nothing over a part while the library has no instructions to
  give anyone (no agent ticked, or no shared text) leaves the part where
  it is and logs a line per agent, naming a record whose last write
  hashes empty. The reporter's library.json had both. Only the page's
  own write (changeInstructions) takes parts back; a text still held
  with one agent unticked takes back as before (TestWSLStoppedInstructions).
- An automatic write never removes a whole instructions file; it empties
  it in place. The page's write keeps the removal, with the backup first.
- A set's or an agent's extra text that is there but can't be read
  (readText swallowed the error) is a Problem, never an empty text: an
  unreadable set file no longer cuts parts down, on the page's writes too.

Siblings left: syncMCP, syncHooks, syncSkills and syncSubagents take back
by Applied record what magpie wrote (config entries and links that the
library and market can give again, not prose), and a library reset that
loses their lists loses those records too. The sync chain (an empty part
coming down from another computer) is #5642's commit.

Ported from ggbdpq's patch on the issue, with the guard widened from
"no shared text" to "no agent ticked or no shared text" and the
unreadable-text check added.

Run:
- New tests in internal/library/empty_library_test.go, all red on the
  old instructions.go/sync.go (part cut to the user's own lines, or
  "deleted whole by the apply"), green after:
  TestEmptyLibraryApplyLeavesAgentsFilesAlone,
  TestEmptyTextApplyLeavesTickedFilesAlone,
  TestApplySaysWhyItLeftAPartAlone,
  TestUntickedLibraryApplyLeavesFilesAlone (agents unticked, text kept:
  red under the original patch's guard too; the page's untick still
  takes back), TestUnreadableTextLeavesFilesAlone (set file mode 000).
- go test -tags nogui ./internal/davsync/ ./internal/library/ on mote.
- gofmt -l on the changed files: nothing.

Not tried: the reporter's v0.1.3327 upgrade that emptied the index.

Reported-by: lennonli (yetone/magpie#5709)
Reported-by: gua2100 (Discord)
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-09 12:04:06 +08:00
yetone dc098c1e82 library: a skill from a folder follows GitHub once installed from there (biubiu8802 on X)
biubiu8802 (X, 2119602075864903924) downloaded a skill from GitHub and
put it in the Library from its folder, so it had nothing to update from
and no way to link it to GitHub. Installing it from its GitHub link now
links the two, the way an update of a CC Switch skill already does: the
library's skill by that name takes GitHub's files and GitHub as its
source. A check and an update cover it from then on, and the agents'
links keep pointing at it. When its own files aren't GitHub's, they go to
the backups like UpdateSkill's replace does, and the result says so. A
folder of the user's it was linked to stays as it is.

followsHere (skill_link.go) decides it. It links only a skill with no
remote source that wasn't renamed and is that skill: it traces to this
repository (CC Switch, the skills CLI's lock, a git checkout, From), or
it traces nowhere and its SKILL.md has the same description as GitHub's,
as an older download of it does. One traced to another repository, or
an untraced one that describes something else (mora1n's case,
TestInstallSetPutsAnotherByTheSameNameBeside), still goes in beside it
(skill_beside.go). A had skill with
the same files and no source is bound to the GitHub source it was found
in, so a later install of another repository's skill by that name goes
beside it, not over it (TestSameFilesByNameAreHad).

The probe marks such a candidate links:true. The GUI's Add list tags it
"links to GitHub" with a tooltip, and the report names "updates from
GitHub now" and "files of their own kept with the backups". The TUI's
probe list and result line say the same. The new strings are in zh,
zh-TW, ja and de.

Run on mote (macOS), on 64ecd0f69, then rebased on 8a58c0e30, whose
new commits touch none of internal/library, the TUI's library or the
library page:
- gofmt -l clean; go vet ./..., GOOS=windows go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=linux go build -tags nogui
  ./..., GOOS=windows go build ./... all ok
- go test ./internal/library/... ok at this tree; ./internal/tui/...,
  ./internal/cli/... and ./internal/gui/ ok at the tree before the
  description check (that change touches internal/library only)
- GUI (chromium + webkit, 5 languages, wide and narrow):
  skill-install-link (new), skill-install-beside, skill-install-skip,
  skill-install-agents-all, skill-git-source, skill-too-big,
  provider-discovery, i18n-en-no-cjk pass. i18n-keys' "a plugin's words
  are its own" is red on main for three strings this change doesn't
  touch, already filed: #5332/#5327 ("View routing"), #5482 ("Use the
  library's"), #5426 ("No session ID").

Broken by hand: without the description check (the first version),
TestInstallSetPutsAnotherByTheSameNameBeside is red (caveman taken over).
followsHere returning false always turns
TestFolderSkillFollowsGitHub red (probed As:pdf-pro-biubiu) and
TestOwnSkillFollowsGitHubKeepsItsFiles red (linked [] kept []).

Not run: the full go test ./... suite. mote's suite lock had a queue
waiting up to 16h, so this change ran the packages it touches.
No real GitHub install either: the tests use a fake tarball server. Not
tried on Windows or Linux. The market's had-check (haveSkill) is
unchanged: a market skill with a folder copy by that name still counts
as had.
2026-11-09 11:29:51 +08:00
yetone 2a64b4bcb7 library: a skill router, one magpie-skills skill listing an agent's skills
Like the MCP router, for skills. With the Skills tab's new "Skill
router" switch on (off by default), each agent's skills folder gets
one skill of magpie's, magpie-skills, in place of a link of each skill
ticked for it. Its SKILL.md lists them, each with its description and
the path of its SKILL.md, and the agent reads that file when a task
fits. An agent then carries one skill's description in its prompt
however many the Library gives it.

- The entry is a link to <settings dir>/skill-router/<hash of the
  folder>/, which holds SKILL.md and a hidden .skills/<name> link of
  each listed skill (hidden, so Codex, OpenCode and Pi don't find a
  skill twice). Its description stays within 1024 bytes (Codex's
  limit), cut on a whole character.
- Every skill is listed unless it is kept direct (a button on the
  skill, or `magpie library skill router <name> direct`; carried by a
  sync), is only for the user to type (disable-model-invocation), is
  in ~/.agents/skills, is blocked, or the agent has its own by that
  name. Those keep their own links.
- An agent whose folder can't take it keeps every link, and the page
  says why: given copies, a live agent picking its own, the shared
  ~/.agents/skills, a Library skill called magpie-skills, or a
  magpie-skills of the user's (never written over).
- Claude Code 2.1.316 asks before reading outside its project, its
  skills folder too, so magpie adds Read rules for the entry and the
  folders behind it to permissions.allow, records them, and takes out
  only its own when they go (as permissions.deny does).
- The switch is this computer's alone; `magpie library skill router
  on|off` sets it from the CLI.
- Sessions count a routed read of .skills/<name>/SKILL.md as <name>
  (Claude Code, Alma, Droid), and calling up magpie-skills itself as no
  skill, so a use counts once.
- docs/subsystems/skill-router.md, with a row in the index.

Run at this tree (rebased on origin/main 8f74442e4), on mote unless
named:
- go test -tags nogui ./internal/library ./internal/sessions -count=1: ok
- go test -tags nogui ./internal/cli ./internal/gui: ok at bca122bf9;
  ./internal/gui again at 8f74442e4 (app.js changed there): ok
- node --test of every library-*, *skill*, i18n* and gui-* GUI file
  (96 files), in the Linux VM (wsl-run): mote's browsers didn't start
  while another session's simulators ran. 1678 pass, 11 fail at
  bca122bf9, every red also red on origin/main and filed: library-all
  WebKit (#4967), skill-where WebKit 400px (#5154), i18n-keys' plugin
  words (below), and library-own-folder under load, fixed here. The
  files this change touches, add-partners-shine and i18n-keys again
  at 8f74442e4: 111 pass, i18n-keys the 1 red.
- The router's row under the skill list moved four GUI tests'
  footing, fixed in the tests: remove-all-skills counted it as a skill
  (now rows of lists other than a hub's, as list-sort does);
  found-skill-pick-remove and library-pick-remove's reach only wheeled
  down from above the target, so a Select pushed under the sticky tabs
  or below the fold was never reached (now toward it, over the list,
  and the scroll at rest before the click, WebKit's settled a pixel
  late); library-own-folder's Playwright click scrolled the now
  taller page under load (now a click where the button is). Each red
  on the branch before, 22/22 or 14/14 after, twice.
- skill-router.test.cjs: 22/22 (chromium and webkit, 1100 and 420px,
  en zh zh-TW ja de)
- go vet -tags nogui, GOOS=linux and GOOS=windows: ok
- win-run (xiaomi-gpu) go test ./internal/library: ok but
  TestGoneAgentListedToTakeOut and TestCheckMixedServerEachSide, red the
  same at origin/main 6b0b7a96e and filed in #4115 (run at that
  base; nothing in internal/library has changed on main since). The
  router tests' expected rules were /C:/…; Claude Code's form is
  //c/… (claudePath), which the code wrote, so the tests now ask
  claudePath too.
- Broken by hand: routable returning true is red in TestSkillRouter (a
  skill for the user to type is listed); with the routerSkill check
  out of the sessions reader, TestClaudeRoutedSkillCounted is red.
- Real Codex 0.165.0, sandbox HOME, through the live gateway with no
  sign-in copied: a binary built from this change at 6b0b7a96e ran `library skill
  hand-over`, `skill agents secret-word codex` and `skill router on`;
  `codex exec "What is the project's secret word?"` read
  magpie-skills/SKILL.md, then .skills/secret-word/SKILL.md at the path
  given, and answered PELICAN-7319. `router off` put the skill's link
  back and removed the router's folder.
- Real Claude Code 2.1.316, sandbox HOME, through the live gateway on
  auto/gpt-5.6-luna: that binary wrote the router and two
  Read rules into settings.json (the user's "model" kept). "Check your
  skills for one that fits, then greet me." ran Skill magpie-skills,
  then Read .skills/greet-user/SKILL.md without asking, and answered
  with the skill's words. Without the rules that Read was refused
  (tried earlier with hand-written settings). Not tried on the Claude
  subscription route with this binary: there the live gateway drops a
  skill's body, which the gateway commit before this one fixes.

Known: Alma reads Claude Code's and Codex's folders too, so it may find
several magpie-skills (#5722, not tried with a real Alma).
i18n-keys is red on 3 keys that aren't this change's, the same
on origin/main (#5327, #5332, #5482, #5426).
2026-11-09 08:38:02 +08:00
yetone 922cc0ccf8 library: a plugin's tools hidden from every agent from its Plugins row
chengming0v0 (Discord) keeps a plugin for its providers but doesn't want
the MCP server it brings (minimax_query_video_generation and the rest)
shown to agents, and doesn't want to remove the plugin.

Before: a plugin that gives tools is a Library server of its own
(plugin_tools.go), switched per agent with the row's chips in Library ›
MCP, which held through updates and off/on. Nothing on the Plugins page
said so: its line read "Tools for every agent" whatever the Library had,
and an app at the router's address (/mcp/magpie/hub, agent "") was given
every server, ticked for any agent or none, so taking every chip off
still left the tools there.

Now:
- The plugin's tools line says "Tools for agents" or "Tools, hidden from
  agents", with Hide from agents / Give to agents beside the copy button
  (plugins.js, toolsServer in /api/plugins from library.PluginServers).
- PluginServerOn (servers/plugin-on {name, on}) sets Server.Hidden and
  keeps the agents it had in Paused. Hidden, no agent is given it and
  hubServers leaves it out for the router's address too. Give to agents
  gives the kept agents back; with none kept, the router's agents
  (hubAgents), or else every shown agent that can take it.
- It holds through a plugin update, the plugin off and on, an edit in the
  Library editor (SaveServer keeps it) and an agent's "every server"
  (serversAgents with no names skips a hidden one). Ticking an agent for
  it in Library › MCP shows it again (save clears Hidden).
- Library › MCP tags the server "Plugin", its tooltip pointing at Plugins.
- /mcp/magpie/tools (every plugin's tools, wired by hand) is unchanged.
- Docs: plugin-tools.md, mcp-router.md, site docs plugins (en, zh, ja).
- The core script budget is not raised: two plugins.js comments cut, the
  button's tooltips and status lines left out.

Run on mote at this tree (before the site docs, html only):
- go build ./..., go vet ./internal/library ./internal/gui, GOOS=windows
  go vet of both, GOOS=linux go vet ./internal/library: ok.
- go test -count=1 ./internal/library/: ok (187s).
- go test -count=1 ./internal/gui/ -run 'Plugin|Library|Budget|Script':
  ok (TestCoreScriptBudget 1,533,514 of 1,533,802).
- node --test plugin-tools.test.cjs (new: the line's words, Hide and Give
  posting {name, on}, the button inside its row at 980 and 420, all five
  languages, Chromium and WebKit): ok; builtins, every library-mcp-* and
  mcp-* file: ok.
- i18n-keys "a plugin's words are its own": red, the same three words on
  origin/main 61394481c (#5327/#5332, #5426, #5482); nothing of mine.
- library-mcp-first-click: one 1500ms wait red per run (chromium en 1100
  once, webkit zh-TW 1100 once) with several files at once; green alone on
  origin/main 61394481c. Not filed yet; the whole GUI suite comes next.
- site/worker.test.mjs: ok.

Broken by hand: without `!s.Hidden` in hubServers, TestPluginToolsHidden
is red ("hidden: still listed"); without the every-server skip, red at
"every server given to claude".

Not tried: a real MiniMax plugin or the real app; the whole GUI suite and
go test ./... (queued under the suite lock on mote after the push); a Go
test of toolsServer in pluginsState (the GUI test fakes /api/plugins);
Windows and Linux runs.

Reported-by: chengming0v0 (Discord)
2026-11-07 20:14:49 +08:00
yetone adcb69107c library: a skill set to disable-model-invocation is marked Manual only
sunset3279 on Discord asked to see which skills set
disable-model-invocation: true in their SKILL.md, the ones Claude Code
runs only when the user types /name. parseMeta reads the field into
meta.Manual; the library's rows (SkillView.Manual) and the agents' own
(FoundSkill.Manual) carry it, and the page puts a quiet "Manual only"
tag after the name, its tooltip naming /name and the field. A front
matter that doesn't parse, or a value that isn't a bool, is not known
to be manual: no tag. Translated in zh, zh-TW, ja and de.

Run (mote, through mote-run):
- go test -run 'TestSkillManualFromFrontMatter|TestSkillsFromFolder|TestFoundInLibraryFolder' ./internal/library: ok
- node --test internal/gui/tests/skill-manual.test.cjs: 22 pass, 0 fail
  (en, zh, zh-TW, ja, de at 420 and 1180 px, Chromium and WebKit)
- go test ./internal/library: ok (692s)
- go vet ./internal/library for darwin, windows and linux (nogui): ok
- node --test i18n-keys and i18n-en-no-cjk: 7 pass, 1 fail. The fail is
  "a plugin's words are its own", the same three entries on origin/main
  fe61503e6 (#5327, #5426, #5482); none is a word of this change.

Broken by hand:
- the Manual assignments in sync.go and skills.go taken out:
  TestSkillManualFromFrontMatter red ("deploy: manual false, want
  true", "crlf: …", "release: {…Manual:false…}").
- the manualTag calls in client.js taken out: all 22 GUI cases red
  (null, want 'Manual only').
- an explicit error branch in parseMeta was tried and left out: the test
  passed with and without it, since yaml.v3 decodes nothing on a syntax
  error and leaves a wrong-typed field zero.

Not tried: the real app with the user's own skills; the TUI and CLI show
no mark. A long name clips its tag in a narrow window, as every name tag
in the row does (.row .name is nowrap; #5512); the test uses short names.

Reported-by: sunset3279 (Discord)
2026-11-06 22:22:20 +08:00
yetone 77bda84a6f library: a check offers the skills a git repository or folder added since
refeccd (Discord): skills added from a repository or a folder only had
the existing ones updated; ones the source added later never reached
the library. GitHub sources already had this (findNew); git repositories
on other hosts and folders on this machine did not, and a folder install
didn't even remember the folder it came from.

- git: when ls-remote gives the ref a head, findNewGit reads the fetch
  the check shares and offers skills under newBase that the library
  doesn't have and hasn't offered. Once per head while its finds are
  kept (gitLooked). The address is kept as the library has it (.git and
  all), so an Add lands on the same repo@ref key.
- folder: an install from a folder now records "folder:<path>" in
  SeenSkills (offered), which is how the library knows where to look
  again. findNewFolder reads it as Add from folder does and skips a
  folder the library links, has offered, or has a skill by that name of.
- A check never adds or writes a skill: each is offered with Add and
  Ignore, as GitHub's are. A skill the user removed or set aside isn't
  offered again, and a folder edit is never written over.
- View.CheckFolders shows Check for updates with only linked skills and
  makes checkDue true; its title says it looks in folders too. A find's
  row shows its folder (pathLink) or git address. The old head note
  ("on GitHub beside skills you have…") is gone; the new title is in all
  five languages.
- docs/subsystems/library.md says so.

Old data: a folder added before this kept no folder: key, so it is
looked in only after the user adds from that folder once more (the
picker then lists the new skills, and the install records the folder).

Run (mote, at fcc0daa23 plus this change):
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...; go build ./... and the CGO_ENABLED=0
  nogui build: ok.
- go test ./internal/library: ok. go test ./internal/gui: ok except
  TestPanelHiddenByWailsMarksPageOutOfSight (#5322) and
  TestMainWindowCorners (#3949), both red the same on origin/main
  19c45d5d4 run alone.
- GUI, both engines: every library-*, skill-*, github-token,
  plugin-check-*, plugin-git, i18n-keys, i18n-en-no-cjk, gui-de,
  gui-ja, gui-zh-tw file: 1526 of 1529. Reds: i18n-keys "a plugin's
  words are its own" (#5332, #5426, #5482, red on origin/main) and
  skill-where "the switch scrolls nothing", flaky on origin/main
  19c45d5d4 too (1, 0 and 2 reds in three runs; noted on #5154).
  skill-new-in-repo's new folder case runs en and zh at 860 and 440px.

At the pushed head (rebased on origin/main 94d4866b5), again on mote:
go vet of internal/library and internal/gui, go test ./internal/library
ok, internal/gui's Budget/Size tests ok, skill-new-in-repo 4 of 4 and
i18n-keys with only the known red above.

Broken by hand: with the git branch of CheckSkills and lookInFolders
off, TestCheckSkillsFindsNewInGitRepo and TestCheckSkillsFindsNewInFolder
fail ("new: []"); with offered() not recording the picker's shown
skills, both fail offering what the picker showed ([review], [xlsx]).

Not tried: a real GitLab or intranet repository (the test uses a local
file:// bare repo with the real git); the CLI and TUI, which don't list
new skills; the Windows and Linux boxes.

Reported-by: refeccd (Discord)
2026-11-06 19:50:40 +08:00
yetone 4c8e1cfdfc providers: a Remote magpie's MCP servers go to the Library only when switched on, and follow its rename
treeman_26897 (Discord) on v0.1.3127's bridge MCP auto-discovery:

- Renamed (name and id), a Remote magpie's auto-added MCP server went:
  adoptBridges keyed it on the provider id, and after provider.Rename
  that id is gone, so the server was taken out as the provider's. Now
  RemoteHub carries the provider's Was, and adoptBridges moves the
  server's bridge, bridgesOn and bridgesOffered from an id it had to
  the id it has (one that another provider has now stays that one's).
  The server keeps its name.
- The add dialog had only the address and key. A new Remote magpie's
  editor has a Name and an ID under the key; blank, they are the
  preset's as before (provider.Add numbers them when taken), and the
  ID follows the name until one is typed.
- Adding its MCP servers is opt-in: a switch, "Add its MCP servers to
  the Library", in the add dialog (off) and in a saved one's editor.
  It lives in library.json (bridgesOn); /api/providers says it as
  libraryMCP and the save takes it (library.SetRemoteMCP). On asks the
  remote at once (provider.AskRemoteHub) when no model list is fetched
  on that save; off takes its server out. Only one switched on is
  asked (bridgeWanted). A server auto-added before this (no bridgesOn)
  is kept, and its switch shows on. A server removed in the Library
  turns its switch off; the provider gone takes its switch with it.

Run (mote, at this tree):
- go test ./internal/library ./internal/provider ./internal/gui:
  library ok; provider ok but TestRenewLoginsKeepsClaudeReading
  (#5481, red the same at the base); gui ok but TestMainWindowCorners
  (#3949). The first gui run had TestCoreScriptBudget red (app.js
  over by ~1.2KB); the new code was made compact and seven editor
  comment blocks cut to one line each. Rebased on 09812e66b the core
  was 68 bytes over again, so three more comments near the editor
  (decidesModel, modelAPIs, pickedOf) were cut: app.js is 161 bytes
  smaller than at its base, and the budget (not raised) passes there:
  go test -run 'TestCoreScriptBudget|Provider' ./internal/gui ok.
- go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags
  nogui ./...: ok; gofmt -l clean.
- node --test remote-magpie (chromium + webkit, en + zh), i18n-keys,
  i18n-en-no-cjk, gui-de, gui-ja, gui-zh-tw, preset-name,
  name-suffix-remote, remote-self, provider-unmasked, key-row-chips-fit,
  ctx-head-narrow, routing-remote-windows, usage-remote-cards,
  old-webkit: all
  green except reds that are red the same at the base 1ccad582d and
  filed: remote-magpie's "asks for the other magpie's address" fails
  at its decision-model chips before reaching anything this changes
  (#5013, #4398), and i18n-keys' "a plugin's words are its own"
  (#5332, #5426, #5482). With that one chips assertion bypassed in a
  local copy, remote-magpie's new assertions are 12 of 12 green.
  name-suffix-remote went red in Chromium (zh, zh-TW, de) beside 10
  other files, its scrollends.js import failing (#5147); alone it is
  10 of 10 green. The switch's label in the editor is the existing
  "MCP servers".

Broken by hand:
- the Was mapping off: TestRemoteMagpieMCPFollowsRename red ("renamed
  home, read before a sync: switch map[]").
- bridgeWanted/adoptBridge not asking bridgesOn: TestRemoteMagpieMCPIsOptIn
  red ("switched off, asked").
- the new editor's switch defaulting on: remote-magpie red ("off when
  added") in both engines.

Not tried: a real rename against a real second magpie (the library
tests fake RemoteHubs; the provider test renames a real providers.json
in a sandbox and checks Was reaches RemoteHubs). The CLI (provider
add/set remote-magpie) and the TUI have no switch: from there a new
Remote magpie gets no MCP server until it is switched on in the GUI.

Reported-by: treeman_26897 (Discord)
2026-11-06 15:41:43 +08:00
yetone cd9c52c16e library: a Remote magpie's MCP router is a Library server of its own
With another magpie as a provider (preset remote-magpie), its router's
MCP servers took adding that same magpie again under Library -> MCP.
Now the gateway's info (GET /v1) says "mcp_hub": true to a caller it
serves MCP to while its router is on with a server that isn't itself
another magpie's router. A fetch of a Remote magpie's models asks that
info with the provider's key, only while the library would still give
it a server, and the library then adds one: named for the provider,
http at <root>/mcp/magpie/hub with Authorization: Bearer <key>, kept to
this computer (local), on for the agents given the hub's entry.

- Offered once (bridgesOffered in library.json): removed or switched
  off by the user, it stays so until the provider is removed and added
  again.
- A server the user already has at that magpie's router (same origin,
  the router's path) is the one; none is added beside it.
- The provider removed takes its server out (adoptBridges, at Sync and
  the View read); providers.json unreadable takes nothing out; the
  provider's address or key changed changes the server's; edited to
  another address or key it becomes the user's own (keptBridge).
- No loop: every dial to a URL under /mcp/magpie/hub carries
  X-Magpie-Router, and a request with it is given no such server,
  neither listed (library Tools, gateway hubServersOf) nor run (Call,
  hubToolNamed). A server carried in by sync is never a bridge.
- No GUI change: it is a server row as any other.

Run (mote, at base 1c45645b5):
- gofmt -l clean; go vet ./internal/{gateway,library,provider} on
  darwin, GOOS=windows, and GOOS=linux -tags nogui: ok.
- go test ./internal/gateway -run 'TestHubLeavesRemoteRouterToARouter|
  TestInfoSaysMCPHub|TestHubMCP'; ./internal/provider -run
  'TestRemoteHubNoted|TestRemoteSelf'; ./internal/library -run
  'TestRemoteMagpieRouter|TestCarriedServerIsNoBridge|TestPluginTools|
  TestHub': ok.
- Real two-magpie run on mote: a built binary, two sandbox HOMEs /
  XDG_CONFIG_HOMEs, B on 3512 with a python stub provider and a stub
  HTTP MCP server behind its router, A on 3513 with B as a Remote
  magpie. After `magpie sync` on A, A's library.json had home-magpie
  (http://127.0.0.1:3512/mcp/magpie/hub, Bearer key, bridge home) and
  bridgesOffered [home]; A's /mcp/magpie/hub listed
  home-magpie__stubmcp__echo and tools/call returned the stub's echo;
  A asked with X-Magpie-Router listed nothing (loop guard); B asked
  with it still listed its own stubmcp__echo.

Broken by hand, each red: the Tools filter, the Call filter, the router
header in remoteHeaders, the same-origin dedup, offered-once, the
unreadable-providers keep, the key refresh, keptBridge, putServers'
carried reset, hubServerOf's Bridge, the gateway's hubServersOf, the
gateway's header -> ctx, info's non-bridge check, fetch's hook, the
older-magpie check and the this-magpie check.

Not tried / not handled:
- The real run was over loopback; a LAN remote's key check is covered
  only by the existing TestHubMCPRemoteEntryNeedsKey path.
- The provider's own extra headers (a proxy's) aren't carried to the
  server; a remote with several keys is asked with p.Key.
- A remote whose router is turned off later keeps its server (it lists
  no tools).
- A server the user added by hand at another magpie's router now sends
  X-Magpie-Router too, so that router leaves out its own Remote
  magpies' servers for it.
- Windows and Linux test runs (vet only).

Reported-by: treeman_26897
2026-11-06 14:33:18 +08:00
yetone 6ddfc15843 library: an MCP command's $HOME, ${NAME} and ~ work in every agent (math_milian)
A Library server whose command is $HOME/bin/x (one value for a Mac's
/Users and Linux's /home) reached each agent as written. Claude Code
spawns '$HOME/bin/x' (it expands only ${NAME}), Codex and the rest
spawn it with no shell, and magpie's own check, router and Codex run
did the same.

library.json keeps what the user wrote. withCmdVars (cmdvars.go) makes
the copy an agent is written, in sync after runVia and in a project's
files:
- an agent that expands a reference in command and args itself
  (Claude Code, CodeBuddy, WorkBuddy, Grok, Gemini, omp/Qoder/AtomCode,
  OpenCode as {env:NAME}, Cursor as ${env:NAME}) gets the reference in
  its syntax, $NAME written ${NAME}, so it is read from the agent's own
  environment and a token in an arg stays out of its file;
- every other agent (Droid, which shares Claude Code's format, by the
  new NoCmdRefs; Codex, Kiro, Crush, Copilot, Goose, Pi, Hermes, dsh,
  Command Code, LiveAgent and those reading none) gets the values: HOME
  is its own home, the rest from magpie's environment or a terminal's;
  in WSL the distro's home and no variable of magpie's;
- a leading ~ is put in for all of them; a variable nothing has is
  left as written.
Sync compares against that copy, so a second sync rewrites nothing.
magpie starting the command itself (startServer for the check and the
router, a distro's HOME asked of its login shell; specOf for Codex on
magpie) puts the same values in (launchCmd). Env and headers keep
their ${NAME} handling (envref.go) as before.

Run:
- mote: go vet ./internal/library for darwin, linux and windows;
  gofmt -l clean; go test ./internal/library ./internal/gui: every test
  but TestRunServerAsks (once, then 10/10 alone; filed #5433, my change
  leaves a command without $ or ~ as it is) and TestMainWindowCorners
  (macOS 27 on mote, #3949).
- wsl-run and win-run: TestCmdVars*, TestEnvRefs*, TestCheckStdio ok.
- Real Claude Code 2.1.316 in a sandbox HOME/CLAUDE_CONFIG_DIR, claude
  mcp list: "${HOME}/bin/srv" Connected, "$HOME/bin/srv" ENOENT
  posix_spawn '$HOME/bin/srv', the reporter's failure and why $NAME is
  written ${NAME} for it.

Broken by hand: with the sync, specOf and startServer wiring taken out,
TestCmdVarsSync (claude and codex files) and TestCmdVarsLaunch ($VAR,
~ and the spec) are red.

Not tried: the reporter's own agent and server; a real Codex, Cursor,
OpenCode, Gemini or Droid starting the written entry (their expansion
is as envref.go's cited sources say); a real WSL distro (distroHome is
unit-free, the WSL target is tested with a set Home); npxDirect on a
command spelled with a variable (it still sees the written value).
2026-11-06 10:20:34 +08:00
yetone 93d5c76c0d router: an agent with many tools is given them on demand
ArvinCharl on X: the MCP router's tools fill the context. An agent that
doesn't search its MCP tools itself (all but Claude Code, Claude
Desktop, Codex and Pi) sends every tool's whole schema on every
request. Given more than 10 router tools, such an agent now lists two in
their place: find_tools (matches by name and description, the first 5
with their inputSchema, 15 more by name) and call_tool (runs one by
<server>__<tool>, its bare name, or arguments sent as a string; an
unknown name is told the close ones). The instructions still name every
server and its tools, and a tool called by its own name still runs. The
request log names the tool call_tool ran. The address for any other app
lists every tool, since which app connects isn't known.

Library → MCP gains a "Tools on demand" toggle (settings
routerAllTools, kept by KeepOwn and the settings API); turned off,
every agent gets every tool whole as before.

Run on mote (after the rebase onto 083821dc9: gateway vet, -run
'Hub|MCP|Settings|Search' and the four GUI files again, ok, 70 of 70):
- gofmt -l: empty. go vet, GOOS=linux go vet -tags nogui, GOOS=windows
  go vet of gateway, settings, settingsapi, gui, library: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/settings
  ./internal/settingsapi ./internal/gui ./internal/library: ok;
  ./internal/gateway -run 'Hub|MCP|Settings': ok.
- GUI (Chromium + WebKit, every language): library-mcp-router-tools,
  library-mcp-router-note, library-mcp-hub, i18n-keys: 70 of 70.
Broken by hand: hubOnDemand forced false turns TestHubMCPToolsOnDemand
red.
Not tried: a real OpenCode or Gemini CLI session against the router;
the full gateway package and full GUI suite.
2026-11-04 21:00:51 +08:00
yetone 50265256ba library: a note on a skill or an MCP server, the library's own (youyo.p_10001)
youyo.p_10001 on Discord: with many skills and MCP servers installed,
you can't tell what each is for or which to use. A skill has the
description its author wrote for models, often in English and about
what it does, not why you installed it. An MCP server has nothing but
its command and its tool list. So each now takes a note in the user's
own words.

- Server.Note and Skill.Note in library.json: one line of at most 200
  characters, whitespace run together (checkNote), as a hook's
  description (#2011). A longer one is turned away, not cut.
- The server editor has a Note field under the name. A skill's reader
  (2a19043af's file reader) has one over its files: Save shows once it
  changes, saves the file being edited with it, and a changed note is
  asked about before the dialog closes. SkillNote, POST skills/note.
- A row shows the note in place of its command or description, so rows
  keep their height; the tooltip gives the note, then that line. The
  skills' filter matches notes.
- No agent is given a note: not in any agent's MCP entry, a project's
  file, the MCP router's list or a skill's copied SKILL.md.
- A sync carries it (CarriedSkill.Note; a server goes whole), and
  clearing it is carried too. An older magpie on another computer
  doesn't know notes: a bundle it writes has none, so a sync from it
  clears them. The TUI's server editor keeps a note as it was.

Run at the pushed head:
Run at the pushed head (on origin/main f168dd278, then
rebased onto 94d0fbfcd, whose two commits change only
migrate_zcode.go and the searcher-pick test):
- mote: go test -timeout 45m internal/library (TestNoteNeverGiven,
  TestNoteCarried, TestNoteTooLong), gui, tui, davsync, backup: ok,
  except internal/gui's TestMainWindowCorners/macOS_26_SDK, mote's SDK
  (#3949). GOOS=windows go vet of library, gui, tui and GOOS=linux of
  library, tui: clean. gofmt -l: clean.
- mote, both engines, every language, narrow and wide: skill-edit (the
  skill reader's note), library-mcp-json (the server's note, its row and
  the filter), mcp-editor-cancel, library-mcp-win-line, market-address,
  market-have, i18n-keys: 108 of 108.
- WSL, the whole GUI suite: no red in a library file that origin/main
  hasn't too (see the command commit; #4120, #4471 for the rest).
- "Note" is in core i18n.js, not the plugin's: agent code says it as a
  word. The rebase had dropped main's title on a server row's command
  line (library-mcp-win-line went red); it is back, and with a note the
  tooltip gives the note, then that line.

Broken by hand, each red, then restored:
- add("note", s.Note) in Claude's MCP format: TestNoteNeverGiven
  (.claude.json held the note).
- the carry of Note left out: TestNoteCarried.
- note left out of the server editor's save: the GUI test, 22 of 22.
- notes left out of the skills' filter text: the GUI test, 22 of 22.
- the note's save left out of the skill reader's Save: skill-edit, 22
  of 22 (Save never goes away).
- the note left out of the reader's unsaved check: skill-edit, 22 of 22
  (closing never asks).

Not tried: a real sync between two computers, a real agent reading its
config (the guard reads every file magpie writes in a sandbox HOME), a
real app window, Linux WebKitGTK.
2026-11-03 21:43:54 +08:00
yetone 22f5cf69e5 library: an agent in WSL links to the distro's one copy of a skill (cutemmuu on X)
Cause: an agent in a WSL distro could only get copies (Target.Copy).
A distro can't follow a link to the library's folder on Windows. A
link Windows makes through \\wsl.localhost (os.Symlink) is an empty
folder inside the distro. Windows can't use a link the distro has: it
can Lstat one (irregular), but Readlink fails ("Incorrect function"),
and Stat, ReadDir and Remove all say it isn't there. Probed on
xiaomi-gpu with magpie-desktop. So every agent there got a copy of
its own of every skill.

Now each distro keeps one copy of each skill its agents are given,
magpie's and marked, in ~/.local/share/magpie/skills (Target.Store,
storeSkill). Each agent there gets a link to it, which wsl.exe makes,
reads and removes inside the distro (agent.WSLSymlink, WSLReadlink,
WSLRemoveLink). The scripts refuse to put a link over a folder or file.
- An edit made through the link is in that copy, and takeEdits reads
  it like any copy of magpie's.
- When no agent there links to a copy or is given its skill any more,
  sweepWSLStores removes it. An edited copy goes to the backups.
- A folder in the store that isn't magpie's is never touched. Each
  agent it blocks reports a problem and keeps what it had.
- An agent set to copies (SkillHow) still gets copies of its own.
- So does one whose skills folder or the store is on a Windows drive
  (#4502): a link the distro makes there can't be read from Windows.
- The copy isn't put in the distro's ~/.agents/skills. Every agent
  there that reads that folder would get each skill, ticked or not.
- A stopped distro's agents are now shown as linked (HowLink), not as
  forced to copies.

Agents that read ~/.agents/skills on their own (readsShared, checked
against each one's source or docs when the list was made): Codex,
Gemini CLI, OpenCode, DevEco Code, Crush, dsh, Command Code, Devin,
Droid, Cline, Grok Build, Grok App, fx, Alma, Kimi Code and OmO, plus
Pi from 0.54.0 and omp from 11.0.0. Claude Code doesn't. Ticks are per
agent, so the store keeps per-agent choices working in WSL.

Existing users: nothing to do. On the next sync, each per-agent copy
magpie made in a distro is replaced by a link:
- its edit is taken into the library first (newest edit wins);
- a copy whose edit lost is set aside with the backups (wslRelink);
- unmarked folders (the user's own skills) are left alone.

Run:
- mote, at 3f1f1882a plus this change:
  - go test ./internal/library ./internal/agent -timeout 45m -count=1:
    both ok (493 and 1210 Test funcs; library 184s, agent 312s).
  - gofmt -l .: empty.
  - GOOS=windows, linux and darwin go vet of both packages: ok.
- xiaomi-gpu, Windows 11, WSL 2, distro magpie-desktop only:
  - TestWSLLinksLive passes. A link made through wsl.exe is followed by
    the distro, read back from Windows, refused over a folder and
    removed alone.
  - TestWSLSkillsLinkedLive passes. Working in a /tmp home inside the
    distro, it checks:
    - links for Codex and Claude Code that the distro follows;
    - a second sync changes nothing;
    - an edit made in WSL through the link reaches the library and
      Windows' Claude Code;
    - copies, then links again;
    - an untick removes the links and the store copy.
  - go test ./internal/library ./internal/agent -run 'WSL|Wsl|Skill'
    with MAGPIE_WSL_TEST_DISTRO set: library ok. In agent, only the
    older TestWSLCodexLive is red. It calls wslList() without -l -q, so
    it lists no distros. Filed as #5077; this change doesn't touch it.
New tests:
- TestWSLLinks (fake);
- TestWSLOldCopiesBecomeLinks, which edits a copy and then syncs;
- TestWSLEditThroughLinkReachesTheLibrary;
- TestWSLStoreSweepKeepsEdits;
- the two live tests above.
TestWSLSkillsCopied is now TestWSLSkillsLinked.

Broken by hand (logs in wsl-skills-scratch):
- WSL targets given copies again: 7 red, including TestWSLTargets,
  TestWSLSkillsLinked and TestWSLOldCopiesBecomeLinks.
- takeEdits not following the link to the store: 1 red,
  TestWSLEditThroughLinkReachesTheLibrary.
- ours not counting a link to the store: 3 red.
- wslLinkScript's folder refusal dropped: TestWSLLinksLive red on the
  real distro.

Not tried:
- the magpie GUI on Windows against a real distro, and agents running
  in a real WSL reading a skill through the link (the distro reads the
  link's files, checked with cat);
- WSL 1;
- a distro whose home is on a Windows drive (covered by the fake
  #4502 tests only);
- the GUI suite, since no GUI file changed.
2026-11-03 20:03:00 +08:00
yetone 1851ead1a7 library: Pi and omp lock ~/.agents/skills from their versions; Put skills in links every skill there
usrname1833 on Discord asked for two things.

Pi reads ~/.agents/skills itself, so a skill kept there is Pi's whatever
is ticked, with the lock as Codex and OpenCode have. Pi started to in
0.54.0, not 0.19 (its CHANGELOG; userAgentsSkillsDir in
package-manager.js), and omp in 11.0.0 (src/discovery/agents.ts; 10.6.2
doesn't). Target.SharedToo says so from the version, and every reader of
readsShared goes through Target.readsSharedDir: Always (the lock),
syncSkills' inShared (no second link) and a handover's readsSharedHere.
OmO's senpi reads it in every npm version (0.74.0 up), so omo joins
readsShared. A Pi or omp of no known version is taken as older, as
before.

The second ask is a switch: Library > Skills > "Put skills in": each
agent's own folder (the default, today's behaviour) or ~/.agents/skills
(Library.SharedSkills; POST /api/library/skills/where {how};
magpie library skill where agents|shared). On, every library skill on
here gets magpie's link in ~/.agents/skills (syncShared, after
sweepShared), so every agent and tool reading that folder has it and
shows it locked. The files stay in the library rather than moving, so
updates, edit tracking and Off here keep working; existing skills just
get links when it is turned on, nothing is moved. A user's own entry by
the same name is never written over. Off takes out magpie's links there
and nothing else, and agents' own links come back. Per computer:
Collect doesn't carry it. docs/subsystems/library.md says all this.

Not covered, filed: on Windows without link rights the shared entry is
a marked copy, and takeEdits doesn't take edits made in it (#4958).

Run on mote rebased on d76c4b23a (which has 8abdf53a8):
gofmt -l clean; go vet GOOS=linux and GOOS=windows on internal/library,
internal/gui, internal/cli ok; go test internal/library, internal/gui,
internal/cli ok. GUI, every skill-*, library-* and i18n-keys file in
chromium and webkit: 1302 pass, 4 fail, all in library-all (webkit) and
library-null-agents (chromium). Both pass alone at this tree (52/52), so
they are load reds, filed as #4967. skill-where.test.cjs (new) covers en,
zh, zh-TW, ja, de at 900px and 400px. Before the rebase, cli's
TestEveryRouteHasACommandOrIsNamed was red on /api/usage/checkin-account
(not this change); it is green at this base.

Rebased twice more on origin/main (cli's settings_parity_test, app.js,
i18n.js, settings): internal/cli and internal/gui go test ok, i18n-keys
and skill-where green at the pushed tree.

Broken by hand, each red, then restored: since() always false
(TestPiReadsSharedSkillsFromItsVersion, TestSkillsWhereShared red);
syncShared step dropped (red); sweepShared's keepsShared keep dropped
(red on the SameFile no-relink check); the holder line in wanted
(TestSkillsWhereSharedWithKimi red); skillWhereBar not appended
(skill-where 0/11 per engine).

Not tried: a real Pi, omp or OmO run (versions read from their npm
source); the setting on the Windows box or in WSL; the whole GUI suite.
2026-11-03 05:43:12 +08:00
ggbdpq ecdcbe48a8 fix(library): give Kimi Code its own skills folder (#4379)
A skill given to the new Kimi Code (2.x) had no folder of its own to
go to: its target was ~/.agents/skills, which fourteen other agents
read as well, so it reached every one of them whatever the library
ticks, and the page locked their chips for it. Handing it over to the
library didn't isolate it either: Kimi Code's own link was written
into the shared folder all the same, and no sync took it out, since
none of the agents whose folder the shared one is had given the skill.

Kimi Code 2.x reads a folder of its own besides the shared one
($KIMI_CODE_HOME/skills, else ~/.kimi-code/skills - docs/
customization/skills.md, "Skill Locations"), so its skills go there
now, and it joins readsShared: a skill kept in ~/.agents/skills for
another agent is read where it is, with no second link in Kimi
Code's own folder. The legacy kimi-cli branch stays as it was: it
reads the first of ~/.kimi/skills, ~/.claude/skills, ~/.codex/skills,
so a folder of its own would hide Claude Code's from it.

What an older magpie put in ~/.agents/skills for Kimi Code is swept
out: an entry of the library's own stays there only while an agent
whose folder the shared one is still gives the skill. The user's own
entries stay, and so does a copy takeEdits couldn't scan.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 07:40:21 +08:00
ggbdpq 6803d7d51c fix(library): update skills the skills CLI installed from where its lock says (#4645)
What changed:
A skill installed with the skills CLI (npx skills add) and brought in
or handed over kept only a From label in library.json, so
`magpie library skill update` said it "isn't from GitHub or a git
repository" and the check for updates skipped it. The lock that named
its repository for grouping now names it for updating too: lockOrigin
(the lock entry's sourceType is github, the lock says when it wrote
the folder, and the folder is the one it wrote, madeBy) is asked where
CC Switch's record is, in updatable and prepare. Updated that way, the
skill carries the source in library.json from then on, as one
installed from GitHub does. A lock entry that says no time, or a
folder the CLI didn't write, only groups, and stays as it is.

Run:
go test ./internal/library/ -run 'TestSkillLockOrigin' -count=1 -v
go test ./internal/library/ -count=1 -tags nogui

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 05:38:11 +08:00
yetone 8f804396fd mcp router: the hub says what its servers are for, and Pi's first prompt hears it
Asked "can you drive a browser?", Pi said no until nudged. Two causes:

- The hub's initialize instructions were one generic sentence ("The tools
  of the MCP servers ticked for this agent…"), so nothing said that
  playwright drives a browser or deepwiki answers about GitHub repos.
  They now start with one line, "Tools of context7 (…), deepwiki (…),
  playwright (Drive a real browser), …", at most 250 characters (names
  first, "and N more" past room, abouts shared out short-first), then a
  "- name: about" line per server. An about comes from the market entry
  the server was added from (by key, then by name), else none.
- Pi 1.4.0 lists a codemode server in its system prompt by its config
  description, else its instructions' first line, but writes the first
  prompt without waiting for codemode servers. In -p runs the first
  prompt had "- mcp__magpie (codemode)" and nothing after it. The hub
  entry in Pi's mcp.json now carries that line as its description,
  kept in step with the servers ticked; a description on another entry
  is the user's and is left alone. Pi only: other formats are unchanged.

Sync runs under the library lock, so the hub's servers are read from the
library already loaded ((*Library).hubServers), not through hubServers().

Run (mote, at origin/main ee7b8b072 + this change):
- go test ./internal/library ./internal/gateway -run 'TestHub|TestPi'
- TestHubMCPNamesItsServers: 10 failures without the change, green with it.
- TestHubPiDescription: red with the description assignment removed by
  hand ("the hub entry's description \"\""), green with it.
- gofmt -l, go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet,
  the three builds, go test -tags nogui -timeout 45m ./...: all ok (87 packages).

Real use: a sandbox HOME with context7, deepwiki, fetch, playwright and
time ticked for Pi 1.4.0 (deepseek through the sandbox gateway). After
`magpie library sync`, Pi's mcp.json hub entry carries the line. Five
everyday questions, none naming MCP, two runs without the description
and three with it:
- "can you drive a browser": playwright used every time.
- the H1 of usemagpie.ai: fetch + playwright every time.
- "is it OK to call a colleague in San Francisco now": bash `date`
  without the description (2 of 2), the time server with it (3 of 3).
- Hono timing middleware docs: context7 in 1 of 2 without, 2 of 3 with.
- how the Next.js App Router client cache works: deepwiki in 1 of 2
  without, 1 of 3 with; Pi mostly clones the repo instead. Not fixed here.

Not tried: other agents' first prompts (they get the new instructions
text, not a description), Pi versions other than 1.4.0.
2026-11-01 21:22:58 +08:00
yetone 01ccbd40a0 library: an MCP router says which computer it is, so an agent can pick between two (packinggoodsllc_07668 on Discord)
Two magpies, one in China and one in Los Angeles, each serve the same
tools through their MCP router (/mcp/magpie/hub). An agent connected to
both saw two identical web fetches and couldn't pick the one in Los
Angeles to reach Google.

Each router now says where it is:
- initialize's instructions end "This router: <name>. Each of its
  tools' descriptions starts with [<name>]; ...", and serverInfo.title
  is "Magpie MCP hub · <name>";
- each tool's description in tools/list starts "[<name>] " (once: a
  description that starts so already, another magpie's router behind
  this one, isn't given it twice).
<name> is the user's words (settings.RouterNote, one line, 80
characters at most) to every caller. With none it is this computer's
name, to callers on other computers only: an agent on this computer
has one router at hand, and its prompts stay as they were.

RouterNote is this computer's own (KeepOwn): library.json is synced,
settings.json isn't, so a sync never brings the other machine's name.
It is set in the Library's MCP tab, in a Router name row under the
router's address (shown while the router is on): a plain field with the
computer's name as placeholder, saved on Enter or leaving it, Escape
puts the saved words back, an input method's Enter is its own. POST
/api/settings keeps it. Translated in zh, zh-TW, ja, de.
docs/subsystems/mcp-router.md has the rule.

Run (mote, at a5a9cdf7b + this change): go vet ./... for darwin, linux
and windows ok; go test -tags nogui ./... -timeout 45m: every package
ok except internal/gui's TestSettingsSaveKeepsWhatItDoesNotSend on
BusyLoad, red on main since 8d8df0639 (#4739, fixed in the next
commit). After rebasing on 9feb1024c: internal/gui, settings, library
and gateway again, and node --test library-mcp-router-note (new),
library-mcp-hub, mcp-hub-direct and i18n-keys, chromium and webkit,
en/zh/zh-TW/ja/de, at 1100 and 420 wide.

Broken by hand: hubWhere returning "" turns TestHubMCPSaysWhere red;
dropping RouterNote from KeepOwn turns TestRouterNote red; dropping it
from POST /api/settings' carry list turns TestHubNoteSaved and
TestSettingsSaveKeepsWhatItDoesNotSend red. i18n-keys caught a test
comment saying "Router name", reworded.

Not tried: two real magpies on two computers with a real Claude Code
or Codex connected to both, and whether a model actually picks by the
prefix; the Linux and Windows apps' Library tab.
2026-11-01 15:23:15 +08:00
yetone 557f51dbf0 library: a skill linked into an app version the update deleted follows it to the current one (tjhhhh on Discord)
tjhhhh: ego lite keeps its skills in its framework's Versions/<v>. After
the app updated, the skill was in the new version's folder, the old folder
was gone, and magpie still linked the old one. dccfefdf7 (#2635) linked new
imports through the app's own steady link (~/.local/share/ego/ego-skills, or
Versions/Current), but a skill brought in before then links straight to the
resolved Versions/<old> path. tjhhhh's case is that old link: an import
made since dccfefdf7 already follows the update
(TestImportedSkillFollowsAppUpdate).

followMovedSkills (skill_moved.go) runs on every read of the Library page,
under the read's link memo, which is restarted when a link is mended. It
also runs as the first step of every sync. For each library skill that is
a link:
- Target gone, and its first missing part named like a version: link the
  same place under the folder's Current/current/latest link. With no such
  link, use the highest version beside it that has a SKILL.md there
  (1.10 after 1.9).
- Target in Versions/<v> while the bundle's Versions/Current links to
  another version with the same skill: link it through Current.
Source.Dir follows. Only the link is replaced (os.Remove of the link, then
dirLink, and the old link is put back if the new one can't be made). A
folder of the library's own, a link the user deleted that isn't a version
(still shown missing), and the app's old version folder are left alone.
docs/subsystems/library.md says so.

Run (all on mote via mote-run):
- New tests on ego lite's real layout (egoLite: framework Versions/<v>,
  Current, ~/.local/share/ego links): TestOldImportFollowsDeletedVersion
  (0.5.1.13 deleted, then 0.6.0.12, then the next update to 0.7.0.1 by
  itself, plus the agents' link through the library),
  TestOldImportFollowsVersionsCurrent (old kept, through Sync()),
  TestOldImportFollowsHighestVersion, TestMovedSkillsLeaveTheRest and
  TestVersionLess. All pass, as do dccfefdf7's three tests.
- Broken by hand: with followMovedSkills returning false at once, the
  three OldImport tests are red.
- go vet -tags nogui ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean. gofmt -l: nothing.
- Full go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME:
  80 ok, 3 FAIL.
  - internal/library TestReadLooksAtEachFolderOnce was mine: the mend ran
    before the read's memo, so each skill link was looked at twice. Fixed
    (the memo starts first and restarts after a mend). The whole
    internal/library package then passed (75s).
  - internal/gui TestSettingsSaveKeepsWhatItDoesNotSend is red on
    origin/main 3ecc02b78 and ccc791231 alike (#4514, SearchAll).
  - internal/cli TestAgentFieldNameShowsIt failed once under load. It
    passes alone and in a whole internal/cli run, and its message was lost
    to my grep of the log (#4583).
  The full ./... was not run again after the memo fix.
- At the pushed head, rebased on a51776f9c (which changed internal/library
  too): go vet and the whole internal/library package ok (95s).

Not tried: tjhhhh's own machine and ego lite's real update (the layout is
the #2635 fixture, built from iomect's report). Windows junctions to a
deleted version (dirLink is the same call ImportSkill uses). An app that
renames the folder above the version is not followed: it stays missing.
2026-10-31 22:01:45 +08:00
yetone 73a12e8bf6 wsl: a distro's agent folder that is a link is opened where it leads (#4502)
On Windows, adding a skill or switching RTK on for an agent in WSL failed
with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file
when that file already exists` (linusxiong). In the distro ~/.codex is a
link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't
follow a link the distro has: a mkdir of it says it exists, and nothing
below it can be made, written, read or listed. ggbdpq found and explained
the link (thanks); their patch, which takes that EEXIST as "there", wasn't
used: the writes below the link fail next (its test passed because a
symlink here is followed).

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

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

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

Not tried: the full ./... suite; the GUI (no GUI change; the unreached
notice uses the existing Notice); a real Codex/Claude Code run against
the moved files in the distro.
2026-10-31 21:29:22 +08:00
JoeyWu-tech 722ca104c0 library: the Subagents page lists a stopped WSL distro's agents, greyed (#4238)
While a WSL distro runs, the Subagents page lists its agents that take
subagents here (Claude Code, Codex and the rest of SubagentAgents) with
a greyed chip that says magpie gives subagents only to agents on this
computer, not yet to it in WSL. With the distro stopped, they were gone
from the page: subagentsView built its agents from the targets only, and
an agent in a stopped distro is no target (#3896).

As the commit before did for the Hooks page: subagentsView now also
lists each stopped agent of those kinds that the MCP and Skills pages
list from its shape (asleepView), with the reason it has while the
distro runs (wslNoSubagents, which subagentSpecOf now shares), so its
chip, a subagent's problem for it and the "magpie can't give subagents
to ... yet" line are the same, stopped or running. Nothing of the
distro is opened. One magpie never saw (unseen) isn't listed.

No WSL agent can be given a subagent yet, so there is nothing to keep
for Woken. No change to the page; nothing new to translate. The line in
library.md that named the pages leaving a stopped distro's agents out
(#4182, #4237, #4238) is gone with this.

What was run (tree e03c52f0, on origin/main ec5571d6, go1.26.8,
linux/amd64, Linux 5.15, umask 077):
- TestWSLStoppedSubagents (new): the Subagents page's WSL agents read
  while a FakeWSL distro runs (Claude Code and Codex, the kinds it
  lists, each with the reason), then with it stopped and its folder
  moved away: the same two, field for field. A subagent given the
  stopped Claude Code has the same problem for it. Nothing was written
  into the distro and FakeWSLRuns didn't move.
- Broken by hand, each alone: subagentsView skipping the stopped agents
  ("... while it is stopped: map[], while it ran: map[claude@wsl:...]",
  and the subagent with no problem for Claude Code); the stopped agents
  listed with no reason ("No:" empty against the running ones', the
  same problem missing).
- library-wsl-asleep, its new Subagents case beside the Hooks one,
  Chromium and WebKit, en, zh, zh-TW, ja and de at 1100 and 390px: a
  subagent's chips are Claude Code and the stopped Codex, Codex's
  blocked, asleep, aria-disabled, with the WSL reason as its tooltip,
  the line names it, a click on it sends nothing. As for Hooks, the page
  isn't changed, so only TestWSLStoppedSubagents catches the gap.
- GUI files, each alone, Chromium and WebKit, Node 22.22.1, Playwright
  1.62.1, DISPLAY unset: library-wsl-asleep 44/44 each, i18n-keys 4/4,
  library-subagents 6/6, library-hooks 6/6, library-gone-agents 11/11:
  142 of 142.
- go test -tags nogui -count=1 ./internal/library ./internal/agent
  ./internal/cli: library and cli ok; agent red in TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
  TestOmpDetectedWithPiDir
  (#3141). go test -race -run TestWSL ./internal/library: ok.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag on
  linux: exit 1 (no GTK headers here).
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2; 9m49s,
  load 20 at its start): 78 packages ok, and 8 tests red in 3 packages,
  each filed: agent TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649); plugin
  TestGatewayHookMixedPiPackage ("starting plugins: context deadline
  exceeded", #2865, under load). The same suite on an origin/main
  ec5571d6 worktree right after (10m01s): the same agent and gui reds,
  test for test, and plugin ok there.

Not tried: a real distro, and the real app; FakeWSL counts the wsl.exe
-d commands run in the stopped distro (none).

Reviewed and run again by the maintainer at the stack's tree 45994757c
(this commit and the six beside it, on origin/main 90518de26), go1.26.8:
- mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin,
  GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0.
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  internal/proc TestNoCommandBypassesProc (#4491), both red on main
  from b09349d17 and c59c547c5, in files this stack doesn't touch.
  go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for
  library and plugin: ok.
- magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and
  WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys
  file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here
  touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items,
  -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a
  time, at load ~60: 74 of 92 here, 77 of 92 at 90518de26 itself. Red
  in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in
  Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case
  red here only, the case #4483 has red on main. -chip-fan and -items
  are #3072's and #4501's kind, WebKit under load.
- Broken by hand on mote: subagentsView skipping the stopped distro's
  agents turns TestWSLStoppedSubagents red.
2026-10-31 17:00:14 +08:00
JoeyWu-tech 0bd89a0237 library: the Hooks page lists a stopped WSL distro's agents, greyed (#4237)
While a WSL distro runs, the Hooks page lists each of its agents with a
greyed chip that says magpie gives hooks only to agents on this
computer, not yet to it in WSL. With the distro stopped, they were gone
from the page: hooksView built its agents from the targets only, and an
agent in a stopped distro is no target (#3896). So a hook's chips, and
the "magpie can't give hooks to ... yet" line, changed with whether WSL
was running.

hooksView now also lists each stopped agent that the MCP and Skills
pages list from its shape (asleepView), with the reason it has while
the distro runs (wslNoHooks, which hookSpecOf now shares), so its chip,
a hook's problem for it and the line are the same, stopped or running.
Nothing of the distro is opened. One magpie never saw (unseen) isn't
listed, as on the other pages.

No WSL agent can be given a hook yet, so there is nothing to keep for
Woken: the issue's "write a change once the distro runs" has no change
to write until hooks reach WSL. No change to the page, which already
greys a chip whose agent has `no` set; nothing new to translate.

What was run (tree fb979055, on origin/main ec5571d6, go1.26.8,
linux/amd64, Linux 5.15, umask 077):
- TestWSLStoppedHooks (new): the Hooks page's WSL agents read while a
  FakeWSL distro runs (Codex, Claude Code, Pi and OmO, each with the
  reason), then with it stopped and its folder moved away: the same
  four, field for field. A hook given the stopped Codex has the same
  problem for it. Nothing was written into the distro and FakeWSLRuns
  didn't move.
- Broken by hand, each alone: hooksView skipping the stopped agents
  ("... while it is stopped: map[], while it ran: map[claude@wsl:...]",
  and the hook with no problem for Codex); the stopped agents listed
  with no reason ("No:" empty against the running ones', the same
  problem missing).
- library-wsl-asleep, its new Hooks case, Chromium and WebKit, en, zh,
  zh-TW, ja and de at 1100 and 390px: a hook's chips are Claude Code and
  the stopped Codex, Codex's blocked, asleep, aria-disabled, with the
  WSL reason as its tooltip, the line names it, a click on it sends
  nothing. The page isn't changed, so this case pins what it draws from
  hooksView's answer and can't go red by a break in the Go code: only
  TestWSLStoppedHooks does.
- GUI files, each alone, Chromium and WebKit, Node 22.22.1, Playwright
  1.62.1, DISPLAY unset: library-wsl-asleep 33/33 each, i18n-keys 4/4,
  library-hooks 6/6, library-gone-agents 11/11: 108 of 108.
- go test -tags nogui -count=1 ./internal/library ./internal/agent
  ./internal/cli: library and cli ok; agent red in TestInstalledVersion,
  TestHowInstalled, TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
  TestOmpDetectedWithPiDir
  (#3141, a set that varies from run to run;
  three of them red at origin/main ec5571d6 in its suite too). go test
  -race -run TestWSL ./internal/library: ok.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag on
  linux: exit 1 (no GTK headers here).

Not run at this tree: the full go test ./..., which ran at the
branch's last commit. Not tried: a real distro, and the real app;
FakeWSL counts the wsl.exe -d commands run in the stopped distro
(none). Not changed: the Subagents page (#4238, the next commit).

Reviewed and run again by the maintainer at the stack's tree 45994757c
(this commit and the six beside it, on origin/main 90518de26), go1.26.8:
- mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin,
  GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0.
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  internal/proc TestNoCommandBypassesProc (#4491), both red on main
  from b09349d17 and c59c547c5, in files this stack doesn't touch.
  go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for
  library and plugin: ok.
- magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and
  WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys
  file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here
  touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items,
  -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a
  time, at load ~60: 74 of 92 here, 77 of 92 at 90518de26 itself. Red
  in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in
  Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case
  red here only, the case #4483 has red on main. -chip-fan and -items
  are #3072's and #4501's kind, WebKit under load.
- Broken by hand on mote: hooksView skipping the stopped distro's
  agents turns TestWSLStoppedHooks red.
2026-10-31 17:00:14 +08:00
JoeyWu-tech 4ff086d1fb library: the Instructions page lists a stopped WSL distro's agents (#4182)
With a WSL distro stopped, the Instructions page listed none of its
agents: instructionsView built its rows from the targets only, and an
agent in a stopped distro is no target (#3896). So Claude Code, Codex
and the rest in WSL couldn't be switched on until the distro ran. And a
switch on the page sent the agents the page listed, so switching any
agent on or off while the distro was stopped took its agents off the
set, and the next sync once the distro ran took magpie's part out of
their files.

The same way c1da9ccda did it for the MCP and Skills pages: keepShape
keeps the instructions file's path in the shape (wsl.json, key
library:<kind>) while the distro runs. While it is stopped,
instructionsView lists its agents from that (asleepInstructions, asleep:
<distro>), switched on as library.json has them, with what each gets
besides, which is in magpie's own folder. The file itself isn't read:
its own lines, an edit to magpie's part and an override file aren't
known then, so the row says nothing of them, and Move its own and Write
again don't show. One switched on whose file magpie never saw (no path
in its shape, or a shape kept before this commit) is listed as unseen.
ReadInstructions, which the page reads after each instructions change,
lists them too, or the rows would go after the first switch. The TUI's
instructions picker sends the agents Read lists as on, so by its code it
had the same loss and keeps them now, with no change of its own (read,
not run).

A switch on one is kept in library.json, as any is. Takes accepts one
with a known file, so the CLI's `library instructions agents` records
it, and says on stderr that the distro isn't running (AsleepIn, as
before). Woken now watches a distro that Instructions.Agents names, or
whose agent still has magpie's part (Applied.Instructions), so a switch
on is written there once the distro runs, and a switch off is taken
out. Nothing is opened or run in the distro while it is stopped.

The page greys a stopped agent's row (icon as on the chips), shows its
path as text, not a button (showing it in Explorer opens the distro),
gives its switch the line's words as its tooltip and as the status after
a switch, and adds the one line per distro under the list
(asleepAsides, now given the page's own rows). An unseen agent's switch
is greyed out (aria-disabled), says why with the unseen chip's tooltip,
and sends nothing; every other switch keeps it on. No new strings: the
line, the unseen tooltip and "{agents} can be changed once it runs." are
c1da9ccda's, in en, zh, zh-TW, ja and de. The "keeps no user-wide
instructions file" line still leaves stopped agents out.

The MCP and Skills pages are the same, except that an agent seen with
an instructions file only (no MCP file or skills folder) now has a
shape: it is listed there as it is while the distro runs, among the
agents with no MCP servers or no skills folder, where before it was
listed only when unseen and named.

What was run (tree 7fd5f65a, on origin/main ec5571d6, go1.26.8,
linux/amd64, Linux 5.15, umask 077):
- TestWSLStoppedInstructions (new): Codex and Claude Code in a FakeWSL
  distro, seen running, then stopped with the distro's folder moved
  away. Both are on the Instructions page, asleep, at their files, Own,
  Edited and Override empty (Codex's AGENTS.md has a line of its own,
  counted once it runs), from Read and from ReadInstructions alike.
  Codex switched on while stopped is kept; Woken writes the shared text
  into its AGENTS.md once the distro runs. Stopped again and switched
  off, Woken takes the part out (the file is "Mine.\n" again). Nothing
  was written into the stopped distro and FakeWSLRuns didn't move.
- TestWSLStoppedInstructionsUnseen (new): Pi switched on in a distro
  stopped before magpie saw its file is listed on and unseen; Codex,
  never seen and off, isn't; Takes refuses it.
- Broken by hand, each alone, the two tests above run:
  instructionsView skipping the stopped agents: "a stopped distro's
  Codex isn't on the Instructions page", "Pi switched on while stopped:
  <nil>". distrosNamed without Instructions.Agents: "no sync once the
  distro ran" at the first start. distrosNamed without
  Applied.Instructions: the same at the second start, the switch off.
  ReadInstructions back on Targets(): "Read lists 15 instructions rows,
  ReadInstructions 11". Takes without instructions: "Takes while
  stopped: ... can be given instructions". keepShape without the path:
  Codex not on the page.
- library-wsl-asleep, its new Instructions case, Chromium and WebKit,
  en, zh, zh-TW, ja and de at 1100 and 390px: Codex's row greyed, its
  path a span, not the reveal button, its switch's tooltip the
  distro's line; Pi's switch aria-disabled with the unseen tooltip; one
  line naming the distro and Pi. A click on the path asks no reveal, a
  click on Pi's switch sends nothing, Codex switched on sends claude,
  Codex and Pi with the line as the status, and Claude Code switched off
  sends Codex and Pi. Broken by hand in the page, in Chromium: Pi's
  switch sending (all 10 red at the deepEqual of the posts with [] after
  Pi's switch is clicked), the path a reveal button again (all 10 red,
  tagName BUTTON for SPAN), no line (all 10 red, 0 .lib-asleep lines for
  1).
- GUI files, each alone, Chromium and WebKit, Node 22.22.1, Playwright
  1.62.1, DISPLAY unset: library-wsl-asleep 22/22 each, i18n-keys 4/4,
  library-instr-sets 3/3, library-instr-busy 6/6, library-linked-set
  11/11, library-alma-profile 6/6, library-gone-agents 11/11,
  library-items 9/9, library-mcp-hub 11/11: 166 of 166.
- go test -tags nogui -count=1 ./internal/library ./internal/agent
  ./internal/cli: library and cli ok; agent red in TestInstalledVersion,
  TestHowInstalled, TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141, a set that varies from run to run;
  five of them red at origin/main ec5571d6 in its suite too). go test
  -race -run TestWSL ./internal/library: ok.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag on
  linux: exit 1 (no GTK headers here).

Not run at this tree: the full go test ./..., which ran at the
branch's last commit. Not tried: a real distro stopped and started, and
the real app; FakeWSL counts the wsl.exe -d commands run in the stopped
distro (none). Not changed: the Hooks and Subagents pages (#4237,
#4238, the next commits), and the CLI's code for `library
instructions agents`, which already says on stderr that a stopped
distro's agent is written there once it runs.

Reviewed and run again by the maintainer at the stack's tree 45994757c
(this commit and the six beside it, on origin/main 90518de26), go1.26.8:
- mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin,
  GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0.
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  internal/proc TestNoCommandBypassesProc (#4491), both red on main
  from b09349d17 and c59c547c5, in files this stack doesn't touch.
  go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for
  library and plugin: ok.
- magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and
  WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys
  file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here
  touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items,
  -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a
  time, at load ~60: 74 of 92 here, 77 of 92 at 90518de26 itself. Red
  in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in
  Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case
  red here only, the case #4483 has red on main. -chip-fan and -items
  are #3072's and #4501's kind, WebKit under load.
- Broken by hand on mote, each red: instructionsView skipping the
  stopped distro's agents (TestWSLStoppedInstructions, "a stopped
  distro's Codex isn't on the Instructions page", and ...Unseen, "Pi
  switched on while stopped"); keepShape without Instructions (Codex
  not on the page); distrosNamed without Instructions.Agents ("no sync
  once the distro ran"). On Linux, client.js's asleep row back to
  pathLink with the unseen switch's guard gone: library-wsl-asleep's
  Instructions test red in both engines, 10 subtests each.
2026-10-31 17:00:13 +08:00
yetone 0d5df496aa library: a server kept direct is given to Codex as its command, so Codex starts it in the thread's folder (#4382)
cuipengcx90 on #4382 (and nifengfanpan0853 on Discord): with cocoindex set
to direct, Claude and Pi start it in their own folder, but Codex on magpie
was still given `url = "http://127.0.0.1:3425/mcp/run/cocoindex"`. magpie's
/mcp/run (#3885) starts the command from home, so cocoindex answered "Run
`ccc init` in your project root". syncMCP now leaves a direct server out of
runVia, so Codex's entry is the server's command, args and env, as it is
for every other agent, with the hub on or off. runSpecOf, which serves
/mcp/run before a sync has recorded what it gave, no longer runs a direct
server either. A shared server is still run by magpie for Codex, as before.

No `cwd` is written: Codex's codex-mcp make_rmcp_client builds its
LocalStdioServerLauncher with the session's config.cwd as fallback_cwd,
used when the entry has no cwd (openai/codex 67f0994,
stdio_server_launcher.rs launch_server). RawMcpServerConfig takes command,
args, env, env_vars and cwd for stdio.

Siblings: runVia is the only place a command server becomes a URL
(runsFor needs fmtCodex). Every other format is given the command and
starts it itself; npxDirect (node in place of npx) and side (WSL image
server) keep it a command; magpie writes no cwd for any agent. Project
MCP files never went through runVia.

Run:
- TestRunDirectServerIsCodexsCommand (new): red on the old code with the
  issue's exact entry, `url = "http://127.0.0.1:3425/mcp/run/cocoindex"`,
  when the syncMCP guard was taken out by hand; red again with only the
  runSpecOf guard taken out ("before a sync /mcp/run would start the
  direct server true"); green with both.
- mote-run: go test -tags nogui ./internal/library (ok, at the rebased
  head 1a2ce7b8e), ./internal/cli ok, ./internal/proc FAIL
  TestNoCommandBypassesProc on internal/claudetui/child_unix.go, which is
  #4491 (on main, not this change).
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build, GOOS=linux go build -tags nogui,
  GOOS=windows go build: all ok on mote.
- Real Codex: codex-cli 0.165.0 on mote, a sandbox HOME and CODEX_HOME, a
  config.toml entry shaped as magpie now writes it (command, args, env,
  no cwd) for a tiny node stdio server that logs its cwd. Run from
  ~/elsewhere with `codex exec -C <proj>`: the server logged
  cwd=<proj> K=v, the thread's folder, not Codex's own.

Not run: the full go test ./... (another session's full suite was on
mote; one per machine). No GUI change. Not tried: real cocoindex, Codex's
app-server (the desktop app) with a thread whose cwd differs from the
app-server's, and a real magpie sync writing the entry for a real wired
Codex (the unit test covers those bytes).
2026-10-31 10:14:03 +08:00
yetone b78b1de003 library: magpie-image is behind the MCP hub, saving into the calling agent's project
magpie-image was the one MCP server the hub left out, because it saves
what it makes on disk and needs to know whose project that is. The hub
now serves its tools like any other server's and tells it where the
caller works:

1. the hub answers a tools/call as SSE and asks the agent roots/list on
   that stream (3s), as Claude Code answers;
2. else Codex's _meta x-codex-turn-metadata.workspaces (git repos only);
3. else the Codex thread's cwd from its session file
   (sessions.CodexThreadCwd), only with session consent;
4. else none, and the image goes to ~/Pictures/Magpie as before.

The hub passes `magpie/roots` and `magpie/client` in the call's _meta;
imagemcp saves into the first root and names the agent on its usage
row. Its result carries `magpie/model`, which the hub's own usage row
takes, so the row says which image model drew it. A WSL agent keeps
magpie-image as its own entry (the hub can't reach a path inside the
distro). docs/subsystems/mcp-hub.md (mcp-router.md after the next commit), gateway-routing.md and
gateway-sessions.md say so.

It is rebased on #4382 (b889ffe81), which lets the user keep a server
out of the hub (Server.Hub = direct). inHub now asks both: a server
kept direct is out, and magpie-image is in unless the agent is in WSL,
so the user can keep magpie-image direct too; the editor's switch
shows for it like any server, and the hub's line counts it with the
others (mcp-hub-direct.test.cjs follows).

Run at e2583df31 (this stack on 86fef947e), on mote: gofmt -l clean;
go vet for darwin, linux (-tags nogui) and windows; go build ./...;
go test -tags nogui ./... -timeout 45m, 81 packages ok, 0 FAIL;
library, gateway, imagemcp, sessions, cli and gui again alone, ok;
site's node --test, 49 of 49. GUI on xiaomi-gpu (Windows; mote's
browsers crashed under other sessions' suites): library-*, image*,
mcp-hub-direct, i18n-keys, list-sort and plugin-tools, both engines and
every language, 1055 of 1056: i18n-keys found "{name} is given to each
agent directly" dropped from the library's strings in the rebase. Put
back in the first commit; at the pushed head i18n-keys, mcp-hub-direct
and library-mcp-hub are 48 of 48. That is the only difference from
e2583df31.
Broken by hand at e2583df31: imagemcp ignoring magpie/roots fails
TestHubCallSavesInTheCallersProject; the router asking anything but
roots/list fails TestHubAsksTheAgentItsRoots and TestHubRootsUnasked;
inHub leaving magpie-image out fails TestHubGivesMagpieImage.
Real use, sandbox HOME and gateway, at 62421e570 (before the rebase): Claude Code saved into its project
via roots/list; Codex in a git repo via its workspaces _meta; Codex
outside a repo with session consent via the thread's cwd.
At 62421e570 the whole GUI suite ran on WSL magpie-desktop at load 116 to 135 from other
runs: 504 of 15757 red in 118 files, WebKit timeouts, none in a file
this change touches; filed as #4471 with the list.

Rebased once more onto 2570efb5f, which changed library-mcp-hub,
list-sort, mcp-hub-direct and gateway-routing.md. Run at the pushed
head: go build; gateway, library, cli and imagemcp tests ok; the GUI
budget tests ok; on xiaomi-gpu i18n-keys, mcp-hub-direct,
library-mcp-hub and list-sort, 51 of 54. The three reds were WebKit
420px library-mcp-hub cases with no Connect sheet after a reload.
origin/main d77da5bff goes red the same way (de 420px, 9 of 11). In a
second run of library-mcp-hub on WebKit at this head, 11 of 11 passed.
Filed as #4483.
Not tried: Codex outside a git repo without consent (it saves to
~/Pictures/Magpie, #4435); agents on Windows and in WSL with real use.
2026-10-31 02:49:08 +08:00
yetone 2f65a33aaf library: a tools plugin is a Library server of its own, in the MCP hub (Search1API)
chenxiang0010 (Discord #general) asked for a tools plugin's tools, Search1API's
(@magpie-community/tools-search1api), to be in magpie's aggregated MCP server.
Until now plugin tools were served only at /mcp/magpie/tools, wired by hand;
the hub listed Library servers only.

Now each plugin that is on and gives tools becomes a Library server once the
plugin host has noted its tools (plugin-tools.json, new plugin.ToolsNoted):
- named by the plugin's short name (search1api, search1api-plugin beside a
  user's server of that name), `plugin` set, `local`, its URL the new
  /mcp/magpie/tools/<short> (gateway ToolsMCPOne), which serves that
  plugin's tools alone by their own names;
- added with the hub on, it is on for the agents given the hub's entry, so
  their hub lists search1api__search etc. at once; with the hub off it is on
  for none until switched on. Per agent and per tool it is switched like any
  server;
- the hub lists and runs its tools in process (gateway.PluginToolsOf,
  RunPluginToolOf, under the Plugin tools gate); with the hub off an agent is
  given the per-plugin URL at the address it reaches the gateway (through),
  with a key from another machine;
- offered once (pluginsOffered): removed by the user, it comes back only when
  the plugin is removed and added again. The plugin removed takes the server
  out; turned off it stays and lists nothing; an unreadable plugins.json
  changes nothing (plugin.ReadList). Edited in the Library's editor, which
  doesn't send `plugin`, it stays the plugin's.
Docs: docs/subsystems/plugin-tools.md, mcp-hub.md, site docs plugins (en, zh, ja).

Run (mote; full suite at this change on origin/main 024393fbb, then rebased on
acdc85ac8, whose 5 commits touch internal/plugin/page.go and a gateway test;
library, gateway and plugin focused runs again at the pushed head: ok):
- go test -tags nogui ./internal/library ./internal/gateway ./internal/plugin
  -run 'PluginTool|Hub|ToolsMCP|ServingGates|OwnMCPRejects|Tool': ok.
- TestReadOnlyKeyEveryRoute also covers the new route.
- New tests: TestPluginToolsInHub, TestPluginToolsServerComesAndGoes,
  TestPluginToolsServerThroughAnotherAddress (library), TestToolsMCPOnePlugin
  (gateway).
- go vet (darwin, GOOS=linux, GOOS=windows) on the three packages; go build: ok.
  gofmt -l: clean.
- Full suite, go test -tags nogui -count=1 -timeout 45m ./... (log kept):
  80 packages ok, internal/gateway red on TestReadOnlyKeyEveryRoute: the new
  route wasn't classified for read-only keys. Added to readOnlyRefused's
  list in the test (a read-only key is refused there, as at
  /mcp/magpie/tools); internal/gateway whole package again: ok (846s).
- Real run, sandbox HOME on mote, built binary, MAGPIE_ADDR on a free port:
  `magpie plugin add @magpie-community/tools-search1api` (latest from npm),
  `magpie serve`. library.json got the search1api server (plugin, local,
  url .../mcp/magpie/tools/search1api, pluginsOffered); the per-plugin
  endpoint listed search, news, ask, crawl, sitemap, trending, send_feedback;
  with the hub on, /mcp/magpie/hub listed search1api__search ... and
  search1api__search answered isError "Sign in with `magpie plugin login
  search1api`, configure apiKey ..." from the plugin.

Broken by hand (each red, then restored):
- hub ignoring plugin servers (backend path): TestPluginToolsInHub red
  ("claude's hub tools [fake/a fake/b fake/c]").
- adoptPlugins returning false at once: both library tests red ("no server
  for the plugin").
- through's plugin branch off: TestPluginToolsServerThroughAnotherAddress red.
- the ToolsMCPOne route removed: TestToolsMCPOnePlugin red (404).

Not tried: a signed-in Search1API account (none here), so no search went
through; a real agent (Claude Code, Codex) calling the hub; WSL/remote
agents through another address (unit test only); the GUI's Library page
showing the server (no GUI file changed, GUI suite not run).
2026-10-30 22:33:25 +08:00
yetone c1da9ccda3 library: a stopped WSL distro's agents are listed, and a tick for one is written there once it runs (cybercaius on Discord)
cybercaius: with WSL not started, the Library's MCP page didn't list the
agents in the distro at all, and nothing ticked for them could be kept.
A stopped distro's agents are no targets (#3896: opening their files
starts the distro), so they fell off the page.

While a distro runs, each agent's places and what its MCP file takes are
kept in wsl.json (keepShape, agent.WSLKeep, key library:<kind>). While it
is stopped, Read lists its agents from that (asleepView, asleep: <distro>)
with the library's ticks; one magpie never saw is listed only on rows that
name it, as unseen, its chip disabled and kept by every click (keptOf). A
tick on a stopped agent is kept in library.json (Takes accepts a known
shape, serversAgents judges it by shape.reaches); nothing is opened or run
in the distro. Woken, from KeepLinked's 30s loop, syncs once a distro the
library names goes from stopped to running (wsl.exe -l --running starts
nothing). The page greys a stopped agent's chip and says why in its
tooltip and one line per distro; the MCP hub leaves them out. The CLI says
the same on stderr (AsleepIn). en, zh, zh-TW, ja, de.

Run at this tree (20695ad8b before this message; on adc618bbf):
- mote: gofmt -l clean; go vet -tags nogui for darwin, GOOS=windows and
  GOOS=linux on internal/library, internal/agent, internal/cli; go test
  -tags nogui -timeout 45m ./internal/library ./internal/agent
  ./internal/cli: ok (internal/gui ok too at the 96a703a59 base).
- WSL magpie-desktop: library-wsl-asleep, i18n-keys, library-gone-agents,
  library-items and library-mcp-hub, Chromium and WebKit: 88/88. At the
  96a703a59 base every library-*, mcp-*, skill-* file and i18n-keys:
  1148 of 1164; the reds were library-chip-fan (WebKit),
  library-mcp-tools (chromium ja 420), library-items and
  skill-group-shared (WebKit) beside another session's full GUI suite.
  Alone, library-items and skill-group-shared pass, and chip-fan and
  mcp-tools are red the same on an origin/main 96a703a59 copy (#4120,
  commented).

Broken by hand: asleepView returning nothing made TestWSLStoppedListedAndQueued
("a stopped distro's Codex isn't listed") and TestWSLStoppedUnseen red;
Woken never syncing made TestWSLStoppedListedAndQueued red ("no sync once
the distro ran"); keptOf without unseen made library-wsl-asleep red in
all 10 Chromium cases (Pi's tick dropped by a click on Claude Code).

Rebased onto fa2332976 (gateway, provider and Codex effort commits, nothing
in internal/library, internal/agent/wsl or the Library page) before the
push: go vet of the three packages and go test -run TestWSL
./internal/library ok there; the full packages ran at adc618bbf.

Not tried: a real distro stopped and started. magpie-desktop was running
another session's full GUI suite, which stopping it would have killed, and
the other distros are other people's. The tests use FakeWSL, which counts
every wsl.exe -d command run in the stopped distro (none). Not changed:
the Instructions, Hooks and Subagents pages still leave a stopped
distro's agents out (#4182, #4237, #4238).
2026-10-29 18:34:44 +08:00
yetone da8039368f library: skills kept in ~/.agents/skills can be handed over to the library, and then turned off per agent
tnt1223 on Discord asked for the skills in ~/.agents/skills to move into
magpie's library folder and be managed there ("统一移入 magpie 的资源库文件
夹,交给 magpie 管理"), since a skill there can't be turned off for one agent
("不能决定某个 skill 是否自由开启"). Codex, Gemini CLI and the other readers
of that folder read it themselves, whatever the library ticks. Goose, Kimi
Code and Cindy use it as their own folder.

HandOverSkills (POST /api/library/skills/hand-over with names) does the
hand-over only when the user asks for it:
- A folder kept in ~/.agents/skills moves into library/skills/<name>
  (moveIn). It is renamed, or, across disks, copied. A copy has to read
  back the same (sameTree) before the original is set aside with the
  backups. On any failure the folder stays where it was and the library's
  link stays as it was.
- An entry there that only links to a folder elsewhere is removed, and
  the library links straight to that folder. The folder itself stays.
- The user's own links to the skill in agents' folders are removed too,
  since they would point at nothing. The library gives those agents its
  own link.
- Every agent here that read the skill there (readsSharedHere, plus the
  agent of each such link) is ticked. So each agent keeps the skill, now
  from the library, until the user unticks it or turns it off here.
- A skill found there that isn't in the library yet is imported first.
- A name that can't be handed over is listed in Result.Unmoved, and the
  other names are handed over all the same.
HandBackSkill moves the folder back and links the library to it again.

"Kept there" is now sharedEntry: the skill's own entry in the shared
folder, by its name, or, for a library link into it under another
folder's name, by that folder's name. Everything that read the old
by-name check follows it:
- SkillView.Always, plus the new Shared and SharedElsewhere fields;
- syncSkills' in-shared check;
- the shared folder's own target, which no longer gets a second link
  beside such an entry. TestSharedUnderAnotherName covers this, and it
  fails without the guard.

Where:
- GUI, Library > Skills: a row kept there has "Manage in magpie"
  ("交给 magpie 管理") in its source line. With more than one such row,
  the skills heading has "Manage {n} in magpie". Each asks first, in the
  page, and says:
  - where the folder goes, or that only the link goes;
  - which agents keep the skill, ticked;
  - how to put it back.
  Cancel sends nothing. The strings are in en, zh, zh-TW, ja and de.
- CLI: `magpie library skill hand-over <name…>|--all` and
  `magpie library skill hand-back <name>`.

Existing users: nothing changes until they click. A library.json gains
no new key.

Run (mote, at 58e926e5d/d4b7c0586 rebased on 3142a5559 unless said):
- gofmt -l: clean.
- go vet on darwin, GOOS=linux -tags nogui and GOOS=windows, for
  library, cli and gui. GOOS=linux and GOOS=windows builds.
- go test -tags nogui ./... -timeout 45m, at the pre-rebase base
  a14f5c9c9: 76 packages ok. The one red was internal/gui's
  TestCoreScriptBudget (1531446 > 1530861), which is red on main since
  a4e929212 (#4133). This change adds no core script.
- Windows (win-run, xiaomi-gpu): TestHandOver*, TestSharedUnderAnotherName
  and TestSharedAgentsSkills pass. TestHandOverFailureKeepsOriginal
  skips there, because a read-only folder can still be written.
- GUI: skill-handover.test.cjs in Chromium and WebKit, at 860 and 400px,
  in five languages, plus the heading's all-at-once case. It ran with the
  library skill files and i18n-keys: 84/84.
- Whole GUI suite, on the Windows box (mote was running another
  session's full suite). Nine reds, all in pages this change doesn't
  touch:
  - webkit: agents' sign-ins read, or not at all;
  - disconnect previews use the full body width (chromium and webkit,
    en and zh);
  - webkit zh: an agent's model list;
  - webkit en/ja 1100: an agent's own settings are in its opened row;
  - webkit: a token on a new custom provider with no Balance URL.
  These are NOT yet compared with main. The local disk filled up before
  the run's summary could be read.

- At the head rebased on 4d9058a98 (WSL magpie-desktop): go vet
  -tags nogui on library and cli; TestHandOver*,
  TestSharedUnderAnotherName, TestSharedAgentsSkills and
  TestLibrarySkillHandOver pass; skill-handover and i18n-keys pass 28/28.
  i18n-keys was red there first: the hand-over tooltip "Move these {n}
  out of ~/.agents/skills…" said the usage plugin's word "{n} out".
  It now reads "Move these {n} from ~/.agents/skills…".

Broken by hand:
- Without the ticking, the HandOver tests fail.
- Without syncSkills' guard, TestSharedUnderAnotherName fails ("goose
  was given it twice").
(At 400px the first layout squeezed the path to nothing. The button
now shrinks first, and the test checks the path's width. That check
wasn't run against the old CSS.)

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.
- The skills CLI's lock (npx skills update) may put the entry back.
- No hand-back button in the GUI; the sheet names the CLI command.
- Tried in a sandbox HOME only, never on a real ~/.agents.
2026-10-29 15:52:42 +08:00
yetone fe05f0a721 library: a skill can be turned off on this computer alone, and a sync neither carries that nor turns it on
hanslin1666 on Discord (#general 1565016936344191096) wanted a library
skill off on one computer only ("只在这台电脑上关掉"). The only way to do
that was to untick its agents, and the ticks are what a sync carries, so
every other computer lost it too. A sync from a computer that had it on
also gave it back here.

Skill.OffHere (library.json "offHere", omitempty) turns a skill off on
this computer. No agent here gets it, whatever Agents says. Every reader
that gives a skill to an agent now asks gives():
- syncSkills, including the shared ~/.agents/skills check;
- desktop_skills.go;
- skill_changed.go;
- skill_edits.go;
- behind;
- Targets.
Agents stays what a sync carries, and the page shows those chips faded.

Collect never carries OffHere, so turning a skill off changes no part a
sync uploads. Put keeps this computer's OffHere for a skill it puts, so
a sync from a computer that has it on (or that gives it to more agents)
leaves it off here.

Where to turn it off:
- GUI: a power button on the skill row (aria-pressed). When off, an
  "Off on this computer" tag sits on its own line under the name; it
  says why and turns the skill on when clicked.
- CLI: `magpie library skill off-here|on-here <name>`.
- TUI: the row says the skill is off.
The strings are in en, zh, zh-TW, ja and de.

Existing users: nothing changes. An older library.json has no offHere,
so every skill stays on, and a skill that was never turned off writes no
key (TestSkillOffHereOldLibraryIsOn).

Not covered:
- a project's skills;
- a library skill whose own folder is inside ~/.agents/skills, which
  agents read in place;
- a skill another computer removes (the flag goes with it).
The skill's files in the library folder still update while it is off.

Docs: docs/subsystems/library.md and sync-backup.md.

Run at the parent aeacc6358 (rebased on origin/main), on mote:
- gofmt -l: clean.
- go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go
  vet ./...; go build ./...: ok.
- go test -tags nogui -timeout 45m ./internal/library ./internal/davsync
  ./internal/cli ./internal/tui ./internal/gui ./internal/backup: all ok.
- GUI, Chromium and WebKit:
  - skill-off-here: 22/22 (en, zh, zh-TW, ja, de at 860 and 400px).
  - i18n-keys, gui-ja, gui-de, gui-zh-tw, library-items, library-mcp-hub,
    library-all and library-toggle-status: green. The first try timed out
    in browserType.launch (mote at load ~60); run again one file at a
    time, they passed.
  - library-row-remove: Chromium red in the hooks part, 2 or 3 of 11
    each run. It is red the same way on origin/main aeacc6358, 3 of 3
    runs there too (#3099); this change doesn't touch hook rows.
- Before the rebase, at e5e2aa58e plus this change: the 98 GUI files
  that reach the library page (1350 tests). 68 reds, nearly all
  browserType.launch timeouts under load; run again one file at a time,
  all passed except mobile-web's "desktop matches origin/main"
  subtests. Those need .git, which mote-run doesn't copy.

Then rebased onto ec3dad75a, which changes no library file. At this
pushed head: go build ./..., go vet of library and gui, the gui Budget
tests, and i18n-keys plus skill-off-here in both engines (26/26), all
ok.

Broken by hand (restored afterwards):
- Put dropping OffHere:
  - TestSkillOffHereStaysHere:96 failed: "a sync from a computer with it
    on gave pdf to an agent here again".
  - TestSkillOffHereThroughSync:108 failed: "a sync from A, with pdf on,
    gave it to an agent on B again".
- gives() ignoring OffHere: TestSkillOffHereStaysHere:74 failed: "off
  here, claude still has pdf".
- The GUI test fails on the old code, which has no button.

Not tried:
- no real WebDAV or GitHub backend (the sync test uses the fake S3);
- no real app run with real agents;
- no Windows or Linux test runs (only GOOS=windows and GOOS=linux vet);
- not the whole GUI suite, only the 98 files that reach the library page,
  the i18n checks and gui-ja, gui-de and gui-zh-tw.
2026-10-29 04:23:33 +08:00
yetone e0ea15b8e8 library: an MCP hub, one magpie server in place of every library server (#2679)
With Library → MCP → "MCP hub" on (off by default), each agent that takes
an MCP server over HTTP is given one entry, magpie, at
/mcp/magpie/hub/<agent>, in place of the library servers ticked for it.
magpie runs those servers itself, once for every agent: a command starts
on its first call and ends after 10 idle minutes, a URL server is reached
with its headers and MCP sign-in. Tools are <server>__<tool>; a tool off
in the library is neither listed nor run. Any other app connects at
/mcp/magpie/hub, which serves every library server. Both are guarded as
/mcp/magpie/tools is (local or a gateway key, no foreign page, 4 MiB,
the key's limit per call). An agent that reaches no server over HTTP
(Claude Desktop), has a magpie entry of its own, or sits beside a library
server called magpie keeps each server's own entry, and the page says why.
Off gives every agent its servers back and ends every process the hub
started.

GUI: a switch under the MCP list, a line of what it serves, the address,
and a Connect… sheet. The sheet lists every agent magpie detects that
takes MCP (not a fixed four), each with where it stands; one given none of
the hub's servers has a Connect that ticks it for every server it can
reach (servers/agents-all), so it gets the entry, and the sheet stays
open. Then any other app: Cursor (when it isn't a detected agent), VS
Code, Other, with the JSON and, in the app, "Add to …" through the app's
own install link built in Go (servers/hub-open; the page never sends a
link). CLI: magpie library mcp hub on|off. Design: docs/subsystems/mcp-hub.md.

With #3885 (62045475b): with the hub on, Codex is given the one magpie
URL entry, and the servers behind it never reach runVia, which takes a
command server only; with the hub off Codex gets /mcp/run/<name> as before.
Rebased onto it; the one conflict was both commits declaring base in
syncMCP.

Run:
- At 62045475b + this (the pushed tree), on mote: gofmt -l, go vet,
  GOOS=windows go vet, GOOS=linux go vet -tags nogui clean; go test
  -timeout 45m internal/library (108s), gateway (510s), cli (50s) ok.
  The GUI files and internal/gui weren't run again: 62045475b touches
  neither, and the rebase changed nothing in them.
- At ddf31ca30 + this: go test -timeout 45m for
  internal/library, gateway, cli and gui on mote; gofmt -l; go vet,
  GOOS=windows go vet, GOOS=linux go vet -tags nogui; win-run of
  library-mcp-hub and i18n-keys (both engines, en zh zh-TW ja de, 420px).
  gofmt and the three vets clean; library, gateway (554s) and cli ok;
  gui ok but TestMainWindowCorners, red the same on origin/main ddf31ca30
  on mote (#3949); GUI 26 of 26 pass.
- Earlier base (582bd8036, before TestHubConnectAnAgent and the oneport
  consts): full go test ./... on mote, every package ok but gateway's
  TestClientPathCoversHandler (fixed here: HubMCPPath, HubMCPAll and
  {agent} added to its consts; passes) and internal/gui's AppKit tests.
  Of those, TestMainWindowCorners fails the same on origin/main ddf31ca30
  on mote's macOS 27 (#3949); the other six (dock, panel, plugin page,
  right-to-left) passed rerun alone at load ~95 (#2645).
- win-run of every library-*, gui-*, i18n*, click-scroll and menu-scroll
  GUI file: 49 files, 839 tests, 839 pass.
- Real use in WSL (magpie-desktop), sandbox HOME, real echo MCP server:
  hub on, Cursor given servers → ~/.cursor/mcp.json holds only magpie at
  /mcp/magpie/hub/cursor; initialize, tools/list (echo__echo) and two
  calls ran on one server pid; a foreign Origin got 403; hub off → the
  echo process ended, tools [].

Broken by hand: Connect button removed → 6 GUI cases red; the old row
wrap rule → 6 red (icon on its own line at 420px); EveryServerAgents
call removed from TestHubConnectAnAgent → red (hub "").

Not run: the whole GUI suite (~960 files); Windows agents (VS Code, Cursor
on Windows) against a real hub; an "Add to Cursor" click in the real app
(the link is built and tested, the app's own confirm wasn't driven).
2026-10-29 03:17:58 +08:00
yetone 62045475b4 library: Codex on magpie reaches a command's MCP server through the gateway, run only while a thread uses it (#3885)
Codex starts every stdio server in its config once for each thread it
has loaded and keeps them as long as the thread: YPYT1 counted 204 node
processes, 21 GB, beside one Codex. While Codex is on magpie (Wired, not
disconnected, this machine's gateway key, not WSL) the library now gives
it a server run by a command as url = <gateway>/mcp/run/<name>, which
magpie serves over streamable HTTP and runs the command for itself
(internal/library/mcp_run.go):

- a session (Mcp-Session-Id) starts its own child only when it sends
  something past initialize, the first page of tools/prompts/resources
  lists and ping; those are answered from what the first child said for
  the same command, args and env, and a list_changed from a child drops
  that list;
- a (re)started child gets the session's own initialize replayed, so a
  server that keeps state per client still keeps it per thread;
- a child idle for 15 minutes is stopped (a later call starts it again),
  DELETE stops it, and a server changed or removed from the library has
  its children stopped at the next sync;
- server-initiated requests and notifications go to the session's newest
  open stream (GET, or a POST answered as SSE).
The gateway route lets only this machine in: no Origin, a loopback Host,
no forwarded or LAN address (TestRunMCPThisComputerOnly). A server with
an env var magpie hasn't, a remote one, and Codex off magpie, in WSL or
on another machine's key keep the command as before. agent.Rewired
re-syncs the library when Codex is connected or disconnected, so it is
handed the commands back when it leaves magpie.

Tests (internal/library/mcp_run_test.go, a fake server): starts on a
call and not on initialize/lists, idle end and DELETE, a server's own
request round-trips, list_changed, a changed/removed spec, an unknown
session, and the Codex entry in a sandbox (url when wired, the command
back when not, a keyed env var kept as a command). Each was red with its
part broken by hand: the init cache removed, the sweep off, runsFor
forced false, forget a no-op, the Origin/Host guard dropped.

Real runs:
- mote, sandbox HOME, real codex 0.162.1 + @modelcontextprotocol/
  server-memory: config.toml gets url = "http://127.0.0.1:3581/mcp/run/
  mem"; codex app-server's mcpServerStatus/list lists its 9 tools
  through the bridge.
- this Mac, sandbox HOME with only the DeepSeek provider copied, codex
  0.162.1 on deepseek/deepseek-flash: a real turn called mem
  create_entities and read_graph through the bridge and answered with
  the stored observation. Three codex exec turns at once that used no
  tool started 0 memory-server node processes (before: one each).
- Windows 11 (xiaomi-gpu), sandbox profile, codex 0.161.0: url entry
  written, app-server lists the 9 tools, 0 memory-server node.exe left
  after Codex closed.

Run at the pushed head (mote): GOOS=linux/windows/darwin go vet -tags
nogui ./internal/library/ ./internal/gateway/ ./internal/agent/: ok.
go test -count=1 -timeout 45m ./internal/library/ ./internal/gateway/
./internal/agent/ ./internal/gui/: library ok (167s), gateway ok
(596s), agent ok (279s); gui FAIL only TestMainWindowCorners/macOS_26_SDK
("a toolbar doesn't change the corners ... yet the main window's was
taken off"), #3949, red on mote's macOS 27 on main too; no gui or AppKit
file is touched here.
Windows (win-run): go test -run 'TestRun|TestFakeRunServer|TestMCPProxy'
./internal/library/ ./internal/gateway/: ok.

Not tried: the Codex desktop app (the same config.toml), a server that
asks the client for sampling or elicitation in a real agent. Codex picks
up the new entries when it restarts.

Reported-by: YPYT1
2026-10-29 03:06:48 +08:00
yetone 425a613224 library: a server run with npx -y reaches the agent as node running the package (#3885)
npx stays running as the server's parent for the server's whole life.
On Windows that is cmd.exe + npx's node + a second cmd.exe beside the
server: measured on xiaomi-gpu with @modelcontextprotocol/server-memory,
4 processes and 143 MB (cmd 8.1, npx node 76.2, cmd 8.2, server 50.8)
for one instance. Codex starts an instance a thread; #3885 had 223 node
processes under codex.exe.

A library server `npx -y <registry package> args` (no other npx flag)
is now installed with npm into ~/.config/magpie/mcp-npm/<hash> in the
background, and the next sync writes it into each agent on this machine
as `node <package bin> args`: node by name for npx by name, or the node
beside an npx given by path. Until the install is done, or when npm
fails (tried again after an hour), the agent keeps npx. An unpinned
spec is installed again after a day, as npx would fetch the newer one;
an install no library server runs any more is removed a day after its
last. The library's own entry, a server's check, Copy config… and WSL
agents keep npx. Taking a server off ends node's run of the program
(launchedBy reads the node line), as before for npx.

Run at this head (rebased on origin/main 1ff54f079; nothing it brought
touches internal/library):
- mote: go test -count=1 -timeout 45m ./internal/library ok (116s);
  GOOS=linux/windows/darwin go vet -tags nogui ./internal/library ok;
  ./internal/proc/... ./internal/testenv/... and the root package ok;
  TestNpx*/TestReadNpx under -race ok.
- xiaomi-gpu (win-run): TestNpx*/TestReadNpx ok.
- Real, on xiaomi-gpu, Node 22 + real npm registry, sandbox HOME: the
  library synced server-memory into a Codex config.toml; the install
  took 12.8s and the second sync wrote command = "node", args = [the
  install's …\server-memory\dist\index.js]. Started from that entry, the
  server answered initialize and tools/list, and its process tree was 1
  process at 56.2 MB, against 4 processes and 143 MB through npx.
- Broken by hand: without the npxDirect call in syncMCP,
  TestNpxServerRunsByNode is red ("the package was never installed").

Not tried: a real Codex or Claude Code session starting the node entry
(the entry has the same command/args shape they already start), and
macOS's process tree (npx's node and sh there too).
Not done (#3885 stays open): Codex starting the same MCP once a thread.
2026-10-29 01:30:58 +08:00
yetone c89284ae66 library: a server turned off everywhere has its running processes ended (#3885)
Turning MCP servers off in the Library rewrote the agents' configs, but
Codex, the Codex app and Claude Code read them only at start, so the
servers they had started kept running. With every server turned off, the
reporter's machine still held 17.75 GB of node processes for them.

A change, and the sync at start, now record each stdio server it took out
of an agent's config as that config had it. Once no agent's config runs
that command and those arguments (another agent's entry, or the user's own
under another name, keeps it), proc.EndTrees ends every process whose
command line runs it, with all it started: the cmd /d /s /c "npx -y x"
wrapper, the node npx-cli.js under it and the server under that. magpie
and what it runs under are never picked, and a process under one picked
goes with that one. An interpreter with nothing after it (node, npx) is
never matched. It runs after the change lets go of the Library lock and
before it returns, so magpie library mcp ends them too before it exits.

On Windows the processes come from a Toolhelp snapshot with their command
lines (no PowerShell); elsewhere from ps -o pid=,ppid=,args=.

Run at base e54a7d50b, before the rebase onto 34d38ed66:
- gofmt -l internal/: clean; go vet -tags nogui for linux, windows, darwin
  on internal/proc, internal/library, internal/cli: ok
- go test -count=1 -timeout 45m ./internal/proc ./internal/library
  ./internal/cli: ok (28s, 197s, 66s)
- the proc test binary on the Windows box: TestParseFamily, TestPicks,
  TestEndTreesEndsWhatItStarted, TestEnd*, TestList*: PASS
- broken by hand: endFamily ending the picked process alone on macOS made
  TestEndTreesEndsWhatItStarted red (its child ran 20s on); dropping the
  dropped-server record made TestDroppedServerEndedOnceNoAgentRunsIt red
- real, on the Windows box in a sandbox USERPROFILE, with Node 22.11.0
  (SHA-256 checked against nodejs.org's SHASUMS256): magpie library mcp add
  fs npx -y @modelcontextprotocol/server-filesystem <dir>
  agents=codex,claude; a stand-in agent started it as Codex does, through
  cmd with stdin held open: cmd -> node npx-cli.js -> cmd -> node
  index.js, 4 processes. Off for Codex only (Claude Code still has it): 4
  left. Off for every agent: "ended 1 process trees of fs", 0 left, the
  stand-in agent still running.

Not tried: a real Codex or Claude Code session holding the server (no
signed-in agent may be copied to the sandbox). Not done here, from the
same issue: writing the installed bin instead of npx, the opencode.json
servers stub, and an applied.json record of MCP changes.

At the rebased head (base 34d38ed66): go build ./..., GOOS=linux/windows/darwin
go vet -tags nogui ./internal/proc ./internal/library ok; TestParseFamily,
TestPicks, TestEndTrees*, TestDroppedServer*, TestLaunchedBy ok. The
rebase brought no proc or library changes.
2026-10-28 00:19:24 +08:00
yetone 769355ab93 library: an MCP server's startup timeout reaches Codex as startup_timeout_sec, a hand-written one stays (#3168, miaomiaozi)
The Library's MCP server editor has a "Startup timeout" field (seconds),
shown when an agent that reads one is installed (AgentView.Startup; Codex
only). It is written to Codex's [mcp_servers.<name>] startup_timeout_sec,
user-wide and in a project's .codex/config.toml. Empty writes nothing, so
Codex keeps its own 30s, as before. The key and its unit are from Codex's
own source: RawMcpServerConfig in codex-rs/config/src/mcp_types.rs
(cb2581dae8de) has startup_timeout_sec: Option<f64> in seconds, and the
older startup_timeout_ms, which is read only when _sec is absent.

A value the user wrote in config.toml is never written over. magpie
records the value it last wrote (Applied.Startup per agent,
Project.Startup per project file). A value in the entry that differs from
that record, one there before magpie wrote any, or any
startup_timeout_ms, is the user's (startupTheirs), and magpie leaves the
key alone. Once the user takes theirs out, magpie's goes in. The TUI's
server editor keeps the GUI-set value, as it does for OAuth.

Other agents with a startup timeout (Grok Build, Hermes, OpenCode) and a
`magpie mcp add` flag are #3536.

Run, in a sandbox HOME with pinned GOMODCACHE/GOCACHE:
- go test -tags nogui ./internal/library ./internal/tui: ok (162s, 16s).
- New tests: TestCodexStartupTimeout, TestCodexStartupTimeoutKeepsUsers,
  TestCodexProjectStartupTimeout. Broken by hand, each red:
  every existing value counted as the user's -> "startup_timeout_sec =
  120, want 45"; magpie always winning -> "= 20, want 90"; no encode (the
  old code) -> "= <nil>, want 120".
- GUI: new mcp-startup-timeout.test.cjs, Chromium and WebKit, en zh zh-TW
  ja de, 1100 and 390px: 22/22; red on the old client.js (no field).
  The 59 GUI files the change reaches (mcp-*, library-*, i18n-keys,
  gui-de/ja/zh-tw, every editServer/lib-editor file): 935 of 937 pass.
  The red, library-row-remove's hook-row trash in Chromium, fails the
  same way on origin/main 208bd5c48 run alone (2 of 2); it is #3099.
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; linux nogui, windows and darwin builds ok.
- Real Codex: config.toml written by magpie under a scratch CODEX_HOME,
  read by codex-cli 0.162.1 `codex mcp list --json`:
  "startup_timeout_sec": 2.0.

After rebasing on origin/main 208bd5c48: go vet library+tui, linux nogui
and windows builds ok; go test -tags nogui internal/library (130s), tui
ok; internal/gui red once on TestRestartHandsTheGatewayOver (#3451, a
handover EOF, untouched here), then -count=3 alone and the package again
ok; GUI mcp-startup-timeout + i18n-keys 26/26.

Not tried: a real Codex start that actually times out (codex exec needs
a signed-in account in the scratch home); the full ./... suite.
2026-10-25 09:41:32 +08:00
yetone c417b1f4e3 library: a skill removed from its source is said so, and every such skill goes in one click, asked first
スライム on Discord (#help, 10-22): taste-skills took some of its skills
out, Update all reported each of them as a failure, and the only way
out was to delete them one by one.

An update or a check that reads the source whole and finds the skill's
folder (or its SKILL.md) gone now calls it removed upstream, not a
failure. GitHub tarballs and other git repositories both work this way.
- UpdateSkill returns *GoneError.
- UpdateSkills and UpdateSomeSkills list it in Result.Gone, not
  Unupdated.
- A check gives status "gone".
- Each marks Skill.Gone. The mark is cleared when a check or an update
  finds the skill there again.
- A fetch that failed, a skill left out of a fetch as too big, and a
  folder that can't be read stay unknown, never gone (goneFrom).

Nothing is deleted by itself. RemoveGoneSkills takes the named skills
out, or every marked one when none are named, through RemoveSkills, so
the folders go to the backups. A skill found in its source again is
kept and said so.
- GUI: a "Removed upstream" tag replaces Update available and the
  update icon. Update all says gone skills apart from failures. "Clean
  up N" sits in the group heading, or in the bar when there is one
  group, and opens a sheet naming each skill. One changed here carries
  "Changed here". Strings are in en, zh, zh-TW, ja and de.
- CLI: `magpie library skill rm --gone [--yes]` asks at a terminal and
  refuses without --yes otherwise. It names the ones changed here.
  update and status print the hint.
- TUI: the row says "removed from <repo> · d takes it out".
- API: POST /api/library/skills/remove-gone {names}.
- Docs: the Skill updates row and Verification in
  docs/subsystems/library.md.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- skill-gone passes, chromium and webkit, en and zh, 860 and 400px.
- internal/library, internal/cli and internal/tui ok, the Gone tests and
  TestLibrarySkillRm among them.
- The rebase onto main met c2636b7b5's Verification line in library.md;
  both sides' tests are kept in it.
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Broken by hand, each red, then restored:
- prepare not returning GoneError
- apply not clearing Gone
- leftOutAt ignored
- every Stat error read as absent
- the git check not saying gone
- RemoveGoneSkills taking a skill that isn't marked

Not tried:
- the real taste-skills repo over the network
- the Windows box
- a skill CC Switch installed (Origin, adopt path), which still reports
  as a failure
- a GitHub check with a known commit, which keeps an existing gone
  mark but only marks gone after an update
2026-10-23 01:58:00 +08:00
yetone 9fd80b2128 library: skills install from any git repository, GitLab and a company's own among them (sunset on Discord)
ProbeSkills took only a GitHub source or a folder. It now also takes any
git repository's address: https/http on gitlab.com or a self-hosted
server (any depth of groups), a GitLab or Gitea page of a folder
(/-/tree/<ref>/<path>, /-/blob/..., /src/branch/...), ssh://,
git@host:group/repo.git, a bare host.name/group/repo, and file://.
Such a source is kind "git" (gitSource, skillgit.go).

It is fetched with 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|HEAD>, checkout FETCH_HEAD into
a magpie-skill-* folder, .git removed; the same keepProbe/maxFetch path
GitHub's tarball takes.

What the user typed is data: an address starting with - and any
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 ssh -o
BatchMode=yes unless the user set their own SSH command (GIT_SSH,
GIT_SSH_COMMAND, core.sshCommand), 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, an unknown host key, a missing branch and an unreachable host
each say so plainly (gitError).

Updates: Commit keeps the repository head the skill was fetched at. A
check runs git ls-remote; another head is fetched (once per repository
and ref) and the skill's folder hashed, so a commit elsewhere in the
repository leaves it current and moves Commit on. UpdateSkill and the
edited-skill refusal work as for GitHub; EditedError and the page's
Changed here / Update / replace question name the repository instead of
GitHub. findNew, Group again, icons and the market stay GitHub's only
(documented).

Page, TUI and docs: the add box's placeholder in en/zh/zh-TW/ja/de
(zh: owner/repo、GitHub 或 GitLab 链接、任意 git 仓库地址,或本机上的文件夹),
a git skill's source shown as a link (https) or text (SSH), its own
Update and Check for updates; the TUI's prompt; library.md's Skills and
Skill updates rows. GIT_SSH/GIT_SSH_COMMAND are listed in agentenv's
notAnAgent (TestFolderVarsAreListed).

Tests (fail on the old code: gitSource/gitPath don't exist there, and
skill-git-source.test.cjs fails on the old assets' placeholder, checked
by stashing client.js/i18n.js): TestGitSourceReads,
TestInstallFromGitRepo (a local bare repo over file://: probe, install,
check finds an update, update, a commit elsewhere stays current, an
edit here is refused naming the repo), TestGitTreeURLInstallsFolder,
TestGitMissingSaysSo, TestGitSignInRefusedSaysSo (a local httptest 401,
GIT_CONFIG_NOSYSTEM so no Keychain), TestGitRefusesOptionsAndTransports,
TestGitErrorsSaid. No test reaches the network.

Run (worktree at origin/main 224ea7d5b, machine load average ~120-145
from other sessions):
- gofmt -l: clean. go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
  clean.
- set -o pipefail; go test -timeout 45m ./...: 63 packages ok; one red,
  internal/agent TestFolderVarsAreListed (GIT_SSH vars), fixed above
  and rerun alone: ok.
- After later edits, rerun ./internal/library ./internal/cli
  ./internal/tui ok; internal/gui TestMainWindowCorners red once at
  load 144 (76.5s, AppKit window test this change doesn't touch),
  passed alone (28.6s); internal/agent timed out at 45m in that
  combined rerun at load ~140 (it ran 962s in the full run) and passed
  alone (1808s, load ~100).
- GUI: the 88 test files that load the library page, chromium and
  webkit: 1420/1420 pass; skill-git-source + skill-update-edited rerun
  after the last client.js edit: 20/20.
- Real use in a sandbox HOME (GIT_CONFIG_NOSYSTEM=1): a local bare repo
  over file:// probed, installed, checked current, a new commit found as
  update, updated to v2; ext:: and --upload-pack refused with nothing
  run; https://gitlab.com/gitlab-org/ai/skills probed (52 skills), its
  /-/tree/main/skills/glab installed and checked current; a private
  gitlab.com address said "git couldn't sign in to gitlab.com ...".
- Not tried: a real self-hosted GitLab with credentials, ssh:// against
  a real host, Windows.
2026-10-19 18:16:57 +08:00
yetone 0dbb1a8490 library: subagents are written once and given to every agent in its own format, with what each agent can't bind shown (#2283, chuanchinatest)
The Library has a Subagents tab beside Hooks. A subagent is a name, a
description, a prompt, and the library's skills and MCP servers it uses.
magpie writes it to each ticked agent's user-level folder in that agent's
format, rewrites it on every change, and takes back only files it wrote.

Where each one goes (syncSubagents, subagentSpecOf):
- Claude Code: ~/.claude/agents/<n>.md, with skills and mcpServers
- Codex: $CODEX_HOME/agents/<n>.toml (name, description, developer_instructions)
- OpenCode: ~/.config/opencode/agents/<n>.md (mode: subagent)
- Gemini CLI ~/.gemini/agents, Qwen Code ~/.qwen/agents, Grok ~/.grok/agents,
  Cursor ~/.cursor/agents, Copilot CLI ~/.copilot/agents/<n>.agent.md
- Factory Droid: ~/.factory/droids/<n>.md, with mcpServers
Skills and servers are named only where the agent's file can name them.
The page says, per agent, which of the two it won't bind, and that only
the Cursor app reads ~/.cursor/agents (cursor-agent reads a project's only).
Agents in WSL and agents with no user-level folder are greyed out.

The user's own files: every file is recorded by the hash of what magpie
wrote (Applied.Subagents). A same-name file of the user's is never written
over (the agent gets a problem). A file the user edited is theirs from then
on: it is neither rewritten nor removed. A carried library doesn't carry
subagents yet (as with hooks).

The Library's tabs now wrap onto a second line rather than scroll a narrow
window sideways (eight tabs in German at 560px). library-servers-bulk's
window goes from 1000 to 1100px tall to keep its stated premise that the
whole list fits.

Run:
- gofmt -l, and go vet -tags nogui for darwin, windows and linux: clean.
- go test of internal/library, internal/gui and the packages that import
  internal/library, at this head: green.
Full suite: SUITE_LINE
- New tests: TestSubagentsEachAgentsFile, TestSubagentsLeaveTheUsersFiles
  (covers the user editing magpie's file and then a sync), TestSubagentCheck.
- GUI: library-subagents (new) passes in Chromium and WebKit, at 1100 and
  420, in en, zh, zh-TW, ja and de. Also all library-*, gui-ja, gui-de,
  gui-zh-tw, i18n-keys, images-library-way, skill-* and mcp-* tests pass.
  Greying out the WSL agent was broken by hand, and library-subagents
  went red.
- Real binaries in a sandbox HOME against a fake upstream: each one sees
  the subagent magpie wrote.
  - Claude Code 2.1.300: it is listed in the system prompt.
  - OpenCode 2.0.25: debug agents.
  - Grok 1.0.50: grok inspect.
  - Codex 0.162.1: spawn_agent's roles, with --enable multi_agent_v2. v1
    showed no spawn_agent with a custom provider.
  - Gemini CLI 0.63.0: <subagent> in the request.
  - Qwen Code 0.21.9: its agent types.

Not tried: Factory Droid and Copilot CLI (both need a sign-in; Copilot
stops on auth before it reads agents), and the Cursor app.
2026-10-15 23:08:03 +08:00
yetone 03eb0633af library: an agent not installed is on no row but those of what it still has (@jiahao_jayden on X)
Library → Skills showed a chip for WorkBuddy on every row though it
wasn't installed ("一排有点密恐了"). WorkBuddy has no CLI and no detect
rule, so it counted as installed whenever ~/.workbuddy (or its
models.json) existed; that folder stays after the app is trashed, and
magpie itself writes models.json, mcp.json and skills/ there.

- agent: on a Mac WorkBuddy and WorkBuddy AI are detected by their apps,
  each by its own bundle id (com.tencent.workbuddy.mac,
  com.workbuddy.workbuddy-ai) in /Applications or ~/Applications
  (macBundle). Off a Mac the folder still counts, as before.
- library: an agent that isn't a target but still has skills, servers or
  hooks magpie gave it is held (Target.Gone). A sync takes edits from its
  copies and then only takes things out of it; Read lists it with
  gone: true while it has any, and not once it has none.
- GUI: a gone agent's chip is only on the rows of what it has, lit; a
  click takes it away. All, the How-per-agent sheet and the pickers leave
  it out; By agent lists it as "Not installed here" with Turn all on off.
  No layout change. New strings in zh, zh-TW, ja, de.

Run at this tree (macOS, sandbox HOME, Go caches pinned):
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean. go build, GOOS=linux go build -tags
  nogui, GOOS=windows go build: ok.
- go test -tags nogui -timeout 30m ./...: all ok (59 packages);
  internal/gui rerun after the last string rename: ok.
- GUI: the 74 test files that open the Library, chromium and webkit:
  563/563 each. library-gone-agents.test.cjs (new; 1100px and 390px, en,
  zh, zh-TW, ja, de): 11/11 in both; i18n-keys.test.cjs: 3/3.

Broken by hand, each went red, then restored and green:
- old client.js: library-gone-agents fails "a chip for an agent not
  installed on a row it has nothing on".
- workbuddyHere's Mac branch falling back to the folder:
  TestWorkBuddyOnMacIsItsApp "no app, only the folders: WorkBuddy true,
  WorkBuddy AI true".
- syncSkills' Gone guard off: TestGoneAgentListedToTakeOut "a sync gave
  the gone hermes a skill again".
- held() returning nil: "hermes, holding a skill and a server, isn't
  listed as gone".
- the gone sync steps skipped: "hermes, holding nothing, is still listed".

Not verified: the reporter's machine; WorkBuddy detection on Windows and
Linux (unchanged, still by folder); other agents detected by folder alone
(zcode, alma, grok-app, air, hanako, morph, grok) are unchanged. WorkBuddy
AI.app is installed on the owner's Mac without ~/.workbuddy-ai, so it now
shows as detected there.
2026-10-15 14:52:51 +08:00
yetone 04ff9a775c library: the sync at start lets go after each agent's part, for the page's reads and changes to go first (#1624, Hipple)
magpie writes the library into the agents again at every start
(app.go's library.Sync). That ran as change(): one hold of the library's
lock through every agent's instructions, servers, hooks and skills. Every
read of the Library page (Read, Glance, ReadInstructions) and every change
waits on the same lock, so the first one or two operations after opening
magpie waited for the whole sync, and later ones didn't: Hipple's "the
slow ones are the first one or two after opening, then under 1s" on
0.1.1223, 11 agents and 88 skills on Windows.

Sync now runs the same steps change's sync does (syncSteps, shared by
both, so the order stays one), each under the lock on a fresh load and
saved after it. A read or change that comes meanwhile waits for one
agent's part, not the rest. What a step learnt of the skills (hashes,
copies found untouched) goes on to the next only while nothing else took
the lock between; the lock counts its holders for that. A change by the
page still syncs as before, in one hold.

Measured: with the library's sync made slow (looks slowed), a Read
started during it came in with 0 of 6 agents' skills given back; on the
old Sync it came in after all 6, every time.

Run:
- TestReadDuringSyncWaitsForOnePart: -race -count=5 green; with Sync put
  back to change(nil) it fails 2 of 2 ("the read went after the whole
  sync").
- go test ./internal/library/ green; ./internal/cli/ green after
  rebasing onto 494609866 (TestAgentQwenDefault was red at the old base).
- gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Not verified: on Hipple's Windows machine, or on the Windows box with 11
agents. That the start-up sync is what the first operations wait behind
there is inferred from the lock and the report's pattern, not measured.
The sync itself is still slow on its own: with 12 agents and 4 skills it
looks at paths ~7000 times, not memoized (linkmemo is read-only), which
is the next step.
2026-10-13 14:55:46 +08:00
yetone 6d7e5b53a0 library: the Library page opens without looking at the same folders thousands of times (#1771, oxyuan)
oxyuan's profile after v0.1.1214: every page opens at once but the
Library, ~1.3s a visit on Windows, 68% of it in library.resolve and the
read 97% system calls.

Cause: resolve follows links a part at a time, and for each part it
called linkTarget (an Lstat, and a Readlink for a link) and then Lstat'd
the same part again. One read of the page resolves a few hundred paths,
most of them many times over (each agent's skills folder for each skill,
CC Switch's folder and the source for each skill, home and the shared
folder once per skill), so the same ~150 folders were looked at
~10,000 times a read. On Windows each look is a cgocall.

Fix: while a read of the page (Read, Glance) holds the library's lock,
lookPart (linkmemo.go) keeps what each entry was found to be, one Lstat
and a Readlink for a link, for the rest of that read; linkTarget and
resolve both go through it, so the second Lstat is gone too. No change
runs while the read holds mu, so nothing the read keeps can be changed
by magpie under it. Nothing is kept past the read: the next visit looks
again, so a link made or moved on disk between visits shows. A look that
failed for another reason than "not there" is unknown and isn't kept. I
looked at a cache across visits keyed on the folders' times; checking it
costs one stat per folder on the way, the same as the memo's single look,
so it would save nothing over this.

Numbers, 11 agents, 40 skills from a linked folder given to all of them,
10 MCP servers (the package's sandbox, test binary built for each):
  Windows 11 x64 box, median of 7:
    Glance  10,144 looks, 116ms -> 117 looks, 26ms
    Read    10,473 looks, 150ms ->  284 looks, 61ms
  macOS (arm64), median of 7:
    Glance  11,660 looks, 41ms -> 159 looks, 13ms
    Read    12,040 looks, 53ms -> 360 looks, 28ms
The rest of a full Read (comparing the agents' copies, found skills)
runs without the lock, as before, and isn't memoized.

Tests: TestReadLooksAtEachFolderOnce (red with the memo taken out, and
with it outliving the read), TestLinkChangedBetweenVisitsShows (red with
a memo kept across visits), TestUnreadablePartIsLookedAtAgain (red when
an unknown look is kept).

Run: go test -tags nogui ./internal/library ./internal/gui (ok);
gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui
./internal/library; node --test internal/gui/tests/library-*.test.cjs,
chromium and webkit: 450/450 on the second full run. The first full run
had library-mcp-tool-switch red in WebKit (#1609, filed) and
library-chip-fan red once in Chromium under --test-concurrency=4; it
passed 3/3 alone and in the second full run. Not tried on oxyuan's
machine or with their library.
2026-10-13 11:10:59 +08:00
yetone e3a497d7a2 library, gui: Hooks are a fifth Library category, kept once and written into each ticked agent's own hooks file (#1790, AllenReder)
What: the Library page has a Hooks tab beside Instructions, MCP, Skills
and RTK. A hook is a command, an event, an optional tool filter, a
timeout and the agents ticked for it. magpie writes it into each agent in
that agent's own file and shape:
  Claude Code  <claude dir>/settings.json   hooks.<Event>[{matcher, hooks[]}]
  Codex        <codex home>/hooks.json       same shape
  Gemini CLI   ~/.gemini/settings.json       same shape, timeout in ms
  Cursor       ~/.cursor/hooks.json          flat entries, version 1
Portable events (turn end, after a tool, before a tool, prompt sent,
session start) map to each agent's own name; "shell"/"edit" map to each
agent's own tool names. An agent's own event (codex:PermissionRequest,
cursor:afterFileEdit, ...) is offered too and given to that agent only.
Rows have agent chips (All first), Select + bar, and Remove all, like
skills and servers. An agent that can't take a hook has its chip greyed
with the reason: every agent but those four ("has no hooks magpie can
write"), an agent in WSL (not yet), and another agent for a native event.
The page also says when an agent has all hooks turned off
(disableAllHooks, hooksConfig.enabled=false, [features] hooks=false).

Why these choices (product call delegated to us): the four agents are
the ones with a documented, file-based command-hook API whose events line
up; others (OpenCode's JS plugins, dsh, ...) have no comparable file, so
they're named as unavailable rather than half-supported. Removal is
exact: Applied.Hooks records each entry as written (canonical JSON), and
only an entry still exactly as written is taken out; one the user edited
is theirs, and their own hooks beside it are never touched. A hooks file
that doesn't parse is a problem, never treated as empty or written over.
Codex keeps trust per hook in config.toml keyed by group position, so
taking a group out re-keys the user's trust for the groups after it
(codexRekey) instead of silently untrusting them. Carried bundles
(backup/WebDAV/S3) don't carry hooks in this first version.

Run:
- go test ./internal/library ./internal/gui (sandbox HOME): pass. New
  hooks_test.go: each agent's shape; the user's edited entry stays and is
  no longer recorded; an unparseable file is left alone and reported;
  Codex trust moves with its groups; native events/unavailable agents;
  hooks-off reported.
- library-hooks.test.cjs: 12/12 in chromium and webkit, at 440px, in en,
  zh, zh-TW, ja, de; against the old library.js it fails (timeouts on the
  missing tab). All 52 new strings translated in the 4 languages.
- library-loading.test.cjs expects the Hooks tab in its tab lists
  (it failed on this change before; 6/6 now).
- Every library-*/skill-* GUI test in chromium and webkit: all pass but
  WebKit timeouts in library-mcp-tool-switch/library-mcp-tools, which fail
  the same on origin/main b0a904bd9 under load (#1609, commented).
- gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean. Full go test ./... at the pre-rebase
  head c1c1a730f: 49 packages ok. After rebasing onto 86b2f4d05:
  library, gui and gateway's Anthropic/Zed tests ok.

Not tried: real Claude Code / Codex / Gemini / Cursor runs firing the
written hooks; the shapes were checked against each agent's source and
docs, not executed.
2026-10-12 22:44:28 +08:00
yetone f57dc9610b library, gui: an instruction set made, saved or removed writes only the instructions, and the page holds its buttons while it does (#1624, Hipple)
On Windows 11 the Library's Instructions tab took 30s+ to show, and each
instruction made, saved or removed took about a minute with nothing on
the page to say so; a second click made a second set or removed twice.

What an instruction change cost:
- SaveInstructions and ImportInstructions went through change(), which
  gives every agent its MCP servers and skills again too (takeEdits and
  syncSkills look through every skill folder, and the projects), and
  the API then answered with a whole library.Read, which reads every
  agent's skill folders through again (foundSkills, behind: minutes on
  a machine with many skills, #541).
- Every read of the library found the agents (Targets: every agent's
  folders, WSL too) three times: ReadInstructions, readView, and
  foundServers.

Now:
- library: changeInstructions writes only the instructions into the
  agents (with backups as before); readView finds the agents once and
  passes them to instructionsView and foundServersOf. ReadInstructions
  stays for the TUI.
- gui: an instructions/* action answers {part: "instructions",
  instructions, result, problems}; the problems the last change had with
  servers and skills stay, those with the instructions are the new
  change's.
- library.js change(): one change at a time; while one is out the
  page's (and the Library dialog's) buttons are disabled, the page is
  aria-busy, the button pressed says "Saving…" and so does the status.
  An answer with part "instructions" is merged into the page's library.

Timed on the Windows test box (sandbox profile, 1 agent, 80 skills, copy
mode): an instruction create was ~170ms + a ~460ms Read, now ~80ms + a
~70ms instructions read; Glance 350 -> 200ms, Read 480 -> 320ms. The
30s/1min the reporter sees wasn't reproduced there.

Tests (each fails on the old code):
- TestInstructionChangeWritesOnlyInstructions: a server taken out of
  codex's config by hand stays out through instruction create, switch,
  save and remove, and comes back with a server change.
- TestInstructionChangeAnswersInstructions: the instructions answer and
  the problems kept.
- library-instr-busy.test.cjs: a double click on Add sends one create,
  every page button is disabled and the pressed one says Saving… while
  the answer is held, the page keeps the rest of the library after an
  instructions-only answer; the sure Remove double-clicked sends one.
  Chromium and WebKit, en/zh/zh-TW/ja/de.

Also run: go test ./internal/library ./internal/gui ./internal/tui;
gofmt; GOOS=linux and windows go vet; every library*.test.cjs plus the
30 other GUI tests that reach the Library, Chromium and WebKit: all pass
but library-mcp-tool-switch in WebKit, which fails the same alone on
origin/main (#1609), and mobile-web's desktop-vs-main check, which needs
a git checkout the scratch copy it ran in hadn't.
2026-10-12 00:10:59 +08:00
yetone 234b2399c4 library: an MCP server an agent has of its own can be removed from it, its files backed up first (#1618, sxwedo)
A server listed under Library > MCP servers > "In your agents" could
only be brought into the library. As a found skill can (#1303), it can
now be taken out of every agent that has it, without bringing it in.

- library.RemoveFoundServer(name): every agent the server was found in
  has it deleted from its MCP settings by the same per-format code the
  library writes with (JSON/JSONC paths, Codex and Grok TOML, Goose and
  Hermes YAML, dsh profiles, the Also files and the Extra files an agent
  still reads, Pi's old mcp-adapter.json among them). The user's other
  keys, comments and servers stay.
- Every file it touches is copied to magpie's backups (res.Backup)
  before it is written; a file that doesn't hold the server isn't.
- Every file is read before any is written: one that doesn't parse stops
  the removal with nothing changed (a failed read is unknown, not
  empty). The file is read back after, and a server still there is an
  error, not "removed".
- A server the agent's app puts there itself (Own, e.g. Codex's
  node_repl) is refused: taking it out wouldn't last. The GUI doesn't
  list those, and the TUI says so.
- An agent with a different server by that name (Others) is left alone.
- GUI: a trash beside Bring in asks first, naming the agents, that each
  file goes to the backups and that the other server by that name stays;
  posts servers/remove-found. Strings in zh, zh-TW, ja, de.
- TUI: d twice on a found-mcp row, as on a found skill.

What was run:
- go test ./internal/library ./internal/tui ./internal/gui (sandbox
  HOME). New tests: TestRemoveFoundServer (Claude/Codex/OpenCode files
  with user keys, comments and other servers that must survive; Gemini
  with a different one and an unparseable Cursor file left
  byte-identical), ...Unreadable, ...Own, ...EveryAgent (claude, codex,
  gemini, opencode, mimocode, pi, goose, cursor, copilot, crush, dsh),
  TestRemoveFoundEntryEveryFormat (every format, with backups),
  TestRemoveFoundEntryPiExtra; tui's d-twice found-mcp case keeps the
  rest of .claude.json.
- Broken by hand, each went red: no backup, Extra file skipped, Extra
  unreadable read as empty (mcp.json must stay unwritten), no delete,
  Own allowed; GUI trash posting without the confirm. The main file
  unreadable read as empty stays green on purpose: nothing is written
  and the read-back still refuses.
- GUI: remove-found-server.test.cjs (new), remove-found-skill,
  i18n-keys, every library-*.test.cjs, view-no-sideways, mobile-web,
  by-agent in Chromium and WebKit. library-mcp-tool-switch fails in
  WebKit with or without this change, and also when run alone (#1609);
  it has no found servers.
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on the three
  packages.
Not tried against a real agent's live config.
2026-10-11 22:23:45 +08:00
yetone f1001ec991 library, gui: each of an MCP server's tools has a switch, and the agents that can leave one out are told to (nf1qaz2w on Discord)
nf1qaz2w asked to turn single tools of a Library MCP server on and off.
6f4fb883e listed each server's tools by name and description; each now
has a switch beside it.

What changed
- Server.DisabledTools keeps the tools turned off, by the names the
  server gives them; ServerTools (POST library/servers/tools) sets them.
  The editor's save sends none, so SaveServer keeps them.
- Each agent given the server that reads a per-tool setting is written
  it in its own form (mcp_tools_off.go, toolsOffOf), checked in source:
  - Codex: [mcp_servers.<name>] disabled_tools (codex-rs/config/src/
    mcp_types.rs, ToolFilter in codex-rs/codex-mcp/src/tools.rs;
    openai/codex cc7ba336)
  - Gemini CLI: excludeTools in the entry (docs/tools/mcp-server.md,
    mcp-client.ts; gemini-cli 9b6e0265)
  - Crush: disabled_tools in the entry (internal/config/config.go
    MCPConfig, filterTools; crush df5b024a)
  - Hermes Agent: tools.exclude in the entry, original names
    (tools/mcp_tool_registration.py, mcp-config-reference.md;
    hermes-agent c5733167)
  - Claude Code: mcp__<server>__<tool> in permissions.deny of
    settings.json (code.claude.com/docs/en/permissions; names spelt as
    Claude Code 2.1.296 normalizes them, [^a-zA-Z0-9_-] -> _)
  - OpenCode: "<server>_<tool>": false in top-level tools of
    opencode.json (docs mcp-servers "Manage"; name() in
    packages/core/src/tool/mcp.ts, migrateTools in config/normalize.ts;
    sst/opencode 0d61729b)
  Every other agent (Cursor, Copilot, Goose, Zed, Kimi, Pi, Grok, Devin,
  Antigravity, Alma, dsh, omp, ZCode, Command Code, Cline, WorkBuddy,
  CodeBuddy, Droid, Claude Desktop, MiMo Code, plugin agents) gets the
  server whole; AgentView.ToolsOff is false for it, and the open tool
  list names those agents as unable to turn off single tools.
- Applied.ToolsOff / Applied.ToolRules record only what magpie added
  (offList): a name, deny rule or tools key the user had is theirs and
  stays when the tool is turned on again; an OpenCode key the user set
  to true is never written over. A list or deny that isn't a list of
  names is a problem and the file is left as it is. The key (and an
  emptied permissions / tools) goes when magpie's were the last.
- GUI: a switch per tool, flipped at once with no repaint or scroll,
  quick clicks sent as one request; turned-off tools dimmed. zh, zh-TW,
  ja, de strings. Project files and Copy config… don't carry it
  (docs/subsystems/library.md says so).

What was run
- go test ./internal/library -run 'ToolsOff|OffList': per format the
  list is written, removed on re-enable, the user's own entries kept
  (Codex, Gemini, Crush, Hermes, Claude deny, OpenCode tools); cursor
  untouched; SaveServer keeps the list. Broken by hand (no off.apply,
  no syncToolRules): TestToolsOffInTheEntry, TestToolsOffClaudeDeny,
  TestToolsOffOpenCode go red.
- go test -tags nogui ./internal/library ./internal/gui: ok.
- library-mcp-tool-switch.test.cjs: chromium and webkit, en/zh/zh-TW/
  ja/de, 980 and 420 wide: pass; 10/10 red against the old library.js,
  library.css and i18n.js. library-mcp-tools.test.cjs' fixture gives
  Claude Code toolsOff (as the real view does).
- library-*.test.cjs, click-scroll, i18n-keys: chromium and webkit.
- gofmt -l; go vet, GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/library ./internal/gui.
- go test -tags nogui ./... (full suite, under the queue lock).
All in sandbox HOMEs; no live agent config was touched.
2026-10-11 13:44:02 +08:00
yetone 69c47c9e57 library, gui: the Library page is drawn at once from a glance, and the agents' own skills and out-of-date copies come in after it (#541)
Even with the memo, the first read after skills change still reads
them through, and before this the page showed only its outline until
the whole read was done (0day404, #541: minutes on Windows).

library.Glance (GET /api/library?glance=1) is the view without
FoundSkills and the skills' Behind, marked partial. The page asks for it
first, draws it, then asks for the whole read. The Skills tab shows "In
your agents · Looking through the agents' skill folders…" (aria-busy)
until the whole read comes. The other tabs aren't drawn again for it. A
whole read that a change answered first is dropped (take() counts the
answers), so it never draws an older library over a newer one.

Read now runs behind and foundSkills after letting go of the library
lock, so a change doesn't wait on them either.

New strings in zh, zh-TW, ja and de. docs/subsystems/library.md
describes the memo and the glance.

Tests:
- TestGlanceLeavesOutTheAgentsSkills (Go).
- library-loading.test.cjs: drawn from the glance, the wait row, then
  the found skill, with reads glance then read. Chromium and WebKit, 980
  and 420px. Red on the old library.js.

Run: go test -tags nogui ./internal/library ./internal/gui; node --test
for library-*.test.cjs, skill*.test.cjs, gui-ja, gui-de and i18n-keys in
both engines; gofmt; vet on darwin, linux and windows.
2026-10-10 19:53:02 +08:00
yetone c4476d5658 library: skills from GitHub are checked as the skills page opens, and one changed here is marked and asked about before an update replaces it (#1449)
YangZhiqiang98 asked (#1449) that the Library find which skills have
updates and update them. magpie already checked skills from GitHub (a
market install among them) by hand and could update them, but an update
deleted the library's folder, so a skill the user had changed (by hand,
through an agent's link, or in an agent's copy not yet taken in) was lost
without a word, and nothing checked unless the user pressed Check.

- A skill is "changed here" when its library folder no longer hashes to
  what was fetched (Finder's .DS_Store aside), or an agent's copy was
  edited since its mark and not yet taken in (editState, skill_changed.go).
  The view says so (SkillView.edited) and the row shows "Changed here".
- UpdateSkill refuses such a skill with *EditedError unless told to
  replace it. The row's Update asks in the page first (Keep mine / Update;
  Update sends replace). Update N, the group's Update N and the CLI's
  update-all leave it as it is and say so. The CLI takes
  `magpie library skill update <name> --replace-edits`.
- The version an update replaces is moved to the backups when it was
  changed, or when it can't be told (a skill with no hash from before).
- View.checkDue: no check since magpie started, or none for 12 hours. The
  page then runs the check once by itself as the skills open, and says
  only what there is to update or add.

Not checked, by design: skills the skills CLI manages (`npx skills
update` updates them; magpie only groups them), linked local folders,
skills imported from an agent with no source, and From-only skills have
no remote; CC Switch-installed skills can still be updated by hand.

Verified:
- go test -tags nogui ./... (sandbox HOME); new TestUpdateKeepsASkillChangedHere,
  TestUpdateKeepsACopyEditedInAnAgent, TestUpdateKeepsWhatItCantTell,
  TestCheckDue, TestCheckSkillsMarksItDone, all from httptest. With
  editState forced to "not changed" the first three fail.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui on
  ./internal/library ./internal/gui ./internal/tui .
- GUI: new skill-update-edited.test.cjs (Chromium and WebKit, 860 and
  400px, en and zh; no scroll on click; fails with the row's ask removed),
  plus the 22 other library skill tests, gui-ja, gui-de, gui-zh-tw,
  i18n-keys and click-scroll: 262 pass.
- Real use in a sandbox HOME with github.com/anthropics/skills: installed
  pdf and docx, the real check said both current; an edit through Claude
  Code's link was refused by `skill update pdf`, skipped by `skill update`
  (docx updated), replaced by `--replace-edits` with the edit in
  backups/<time>/library/skills/pdf; docx edited later shows edited, a
  .DS_Store doesn't.
2026-10-10 09:14:35 +08:00
yetone 2c1b593675 library: Zed takes MCP servers, in its settings.json context_servers (lc on Discord)
lc on Discord ("agent未识别到zed"): the MCP server editor's agent chips
had no Zed. magpie already edits Zed's settings.json for its model, and
Zed reads its MCP servers from context_servers in that same file, so Zed
is now an MCP target like the other agents.

What Zed takes, from its own source (zed-industries/zed 2c99f547):
- crates/settings_content/src/project.rs ContextServerSettingsContent is
  untagged: a command as command/args/env (enabled, remote, timeout
  beside it), a url as url/headers (enabled, timeout, oauth), or an
  extension's entry as settings. docs/src/ai/mcp.md writes the same.
- crates/context_server/src/transport/http.rs only POSTs (and DELETEs):
  streamable HTTP, no SSE. So an SSE server is refused for Zed and its
  chip is greyed with the existing reason (AgentView.NoSSE).
- stdio_transport.rs hands command.envs over as written and http.rs sends
  headers as written: no ${NAME}. Zed is refNone, so a server naming a
  variable is refused and its chip greyed (AgentView.NoEnvRefs).

Changes:
- targets.go: "zed" gets mcpFile{agent.zed's settings.json, fmtZed}; the
  path is agent.zed's for every OS (~/.config/zed, $XDG_CONFIG_HOME/zed,
  %APPDATA%\Zed, $MAGPIE_ZED_CONFIG_DIR).
- mcp.go: fmtZed under "context_servers", encoded as Cursor/Desktop are;
  magpie owns url/headers/command/args/env only, so enabled, remote,
  timeout and oauth the user sets on magpie's entry stay. The file is
  JSONC and edited in place (edit.SetJSON/DelJSON), so comments, other
  settings and the user's own servers are kept.
- mcp.go, sync.go: an entry Zed's extensions configure (settings, no
  command or url) is never written over: a library server by that name
  is a Problem for Zed (errZedExtension), asking for another name.
- envref.go: a comment citing why Zed has no syntax.
- docs/subsystems/library.md: Zed's file, format, no SSE, no ${NAME},
  the extension guard, and the new tests.

Tests:
- internal/library/zed_mcp_test.go TestZedMCP, on a Zed-style JSONC
  settings.json with comments, trailing commas, a user stdio server
  (enabled:false, timeout), a user remote server and an extension's
  entry, at the default path and under MAGPIE_ZED_CONFIG_DIR: found
  servers, the page's chips, written entries, SSE/${NAME}/extension
  refusals, user keys kept through an edit, uncheck and remove leaving
  only the user's, comments kept, a Sync rewriting nothing.
- internal/gui/tests/library-zed-mcp.test.cjs: Zed's chip on every row
  and in the editor, a click gives it the server, greyed with the reason
  for SSE and ${NAME}; Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and
  560px, no sideways scroll. No new strings.

Broken by hand, each went red and was restored: no zed target, no
extension guard, SSE allowed, enabled owned by magpie, wrong key (Go);
Zed without noSSE (GUI).

Run (temp HOME, Go caches pinned): gofmt -l internal/ (clean); go vet
-tags nogui ./... on darwin, GOOS=linux and GOOS=windows; go vet
./internal/library ./internal/agent; go build ./..., GOOS=linux go build
-tags nogui ./..., GOOS=windows go build ./...; go test -tags nogui ./...
(all ok); node --test library-zed-mcp.test.cjs (22/22, both engines).

Not verified: a real Zed reading the written file (the live
~/.config/zed was never touched); Linux and Windows beyond vet/build;
Zed found in WSL (not in ownFolder, so no MCP target there); a
project's .zed/settings.json (not added).
2026-10-10 00:37:32 +08:00
yetone db0feb3615 library, gui: a remote MCP server's headers and a command's env can name ${NAME}: the library keeps the placeholder and each agent gets its own syntax, so the token is never written into an agent's settings (#1250)
The library keeps `${NAME}` as typed. refsOf (internal/library/envref.go)
gives each MCP format the agent's own syntax, with the source beside each:
${NAME} for Claude Code, Droid, Grok, Gemini, Crush, Copilot, Pi, OmO, omp,
Qoder, AtomCode, Hermes and Command Code; {env:NAME} for OpenCode and MiMo;
${env:NAME} for Cursor; Codex's bearer_token_env_var, env_http_headers and
env_vars; Goose's ${NAME} plus env_keys. An agent with no syntax (Claude
Desktop, Antigravity, Kimi, Cline, ZCode, dsh, Devin, Pi with
pi-mcp-extension) is never given such a server: supports() refuses it with
the reason, an entry magpie wrote before is taken out, and its chip is
greyed with the reason on the row and in the editor. Codex's and Goose's
extra keys are magpie's only while the server names a variable, so the
user's own env_vars / env_keys stay. The editor says how to write one under
Headers and Environment; a check whose variable isn't set where magpie runs
says which one ("GH_TOKEN not set").

Verified:
- go test -tags nogui ./... (sandbox HOME): all ok.
- New TestEnvRefs* (per-agent encode/read-back, left-out agents, library
  keeps the placeholder, user values kept, health check novar) fail with
  the behaviour turned off (refsOf -> ${NAME} for all, no refsProblem /
  refKeys, no expansion).
- library-env-refs.test.cjs (Chromium + WebKit, en/zh/ja/de at 440px)
  fails on the old library.js (4/4 subtests); gui-ja, gui-de, i18n-keys,
  library-servers-bulk, library-all, by-agent, project-servers,
  library-mcp-health, library-null-agents, library-items: 109/109 pass.
- Real: magpie built from this tree synced a library server with
  Authorization: Bearer ${FAKE_MCP_TOKEN} and X-Api-Key: ${FAKE_KEY} into a
  sandbox HOME, then against a fake MCP on 127.0.0.1:3561 that answers only
  the right bearer: Claude Code 2.1.293 `mcp list` Connected, Gemini CLI
  0.62.0 Connected, Codex 0.160.1 app-server listed the tool (authStatus
  bearerToken), cursor-agent sent both headers expanded; no agent file held
  the token. Antigravity got the Problem and no entry. Not run for real:
  OpenCode (its mcp list goes through the user's background service),
  Goose, Crush, Copilot and the rest; their syntax is from their source.
- go vet (darwin, GOOS=linux, GOOS=windows) for internal/library and
  internal/gui.
2026-10-08 14:04:21 +08:00
yetone 9dc0121f90 library: installing a set of skills skips the ones in the way and installs the rest; the toast names the ones already in the library and the ones skipped (lc on Discord: 安装skills的时候,没有跳过已经安装的)
installFrom stopped the whole set at the first skill whose name was taken,
and returned before change saved library.json. The folders it had already
copied for the skills before that one stayed in the library's folder,
unlisted. Every later try then failed on the first of them with "the
library's folder already has a caveman-commit in it".

Now each skill is installed on its own (InstallSkills, InstallMarketSkill
and AddNewSkills, through installChange):
- the library lists it from the same source: had already (Result.Had),
  nothing written, so the user's edits stay;
- a folder in the library's folder holding exactly its files (not a link,
  sameTree, which counts a failed read as different): listed where it is,
  as had;
- another skill by that name, listed or only a folder, or a folder that
  can't be read: left as it is, in Result.Skipped with why;
- the rest are installed (Result.Installed). Only when nothing was
  installed or had does the change fail, with the first reason.
The GUI's toast and the TUI's line say how many were installed, the ones
already in the library and each one skipped with why.

Verified (temp HOME, pinned caches):
- go vet -tags nogui ./internal/library ./internal/tui ./internal/gui .;
  GOOS=windows go build and GOOS=linux go build -tags nogui of
  internal/library and internal/tui: clean
- go test -tags nogui ./internal/library ./internal/tui ./internal/gui: ok
- with the old skills.go, market.go and skillnew.go, TestInstallSetSkipsOneInTheWay,
  TestInstallListsItsOwnLeftoverFolder (fails with lc's exact "the library's
  folder already has a caveman-commit in it") and
  TestInstallSetSkipsAnotherByTheSameName FAIL; TestSkillsFromGitHub's
  reinstall now asserts Had
- skill-install-skip.test.cjs (Chromium + WebKit, en and zh at 440px) fails
  on the old library.js ("status ok", no names) and passes now; with
  gui-ja, gui-de and 11 library GUI files, 99/100 passed, and the one that
  failed (by-agent, Chromium, at load average ~150) passes 3 times in a row
  in both engines when run alone
- not tried in the real app, or with lc's library
2026-10-08 04:57:40 +08:00
yetone 92469ee9f9 library, gui: a check for updates lists the skills a repository added beside the library's skills from it, to Add or Ignore (Raven on Discord)
Raven: "check for updates" only updated skills already in the library; when
dontbesilent2025/dbskill or mattpocock/skills adds a skill, magpie never said.
CheckSkills now asks GitHub's git trees API once per repo@ref (ETag-cached, a
304 is free) and only when a skill folder under the installed skills' common
folder (newBase) is neither in the library nor already offered does findNew
fetch the tarball for names and descriptions. library.json's seenSkills keeps,
per repo@ref, the paths the install picker showed and the ones set aside, so
an offered skill is offered once. The Skills page shows them under "Also in
their repositories" with Add (to the agents that have the repo's other skills)
and Ignore, plus Add all / Ignore all (/api/library/skills/{add-new,ignore-new}).

Verified: TestCheckSkillsFindsNewOnes (fake repo: nothing offered after
install, no tarball on a second check; two added skills offered, a nested one
and a .wip one not; Add installs with the repo's agents; Ignore keeps it out
on the next check via 304; remove clears) fails without the change (no
NewSkills / findNew) and passes -race -count=10; TestNewBase. A real run in a
sandbox HOME against GitHub: tdd from mattpocock/skills/skills/engineering
offered its 19 siblings; dbs from dbskill offered nothing (the picker showed
all), 33 with seenSkills wiped, and Add installed dbs-action. GUI:
skill-new-in-repo.test.cjs (Chromium+WebKit, 860/440px, en+zh) fails on
main's library.js and passes; gui-ja, gui-de, click-scroll, library-items,
every-skill, pick-skills, import/remove-all-skills, skill-groups,
skill-repo-groups, github-token, library-all pass. -race on library, gui,
tui; gofmt, vet, darwin/linux/windows builds.
2026-10-07 00:26:54 +08:00
yetone dcbae2ef98 library, gui: the MCP servers page has the skills page's Select, Turn all on, Turn all off and Remove all, under one "In the library" heading (#1027, emo172)
The servers page had only By agent and the order, each with its own "In the library" heading, so with both the heading showed twice. Turning every server on or off, or removing them all, took one chip or one row at a time. The page now has one heading (lib-serverhead, which wraps when narrow) holding the order, Select, Turn all on, Turn all off, By agent and Remove all, as the skills page does. The skills page's helpers now serve both pages rather than being copied. picking names the page ("skills" or "servers"). pickingFor, pickRow, pickBar and groupChips(kind) are shared, and so are everyButtons, confirmEveryOff and everyOf, which replace everySkillButtons and everySkill. removeEveryButton, confirmRemoveEvery and removeEvery replace removeEverySkillButton. The skills page says and does what it did before.

- Turn all on and Turn all off post every agent shown to servers/agents-all (EveryServerAgents, now serversAgents(nil, …)). A hidden agent is left alone. Turn all on is greyed once every server is on for every agent that can reach it. Turn all off asks first, in the page.
- Select puts a box on each row. A row's click ticks it rather than opening the server. The bar's chips post the servers picked to the new servers/agents-some (SomeServersAgents), which gives an agent only the ones it can reach (mcpFile.supports) and leaves unnamed servers and agents as they are. An agent that can reach none of the picks has its chip greyed, with the reason.
- Remove all asks first. It says which agents lose the servers, the projects they are taken from, the sign-ins forgotten, and that the agents' own servers stay. It then posts every name to the new servers/remove-all (RemoveServers). This is one change that takes each server out as RemoveServer does: out of the library, its projects and its icon (removeServer, now shared by both), then out of every agent through syncMCP, which takes only what Applied says magpie wrote, and then forgets its sign-in. A name the library hasn't is listed in Unremoved, and the rest go all the same.
- The pick bar wraps, so its chips and Done fit at 440px in ja and de.

TestRemoveServers checks a server the user put in Claude Code's file and Codex's own "docs" of a library server's name: both stay, while fs, docs and neon leave the library, both agents and the project's .mcp.json, and the project's own "team" stays. neon's sign-in is gone, "nope" is reported, and an empty list or one with only "nope" errors. TestSomeServersAgents checks that Codex gets fs but not the SSE web, that git stays untouched, that a call naming no servers or no agents errors, and that a call naming an unknown server writes nothing. Both pass with -race -count=10, alongside TestEveryServerAgents and TestRemoveServer*.

library-servers-bulk.test.cjs passes on Chromium and WebKit in en, zh, ja and de at 440px. It checks one heading with every button, Turn all on's post without the hidden Copilot CLI, Turn all off's Cancel posting nothing and Confirm keeping Copilot CLI's, the pick bar's codex chip posting agents-some for the two picked and its greyed state for web alone, the All box, Done, and Remove all's lines, Cancel and post. It also checks for no sideways scroll and that each control clicked stays where it was on the screen. The fake check answers every server, since an unchecked one is checked again at each drawing. It fails without the change and passes 6 runs beside pick-skills, every-skill and gui-ja at --test-concurrency=4. by-agent, pick-skills, every-skill, remove-all-skills, group-*, library-*, mcp-signin, project-servers, skill-*, i18n-keys, gui-ja and gui-de pass. skill-how's WebKit case and click-scroll's "Live and a day" fail the same on the unchanged origin/main when run beside each other, and pass alone. go test -tags nogui ./internal/..., go vet, gofmt -l, and the linux (nogui) and windows builds pass. Not tried in the real app. docs/subsystems/library.md says it.
2026-10-06 22:24:04 +08:00