Commit Graph
308 Commits
Author SHA1 Message Date
yetone 88b541a25c images: every pointer names Settings › Models › Images, where the page is
The image models moved under Settings › Models, but the Library's Magpie
Image sheet, the MCP server's instructions to agents, the gateway's
"no image model" errors, the video tool's text and the docs still sent
users to "Settings › Images", a tab that no longer exists (the scattered
settings audit after netube99 on X). Every user-facing string now names
Settings › Models › Images in en, zh, zh-TW, ja and de, as do the site's
Qwen docs (en, zh, ja), llms-full.txt, the subsystem pages and comments.

Run in the tree with this change and the rest of the audit's fixes
(mote, base cd0ba05c2):
- go vet ./internal/gui ./internal/gateway ./internal/agent
  ./internal/provider ./internal/settingsapi: ok
- go test -run 'Image|Draw|Video|Hidden|Group|Settings' ./internal/gui
  ./internal/gateway ./internal/settingsapi: ok; ./internal/imagemcp,
  ./internal/library, ./internal/catalog: ok
- GUI: i18n-keys, i18n-en-no-cjk, image-models-hide,
  library-browser-setup: pass in Chromium and WebKit
- gofmt -l: nothing
Not tried: a real agent reading the new MCP instructions (text only).
2026-11-09 21:51:53 +08:00
yetone dae104bfac capre: a length check, not an unrolled repeat, holds nine patterns
Go's regexp unrolls a bounded repeat into that many copies of its
class: [A-Za-z0-9.-]{0,254} (the session terminal's bundle id) was
89kB of program, kept from start to exit, and Codex's item-id refusal
`.{0,1000}?` 88kB. Measured one by one over magpie's 540 package-level
patterns (1.5MB in all), the nine largest bounded ones were ~440kB.

capre.MustCompile(expr, max) is the pattern with * or +, matching only
a string of max characters at most (rune count, so the (?i) Kelvin
sign and invalid bytes count as the regexp counted them). The nine:
settings' bundle id, library's name and agent id (now name@wsl:distro
cut in two), Anthropic tool names, the trace page's name and find,
access's MCP server, OpenClaw's profile and Codex's provider id. The
item-id refusal is a function: the tail within 1000 characters of a
head.

Run on mote (go1.26.8):
- go test ./internal/capre ./internal/access ./internal/settings
  ./internal/library ./internal/sessions ./internal/agent ./internal/gui
  . : ok; ./internal/gateway -run 'ItemID|Undeclared|ToolName|Refus': ok
- TestCappedMatchesBounded holds each old pattern against its new one
  over 14 units x 19 lengths (0..300, at each bound +-1); with the
  length check taken out it is red (1586 mismatches).
  TestItemIDRefusalAsTheRegexp holds the function against the old
  regexp at 998..1002 characters of x, é, 日, \xff, \n; with 1001 it is
  red. TestCappedIsSmall: 1304 bytes held, 49680 bounded.
- go vet native, GOOS=linux and GOOS=windows over the touched packages
  (gui natively: its Linux build needs cgo); gofmt -l clean.
- Real build, GODEBUG=inittrace=1: magpie's own inits allocate
  11.93MB -> 10.61MB.
- Idle on the real-account copy, 180s heap: regexp programs (sampled)
  4.54MB -> 3.01MB.

Not tried: the full ./... suite; the gateway package beyond the run
above.
2026-11-09 21:47:24 +08:00
yetone fc8e98ba47 edit: Codex's thousands of [projects] tables are left out of the reads that don't want them (#2278)
Codex writes a [projects."…"] table for every project it is trusted in;
the owner's config.toml has 10,933 of them in 1.5 MB. go-toml's decoder
checks each table against its siblings one at a time, so every decode
of the file cost ~0.3s of CPU, and six readers decoded it again each
time Codex wrote it, plus a whole-file check before each write magpie
made to it.

- edit.TOMLWithout drops [projects…] tables in a single unstable.Parser
  pass. The agent's codexTopOf, sessions' readCodexConfig, provider's
  readCodexStoreSetting, library's rtk sandbox, hooks rekey and MCP
  entries read through it. None of them reads projects. A file that
  doesn't parse is passed through unchanged, so it still fails.
- validateTOML checks definitions with the rest of the file and the
  projects decoded apart, 128 projects to a decode. A bare [projects]
  table, a dotted projects.… key outside the tables, or any error
  decodes the whole file, so the error is the one it gives.

Run on mote (M5 Pro):
- BenchmarkCodexConfigDecode (10,933 projects): 283ms -> 7.6ms a decode.
- BenchmarkValidateCodexConfig: 52ms (the whole decode was 283ms).
- Startup CPU profile, first 70s, the real-account copy (the real
  1,524,099-byte config.toml): 2.76s -> 2.26s of samples; go-toml
  0.32s -> none sampled.
- go test ./internal/edit ./internal/sessions ./internal/provider
  ./internal/library ./internal/agent: all ok.
- go vet of the same five on darwin, GOOS=linux and GOOS=windows; gofmt -l clean.

Broken by hand:
- Decoding the batches into struct{} instead of a map:
  TestValidateTOMLDefinitionsInGroups went red ("a key twice", "a
  subtable then its key"), so the check keeps maps.

Not tried:
- the whole suite. Only the five packages that read the file were run.
- Now that projects is left out, a project table defined twice no longer
  fails these readers' decode. Codex itself refuses such a file.
2026-11-09 19:07:06 +08:00
yetone b475004d52 library: Pi's extensions and packages, switched and copied between Pis
leokon3 runs Pi on Windows and in WSL and asked for magpie's Library to
manage Pi's extensions and packages. A new "Pi packages" tab in the
Library lists each Pi here (this computer's and each WSL distro's), with
the extensions and packages it loads, read by Pi's own rules
(@earendil-works/pi-coding-agent 1.4.0). Each has a switch, written as
`pi config` writes it, and a "Copy to…" menu for the other running Pis.

- A package is copied as its settings.json entry; Pi installs it itself
  when it next starts. node_modules is never copied. A local package, and
  one the other Pi already has by Pi's identity (npm name, git host/path),
  is refused.
- An extension file or folder is copied as files, without node_modules,
  .git or symlinks, never over one of the same name. The page says to run
  npm install there when it has dependencies.
- A package that already picks some parts (filtered in `pi config`) shows
  its switch disabled. A settings.json that can't be parsed lists nothing
  and is never written; a stopped distro is never started; every write is
  backed up first.
- GET/POST /api/library/pi, POST /api/library/pi/copy (notYet in the CLI
  parity list, stage 3: the library).

Run at 29d63e2dd (this tree on origin/main c7ebb6f8d; rebased after onto
608c1543e, which changes only internal/gateway), on mote:
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows on
  internal/library and internal/gui: ok.
- go test -tags nogui ./internal/library ./internal/gui ./internal/cli:
  ok, ok, ok.
- A real pi 1.4.0 (npm) in a sandbox HOME and PI_CODING_AGENT_DIR, through
  an uncommitted pireal test: pi -p loads hello.ts (a marker file), the
  switch turns it off (no marker) and on again; a todo folder copied from
  a second Pi's dir is loaded by the real pi; npm:pi-web-access@0.47.0
  copied as a settings entry was installed by pi itself into
  <agentDir>/npm/node_modules and read back as installed v0.47.0; switched
  off, `pi list` still lists it and magpie reads it off.
- GUI, 70 files (library-*, i18n-*, gui-* and the Library's neighbours),
  both engines: 1503 of 1515 pass. The 12 reds are the same on origin/main
  c7ebb6f8d: page-width-steady's 11 (run there alone, 11 of 20 red; #5013)
  and i18n-keys "a plugin's words are its own" for "Use the library's",
  "No session ID" and "View routing" (#5482, #5426, #5332).
  library-pi-extensions runs en, zh, zh-TW, ja and de at 980 and 380px.
On Windows (win-run): go vet with and without the pireal tag ok; go test
-run TestPi ./internal/library ok.

Broken by hand: the first run named the tab "Pi extensions", which a
comment in internal/provider/discovery.go says too, and i18n-keys went
red for it; library-loading went red for the new tab next to RTK while a
Pi is here; and TestEveryRouteHasACommandOrIsNamed went red for the three
routes. All three were fixed and pass in the run above.

Not tried: a real copy between a WSL Pi and the Windows Pi (the WSL side
is covered by the unit tests' fake distro only), the full go test ./...,
and the whole GUI suite.

Reported-by: leokon3 (Discord)
2026-11-09 16:33:28 +08:00
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 56f0956044 codex: switching Codex off gives a relay's table its own base_url back
Switching Codex off on the Agents page left a provider table of the
user's own (a relay, not CC Switch's) pointed at magpie's gateway, and
forgot the relay's URL for good. takeTables points such a table at
magpie while a Codex thread names it, and keeps its base_url in the
stash (codex.tables). bringOver then moves that thread onto magpie, so
by the Disconnect no thread names the table any more: giveTables asked
ccSwitchTables for the tables on magpie, which skips a table no thread
names, put nothing back, and dropped the stash. Codex was left on the
user's provider again, with that provider sending to 127.0.0.1:3425.
giveTables now reads each stashed table as it is and puts the URL back
where it still says magpie's; one the user changed since stays.

The report ("all of Codex's configuration was reset to defaults" after
the switch and a Codex restart) is not reproduced as such: every other
line of a full config.toml survives the Disconnect, an edit made while
connected too, in each auth and provider case. The new test is the
guard for all of it. TestCodexOffKeepsAppsOwnConfig guards the other
writer the switch sets off (agent.Rewired starts the library's Sync,
which gives Codex its MCP servers one way on magpie and another off it):
what the Codex app writes for its browser, Chrome and computer use
(plugins, marketplaces, node_repl with its env table and env_vars, a
server kept off, shell_environment_policy.set, [desktop]) stays through
on and off, node_repl imported into the library or not. It passed on the
old code too.

Run (mote, then the Linux box once mote's disk filled up): go test -run TestCodexOffKeepsUsersConfig ./internal/agent
(10 subtests: ChatGPT, API key, no auth, relay, relay + ChatGPT, each
with and without an edit while connected), go test -run Codex
./internal/agent ok 37s, go vet for darwin, linux and windows; on Linux (wsl-run) go test -run
'TestCodexOffKeepsAppsOwnConfig|TestRunCodexEntry|TestRunDirectServerIsCodexsCommand'
./internal/library and TestCodexOffKeepsUsersConfig ok, go vet for all
three systems of internal/agent and internal/library. The
config.toml each subtest leaves was loaded by the real Codex CLI
0.164.0-alpha.11.1 (codex mcp list, sandbox CODEX_HOME): all ten load
and list the user's MCP servers.
Broken by hand: the old giveTables back, the four relay subtests go red
with "lost base_url = https://relay.example.com/v1".
Not tried: the Codex app (ChatGPT.app) itself switched off and
restarted; the reporter's own config, version and OS (not known).

Reported-by: darwish4021 (Discord)
2026-11-07 20:57:30 +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 a2b552a34b library: a session-start hook can be narrowed to some starts (#5604)
A Library hook on "When a session starts" can now carry a matcher of
starts: one or more of startup, resume, clear, compact and fork (Claude
Code's words, library.HookStarts), joined by "|". NEKO-CwC's case is a
hook that re-injects a file after compaction alone; written whole, it
also ran at startup and once for every subagent fork.

Each agent's format was read from its own source:
- Claude Code 2.1.316 tests the matcher against source, which has all
  five starts. Its entry is written as given.
- Codex (codex-rs/hooks, rust-v0.165.0): SessionStartSource has the
  same five, and a "|" list is read as exact names. Written as given.
- Gemini CLI 0.63.0 has startup, resume and clear only, and its
  matchesTrigger compares the matcher whole. It takes one of those.
- Grok 1.0.67 tells only "new" (fresh, /new, /clear) from "load"
  (resumed). It takes a set that is exactly one of those groups.
- Cursor (cursor-agent 2026.10.01) takes no matcher: its Claude-hooks
  importer warns that a SessionStart trigger matcher "is not supported
  in Cursor, hooks will fire for all triggers".

startMatcher keeps the chosen starts that the agent has. With none
left, the agent is refused; with every one it has, it gets the hook
whole. An agent that can't run the hook at exactly the starts picked is
refused with why, and its chip is greyed, as for any other per-agent
limit. This is the least surprising choice. Widening the hook to every
start would run it at the very starts the user excluded (the fork runs
the issue is about), and a matcher the agent never matches would do
nothing without saying so. SomeHooksAgents (Select) gives a narrowed
hook only to the agents that can run it.

Tool-event validation is unchanged: only tool events take shell or
edit, and only session-start takes starts. check() refuses an unknown
start, a start named twice, an empty part and a wrong case. The matcher
as written is recorded in Applied.Hooks, so an agent's own edit of the
entry is still theirs, and is kept when the hook changes or is removed.

GUI: the editor shows an "At which starts" app menu for session-start
(openProtoMenu, no <select>), with Any start, A fresh session, A
resumed session, After /clear, After the context is compacted, A
forked session and Any start but a fork. HookAgentView.Starts and
StartSources tell the page which matchers each agent takes. A chip that
can't take the matcher greys with one of three reasons, in the editor
and on the row, and save leaves it out. Every new string is in zh,
zh-TW, ja and de. docs/subsystems/library.md's Hooks row says all this.

Run, at 7f60927fd (origin/main 61394481c + this), all on mote:
- go test -tags nogui -count=1 ./internal/library ./internal/backup
  ./internal/davsync: ok.
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...:
  ok. gofmt -l: clean.
- node --test --test-concurrency=4 library-*.test.cjs (57 files)
  i18n-keys.test.cjs, both engines: 1183 of 1186 passed.
  - i18n-keys "a plugin's words are its own" is red for three strings
    already filed: #5482, #5426 and #5332/#5327. My "A new session"
    hit that test too (internal/claudetui says it), so it became "A
    fresh session".
  - library-mcp-json chromium "ja 390" timed out once. It passed 11/11
    run alone, twice. Filed as #5613.

Broken by hand:
- With the old hooks.go, TestHookSessionStartNarrowed and
  TestHookMatcherKeptToItsEvent fail ("session-start can't be narrowed
  to compact").
- With entry() writing no matcher and the sync check skipped, 17
  assertions fail: Claude and Codex are given matcher "", Gemini,
  Cursor and Grok get the hook whole, and no problems are shown.
- With the old client.js, library-hooks.test.cjs fails in every
  language, waiting for .lib-hookstart.

Not tried:
- No real agent ran a narrowed hook. The formats come from each
  agent's source and docs, not from a live session start.
- Old data: a hook saved before this has no matcher and is unchanged.
  A narrowed hook carried in a backup or sync to an older magpie is
  written whole there, because that magpie's sync doesn't check the
  matcher.
- The full go test ./... and the whole GUI suite run after the push,
  as agent-rules.md orders.

Reported-by: NEKO-CwC
2026-11-07 20:14:25 +08:00
yetone e932cd2589 library: a program whose path has spaces, typed as it is, is that program (zachzhao1984)
Library → MCP's command field splits a line at each unquoted space, as a
shell does, so "/Applications/Agent HUD.app/Contents/MacOS/Agent HUD --mcp"
reached the library as the program /Applications/Agent with the arguments
HUD.app/Contents/MacOS/Agent, HUD and --mcp. The save itself went through;
what was saved and written into every agent's config was a program that
isn't there, so the server never started. `magpie mcp add` with an
unquoted path and the TUI's line (strings.Fields) split it the same way.

Server.check, which every way in passes (the GUI's save, `magpie mcp add`,
the TUI, a market install, a backup or sync read in), now joins the words
back: when the command is a full path to no file, and it with the words
after it, joined by a space, is a program on this computer (a regular
file, executable outside Windows), that is the program and the rest are
its arguments; the fewest words that make one, as Windows reads an
unquoted path. A command that is there, a bare name (npx -y foo), or a
path no join makes stay as typed. Each agent is then given the program as
one argument with its spaces (JSON's and TOML's own quoting), and the GUI
shows it quoted ('/Applications/…/Agent HUD' --mcp), which reads back as
one word. A path typed in quotes, or with \ before its spaces, was already
one word. A server saved split before stays so until it is saved again:
opened and saved, its line is joined.

Tests:
- internal/library TestSpacedProgram: split, no arguments, given whole,
  a bare name, a path no join makes, a program that is there keeps its
  next word, a folder is no program.
- TestSpacedProgramSaved: ServerOf from the split words, SaveServer, the
  library and Claude Code's .claude.json and Codex's config.toml each
  hold the program whole and --mcp.
- internal/gui/tests/library-mcp-spaced-path.test.cjs: the reporter's
  line typed in a new server's dialog is sent as typed; the row and the
  editor show the path quoted; saving unchanged sends it whole; a quoted
  path is sent whole; a save the library refuses (a name with a space)
  shows its reason and the dialog stays. en and zh, 1100 and 390 wide,
  Chromium and WebKit, nothing scrolls sideways. The fake save stands in
  for the Go join.

Run (mote, via mote-run, at this tree on 30ae0e3f9):
- go test -count=1 ./internal/library ./internal/cli ./internal/tui: ok.
- go vet (library, cli, tui), GOOS=linux go vet -tags nogui and
  GOOS=windows go vet ./internal/library, go build ./..., GOOS=linux
  go build -tags nogui ./..., GOOS=windows go build ./...: ok. gofmt -l:
  nothing.
- win-run go test -run TestSpacedProgram ./internal/library (Windows 11):
  ok.
- node --test library-mcp-spaced-path: 10 of 10, four runs in a row.
  library-mcp-win-line, library-mcp-json, mcp-local-server: ok.
  i18n-keys "a plugin's words are its own" is red, the same three lines
  on a clean origin/main 30ae0e3f9 copy (filed: #5332, #5426, #5482);
  this change adds no strings.

Broken by hand:
- the spacedProgram call in check() commented out: TestSpacedProgramSaved
  FAIL, the library has Command .../Agent and Args [HUD.app/Contents/
  MacOS/Agent HUD --mcp].
- quote() taking a space as safe: library-mcp-spaced-path 0 of 10, the
  editor shows the line unquoted.
- The GUI test first flaked 2 of 10: a new dialog focuses its name a
  frame after it opens, and a command typed sooner landed in the name.
  The test waits for that focus now.

Not tried: the real Agent HUD app (not installed here), nor a real agent
starting the saved server; a program path with spaces given to an agent
in WSL (the join stats this computer's files, so a Linux path typed for a
distro is left as typed); the full go suite before this push (runs after,
under the lock).

Reported-by: zachzhao1984 (Discord)
2026-11-07 12:59:36 +08:00
yetone d55881730d gateway: a key can be held to some MCP servers and tools
wakaka on Discord (#help, 11-06) asked for gateway keys limited to some
MCP servers and tools, as keys already are to models (#882).

A key's MCP list (caller-keys.json "mcp") holds entries "server" (every
tool of it) or "server/tool"; "-" alone is no MCP server; an empty list
is every server, as before. A key issued under another is held to its
issuer's list too.

Every MCP route checks it:
- magpie's own servers (web search, vision, image, Magpie Browser, plugin
  tools) through serveMCP: initialize/tools/list/tools/call are refused
  or filtered per server and tool, and /v1/magpie/key-limits names "mcp";
- the Library hub ("magpie"): only the backing servers and tools the key
  may use are listed, and a call by name or by fallback is refused;
- /mcp/<name> and /mcp/run/<name>: the server is refused, tools/list is
  filtered in JSON and SSE replies, tools/call refused; a reply the
  filter can't read (an encoded body) is a 502, never passed through.

GUI: "MCP servers" in the key row's menu opens the app's own picker (no
native select) with All, No MCP server, each server and its tools (GET
/api/caller-keys/mcp lists magpie's own servers and the Library's). A
key held to some shows a badge saying which, that opens the same list;
a free key shows nothing more in its row, on hover either. A hover badge
was tried first: it pushed the row past 560px (gateway-caller-keys) and
squeezed the masked key under a drag at 420px (gateway-key-arrange).
CLI: magpie gateway-key mcp <id> github fs/read_file | none | all.
zh, zh-TW, ja, de strings; docs/reference.md and the gateway-routing and
library subsystem pages.

Not covered: a model's own built-in web search (a vendor tool, not MCP).

GET /api/caller-keys/mcp is named in the CLI parity test's notYet (its
list is what `magpie gateway-key mcp` takes; TestEveryRouteHasACommandOrIsNamed
caught it at the rebased head).

Run on mote (mote-run), at the pushed head:
- go test ./internal/access ./internal/cli ./internal/gui
  ./internal/library ./internal/gateway at a9c40186d (this change on
  2ce44dc28): ok except internal/gui's TestMainWindowCorners/macOS_26_SDK
  (#3949, the same message on macOS 27). After the rebase onto a9667daad
  (no file in common): TestCoreScriptBudget, TestCallerKey*,
  TestEveryRoute*, TestGatewayKey*, TestKeyMCP*, internal/access and
  go vet ./internal/... at d36f89224's tree: ok.
- gateway-caller-keys chromium en reads wider than 560px 4 of 6 runs
  alone on this branch and 4 of 6 on origin/main a9667daad: #3797,
  recorded there.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: clean; darwin, linux (nogui) and windows builds ok; gofmt -l
  clean.
- GUI: gateway-key-mcp.test.cjs in chromium and webkit, widths 1100 and
  420, en/zh/zh-TW/ja/de: 20/20. Every gateway-key*, gateway-keys* and
  i18n* file in both engines: ok except gateway-key-models en (red on
  origin/main ecc26a339 too, #4081/#5233) and i18n-keys "a plugin's words
  are its own" (red on main, #5332).
- The whole GUI suite (both engines, every language) with the hover
  badge: 91 reds in 25 files. Rerun alone on this branch and on
  origin/main 54dc257f1: only gateway-caller-keys (560px sideways),
  gateway-key-readonly, models-fold and models-select-all-api were red
  on the branch alone; the badge moved into the row menu for the first
  two. After it, every gateway-key*, gateway-caller-keys, gateway-card,
  gateway-connect-keys, api-key-theme and i18n* file passes in both
  engines, except i18n-keys "a plugin's words are its own" (red on main,
  #5332, none of the three strings are this change's) and 1 of 20
  models-select-all-api "the click scrolled" (#4389; models-fold is
  #4071). The rest are red on origin/main too and each has an issue:
  account-weight #4644, codex-auto-reset #2360, header-centre #3479,
  images-codex-one #4618, key-replace #4126, menu-input-scroll #3402,
  mobile-web #3952, model-chip-steady #4388, model-copy-id #4621,
  models-works-only #4391, nav-timeout #4787, omarchy #4624,
  page-width-steady #5013, phone-connect-menu #4706/#4707,
  plugin-move-unserved #4392.

Broken by hand, each went red: the serveMCP server gate, call check and
list filter, the own-server list filter and key-limits "mcp"
(TestKeyMCPOwnServer); hubTools, hubServersOf, the hubToolNamed
fallback and hubMCPRun (TestKeyMCPHub); /mcp/run (TestKeyMCPRun); the
/mcp/<name> guard and filter (TestKeyMCPProxy); the GUI's "No MCP
server" being exclusive (gateway-key-mcp).
gateway-key-readonly chromium 420 ja was red with the hover badge (the
sibling run, the whole suite and its rerun; green on origin/main) and
passes with the badge in the row menu.

Not tried: a real Library server through a live gateway, the hub with a
real agent, and running on Windows or Linux (vet and build only).

Reported-by: wakaka
2026-11-07 03:21:57 +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 483b131ef0 browser: magpie in Docker uses the host's own browser, through a key the page hands out
noahhrreion ran magpie in a container and its Magpie Browser never
connected. The host's Chrome dials ws://127.0.0.1:3425/v1/magpie/browser/
extension, which reaches the container from the bridge (172.17.0.1). That
is not loopback, so the gateway refused it (403). The browser MCP also
refused every caller from elsewhere, and the hub marked the browser
HereOnly. The extension's folder under the container's HOME can't be
loaded by the host's browser either.

Nothing is opened to the network without a key:

- The extension takes a gateway key: its popup has a Gateway key field,
  and config.js carries KEY (extension 0.1.7). From another computer the
  extension connects only with ?key= of a gateway key that is on, and
  only from the extension's own Origin (checked first). Loopback is
  unchanged, and a page's origin, null, a keyless call or a rebound Host
  are all still refused (TestBrowserExtensionOnlyFromItsOrigin).
- A browser that connects with a key belongs to that key. Sessions are
  tagged key:<id>/... (browserOwner, keyedSession), and a remote caller's
  session is forced to its own key's whatever it names. The relay filters
  every lookup (forSession, all, choose) through browserConn.serves. The
  browser MCP admits a remote caller only with a gateway key; a web page
  is refused as before.
- The key the page makes is recorded as this magpie's own browser's: its
  id goes in settings.Dir()/browser-key, written temp-and-rename. This
  goes by where the key came from, not by its name. A browser connecting
  with it serves this computer's sessions too, so agents inside the
  container use it as they would one on loopback. A record that can't be
  read names no key, so no keyed browser is this computer's.
- Router: magpie mcp browser is HubServer.Keyed. A visitor from
  elsewhere gets it only with a key (HubVisitor.Key), and hubCall names
  its session key:<id>/..., so it reaches only that key's browser.
- GUI: a page whose browser can't reach magpie's folders (InContainer, or
  a page from another computer) is "away". The Magpie Browser sheet's
  button then reads Download the extension. It does a POST to
  /api/library/browser/extension with the page's origin, which answers a
  zip pointed at that origin (3430 passes the gateway's routes on) and
  holding the recorded key's secret. The key is made the first time and
  reused while it is on. The steps (unzip, chrome://extensions, Developer
  mode, Load unpacked) are shown in every language. It is a POST so that
  a link from another site can't mint a key.
- Docs: reference.md (Docker), subsystems/library.md and mcp-router.md,
  and site docker.html in en, zh and ja.

Run, at this tree rebased on origin/main 6302f88bf, on mote:
- gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., and darwin, linux and windows builds:
  clean, all ok
- go test -tags nogui -run 'Browser|Hub|OwnBrowser' ./internal/gateway/,
  and the whole of internal/library, internal/gui and internal/browserext:
  ok (gateway 2.4s, library 166s, gui 104s, browserext 0.3s)
- GUI tests library-browser-away (new: every language, Chromium and
  WebKit, 1100 and 420 wide), library-browser-setup, library-browser-ask,
  i18n-keys and i18n-en-no-cjk: 115 pass. One red, i18n-keys "a plugin's words are its own", is for three
  strings this change doesn't touch and is already filed (#5332, #5426,
  #5482)

Real use, in Docker Desktop on xiaomi-gpu (Windows 11): this tree's
Dockerfile image, run as `web --addr 0.0.0.0:3430` with 3425 and 3430
published to the host's localhost. The host's Node and Playwright Chromium:
- signed in to the page, which says away:true;
- downloaded the zip (GATEWAY "ws://localhost:3530" and a KEY), twice,
  getting the same key both times;
- a keyless /mcp/magpie/browser call from the host got 401;
- loaded the unzipped extension with --load-extension. The container's log
  says "Magpie Browser 0.1.7 connected with gateway key 12d2702a…" and
  /api/library/browser says connected:true;
- an MCP client on the host with that key listed b1 (Chrome 151), opened
  http://localhost:3531/ (served on the host) and read "hello from the
  host";
- a second gateway key made in the container got "isn't connected with
  this gateway key";
- a curl inside the container to 127.0.0.1:3425/mcp/magpie/browser with no
  key listed the host browser's tabs, the host page included.

Broken by hand, each red:
- forSession left unfiltered;
- a remote session not forced to its key;
- no Origin check on a keyed connect;
- hubCall not prefixing the session;
- Keyed given to a visitor with no key;
- the old MCP guard;
- browserKey not reusing the key;
- the away peer check removed;
- serves("") without own (TestOwnBrowserKeyIsThisComputers,
  TestOwnBrowserKeyUnreadable);
- OwnBrowserKey reading the wrong file (the gateway tests and
  TestBrowserExtensionDownload).

Not tried:
- the reporter's own setup (their compose file and Chrome);
- a real agent's MCP client calling the browser from the host. Node's
  fetch sends Sec-Fetch-Mode: cors, which fromBrowser counts as a web page
  and refuses. The e2e used node's http instead. Whether an agent's MCP
  client built on fetch is hit by this is not checked; filed as #5522.
- Edge, Brave and Firefox;
- a remote page over https/wss through a proxy.

What the user does: update magpie and publish 3425 and 3430. In the web
UI open Library -> Magpie Browser -> Download the extension, unzip it and
Load unpacked in chrome://extensions. An extension 0.1.7 already loaded
can take the address and key in its popup instead.

Reported-by: noahhrreion (Discord)
2026-11-06 20:06:15 +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 64b563cee8 gateway: the MCP router keeps Magpie Browser, the image server and other routers to this computer
A gateway key from another computer (LAN, tunnel, or a proxy here) or a
web page could reach, through /mcp/magpie/hub, servers that act as this
computer's user:

- Magpie Browser, which /mcp/magpie/browser itself refuses to such a
  caller, so a LAN key could drive the user's signed-in browser;
- magpie's image server, which draws with this magpie's own token, past
  the key's model, account and spend holds;
- another magpie's router, which passes calls on to its own browser.

These are now HereOnly (keepsSession or isSelf in the library) and are
neither listed nor run for an away caller. The check sits both in the
gateway (hubServersOf, hubTools) and in the library (visitorServers,
Call), so a call by name is refused too. A held key (nativeHeld) from
another computer also no longer gets programs run here (stdio commands,
plugins), only HTTP servers elsewhere. Local callers are unchanged. The
mcp-router subsystem page says both rules.

Run on mote (macOS 27) at this tree, base 49c9491b7:
- gofmt -l internal: clean
- go vet: darwin; GOOS=windows; GOOS=linux -tags nogui (gateway, library)
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway
  ./internal/library ./internal/gui ./internal/provider: gateway, library
  and gui ok. In provider, TestRenewLoginsKeepsClaudeReading fails
  (#5481, a fixed-date fixture, red on main and taken by another
  session).

Rebased on fe61503e6 (gateway.go, remote_moved_test.go changed):
gofmt, go vet, and go test -run 'Hub|RemoteMoved|Moved' in gateway and
library ok at the pushed tree.

Broken by hand: making Gives always true turns both
TestHubKeepsThisComputersOwnServersHere tests red (the browser and image
are listed and run for 192.0.2.7). Taking the library's Call check out
leaves the library test red on a call by name.

Not tried: a real LAN client against a live magpie. Windows and Linux
were vetted, not tested.
2026-11-06 18:36:04 +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 1ccad582d8 library: a skill the user has in ~/.agents/skills under another folder or with other files is not given a second time
math_milian (Discord #feedback, 11-06) still saw skills twice after
d487aaab7. That commit kept the library's link out of a reader's own
folder only when ~/.agents/skills held the same files under the same
folder name. Pi, Codex, Gemini, Kimi Code and the other readers of that
folder still got a second copy when the user's entry there:
- had other files (an update through `npx skills`, a local edit), or
- sat under another folder name with the same SKILL.md name (Pi goes by
  the frontmatter name; real Pi 1.4.0 warns `name "hunk-review"
  collision` for both cases with magpie's link beside it, and loads the
  user's alone with no diagnostics once the link is gone).

readSharedOwn/sharedOwn.rival now finds the user's entry by folder
name or SKILL.md name. A same-tree one counts as the library's (as
before). A differing one gets no second copy: it raises the Own problem
("{agent} already has a skill of its own called X"), whose Use the
library's sets the shared entry aside with the backups and gives the
link, and whose Keep {agent}'s unticks it. Agents that don't read the
folder (Claude Code) keep their link. Old users' second links go on
the next sync (the GUI syncs at start), through the existing unlink.

TestKimiSweepLeavesTheUsersOwnSharedSkills and TestSkillsWhereShared
assumed a differing same-name user skill gave the library's again;
they now expect the Own problem and no second link.

Run (mote, at this tree on cd9c52c16):
- go test -tags nogui -count=1 ./internal/library ./internal/cli
  ./internal/gui: ok
- GOOS=linux/windows go vet -tags nogui ./internal/library, go vet: ok;
  gofmt -l clean
- win-run: TestSharedCopy*, TestSharedOwn*, TestSkillsWhereShared,
  TestKimiSweep*: ok
- probe in a sandbox HOME, skill ticked for claude, codex, pi, gemini,
  opencode: same tree / other files / other folder name / shared link
  elsewhere; before, the last-but-one two gave pi, codex, gemini a
  second entry; after, none (OpenCode merges ~/.claude/skills with
  ~/.agents/skills by id, so it never shows two)
- real Pi 1.4.0 loader on mote for the two cases, before and after

Broken by hand:
- rival matching same-tree only: TestSharedCopyNotGivenTwice and
  TestSharedOwnSettled red
- readSharedOwn keyed by folder name only: TestSharedCopyOtherFolderName
  red (.pi, .codex, .gemini still have a second one)

Not tried: the reporter's own tree (asked for), the real GUI's Use/Keep
buttons on this problem, WSL/Linux runs, a Pi or omp of unknown version
(still given its own, in docs' Not covered).

Reported-by: math_milian
2026-11-06 15:04:01 +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 9e3a389e0b library: a skill whose app left its own link on a deleted version follows the version on disk
tjhhhh_84378 on Discord (11-06): ego lite updated from 0.6.2.5 to 0.6.2.7,
deleted Versions/0.6.2.5, and left its own ~/.local/share/ego/
active_version_dir naming it. The library's ego-browser, brought in since
dccfefdf7 (#2635), links to ego's ~/.local/share/ego/ego-skills ->
active_version_dir/Resources/ego-skills/ego-browser, so the whole chain led
nowhere and the skill was lost, while 0.6.2.7 had it complete.

Who owns which link: ~/.local/share/ego/ego-skills, active_version_dir and
the framework's Versions/* are ego's; magpie only reads them. magpie writes
the library's own link (library/skills/ego-browser) and the agents' links
to it. The stale pointer is ego's, but magpie lost the skill with a newer
version on disk.

557f51dbf mended a library link that points straight into Versions/<old>,
but movedVersion looked only at the link's own target: for ego-skills the
first missing part is not a version name, so nothing was found.

followMovedSkills (skill_moved.go) now, for a dangling library link whose
target isn't in a version folder, follows the links on the way as far as
they are there (linkedEnd) and asks movedVersion of where they end:
Current/current/latest when that leads to the skill, else the highest
version beside the deleted one with a SKILL.md there. The library links to
that folder, and keeps the app's steady link as the new Source.Via. Once
the steady link leads to a SKILL.md again (ego or the user mended it), the
library links through it once more and Via is cleared. ego's links are
never written. With no other version on disk the link is kept as it was
and the skill is shown missing, as before.

Old imports: a skill linked straight into Versions/<old> was already
mended by 557f51dbf; one linked through ego's link (since dccfefdf7) is
mended by this on the next read of the Library page or the next sync. No
re-import needed. Agents that read ~/.agents/skills directly still see
ego's own entry there, which is the user's/ego's and is left alone.

Tests (skill_moved_test.go), the reporter's layout: egoLite at 0.6.2.5,
brought in through ~/.agents/skills/ego-browser -> ego-skills, then 0.6.2.7
added, 0.6.2.5 deleted, active_version_dir and Versions/Current left on
0.6.2.5:
- TestSteadyLinkLeftOnDeletedVersion: Read shows it not missing, it reads
  as 0.6.2.7's, active_version_dir is unchanged, Via is ego-skills; after
  active_version_dir is pointed at 0.6.2.7, a Sync links through ego-skills
  again with no Via.
- TestSteadyLinkLeftOnDeletedVersionNoOther: no other version, shown
  missing, link left as it was.

Broken by hand:
- linkedEnd step turned off: TestSteadyLinkLeftOnDeletedVersion red
  (Missing:true), i.e. red on the old code.
- the go-back-to-Via case turned off: red, still linked to 0.6.2.7.

Run (mote via mote-run): gofmt -l clean; go vet -tags nogui
./internal/library for darwin, GOOS=linux and GOOS=windows clean; go test
-tags nogui -count=1 ./internal/library ok (91s). Windows box (win-run):
SteadyLink, OldImport and ImportedSkill tests pass (junctions). Full suite
after the push, recorded on the tag's follow-up.

Not tried: the reporter's machine or a real ego lite update; the layout is
the #2635 fixture with the paths from their message. Whether ego's
Versions/Current also stayed on 0.6.2.5 isn't known; both are covered.

Reported-by: tjhhhh_84378
2026-11-06 12:13:16 +08:00
yetone d487aaab79 library: no second copy of a skill the user keeps in ~/.agents/skills
math_milian: a skill given to every agent was in ~/.agents/skills and
in ~/.pi/agent/skills, and Pi warned
  "hunk-review" collision: ~/.agents/skills/hunk-review (skipped)
Pi 1.4.0 reads ~/.pi/agent/skills, then ~/.agents/skills
(userAgentsSkillsDir in dist/core/package-manager.js), and drops a
skill read twice only when both paths are one file (realPathSet in
dist/core/skills.js). magpie already left out its own link for an
agent that reads the shared folder when the entry there was the
library's folder, magpie's link, or a holder's (Goose, Kimi Code). It
did not when the entry was the user's own copy of the same files
(another installer's, or copied by hand), so Pi, Codex, Gemini CLI,
OpenCode and the other readers each got a second tree beside it.

inShared now also counts such a copy (sharedCopy: not ours, not the
library's own folder, sameTree with the library's). The reader gets
nothing in its own folder, and the existing unlink loop takes out
magpie's link or marked copy there on the next sync, which only ever
touches entries ours() proves magpie made. The user's copy is never
touched; once it differs from the library's, the library's is given
again. Readers checked in their own code: Pi 1.4.0's loader, Codex
0.165.0's binary (user-agent-skills, .agents/skills), Gemini CLI
0.35.3's bundle (Storage.getUserAgentSkillsDir) and OpenCode 2.0.25's
binary (home/.agents). Amp isn't a skills target of magpie's.

Run:
- mote-run go test -count=1 ./internal/library ./internal/gui
  ./internal/cli: library and cli ok; gui red only on
  TestMainWindowCorners/macOS_26_SDK, #3949 (mote is macOS 27). go vet internal/library (darwin, GOOS=linux
  -tags nogui, GOOS=windows): ok. gofmt -l: clean.
- Real Pi 1.4.0's own loader (DefaultResourceLoader) in a sandbox HOME,
  cwd outside the home: a link in ~/.pi/agent/skills to the library's
  folder beside the user's copy in ~/.agents/skills gives
  'name "hunk-review" collision'; with the link gone (what the sync now
  does) the skill loads from ~/.agents/skills and no diagnostic.
Broken by hand: sharedCopy's return replaced with false,
TestSharedCopyNotGivenTwice red (link and copy: pi's and codex's
second entry stays).
Not tried: the magpie GUI against the reporter's real tree (their
layout is inferred from the warning); a library skill that is itself
a link to the agent's own folder beside such a copy keeps both (that
folder is the library's); a Pi or omp of unknown version is given its
own as before; Windows and WSL not run.

Reported-by: math_milian
2026-11-06 11:18:51 +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
ggbdpq 9f6407321d library: a project whose folder was deleted outside magpie comes off the list when it's removed (#3510)
RemoveProject empties a project (Skills, Servers, then syncProject) and
takes the entry off the list only once nothing magpie placed or wrote is
left in it. But the only thing that empties those records, syncProject,
gives up on a folder that's gone: it says "the folder is gone" and
returns with the records as they were — and the Result RemoveProject
hands it is thrown away, so the removal itself says nothing; the toast
the user sees is the one the full sync after every change reports. With
the folder gone there is nothing magpie can ever take back, so the
records never empty and the entry stays for good: the only way out was
the keep checkbox, which takes the entry off the list without looking at
the folder (#514), though that reads as keeping what magpie wrote, not
as the way out of a dead removal.

So removal now does what a skill's removal already does when its folder
is gone (removeSkill: only the entry goes): a folder that isn't there
has nothing of magpie's on disk to take back, so the project and the
records of what it placed and wrote go together, and the removal says
nothing failed. A folder that is there removes as before; a project
gone from disk still shows its "folder is gone" badge and still reports
the folder on a full sync; keep is untouched.

TestRemoveProjectWhoseFolderIsGone is new: a project with placed skills
whose folder is deleted outside magpie, removed without keep — the
entry goes, the Result has no problem, the library's skills stay; and a
gone project removed with keep goes off the list as it always did. It
fails without the change (the removal says "the folder is gone" and the
entry stays) and passes with it.

go test -tags nogui -count=1 ./internal/library/ pass (28 project and
gone-family tests targeted first); gofmt, go vet -tags nogui and
go build -tags nogui ./... pass. The cgo warning from
internal/gui/trayimage_darwin.go is there before this change.

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and ported, narrowed: only a folder known to be gone (not
there, or not a folder) drops the records. A Stat that fails another way
(no permission, a drive answering with an error) isn't known to be gone,
so the removal goes as before and the records stay, to be taken back
once the folder answers; TestRemoveProjectWhoseFolderCantBeRead pins it.

Run on mote (darwin arm64, Go 1.26.8): go test -tags nogui -count=1
./internal/library/ ok 73.8s. On Linux (wsl-run, magpie-desktop):
-run TestRemoveProject ok.
Broken by hand: projects.go back at main, tests kept:
TestRemoveProjectWhoseFolderIsGone FAIL "the removal said: [... the
folder is gone]", the entry left with Placed [.agents/skills/pdf
.claude/skills/pdf]. The patch's own check (err != nil):
TestRemoveProjectWhoseFolderCantBeRead FAIL "projects: []".
Not tried: removing a deleted project from the GUI on Windows, the
reporter's system.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 05:46:03 +08:00
ggbdpqandIkki c6d2bd3316 library: ZCode reads the shared skills folder too (#4987)
ZCode reads ~/.agents/skills beside its own ~/.zcode/skills, but it
wasn't among the readers of the shared folder: a skill kept there
behaved as if ZCode didn't have it — its chip unlocked, a tick writing
a second link into its own folder. It reads it as the others do.

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and ported: docs/subsystems/library.md now lists ZCode among the
readers of ~/.agents/skills, as Ikki6666's own branch (a23828e81) had it;
the reporter checked the published ZCode builds for a version boundary
and found none (#4987).

Run on mote (darwin arm64, Go 1.26.8): go test -tags nogui -count=1
./internal/library/ ok 76.5s; -run 'ZCode|Shared|Always' ok.
Broken by hand: "zcode" taken out of readsShared, test kept:
TestSharedSkillReachesZCode FAIL "zcode has a second link to it in its
own folder" and "zcode's own folder got it on the sync too".
Not tried: a real ZCode install reading the skill.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
Co-authored-by: Ikki <824310075@qq.com>
2026-11-06 05:41:29 +08:00
yetone 7625481b9e library: a Codex MCP entry never keeps the other transport's keys
kwanyu (Discord #help, 11-06): with Codex connected to magpie, the
ChatGPT/Codex app wouldn't start: "config.toml:209:1: env_vars is not
supported for streamable_http". Codex refuses a command's keys (args,
env, env_vars, cwd) beside a url, and a url's (bearer_token_env_var,
http_headers, env_http_headers, http_headers_helper, oauth,
oauth_resource, auth) beside a command (codex-rs/config/src/
mcp_types.rs, TryFrom RawMcpServerConfig).

merged kept every old key magpie doesn't own. env_vars is magpie's only
while the server references a variable in its env, so a server changed
from a command to a URL (in the Library, or one imported from the
user's own stdio entry) kept its env_vars and cwd under the new url.
The converse kept bearer_token_env_var and env_http_headers under a
command. The sync's in-step check decodes neither key, so an entry
already broken was never written again.

Now codexRefused names the other transport's keys. merged drops them,
and behind reports an entry holding one, so the next sync (and a
project's .codex/config.toml) rewrites it. The user's keys of the
entry's own transport stay (enabled_tools, tool_timeout_sec, scopes, a
stdio entry's own env_vars). bearer_token, which Codex refuses for both
transports, is left as the user wrote it.

Run (mote): go test ./internal/library -count=1 ok (77.8s); GOOS=linux
and GOOS=windows go vet ./internal/library ok; gofmt -l clean.
Broken by hand: the four new tests against the old mcp.go are all red
(env_vars/cwd kept under a URL; bearer_token_env_var, env_http_headers
and oauth_resource under a command; a broken entry left in step; a
project entry read as in step).
Real Codex (codex-cli 0.165.0, sandbox CODEX_HOME, codex mcp list): a
url + env_vars entry fails with the reporter's exact error. The three
config.toml files the new tests write load and list their servers.
Not tried: the reporter's own config.toml (we only have the error line);
the ChatGPT desktop app itself; Grok's config (written by the same TOML
writer, its own transport rules not checked); a full suite before push
(runs after).
2026-11-06 02:04:53 +08:00
yetone c24915f04e library: LiveAgent in the MCP and Skills pickers (zero2sin)
LiveAgent was missing from the Library's MCP and Skill agent pickers
(zero2sin on Discord #feedback). It is now a target, written in its own
engine's formats, read from K-brain 507f560 (the one LiveAgent af89ea7
pins), not guessed:

- MCP: <data dir>/config.json.live-mcp.json (cmd/kn/backend.go,
  internal/mcp/live.go LiveSettings): {"servers":[{"id","enabled",
  "transport":"stdio"|"http","command","args","env" | "url","headers",
  ...}],"selected":[...]}. Streamable HTTP only, so SSE is refused.
  ${NAME} in env and headers resolves as K-brain's secret refs
  (internal/config/secret.go). The user's servers and their
  description/enabled/cwd/timeoutMs/policy/auth/... are kept; untouched
  servers are written back byte for byte (json.RawMessage). A non-empty
  selected gets magpie's server added (or it would have no tools) and
  taken out on remove, never the last one. With no file yet, K-brain
  reads config.json's "mcp" object (settingsFromConfigs), so the first
  write carries those servers over the way K-brain's own first save
  does. A new file is 0600 like K-brain's. A file K-brain itself could
  not parse is not written over.
- Skills: <data dir>/skills, as copies (Target.Copy): K-brain refuses a
  link in a skill's path (safePath) and ScanDetailed walks past one. A
  skill there loads only when picked in skills-settings.json
  global.selected (Manager.Effective), so syncLiveAgentPicks picks each
  copy magpie makes once (Applied.Picked), never again after the user
  unpicks it, and unpicks it when the copy goes. Names K-brain refuses
  (validManagedName) are never put in selected, since its next save
  would fail on them. Its built-in skills-creator/skills-installer are
  not offered for import.
- Not added: instructions (K-brain's brain.md is its own memory file).
  A server written while LiveAgent runs is seen at its next start (the
  app holds the list in memory and saves it whole).

Run (mote-run, at base 326e72f4c):
- go test -run LiveAgent ./internal/library/: 7 tests ok
- go test ./internal/library/... ./internal/agent/ ./internal/gui/:
  library ok, agent ok, gui FAIL only TestMainWindowCorners/macOS_26_SDK
  (#3949, macOS 27 on mote, no library code)
- GOOS=linux and GOOS=windows go vet ./internal/library/: clean;
  gofmt -l: clean
- node --test of 100 GUI files (library-*, *skill*, *mcp*, i18n-keys)
  in chromium and webkit: 1941 of 1946 pass. Red: i18n-keys "a plugin's
  words are its own" (two Go test files elsewhere say a plugin's word)
  and found-skill-pick-remove "en at 420px" in both engines; this change
  touches no GUI file.
- Rebased on origin/main 125fd93ec and run again there:
  go test ./internal/library/ ok; found-skill-pick-remove and i18n-keys
  red the same (en at 420px both engines; "a plugin's words are its
  own"), and red the same on a clean origin/main 125fd93ec worktree:
  filed as #5013 and #5327/#5332.

Broken by hand, each red: Copy=false (TestLiveAgentTarget,
TestLiveAgentSkills: a link); no syncLiveAgentPicks call (nothing
picked); re-picking every sync (TestLiveAgentSkills: xlsx picked again
after the user unpicked it); no built-in skip (found lists
skills-creator); no selected append (TestLiveAgentMCP); no config.json
seeding (TestLiveAgentMCPFromConfig); no chmod (0644); no name check
(TestLiveAgentSkillsNewSettings: My_Skill picked).

Not tried: a real LiveAgent app reading the written files (no LiveAgent
on mote or here); Windows and Linux test runs (vet only).
2026-11-06 00:26:59 +08:00
ggbdpq 38c3ba846f library: an edit made in the shared copy of a skill is taken into the library (#4958)
What changed: takeEdits reads the shared copy too - ~/.agents/skills
where no link could be made (Windows without the right to), the entry a
marked copy - as it reads an agent's copy: anything newer than the
copy's mark is an edit, the newest one taken unless the library changed
after it, losers kept aside. An agent whose own folder ~/.agents/skills
is has its copy read as it was; the shared scan only runs where no
target already covered that folder. syncShared, which sets a stale copy
aside before copying again, runs after, so the edit is in the library
and every other agent's copy first.

Run:
- go test ./internal/library -run TestEditInSharedCopyTaken -count=1
  RED before: the edit wasn't taken (the library's skill has no
  notes.md) and the shared entry lost it; green after.
- go test ./internal/library -count=1: ok (66s).
- gofmt, go vet -tags nogui (darwin/linux/windows), builds
  (darwin/linux/windows), the new test with -race: clean.

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and ported: differs from 1851ead1a, which handled an agent's
own copy; the shared ~/.agents/skills copy (Windows' marked copy where no
link can be made) was still overwritten by syncShared. On mote, with
skill_edits.go at the parent: TestEditInSharedCopyTaken FAIL ("the edit
in the shared copy wasn't taken into the library", "the shared entry
lost the edit"); green with the patch. go test ./internal/library ok on
mote, and TestEditInSharedCopyTaken ok on Windows (win-run, xiaomi-gpu).
GOOS=linux/windows/darwin go vet -tags nogui ok. Not tried: the real
GUI's "Put skills in ~/.agents/skills" on Windows with a real agent.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-05 18:31:17 +08:00
yetone 06508f2bf5 library: a stdio server that refuses home is checked again in a project folder (fff)
math_milian on Discord: fff-mcp worked in their agent, but Library → MCP
said "fff exited (1)". fff-mcp indexes the folder it starts in and
refuses a file system root or home ("Can not run certain FFF features in
a file system root or home directories"), exiting 1. magpie's check
starts every stdio server in home (#1727), where agents never start it;
they start it in their project.

When a local check exits, it now starts the server once more in an empty
project folder of its own (removed after). If it answers there:
- given to agents that start it themselves (no router, not Codex on
  magpie, or hub "direct"), the row shows its tools, and the tooltip says
  it exits in home, with what it said;
- run by magpie in home for agents (the MCP router, or Codex on magpie's
  RunPath), the row says "won't start in home" (why "home"), and its
  editor offers "Through the MCP router" to turn off, even with the router
  off, so each agent starts it in its project.
A server that exits in both places reads as before. WSL checks are
unchanged. healthKey (Go and client.js) now includes whether magpie runs
it in home, so a router change checks it again. startServer takes the
dir; the hub and the RunPath runner still pass home.

Run:
- go test -count=1 -timeout 30m ./internal/library on mote: ok (159s).
- TestCheckServerThatRefusesHome red on the old code: State error, Why
  exited, Code 1, with fff's text, the reporter's case.
- Real fff-mcp 0.11.0 (cargo-built on mote, sandbox HOME resolved through
  /private/var) via CheckServer: direct ok, 3 tools, Project; router on,
  Why home, Code 1.
- go vet ./internal/library ./internal/gui (darwin), GOOS=windows and
  GOOS=linux go vet ./internal/library on mote; gofmt -l clean.
- GUI on mote, Chromium + WebKit: mcp-home-health (new, every language,
  1100 and 390), library-mcp-health, mcp-hub-direct, library-mcp-hub,
  library-mcp-health-wsl, i18n-en-no-cjk, i18n-keys: 91 of 92 ok. The red
  is i18n-keys "a plugin's words are its own" on search_row_archive_test.go's
  "View routing", red on main since 73c98ebc2 (#5327, #5332).

Broken by hand: the new test run against the old mcp_check.go (red as
above).

Not tried: Windows and WSL runs; a real agent session through the router
or Codex's RunPath; the whole GUI suite.
2026-11-05 14:50:02 +08:00
yetone 47d5839397 library: sync and backup files carry the hooks
VincentChan on Discord (v0.1.3005) said part of the Library doesn't reach
his other computer through sync. Checked kind by kind what the library part
of a bundle carries: instructions (each set's text, a linked set's file text,
the agents ticked, each agent's own addition), MCP servers, skills and
subagents all go. Hooks didn't: library.Bundle had no field for them, so a
hook made on one computer never reached the other, by WebDAV/S3/GitHub sync
or a backup file.

- library.Bundle.Hooks (*[]*Hook): name, description, event, matcher,
  command, timeout, agents ticked. Collect always sets it, empty too.
  Applied.Hooks (the entries magpie wrote into each agent here) stays out:
  each computer writes them on the sync Put runs, beside the user's own
  hooks, and records its own entries, so an entry the user edited there
  stays theirs.
- Put replaces the hooks with the bundle's, so one taken out on one
  computer goes from the others. A nil list (a bundle from a magpie before
  this) keeps this computer's.
- check refuses a hook with no name, no command, or named twice. The event
  and agents are carried as they come: an event a newer magpie knows is a
  problem on the agent here, not a refused library.
- davsync: an empty list hashes as before the field, so upgrading with no
  hooks syncs nothing.
- The CLI's backup line counts hooks; the GUI's sync/export/import ticks
  say "instructions, MCP servers, skills, hooks and subagents" in every
  language.
- library.md and sync-backup.md updated, and they now name what stays
  this computer's own: projects, skill groups, CopySkills/SkillHow,
  SharedSkills, MCPHub.

Instructions: two sandbox computers through the fake DAV server carried a
named set and a change to it, a set linked to ~/.agents/AGENTS.md and a
hand edit of that file, both computers having their own text first, an
agent's own addition, and an agent installed after the first sync. All
reached the second computer's CLAUDE.md/AGENTS.md (exploration tests, not
kept). So no instructions change here; what VincentChan saw is not
reproduced yet.

Run (worktree at 0e55a7593; origin/main bf60ea596's two commits touch
none of these files):
- mote: go test -tags nogui ./internal/backup ./internal/davsync
  ./internal/cli ./internal/library ok; go vet -tags nogui for darwin,
  GOOS=linux and GOOS=windows on the four packages ok; gofmt -l clean;
  go test ./internal/gui -run 'TestCoreScriptBudget|Words|I18n|Builtins' ok
- GUI (wsl-run, Linux): i18n-keys, github-sync, s3-sync, sync-*,
  webdav-settings-refresh, library-backups-top, gui-de, gui-ja, gui-zh-tw:
  187/187

Broken by hand: with Collect not setting Hooks, Put ignoring them and the
hash not dropping an empty list (the old code), TestCarryHooks,
TestCarryOldBundleKeepsHooks, TestCarryNewerHooks,
TestBackupFileCarriesHooks, TestSyncHooks and TestNoHooksHashAsBefore
went red.

Not tried: a real WebDAV/S3/GitHub remote between two real computers;
Windows and Linux runs of the Go packages.
2026-11-05 11:29:20 +08:00
yetone 7564e46690 library: a subagent names its model, written into Codex's role as model (#4421)
luckymanjc (Discord) set Codex's subagent model to Default on the Agents
page and gave a Library subagent a prompt that named a routing group.
Codex knew the group's name, but the subagent ran on Codex's own model.
A Library subagent had no model field, and Codex's role file
($CODEX_HOME/agents/<name>.toml) got only name, description and
developer_instructions. So Codex started the subagent on the model the
lead passed in spawn_agent, or on the lead's own model. The group was
only text in the prompt.

codex-rs reads a role file's model (AgentRoleOverrides). In
child_config.rs, prepare_agent_spawn_config applies the lead's
spawn_agent model, or [agents] default_subagent_model, first, and then
the role. So the role's model wins. A subagent now has a Model field: an
app menu with "Picked by the agent", the models and routing groups Codex
lists (groups noted as a routing group), and a saved id Codex no longer
lists. The Model is written as model = "..." to Codex's role only. A
subagent without a Model is written as before, byte for byte. Other
agents' files don't change; the hint names the agents that don't take
it. When the Agents page's Codex subagent model is set, the gateway still
puts that in place of the role's model (codexSubagentPick), and the hint
says so.

Run:
- Real codex 0.165.0 on mote, sandbox CODEX_HOME, fake Responses
  server. With no role model, the collab_spawn request carried the
  lead's model. With model = "group/review" in the role, it carried
  group/review, also when the lead named gpt-6-sol in spawn_agent.
- mote-run go test ./internal/library: ok. TestSubagentModelGoesToCodex
  went red with codexRole given "" for the model by hand.
- GUI library-subagents.test.cjs: 12/12 in Chromium and WebKit, in en,
  zh, zh-TW, ja and de. Red with origin/main's client.js (timed out
  waiting for the model picker).
- i18n-keys 4/4: it was red at first, because the plugin defined
  "Routing group" and "Find a model". The change now uses core's
  "routing group" and "Find a model…".
- gui-zh-tw, gui-ja, gui-de, library-all, library-gone-agents,
  library-wsl-asleep: ok.
- gofmt -l is clean. go vet, GOOS=windows go vet, and GOOS=linux go vet
  -tags nogui on internal/library and internal/gui: ok.
- go test ./internal/gui: only TestMainWindowCorners/macOS_26_SDK is
  red. It is red alone on origin/main 93d5c76c0 too: #3949.

Not tried: a real magpie gateway with a real routing group end to end,
the Codex app or IDE extension, and Windows and Linux runs. A
reasoning effort per subagent, and a model for Claude Code, OpenCode,
Droid and the other agents, stay open in #4421.
2026-11-04 21:18:56 +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 5957223d89 library: a project's skills can be given to DeepSeek Harness, in the project's .agents/skills
xingchen_c on Discord (#general, 11-04): "资源库按照项目配置能否支持一下dsh".
projectSkillsDirs left dsh out, its comment saying it reads no project
folder magpie can rely on. It does, and always has: the skill provider
every dsh profile mounts (dsh-base's cordis.patch.yml, id skill-filesystem)
scans <projectRoot>/.dsh/skills (rank 100) and <projectRoot>/.agents/skills
(rank 200), the project root being the nearest folder up from the
session's cwd with a .git, else the cwd (roots and findProjectRoot in
@deepseek-ai/dsh-skill-filesystem 0.2.1-rc.5; the same two joins in
0.0.1-rc.3, 0.1.0-rc.6, 0.1.5-rc.3, 0.1.7-rc.2, 0.2.0-rc.2, 0.2.1-rc.1
and 0.2.2-alpha.3). dsh now gets the shared .agents/skills, so the
project row lists it and one link serves it with Codex and the rest.

MCP stays as it was: dsh's servers are dsh-mcp-client rows in a
profile's patch layers (bundles, the profile's and $DSH_HOME's
cordis.patch.yml, --patch overlays; composeProfile in @deepseek-ai/dsh
0.2.1-rc.5), none of them the project's. Said in project_mcp.go and
docs/subsystems/library.md.

Run:
- mote: go test -count=1 ./internal/library/ ok (102.9s); gofmt -l
  clean; GOOS=windows and GOOS=linux go vet ./internal/library/ ok.
- Broken by hand: TestProjectSkillsDsh with projects.go at origin/main
  fails ("magpie knows of no folder dsh reads a project's skills from").
- Real dsh: @deepseek-ai/dsh 0.2.1-rc.5 from npm on mote, sandbox HOME
  and DSH_HOME, headless profile against a fake OpenAI-compatible server.
  Run in a folder with .git, a skill linked into its .agents/skills is in
  the request's <available_skills>; run in a folder with no .git, its own
  .agents/skills is read; run in a subfolder of the repository, only the
  root's is read, not the subfolder's (filed as #5172).
- GUI: /api/library's view from library.Read with a sandbox ~/.dsh,
  served to the real assets in Chromium and WebKit, en and zh: the
  project card's skill rows have a dsh chip (lit where given), and the
  "reads no project skills folder" line no longer names it.

Not tried: the dsh Desktop app (its own profile; the same base bundle
is assumed, not checked); the full GUI suite (no GUI file changed);
Windows copy mode with a real dsh.
2026-11-04 13:53:04 +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 8c93923638 library: no package's tests install an npx server's package or end the machine's servers (#4140)
TestLibraryMCPHub (internal/cli) adds `npx -y fs` to Claude Code, turns
the MCP router on and off and keeps fs direct. Each sync gave the agent
the package run by node from magpie's own install (mcp_npx.go), so it
started `npm install fs` in the background under the test's temp HOME,
and each change that took fs out of every agent ended the machine's
processes running `npx -y fs` (mcp_reap.go). Only internal/library's
TestMain turned the two off (npxInstall = nil, ending a no-op); every
other package that syncs the library ran them for real. So npm was
still writing .config/magpie/mcp-npm/<hash>/node_modules when TempDir
cleaned up (#4140, macOS: "directory not empty"; Windows: "being used
by another process"), and the user's own running fs server was ended
by a test. coffemon (Discord) pointed out the second.

Now the library turns both off itself in any test binary
(testing.Testing(), in init), as internal/provider and internal/agent
do for their own reach out of a test; internal/library's TestMain no
longer sets them, and the tests about either still set their own.

What was run (mote, macOS, go1.26.8):
- TestTestsLeaveTheMachineAlone, new (internal/library): ok; with
  mcp_npx.go as on 5ee5274bd and the new tests, red: "npxInstall is set
  in a test binary: a test adding an npx server runs npm install" and
  "ending is endDropped in a test binary: ...".
- TestLibraryMCPHub with a fake npm first on PATH that records its
  calls, and a process `.../npx -y fs` (a sh script sleeping) started
  before it: on 5ee5274bd npm was run twice, "npm install --prefix
  .../TestLibraryMCPHub2348071777/001/.config/magpie/mcp-npm/
  dce7cce055566bed ... fs", and the running `npx -y fs` was ended by
  the test (Terminated: 15); with this change npm was never run and the
  process was still running after it.
- go test -count=1 ./internal/library ./internal/cli ./internal/proc:
  library and proc ok; cli's one red is TestEveryRouteHasACommandOrIsNamed
  ("GET /api/context/reply has no command"), #5026, red on main.

Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
  changes (agent, autostart, daemon, gateway, library, proc, provider,
  sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
  library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
  batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
  internal/cli TestEveryRouteHasACommandOrIsNamed (GET
  /api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
  proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
  (#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
  pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
  tui ok; library and agent red in the same tests as on origin/main
  f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
  common with the batch) and run again at the pushed tree: gofmt -l
  nothing, go build ./... and go vet ./... ok; go test -tags nogui
  sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
  library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
  cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
  the tag and any red is filed).
2026-11-03 20:38:11 +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 2a19043afc library: a skill's files are read as Markdown and edited in the page (refeccd)
refeccd on Discord kept skills in ~/.agents/skills, handed them over to
magpie ("let magpie manage"), and then had nowhere to edit them: the
Library's skill view showed SKILL.md as raw text with no way to change
it. There never was an edit path; this adds one.

- GET /api/library/skill takes `file` and answers library.ReadSkillFile:
  the file (SKILL.md by default), its text, the skill's folder and its
  text files (UTF-8, no NUL, up to 1 MB each, 200 listed, SKILL.md first;
  links, hidden folders and what installing writes left out).
- POST /api/library/skills/save {name, file, text, was} is
  library.SaveSkillFile, through change(): it writes only a regular
  file already in the skill's library folder (no .., no absolute path,
  no link, no folder that is a link out of the skill, nothing under
  node_modules/.venv/…), refuses when the file no longer holds `was`
  (the text the page opened), keeps CRLF line ends, and writes with
  edit.WriteAtomic. The sync after it reaches every agent: a linked
  one reads the library's folder, a copy is made again. A copy edited in
  an agent before the save is older, so takeEdits sets it aside in the
  backups. A GitHub skill saved here reads as Changed here, so an update
  asks first.
- The page (viewSkill in plugins/library/client.js) draws a Markdown
  file with the Plugins page's own renderer (plugins.js exports it as
  window.mdRender, 27 bytes of core script) and its front matter as
  rows; other files as text. Edit swaps in a text box; Save or ⌘S/Ctrl+S
  sends it; Cancel asks when there are changes. Other files are the
  app's menu under the name (no native select). New code is in the
  library plugin, so the core script budget is not raised.
- SkillText is gone (its only caller was the route). One new string, in
  all five languages. docs/subsystems/library.md says all this.

Run on mote at the change rebased on 9335e23d3:
- go test -count=1 -timeout 45m ./internal/library ./internal/gui
  ./internal/cli: library ok. gui: TestCoreScriptBudget passes; the only
  red is TestMainWindowCorners/macOS_26_SDK (#3949, mote's macOS 27).
  cli: the only red is TestEveryRouteHasACommandOrIsNamed on GET
  /api/context/reply (#5026, from 0872bc2a0). Both are red on main and
  filed.
- GOOS=linux and GOOS=windows go vet -tags nogui on the three packages;
  gofmt -l clean.
- skill-edit.test.cjs: 22/22 (chromium and webkit; en, zh, zh-TW, ja,
  de; 860px and 400px). It checks the drawn Markdown and front matter,
  no sideways scroll, ⌘S posting the exact body with `was`, the status,
  the file menu, Cancel sending nothing, Save on a second file, no click
  scrolling the page, no left-border stripe or gradient. i18n-keys ok.
- Whole GUI suite (a new API call), on the Linux box (wsl-run; mote had
  two other full suites): ~4460 of its results in at the push, not
  finished. Its reds are all WebKit and none is in a file this touches.
  The ones near it, run alone at this change and at origin/main
  bc10a6198: click-scroll, found-skill-pick-remove and account-eye fail
  the same on both (#4385, #4097/#5013, #4244).

Again at the pushed head (rebased on b967b1620; its commits change
app.js and the core budget), on the Linux box: TestCoreScriptBudget ok,
go test ./internal/library ok, gofmt -l clean, skill-edit.test.cjs and
i18n-keys 26/26.

Broken by hand: without the `was` check, without the linked-folder check
and without the CRLF handling, TestSkillFileSaveRefusesAChangedFile,
TestSkillFileStaysInTheSkill and TestSkillFileKeepsLineEnds each went red.
skill-edit.test.cjs on the old assets: 0/11 in chromium (.lib-mdview
never appears).

Not tried: refeccd's own skills (the fixture is a made-up handover from
~/.agents/skills, with a copy agent and a link agent); the real app
window (the GUI tests fake the API); the TUI and CLI, which have no
editor; making, renaming or removing a file from the page; Windows.
2026-11-03 16:33:03 +08:00
yetone b295d11965 serve, update: one magpie works the gateway; the service waits, the copy an update left stops (#4938)
ox01024's #4938, Bug 2. Two magpies did the gateway's work at once on a
Mac:

- launchd's com.yetone.magpie.serve ran `magpie serve` beside the app.
  It ran startUp (plugin Settle/Refresh, FoldCopies, Hold, the agent
  moves), the plugin host and every account's model fetch, then failed
  to bind, exited 1 and was started again 5s later: 6,035 times in two
  days, a 279MB serve.log, and logins.json.lock held against the app's
  requests until they went 504.
- The copy an update left (.magpie-update/old) handed the socket over,
  hid, and lived on ~3h, its loops writing beside the new one.

What changed:

- cli: `magpie serve` (no --web) checks codexrelay.Leave,
  gateway.ServedBy and gateway.Taken before startUp, as the app's
  serveGatewayLocked does. While the port is held it prints one line
  and looks again every 15s, doing nothing else. Once the port is free
  it serves (serve_wait.go). It waits rather than exiting 0: under
  KeepAlive SuccessfulExit:false a clean exit would leave no service
  after the app quits.
- gui: after a handover the old magpie's loops end with backendCtx:
  - library.KeepLinked (now takes a ctx),
  - provider.WatchQuotas,
  - the menu bar usage loop,
  - the updater's check/auto-restart loop.
  lighten lets its hidden webviews go as lightweight mode does, so
  their polls stop. quitBy exits it at handedOffDrain + 3m whatever
  holds its quit up (gateway.HandedOffDrain getter; exitNow stubbable).
- docs/subsystems/gui-shell.md says both.

Run at the pushed head on mote (mote-run):
- gofmt -l internal/: nothing. go vet ./internal/{cli,gui,library,gateway};
  GOOS=linux go vet -tags nogui and GOOS=windows go vet of the same: ok.
- go test -count=1 -timeout 45m ./internal/cli ./internal/library
  ./internal/gui ./internal/gateway at bf05291e2 + this: cli and
  library ok. Two reds, both already filed:
  - gui TestMainWindowCorners/macOS_26_SDK (#3949). It is red the same
    on origin/main 443e53d6b, run alone.
  - gateway TestCodexPoolSaysTheClientsVersion (#4807). It is red only
    in the full package run, and passes alone 5 of 5 at this head.
- After rebasing on 8819beeb0, on that head: the vets above; cli and
  library in full, ok; gui and gateway with -run for handover, handoff
  and lightweight, ok.
- Sandbox HOME on mote, a fake app answering / as magpie 0.1.2770 on a
  private port (3593), `magpie serve` built from this tree beside it:
  alive after 8s at 0% CPU, nothing written under HOME, one standby
  line. 20s after the fake quit it served the port. The same with the
  old wait call removed: "magpie: listen tcp 127.0.0.1:3593: bind:
  address already in use", exit, and plugins.yml and lock files written
  first.

Broken by hand, each red:
- No wait before startUp: TestServeWaitsForTheGatewayBeforeStartingUp
  ("ran the start-up moves while another magpie served the gateway").
- KeepLinked ignoring its ctx: TestKeepLinkedEndsWithItsContext
  ("went on after its context ended").
- No quitBy in handover.run: TestRestartHandsTheGatewayOver ("has no
  deadline to quit by").

Not tried:
- A real launchd service beside the real app, and a real update
  handover on a Mac. Neither was run: no live app or launchd.
- The lighten change (needs Wails webviews) has no test.
- Not done here: serve.log rotation, `magpie daemon install` beside a
  running app (#4887), the old copy's appPage port, and Bug 1 and
  Bug 3 (ggbdpq has Bug 1).

cdredfox on Discord reports ~270% CPU after v0.1.2770. That fits this,
but it is not confirmed as their cause.
2026-11-03 11:16:02 +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
yetone 58a833f254 mcp router: initialize says what each server behind it is and does
packinggoodsllc_07668 (Discord) runs magpies that only share MCP servers,
and an agent given several routers knew each by its name alone. A
router's initialize instructions now describe what it holds, built from
what the servers themselves say; no model writes any of it.

- After the "Tools of …" first line (and the router's name sentence when
  it has one), a line per server: "- name (its serverInfo.title): what it
  is for. Tools: tool (first clause of its description), …". The tools
  the Library turned off are left out; another router's "[name] " prefix
  is dropped. A line too long for its share says tools by name, then as
  many as fit and "and N more". The whole is at most 2000 characters
  (hubSayMax), the closing text kept whole.
- What a server is for: the market's words as before, else its
  serverInfo.description, else its instructions' first line (saysOf).
  Another magpie's "Tools of a (…), b." is said with "Tools of" once.
- What a server said and listed is kept in settings.Dir()/
  mcp-hub-servers.json (not the synced library folder), keyed by name and
  a hash of hubKey, written via temp+rename only on change, pruned of
  servers gone. A router started again describes its servers without
  starting any; one added or edited since is listed by initialize, which
  waits up to 5s for it.
- Pi's hub description (hubAbouts) uses the server's own words too.

Agents, from their installed source (research, not run): Claude Code
shows instructions (4096 chars), Codex as the namespace description,
OpenCode, Gemini CLI (trusted folders only), Qwen Code, Pi (first line in
the prompt); Kimi CLI ignores them. None shows serverInfo.title.

Run at this tree (mote):
- go test -tags nogui ./internal/library: ok (116s)
- go test ./internal/gateway -run 'Hub|MCP|Roots|OversizedBody|
  ReadOnlyKeyEveryRoute|FileURI|ImageModel': ok
- GOOS=linux and GOOS=windows go vet internal/gateway internal/library;
  go vet internal/gui internal/cli; go build ./...; gofmt -l: clean
- New: TestHubInstructionsDescribeServers, TestHubDescriptionsOutlive
  ARestart (library); TestHubAboutBounded, TestHubServerLine,
  TestHubClauseBrackets, TestHubLineOfARouter (gateway).
- Red on the old code: TestHubInstructionsDescribeServers at c9af34446
  fails ("Tools of la, notes." and nothing more).
- Broken by hand, each red: noteCard not writing the file (restart test),
  the DisabledTools filter removed, saysOf returning nothing.
- Real use: two magpie serve builds of this tree in sandbox HOMEs on
  mote (127.0.0.1:3561, :3562), A serving a stdio notes server, B with A's
  /mcp/magpie/hub as server "la". B's initialize said
  "- la (Magpie MCP hub): Tools of notes (…). Tools: notes__add_note (Add
  a note to the notebook), notes__search_notes (…)."; B restarted with A
  down said the same from the file.

Not tried: a real agent reading the new text (Claude Code, Codex,
OpenCode etc. were read in source only); a router with dozens of real
servers; Windows and Linux runs (the change has no OS-specific code).
2026-11-02 18:37:57 +08:00
yetone b3eb26400c library: a ${NAME} only the login shell exports reaches the MCP server magpie starts or calls
Cyrus on Discord: once a Library MCP server's token was written as
${NAME}, the Library listed no tools for it. magpie expanded the
reference from its own environment only, and a magpie opened from the
Finder or the Dock has none of the profile's variables, so a token
exported in .zshrc was "not set" for the tool-list check, and the
router (dialHub) and Codex's run through the gateway (specOf) didn't
start the server either.

expandAll, the one place all three expand a reference, now takes a
variable magpie's environment hasn't from proc.LoginVars: what the
login shell (and fish or nushell, as shellEnv asks them) exports, read
through /bin/sh as the existing PATH probe is, each answer kept a
minute. On Windows it reads the registry's user then machine variables
(one set with setx after magpie started). The value is only in memory
at call time: never set in magpie's environment, never written to
library.json or an agent's file, never logged. A variable set nowhere
is still novar, naming it ("NAME not set" on the page, unchanged). The
library only documents ${NAME} (no ${NAME:-default}), so nothing else
is parsed.

Run at this head (90d554db1 rebased on 46a13f837), on mote:
- go test -tags nogui ./internal/proc ./internal/library: ok
- GOOS=linux and GOOS=windows go vet ./internal/proc ./internal/library: ok
- gofmt -l: clean
- wsl-run (magpie-desktop): TestLoginVars, TestEnvRefs*, TestCheckStdio,
  TestCheckHTTP, TestShellEnv*, TestLoginEnv*: ok
- ./internal/cli before the rebase: only TestEveryRouteHasACommandOrIsNamed
  red, POST /api/usage/checkin-account, already filed as #4826.
- By hand on mote: LoginVars with the real /bin/zsh (.zshrc) and
  /bin/bash (.bash_profile) in a temp HOME read the exported token and
  left an unset name unset.

TestEnvRefsFromLoginShell: a fake login shell exports CYRUS_TOKEN,
magpie's environment hasn't it; a fake stdio server that exits without
the right token and an http one that answers 401 without it are each
checked (ok, with tools) and dialled by the router, Codex's run spec has
the value, a variable set nowhere is novar, and after SaveServer, a
check and a Sync no file in the sandbox HOME holds the token.
TestLoginVars: exported, exported-empty, unexported and unset names, bad
names never asked, the minute's cache and a new SHELL asked again.

Broken by hand: loginVars returning nothing made TestEnvRefsFromLoginShell
red (command and url both novar CYRUS_TOKEN, the reporter's case);
parseNamed ignoring the set flag made TestLoginVars red.

Not tried: the Windows registry read (compiled by vet only, no run on
xiaomi-gpu); a real Finder-launched magpie.app with a real token; the
GUI suite (no GUI file changed).
2026-11-02 11:01:51 +08:00
yetone 1ad8b20c7a library: the sweep of ~/.agents/skills leaves the user's own entries (#4379)
e938a4f13's sweepShared removes magpie's entries from the shared folder
once no agent whose folder it is gives them. Its tests cover magpie's
links only. TestKimiSweepLeavesTheUsersOwnSharedSkills puts the user's
own folder, a folder by the name of a library skill Kimi Code is given
(pdf), and the user's own link to a folder elsewhere into a sandbox
HOME's ~/.agents/skills, syncs twice, and checks each is still there with
its SKILL.md and link target unchanged. A skill given to Kimi Code and
Codex (both read the shared folder besides their own) lands in each
one's own folder, not the shared one. Test only; no code change.

Run on mote: go test -tags nogui ./internal/library/ -run
'Kimi|Shared|Skill' ok. Broken by hand: the sweep without its ours()
check deletes all three of the user's entries (the new test red);
without the sweep step TestKimiOldSharedEntrySwept is red; Kimi Code's
folder put back to ~/.agents/skills turns all three Kimi tests red.
Not tried: a real Kimi Code 2.x reading the folder.
2026-11-02 07:40:21 +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
yetone 50be0751ff library: a skill lock entry doesn't take over a folder of the user's own
51be9afb0 (ggbdpq, #4645) lets a skill the skills CLI installed be
updated from where ~/.agents/.skill-lock.json says it came from. The
lock is matched by name and by the folder's write time, and lockOrigin
asked nothing about the skill's own source. A skill the user installed
from a folder of their own, under a name the lock also has (grill-me
from their own skills folder and a lock entry for mattpocock/skills),
showed GitHub as its origin, and an update replaced it with the
repository's copy.

lockOrigin now follows lockRepo's grouping rule: it is the origin only
of a skill with no source, or one whose folder is in ~/.agents/skills.

Run (mote, at this commit's tree): go test -tags nogui ./internal/library
ok, with TestSkillLockOriginUpdates, TestSkillLockOriginStale and the
new TestSkillLockOriginLeavesUsersFolder.
Broken by hand: without the guard, TestSkillLockOriginLeavesUsersFolder
is red: "origin https://github.com/mattpocock/skills" and, after the
update, the source is the GitHub tree, not the user's folder.
Not tried: the skills CLI itself; the lock is written by hand in the test.
2026-11-02 05:38:11 +08:00
ggbdpq c57ac416d3 fix(library): MCP writes to Claude Code's .claude.json take its save lock (#4747)
What changed: the Library gave Claude Code its MCP servers by reading
~/.claude.json (or $CLAUDE_CONFIG_DIR's) and writing it back with no
lock held, while Claude Code saves the same file often (project state,
tips, usage counters) under a lock of its own, <the file's real
path>.lock: a save of its own between the Library's read and write was
lost. The lock helpers move out of internal/provider into a small
claudelock package (the mkdir lock Claude Code 2.1.316 takes, stale
after 10s for this file), putClaudeLogin keeps its #4532 behavior
through wrappers, and the Library's mcpFile.putEntry and mcpFile.del
take <file>.lock around the .claude.json read-modify-write: they wait
while Claude Code holds it, take over one left stale, and fail the
server's write with nothing changed when it holds one past 20s. A WSL
distro's copy is left as it was: the Claude Code there saves under a
lock in the distro's own files.

Run (mote, -tags nogui):
- TestClaudeJSONMCPWaitsForClaudeCodesLock and
  TestClaudeJSONMCPTakesAStaleLock (internal/library): red on the old
  code (saved while Claude Code held the lock; a stale lock left
  behind), green now.
- go test ./internal/library ./internal/provider -tags nogui: both
  packages green, the #4532 lock tests among them (TestClaudeSwitch…
  refresh/legacy/config, stale takeover, held past the wait).
- race on the lock tests of both packages; go vet on the three touched
  packages for darwin, linux and windows; gofmt clean; go build -tags
  nogui for darwin, linux and windows.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 05:38:11 +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 97e66bce26 library: an uninstalled Kiro CLI is listed to take back what it was given (#4769)
b4c67477f lists Kiro CLI in apps only while kiro-cli is found. held, which
lists an uninstalled agent on the rows of what magpie gave it so that can
be unticked and taken out of its folder (TestGoneAgentListedToTakeOut),
walks apps and agent.All, so once kiro-cli was uninstalled magpie's
entries stayed in ~/.kiro/settings/mcp.json, ~/.kiro/skills and the
steering file with no row to take them out.

Kiro CLI is now always in apps, with Bin the found path or "kiro-cli":
Detected (binAt) still decides whether it is a target, so ~/.kiro alone
(Kiro Crew, the Kiro IDE) makes nothing a target, as before. Takes tells
an app that isn't installed so, rather than recording it and then giving
it nothing (the #2254 shape); before, an uninstalled Kiro CLI got
"unknown agent".

Run (mote, mote-run -tags nogui):
- go test -count=1 -run 'Kiro|Gone|Takes|Held|Target' ./internal/library: ok
- go test -count=1 ./internal/library (whole package, before this
  change, with b4c67477f): ok 156s
- Broken by hand: apps() back to listing Kiro only when found ->
  TestKiroCLIUninstalledHeld red ("isn't listed as gone: <nil>", Takes
  "unknown agent"); Takes' new check off -> red (Takes returns kiro-cli
  for an uninstalled one).
- gofmt -l: clean.
Not tried: a real kiro-cli uninstall (the user's live ~/.kiro untouched).
2026-11-01 22:32:41 +08:00
ggbdpq eb469c70a9 fix(library): Kiro CLI gets the Library's skills, MCP servers and instructions (#4769)
The library's targets are agent.All plus apps, and apps held Claude
Desktop alone: Kiro CLI, which magpie wires no model into and the Agents
page rightly leaves alone, could be given none of the three, and a user
of it copied skills, servers and instructions into ~/.kiro by hand
(#4769, ump45nose).

Kiro CLI is an app now, found by the kiro-cli program alone — PATH,
~/.local/bin, Kiro CLI.app, where provider.KiroExecutable already
looked — never by ~/.kiro, which Kiro Crew and the Kiro IDE keep too. It
reads ~/.kiro/skills, ~/.kiro/settings/mcp.json and
~/.kiro/steering/AGENTS.md, its global steering's AGENTS.md being always
included (kiro.dev/docs). Its mcp.json has a format of its own: entries
of command/args/env or url/headers, no type written, the user's fields
(disabled, autoApprove, disabledTools, oauth) kept, no SSE named — a url
is streamable HTTP, the docs give no way to say SSE — and a ${NAME} in
headers or env passed through, Kiro expanding those its Mcp Approved Env
Vars approves.

What a kiro-cli in a WSL distro is given, and a project's .kiro, stays
out: apps are this machine's, and per-tool off stays the user's.

Run: go test -tags nogui ./internal/library (ok; TestKiroCLITarget,
TestKiroCLINotByItsFolder and TestKiroMCP new); go vet (darwin, linux,
windows; nogui) and gofmt -l clean on the package; builds for all three
platforms.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:32:41 +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 6dc94f57aa library: the MCP market offers the registry's 478 most starred servers, and 100 a search
The owner: both markets have too little in them. With nothing searched,
the MCP market offered only its 31 featured servers. A search asked the
MCP Registry and kept at most 30 of its results.

What changed:
- market_servers.json is a snapshot of the registry, crawled 2026-11-01:
  54,048 latest entries and the GitHub stars of their 27,816 repositories.
  It keeps the 500 most starred servers that can be installed: an https
  remote, or an npm/pypi/oci stdio package with no required named argument
  left blank. At most 3 come from one repository. Smithery's re-hosts,
  inactive entries and entries with no description are left out.
- A name has to belong to the repository it points to. io.github.<owner>/
  matches the repository's owner, and a domain name's main label is in the
  repository's path. That drops name squatters pointing at famous repos
  (IncorporatedPartners → paperclip, secforge → ChromeDevTools, ai.com.mcp
  → agentskills). Past that, star order is the only rule.
- After the featured servers and their copies, 478 remain. Browsing offers
  featured, then these by stars: 509 in all. Show more pages them 60 at a
  time (df0320156).
- A search keeps up to 100 of the registry's results, not 30. Popular
  servers that match the words come after them, and for an address search
  they come before the registry's. A server is offered once.
- A popular server installs by its id with no registry call (marketServer),
  and its icon is offered like a featured one.

Run at f79c0994e (origin/main ace58117a plus this), on mote:
- gofmt -l internal/library: clean. go vet ./internal/library: ok.
- go test -count=1 ./internal/library: ok (133s); ./internal/gui: ok.
- GUI: i18n-keys, market-*, library-mcp-*, search-mcp-library,
  images-library-way and vision-mcp-library: 280 of 284.
  - The 4 reds are search-mcp-library's WebKit 420px "Turn on the
    Library" cases, TimeoutError, at load 145 to 220, a different language
    each run. This change touches no GUI asset, so the page is main's.
  - They are #4756 (comment with this run). The same file passed 62/62 at
    77e853588. images-library-way and vision-mcp-library pass alone.

Broken by hand, each red in TestMarketServersPopular:
- no popular servers when browsing;
- the cap back at 30;
- a popular server not installable by id;
- popular matches put before the registry's in a word search;
- featured not seeded into the snapshot's dedupe (caught by the
  marketServer("io.github.feat/copy") check);
- a popular icon not offered.

Real servers:
- the tldraw and frontend-checklist remotes answered initialize;
- worldmonitor answered 401 (it needs a sign-in);
- on mote, npx -y @agent-infra/mcp-server-commands answered initialize
  as "Run Commands".

Not tried:
- installing a popular server from the GUI in the real app;
- a fresh crawl. Stars are a snapshot, and crawl.py/build.py are not in
  the repo.
2026-11-01 17:26:12 +08:00
yetone df0320156b library: the skill market offers every skill skills.sh lists, 60 at a time
The owner: the Library's markets had too little in them ("这两个市场的
东西都太少了"). The skill market showed at most 60, four a repository.

Now it offers every skill on skills.sh's front page (its 600 most
installed), then each one on its trending page that isn't there, with no
count of installs: trending counts recent installs only, so the card
shows none rather than a wrong one. A repository's first skill comes
before anyone's second, so the first page still isn't one author's, and
nothing is cut. A search asks skills.sh for 200, not 40. The snapshot
magpie ships with has the same 772.

The page shows 60 cards and a "Show more (N left)" button that adds 60
under them; what was shown stays where it is, and skills' about is asked
for the cards shown only. MCP's list pages the same way. Strings in zh,
zh-TW, ja and de.

Run on mote at 0de6f2e57 (origin/main 1d8ded3ec plus this; pushed on 7c712847b, an agent row only): go test
./internal/library ok, gofmt clean, and the GUI files i18n-keys, market-*
and every-skill in both engines, 88/88. Main had changed internal/library
twice since the base below (399385307, 655d23f79).

At 073b3dfbb (origin/main c991733dc plus this):
- gofmt -l internal/library internal/gui: clean; go vet ./internal/library
- go test ./internal/library: ok
- go test -skip TestMainWindowCorners ./internal/gui: ok. That test is
  red on origin/main too (#3949).
- GUI: i18n-keys, market-*, every-skill in Chromium and WebKit: 88/88.
  i18n-keys was red at first, from a Go module cache an earlier run of
  mine had left in mote's copy of the tree; with it removed, 4/4.
- At 098f28929 (origin/main 5dfbca627 plus this), the wider set:
  i18n-keys, market-*, library-*, skeleton-bird, search-mcp-library,
  skill-install-agents-all, every-skill in both engines, 1128/1128.
  Between that base and this one, main changed only internal/library's
  MCP hub, browser and gateway code; none of it is in these pages.
- An earlier run of the same files at 647323409 plus this, with mote at
  load ~130, had 6 reds. All three files pass alone, both on main and on
  this change (110/110), and each has an issue: #4756
  (search-mcp-library), #4483 (library-mcp-hub) and #4125 (browser
  launch).

Broken by hand, red each time: the 4-per-repository cap back
(TestMarketSkillsAll), search limit 40, no trending page, and installs
shown for a trending skill (market-more.test.cjs). Removing the button
before the new cards are put in still passes, because the click scroll
keeper holds the reader's card. So nothing claims that order matters.

Not tried: the real skills.sh from the app. fetchPopular's parsing is the
one it had; the snapshot was made from the live pages today.
2026-11-01 17:00:04 +08:00