Commit Graph
240 Commits
Author SHA1 Message Date
yetone b78b1de003 library: magpie-image is behind the MCP hub, saving into the calling agent's project
magpie-image was the one MCP server the hub left out, because it saves
what it makes on disk and needs to know whose project that is. The hub
now serves its tools like any other server's and tells it where the
caller works:

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

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

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

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

Rebased once more onto 2570efb5f, which changed library-mcp-hub,
list-sort, mcp-hub-direct and gateway-routing.md. Run at the pushed
head: go build; gateway, library, cli and imagemcp tests ok; the GUI
budget tests ok; on xiaomi-gpu i18n-keys, mcp-hub-direct,
library-mcp-hub and list-sort, 51 of 54. The three reds were WebKit
420px library-mcp-hub cases with no Connect sheet after a reload.
origin/main d77da5bff goes red the same way (de 420px, 9 of 11). In a
second run of library-mcp-hub on WebKit at this head, 11 of 11 passed.
Filed as #4483.
Not tried: Codex outside a git repo without consent (it saves to
~/Pictures/Magpie, #4435); agents on Windows and in WSL with real use.
2026-10-31 02:49:08 +08:00
ggbdpq 50816ce024 library: turning RTK off matches the hook Claude's settings actually holds (#2879)
What changed: taking RTK out of Claude Code now drops its hook entries
from hooks.PostToolUse and hooks.SessionStart in ~/.claude/settings.json
beside hooks.PreToolUse, matching the same "rtk hook claude" mark.

Why: magpie says Claude Code has RTK by searching the settings file
whole for "rtk hook claude", but its remover only looked under
hooks.PreToolUse. rtk 1.0.1's installer writes that command under
hooks.PostToolUse too, when the user's rtk pipeline has after_tool rules
(rtk:posthook; src/hooks/init/claude.rs), and rtk's own uninstaller
sweeps PreToolUse, PostToolUse and SessionStart alike. With an entry
under another event, switching RTK off in the Library removed the
PreToolUse entry, found the command still in the file, and failed with
"rtk's hook is still in Claude" — the reported bug: the row stayed on
and the hook had to be taken out by hand. The user's own hooks under
those events are kept, as the PreToolUse ones already were.

Run: go test ./internal/library/ (ok, 75.6s); the new
TestRTKRemoveClaudeOtherEvents fails on the base with "rtk's hook is
still in Claude Code" and passes with the fix; gofmt -l clean; go vet
clean on darwin, linux and windows; the package builds on all three.

Review (magpie): checked against rtk v1.0.1's own claude.rs, which
writes and sweeps PreToolUse, PostToolUse and SessionStart; the other
agents' single key is unchanged. Run on the Mac mini: go test
./internal/library -count=1 ok; TestRTK* on the Windows box ok. Broken
by hand: rtk.go at the base - TestRTKRemoveClaudeOtherEvents red
("rtk's hook is still in Claude Code"). Not tried: the reporter's ask
to roll the switch back in the UI when a removal fails.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-31 02:00:10 +08:00
yetone b889ffe813 library: a server can stay each agent's own entry with the MCP hub on (#4382)
cuipengcx90's #4382, Option A's first step (nifengfanpan asked on
Discord): with the MCP hub on, every Library server went behind magpie's
one entry, so a server that reads its project from the folder it starts
in, or keeps a session's state, resolved the wrong repository or shared
state across agents. A server now has a hub policy, Server.Hub ("hub" in
library.json): "" (shared, the default, so nothing changes for existing
users; "shared" is saved as "") or "direct". A direct server is left out
of the hub through inHub, the test that already keeps magpie's own image
server out, so each agent given it keeps its own entry written as with
the hub off, beside the hub's entry for the rest. An agent whose every
server is direct gets no hub entry. The hub neither lists nor runs a
direct server, at /mcp/magpie/hub either, and hubPrune ends one it held.
Switching goes through change(), so the agents are written again at once
and the entry from the other policy is removed. An unknown policy is an
error.

- GUI: with the hub on, the server editor has a "Through the MCP hub"
  switch (role=switch, not a <select>; not shown with the hub off or for
  the image server), a direct server's row has a "Not through the hub"
  tag, and the hub's line and the Connect sheet name the direct servers
  with the image server as given directly. Strings are in zh, zh-TW, ja
  and de ("MCP 聚合" as the core uses it).
- CLI: magpie library mcp hub <name> shared|direct (ServerHub), and
  magpie library marks a direct server.
- TUI: an edit keeps the policy.
- Not done: Option B (per-roots/project backends behind the hub, keying
  hubPool by roots). It is left for later; #4382 stays open for it.

Run:
- TestHubDirectServer (internal/library) and the extended
  TestLibraryMCPHub (internal/cli) on mote. Broken by hand: inHub back to
  !isSelf(s) makes TestHubDirectServer red ("codex with the hub on:
  [magpie], want [index magpie]").
- Real configs in a sandbox HOME on mote (fake claude on PATH, the real
  binary built from this tree): mcp add index + web for claude and codex,
  hub on, hub index direct, shared, then both direct. The direct index
  entry was in .claude.json and .codex/config.toml beside magpie's; with
  every server direct both files were byte-for-byte as with the hub off
  (json.tool diff and diff); shared again removed the index entry.
- Full Go suite (-tags nogui -timeout 45m ./...) on mote at this tree
  rebased on origin/main 72ed121fd: 81 packages ok. Before the rebase
  the only red was TestQuotaSpanCarriesEveryWindowField (#4457, fixed by
  ccbefe2a2). GOOS=linux and GOOS=windows go vet clean, gofmt clean.
- GUI on WSL (magpie-desktop; mote's GUI is broken, #4125), both engines,
  every language: the new mcp-hub-direct.test.cjs (1100 and 390 wide,
  hub on and off), library-mcp-hub, mcp-local-server, i18n-keys: 88 pass.
  Broken by hand: not sending hub in the save makes mcp-hub-direct red
  (11 of 11 in chromium).
- The 54 library/mcp/i18n GUI files at --test-concurrency=4 on WSL at load
  ~160: 978 of 988 pass. Red: library-chip-fan (webkit, fan positions),
  library-mcp-tools (chromium ja 420, "the click scrolled the page") and
  mcp-oauth-app (chromium de 390). None of them touch the hub switch or
  the editor's new field. They are being rerun alone, here and on
  origin/main, after this push; a red that only this change has is fixed
  next, and a red on main too is filed.

Not tried: the whole GUI suite (1028 files); a real cwd-sensitive
server in a real agent session; the live app window.
2026-10-31 00:34:45 +08:00
yetone 2f65a33aaf library: a tools plugin is a Library server of its own, in the MCP hub (Search1API)
chenxiang0010 (Discord #general) asked for a tools plugin's tools, Search1API's
(@magpie-community/tools-search1api), to be in magpie's aggregated MCP server.
Until now plugin tools were served only at /mcp/magpie/tools, wired by hand;
the hub listed Library servers only.

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

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

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

Not tried: a signed-in Search1API account (none here), so no search went
through; a real agent (Claude Code, Codex) calling the hub; WSL/remote
agents through another address (unit test only); the GUI's Library page
showing the server (no GUI file changed, GUI suite not run).
2026-10-30 22:33:25 +08:00
yetone 48edbcb674 library: RTK covers Droid, and lists Qoder, Cline and Kimi Code with why
lml0664 on Discord: Library > RTK offered a fixed few agents, even on the
latest magpie. RTK 1.1.0 (rtk-ai/rtk, Latest, 2026-10-25) has `rtk init`
agents claude, cursor, trae, windsurf, cline, kilocode, antigravity, kimi,
pi, hermes, droid, vibe, omp, plus --codex/--gemini/--opencode/--copilot.
Every one with a global hook that magpie has an agent for was already on
the page except Factory's Droid, which is added now:

- droid: rtk's own `rtk init -g --agent droid`, given Droid's folder as
  FACTORY_HOME_OVERRIDE (magpie's droid agent honours it). rtk writes its
  Execute group (`rtk hook droid`) into the root hooks.json, or into
  settings.json's hooks.PreToolUse when Droid's hooks already live there
  (src/hooks/init/droid.rs), so ReadRTK and switching off look at all
  three files rtk may use (hooks.json, hooks/hooks.json, settings.json)
  and leave the user's own hooks and settings. rtk before 0.44 has no
  Droid agent, so it is blocked with "needs RTK 0.44 or newer".
- dropHook no longer slices key[:-1] for a top-level key (hooks.json's
  "PreToolUse"); before, it would have panicked.

Listed with the switch off and their own reason (rtkNoHook and the page's
rtkNoHookWhy, in zh, zh-TW, ja and de too):
- Qoder, Qoder CN: rtk 1.1.0 has no Qoder agent (`--agent qoder` is an
  invalid value), rtk-ai/rtk#1327 (PR #1721 open).
- Cline: `rtk init --agent cline` only writes a .clinerules in the
  current project asking the model to type rtk, no hook (#3841).
- Kimi Code: Kimi's hooks can't rewrite a command; rtk writes only one
  project's AGENTS.md and refuses -g ("Kimi AI is project-scoped").
RTK's Trae, Windsurf, Kilo Code and Mistral Vibe have no magpie agent.

Run:
- go test -tags nogui ./internal/library -run TestRTK on mote: ok
  (TestRTKDroid home/override, TestRTKDroidSettingsHooks,
  TestRTKNoHookQoderClineKimi new, sandbox HOME, fake rtk).
- Red on old code: rtk.go at HEAD^ -> TestRTKDroid, ...SettingsHooks and
  ...NoHookQoderClineKimi red. Broken by hand: version gate at 0.43, the
  settings.json entry dropped -> red; FACTORY_HOME_OVERRIDE not passed ->
  TestRTKDroid/home red. client.js at HEAD^ -> library-rtk-nohook red
  (Qoder's reason was the generic one).
- Real rtk 1.1.0 (release tarball, sha256 checked against checksums.txt)
  on mote in a sandbox HOME through SetRTK/ReadRTK: plain ~/.factory,
  settings.json with the user's own Execute hook (kept, rtk's taken out)
  and FACTORY_HOME_OVERRIDE: on, seen on, off, seen off. Real rtk also
  refuses --agent qoder and -g --agent kimi, and cline writes .clinerules.
- Full suite on mote, go test -count=1 -timeout 45m ./...: 80 packages
  ok; internal/gui red only in its 10 real-window AppKit tests (#4125).
- GOOS=linux and GOOS=windows go vet ./internal/library: ok. gofmt clean.
- GUI on the WSL box (mote's browsers crash at launch, #4125):
  library-rtk-nohook (chromium+webkit, en+zh) and i18n-keys 10/10; all 45
  library-*.test.cjs files 810/824, the 14 reds (library-chip-fan webkit,
  library-items webkit, library-mcp-tools chromium ja 420) are the same
  at origin/main cf9ea977c and are #4120.

Not tried: a real Droid session running the hook; the whole GUI suite
(only the Library files); Windows (Droid's folder there is the same code
path; no run).
2026-10-30 20:03:32 +08:00
JoeyWu-tech 497100488a provider, library: a .git is a repository only when git takes it for one (#3675)
TestPluginToldWhereTheAgentWorks was red on any machine with an empty
.git above its temp folder. GitOnDisk took the first .git it met going
up as a repository, and on this box /tmp/.git is an empty folder (owned
by nobody), so every folder under /tmp read "yes". git passes such a
folder over and goes on up: git rev-parse under it says "not a git
repository".

GitOnDisk now reads each .git on the way as git's own search does
(repo_discovery_find_dir in git 2.56's setup.c), through GitAt:
- A folder counts when git takes it for a repository (is_git_directory):
  a HEAD git takes (a link into refs/, "ref: refs/...", or a commit's
  id), and objects and refs folders, in the folder its commondir names
  for a linked worktree. Any other folder, an empty one say, is passed
  over and the walk goes on up.
- A file counts when it is "gitdir: <folder>" naming such a folder,
  relative to the .git's own folder (a linked worktree's, a
  submodule's). Any other file, one over git's 1 MB, or one that is
  neither file nor folder is "no": git stops there with "not a git
  repository" (a worktree whose repository has gone) or "invalid
  gitfile format". (git 2.34 passed a .git that is neither file nor
  folder over; 2.55 and 2.56, CI's, stop at it.)
- A .git it can't read is unknown, and the header is left off. git
  passes such a folder over and stops at such a file, but either way
  it can't tell an empty .git from a repository it isn't let into
  (another user's, through a shared magpie), and a failed read is
  unknown here.
A bare repository kept as a folder's .git (git init --bare .git) is
still "yes": git finds one there, though no work tree. Not mirrored:
the filesystem boundary, GIT_CEILING_DIRECTORIES and safe.directory's
ownership check. Cost: the same one stat per folder on the way up; at
a .git, a read of HEAD (255 bytes at most) and stats of commondir,
objects and refs.

What a user sees: a request to a plugin provider from an agent that
doesn't say whether its folder is a repository (Codex, Pi) was told
"yes" for a project under a stray empty .git, under a worktree whose
repository was deleted, or under a .git file that names nothing. The
community ZCode plugin then tells the model "- <git label>: yes" and
Command Code's sends isGitRepo: true, so the model may run git commands
that fail with "not a git repository". They are now told "no", and
with a .git on the way magpie can't read, nothing (ZCode's plugin
leaves the line out, Command Code's sends false). Claude Code's and
OpenCode's requests say it themselves and are passed on as they say it,
so nothing changes for them; Claude Code 2.1.310's own check takes any
.git, an empty one too.

The only caller of GitOnDisk is tellWorkPlace (workdir.go), which needs
no change. The library's skill groups had the same first-.git walk:
gitRepoOf took the first .git within four folders of a linked skill for
its checkout, so an empty one between a skill and its clone left the
skill in no group, and gave one imported from there no From. gitRepoOf
now asks provider.GitAt, passes such a .git over to the clone's, and
reads the origin from the folder GitAt names (a linked worktree's
common one), which replaces gitdirConfig. gitdirConfig also took
"gitdir:" with no space after it, or with spaces around the line,
which git doesn't take; such a .git now traces to nothing, as git finds
nothing there. Checkouts git made are traced as before; the test's
fake ones had only a config and now have a HEAD, objects and refs.
Every other .git folder in the Go code is one a walk skips when it
copies, hashes or checks a skill (carry.go, skillcheck.go, skills.go,
skill_edits.go), or the one magpie removes from its own fetch of a
skill (skillgit.go), not a decision about a repository. The Claude
bridge's claudeWorkDir takes the temp folder for one in no repository;
Claude Code decides that for itself, and its git status is off for
every run (CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS), so it stays.

TestPluginToldWhereTheAgentWorks gets a real repository for "in a
repository" (HEAD, objects, refs; an empty .git was all it had) and a
case under an empty .git in its own temp folder, so it fails without
this on any machine. Its "not in one" cases, and the new provider
tests' "no" ones, still need no repository above the temp folder, as
the test did before. TestGitOnDiskIsWhatGitFinds lays out each kind of
.git by hand; TestGitOnDiskAgreesWithGit asks git rev-parse
--git-common-dir in each of those folders and in ones git made (init,
worktree add, a worktree whose record was removed, --separate-git-dir,
init --bare .git), for yes or no and where;
TestGitOnDiskUnreadIsUnknown locks a .git folder and a worktree's .git
file. provider-plugins.md and library.md say the same.

What was run (tree 9a4504d9, on origin/main 56602426, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077, git 2.34.1, with
the box's empty /tmp/.git above the tests' temp folders:
- TestPluginToldWhereTheAgentWorks -count=5, Bun 1.4.2: 5 of 5 ok.
  TestGitOnDisk* and TestSkillRepo*, -count=3: 15 of 15 ok. The same
  and TestPluginToldWhereTheAgentWorks, -race -count=2: 12 of 12, no
  race. internal/library and internal/provider whole: ok.
- 56602426's workplace.go and skill_from.go put back under the new
  tests: TestPluginToldWhereTheAgentWorks red 5 of 5, at
  plugin_workdir_test.go:125 both "not in one" and "not in one, under
  an empty .git": the plugin was told git "yes", want "no";
  TestSkillRepoTraced red, "write-a-prd: repo "", want
  "mattpocock/skills"".
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag
  on linux: exit 1 (no libsoup-3.0 or gio-unix-2.0 here).
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2, log
  kept; 8m37s, load 32 at its start): 73 packages ok, and 14 tests red
  in 4 packages, none of them this commit's tests or what they cover.
  internal/gateway ran to its end (504s), so
  TestPluginToldWhereTheAgentWorks passed in it; internal/library and
  internal/provider ok. The reds: agent TestCodexDriftReached and
  TestCodexBehindReverseProxy (#3398); TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141);
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641: go build's own VCS
  stamping meets the same /tmp/.git, which this doesn't change); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask
  077, #3640); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649).

This commit is 595b361c rebased: the same internal/ patch-id, and
the same row in docs/subsystems/library.md, put in by git's 3-way
merge, as main's 33ccc618 (#2794) rewrote the Skills row, a line of its
context three rows above. The rest is what was run for 595b361c, at
tree d56bed31 on origin/main 098ac969, the same code (not this tree):
- main's GitOnDisk and gitRepoOf under the new tests (098ac969's
  workplace.go and skill_from.go put back):
  TestPluginToldWhereTheAgentWorks -count=5, Bun 1.4.2: red 5 of 5,
  "not in one" and "not in one, under an empty .git" told git "yes".
  With TMPDIR=/var/tmp/3675-clean, no .git above it: red 5 of 5 on the
  new case alone. TestSkillRepoTraced: red, write-a-prd: repo "", want
  "mattpocock/skills".
- Broken by hand, one at a time in workplace.go, each red in the
  GitOnDisk tests on what it breaks, and green again restored:
    any .git folder taken, main's rule for folders: "yes" under an
      empty .git, a zeroed HEAD and a HEAD alone, and for a locked .git
    a gitfile naming no repository, or not a gitfile, walked past:
      "yes" from the repository above it
    HEAD's content not read: "yes" for the zeroed HEAD; objects and
      refs not looked for: "yes" for a HEAD alone
    a HEAD at a commit not taken, or commondir not read: "no" for both
      linked worktrees; a worktree's own folder named, not its common
      one: the repository at .../worktrees/wt where git finds .../.git
    a HEAD linked into refs/ refused: "no"; a relative gitdir read
      from magpie's folder: "no" for the submodule; no 1 MB cap: "yes"
    ENOTDIR taken for a failed read: unknown for a gitfile naming a
      file; a .git it can't read walked past: "no" for both locked ones

Not tried: CI's git 2.55.0 (ubuntu) and 2.56.0 (macOS, Windows) under
TestGitOnDiskAgreesWithGit, which met git 2.34.1 alone; macOS and
Windows at all (Windows CI only compiles the tests); a real ZCode or
Command Code plugin end to end; a shared magpie told another user's
folder; the Library page itself.

Landed by yetone in a batch of Coffemon's patches from the issues.
What was run, go1.26.8, on origin/main cc81ad4ea, then again at
70a0c387c (gofmt, the three vets, the changed tests, umask 077):
- mote (macOS 27): gofmt -l clean; go vet, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet ./...: ok. edit and testenv at umask
  077; agent, provider, library and gateway with an empty .git above
  TMPDIR; davsync, imagemcp, plugin, library, edit, testenv whole; the
  changed tests in agent, provider, gateway and gui; the timing tests
  -count=10 (gateway, davsync, imagemcp) and -count=5 (agent): all ok.
  TestCoreScriptBudget ok: core 1,536,751 of 1,537,034, app.js
  1,312,975 of 1,315,316, no budget raised.
- Red on the old code: on origin/main, TestWriteAtomicReadOnlyHardLink
  at umask 077 and two Reasonix tests under an empty .git; on Linux
  (wsl-run) TestProgram at umask 077 with the old program.go. With
  each fix's code taken back to main's, the Gemini imageConfig tests,
  TestPluginToldWhereTheAgentWorks, TestSkillRepoTraced,
  TestTaggedHooksAlone, TestMainURL/TestMainView and update-auto,
  plugin-github-hooks, plugins-more-discover, plugin-namesake were
  red. Broken by hand: claudeKeyed always true (both
  OwnEndpointNeverAsked tests red), claudeAsk a no-op
  (TestClaudeFirstWriteAsksTheProxy red), GitAt taking any .git folder
  (the three TestGitOnDisk tests red).
- GUI: 123 files (plugins*, update-*, panel/tray/start/context, i18n,
  gui-zh-tw/ja/de and every file that evals app.js parts) in WebKit on
  Linux (wsl-run). 11 files had reds (click-scroll, panel-fold,
  plugin-card-update, plugin-github, plugin-move*, segs-glide,
  tray-totals, update-*), and run again side by side they fail the
  same on origin/main d80d75f30 (79 pass, 26 fail here; 78 and 27
  there). They are click-scroll guards ("the click must not scroll
  the page"), varying by language from run to run (#4385).
  copilot-ghe's route-after-close red is #1949, seen on main 244d80e23
  too. In Chromium on mote, Chromium segfaulted partway through files
  (#4125): context-map, context-scroll-end and context-tune fail the
  same on origin/main 0911a65e7, so the batch's own files
  (plugin-namesake, update-auto, plugins-more-discover,
  plugin-github-hooks) ran in Chromium on Linux: 62 of 62.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./..., mote)
  at 472a0608f (on 70a0c387c): every package ok but internal/gateway,
  whose five reds were #4362's (Antigravity turned-away and
  TestCodexSpentGrokFailingIsTold), fixed on main in d80d75f30. After
  the rebase on 244d80e23 the five pass, and gofmt, the three vets
  and the targeted runs above were run again: ok. In Linux the
  sign-in, copilot, plugin-github*, plugins-more-discover,
  plugin-namesake, plugin-gateway, update-auto, quota-refresh-order
  and i18n files ran in both engines: 475 pass, 4 fail (copilot-ghe
  #1949, plugin-github's click scroll, both red on main too).
- Rebased again on c7171a256, over its budget fix e94bf7a08: gofmt, vet of
  gui, gateway, provider and plugin, TestCoreScriptBudget (core
  1,536,265 of 1,536,586 with the batch's last commit, statusTErr and settingsErr), the Gemini,
  GitOnDisk and plugin tests, and in Linux both engines i18n-keys,
  update-mirror, plugin-namesake, plugins-more-discover,
  plugin-github-hooks and update-auto (138 of 138): ok.
Not tried: the whole GUI suite (mote's WebKit wouldn't launch and its
Chromium segfaulted, #4125); macOS WebKit; the real app's window.
2026-10-30 15:53:22 +08:00
yetone 969868ccda library: a Python MCP server in a GitHub repository's folder is found and added filled in (CyberCaius on Discord)
CyberCaius pasted
https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_askecho_search_infinity
(Volcengine's askecho web search) into the Library's MCP search. The
fragment was dropped, the MCP Registry was asked for "mcp-server" and
"volcengine", nothing it lists is there, so the page offered only a
blank command named "server".

A GitHub address naming a folder (#subdirectory=, /tree/<ref>/…,
/blob/<ref>/…/file) is now read before the registry: the folder's
pyproject.toml names the program ([project.scripts]) and its README's
"env": {…} examples the keys. It is offered as a normal market card:
uvx --from git+https://github.com/o/r[@ref]#subdirectory=<path> <program>,
with the keys asked for in the install sheet. Of several keys none is
required (askecho takes an API key, or an access key and secret); one
alone is. A bare repository is read that way only when the registry
has nothing at it. A pypi.org/project/ page, or a one-word search
naming mcp (with - _ or .) that the registry lists nothing by, asks
PyPI's JSON API and offers uvx <package> with its description's keys.
Claude Desktop is already wired for local Library servers
(claude_desktop_config.json); the test installs it there.

Run (mote):
- go test ./internal/library -run 'TestMarket|TestParseRepoAt|TestEnvInputs': ok
- go test ./internal/library rebased on ceef9e943 (AnySearch d05482bab in): ok; the push then rebased onto 70a0c387c (agent, cli only), not run again
- Full suite go test -timeout 45m ./... at d29414c1a (rebased only onto
  origin/main since): 78 ok; reds in internal/gateway (Antigravity
  turned-away x4, TestCodexSpentGrokFailingIsTold) and internal/gui
  (AppKit real-window tests). Same reds on fresh origin/main ceef9e943,
  filed as #4362, #2645, #4125, #1936, #3178, #3949.
- GOOS=linux/windows/darwin go vet ./internal/library: ok; gofmt clean.
- Broken by hand: MarketServers back on searchRegistryAt/searchRegistry,
  TestMarketServerInRepoFolder, ...RepoFolderPage and ...OnPyPI red.
- Real use: the search against live GitHub and PyPI returns the uvx
  command and the three keys; the command itself, run with uvx and a
  fake key, answered initialize and listed web_search.
- Fixtures are the real pyproject.toml, README.md and PyPI entry, in
  testdata/askecho; tests reach no network.

Not tried: a real search with a real Volcengine key; Claude Desktop
launching it (Desktop needs uvx and git on its PATH, as for the
featured fetch/git/time servers); Node servers in a folder (still the
blank form); a word search like "askecho" (no index has it). No GUI
change.
2026-10-30 14:47:13 +08:00
yetone d05482bab3 library: AnySearch in the market (lileo on Discord)
lileo asked for the AnySearch MCP. From AnySearch's own repo
(github.com/anysearch-ai/anysearch-mcp-server, README): remote Streamable
HTTP at https://api.anysearch.com/mcp; the key is optional (anonymous use
has a lower rate limit), sent as Authorization: Bearer as_sk_..., and made
at anysearch.com/console/api-keys. Like Exa, a remote entry with an
optional secret header; the icon is the anysearch-ai GitHub account and
the docs link the repo. Its examples also send X-Anysearch-Client;
tools/list answers without it, so it isn't added.

Probed by hand from mote (not in a test): initialize 200, serverInfo
anysearch-mcp-server 1.0.0, protocol 2025-06-18; tools/list gives
batch_search, extract, get_sub_domains, score, search.

Run at this commit after the last rebase (on e8d42c02d): go test
./internal/sessions ./internal/library ok; go vet darwin, linux -tags
nogui, windows over ./internal/... VET-OK; i18n-keys ok (mote).
Run at 7ec95b5dd (the same two commits on 1534474c8):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  (mote): VET-OK.
- Full go test -tags nogui ./... -timeout 45m on the Linux box (wsl-run):
  internal/library ok. Reds only where origin/main eadeb89c4 is red on the
  same box, each filed: internal/agent (#4033, #3548), internal/gateway
  (#4362); internal/cli's two field-name tests red in the full run and ok
  alone here (#4247).
- GUI files this reaches: i18n-keys and gui-de/ja/zh-tw ok on mote,
  both engines; library-* ok in the WSL full GUI run at this tip (on mote
  they timed out launching browsers at load ~140, not on an assertion).
  market-*, sessions-* and usage-* hadn't finished on mote when pushed.
- The whole GUI suite has not finished (WSL run about half way when
  pushed; its reds so far are in files this doesn't reach). It will be
  finished and each red filed on its own.
Before the rebase: go test ./internal/library and the internal/gui
Market/I18n tests on mote, ok.

Broken by hand: format "{}" in place of "Bearer {}" turns
TestAnySearchKeyIsOptional red.

Not tried: a search with a real AnySearch key, or the entry added from
the GUI and called by a real agent.
2026-10-30 14:38:22 +08:00
yetone d6284bf8a0 library: a skill's installed dependencies are no change of the user's
ggbr on Discord (#help): easyeda/easyeda-api-skill says to run
`npm install` in its own folder. Once that ran, the Library tagged the
skill Changed here (本地已改动). The check for updates still ran on it
(it compares commits, not the folder), but Update all left it out as
changed, and its own Update asked to replace "your changes" and threw
node_modules away with the old version, so the user had to install again.

Cause: editState compared the hash of the whole library folder (only
.DS_Store left out) with Hash, the hash of the files as fetched. The
install's node_modules and its rewrite of package-lock.json made them
differ.

Now what installing dependencies or running the skill writes is not a
change (fromInstall): node_modules, .venv, venv, __pycache__,
.pytest_cache, .mypy_cache, .ruff_cache, *.pyc/*.pyo, and the lock files
package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lock(b), uv.lock.
- New Skill.Own: the hash of the files as fetched without those, set on
  install, update and when skill_from binds a skill to its repo.
  onlyInstalled compares the folder with it first.
- An agent's copy (copy mode) counts as edited only when its ownHash
  differs from the library's.
- An update carries those entries from the version replaced into the new
  one wherever the new one has no entry of its own (carryInstalled). The
  new version's own lock file wins.
A file the user really edited (run.py, SKILL.md, package.json, ...) still
marks the skill changed and is never overwritten without asking. An edit
to a lock file alone is no longer protected; an update takes upstream's.

Skills already marked changed: they clear on their own on the next page
read when only installed folders and bytecode differ, or the lock file the
skill came with was left byte-for-byte (compared with Hash, leaving
installed folders aside). A skill fetched before this commit whose lock
file the install did rewrite has no Own, so it stays marked until its
next update (Update on its row asks once, keeps the old folder in the
backups, carries node_modules over and records Own). From then on, a
rewritten lock file isn't counted.

Run (mote, worktree at e863f520c plus this change):
- go test -timeout 45m -count=1 ./internal/library: ok (107s)
- go vet ./internal/library, GOOS=windows and GOOS=linux go vet: clean
- gofmt -l internal/library: clean
- Windows box (win-run): TestInstalledDependencies* and TestUpdateKeeps*
  pass (the first run found the test comparing a link target with "/";
  it now uses filepath.ToSlash)

Broken by hand, each red on mote:
- editState without onlyInstalled: TestInstalledDependenciesAreNoChange
  and TestInstalledDependenciesBeforeOwnWasKept red ("installing eda's
  dependencies made it changed here")
- apply without carryInstalled: node_modules, .venv, __pycache__ and the
  .bin link didn't go on with the update
- copy branch on sameTree alone: TestInstalledDependenciesInACopy red
- onlyInstalled ignoring Own: the lock-file rewrite after an update reads
  as changed

Not tried: a real `npm install` of easyeda-api-skill in the GUI. No GUI
assets changed. Not changed: takeEdits still takes node_modules
installed in an agent's copy into the library (as before), and folders
like build/ or dist/ still count, since a skill can ship them.
2026-10-30 10:29:59 +08:00
yetone 4054251865 library: an MCP server can be kept to this computer, never synced
huhuy72219405 on X: "能不能把不同设备的mcp区分一下,有些mcp属于本地的,
同步之后其他设备不应该读取到". A server in Library > MCP now has a
"This computer only" switch in its editor (Server.Local; CLI
`magpie library mcp add ... --local` and `magpie library mcp local
<name> on|off`; the TUI keeps it on edit and marks the row).

- Collect leaves local servers out (carriedServers), so neither a sync
  nor a backup file takes one to another computer. Turning a shared
  server local takes it out of what is carried, so the other computers
  drop it at their next sync; the flag itself is never carried.
- Put (sync, join, Restore, Undo, backup file) keeps every local
  server, with its agents, and clears Local on what comes in.
- Another computer's server by a local server's name goes to
  Library.Away: given to no agent, not in the hub, carried on as it
  came, so a push from here never removes it from the computers that
  have it. settleAway (every change) promotes it once the name is gone
  here, and drops it once the name is shared here again.
- The hub serves local servers like any other (it runs here);
  subagents aren't carried, so one naming a local server keeps it.

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

Run at f5dd4e142 + this change; after rebasing on d3898ca8d (gui/provider only, then 2a1ef15ba, routing), vet, the five new Go tests, mcp-local-server and i18n-keys again, ok:
- mote: gofmt -l clean; go vet of library/backup/davsync/cli/tui;
  GOOS=linux and GOOS=windows go vet -tags nogui of the same; go test
  of TestLocalServerNotCarried, TestPutKeepsLocalServer,
  TestPutSameNameAsLocal (library), TestRestoreKeepsLocalServer
  (backup), TestLocalServerThroughSync (davsync, two computers through
  the fake S3) ok.
- mote GUI, Chromium and WebKit: mcp-local-server.test.cjs (new; every
  language, 1100 and 390 wide, switch saves local true/false, row tag,
  no sideways scroll), i18n-keys, mcp-editor-cancel,
  mcp-startup-timeout, every library-mcp-*, mcp-oauth-app, mcp-signin*,
  library-items, library-servers-bulk, library-subagents,
  library-pick-remove, library-env-refs, library-zed-mcp,
  library-loading: all pass (126 of 126 in the last batch).
- Full Go suite, -tags nogui -timeout 45m, on the Linux box (wsl-run;
  mote had another session's full suite running): every package ok
  but internal/agent, whose TestInstalledVersion, TestGrokInstalled,
  TestOmpDetectedWithPiDir and TestZedAppPath fail the same at
  origin/main 9b4d0bda8 on that box; all four are #4033.
- Real CLI in a sandbox HOME on mote: mcp add --local, local on/off,
  `magpie library` shows "this computer only", library.json has
  "local": true; an unknown name and a bad value are refused.

Broken by hand: putServers not keeping local servers turned
TestPutKeepsLocalServer, TestPutSameNameAsLocal,
TestRestoreKeepsLocalServer and TestLocalServerThroughSync red;
carriedServers carrying local servers turned TestLocalServerNotCarried,
TestPutSameNameAsLocal, TestRestoreKeepsLocalServer and
TestLocalServerThroughSync red.

Not tried: a sync between two real computers; the real GUI app (the
Playwright run fakes the API); the full Go suite on macOS or Windows.
2026-10-30 02:31:08 +08:00
yetone 3ce2a9819f library: RTK for agents in WSL, with the distro's own rtk (lex on Discord)
lex: Claude Code and other agents in WSL couldn't use the RTK of magpie
on Windows. rtkAgents looked an agent up in rtkSpecs by its whole id, so
claude@wsl:Ubuntu never matched and WSL agents weren't on the RTK page at
all. Even matched, the specs read this machine's home, and Windows' rtk.exe
is no command inside the distro, where the hook runs.

Now an agent is looked up by its kind (rtkKind). One in WSL:
- has its files read and written under the distro's home as magpie opens
  it (rtkClaudeDir, rtkCodexDir, rtkHome), with blocked/version checks
  against the distro's rtk and OpenCode;
- uses the distro's own rtk: rtkDistroOf asks the distro (wsl.exe -d <d>
  -e sh -lc) where rtk is on its shells' PATH, else in ~/.local/bin or
  ~/.cargo/bin (offPath), kept 15s; ReadRTK lists one RTKDistro per distro;
- switching on runs that rtk there (rtk init -g ..., its folder on PATH);
- Install RTK in WSL <distro> (POST /api/library/rtk/install {distro},
  magpie library rtk install <distro>) runs RTK's own Linux installer in
  the distro (curl, or wget).
A distro that isn't running is never started (#3896): its agents are
listed asleep with the switch off, and switching or installing says to
start it. The page has a card per distro (install, off-PATH, asleep) and
uses the distro's rtk for each WSL row's tags and switch; strings in zh,
zh-TW, ja and de. The install route now refuses a body it can't read
instead of installing on this computer.

Run:
- mote (macOS 27), at origin/main ec8fe29b8 plus this: gofmt -l clean;
  go vet darwin, GOOS=linux -tags nogui, GOOS=windows for internal/library,
  internal/gui, internal/cli: ok. go test ./internal/library ./internal/cli
  ok; ./internal/gui: TestMainWindowCorners/macOS_26_SDK red (#3949, open,
  mote's macOS 27), everything else ok; -run Library ok after the route
  change. node --test library-*.test.cjs + i18n-keys in Chromium and WebKit:
  828 tests, 3 red, all library-row-remove (#3099, open; 1 of 2 runs alone
  is red the same); library-rtk-*.test.cjs + i18n-keys at the pushed base:
  180 pass. New library-rtk-wsl.test.cjs: en, zh, zh-TW, ja, de at 980 and
  380px, both engines.
- New TestRTKWSL / TestRTKWSLAsleep (fake wsl.exe runs the real probe
  script with sh, the distro's home as HOME). Broken by hand: the old
  rtkSpecs[a.ID] lookup makes TestRTKWSL red (claude@wsl not on the page).
  Also ok on Windows (win-run) and Linux (wsl-run), -run 'RTK|WSL'.
- Real WSL, xiaomi-gpu with magpie-desktop (Ubuntu 24.04): from Windows,
  through real wsl.exe and the exact rtkWSLScript/rtkWSLProbe/rtkInitWSL
  strings, with HOME set to a throwaway folder in the distro: RTK's
  installer put rtk 1.1.0 in ~/.local/bin, the probe found it (on:0, not
  on that bare PATH), rtk init -g --auto-patch wrote "rtk hook claude" into
  ~/.claude/settings.json, and sp.has read it back over
  \\wsl.localhost\magpie-desktop\.... ReadRTK on Windows lists
  claude@wsl, codex@wsl and pi@wsl:magpie-desktop with an install offered.

Not tried: a real Claude Code session in WSL running a command through
the hook; the install and switch in the distro's real home (only the
throwaway HOME); the real GUI window on Windows; OpenCode, Gemini, agy,
Hermes, OMP in WSL (same code path, not run for real).
2026-10-29 19:58:40 +08:00
yetone c1da9ccda3 library: a stopped WSL distro's agents are listed, and a tick for one is written there once it runs (cybercaius on Discord)
cybercaius: with WSL not started, the Library's MCP page didn't list the
agents in the distro at all, and nothing ticked for them could be kept.
A stopped distro's agents are no targets (#3896: opening their files
starts the distro), so they fell off the page.

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

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

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

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

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

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

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

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

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

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

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

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

Not covered:
- Another computer whose skill is still in its own ~/.agents/skills gets
  the library's copy from a sync, beside its own, until it is handed over
  there too.
- The skills CLI's lock (npx skills update) may put the entry back.
- No hand-back button in the GUI; the sheet names the CLI command.
- Tried in a sandbox HOME only, never on a real ~/.agents.
2026-10-29 15:52:42 +08:00
yetone 033b17bafe library: every skill named in another script is listed, under its folder's name
4db65681c carries this commit's first message by mistake (another session's amend read it from a shared file); it holds none of this change, which is here.

tnt1223 on Discord: Library › Skills listed 16 skills for
https://github.com/asdfgh1445/ctf-super-hub, which has 35 (one folder each
at the top, 35 SKILL.md in its recursive tree, not truncated).

Cause: the listing found all 35, but nameFor made each SKILL.md's `name`
fit for a file name by dropping everything outside ASCII. "CTF•密码学" and
ten more became "CTF", "Strix•RCE 测试" and nine more "Strix", "头脑风暴"
nothing, and unhiddenFirst lists skills of the same name once, so 35
became 16. Not a depth limit, cap, pagination or truncated tree: the probe
downloads the tarball and walks it; a truncated tree and GitHub's rate
limit are already said (skilltree.go, fetch).

Fix: a declared name that would lose a letter or digit (another script)
or comes out empty goes by its folder's name, which a repository keeps
apart. An ASCII name goes as before ("My Skill" is still My-Skill), so a
skill installed from one is still the library's. A skill at a
repository's top now falls back to the repository's name (srcFolder),
not the temporary download folder; candidates takes that name from each
caller (probe, Group again, CC Switch origin, new-skill check).

Tests: TestSkillsNamedInAnotherScriptAllListed probes and installs from a
fake of the repository built from its real tree (35 folders, front matter
names as written at 7715719); TestSkillNameFallsBackToFolderOnlyWhenLettersAreLost
and TestSkillAtTheTopNamedInAnotherScript cover the rule and the top
folder. No network.

Run:
- mote: go vet ./internal/library; GOOS=linux and GOOS=windows go vet
  -tags nogui ./internal/library; gofmt -l internal docs (empty);
  go test ./internal/library -run 'TestSkillsNamedInAnotherScript|
  TestSkillNameFallsBack|TestSkillAtTheTop|TestRepoWithAPlugin|Probe|
  CCSwitch|Regroup|NewSkill|From' -count=1: ok.
- wsl-run (magpie-desktop): go test -tags nogui ./internal/library
  -timeout 45m -count=1: ok 94.9s.
- Live, sandbox HOME (the package's TestMain/testenv), a throwaway test
  calling ProbeSkills("https://github.com/asdfgh1445/ctf-super-hub")
  against the real GitHub: 35 candidates, each named by its folder,
  nothing left out. Not committed.

Broken by hand: nameFor using the declared name whenever it isn't empty
(the old rule): TestSkillsNamedInAnotherScriptAllListed lists 16 with
names CTF/Strix/..., and the rule test fails on "CTF•密码学" and
"Café notes". Restored, green.

Not tried: the full ./... suite (mote at load ~350 from other runs; only
internal/library changed); the GUI suite (no app.js change); Windows test
run; installing the real repository's skills into a real agent. Not
changed: two different skills declaring the same ASCII name in folders of
different names are still listed once, as copies of one skill are
(unhiddenFirst).
2026-10-29 14:39:57 +08:00
yetone f02390544d edit: a JSONC delete takes the last member's trailing comma, so the MCP hub never leaves OpenCode's mcp as {,}
chenxiang0010 (Discord #general, Windows): turning the Library's MCP hub on
for OpenCode and off again left a comma at the end of opencode.jsonc's
"mcp", and OpenCode said "opencode.jsonc: invalid"; deleting the comma by
hand fixed it, and a second try didn't reproduce.

Cause: delJSONBytes looked for the deleted member's trailing comma in the
tidwall/jsonc copy, which blanks every comma before a closing bracket.
So when the member was the last one and had a trailing comma (as OpenCode,
editors and users allow), the comma was left behind; when it was the only
member, it was left with nothing before it: "mcp": {\n,\n}. The hub sync
then inserted the magpie entry in front of it ("magpie": {...},\n,) — a
double comma. OpenCode parses with jsonc-parser allowTrailingComma
(packages/opencode/src/config/parse.ts at v1.19.5, packages/core/src/config.ts
on dev): a trailing comma after a value is fine, a lone one is an error.
magpie's own validity check went through the same tidwall copy, so it
passed the broken file. Once the comma was deleted by hand there was no
trailing comma left, which is why it didn't happen again.

- delJSONBytes takes the last member's own trailing comma (nextToken, as
  delItem already did for arrays), and its line with trailing blanks.
- insertKey adds no comma after the first member of an object that holds
  comments only (it used to, leaving a trailing comma only some apps read).
- edit.ValidJSONC reads JSONC as jsonc-parser with allowTrailingComma does.
  SetJSON, DelJSON, PatchJSON, SetJSONItem and DelJSONItem refuse an edit
  that would turn a file the app reads into one it can't (checkJSONC):
  nothing is written, and the error names the file.
- A lone comma an older magpie left is dropped by the next object edit of
  that file (dropLoneCommas), so users already hit are mended by the next
  sync that writes it. A file nothing writes again keeps it until then.

Every JSON/JSONC object writer goes through SetJSON/DelJSON/PatchJSON
(library MCP for OpenCode, Zed, VS Code, Claude, etc., agent wiring for
DevEco, MiMo Code, OpenCode, ...), so all of them get it.

Tests (red on the old json.go/jsonarray.go, put back by hand, green now):
- TestHubToggleLeavesValidJSONC: 12 file shapes (LF, CRLF, tabs, compact,
  trailing commas, comment-only, comment after, comma after a comment) x 7
  add/delete orders; old code: invalid in the trailing-comma and
  comment-only shapes.
- TestDelOnlyMemberTakesItsTrailingComma, TestInsertIntoCommentOnly-
  ObjectNoTrailingComma, TestLoneCommaMendedOnNextEdit: red on old code.
- TestValidJSONC, TestInvalidEditNotWritten.
- internal/library TestHubToggleKeepsOpenCodeJSONCValid: the real
  SetMCPHub on/off twice for OpenCode, LF and CRLF; old code: invalid at
  the first "hub on" ("magpie": {...},\n,\n}).
2026-10-29 09:33:11 +08:00
yetone fe05f0a721 library: a skill can be turned off on this computer alone, and a sync neither carries that nor turns it on
hanslin1666 on Discord (#general 1565016936344191096) wanted a library
skill off on one computer only ("只在这台电脑上关掉"). The only way to do
that was to untick its agents, and the ticks are what a sync carries, so
every other computer lost it too. A sync from a computer that had it on
also gave it back here.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Not tried: a real Codex or Claude Code session starting the node entry
(the entry has the same command/args shape they already start), and
macOS's process tree (npx's node and sh there too).
Not done (#3885 stays open): Codex starting the same MCP once a thread.
2026-10-29 01:30:58 +08:00
yetone 053d0d37f8 library: Install RTK uses brew only when Homebrew has rtk's bottle, and keeps why it failed on the card (Scott__D on X)
Scott__D on X: "Magpie 里的这个 RTK 安装一直都不成功". The RTK card sat on
"Installing RTK… this can take a minute." over `brew install rtk`.

Cause: Homebrew bottles rtk only for Apple silicon on the newest macOS
(arm64_sequoia, arm64_tahoe, arm64_golden_gate, and Linux). On an Intel Mac
or macOS 14 and older, `brew install rtk` builds rtk from source, and first
the 19 formulae it builds with, rust, llvm and python among them: hours.
InstallRTK gives the installer five minutes, so each try was ended, said so
in a status line gone after ten seconds, and the next try started over.
Reproduced on mote with a sandbox Homebrew (HOME and prefix of its own)
and HOMEBREW_FAKE_MACOS=14.7: brew info rtk says "stable 1.1.0, HEAD" with
no "(bottled)", brew install rtk lists 19 dependencies to build, and
magpie's InstallRTK spent 3m43s in it before failing.

Fix:
- rtkInstaller asks `brew info rtk` and uses brew only when it says
  "(bottled)", brew's own word for pouring the bottle here. Otherwise, and
  when brew fails or doesn't answer in 30s, it is rtk's own script
  (install.sh from rtk-ai/rtk's README, which downloads rtk's release for
  darwin x86_64/aarch64 and Linux). The answer is kept an hour per brew,
  since ReadRTK asks on every read while rtk isn't installed.
- A failed brew says Homebrew's first Error: line and what it says to do,
  not the support-tier notice its output ends with.
- The card keeps "The install failed: {why}" beside Get RTK until the
  next try (as the upgrade's error already did), in every language.
- The five-minute bound on the installer was already there and stays.

Run on mote (macOS 27.2, arm64):
- real InstallRTK, sandbox HOME, sandbox Homebrew, HOMEBREW_FAKE_MACOS=14.7:
  chose rtk's script, installed rtk 1.1.0 into the sandbox ~/.local/bin in
  12.2s (`rtk --version`: rtk 1.1.0); the card then offers Put RTK on PATH.
- real InstallRTK, same sandbox, macOS 27 as it is: chose brew (bottled),
  installed rtk 1.1.0 in 10.7s.
- go test ./internal/library (TestRTK*): ok. New tests:
  TestRTKInstallsWithBrewOnlyFromItsBottle (brew info output read from the
  real brew, bottled and not), TestRTKBrewInfoThatHangs,
  TestRTKBrewInstallSaysBrewsError (brew's real output on mote).
- GUI: library-rtk-install.test.cjs, 5 languages x 1100/420, Chromium and
  WebKit: 22/22. All library-*, gui-de/ja/zh-tw and i18n-keys files: 770 of
  771; the one red is i18n-keys "a plugin's words are its own" on
  plugins/routing "masking…", red on origin/main too (#4053).
- gofmt -l: nothing. go vet ./internal/library ./internal/gui;
  GOOS=linux and GOOS=windows go vet ./internal/library: ok.
- Full suite on mote, go test -tags nogui -count=1 -timeout 45m ./...
  at base df9376592: 77 packages ok, exit 0. Rebased on 874b86653 (no
  change under internal/library or the library plugin); at the pushed
  tree: go test ./internal/library ok, GOOS=linux go vet -tags nogui ./...
  ok, library-rtk-install + i18n-keys 25 of 26 (the one red is #4053).

Broken by hand: rtkInstaller back to "brew when there is one": all four
bottle cases, the hang test and (with brewError off) the error test red.
The kept answer dropped: "brew asked 2 times". The card's error line
dropped: library-rtk-install red in every language.

Not tried: a real Intel Mac or a real macOS 14 (simulated with
HOMEBREW_FAKE_MACOS); Scott__D's own Mac, macOS version and network; a
network where GitHub downloads fail (the script's error then shows on the
card).
2026-10-28 19:28:44 +08:00
yetone e29ddc407f library: a Pi in WSL is given MCP servers, and so are seven more WSL agents
leokon on Discord (#help): the Library's MCP section listed only the
Windows Pi, never a Pi installed in WSL. wslTargetOf left pi@wsl's MCP
out because its version wasn't known, and Pi's MCP file depends on the
version: 0.99+ reads mcp.json itself; before that, pi-mcp-adapter 3 reads
mcp-adapter.json and 2 reads mcp.json.

- The WSL probe now asks the distro's pi for --version (wslKind
  version: true). The answer is stored as the agent's wslVersion, and
  InstalledVersion returns it for an agent in WSL.
- pi@wsl:<distro> gets piMCP. The file is chosen as on this computer,
  with the distro's npm roots for the adapter (~/.npm-global,
  /usr/local/lib and /usr/lib node_modules): wslPiRoots, piDetectIn.
- Siblings: every agent with a local MCP target and no WSL one now
  has one, in its own file under the distro's home. These are Gemini
  CLI, Antigravity CLI, Crush, Cline, CodeBuddy Code, Kimi Code and
  Goose.
- Every WSL MCP file is marked WSL with its distro, so a Windows
  program (C:\...\npx.cmd) is refused, as for claude/codex@wsl.
- Not fixed: Kimi Code's and Goose's skills in WSL. On this computer
  they get the shared ~/.agents/skills, but the distro's needs that
  folder's sharing rule (#3966).

Run (at d8c70504d + this commit; rebased on d50f84c9f, two mover mins):
- go test -tags nogui ./internal/agent ./internal/library on mote: ok.
- GOOS=windows and GOOS=linux go vet ./internal/agent ./internal/library:
  ok.
- gofmt -l: clean.
- New tests:
  - TestWSLPiMCP covers three fake distros: Pi 1.2 gets mcp.json
    (native); Pi 0.98 with no extension gets mcp-adapter.json; Pi 0.98
    with adapter 2 in ~/.npm-global gets mcp.json (fmtPi). Each is in
    the page's view, and is written to its distro and not this
    computer's Pi. A Windows program is refused.
  - TestWSLMCPSiblings covers the 7 siblings: path, WSL mark, writes,
    and refusal. The OS switch is forced with agent.FakeWSL.
- GUI, on mote: library-*.test.cjs, wsl-agents-setting and i18n-keys
  (Chromium and WebKit, every language): 769 of 770 pass. The red is
  i18n-keys "a plugin's words are its own" ("Runs as" in
  claude_code_cli.go), red on main since 7f827b3b0, #3897.
- Full suite on mote (go test -tags nogui -timeout 45m ./...) at
  d8c70504d + this change: 76 packages ok, no FAIL, exit 0.
- Real run, on the Windows box: magpie built on Windows, run in a
  sandbox USERPROFILE. `magpie library mcp add wslfetch uvx
  mcp-server-fetch agents=pi@wsl:magpie-desktop` wrote the server into
  magpie-desktop's ~/.pi/agent/mcp-adapter.json. The distro has pi
  0.73.0 from npm, which the probe asked; it is before 0.99 and has no
  extension. A C:\Program Files\nodejs\npx.cmd server was refused for
  pi@wsl. Both files were then removed.

Broken by hand, each turned the new tests red:
1. pi@wsl with no MCP: TestWSLPiMCP.
2. The version not passed: Debian got mcp.json.
3. No distro roots: Arch got mcp-adapter.json.
4. No WSL mark on the file: the Windows program was written.
5. The gemini case removed: TestWSLMCPSiblings.

Not tried:
- A real Pi 1.x in WSL. magpie-desktop's own pi is 0.73 and was left
  as it is. The 1.x choice (mcp.json) is covered by the test only.
  @earendil-works/pi-coding-agent 1.4.0 answered `--version` with "1.4.0"
  on the box.
- The seven siblings with real installs in WSL.
- A distro that is stopped. Its saved probe from before this release
  has no pi version, so the file is chosen as for an unknown version
  (mcp.json), until the distro is probed while it runs.
- The GUI on Windows. Its MCP list shows any agent whose view has an MCP
  file, unchanged.
2026-10-28 10:37:13 +08:00
yetone dc1af8231b ghtoken: a Settings token GitHub refuses is said, and requests go without one (#3926)
A GitHub token in Settings → Network and sharing that GitHub refused
(401, expired or revoked) failed every plugin and skill check, so a
stale token was worse than none. Now it is treated as an environment
token already was: the request is asked again without it, the token
isn't sent again while magpie runs or until the field changes, and the
anonymous answer (60 an hour) is the one taken. This overturns the
package comment and TestSettingsTokenRefusedStaysAnError: the token
being the user's choice is a reason to tell them, not to fail the
check.

The page stays honest about it:
- Settings › Network and sharing still shows the token, masked, with
  Remove, and says in red that GitHub refused it and requests go
  without one until it is replaced (/api/settings githubTokenRefused).
  Before, a refused token simply read as none being set.
- After a Settings token's refusal requests go anonymous, not with
  GITHUB_TOKEN/GH_TOKEN: the user put the Settings one ahead of those,
  and the page says "without one".

Patch by MYCF711 (fix/settings-token-fallback, 7d93f1b5): the ghtoken
change and its tests. Changed from it: the notice is in Settings' row,
where the token lives, instead of the patch's Plugins page note,
which cost ~630 bytes of core script the budget (28 bytes of room at
c54478904) doesn't have; the Library's skill checks reach Settings'
row too. Token() doesn't fall through to the environment; the
library's skill check test (the sibling the patch left red) expects
the anonymous answer; the unreachable new Refused() message is
dropped (Refused's "where" now holds for a refused Settings token).
app.js stays in its budget by shortening renderGitHubToken's comment.

Run at this tree (base c54478904), on mote:
- go test -tags nogui ./internal/ghtoken ./internal/plugin
  ./internal/library ./internal/gui: ok (TestCoreScriptBudget
  included; no budget raised). GOOS=linux and windows go vet, go build
  ./...: clean.
- github-token-refused.test.cjs (new; chromium and webkit, en and zh,
  1000 and 440px): red 8 of 8 against origin/main's assets, green
  with the change. With github-token and i18n-keys: 21 of 22; the red
  is i18n-keys "a plugin's words are its own" ("Runs as"), red at
  origin/main 74dcf40aa alone too (#3897).
- Every GUI file that opens Settings › Network and sharing
  (allow-ips, api-key-theme, bare-ids, browser-access, cors-origins,
  gateway-port, lan-docker, proxy-test, settings-proxy-auth,
  settings-proxy-remember): 126 of 126.
- Broken by hand: Token() falling through to GITHUB_TOKEN after the
  Settings token's refusal turns TestSettingsTokenRefusedGoesWithoutEnvToken
  red; MYCF711 showed TestSettingsTokenRefusedAskedAgainWithout red with
  from == "settings" back in Do.

Not tried: a real revoked token against api.github.com. The Plugins and
Library pages have no notice of their own (Settings' row says it).
2026-10-28 03:50:46 +08:00
yetone c89284ae66 library: a server turned off everywhere has its running processes ended (#3885)
Turning MCP servers off in the Library rewrote the agents' configs, but
Codex, the Codex app and Claude Code read them only at start, so the
servers they had started kept running. With every server turned off, the
reporter's machine still held 17.75 GB of node processes for them.

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

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

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

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

At the rebased head (base 34d38ed66): go build ./..., GOOS=linux/windows/darwin
go vet -tags nogui ./internal/proc ./internal/library ok; TestParseFamily,
TestPicks, TestEndTrees*, TestDroppedServer*, TestLaunchedBy ok. The
rebase brought no proc or library changes.
2026-10-28 00:19:24 +08:00
yetone fce0d84756 library: OpenCode 2's mcp.servers is read, written and emptied as servers, not taken for one
liam_8829 (Discord #feedback, 10-27) turned every MCP server off and found
opencode.json still holding a "servers" node with no type and no enabled.
That node is OpenCode 2's own container: 2.x writes servers to
mcp.servers.<name> (opencode mcp add --global does), still reads V1
mcp.<name> beside it, and V2 wins a name clash. magpie read every child of
mcp as a server, so it listed "servers" as a typeless server, never saw the
servers inside it (so it could not turn them off), and wrote its own as V1
mcp.<name> beside them.

Now, for the OpenCode format (opencode.json, a project's opencode.json,
and the targets sharing that format):
- mcp.servers is read as the container when it has no type/command/url of
  its own, and its entries are servers;
- a server is written where it already is, or to mcp.servers when the file
  uses that layout; a V2 entry gets no "enabled" (OpenCode 2 drops it; the
  field there is "disabled");
- removing a server removes it from where it is, V1 or V2, never the
  container. Turning everything off leaves {"mcp":{"servers":{}}} plus the
  user's own entries, byte for byte.

Run:
- TestOpenCode2Servers (new): red on the old code ("found [mine]"); red
  with del's fix taken out ("ctx7 ... still in"); red with the enabled drop
  taken out ("an OpenCode 2 server has no enabled"); green with the fix.
- Real OpenCode 2.0.25 in a sandbox XDG_CONFIG_HOME, `opencode debug
  config`: the written file (V1 mine + servers{gh, own}) resolves every
  server; {"mcp":{"servers":{}}} resolves to no mcp, no error.
- go test -count=1 -timeout 45m ./internal/library ./internal/proc
  ./internal/provider:
  library ok (312s), proc ok (40s) at b67c7eaa0 (rebased on origin/main
  14e4d8040). provider red only in tests already filed: with
  -skip TestUnreadLoginsWriteErrorsKeepCredentials (the synctest crash in
  filememo.Forget, #3632, on main since 091153bf), its only reds are
  TestFetchAsksOneListOnceForTwoBasesOfIt, TestFetchUnionsProtocolLists-
  WithoutChat and TestFetchAsksASharedBaseOnce (#3854, on main since
  6eb510f78). Neither touches this change.
- gofmt -l internal/ clean; go vet darwin, GOOS=linux -tags nogui,
  GOOS=windows on library, proc and provider.

Siblings: Codex config.toml and Claude .claude.json emptied correctly in
the same repro; ZCode already writes mcp.servers; Crush is V1 mcp.

Not tried: a real OpenCode TUI session; the project opencode.json and the
deveco/mimocode targets were not tested on their own (they share the same
entries/put/del); the full ./... suite was not run.
2026-10-27 18:52:15 +08:00
yetone e4552cca9f library: a cargo RTK upgrades on Windows, and says why when it can't
新v学员 (Discord #feedback, 10-27): upgrading an RTK installed with cargo
failed silently on Windows. Four causes, each fixed:

- No cargo on magpie's PATH (magpie started before Rust was installed,
  or from a shortcut whose PATH rustup never touched): rtkUpgrader gave
  no upgrade, so Upgrade was greyed with only a tooltip, which a click
  never shows. Now the cargo rustup put beside rtk is run by its path;
  with no cargo anywhere, the card (and the CLI) says it was installed
  with cargo, to install Rust from rustup.rs or run the command shown
  (RTKView.NoUpgrade, Manual), and UpgradeRTK's error says the same.
- CARGO_HOME (D:\Rust\.cargo is common) moved cargo's folder: an rtk
  there wasn't cargo's to magpie. cargoBins reads it, for finding rtk
  and for the upgrade; on Windows the folder matches whatever its case.
- cargo install --git built rtk-ai/rtk's default branch, develop, whose
  Cargo.toml says 0.49.0 while v1.1.0 is out from master: the upgrade
  left rtk as it was, or older, on every OS. It now names --branch
  master, as rtk's own installation guide does.
- Windows refuses cargo's move over a running rtk.exe ("failed to move
  … (os error 5)", exit 101, after the whole build), and an agent runs
  rtk for every command. On that refusal the rtk is renamed aside
  (rtk.exe.old-<pid>, which Windows allows), a copy put in its place,
  and cargo run again; its build is kept in magpie's CARGO_TARGET_DIR,
  so the retry builds nothing. Old copies are removed on the next
  upgrade.

A failed cargo now says its first error with the cause, and what to do
for the common ones (rtk in use, link.exe/dlltool missing, GitHub
unreachable), not its last three lines, which only said the build
failed and where its files were left.

Run:
- Real Windows (10.0.0.132, sandbox CARGO_HOME/RUSTUP_HOME/USERPROFILE,
  rustup + cargo 1.99.1, removed after): plain cargo install over a
  running rtk.exe fails with "拒绝访问。 (os error 5)" exit 101; a
  Windows build of this package's tests (GOOS=windows go test -c, a
  scratch test calling ReadRTK/UpgradeRTK, not committed) with no cargo
  anywhere gave NoUpgrade "cargo" and the new error; with cargo only
  beside rtk (not on PATH) and the old rtk.exe running, UpgradeRTK
  built rtk-ai/rtk master and went 1.0.0 -> 1.1.0 in 3m26s, the running
  rtk kept running, rtk.exe.old-<pid> was left and removed once it
  exited. The build used the gnullvm toolchain with llvm-mingw; the
  gnu toolchain failed with "error calling dlltool" and lld's missing
  -lgcc_eh, which is the output the tests use.
- New tests (rtk_cargo_test.go) and the updated
  TestRTKUpgradeCargoNamesThePackage are red on origin/main
  (32ea16c5a): no upgrader without cargo on PATH, the generic error,
  the last-three-lines message, no --branch. The Windows paths are
  forced through rtkOnWindows.
- go test ./internal/library ./internal/cli ./internal/gui (sandbox
  HOME): ok. gofmt -l clean; go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./...: clean.
- GUI, chromium and webkit: library-rtk-*.test.cjs and i18n-keys (136
  pass), the new card test in en, zh, zh-TW, ja, de at 440px; then
  every library*.test.cjs file (736 pass, 0 fail).
- Rebased on origin/main 68bbcc01c (none of these files changed
  since 32ea16c5a): the three packages ok again, gofmt and vet clean.

Not tried: the MSVC toolchain (the box has no Visual Studio Build
Tools), so the link.exe hint is from cargo's known message, not seen
here; an rtk installed with non-default features is upgraded with the
default ones; CARGO_HOME is read from magpie's own environment only.
2026-10-27 17:08:57 +08:00
yetoneandye4241 33ccc61884 library: one market skill from a huge repository installs alone; GitHub's file list is never cut (#2794)
Adding clean-code from sickn33/agentic-awesome-skills in the market
failed with "GitHub's list of sickn33/agentic-awesome-skills's files
wasn't understood: unexpected end of JSON input" (CaiusLuo; stablyai/
orca the same, ye4241). The repository's download is over 200 MB, so
its skills are fetched file by file from GitHub's list of its files
(#1941), and that list is 11.3 MB: apiGet cut every answer at 8 MB and
dropped the read's error, so JSON was handed a cut-off body.

From ye4241's patch on the issue (made on 75e769a9, applied as is):
apiGet takes the most its caller reads and reads one byte past it; a
200 over it is an error naming the cap, a read that breaks is a read
error, a rate limit is told from the status and headers before either,
and only answers up to 8 MB are kept for a 304. The file list's cap is
64 MB (maxTree), lastCommit keeps 8 MB.

That alone wasn't enough for the reporter's case: the 8,589 skills of
that repository come to 287 MB together, over maxFetch, so the install
would then fail as "too big to install". On top of the patch:
- fetchSkillFiles fetches only what the caller reads: the skills under
  src.Path, and for the market only the folders named as the skill it
  installs (InstallMarketSkill -> cachedProbeFor/probeSkills; such a
  probe is kept under its own key so a whole probe never takes it).
  When no folder has that name every skill under the path is fetched,
  as before.
- with a path (a link to a folder, an update, a check for new skills
  under newBase) the list asked for is that folder's own, git's
  ref:path (treeUnder; a few KB instead of 11 MB, and small enough to
  be kept for a 304). When it can't be had (404, a ref git can't read
  that way, cut off) the whole list is read, which says for sure what
  is there, so goneFrom never trusts a 404. A rate limit is said at once.
- the fetcher kept one fetch per repository and ref for every skill of
  it. A fetch narrowed to one skill's folder is now kept to that folder
  (fetcher.get): another skill of the same repository gets a fetch of
  its own, where it was read as removed upstream (broken by hand below).
- a CC Switch skill being adopted looks in the whole repository, since
  its Path is only the folder's name.
- a probe of a folder whose skills are all too big lists it empty and
  names them, as before; the whole repository's still fails.
- GitHub's own truncated list is errTooBig, by path or not
  (TestTruncatedListIsTooBig).
- apiGet's client waits 2 minutes, not 20s, for an answer over 8 MB.

docs/subsystems/library.md says how far a big repository is fetched.

Tests (no network; fake codeload, API and raw):
- TestMarketSkillFromAHugeRepository: an 11 MB list, a download over
  the limit and skills over it together. The market installs one, raw
  is asked only for its files, and UpdateSkills of two of its skills
  updates both, each asking for its own folder's list.
- TestRepoTreeBigList, TestApiGetWholeAnswer: ye4241's.
- the fake trees in skilltree_test and skillnew_test answer git's
  ref:path as GitHub does (checked against api.github.com: HEAD:skills/
  clean-code lists that folder, HEAD:nonexist is 404).

Broken by hand, each red, then restored:
- apiGet back to the 8 MB cut with the error dropped: both
  TestRepoTreeBigList and TestMarketSkillFromAHugeRepository fail with
  "unexpected end of JSON input".
- no name narrowing: "the skills in vectorize-io/hindsight are too big
  to install".
- the fetcher sharing a narrowed fetch: Gone:[hindsight-docs].
- no ref:path list: the update listed ["HEAD" "HEAD"].

Run at this tree (65ee8c65c plus this change):
- gofmt -l internal: clean
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: clean
- go test -count=1 -timeout 45m ./internal/library/: ok 131s
- real: a throwaway realnet test in a sandbox HOME, no GitHub token,
  InstallMarketSkill("sickn33/agentic-awesome-skills", "clean-code"):
  installed in 15s, SKILL.md 5,202 bytes, Path skills/clean-code;
  UpdateSkill then took 0.6s through its folder's list. The same test
  at origin/main 65ee8c65c: "unexpected end of JSON input".

Not tried: the full ./... suite (only internal/library changed, other
sessions' suites were running); Windows and Linux runs (vet only); the
GUI (no GUI text changed); stablyai/orca for real.

Co-authored-by: ye4241 <ye4241@users.noreply.github.com>
2026-10-27 09:31:57 +08:00
yetoneandEdward4226 5b4da5bee3 proc: magpie on Windows finds fnm's node and npx (#2685)
What changed
- fnm puts its Node on a terminal's PATH from the shell profile
  (`fnm env | Invoke-Expression`), never in the registry, so magpie
  started from the Start menu had no node: a Library MCP server run by
  bare npx was "notfound", and one run by npx.cmd's full path (the
  reporter's C:\Users\...\fnm\aliases\default\npx.cmd, alone or under
  `cmd /c`) exited 1 with cmd's "'node' is not recognized", since the
  package npx fetched runs node by name.
- Windows UserPath (no-op before) adds the folder fnm's default alias
  names, after what PATH has. UserBinDirs (FindTool) gets each fnm
  Node: the default alias first, then installations newest by number.
- fnm's Windows layout, checked against Schniz/fnm master (config.rs,
  directories.rs, version.rs, fs.rs, commands/env.rs): root FNM_DIR,
  else etcetera's Windows data_dir\fnm (home\AppData\Roaming, APPDATA),
  else legacy ~\.fnm; versions in node-versions\<v>\installation with
  node.exe/npx.cmd directly in it (no bin on Windows); aliases\default
  a junction to an installation folder; the "system" alias points at
  Z:\_fnm_\..., read as none. XDG vars on Windows only move fnm's
  multishell links, not its versions. LOCALAPPDATA isn't used for them.
- The shared node-version helpers (nodeVersions, parseNodeVersion,
  nodeVersionLess, isDir) and addPath moved from the !windows files to
  nodever.go unchanged; fnmWin* there take home/APPDATA/FNM_DIR as
  arguments so the tests run them on every OS.
- The Library check (checkStdioAt, this machine only) starts a bare
  command PATH lacks from where proc.FindTool finds it and puts that
  folder on the child's PATH (stdioProgram, withPath), as the owner's
  plan on the issue said. Docs: agent-wiring.md, library.md.

Run
- macOS: go test -count=1 ./internal/proc/ ./internal/library/ ok
  (TestNoCommandBypassesProc and the other proc guards included);
  gofmt -l clean; go vet GOOS=windows/darwin for proc, library, cli,
  daemon; GOOS=linux vet proc, library and (-tags nogui) cli, daemon;
  GOOS=windows test binaries for proc and library build.
- Windows box (Win 11 x64), cross-compiled amd64 test binaries:
  TestUserPathFnmNode (real junction via mklink /J, npx.cmd that runs
  node by name) red on origin/main 4a1cd7765's code ("PATH after
  UserPath = [C:\windows\System32], want fnm's default alias"), green
  here; TestFnmWin* green.
- Real fnm 1.39.0 + Node v24.22.1 installed into a sandbox
  (USERPROFILE/APPDATA under C:\Users\yeton\fnm-2685, no FNM_DIR,
  registry PATH without node). A throwaway probe calling UserPath then
  library.CheckServer on chrome-devtools-mcp@latest:
  4a1cd7765: npx -> notfound; ...\aliases\default\npx.cmd -> exited 1;
  cmd /c ...npx.cmd -> exited 1 (the reporter's case).
  This commit: all three ok, 32 tools.
- Broken by hand: stdioProgram without FindTool ->
  TestStdioProgramFindsWhatPathLacks red; fnmWinBins without the
  default alias -> TestFnmWinBins red; Windows UserPath as before ->
  TestUserPathFnmNode red (above).
- Windows full proc/library binaries: TestNoCommandBypassesProc,
  TestGoneAgentListedToTakeOut, TestCheckMixedServerEachSide,
  TestCheckKeepsToolNames and TestRTKNoHookIssuesAreEachAgents fail
  the same with 4a1cd7765's binaries run the same way; the guard and
  two of them read the source tree, which a binary run outside a
  checkout doesn't have; the other two are in #1827.

Not tried
- The desktop GUI on Windows with the reporter's fnm (the probe runs
  the same UserPath and CheckServer calls the app does).
- magpie serve/web/tui on Windows don't call UserPath (as on macOS), so
  there an absolute npx.cmd still lacks node on PATH; a bare npx is
  covered by the check's FindTool.
- Agents magpie starts get the new PATH only from the GUI/daemon.

Refs #2685

Co-authored-by: Edward4226 <234070868+Edward4226@users.noreply.github.com>
2026-10-27 06:45:37 +08:00
vincent 27ca0bef53 library: the MCP Registry is asked with a budget of its own (#3043, shupivot)
The market's one client gave every request 20 seconds, and the Registry's
search answers in 13-37 s often enough (9 of the reporter's 33 tries past
13 s, 6 past 20 s, the slowest 37.3 s) that a search came back empty with
"context deadline exceeded" - twice in ten tries, nothing listed, and
nothing to do but type the same box again. The registry is asked with a
60 s client now, past its measured tail; skills.sh and the icons keep
the short one. The error that remains says what it is (SearchError, the
source named, #1589), the client's own seq guard keeps a slow answer
from overwriting a newer keyword's results, and what the market has of
its own still lists beside the failure.

Red before, on the baseline code with the shared client's timeout stood
in at a scale a test can wait for (the probe: list=0, "context deadline
exceeded (Client.Timeout exceeded while awaiting headers)" - the
reporter's error verbatim); after, the same slow registry answers and
the search lists freecad-mcp. A registry past even its own budget still
fails as a named SearchError (control).

Ported from skygunner's branch fix/mcp-registry-timeout (11d176bd7),
author kept; reported by shupivot.

Run at this head (a7072926d plus this commit): go test ./internal/library
-count=1 ok (181 s), gofmt -l clean, GOOS=linux and GOOS=windows go vet
-tags nogui ./internal/library ok. Broken by hand: fetchRegistry put back
on the shared client, both TestRegistry tests red ("context deadline
exceeded (Client.Timeout exceeded while awaiting headers)"), green again
with the fix. Real registry: three searches for freecad answered 200 in
0.8-1.3 s today, so the reporter's 13-37 s tail wasn't reproduced live;
the fake registry's delay stands in for it. Not tried: the GUI against a
slow registry (client.js's api() sets no timeout of its own).
2026-10-26 16:32:23 +08:00
yetone 758be6d14e library: magpie-setup is first in the market's skills, so an agent can set magpie up as asked
Leyuu_5 on X: "功能越来越多,感觉可以来个skill让AI来帮设置需求了". The skill
lives in magpie-community/plugins (skills/magpie-setup, e513644) and
teaches an agent to turn a request into magpie's own commands. Listing
it in featuredSkills puts it first under Library › Market › Skills,
official, one click to add, with no setup.

What was run at this head:
- go test ./internal/library ./internal/cli: ok (library's first run
  failed only with "no space left on device" while writing testlog.txt;
  run again on its own: ok 193.7s)
- TestFeaturedSkills extended: magpie-setup first, quota second, both
  Official/Featured with a description; "setup", "routing" and
  "gateway key" find magpie-setup first, "quota" finds magpie-quota
  and not setup. Red with magpie-setup taken out of the list.
- gofmt -l internal/: empty; go vet (darwin), GOOS=linux go vet -tags
  nogui, GOOS=windows go vet on internal/library and internal/cli; go build
- library.InstallMarketSkill("magpie-community/plugins", "magpie-setup")
  in a sandbox HOME against the pushed plugins repo: Installed
  [magpie-setup], SKILL.md in library/skills/magpie-setup.
Not run: the full ./... suite (the disk had under 1GB free), the GUI
suite (no GUI asset changed; market-featured-skill.test.cjs fakes the
list).
2026-10-25 19:34:55 +08:00
yetone 769355ab93 library: an MCP server's startup timeout reaches Codex as startup_timeout_sec, a hand-written one stays (#3168, miaomiaozi)
The Library's MCP server editor has a "Startup timeout" field (seconds),
shown when an agent that reads one is installed (AgentView.Startup; Codex
only). It is written to Codex's [mcp_servers.<name>] startup_timeout_sec,
user-wide and in a project's .codex/config.toml. Empty writes nothing, so
Codex keeps its own 30s, as before. The key and its unit are from Codex's
own source: RawMcpServerConfig in codex-rs/config/src/mcp_types.rs
(cb2581dae8de) has startup_timeout_sec: Option<f64> in seconds, and the
older startup_timeout_ms, which is read only when _sec is absent.

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

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

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

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

Not tried: a real Codex start that actually times out (codex exec needs
a signed-in account in the scratch home); the full ./... suite.
2026-10-25 09:41:32 +08:00
yetone 14b10f1166 library: an MCP server signed in to in Claude Code, in WSL too, says so instead of "needs sign-in" (CyberCaius on Discord)
CyberCaius signed in to a remote MCP server with Claude Code's /mcp in
WSL, and the Library still said 需要登录. The check connects as magpie,
without the agent's tokens, so an OAuth server answers it 401, and magpie
read no agent's own sign-in anywhere: not on Windows, not in a distro.

The check now reads each Claude Code target's .credentials.json, beside
the settings.json the target already has (readOwnSignIns,
mcp_agent_signin.go). A distro's Claude Code is a target under the
distro's home (wslTargetOf), so its file is read there through
\\wsl.localhost with no new setting. An mcpOAuth entry of the server's
name and URL with an access or refresh token, as Claude Code 2.1.310
counts one, names the agent in ServerHealth.AgentSignIn; the row says
"signed in in Claude Code (Ubuntu)" with the ok dot, and the tooltip says
magpie can't list its tools without signing in itself. An entry without
a token, another URL by the same name, and a file that can't be read or
parsed name nobody, so the row stays "needs sign-in". The tokens are
never sent or kept. A stopped distro has no target and isn't started.
On a Mac only the file is read, never the Keychain. The sign-ins are part
of the check's cache key, so a sign-in in the agent since isn't answered
from the session's earlier check. Strings in zh, zh-TW, ja and de.

Run:
- TestCheckNamesAgentsSignedInThemselves (internal/library): agent.FakeWSL
  forces the Windows+WSL switch (Ubuntu running, its home a temp root),
  sandbox HOME/USERPROFILE/XDG_CONFIG_HOME, CLAUDE_CONFIG_DIR cleared, a
  real httptest server answering 401 with WWW-Authenticate.
- Broken by hand, each red with a FAIL naming the behavior:
  - the old behavior (the reader names nobody): reading only this
    computer's Claude folder (claudeDir()) instead of the target's:
    "signed in in claude@wsl:Ubuntu, the check says {State:auth ...
    AgentSignIn:[]}".
  - counting an entry with no token: "a sign-in with no token counted".
  - leaving the sign-ins out of healthKey: "signed in on both sides, the
    check says ... AgentSignIn:[claude@wsl:Ubuntu]" (stale cache).
- library-mcp-health-wsl.test.cjs, chromium and webkit, en/zh/zh-TW/ja/de:
  red on the old client.js (expected "signed in in Claude Code (Ubuntu)",
  got "needs sign-in"), 12 of 12 after.
- gofmt -l (nothing); go vet on darwin, GOOS=linux -tags nogui and
  GOOS=windows for ./internal/library ./internal/gui; go build darwin,
  GOOS=windows and GOOS=linux -tags nogui ./...; go test -tags nogui
  -count=1 -timeout 45m ./internal/library ./internal/gui: ok (187s, 63s).
- GUI: library-mcp-health, library-mcp-health-wsl, mcp-signin-health,
  mcp-signin, mcp-oauth-app, library-mcp-tools, library-mcp-tool-switch,
  library-mcp-unshown, library-items, i18n-keys, gui-zh-tw, gui-ja,
  gui-de: 161 of 161 pass.
These ran first at a base before origin/main 1f589e3f4, then again at
this head (on 1f589e3f4): vet, builds, internal/library ok (149s), the 13
GUI files 161 of 161. internal/gui is red at this head on
TestCoreScriptBudget alone: app.js is 1321476 bytes, over 1321336. It is
the same on origin/main 1f589e3f4, from 2a8a17746 (this change doesn't
touch app.js, and its size is main's); #3367. The budget isn't raised.

Claude Code's file format was read from its 2.1.310 binary (td's key,
the token save's serverName/serverUrl/accessToken/refreshToken, $Ci's
"neither token is no sign-in").

Not tried: a real /mcp sign-in in Claude Code in WSL on the Windows box
(ssh to 10.0.0.132 timed out), and the full ./... suite. Not covered:
Codex's own MCP sign-ins (keyring, or a .credentials.json fallback whose
format wasn't checked against its source), #3508.
2026-10-25 00:03:52 +08:00
yetone c417b1f4e3 library: a skill removed from its source is said so, and every such skill goes in one click, asked first
スライム on Discord (#help, 10-22): taste-skills took some of its skills
out, Update all reported each of them as a failure, and the only way
out was to delete them one by one.

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

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

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

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

Not tried:
- the real taste-skills repo over the network
- the Windows box
- a skill CC Switch installed (Origin, adopt path), which still reports
  as a failure
- a GitHub check with a known commit, which keeps an existing gone
  mark but only marks gone after an update
2026-10-23 01:58:00 +08:00
yetone 75df6f4891 library: the git skill tests run again, with the machine's git found before the sandbox
Every test that builds a git repository (gitRepo in skillgit_test.go)
looked git up with exec.LookPath after sandbox() had replaced PATH, found
none and skipped with "git isn't installed". TestInstallFromGitRepo and
the rest of the kind-git tests were skipped on every machine and on CI.
realGit is now looked up once at package init, before any sandbox.

gitRemoved is a fixture helper the next commit's test uses: as a file's
body in a commit, it removes that path from the repository.

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

Not tried: the Windows box (Git for Windows on PATH is found the same
way).
2026-10-23 01:58:00 +08:00
yetone c2636b7b5b library: an MCP command given to agents in WSL is checked in their distro
loong on Discord, Windows host with agents in WSL: a stdio server whose
command is a WSL program (`node /home/loong/tools/xxx.js`), given only to
WSL agents, showed "exited (1) … Node.js v24.9.0" on the Library's MCP
page. The check started it on Windows, where his agents never do; a
sibling written as `wsl -d Ubuntu … node …` checked fine.

What changed:
- checkSides (mcp_check_wsl.go) reads each agent id's `@wsl:<distro>`.
  No WSL agent, not Windows, a Windows path for the command
  (windowsPath: magpie's own image server, `C:/x/npx.cmd`) or Settings'
  Detect agents in WSL off: this computer, as before. Otherwise each
  distro is a side, after this computer when an agent here has it too.
- In a distro the command is found as the agents' shell finds it
  (new wslrun.In: the same login-then-interactive probe Find uses, so
  nvm's node is found; cached for findAge) and started through
  wslrun.Tool.Command, the existing `wsl.exe -d D --exec /usr/bin/env
  PATH=… MAGPIE_WSL_RUN=… <path> args` path, so no new quoting. Its
  env goes over WSLENV (Tool.Env); its Cancel stops the run inside the
  distro.
- A distro that isn't running is never started for a check: Why
  "wsldown", naming it, painted as not checked (ring), like novar.
  Beside a side that was checked it is left out.
- Mixed: each side in turn, the first failure ends it. ServerHealth
  gains Checked (where it started, "" for this computer); the row says
  " · WSL Ubuntu" / " · Windows" on a failure, the tooltip "Failed in" /
  "Checked in". New strings in zh, zh-TW, ja, de.
- healthKey (Go and client.js) includes the sides, so agents moving into
  WSL is a check anew.
- docs/subsystems/library.md says all this.

Tests:
- TestCheckWSLOnlyServerInItsDistro: ok in Ubuntu with the exact wsl.exe
  argv; a stopped Arch is wsldown with no probe and no run; a command
  the distro lacks is notfound there.
- TestCheckWindowsServerHere: a Windows-only server checked here, WSL
  never asked; Windows-path commands stay here.
- TestCheckMixedServerEachSide: ok in both; WSL exit named Ubuntu's;
  Windows failure stops before WSL; stopped distro = checked here only;
  healthKey differs when agents move into WSL.
  All force wslrun.On and fake wsl.exe (Run) and the distro run
  (wslCommand runs this test binary as the fake server).
- library-mcp-health-wsl.test.cjs: chromium + webkit, en/zh/zh-TW/ja/de.

Broken by hand, each red:
- checkSides always this computer: WSLOnly and Mixed red.
- windowsPath exemption removed: WindowsServerHere red.
- mixed drops this computer: Mixed red.
- healthKey without sides: Mixed red.
- stopped distro reported as a failure: WSLOnly and Mixed red.
- client.js without the " · <place>" on a failure: the GUI test 12 of 12 red.

Run:
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- GUI: the 94 library-*/mcp-*/i18n-* files, both engines: 780 of 783;
  library-loading (webkit) and library-pick-remove (chromium zh-TW) red at
  --test-concurrency=4, load ~45, pass alone 3 of 3; filed #3300, #3299.
- Full suite at 3831de1a3 (base 1d1c5cf9c), go test -tags nogui -timeout 45m ./..., alone on the machine: every package ok, no FAIL (library 334s, gateway 515s, agent 394s).

Not tried:
- A real Windows + WSL run: the Windows box (10.0.0.132) didn't answer
  ssh. The argv is magpie's existing WSL launch path, unchanged.
- In a distro the command's cwd is what wsl.exe gives it (the Windows
  home under /mnt/c), not the Linux home an agent starts in.
- A Windows program reached from WSL by interop (npx.cmd under /mnt/c)
  given to WSL agents is skipped by the probe and can show notfound.
- A command the probe can't take as a plain name (spaces, quotes): an
  absolute path runs with the default PATH, anything else is notfound.
- A stopped distro beside an ok Windows side isn't shown on the row.
2026-10-23 01:00:44 +08:00
Edward4226 b91bcf2606 library: a standalone Windows rtk gets rtk's own upgrade action (#2006, Edward4226; LoKi)
An rtk.exe that no package manager installed (rtk's own Windows release
unzipped into %USERPROFILE%\.local\bin, say) had no upgrader, so the
Library page showed RTK's update with no usable Upgrade. LoKi
(lokic7123-star) hit it on v0.1.1285 and again on 0.1.1320; Edward4226
reproduced it and wrote this patch (his bc2056804, author kept).

rtkUpgrader now gives such an rtk.exe the rtk-windows-release action
(shown as "rtk's own Windows release"): on amd64, when winget's folders,
cargo's folder and winget's own records/winget list didn't claim it.
UpgradeRTK then takes RTKLatest's version, downloads checksums.txt and
rtk-x86_64-pc-windows-msvc.zip from rtk-ai/rtk's release through
source.DoOfficial, checks the zip's SHA-256 against checksums.txt, takes
rtk.exe out of it, writes it beside the old one and swaps it in with
steady.Rename, putting the old one back if the swap fails.

Changed from Edward's patch in review:
- The action no longer names a version: it read rtkLatest under the lock
  RTKLatest holds while it asks GitHub (up to ~16s), so ReadRTK, a page
  draw, would wait on it. UpgradeRTK already falls back to the last known
  version through RTKLatest.
- A winget that couldn't say whether it owns the rtk (timed out, failed,
  couldn't run) is no answer, not "not winget's": askWingetOwns now
  returns (yes, known); only winget missing, exit 0 without rtk-ai.rtk,
  or 0x8A150014 (no package) count as known-no. The winget arm above is
  unchanged (yes only when winget listed it). Without this, a winget
  timeout handed a possibly winget-owned rtk to the standalone path.
- Only a zip member named rtk.exe is taken (no "any .exe" fallback, which
  could pick rtk-proxy's), and an oversized one is refused rather than
  cut short.
- An aside (rtk.exe.old-<pid>) an earlier upgrade couldn't remove, because
  an agent was running that rtk, is removed on the next upgrade.
- The arch is a var (rtkArch) so the upgrader test runs on arm64 hosts
  instead of skipping; the redundant winget/cargo folder checks are gone
  (the switch's earlier cases already return for those).
- Two of the patch's tests failed as written on macOS (ReplacesBinary
  counted VERSION as a leftover; UpgradeRunsTheInstall compared the
  script rtkPath finds there with rtk.exe's text); both fixed.
- New tests: TestRTKWindowsStandaloneAsksWinget (no winget / unlisted /
  listed / failed / hung), TestRTKWindowsReleaseZipNeedsRTKExe, the
  arm64 case, and a stale aside in TestRTKWindowsReleaseSwapsTheFile.

Run at the cherry-pick on origin/main ef6f3749d, with these changes:
- gofmt -l internal/library: nothing. go vet ./... (darwin),
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok.
- go test -count=1 ./internal/library/ in a sandbox HOME: ok (207s).
  The full ./... suite was not run here; it runs in a combined suite.
  The last edit after that run was comments only (re-vetted).
- Red on the old code, each broken by hand and restored:
  - standalone arm returning nil (as origin/main has it):
    TestRTKWindowsStandaloneUpgrader "standalone: upgrader []; want
    rtk-windows-release" and TestRTKWindowsStandaloneAsksWinget
    "no winget: upgrader []".
  - winget's unknown taken as not-owned (Edward's semantics):
    TestRTKWindowsStandaloneAsksWinget "winget failed: upgrader
    [rtk-windows-release ...]; want none".
  - UpgradeRTK running the action as an installer:
    TestRTKWindowsReleaseReplacesBinary and ...UpgradeRunsTheInstall
    'exec: "rtk-windows-release": executable file not found'.

Real use on the Windows box (Windows amd64, sandbox USERPROFILE,
LOCALAPPDATA and APPDATA under C:\Users\yeton\magpie-2006-sb, PATH only
the sandbox .local\bin and System32; a throwaway driver calling ReadRTK
and UpgradeRTK, not committed):
- rtk.exe 1.0.0 from rtk's own release in .local\bin: ReadRTK showed
  latest 1.0.1, Upgrade "rtk's own Windows release"; UpgradeRTK fetched
  the real v1.0.1 release, `rtk --version` then said 1.0.1, the file's
  SHA-256 4f7ad08a...ed1e matches rtk.exe in the v1.0.1 zip, and the
  folder held rtk.exe alone.
- the same with the old rtk.exe running (rtk proxy ping -n 25): replaced
  to 1.0.1, rtk.exe.old-<pid> left while it ran; the next upgrade
  removed it.
- The library tests built for windows/amd64 ran on the box: the ones
  that don't need shell fakes pass (Upgrader, ZipNeedsRTKExe,
  ChecksumMismatch, Shown, UpgradeRunsTheInstall, SwapsTheFile).

Not tried:
- rtk's releases ship both rtk- and rtk-oss- editions; this always
  installs the default rtk- edition, as the sh installer path does, so an
  oss user upgraded this way gets the default edition.
- Windows on arm64: rtk has no arm64 Windows build; an arm64 magpie
  still offers no upgrade there. An amd64 magpie under emulation would
  take the amd64 path; not tried.
- A rtk.exe in a folder only an administrator can write (Program Files)
  fails with the write error; not tried.
- The GUI itself was not driven; the Upgrade text is ReadRTK's.

Co-reported-by: LoKi (lokic7123-star)

Full suite at this commit on 87d703c5c: set -o pipefail; go test -count=1
-timeout 45m ./... under the suite lock, every package ok (SUITE_EXIT 0).
2026-10-22 21:15:36 +08:00
yetone c358e76607 zcode: on Windows, write where ZCode reads, %HOME% before %USERPROFILE%
Gearclickist on Discord: magpie connects ZCode without an error, but
ZCode on Windows never lists magpie as a provider; on a Mac it does.

ZCode 3.14.3 (the same JS in the Mac and Windows builds, diff -rq of the
extracted app.asar) picks its data folder from setting.json's dataBaseDir,
then ZCODE_DATA_BASE_DIR, then process.env.HOME, and only then
os.homedir() (USERPROFILE). magpie used Go's home, which on Windows is
USERPROFILE. With HOME set (Git Bash, MSYS2, Emacs and the like), ZCode
reads %HOME%\.zcode\v2\provider_config.json and magpie wrote
%USERPROFILE%\.zcode\v2\..., a folder ZCode never opens. On a Mac HOME is
Go's home too, so the two always met.

appdir.ZCodeHome gives %HOME% on Windows when it is set, absolute, and
the folder asked about is USERPROFILE (a folder given on purpose is
kept). The agent target, the ZCode credential and team readers and the
library target use it. ZCode's CLI database stays under USERPROFILE (seen
on Windows below), so the sessions reader is unchanged; its comment says
why.

Run:
- go test ./internal/agent/ -run TestZCode; the new
  TestZCodeOnWindowsUsesTheHomeZCodeReads forces zcodeOS=windows with
  HOME and USERPROFILE apart. Broken by hand (ZCodeDataIn(home) back in
  zcode()): red, "ZCode's folder on Windows with HOME set: .../001/.zcode
  ... want .../003/.zcode".
- gofmt -l; go vet for darwin, linux (-tags nogui) and windows.
- Windows box, sandbox folders only, HOME and USERPROFILE set apart:
  ZCode 3.14.3 for Windows, extracted and started there, kept its logs,
  workspace and provider_config.json under HOME\.zcode\v2 and only
  cli\db under USERPROFILE. The old magpie.exe's `zcode provider magpie`
  wrote profile\.zcode\v2\{config,provider_config}.json (the bug); this
  build's wrote home\.zcode\v2\..., beside ZCode's own files, and nothing
  under the profile.
- Full suite (go test -timeout 45m ./..., one at a time on the box):
  68 packages ok, exit 0, at d87be7f13 and again after rebasing onto
  b00c82acf (tree of this commit).

Not tried: the reporter's own machine (their HOME is inferred, not
confirmed); ZCode's picker on the Windows box (it ran over ssh, without
a desktop, and exited with the session), so "lists magpie" is read from
where ZCode keeps its files, not seen; the provider and library siblings
have no forced-OS test of their own; ZCODE_DATA_BASE_DIR and
ZCODE_DESKTOP_HOME_DIR are not followed.
2026-10-22 04:32:46 +08:00
yetone e656888867 library: Library → Instructions gives Devin its global AGENTS.md (#3151, eqe365 on Discord)
eqe365 on Discord (#3151): Devin CLI reads AGENTS.md, but Library →
Instructions listed Devin as keeping no user-wide instructions file.
Devin's target had Skills and MCP and no Instructions.

Source: the docs Devin CLI 3000.11.92 ships with it,
share/devin/docs/extensibility/rules.mdx ("Rules & AGENTS.md" → Global
Rules). It reads global rules from ~/.config/devin/AGENTS.md
(%APPDATA%\devin\AGENTS.md on Windows) at the start of every session, and
the singular AGENT.md there too. Devin's folder (a.Dir) is already that
folder, so Instructions is AGENTS.md there, or AGENT.md when only that
one exists (firstThere). The GUI is data-driven and needs no change.

Test: TestDevinInstructions (internal/library/agent_skills_test.go)
checks:
- the target is AGENTS.md before the file exists;
- Save writes the shared block after the user's own text;
- with only AGENT.md present, that file is the target.
With targets.go reverted it fails: "Devin's instructions: "", want
.../.config/devin/AGENTS.md before the file is there".

Run with this change on origin/main ba319a758 (before the rebase),
set -o pipefail, GOMODCACHE pinned:
- gofmt -l: clean.
- go vet ./..., GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet ./...: all clean. darwin, linux nogui and windows builds: ok.
- go test -timeout 45m ./...: 66 packages ok. Two timed out at 45m
  while the machine's load average was 24 to 60 (other sessions'
  suites):
  - internal/library (2724s; TestCheckSkills had been running 6s at the
    deadline). Alone at -timeout 90m it is ok in 2204s. This is #2853.
  - internal/agent (2714s). It doesn't import internal/library, so it
    runs the same code as origin/main. This is #2544.
- Packages that import library are ok: backup, cli, davsync, gui,
  profile, tui.
- No GUI files touched.

Not tried: a real Devin session reading the file; the claim rests on
Devin's own shipped docs.
2026-10-21 18:05:03 +08:00
yetone 0f044e9447 plugins: a GITHUB_TOKEN GitHub refuses is dropped for anonymous requests, not shown as an error (till on Discord)
till's Plugins page said "无法连接 GitHub: GitHub refused GITHUB_TOKEN
(no GitHub token is set in Settings → Network and sharing)". ghtoken.Token
falls back to the environment's GITHUB_TOKEN / GH_TOKEN, and a stale one
there made every GitHub read fail, though GitHub serves the same reads
without a token.

ghtoken.Do now sends a GitHub API request with the token. When the token
came from the environment and GitHub answers 401, it remembers that token
as refused for the rest of the process (Token() skips it, so GH_TOKEN is
still tried after a refused GITHUB_TOKEN, and Settings no longer shows it)
and asks once more without Authorization, returning that answer. A token
set in Settings is never dropped: its 401 is still Refused()'s error. An
anonymous rate limit after the drop is said by LimitedBy as before.

Every caller goes through it: plugin fetchJSONFrom (tagged-repo search,
git plugin checks, githubHead) and getURLFrom (Bun), and library apiGet,
skills fetch, skilltree fetchBlob and latestRTK via doGitHub.
internal/davsync/github.go stays strict: its token is the one the user gave
sync to write a private repo, outside ghtoken, and an anonymous retry can't
write there, so it would only hide why sync failed.

Tests (httptest only): ghtoken_test covers an env token refused then asked
again without, not sent again (and GH_TOKEN tried next), a Settings token
refused stays an error, an env token refused then an anonymous rate limit
is reported, and another host untouched. plugin TestTaggedReposStaleEnvTokenDropped
is till's case: TaggedRepos with GITHUB_TOKEN=stale-till lists 7 repos, no
error. github_token_test and library TestGitHubRateLimitSaid now expect the
env token dropped and the Settings token still refused.

Broken by hand, each red: (a) no anonymous retry: every new env test, the
plugin and library tests red, and TestTaggedReposStaleEnvTokenDropped shows
till's exact error; (b) no memory of the refusal: NotSentAgain, the plugin
and library tests red; (c) a Settings token also retried:
SettingsTokenRefusedStaysAnError, the plugin and library tests red.

Run on the commit before the rebase (base 9b04c4e20):
- gofmt -l: clean. go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
- set -o pipefail; go test -timeout 45m ./... at load ~30: 62 packages ok.
  agent, gateway and library ran past 45m while still progressing; gui
  failed TestSetAnswersWhileDevinAndProvidersHang (set took 10.26s, #1375)
  and TestMainWindowCorners (measuring killed, #1936/#2645); provider failed
  TestPluginPicksComeBackWithTheirList (#3051, fixed on main in c922225f1).
- Each rerun alone at load 21-56: library ok 809.7s, provider ok 308.8s,
  gui ok 159.5s, agent ok 1673.3s, gateway ok 780.4s.

After rebasing onto a3ebed202 (main moved 8 commits): gofmt -l clean; go vet
darwin, linux -tags nogui, windows clean; go test -count=1 at load ~57:
ghtoken ok 2.9s, plugin ok 277.6s, library ok 144.2s.
2026-10-21 06:16:31 +08:00
yetone 4ef718651f library: InUse answers while a sync holds the library's lock
#2774: the macOS window stayed white at start. The window waits on
boot.js before it paints, and boot.js asks library.InUse through the
built-in plugins. InUse took the library's mu, which a sync holds for
its whole run: 13-16s on the reporter's Mac, with many agents and
skills. InUse only reads library.json, and save replaces that file whole
(edit.WriteAtomic), so InUse now reads it without mu. A read beside a
sync sees the file from before or after one of the sync's writes, never
half of one. A file that can't be read is still an error, never 0.

TestInUseAnswersWhileASyncHoldsTheLock holds mu and expects InUse to
return 3 within 5s. It also expects a half-written file to be an error.
With the lock put back by hand, it goes red:
  --- FAIL: TestInUseAnswersWhileASyncHoldsTheLock (14.32s)
      inuse_unlocked_test.go:36: InUse waited on the sync's lock

The sandbox cold start measured for this work has a short library sync,
so boot.js came at about the same time before and after (4527ms against
4822ms after listen at ~4s). The reporter's 13-16s sync wasn't
reproduced here.

What was run (worktree at 9fd80b212 plus this change and the commits
before it):
  gofmt -l internal/: nothing
  go vet ./internal/library: exit 0
  GOOS=linux go vet -tags nogui ./...: exit 0
  GOOS=windows go vet -tags nogui ./...: exit 0
  go test -timeout 45m -count=1 ./internal/library: ok 1220.249s
2026-10-20 20:23:56 +08:00
yetone 7916045591 library: RTK's tag for Grok Build and Grok App gives their own reason and rtk-ai/rtk#2136, not DeepSeek Harness's (新v学员 on Discord)
Every agent RTK has no hook for got dsh's tooltip on the RTK tab: "{agent}'s
hooks can only allow or deny a command, not change it" with
rtk-ai/rtk#3847 ("FR: Support DSH"). For Grok Build that is wrong twice:
the issue is dsh's, and Grok's PreToolUse hooks can rewrite a command
(updatedInput, shown on rtk-ai/rtk#1890). What holds is that rtk init has
no Grok agent (src/hooks/init in rtk v1.0.1 has none), and
rtk-ai/rtk#2136 is the open request for Grok Build (#4513 was closed as
its duplicate). Each link was checked with gh issue view; the others in
rtk.go (#3847, #3934, #4311, #3898, #4187, #3404) are right.

rtkNoHookWhy in plugins/library/client.js gives each agent its own reason:
dsh keeps its text and #3847, Grok Build and Grok App cite #2136 (Grok App
runs Grok Build), and an agent with no entry gets a reason with no link.
New strings in zh, zh-TW, ja and de. rtk.go's grok and grok-app reasons,
which the CLI shows, cite #2136 too.

TestRTKNoHookIssuesAreEachAgents fails when an rtkNoHook agent has no page
reason (or the reverse), when the page and rtk.go cite different issues,
when two agents cite the same issues without a reason in sharedRTKIssues,
or when the fallback carries a link. library-rtk-nohook.test.cjs checks
Grok Build's tag says #2136 and never #3847, DeepSeek or "hook".

Run in a worktree rebased on origin/main 16327872c, sandbox HOME, caches
pinned:
- Broken by hand: with the old client.js the new test fails "client.js has
  no rtkNoHookWhy: the no-hook tag isn't per agent"; with Grok's page link
  set to #3847 it fails "dsh and grok both cite [rtk-ai/rtk#3847]: one's
  reason was copied onto the other". Restored, it passes.
- gofmt -l on the changed Go files: empty. go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./...: ok. go build, GOOS=linux
  go build -tags nogui, GOOS=windows go build: ok (before the rebase).
- GUI: i18n-keys plus all 39 library-*.test.cjs, Chromium 351/351 and
  WebKit 351/351.
- set -o pipefail; go test -timeout 45m ./... at load ~500-650: 60
  packages ok; 4 red, none in the code changed here, each already filed:
  internal/agent timed out at 45m (#2544), internal/gateway timed out at
  45m (#2870), internal/gui TestSetAnswersWhileDevinAndProvidersHang
  10.4s set under load (#1375), internal/library
  TestCheckStdio/timeout_ends_the_tree (#2765). go test ./internal/library
  -run 'RTK|TestCheckStdio' then passed (136.9s).
- Not tried: the real app with a real Grok Build install; the change is
  tooltip text and links only.
2026-10-20 04:13:35 +08:00
yetone 9fd80b2128 library: skills install from any git repository, GitLab and a company's own among them (sunset on Discord)
ProbeSkills took only a GitHub source or a folder. It now also takes any
git repository's address: https/http on gitlab.com or a self-hosted
server (any depth of groups), a GitLab or Gitea page of a folder
(/-/tree/<ref>/<path>, /-/blob/..., /src/branch/...), ssh://,
git@host:group/repo.git, a bare host.name/group/repo, and file://.
Such a source is kind "git" (gitSource, skillgit.go).

It is fetched with the user's own git (proc.FindTool), so their
credential helpers and SSH keys reach an intranet host: git init, then
fetch --depth 1 --no-tags -- <url> <ref|HEAD>, checkout FETCH_HEAD into
a magpie-skill-* folder, .git removed; the same keepProbe/maxFetch path
GitHub's tarball takes.

What the user typed is data: an address starting with - and any
transport:: address (ext::, fd::, file::) are refused before git runs;
the address follows --; git runs with protocol.ext.allow=never and
core.symlinks=false, no shell, GIT_TERMINAL_PROMPT=0, and ssh -o
BatchMode=yes unless the user set their own SSH command (GIT_SSH,
GIT_SSH_COMMAND, core.sshCommand), so a sign-in it can't make fails
instead of waiting. An address with a password or token in it is
refused: library.json is shown and backed up. Git missing, a sign-in
refused, an unknown host key, a missing branch and an unreachable host
each say so plainly (gitError).

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

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

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

Run (worktree at origin/main 224ea7d5b, machine load average ~120-145
from other sessions):
- gofmt -l: clean. go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
  clean.
- set -o pipefail; go test -timeout 45m ./...: 63 packages ok; one red,
  internal/agent TestFolderVarsAreListed (GIT_SSH vars), fixed above
  and rerun alone: ok.
- After later edits, rerun ./internal/library ./internal/cli
  ./internal/tui ok; internal/gui TestMainWindowCorners red once at
  load 144 (76.5s, AppKit window test this change doesn't touch),
  passed alone (28.6s); internal/agent timed out at 45m in that
  combined rerun at load ~140 (it ran 962s in the full run) and passed
  alone (1808s, load ~100).
- GUI: the 88 test files that load the library page, chromium and
  webkit: 1420/1420 pass; skill-git-source + skill-update-edited rerun
  after the last client.js edit: 20/20.
- Real use in a sandbox HOME (GIT_CONFIG_NOSYSTEM=1): a local bare repo
  over file:// probed, installed, checked current, a new commit found as
  update, updated to v2; ext:: and --upload-pack refused with nothing
  run; https://gitlab.com/gitlab-org/ai/skills probed (52 skills), its
  /-/tree/main/skills/glab installed and checked current; a private
  gitlab.com address said "git couldn't sign in to gitlab.com ...".
- Not tried: a real self-hosted GitLab with credentials, ssh:// against
  a real host, Windows.
2026-10-19 18:16:57 +08:00
yetoneandggbdpq f191d6423b agent, library: a dsh patch list that opens with a YAML document start marker is edited, the marker kept (#2667)
What changed
- dshParse (internal/agent/dsh.go) and dshRead (internal/library/dsh.go)
  let a patch list open with "---", YAML's document start marker, where
  before they failed the file as "not a list of entries magpie can edit".
  The marker goes in the head and is written back with it.
- The marker counts only at the left edge, with at most a comment after it,
  and only before anything but blank and comment lines. A second "---"
  (a second document), one after the first entry, an indented one, "----",
  "--- x" or one after "[]" still fail the file instead of being kept as
  if they were the list's. ggbdpq's patch took a bare "---" anywhere before
  the first entry, so "---\n---\n- a" (two documents) was edited as one list.
- The only line-scanning YAML readers with this check are these two; the
  rest go through yaml.v3 (edit.GetYAMLTop/SetYAMLTop read node lines and
  take a leading --- already).

Run (macOS arm64, go1.26.8, load average 130-270 from other sessions)
- New tests: TestDshDocStart and TestDshDocStartOnlyFirst (agent),
  TestDshDocStartPatchList and TestDshDocStartOnlyFirst (library). The
  #2667 fixture is the reporter's bytes.
- Broken by hand, each red: marker never taken (all four red with the
  reported error); no only-once guard (both OnlyFirst red on
  "---\n---\n- id: a"); library alone reverted (library red, agent green);
  anything after "--- " taken (both OnlyFirst red on "--- x").
- gofmt -l: clean. go vet ./... (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./...: clean.
- go test -tags nogui -timeout 45m ./... under set -o pipefail, sandbox
  HOME, at 244538d6d (this change on 9f9bfc160): 64 packages ok; red were
  only internal/agent and internal/gateway at the 45m timeout, with no test
  failing (#2544, #2108). Rerun at the same head with -timeout 110m:
  internal/agent ok 2112s, internal/gateway ok 1817s.
- Rebased onto 17557132c (7 commits, none in the dsh files or internal/edit):
  go build -tags nogui ./..., go vet -tags nogui on agent and library, and
  -run TestDsh in internal/agent and internal/library rerun, ok. The
  full suite was not rerun on that base.
- An earlier full run on 7660399a1 also had internal/middleware
  TestOnUsageRows "strategies.seen: took too long" under load (filed #2687;
  ok alone in 2.9s) and TestPluginStreamLargeReplies client timeouts (#2551).
- Not run: the GUI suite (no GUI change); a real dsh binary.
- Found on the way, filed, not changed here: edit.BlockList drops block
  entries after a root flow list ("[]\n- id: a" -> "[]"), #2674.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-17 18:51:53 +08:00
yetone dccfefdf72 library: a skill brought in from an app's versioned folder follows the app's updates (#2635)
iomect's ego lite keeps its skill in a framework version folder and
points its own links at the current one:

  ~/.agents/skills/ego-browser -> ~/.local/share/ego/ego-skills
  ~/.local/share/ego/ego-skills -> ~/.local/share/ego/active_version_dir/Resources/ego-skills/ego-browser
  ~/.local/share/ego/active_version_dir -> /Applications/ego lite.app/.../Versions/0.6.0.12
  .../Versions/Current -> 0.6.0.12

ImportSkill linked the library to the fully resolved folder
(Versions/0.5.1.13/...). After the update to 0.6.0.12 the old folder was
still there, so the library and every agent it gives skills to kept the
old skill.

importSkill now links to linkVia(f.at, f.real), and Source.Dir is that
same path. linkVia follows the found entry's links one at a time, and
stops at the first one outside every skills folder (the agents', the
shared ~/.agents/skills and the library's): for ego that is
~/.local/share/ego/ego-skills, which the app keeps pointing at its
current version. A Versions/<v> part is named Versions/Current when
Current is a link to that same version, which covers an entry that links
straight into the versioned folder. If that path doesn't resolve to the
same folder as today, linkVia returns the resolved folder, as before.
Nothing else changes: every comparison of Source.Dir already goes
through realDir.

Tests (skill_version_test.go):
- TestImportedSkillFollowsAppUpdate uses the reporter's layout
  (ego lite.app, ego Framework.framework/Versions, active_version_dir,
  ego-skills, ~/.agents/skills/ego-browser), brings it in at 0.5.1.13,
  then moves the app's links to 0.6.0.12 and checks the library's skill
  is 0.6.0.12's, listed and not missing.
- TestImportedSkillThroughVersionsCurrent does the same with an entry
  linking straight into Versions/0.5.1.13.
- TestImportedSkillPlainLink checks that a link to a plain folder is
  still linked to that folder.

Broken by hand:
- with `via := f.real` (the old link), FollowsAppUpdate and
  ThroughVersionsCurrent went red (the skill stayed "ego 0.5.1.13");
- with the Versions/Current step taken out, ThroughVersionsCurrent went
  red.

Not done: a skill brought in before this keeps its old resolved link
until it is brought in again, or its link in the library is replaced.
No ego install here; the tests use the layout from the reporter's ls.

Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows
go vet -tags nogui ./... clean. go test -timeout 45m ./... under
set -o pipefail with a sandbox HOME, load ~280: 65 packages ok
(internal/library 352s), internal/gui red with 8 real-window AppKit tests
killed at their deadlines (#2645). internal/gui doesn't use this code.
It passed alone with the real HOME, with this change (186s at load
~260-341) and on 8bb9375e7 without it (204s at ~300). With the sandbox HOME
it went red again when run alone; the runs are on #2645. No GUI files
touched.

Rebased onto ebf3f48f7, which changes nothing under internal/library or
internal/agent; go build ./... and go test ./internal/library ok there
(697s).
2026-10-17 11:01:48 +08:00
yetone 8bb9375e74 library: another app's MCP server in an agent's config is offered to bring in, not taken for the agent's own (#2635)
iomect's Codex server, written in ~/.codex/config.toml as

  [mcp_servers.netcatty-external]
  command = "/Applications/Netcatty.app/Contents/Resources/app.asar.unpacked/electron/cli/netcatty-external-mcp"
  args = []
  env = { NETCATTY_EXTERNAL_MCP_DISCOVERY_FILE = "…" }

never showed under the Library's servers found in agents. The TOML was
read correctly; the cause was appOwned. It marked any command under a
".app/Contents/" as one the agent's app writes itself (Codex's node_repl
and cua_repl, 0f9d60db0). The page leaves such servers out of the list to
bring in (client.js: foundServers.filter(f => !f.own)).

appOwned now takes the agent and counts only the agent's own install:
an .app bundle or WindowsApps package whose name has the agent's id or
name in it (Codex.app, "Codex Computer Use.app", OpenAI.Codex_…), plus
Codex's runtimes and cua_node folders for Codex. Netcatty.app in Codex's
config is now a found server like any other.

TestFoundServerFromAnotherApp uses the reporter's TOML as given, with the
**** placeholder in the path. It checks the found entry's command, empty
args, inline env and agent, and that Codex.app's computer-use is still
Codex's own. The existing TestFoundServersAppOwned and
TestRemoveFoundServerOwn pass unchanged.

I put the old ".app/contents/" match back by hand and
TestFoundServerFromAnotherApp went red (netcatty-external Own: true).

The issue's second part, imported skills not following an app update
(ego lite's Versions/0.5.0.13 -> 0.6.0.12), isn't in this commit.
ImportSkill links the library to the found skill's fully resolved path
(f.real). Whether ego links into Versions/Current or rewrites a
versioned link on update isn't known yet, so the issue asks the
reporter, and stays open.

Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows
go vet -tags nogui ./... clean; go test -timeout 45m ./... at 7154fe61c, set -o pipefail: 66 packages ok, exit 0 (internal/library 372s under load ~280; internal/gateway cached from the run for d4a1b9baa, same code). No GUI files touched.
2026-10-17 09:39:47 +08:00
yetone 9228bd443f library: skills are grouped by source when the skills CLI keeps its lock under $XDG_STATE_HOME (@_yukirock on X)
skills 1.7 writes its global lock to $XDG_STATE_HOME/skills/.skill-lock.json
when that variable is set, and only to ~/.agents/.skill-lock.json otherwise.
The Library read only the ~/.agents one, so with XDG_STATE_HOME set every
`npx skills add` skill had no repository and the "By source" view could not
group them. Both locks are now read, the XDG one winning per skill, since a
lock written before the variable was set still names older skills.

XDG_STATE_HOME joins agentenv.Vars, so the desktop app takes it from the
login shell like the other folder variables (TestFolderVarsAreListed).

Not handled: a project install's ./skills-lock.json.

Run (worktree at origin/main 1eba266a9 plus this change):
- TestSkillRepoFromXDGLock: red on the old lock() (grill-me "", tdd
  "stale/repo"), green after.
- go test -p 2 -tags nogui -count=1 -timeout 45m ./...: 66 packages ok.
  The first run had TestFolderVarsAreListed red (fixed here) and
  TestMaxRPMWaitsForRoomInTheMinute red under load, the open #1791; the
  rerun had both green.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet clean.
2026-10-17 01:22:21 +08:00
yetone 61ca3924cb library: a pasted "npx skills add owner/repo --skill x" reads as its repo
The skills page's add field now takes the command a skills page offers
to copy (npx, bunx, pnpx, pnpm or yarn dlx, bun x, with -y, --skill and
--agent flags) and installs from the repository it names (RockyShowlle
on X). Anything else is used as typed.

Run at base 78827954f with both changes:
- Full suite: go test -p 2 -tags nogui -count=1 -timeout 45m ./... ok in 66 packages, no FAIL.
- gofmt -l is clean, and go vet passes for GOOS=linux and GOOS=windows.
- Broken by hand: with the change disabled, TestPastedRepoBindsSameCopy and TestSkillsCommand are red. Restored, they are green.
- Not tried: a real npx skills install, or a real repo paste in the GUI.
2026-10-16 21:46:44 +08:00
yetone 83f3316cfe library: a pasted repo binds a skill copy identical to its own, so it updates
When a skill in the library is a copy whose every file matches the
repository the user pastes, it is now bound to that repository, as if it
had been installed from there. Before, it was only grouped under the repo
and never updated (RockyShowlle on X). A copy that is linked from
elsewhere (npx skills, a git checkout) or that was edited stays grouped
only.

Run at base 78827954f with both changes:
- Full suite: go test -p 2 -tags nogui -count=1 -timeout 45m ./... ok in 66 packages, no FAIL.
- gofmt -l is clean, and go vet passes for GOOS=linux and GOOS=windows.
- Broken by hand: with the change disabled, TestPastedRepoBindsSameCopy and TestSkillsCommand are red. Restored, they are green.
- Not tried: a real npx skills install, or a real repo paste in the GUI.
2026-10-16 21:46:43 +08:00
yetone ea3babac89 library: TestSkillRelinkKeepsUnreadableCopy holds under load, where the library skill's hash is remembered past its chmod
Red in a full run at 63be47717 under load avg ~280 (8.46s):
  skill_how_test.go:163: problems: [{Agent:claude What:skill:pdf
  Error:open .../src/skills/pdf/blocked.txt: permission denied}]
It passed alone 3 of 3. The cause is the hash memo (treememo.go,
3a80ce7fa, #541): a folder whose newest file is older than settleFor
(3s) has its hash kept against a stamp of place, type, size and time,
not mode, by design (TestPageReadDoesntReadUnchangedSkillsAgain relies on
a chmod not re-reading). On a loaded run more than 3s passed between
writing src/skills/pdf and SetSkillHow, so relink's
hashDir(realDir(skillDir)) under /private/var hit the remembered hash,
while the test's own "unreadable file prevents hashing" check hashed
the /var spelling, never memoised, and read "".

Injected: age(src) and a hash of realDir(skillDir("pdf")) before the
chmod reproduces the exact red on every run. The test now ages and
hashes the library skill first (the loaded case, always), rewrites
blocked.txt's time as it makes it unreadable, and checks hashing fails
at realDir, the path relink reads. Without the time rewrite it goes red
at the precondition ("the unreadable file didn't prevent hashing"); with
it, -count=3 passes. No product code changes.

Run: go test ./internal/library -count=3 -run TestSkillRelinkKeepsUnreadableCopy
ok; go test -timeout 45m ./internal/library ok (1172s, load ~240);
gofmt -l clean; go vet ./internal/library darwin/linux/windows ok.
Full suite: set -o pipefail; go test -timeout 45m ./... at 63be47717
plus the min bump, sandbox HOME, load avg 240-297 from other sessions'
test binaries: 63 packages ok, internal/provider (changed) 1210s; red
were internal/library (TestSkillRelinkKeepsUnreadableCopy, fixed in
the library commit, package ok after in 1172s) and internal/agent and
internal/gateway, which hit the 45m timeout in that run and in two
reruns each, with no "--- FAIL" in any of them; each timeout's stack
shows one test a few seconds in (TestWSLTargets, TestReasonixEffortAndSync,
TestCodexSwitchOnlyKeepsCodexOffTheGateway; TestLoopGuardLeavesOrdinary-
RepliesAlone, TestReplyNamesMember), so slow under that load, not hung.
One gateway rerun didn't build: a shared GOCACHE entry was deleted
under it; the next used its own cache. Neither package imports the
changed test file; gateway imports provider for the string only. The
tag waits for CI's attempt-1 Test run.
2026-10-16 18:38:31 +08:00
yetone 6b3ee5a03b library: a repository that keeps its skills again under a plugin's folder lists each once (碳碳双键 on Discord)
tw93/waza keeps its eight skills in skills/ and again in
plugins/waza/skills/. Some of the plugin copies lag the top ones.
Typing "tw93/waza" in Library → Skills listed "16 skills", each one
twice. unhiddenFirst only folded a copy in a hidden folder (.claude/
skills, #1964) into the unhidden one; two unhidden copies both stayed.

It now keeps one copy of each skill. It prefers the copy outside hidden
folders, then the one fewest folders deep, then the first. That covers
both candidates (the probe and install) and skillDirsIn (the new-skill
check).

Run:
- TestRepoWithAPluginCopyListsEachSkillOnce uses waza's real paths.
  Against the old skills.go it is red (9 lines: 16 candidates, the
  plugin's descriptions, 16 tree dirs); with the fix it is green.
  TestMarketInstallsASkillKeptInClaudesFolder (#1964) is green too.
- Real use: ProbeSkills("tw93/waza") against GitHub in a sandbox HOME
  lists skills/check … skills/write, 8 in all, each once.
- gofmt -l clean; go vet -tags nogui ./... clean for darwin, linux and
  windows.
- Full suite: go test -timeout 45m ./... at load average ~115 (other
  sessions' suites). 63 packages ok. internal/agent and internal/gateway
  timed out at 45m with no test hung (TestOpenCodeAndCrushKeep… and
  TestStrictAffinity… had each run 0s), and go list -deps shows that
  neither imports internal/library. internal/gui's
  TestPanelJoinsFullScreenSpaces is #2450, red on main already.
2026-10-16 15:35:20 +08:00
yetone a80bc30092 agents: the Cursor editor's ~/.cursor is no Cursor CLI
The editor makes ~/.cursor on its own, so the folder alone says nothing
of cursor-agent (dirShared): cli-config.json or the command finds Cursor
CLI. The Library still writes the MCP servers and skills the editor reads
there when only the editor is here (SharedHere).

Run at this head before the rebase onto 0f391a7a7: go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME, every package ok; gofmt -l clean; go vet clean for darwin, linux (nogui) and windows; GUI files agent*, i18n*, gui-*, getting-started, library*, sess* and import-row in both engines: 1638/1638.
2026-10-16 05:10:43 +08:00