Commit Graph
161 Commits
Author SHA1 Message Date
yetone 4794de398e library: a skill installs from a repository too big to download whole, by fetching only its skills' folders (#1941, Goalonez)
What changed: fetch still downloads a repository as one codeload
tarball first. When its files pass the 200 MB limit (untar's errTooBig),
it now falls back to fetchSkillFiles: one request to GitHub's API for
the repository's file list (git/trees?recursive=1), then every file in
a folder with a SKILL.md, from raw.githubusercontent.com, each checked
against the git hash the list gives. The repository's folders are made
empty, so candidates, origin, a probe of a subfolder and an update check
read the result as they read a whole download. The 200 MB limit now
applies to what is actually fetched: skills that are themselves over it
still say so. A private repository's files come from the API's
git/blobs with the Settings token (it never goes to raw). A repository
found too big is remembered for the run, so the install after its probe,
and update checks, don't download 150 MB again before falling back.
gitTree's entries gained mode, sha and size (named gitEntry).

Why: vectorize-io/hindsight keeps its skills (a few hundred KB) beside
an app; its tarball is 188 MB gzipped, 253 MB unpacked, so any skill
in it failed with "the repository is too big to install skills from".

What was run:
- Real repo, sandbox HOME, no token: on the old code ProbeSkills
  ("https://github.com/vectorize-io/hindsight") fails with "too big"
  after 34s. With the fix it lists all 15 skills (skills/*, the
  integrations' skills; .claude/skills hidden as before) in 32s, and
  installing skills/hindsight-docs writes its 160 files, the same count
  GitHub's tree lists.
- New TestSkillsFromATooBigRepository and
  TestTooBigRepositoryChecksWhatArrives (httptest stand-ins for codeload,
  the API and raw, laid out as hindsight is, paths and tree entries
  from its real listing). With the fallback taken out both fail with
  "the repository is too big to install skills from (over 200 MB)".
  They check raw is never asked for a file outside a skill, codeload
  is asked once across two probes, a file that doesn't match its hash
  is refused, and skills over the limit themselves still error.
- go test -tags nogui ./internal/library (ok, 141s); -race -count=10
  -run TooBig (ok); gofmt -l clean; go vet, GOOS=linux and
  GOOS=windows go vet -tags nogui ./internal/library clean.
Not tried: a private repository over the limit against real GitHub
(covered only by reading: raw 404 -> git/blobs with the token).
2026-10-13 14:53:42 +08:00
wizzy-yang e0a3b8c60a library, plugins: the RTK page and the Installed plugin list open without waiting on the package manager or the plugins' vendors (#1178)
The Library's RTK page took ~3.9s to open and the Plugins page's
Installed list ~2.2s, every time.

- Installed named each plugin's subscriptions from plugin.Providers,
  the whole providers RPC: each plugin in turn fetching its vendor's
  model list. The page uses only the names, which plugin.Cached keeps
  without starting the host (refreshed in the background when a sign-in
  or the plugins change). It now reads those: 2.2s to 13ms with seven
  plugins. A plugin added a moment ago has no names yet, so its row no
  longer claims it "signs in to nothing magpie can use" until the
  plugins have answered (plugin.Answered, the row's named).
- ReadRTK waited up to 3s for GitHub and the package manager; winget
  show refreshes its sources and takes ~7.7s, so every open waited the
  full 3s and #1025's "waiting for winget" tag never came from it.
  GitHub stays on the first read; the package manager is asked in the
  background, its answer kept 6 hours as before. 3.9s to 1.6s.
- ReadRTK and SetRTK detected the agents twice per call; once now.

wizzy-yang's PR head 12342aa3, which conflicted with main: plugins.go
keeps main's clash rows (plugin.Clashes) with the names from Cached,
idName filled from Cached too; plugins.js keeps main's middleware/agent
and clash branches ahead of the PR's named one; providers.go keeps
main's Told and Settle beside the PR's Answered.

Run: see the next commit.
2026-10-13 14:29:52 +08:00
yetone cefdbfd4e3 library: Library → Instructions lists Qwen Code and writes its ~/.qwen/QWEN.md (wongxy on Discord)
What: Qwen Code is a Library instructions target. magpie's block goes into
QWEN.md in Qwen's global folder ($QWEN_HOME, else ~/.qwen), after what the
user wrote there. When the user's settings.json sets context.fileName (a
name or a list, JSONC), the first non-empty name, trimmed, is used instead,
which is the file Qwen Code writes itself. Qwen joins ownFolder, so one in
a running WSL distro gets the same place under the distro's home.

Why: wongxy found that Qwen Code has a user-level instructions file but the
Library didn't list Qwen Code. Qwen Code had no Library target at all.
Source: QwenLM/qwen-code c5098a27: Storage.getGlobalQwenDir
(config/storage.ts, QWEN_HOME), getMemoryFilePaths (memory/
memoryDiscovery.ts, reads <global dir>/<each memory filename>),
memory-constants.ts (QWEN.md then AGENTS.md by default;
getCurrentMemoryFilename skips empty entries), packages/cli
config.ts (settings.context.fileName → setMemoryFilename).

Run:
- TestQwenInstructions (new): default ~/.qwen/QWEN.md, the user's text
  kept, settings.json untouched, Takes("qwen-code"); QWEN_HOME with a JSONC
  context.fileName list whose first entry is blank; a single name.
  Broken by hand three ways, each FAIL: qwen case removed (no target),
  context.fileName ignored (got qwen-home/QWEN.md), no trim/skip of empty
  names (got the folder itself).
- Real Qwen Code 0.21.9 (Homebrew) in a sandbox HOME against a fake OpenAI
  endpoint: `qwen -p hi` sent the model the magpie block from
  ~/.qwen/QWEN.md; with QWEN_HOME and context.fileName ["AGENTS.md"] it
  sent the block from AGENTS.md and not the QWEN.md beside it. The files
  were written in the format the test checks, not by a built magpie.
- go test -tags nogui ./internal/library, gofmt -l, go vet (darwin),
  GOOS=linux go vet -tags nogui, GOOS=windows go vet on ./internal/library,
  after rebasing on origin/main.
Not done: Qwen Code's MCP servers and skills are still not given by the
Library. No GUI strings changed (the page draws rows from the target data).
2026-10-13 14:14:41 +08:00
yetone 0f8cdc79f1 library, gui: Claude Desktop's own built-in skills are one row to keep, on the Skills tab, not five failed writes on every tab (#1896, SivanCola)
What changed: the screenshot on #1896 asked how to read a "duplicate MCP"
box on the MCP page. It wasn't MCP servers: it was five "Claude Desktop
already has a skill of its own called docx/frontend-design/pdf/pptx/xlsx"
lines, Anthropic's built-in skills, shown as failed writes in English
monospace, with a Try again that can never help, on every tab.

- library: that problem is Own (the agent's own skill by the library's
  name), as other agents' are. UseLibrarySkills/KeepAgentSkills settle
  several names at once; Desktop's own skills are never set aside for the
  library's (they are its built-ins), only kept.
- gui: the problems card shows each problem on its own tab and, on the
  others, a "{tab}: {n} more" button that opens it (no scroll). An
  agent's own skills are one row per agent ("Skills docx, pdf, ...");
  Claude Desktop's row says it has its own and offers only Keep. With
  nothing failed the title says so and there is no Try again. API:
  skills/use-library and skills/keep-own take names[] beside name.
  Decision (product calls delegated): follow macOS's pattern of grouping
  related alerts with one action, rather than a list of errors.
- i18n: 10 new strings in zh, zh-TW, ja, de.

Run:
- go test -tags nogui ./internal/library (474s, -timeout 40m at load
  ~90; the 10m default timed out in TestRTKUpgradeScript under that load)
  and ./internal/gui: ok. TestClaudeDesktopOwnSkillsKept broken by hand
  twice, red each time: Own dropped from the problem; Desktop's skills set
  aside by UseLibrarySkills.
- GUI: own-skill, library-items, i18n-keys, gui-ja, gui-de, gui-zh-tw,
  panel-usage in Chromium and WebKit: all pass. With origin/main's
  library.js put back, 10 of own-skill/library-items' 20 fail.
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on the
  touched packages: clean.

Not tried with the reporter's real Claude Desktop; the fixture uses the
skills-plugin manifest's creatorType "anthropic" entries.

Reported-by: SivanCola
2026-10-13 13:03:25 +08:00
yetone 6d7e5b53a0 library: the Library page opens without looking at the same folders thousands of times (#1771, oxyuan)
oxyuan's profile after v0.1.1214: every page opens at once but the
Library, ~1.3s a visit on Windows, 68% of it in library.resolve and the
read 97% system calls.

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

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

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

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

Run: go test -tags nogui ./internal/library ./internal/gui (ok);
gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui
./internal/library; node --test internal/gui/tests/library-*.test.cjs,
chromium and webkit: 450/450 on the second full run. The first full run
had library-mcp-tool-switch red in WebKit (#1609, filed) and
library-chip-fan red once in Chromium under --test-concurrency=4; it
passed 3/3 alone and in the second full run. Not tried on oxyuan's
machine or with their library.
2026-10-13 11:10:59 +08:00
yetone 2d721f7f3d library, gui: the skills in your agents can be picked and removed together
wongxy on Discord: 资源库技能支持批量删除 (batch delete for the Library's
skills). The library's own skills already have this: Select, then
Remove…, since #1852 (a4385e099, v0.1.1217). The skills under "In your
agents" (the ones an agent has of its own) could only be removed one at
a time. This adds the same for them.

What it does:
- RemoveFoundSkills(names), POST /api/library/skills/remove-found-some.
  One change takes each name out exactly as RemoveFoundSkill does (its
  body is now removeFound, shared by both). Folders and byte copies, the
  shared ~/.agents/skills entry and a folder in the library's own folder
  go to magpie's backups, not the OS trash and not deleted. Links are
  taken away. A folder elsewhere that the skill only links to stays, and
  so does another skill by that name.
- A name that can't be taken out is left as it was and goes in
  Result.Unremoved; the others go all the same. When none can go the
  change fails, the endpoint answers 400, and nothing is touched.
- The "In your agents" heading gets its own Select. Each row gets a
  box, its own buttons go, and a bar has All, Clear, the count, Remove…
  and Done. Remove… asks once, naming the count, the agents, how many
  folders go to the backups, how many are only unlinked and how many
  have a shared entry. A name that wasn't removed stays picked, with its
  error in its row's place, and the status names it.
- Only one Select is on at a time: while either is on, the other is
  dimmed with a title saying why ("Done picking … first"). Ending one
  from the other took its bar away above the pointer and scrolled the
  page.
- Eight new strings in zh, zh-TW, ja and de.

Run:
- TestRemoveFoundSkills: picks notes (a folder plus a byte copy), dev (a
  link to a folder of the user's own), stuck (a read-only folder in
  Gemini's skills) and notes again. Checks that stuck is in Unremoved
  with its files intact, that the others are gone with their backups,
  that dev's own folder stays, that keep (not picked) stays, that
  "none can go" fails and touches nothing, and that no names is refused.
  Broken by hand, it goes red both ways: returning on the first error
  ("permission denied", the change fails), and dropping Unremoved
  ("unremoved: []").
- found-skill-pick-remove.test.cjs in Chromium and WebKit, en, zh,
  zh-TW, ja and de, at 1100 and 420: 11/11 each. Every press checks
  that nothing scrolled and that the pressed button didn't move. It
  covers the one-Select-at-a-time rule both ways, picking 3 and the
  sheet's title and lines, Clear, a partial failure, the 400 when none
  can go, and All then unpicking one. Broken by hand (failed names not
  kept, or unpicked anyway), it goes red: 0/11.
- 80 Library, skill, group, removal, i18n-keys, gui-de/ja/zh-tw and
  click-scroll GUI test files: Chromium 458/458; WebKit 456/458. The
  two reds are group-member-info (en) and library-mcp-tool-switch
  (zh-TW 980), both "locator.click: Timeout 5000ms exceeded". Both fail
  the same way, with different cases each run, at 2c3112969 with this
  change stashed.
- gofmt -l is clean. go vet passes on darwin, GOOS=linux -tags nogui
  and GOOS=windows; go build passes on all three.
- go test -tags nogui ./... under a sandbox HOME, rebased on a069f224c:
  all pass except internal/gateway, which hit the default 10m timeout
  while the GUI suites were running alongside it. Run alone with
  -timeout 25m it passed in 327s.

Not tried against a real agent's skills folder; only the sandbox HOME.

Reported-by: wongxy (Discord)
2026-10-13 11:04:13 +08:00
yetone e528aeb3ce agent: DevEco Code, Huawei's OpenCode, as an agent (#1885)
foobra asked for DevEco Code (npm @deveco/deveco-code), Huawei's
HarmonyOS coding agent. It is OpenCode underneath, so it joins through
openCodeLike as MiMo Code did (03a01a548):

- Config in ~/.config/deveco. magpie writes the first of deveco.jsonc,
  deveco.json, config.json there (the one DevEco reads last wins its
  merge), or DEVECO_CONFIG_DIR when that is an absolute folder; agentenv
  carries DEVECO_CONFIG_DIR. Auth at ~/.local/share/deveco/auth.json.
- Its provider block carries the key magpie-deveco, not the plain one.
  0.2.3 sends "deveco/0.2.3 ai-sdk/provider-utils/4.0.23 runtime/bun/1.4.2"
  on chat, but parts of its code still send opencode/<version>, so the key
  keeps its usage DevEco's whichever it sends. Check flags the plain key,
  and Sync writes DevEco's back. OpenCode's own key is unchanged.
- The user's own provider, small_model, $schema and comments stay; the
  model they were on comes back on Disconnect.
- Library: AGENTS.md instructions (with the "reads Claude Code's
  CLAUDE.md" note, as OpenCode and MiMo Code), MCP in OpenCode's shape,
  skills. No WSL folder.
- Install/update: npm @deveco/deveco-code on macOS and Windows only, as the
  package has no Linux binary (new cliSpec.only); the self installer under
  ~/.local/share/deveco/versions updates with `deveco upgrade`.
- Icon: DevEco's own logo, byte for byte from its IntelliJ plugin's
  pluginIcon.svg. Model picker /models. Route hue, READMEs (en, zh), site
  agent lists (en, zh, ja), docs/reference.md, subsystem pages, CLI help.

What was run
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -tags nogui: internal/library, agentenv, proc, cli, gui, usage
  pass; internal/agent passes in 559s with -timeout 40m;
  its first run, at the default 10m with load average ~40 from other
  sessions, was cut off by the timeout (no test had failed).
- New deveco_test.go: config lookup and DEVECO_CONFIG_DIR, the key, and
  Connect/Check/Sync/Disconnect against a deveco.jsonc holding the user's
  own model, provider, small_model, $schema and a comment. Made
  openCodeKeyAt return the plain key by hand: TestDevEcoKeyNamesIt and
  TestDevEcoConnectKeepsTheUsersOwn go red.
- GUI: new library-deveco.test.cjs (the note in en, zh, zh-TW, ja, de,
  and the icon draws), chromium and webkit; red with deveco taken out of
  library.js's note. library-instr-sets, library-instr-busy,
  panel-routing, agent-connect, library-desktop-skills, getting-started,
  filter-ime, routing-account-identity pass in both engines.
- Real use, sandbox HOME: npm-installed @deveco/deveco-code 0.2.3,
  `deveco auth consent --accept` (sandbox only, no Huawei sign-in). magpie
  serve on 127.0.0.1:3592 with a fake upstream; `magpie deveco fake/fake-1`
  wrote provider magpie (magpie-deveco, http://127.0.0.1:3592/v1) beside
  the user's own and kept the file's comment; `deveco run "Reply with one
  word: ping"` answered from the fake, and `magpie usage today` counted it
  under DevEco Code. The User-Agent above is what it sent.

Not tried
- Windows, and DevEco Studio's plugin mode; a Huawei-signed-in DevEco.
- `magpie deveco <model>` then `magpie deveco default` doesn't bring back
  the model the user was on before: the CLI set path doesn't stash. It is
  the same for OpenCode today; Connect/Disconnect in the GUI does.

Reported-by: foobra
2026-10-13 10:57:32 +08:00
yetoneandKenoia 807cacd4a5 library: Pi's adapter isn't loaded under autoload:false or a "+" override (#1189)
47a313f6 stopped piDetect reading a package left in Pi's storage as a
loaded MCP adapter. Two cases Kenoia's #1189 covered still read as
loaded on main, so magpie took over Pi's native mcp.json for a user who
had turned the adapter off:

- {"source":"npm:pi-mcp-adapter","autoload":false} with no extension
  patterns. Pi 1.1.0's package-manager.js applyPackageDeltaFilter loads
  none of the package's extensions then, only the ones it names.
- "+path" in settings.extensions is an override that re-enables a path
  Pi already found; it adds no source, but piDetect counted it as one.

The package object now reads autoload, and a "+" entry is skipped like
"-" and "!". #1189's own glob/override resolver isn't ported: main
handles "-"/"!" by package name and the cases above are what was left.

Ran: TestPiDetectLoaded with five new cases (autoload false, false with
extensions [], false with ["index.ts"], true, and a "+npm/..." override);
with pimcp.go put back the autoload:false and "+" cases fail.
go test -tags nogui ./internal/library ok; gofmt -l clean; go vet
darwin, GOOS=linux -tags nogui, GOOS=windows clean. Not tried with a
real Pi install.

Co-authored-by: Kenoia <73810401+Kenoia@users.noreply.github.com>
2026-10-13 08:36:14 +08:00
yetone a43fa6809b library: two changes in one millisecond each get a backup folder of their own (#1743)
liubing reported on #1743 that TestRemoveFoundEntryEveryFormat failed
in a full run on Linux, the backup read holding another format's
content, on an unmodified main too. The backup folder was named by
the millisecond and taken as this change's own: a second change in
the same millisecond wrote into the first's folder, its file kept
under its folder's name since the first's held the name, and the
copy at the name the change wrote was the other change's. The test's
loop runs one change per format, all named config.json, and on a fast
machine two land in one millisecond. A user's two quick changes did
the same: the backup the second change named wasn't its own.

freshBackup makes the folder with os.Mkdir, adding -2, -3... when the
millisecond's is taken. pruneBackups' sort keeps them in order.
Siblings checked: the skill backups (keepLibrarySkill, keepReplaced,
setAside, carry's and RemoveSkills' aside) use per-skill paths under
the stamp; setAside already steps past a taken name, and the others
only collide on the same skill in the same millisecond, where move
fails loudly rather than mixing; they are left as they were, since
a folder each would split one change's skills over many folders.

Run: go test -tags nogui ./internal/library/ ok on macOS and in
Docker golang:1.26.8 GOTOOLCHAIN=local (also -count=30 of the two
tests). The original red didn't show in Docker in 100 runs; it was
reproduced by injecting a minute-wide stamp, which turned
TestRemoveFoundEntryEveryFormat red on the old code and leaves it
green with the fix. Broken by hand: os.Mkdir -> os.MkdirAll (no
claim on the folder) turns TestBackupsInOneMillisecond red.
2026-10-13 06:43:50 +08:00
yetoneandump45nose d0e412e7a6 library: a checked MCP server's PWD is home too, and #1727's cwd test holds on macOS (#1727)
The previous commit starts the check's server in home. Its own test
failed on macOS with that fix in: the child reported
/private/var/folders/.../magpie-test-home-N and HOME was
/var/folders/.../magpie-test-home-N, the same folder spelled through
macOS's /var symlink, compared as strings. The test now compares the
folders with os.SameFile.

exec sets PWD to Dir by itself only when Env is nil, and the check sets
Env, so the server ran in home with PWD still naming magpie's own
folder; a shell-script server that reads $PWD would see the folder the
fix moved it out of. The check now sets PWD=home with Dir (not on
Windows, which doesn't use PWD, as exec does), before the server's own
variables so one it sets still wins.

The two subtests now give each run a home of its own (t.Setenv HOME and
USERPROFILE) and move the process with t.Chdir, so the "needcwd" fake's
./logs goes with the test instead of staying in the package's shared
test home, and nothing is left in another cwd when a subtest fails. The
read-only-cwd subtest also checks that ./logs landed in home: Windows
doesn't enforce a folder's read-only bit, so that is what makes it fail
there without the fix.

Run (sandbox HOME, private GOCACHE): TestCheckStdio -count=3 on macOS;
the whole internal/library package. Broken by hand: without cmd.Dir both
subtests fail (wrong folder; "mkdir logs: permission denied"); without
the PWD line the cwd subtest fails on its PWD. On the Windows box
(windows/amd64 test binary): TestCheckStdio passes, and without cmd.Dir
both subtests fail there too (the server ran in the test's temp cwd,
and ./logs wasn't in home).

Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-10-13 06:18:27 +08:00
ump45nose 0154fe1135 library: start stdio MCP checks in the home directory (#1727)
A magpie started from a Windows shortcut keeps C:\Windows\system32 as
its cwd. The Library check inherited that directory, so a server that
writes into "." failed as exited (1) with no log. Agents start the same
server from a project or home directory and succeed. Pin cmd.Dir to HOME
for the check.
2026-10-13 06:18:27 +08:00
yetoneandfjrtdk 1f0ff81dfc agent: Grok App's own route picked in magpie is taken, and Disconnect can put one back; a sync that isn't connected writes nothing (#1625)
Follow-up to fjrtdk's commit before this one, which this keeps: magpie never names
itself as Grok App's route.

- Set refused every own route (errGrokAppRoute) while Options still
  offered them, so the picker showed choices that only errored. It also
  broke Disconnect: when unwire leaves no route (Use set it to magpie,
  nothing stashed), Disconnect sets connect.was's route back through Set,
  got the error and stopped half done. An own route now takes magpie's
  channel out and is written as [models] default, the way picking
  another provider leaves magpie on other agents. That route can't be
  magpie, so the App's sign-in is never touched.
- Sync ran rememberRoute/releaseRoute before checking for the channel,
  so every user with Grok App installed but not connected got stash
  entries. Now it returns before them unless the channel is there or
  the route is still magpie (an older magpie's takeover to put back).
- Check again warns when the route is magpie and the channel is gone,
  which that commit dropped.
- The notice uses the App's own labels (Settings › Account, Use; ja
  「使う」, de Einstellungen › Konto / Verwenden, from grok-app 0.2.40's
  settings.nav.account and prov.useThis) and says a chat can pick
  magpie's models in its model picker (composer_prefs_set, which
  doesn't move the route).
- Sibling: rtk init has no grok agent for Grok Build either (rtk 311ebcb
  agents: claude codex copilot cursor droid gemini hermes opencode pi
  trae vibe antigravity), so Grok Build is in rtkNoHook too.

Run: gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows clean; go test ./internal/gateway ./internal/agent
./internal/library -count=1 pass; node --test i18n-keys and
agent-notice-lang pass. Broken by hand: that commit's grokapp.go fails
TestGrokAppOwnRouteStays, TestGrokAppDisconnectPutsTheRouteBack and
TestGrokAppSyncUnconnected; dropping the Check branch fails
TestGrokAppSyncUnconnected; dropping rtkNoHook["grok"] fails
TestRTKNoHookGrokBuild. Not tried: the Grok App GUI itself; the config
format and behaviour are from grok-app 0.2.40's source.

Co-authored-by: fjrtdk <fjrtdk@gmail.com>
2026-10-13 05:09:18 +08:00
fjrtdk ea3d480edf agent: Grok App keeps its own route; magpie is a custom provider under Accounts, and the Library writes instructions, MCP and skills on agent-home (#1625) 2026-10-13 05:09:18 +08:00
yetone 97dfed0f3e library: a site's well-known kit of skills is one group, by the lock's sourceBaseUrl (#1862)
WardLu (#1862): skills that `npx skills add` got from a site's
/.well-known/agent-skills/ index were one group per skill. That was
Feishu's lark-base, lark-doc and lark-sheets, and Fish Audio's
fish-audio-api and fish-audio-sdk. readSkillLock grouped them by each
skill's own sourceUrl (".../lark-base.tar.gz", ".../fish-audio-api/skill.md").

Now a lock entry with sourceType "well-known" is grouped by its
sourceBaseUrl, read as host/path (wellKnownBase/siteOf):
- the user, query and trailing slash are dropped, and the host is
  lower-cased without "www.";
- so Feishu's three are open.feishu.cn/lark-cli/skills/regular and Fish
  Audio's two are docs.fish.audio;
- a kit on the same host with a different base URL stays apart. Hosts are
  not merged.

Fallbacks:
- an older lock with no sourceBaseUrl takes the part of its sourceUrl
  before /.well-known/;
- an entry with neither is grouped by its sourceUrl, as before.

Two things this new key would otherwise get wrong:
- Group again (RegroupSkills) tried every owner/repo-shaped key on GitHub.
  A kit one folder down a site (docs.example.com/kit) has that shape, so a
  key whose owner has a dot is skipped now. GitHub owners have no dot.
- the heading's link sent a key with no path ("docs.fish.audio") to
  github.com. repoURL now opens it at https://docs.fish.audio.

Run:
- go test ./internal/library (all pass). New TestWellKnownKitGrouped uses
  the issue's base and source URLs for 3 Feishu + 2 Fish Audio skills, plus
  another kit on open.feishu.cn, an entry with no base, and a
  docs.example.com/kit kit that Group again must not fetch.
  - With the well-known branch disabled it fails, with the reporter's five
    one-skill groups.
  - With the dot check removed it fails on a GitHub fetch.
- new TestWellKnownBase: a table of base and source forms.
- skill-repo-groups.test.cjs now has a docs.fish.audio group that opens the
  site. It fails with origin/main's assets, which say "on GitHub". It and
  skill-regroup/skill-groups pass in chromium and webkit.
- gofmt -l; go vet for darwin, linux -tags nogui and windows on
  internal/library.

Not run: the reporter's real ~/.agents/.skill-lock.json. The issue quotes
only these three fields of it. A row's own link still isn't its sourceUrl.
2026-10-13 04:32:20 +08:00
yetone e0ecf01610 mcpauth: an MCP server's own OAuth app is called back at Claude Code's http://localhost:<port>/callback, so an app made for Claude Code signs magpie in as it is (新v学员 on Discord)
What changed: accc8c090 took Claude Code's names for a server's own
OAuth app (oauth.clientId, clientSecret, callbackPort) but sent
redirect_uri=http://127.0.0.1:<port>/callback. Claude Code sends
http://localhost:<port>/callback:
- code.claude.com/docs/en/mcp, "Use pre-configured OAuth credentials":
  register http://localhost:PORT/callback; --callback-port fixes the
  port to match it. Its version note says 2.1.229 sent 127.0.0.1 and
  servers that match the registered URL exactly refused the sign-in,
  so 2.1.231 went back to localhost.
- The installed Claude Code 2.1.296 binary builds
  `http://localhost:${n}/callback` (default port 3118 / a random
  free one, MCP_OAUTH_CALLBACK_PORT) and listens on 127.0.0.1 only.
So an app registered for Claude Code at an exact-match server was
refused by magpie. StartWith now sends localhost for a user's own app
and still listens on 127.0.0.1 alone, as Claude Code does, so the hosts
don't differ and the editor needs no note. magpie's own dynamic
registration keeps 127.0.0.1 (it registers that URL itself).

The no-registration error, the editor's hint (now
http://localhost[:port]/callback), its zh/zh-TW/ja/de translations,
the OAuthApp comment and docs/subsystems/library.md say localhost.

Run:
- New TestAppMadeForClaudeCode: the GitHub-shaped fake matching one
  exact registered URL http://localhost:<port>/callback, at authorize
  and at the token request. With the old mcpauth.go it fails (as do
  the three GitHub tests now asserting localhost); with the fix all
  pass. go test -race ./internal/mcpauth/...
- go test -tags nogui ./internal/library ./internal/gui
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
- GUI mcp-oauth-app (Chromium+WebKit, 1100/390, en zh zh-TW ja de,
  22/22) and i18n-keys; with the hint's old 127.0.0.1 put back by hand,
  mcp-oauth-app goes red (0/11 Chromium).

Not run: a real sign-in with a real OAuth app (none to use). GitHub's
docs say a loopback redirect needn't match the registered port but
don't say whether that holds for localhost as it does for 127.0.0.1;
if GitHub wants the port, the user sets Callback port and registers
http://localhost:<port>/callback, as Claude Code's docs also say.
2026-10-13 04:01:32 +08:00
yetone accc8c0903 library: an MCP server whose sign-in has no client registration (GitHub's) is signed in to as the user's own OAuth app (新v学员 on Discord)
What changed: GitHub's remote MCP server (api.githubcopilot.com/mcp/)
points to https://github.com/login/oauth, whose metadata has no
registration_endpoint, so magpie's sign-in, which always registered
itself (DCR), could never sign in to it. A server now carries an
optional OAuth app, `oauth: {clientId, clientSecret, callbackPort}`,
Claude Code's names for --client-id/--client-secret/--callback-port
(oauth.clientId in its .claude.json). mcpauth.StartWith signs in as
that app without registering: PKCE S256, a loopback callback
http://127.0.0.1:<port>/callback (any port unless callbackPort is set),
client_secret_post with a secret (basic only when the server lists
basic alone), "none" without one.

Without an app, a server with no registration endpoint now fails with
mcpauth.ErrNoRegistration, which says to make an OAuth app with the
vendor (GitHub's under Settings > Developer settings > OAuth Apps, with
http://127.0.0.1/callback) and give it under "OAuth app" in the editor.
The editor opens those fields with Client ID focused when that error
comes back. Filling them makes Sign in read "Save and sign in", and
Cancel asks before dropping them, as the earlier Cancel fix does.

GitHub answers token errors with 200 and {"error": ...}; tokenRequest
now reads a 2xx body with `error` as the error, and bad_refresh_token /
incorrect_client_credentials count as a dead sign-in as
invalid_grant/invalid_client do.

Secrets: the client secret sits in library.json like header and env
values. A backup without keys blanks it; WithSecrets puts this
computer's secret back only for the same client ID. No agent file is
given the app. The TUI editor, which doesn't show it, keeps it on save.
check() keeps it only on an HTTP server, requires a client ID when a
secret or port is given, and a port 1-65535.

Run (worktree at 98b5a02d1 + the two earlier commits):
- go test -race ./internal/mcpauth/... (new github_app_test.go: an
  httptest fake built from GitHub's real PRM and AS metadata bytes:
  no app -> ErrNoRegistration, sign-in as the app, wrong secret, fixed
  callback port, bad refresh token)
- go test -tags nogui ./internal/library ./internal/tui ./internal/gui;
  go test ./internal/gateway -run MCP
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
- GUI, Chromium and WebKit, 1100/390, en zh zh-TW ja de:
  mcp-oauth-app (new, 22/22), mcp-editor-cancel, mcp-signin,
  mcp-signin-health, library-mcp-health, i18n-keys - all pass
- Broken by hand, each went red: no 2xx error parse, GitHub codes out
  of dead(), app ignored in StartWith, secret not blanked / not matched
  by client ID in carry, check() without the non-HTTP rule; in the GUI,
  oauth left out of the save, and the failed hook not opening the fields.
- Sandbox HOME, rebuilt magpie web, against the real GitHub server:
  Sign in showed the new error and opened the fields; Save and sign in
  saved the app and produced a real github.com/login/oauth/authorize
  URL with the app's client_id, S256 and a 127.0.0.1 redirect, which
  GitHub answered with its login page. .claude.json didn't hold the app.

Not run: a real GitHub sign-in to completion. There's no real OAuth app
to use, and I didn't make one on the owner's account. Claude Code's
callback says localhost where magpie's says 127.0.0.1, so an app made
for Claude Code needs its callback URL changed; that isn't bridged.
2026-10-13 03:43:05 +08:00
yetone eb1fab34c7 library, gateway: an MCP server magpie is signed in to no longer shows "Signed in" beside "needs sign-in" (新v学员 on Discord)
What was wrong, reproduced in a sandbox HOME with mcpauthtest's fake OAuth
server behind a sandbox magpie:

- A server no agent has is checked only on a click (#1597). Clicked before
  its sign-in it said "needs sign-in"; after signing in, the page rechecked
  only servers in use, so the row kept that result beside the new "Signed
  in" tag. The page now rechecks any server it has a result for once its
  key (sign-in included) changed.
- The check sent magpie's token but never renewed it on a 401, so an
  expired access token with a good refresh token read "needs sign-in"
  beside "Signed in". checkHTTP now renews once and asks again, as the
  gateway's relay does.
- A server that refuses even a just-renewed token was still "Signed in".
  mcpauth.Rejected marks such a sign-in run out, from the check and from
  the gateway's /mcp/<name> relay; ServerHealth.SignIn carries the status
  back (only for a server magpie has a sign-in record for) and the row's
  tag turns to "Sign-in ran out".

mcpauthtest.Fake gains RefuseTokens for the last case.

Run:
- go test -tags nogui ./internal/mcpauth/... ./internal/library
  ./internal/gateway (HOME and GOCACHE in scratch): ok.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on the
  touched packages: clean.
- New TestCheckRenewsMagpiesSignIn, TestCheckSaysSignInRanOut,
  TestMCPProxyRefusedAfterRenewalRunsOut. Broken by hand: renewal removed
  from checkHTTP, Rejected removed from the check, and from the gateway;
  each went red.
- New mcp-signin-health.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de,
  1100 and 390 wide, 22/22. Each of the two library.js changes reverted
  on its own: 0/11 in Chromium. library-mcp-health, mcp-signin and
  i18n-keys pass.
- Sandbox repro before and after with the fake server: both cases now
  show one tag; forget+revoke shows "Sign-in ran out · needs sign-in".

Not run: a real vendor's server refusing a renewed token; the fake stands
in for it.
2026-10-13 03:43:04 +08:00
yetone e08902e79d agent, library: Hermes Agent's folder is %LOCALAPPDATA%\hermes on Windows, and rtk's installer is told it (新v学员 on Discord)
新v学员 runs magpie on native Windows. Library -> RTK -> Hermes Agent
failed with "rtk's installer didn't add its hook to Hermes Agent:
Config: C:\Users\admin\AppData\Local\hermes\config.yaml ...". magpie
hard-coded ~/.hermes. Hermes' own default
(hermes_constants._get_platform_default_hermes_home) is
$LOCALAPPDATA\hermes on win32 (~/AppData/Local/hermes when LOCALAPPDATA
is empty) and ~/.hermes elsewhere, with $HERMES_HOME overriding it.
rtk 0.51's resolve_hermes_home knows only $HERMES_HOME and ~/.hermes,
on every OS.

What changed:
- appdir.HermesHome / HermesHomeIn / HermesDefaultIn: $HERMES_HOME,
  else Hermes' per-OS default. This is the one place that resolves it.
- agent: hermesIn (Agents-page model wiring) and hermesProfiles use it
  through place.hermesHome / hermesDefault. A WSL distro keeps
  ~/.hermes (Linux paths, Windows env not read). The Agents-page wiring
  was wrong on native Windows too: without HERMES_HOME it wrote
  %USERPROFILE%\.hermes\config.yaml, which Hermes never reads.
- sessions.HermesDir uses it, so Windows sessions are found.
- library/rtk: the hermes spec reads and writes the agent's own folder
  (a.Dir), and rtkSpec.env passes HERMES_HOME=<that folder> to
  `rtk init -g --agent hermes --auto-patch`.
- Tests resolve the folder through appdir instead of home/.hermes. New
  TestHermesDefault/TestHermesHome (appdir), TestHermesFolder (agent:
  Windows default, profiles under it, WSL unchanged), and
  TestRTKHermesHome (library, a fake rtk that behaves like 0.51).
- docs/reference.md and docs/subsystems/library.md describe the
  Windows folder and the env.

Run:
- gofmt -l clean. go vet ./... on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- darwin: go test ./internal/appdir ./internal/library
  ./internal/sessions ./internal/agent ./internal/tui.
- TestRTKHermesHome against the old rtk.go fails with the reporter's
  exact message ("didn't add its hook ... AppData/Local/hermes/
  config.yaml"), and its default subtest fails with HERMES_HOME="".
- Windows box (cross-compiled test binaries, testenv sandbox
  USERPROFILE/LOCALAPPDATA): appdir Hermes tests, agent
  Hermes|Reseat|Effort (incl. TestHermesFolder) and library Hermes|RTK
  pass. TestRTKHermesHome skips there (shell fake). The sessions binary
  failed only TestHermesMessageVisibility, because its testdata wasn't
  copied to the box.
- Real rtk.exe 0.51.0 on the Windows box: with
  HERMES_HOME=<sandbox>\AppData\Local\hermes it wrote the plugin there
  and patched that config.yaml. Without HERMES_HOME it wrote
  C:\Users\<user>\.hermes, ignoring a sandbox USERPROFILE (rtk asks
  Windows for the home folder). That confirms the cause and the fix.
  The stray folder it made on the test box was removed.

Not run: real Hermes on Windows (no install, and running hermes under
a temp HERMES_HOME rewrites the live launcher); the GUI suite; the full
go test ./... ; the reporter's own machine.
2026-10-13 00:01:46 +08:00
yetone 8bfe33f1f4 agent, proc: where each command is on PATH is looked up once while its folders are unchanged, so a Windows page doesn't stat PATH per agent and per session (#1771)
oxyuan profiled every page's first load on Windows at seconds (4-7s), and
Sessions, Usage → Sessions and Context at 26-45s: 96-98% of the samples
were os.Stat under exec.LookPath and proc.FindTool. A failed lookup stats
every PATHEXT candidate in every PATH folder (111ms there), and the pages
asked once per known agent (Detected → binAt) and once per Pi session
(sessions.carries → ompThere) on every request.

proc.Look (new, look.go) is exec.LookPath with its answers kept. The
proc.LookPath that 1bf722e28 added (exec.LookPath, then Unwrap of a mise
wrapper script) is now Look then Unwrap, and FindTool keeps its PATH
answer the same way before Unwrap. Unwrap keeps its own answer by the
script's size and time, and on Windows it returns at once. The PATH
answers are keyed on PATH and PATHEXT,
and dropped when a looked-in folder's modification time changes (an
install or removal), checked at most every 2s, every time in a test binary
testenv isolated. proc.Forget drops them all and agent.Rescan (the Agents
page's refresh) calls it. Every exec.LookPath that a page or the gateway
reaches now goes through one of them. The sites 1bf722e28 made unwrap keep
LookPath: agent (agent, air, nativemodels) and provider (codex models,
cursor, devin, kiro). The rest keep exec.LookPath's answer as it was,
through Look: agent (agents, cliupdate, the shim, gemini, install,
reasonix, vscode, zed), sessions/carry and library/rtk. Those left
on exec.LookPath run once per user action (update's pkexec, the
secret-tool read, installers, rtk upgrade) or in tests.

Run:
- look_test.go: asks once while folders are unchanged, sees an install and
  a removal, a changed PATH and Forget, concurrent lookups under -race. The
  first goes red with LookPath calling exec.LookPath directly.
- On the Windows box (yeton@10.0.0.132, amd64 probe, sandbox USERPROFILE):
  Detected with 4 agents 252ms → 7ms per call after the first, 297x
  LookPath(omp) 879ms → 1.1ms; drift over Detected 274ms → 42ms; Titles
  for 6 sessions 23ms → 4ms. The first call is the same (it looks).
- gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., sandboxed go test ./... at the rebased head.
Not run: the reporter's own machine (47 PATH folders, 59 agents).
2026-10-12 22:55:22 +08:00
yetone e3a497d7a2 library, gui: Hooks are a fifth Library category, kept once and written into each ticked agent's own hooks file (#1790, AllenReder)
What: the Library page has a Hooks tab beside Instructions, MCP, Skills
and RTK. A hook is a command, an event, an optional tool filter, a
timeout and the agents ticked for it. magpie writes it into each agent in
that agent's own file and shape:
  Claude Code  <claude dir>/settings.json   hooks.<Event>[{matcher, hooks[]}]
  Codex        <codex home>/hooks.json       same shape
  Gemini CLI   ~/.gemini/settings.json       same shape, timeout in ms
  Cursor       ~/.cursor/hooks.json          flat entries, version 1
Portable events (turn end, after a tool, before a tool, prompt sent,
session start) map to each agent's own name; "shell"/"edit" map to each
agent's own tool names. An agent's own event (codex:PermissionRequest,
cursor:afterFileEdit, ...) is offered too and given to that agent only.
Rows have agent chips (All first), Select + bar, and Remove all, like
skills and servers. An agent that can't take a hook has its chip greyed
with the reason: every agent but those four ("has no hooks magpie can
write"), an agent in WSL (not yet), and another agent for a native event.
The page also says when an agent has all hooks turned off
(disableAllHooks, hooksConfig.enabled=false, [features] hooks=false).

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

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

Not tried: real Claude Code / Codex / Gemini / Cursor runs firing the
written hooks; the shapes were checked against each agent's source and
docs, not executed.
2026-10-12 22:44:28 +08:00
yetone d7a1fcd41a library, gui: a skill pack added a while ago is grouped whole, and the Skills head has Group again (White Immortal on Discord)
Of mattpocock/skills' 38 skills only 20 were grouped with the repository on
the Library page; the rest sat under On this computer, and nothing could
trace them again. Cause: installing from a repository again (noteFrom)
grouped a library skill with it only when its SKILL.md was byte for byte
the repository's. A pack added a while ago is mostly older copies: of the
copies at mattpocock/skills 3cca18b3 (2026-09-04), 18 of 37 match HEAD; at
8b78b531 (2026-08-13) 2 of 35. The GUI's parts draw all 38 when the data
has them (checked with a Playwright run against 38 skills in the repo's
real folder layout, github, lock-traced and mixed paths, both engines).

noteFrom now also notes a skill traced to nowhere by a name the repository
has, when the library has others from that repository (same file, or
traced there already). A skill traced to another repository, and a
same-named skill when the library has nothing from there, are left alone.
RegroupSkills (POST /api/library/skills/regroup) fetches each GitHub
repository the skills are traced to and runs the same; it fails only when
no repository could be fetched. The Skills head has Group again (busy while
it runs, status says how many joined), en/zh/zh-TW/ja/de.

Run: TestRegroupOlderCopies (fails with the name match off: edited and
later stay ungrouped), TestInstallAgainNotesFrom, TestSkillRepoTraced;
skill-regroup.test.cjs in chromium and webkit, en/zh/zh-TW/ja/de at 1100
and 440 wide (red on the old assets: no Group again); skill-parts and
i18n-keys pass; go test -tags nogui ./internal/library ./internal/gui ok;
gofmt, go vet. Not tried against the reporter's library or real GitHub.
2026-10-12 22:08:58 +08:00
yetone bfaedf1830 gui, profile: the profile in use is ticked and named on the panel's Profiles button, not a count read as its name (superhtoooth on X)
superhtoooth (macOS): 保存方案设置了方案名字,但是应用方案没有用这个名字。
menu 里面变成了方案 1,方案 2。而且在应用里面没有显示当前使用的方案.

The bug: the tray panel's Profiles button showed the number of saved
profiles next to its label ("方案" + "2"), which reads as a profile
named 方案 2. Profiles were saved and applied under the typed name all
along; nothing anywhere said which profile was in use.

What changed:
- profile.InUse: a profile is in use while applying it would change
  nothing on this computer - every detected agent's saved field is as
  the profile has it (compared with the same renamed-ref spelling Apply
  writes), its model lists are held (provider.ModelListsHeld, a dry run
  of SetModelLists via the extracted putModelLists) and its library
  setup is as saved (library.Holds, the mirror of Restore). A profile
  that touches no agent here is not in use.
- Why not "last applied": that would stay ticked after the user changes
  a model by hand, a tick that lies. With this definition a profile
  saved from the current setup is in use at once, a hand change clears
  the tick, and applying puts it back. Two identical profiles are both
  ticked; the button names the first.
- GUI: /api/state carries inUse. The panel's button names the profile
  in use (a pop-up button showing what is picked), else counts them as
  before; its chip gets a check mark and aria-current, in panel and
  window; the chip's tooltip and its details say "In use" (string
  already in every language). CLI `magpie profiles` marks it, the TUI
  notes "in use". Docs (reference, start en/zh/ja) say so.

What was run:
- go test ./internal/profile (new TestProfileInUse: save, hand change,
  apply, hidden model list, library instructions, absent agents) and
  ./internal/gui (new TestStateProfileInUse through the HTTP handler),
  scratch HOME. Broken by hand: field compare, ModelListsHeld,
  library.Holds and state's InUse each turned a test red.
- go test -tags nogui ./... in a scratch HOME (the four slow packages
  rerun with -timeout 40m under load ~45).
- GUI: new profile-in-use.test.cjs (reporter's steps in the panel at
  360px, every language, plus the window) and panel-profiles,
  profile-confirm, profile-details, old-webkit, i18n-keys, gui-zh-tw,
  gui-ja, gui-de in chromium and webkit: all pass. Old app.js fails the
  new test.
- Real CLI in a sandbox HOME with a codex config: save/use/profiles
  show the mark, and it goes after a hand edit.
- gofmt; go vet darwin, linux (nogui), windows.
Not tried: the real tray app with real agents, and Windows/Linux at
runtime.
2026-10-12 19:14:54 +08:00
yetone 9300b2a126 library: a visit to the Library no longer parses Codex's config.toml again when it hasn't changed (#1665, laowangba233)
laowangba233 saw magpie's CPU jump on each switch to a Library page.
Profiled in a sandbox HOME with a copy of a real Codex config.toml (1.5 MB,
10,927 [projects."<dir>"] tables, one per folder Codex was ever opened
in): 69% of GET /api/library's CPU was go-toml parsing that file through
foundServersOf -> mcpFile.entries. go-toml's SeenTracker looks each table
name up among every sibling before it, so the parse is quadratic in the
number of projects, ~0.2 s of CPU each time, and the Library parsed it on
every visit (edit.Read already kept the bytes, not the parse).

mcpFile.entries now keeps what it parsed through filememo, keyed by the
file's size and time (and, written in the last two seconds, its bytes),
and hands each caller a deep copy of the servers it found, so a caller
changing an entry doesn't change the next caller's. The RTK page's
codexSandbox (Windows, Codex with rtk on) parsed the same file the same
way on each visit and is kept the same way.

Measured (sandbox HOME, the copied config and library, macOS, 10 warm
GET /api/library after start): 2.67 s of CPU before, 0.55 s after
(~0.27 s -> ~0.055 s a visit).

TestCodexEntriesParsedOncePerChange: a config with 2000 projects read
four times parses once, a caller's change to the entries doesn't reach
the next, a change to the file is read, a file gone is no servers. It
fails with the memo undone (entries parsing edit.Read's bytes each time)
and with the copy undone. go test -tags nogui ./internal/library
./internal/filememo pass; TestCodexSandbox passes. The RTK memo has no
test of its own (Windows only); filememo's own tests cover the keep.
2026-10-12 02:56:01 +08:00
yetone f57dc9610b library, gui: an instruction set made, saved or removed writes only the instructions, and the page holds its buttons while it does (#1624, Hipple)
On Windows 11 the Library's Instructions tab took 30s+ to show, and each
instruction made, saved or removed took about a minute with nothing on
the page to say so; a second click made a second set or removed twice.

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

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

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

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

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

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

What was run:
- go test ./internal/library ./internal/tui ./internal/gui (sandbox
  HOME). New tests: TestRemoveFoundServer (Claude/Codex/OpenCode files
  with user keys, comments and other servers that must survive; Gemini
  with a different one and an unparseable Cursor file left
  byte-identical), ...Unreadable, ...Own, ...EveryAgent (claude, codex,
  gemini, opencode, mimocode, pi, goose, cursor, copilot, crush, dsh),
  TestRemoveFoundEntryEveryFormat (every format, with backups),
  TestRemoveFoundEntryPiExtra; tui's d-twice found-mcp case keeps the
  rest of .claude.json.
- Broken by hand, each went red: no backup, Extra file skipped, Extra
  unreadable read as empty (mcp.json must stay unwritten), no delete,
  Own allowed; GUI trash posting without the confirm. The main file
  unreadable read as empty stays green on purpose: nothing is written
  and the read-back still refuses.
- GUI: remove-found-server.test.cjs (new), remove-found-skill,
  i18n-keys, every library-*.test.cjs, view-no-sideways, mobile-web,
  by-agent in Chromium and WebKit. library-mcp-tool-switch fails in
  WebKit with or without this change, and also when run alone (#1609);
  it has no found servers.
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on the three
  packages.
Not tried against a real agent's live config.
2026-10-11 22:23:45 +08:00
yetone 8902ec2179 library: a server that admits only the apps it lists says so at Sign in, and leaves the sign-in to each agent (#1619, Xichun123)
Figma's remote MCP server (mcp.figma.com/mcp) allow-lists clients by the
client_name they register with: its registration endpoint
(api.figma.com/v1/oauth/mcp/register) answered a plain registration
named Magpie 403 with the bare body "Forbidden" (tried once, by hand).
The Library's Sign in then showed "registering magpie with the server's
sign-in failed (403): Forbidden", which reads as a fault to retry.

magpie doesn't register under another client's name. A 401 or 403 from
registration is now mcpauth.ErrClientRefused: the server's sign-in admits
only the apps it lists and turned magpie away; the agents given it still
have the server's own address, so each signs in itself (in Claude Code,
/mcp). That address is what they already get while magpie isn't signed
in (library.through), so Claude Code, a client Figma lists, signs in
there with its own registration. The message is translated into zh,
zh-TW, ja and de. Other registration failures keep their status and body.
docs/subsystems/library.md says it.

Run: TestSignInRefusedByAnAllowListLeavesItToTheAgents (new, through
library.SignInServer against mcpauthtest serving Figma's 403 bytes)
fails without the change with the reporter's exact "registering magpie
with the server's sign-in failed (403): Forbidden", passes with it, and
checks claude, codex and cursor keep the server's own URL.
mcp-signin.test.cjs (Figma case added) passes in Chromium and WebKit, en
and zh; gui-ja, gui-de, gui-zh-tw and i18n-keys pass. go test -tags nogui
./internal/mcpauth/... ./internal/library/ ./internal/gui/ ok under a temp
HOME; gofmt -l clean; GOOS=linux and GOOS=windows go vet ok. Not tried:
Claude Code's own /mcp sign-in to Figma (no Figma account here).
2026-10-11 22:06:36 +08:00
yetone b7a926e9aa library, gui: a market search one source of which didn't answer says which, over what the rest found, not a failed search; a 503 is asked once more (#1589, Ti800)
Ti800 searched the Library's Discover for "prototype" and saw the amber
error "couldn't search skills.sh: www.skills.sh answered 503 Service
Unavailable" over two results. The cause was neither a stale request
(fetchMarket already drops an answer whose seq is old, results and error
alike) nor an error left over from an earlier search: MarketSkills matches
skills.sh's most-installed list (front page, cached) and magpie's picks
itself, then asks skills.sh's search. The search answered 503; the two
cards were the most-installed list's matches, and the handler sent both
the list and the search's error, which the page drew as a failed search.

- library: the search's failure is a SearchError naming its source
  (skills.sh, the MCP Registry); get() asks once more after a 503, after
  a one-second pause (one extra try, nothing else retried).
- gui: /api/library/market/{skills,servers} add failed and cause beside
  error. With results, the page says in a muted line with an amber dot
  that skills.sh's search (or the MCP Registry) didn't answer and why, and
  that these are only the matches among magpie's picks and the most
  installed (or magpie's featured servers). With no results the error bar
  is as before. Strings in zh, zh-TW, ja, de.

Siblings: the MCP market has the same shape (featured + registry) and gets
the same notice. The Plugins page's npm search already shows its error in
the "On npm" section only, beside the market's own list, keyed by query.

Tests:
- internal/library TestSkillsSearch503 (httptest fake skills.sh): 503 then
  200 gives the search's results and no error; 503 every time gives the
  popular match and a SearchError for skills.sh, searched exactly twice.
  With the retry taken out it fails: "after one 503:
  [mattpocock/skills/prototype] couldn't search skills.sh: … 503 …, 1
  searches".
- internal/gui TestMarketOfNamesTheFailedSource.
- gui tests market-partial.test.cjs: the reporter's case (two results +
  skills.sh 503), nothing found (error kept), an older search's 503
  answered 1.2s after a newer search's results (nothing changes), and the
  MCP Registry case; Chromium and WebKit, en/zh/zh-TW/ja/de, 520px wide:
  10/10. With the new branch disabled, 5/5 Chromium fail with "the partial
  list is shown as a failed search". market-*.test.cjs and
  library-discover-jump: 114/114.
- go test ./internal/library ./internal/gui, gofmt -l, GOOS=linux and
  GOOS=windows go vet -tags nogui on both packages; full suite in the
  push record.
Not tried against the real skills.sh (it answers 200 now); the fake
answers 503 as the report's text says.
2026-10-11 20:10:05 +08:00
yetone f1001ec991 library, gui: each of an MCP server's tools has a switch, and the agents that can leave one out are told to (nf1qaz2w on Discord)
nf1qaz2w asked to turn single tools of a Library MCP server on and off.
6f4fb883e listed each server's tools by name and description; each now
has a switch beside it.

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

What was run
- go test ./internal/library -run 'ToolsOff|OffList': per format the
  list is written, removed on re-enable, the user's own entries kept
  (Codex, Gemini, Crush, Hermes, Claude deny, OpenCode tools); cursor
  untouched; SaveServer keeps the list. Broken by hand (no off.apply,
  no syncToolRules): TestToolsOffInTheEntry, TestToolsOffClaudeDeny,
  TestToolsOffOpenCode go red.
- go test -tags nogui ./internal/library ./internal/gui: ok.
- library-mcp-tool-switch.test.cjs: chromium and webkit, en/zh/zh-TW/
  ja/de, 980 and 420 wide: pass; 10/10 red against the old library.js,
  library.css and i18n.js. library-mcp-tools.test.cjs' fixture gives
  Claude Code toolsOff (as the real view does).
- library-*.test.cjs, click-scroll, i18n-keys: chromium and webkit.
- gofmt -l; go vet, GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/library ./internal/gui.
- go test -tags nogui ./... (full suite, under the queue lock).
All in sandbox HOMEs; no live agent config was touched.
2026-10-11 13:44:02 +08:00
yetone 6f4fb883eb library, gui: an MCP server's tools are listed by name and description (nf1qaz2w on Discord)
nf1qaz2w on Discord: "mcp现在好像只能看到有几个工具,看不到具体的工具名和描述等,
能否支持下?" The Library's MCP check kept only len(tools) from tools/list.

What changed:
- internal/library/mcp_check.go: ServerHealth carries ToolList (json
  "toolList"): each tool's name and the first paragraph of its
  description, whitespace collapsed and cut at 500 runes (a tool with only
  a title gets the title); names cut at 128; at most 500 tools kept while
  Tools still counts all. tools/list is now asked through listTools, shared
  by the stdio, streamable HTTP and SSE checks: it follows nextCursor up to
  10 pages, each page with a step budget of its own (the #1467 per-step
  timeout), and a page after the first that is refused ends the list there.
  Before, nextCursor was ignored and only the first page counted.
- internal/gui/assets/library.js/.css: a server whose check listed tools
  shows a chevron on its "N tools" status; a click opens the list under the
  row (name in the code font, description under it, "N more not shown" when
  magpie kept fewer than the server has, and Check again). Clicking the
  count again shuts it. A server with no listed tools keeps the old click,
  which checks it again. The list stays while it is checked again, no
  editor opens, no left-border stripe, no native select. The click guard
  keeps the clicked status in place (a centred row gives up 1px as it
  grows).
- i18n: "Click to see them", "Click to hide them", "{n} more not shown" in
  zh, zh-TW, ja, de.
- docs/subsystems/library.md: the check's tool list and paging.
There is no CLI/TUI output of a server's check, so nothing changed there.

What was run:
- go test ./internal/library: TestCheckKeepsToolNames runs the check on the
  tools/list reply @modelcontextprotocol/server-filesystem really gave
  (captured with npx, testdata/filesystem-tools-list.json, 14 tools, the
  longest description 457 chars); TestCheckToolPages (no description, title
  only, a 1000-char description cut, two pages by nextCursor, the JSON the
  page reads); TestCheckToolPagesEnd (a server that pages forever is asked
  10 times). With the list not kept and paging off, the first two fail:
  "got {State:ok Tools:14 ToolList:[] ...}, want ok with 14 tools, each
  listed" and "...Tools:3 ToolList:[]..., want ok with 4 tools over 2 pages".
- GUI: internal/gui/tests/library-mcp-tools.test.cjs, Chromium and WebKit,
  en/zh/zh-TW/ja/de, at 980 and 420 wide: 20/20 pass; against the old
  library.js it fails. library-*.test.cjs, mcp-signin, search-mcp,
  i18n-keys and click-scroll in both engines: 377/377 pass.
- gofmt -l (nothing), go vet / GOOS=linux / GOOS=windows go vet -tags nogui
  on internal/library and internal/gui, go build for darwin, linux and
  windows (nogui). Full go test -tags nogui ./... under the queue lock:
  every package ok but internal/provider, where TestClaudeSavedAccountDir
  failed "sign-in never finished" (waitDone's 2s bound on a fake claude
  process under full-suite load); alone it passes 5/5. Not touched here.
2026-10-11 09:24:07 +08:00
yetone 36839d503a agent: Claude Code kept in CLAUDE_CONFIG_DIR is listed on the Agents page, and a model picked for it goes to the settings.json it reads (#1482, edussss)
The Agents page looked for ~/.claude/settings.json alone, while the
sessions, the Library, the sign-in, the account import and the gateway's
Claude subscription all read $CLAUDE_CONFIG_DIR. A Claude Code whose
folder is elsewhere (CLAUDE_CONFIG_DIR set) wasn't listed when its CLI
wasn't on magpie's PATH either, and a pick, a tune and the gateway's
stand-in went to a ~/.claude it never reads. The sibling of CODEX_HOME
(d47c0fea0).

appdir.ClaudeDir/ClaudeDirIn is now the one place that knows the folder;
the six copies in sessions, library, gateway and provider use it, and the
agent's place.claudeDir (a WSL distro keeps ~/.claude) gives it to
claudeIn, StandIn and tune.

Run: TestClaudeConfigDirTakesThePick (red with claudeDir reverted to
~/.claude), go test of agent, appdir, desktopdir, sessions, library,
gateway, provider; the full go test -tags nogui ./...; gofmt -l; go vet
-tags nogui on darwin, linux and windows; the test on the Windows box.
2026-10-11 08:18:27 +08:00
yetone 26816de2f9 library, agentplug: an agent a plugin adds is given the Library's instructions, MCP servers and skills where its agent.library says (AlmarionAI on X)
Agent plugins wired models and keys only: library.targetOf had no case
for them, so the Library's instructions, MCP servers and skills never
reached an agent a plugin adds, while the announcement said the
Library carries over.

An agent export can now say
  library: { instructions, mcp, mcpFormat, skills }
each a path (~ and $VAR expanded, as config is). mcpFormat names the
agent whose MCP file it is shaped like (agentplug.MCPFormats: claude,
codex, gemini, opencode, cursor, zed, ... 18 of the library's
mcpFormats). A format outside the list, or an mcp without one, keeps
the plugin from loading. library.pluginTarget makes such an agent a
Target, so it is written as any agent is: magpie's marker block in the
instructions file, servers merged beside the user's own (their fields
kept), skills linked or copied, Applied recording only magpie's part,
backups kept. Takes refuses a place the plugin doesn't name, and says
which agent.library key would give it.

Docs: docs/subsystems/library.md and agent-wiring.md; plugins.html
(en, zh, ja) gets the library field and what magpie does with it.

Run:
- internal/library/agent_plugin_test.go: TestPluginAgentGetsTheLibrary,
  TestPluginAgentWithoutAPlaceIsRefused, TestPluginAgentMCPFormat,
  TestPluginMCPFormatsAreWritten. With targetOf's plugin case and the
  check() validation taken out by hand, the first three go red.
- e2e: a nogui build in a scratchpad HOME (env -i, no live configs),
  `magpie plugin add` of a throwaway toy agent plugin; `library
  instructions set/agents`, `library mcp add/rm` wrote and took back
  only magpie's block and server, the user's "mine" server, its "note"
  field and other keys kept, backups made; with mcp dropped from the
  plugin, `library mcp add ... agents=toy` is refused naming
  agent.library.mcp.
- go test -tags nogui ./... (one unrelated FIFO flake in internal/agent,
  fixed in the commit before), gofmt -l clean, go vet for GOOS=linux
  and GOOS=windows clean. No GUI code changed.
2026-10-11 07:55:23 +08:00
yetone 6876125a19 agent, library: an npm agent or winget's RTK under Program Files updates after Windows' administrator prompt, and says why when it can't (新v学员 on Discord)
On Windows the official Node.js installer leaves npm's global prefix at
C:\Program Files\nodejs, which only an administrator can change. magpie
runs as the user, and writable() on Windows always said true, so the
Agents page offered the update and npm failed with EPERM (mkdir
...\node_modules\@scope), with nothing saying why. The same user then
reported RTK and other actions needing elevation all failing, and asked
for a setting to run magpie as administrator. There is no such setting:
an elevated magpie would write the agents' configs as the administrator,
couldn't start with Windows without a UAC prompt at each login, and
widens what can go wrong. Instead each action that needs an administrator
asks Windows for one, alone.

- agent: writable() on Windows makes and removes a file in the folder
  (update.Writable) instead of always saying yes. An npm CLI in a folder
  the user can't write in is still offered on Windows, marked Admin, and
  its update runs through update.RunElevated, never as the user. Elsewhere
  (/usr/lib, would want sudo) nothing is offered, as before.
- update: RunElevated (Windows) runs the command through
  ShellExecuteEx "runas" on a .cmd script that sets the env that differs
  from an elevated process's own plus PATH, cds to the folder, and sends
  output to a log read back; the exit code comes from GetExitCodeProcess
  (a non-zero one is update.ExitError, for its code). A declined prompt is
  ErrCanceled; no prompt to be had is the new ErrNoAdmin. Other systems:
  CanRunElevated false.
- library: RTK installed by winget for every user (under Program Files)
  is upgraded through the same prompt when only an administrator can
  change rtk's folder; the card's Upgrade title says Windows asks first.
  Install, and an upgrade whose folder looked writable, run winget as the
  user and go through the prompt only when winget answers 0x8A150019
  (command requires admin). winget's codes from the elevated run are read
  as before (0x8A15002B: no newer RTK, no failure).
- A declined or impossible prompt is agent.AdminError (Via npm or
  winget); the GUI answers it with code needs_admin and says, in the
  reader's language, what needs an administrator and what to do: try
  again and allow it, or run the command in a terminal opened as
  administrator, and for npm also moving npm's prefix
  (npm config set prefix "%APPDATA%\npm") and reinstalling.
- Install another agent: its npm commands note when npm's prefix
  (npm prefix -g, memoized) is such a folder.
- Checked, not changed: autostart uses HKCU's Run key, no admin needed;
  magpie never runs npm uninstall; plugins install into magpie's own
  folder with bun; agent CLIs update only on a click; RTK's PATH fix
  writes HKCU's Environment and rtk init -g the user's own agent folders;
  the library's only other exec is the MCP server check.

Run:
- go test -tags nogui ./internal/agent ./internal/update ./internal/library
  (and the full ./... under the lock). TestNPMUpdateNeedsAdmin fails with
  the admin branch removed and with runAdmin bypassed;
  TestRTKUpgradeAsksForAdmin and TestRTKInstallRetriesAsAdmin fail with
  runRTKInstaller never elevating (checked by hand).
- gofmt -l; go vet (darwin), GOOS=linux and GOOS=windows go vet.
- GUI, Chromium and WebKit: cli-update-admin (en, zh), library-rtk-admin
  (en, zh exact; ja, de, zh-TW translated, no npm advice; fails with the
  old Upgrade title), library-rtk-upgrade/-path/-nohook/-gain, gui-ja,
  gui-de, gui-zh-tw, cli-update, i18n-keys.
- Windows box (10.0.0.132): TestWritableSeesDeniedFolder passes, and fails
  on the old writable(). A portable Node 22 with Program Files' ACL
  (Users RX, Administrators F): as a non-elevated token (runas
  /trustlevel:0x20000) npm install -g failed with the reporter's EPERM,
  Writable said false, and dsh's CLI() said Via npm, Admin true; elevated
  it said Admin false. RunElevated from the elevated ssh session installed
  @deepseek-ai/dsh into that folder for real, and a missing version came
  back as exit status 1 with npm's ETARGET output. The library's RTK tests
  ran there too (TestRTKInstallRetriesAsAdmin passes; the shell-fake ones
  skip on Windows).
- Not tried: the UAC prompt itself, allowing or declining it, as nobody
  sits at the box; the ErrNoAdmin path on a real system; a real
  machine-scope winget RTK (none is installed on the box).
2026-10-11 05:33:23 +08:00
yetone f04792f906 icon: remote icons are fetched through usemagpie.ai/api/icon, so their hosts never see the user's IP
A plugin's package.json icon, an import link's icon= and the library's
market icons sit on hosts their authors pick. magpie fetched each straight
from there, so an author could log the IP of everyone who opened Discover
or the library. The owner asked for icons to keep showing without that.

- site/worker.js: /api/icon?url=<https URL> fetches the picture from
  Cloudflare with only Accept: image/* and its own User-Agent, follows
  redirects, caps it at 1 MB (the app's MaxIcon), passes on only PNG,
  JPEG, GIF, WebP, ICO or SVG (by bytes, as StoreIcon), and counts and
  keeps nothing. It refuses http, userinfo, a non-443 port and
  usemagpie.ai itself; 404s are cached 5 minutes, 5xx not at all.
- internal/iconproxy: URL(u) is the proxied address (MAGPIE_ICON_PROXY
  for tests); a picture already on usemagpie.ai is asked for as it is.
- provider.FetchIcon (plugin, import link and partner icons) and
  library.fetchImage (market icons, avatars) fetch through it. The
  import link's checks (https, public host) still come first; there is
  no direct fallback. provider.FaviconFor still reads the user's own
  provider's site directly: they already send it their requests.
- Privacy text in README en/zh, docs/reference.md and site docs
  start/import in en/zh/ja says so.

Ran:
- node --test site/*.test.mjs: 28 pass. The new test asks with Cookie,
  UA, X-Forwarded-For and CF-Connecting-IP and checks only accept and
  user-agent go upstream; 415/413/502/400 cases; its fetch stub throws
  instead of reaching the network. With the usemagpie.ai refusal
  removed by hand it goes red (27/1).
- TestFetchIconGoesThroughTheProxy and TestIconGoesThroughTheProxy
  (author host is .invalid; an httptest server stands in for the proxy):
  with the proxy taken out by hand both go red (provider: lookup
  author.invalid; library: the proxy was never asked), green restored.
- go test ./internal/iconproxy ./internal/provider ./internal/library
  ./internal/gui: ok. gofmt -l clean; go vet darwin (those four),
  linux (iconproxy, provider, library), windows (all four): clean.
2026-10-11 01:28:22 +08:00
yetone da77e825ff library: RTK installed with winget --location into any folder is upgraded with winget (#1527, whyIMBA)
rtkUpgrader took rtk for winget's only when its path had "/winget/" in
it. winget install --location "D:\codes\tools\rtk" puts rtk.exe in that
folder, and the link winget adds in WinGet\Links points there, so the
path once resolved had no "winget" in it: no Upgrade on the card, and
"magpie library rtk upgrade" said magpie can't tell how rtk was
installed, though winget upgrade --id rtk-ai.rtk works on it.

Now, on Windows, after the brew/winget-folder/cargo checks:
- the path heuristic also looks at the path rtk was found at, not only
  the one its link leads to (WinGet\Links\rtk.exe);
- otherwise winget's own record decides: the entry winget writes for a
  portable package under HKCU/HKLM ...\Uninstall
  (rtk-ai.rtk_<source>, WinGetPackageIdentifier rtk-ai.rtk) names its
  InstallLocation; rtk is winget's when it is in that folder, so an
  rtk.exe copied elsewhere by hand isn't taken for winget's;
- with no record to read, winget list --id rtk-ai.rtk --exact is asked
  through proc with a 15s timeout. The answer is kept 10 minutes per
  rtk path, so the Library card doesn't run winget each time it is
  drawn.

Siblings checked: rtkUpgrader is the only Library upgrader with a winget
path heuristic; its brew case matches /Cellar/rtk/, which every Homebrew
prefix has. Agents' CLI updates (internal/agent/cliupdate.go) and
magpie's own update know Homebrew by its Cellar only, and have no
winget, scoop or choco path rules.

Run:
- go test -tags nogui ./internal/library (sandbox HOME). New
  rtk_winget_test.go with a fake winget (its list output from the test
  box): the reporter's folder via the record (no winget run), a record
  for another folder (and a name-prefix sibling folder) is not winget's,
  winget list asked once per 10 minutes, unlisted/empty record/hung
  winget are not winget's, the WinGet\Links link. Broke it four ways
  (record check off, link check off, folder check as a bare prefix,
  cache off) and each failed a test.
- Windows box (winget v1.29.380): winget install rtk-ai.rtk --location
  D:\tools-1527\rtk. With rtk on PATH as D:\tools-1527\rtk\rtk.exe and
  as WinGet\Links\rtk.exe: origin/main's "magpie library rtk upgrade"
  says "magpie can't tell how the rtk ... was installed"; this build
  runs winget upgrade ("winget's RTK is 0.50.0 so far; RTK 0.51.0 is
  out"). A copy of rtk.exe in another folder is still "can't tell".
  rtk uninstalled afterwards.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet on
  internal/library.
2026-10-11 00:37:16 +08:00
yetone d47c0fea0b agent, provider: with CODEX_HOME set, a model picked for Codex goes to $CODEX_HOME/config.toml, the file Codex reads, and its sign-in is read and switched there (#1513, Wakkana, sunxwei)
Wakkana on Discord (macOS, Codex CLI 0.162.1) keeps Codex in a CODEX_HOME
of their own. Picking a model in magpie wrote ~/.codex/config.toml and
~/.codex/magpie-models.json, which Codex never reads, while magpie read the
pick back from the same file and showed it applied.

Checked each claim in the source: codexIn built its folder from
filepath.Join(at.home, ".codex"); so did StandIn, the compact-window tune
and KeepCodexDaemonCurrent; codexAuthPath (logins.go), codexAccount
(account.go) and the Usage card's auth.json (subscription_usage.go) read a
hardcoded ~/.codex, and since the app-server restart takes its home from
codexAuthPath, it restarted ~/.codex's daemon too. sessions.CodexDir,
catalog.CodexHome, library's codexDir and import_codex's config path
already read CODEX_HOME, each with its own copy of the rule.

Now there is one rule, appdir.CodexHome / CodexHomeIn: $CODEX_HOME through
appdir.LookupEnv (so the value proc.UserPath lends the desktop app from the
login shell counts, and a relative one reads as unset), else ~/.codex.
Every place that reads or writes Codex's files goes through it:
config.toml and the catalog (codexIn, so detection, Dir, models_cache,
history, logs, threads too), StandIn, tune, the daemon check, auth.json
read/switch/sign-in/sign-out, the import's own-catalog check, sessions,
the models cache, library targets (AGENTS.md, skills, MCP, rtk). A WSL
distro's Codex keeps ~/.codex (place.codexHome), since magpie can't read
a distro's variables. Left as they are, on purpose: library's project-level
.codex/config.toml (Codex reads that in the project whatever CODEX_HOME
is), sessions/wsl.go and wsl.go's distro probes, cliupdate's standalone
install path, and gateway/prompt.go's "/.codex/" path heuristic for a
Claude Code memory file. Codex itself doesn't expand "~" in CODEX_HOME
(0.162.0: 'CODEX_HOME points to "~/x", but that path does not exist').

Tests:
- TestCodexHomeEnvTakesThePick (agent): CODEX_HOME set, pick fakeup/m1:
  config.toml and magpie-models.json land in CODEX_HOME, Get reads it back,
  StandIn and tune use it, nothing exists under ~/.codex. Old codexIn:
  FAIL "Codex's files at …/001/.codex/config.toml, want under
  …/codex-home"; old tune.go: FAIL "tune didn't write
  $CODEX_HOME/config.toml"; old StandIn: FAIL "stand-in … is """.
- TestCodexHomeEnvSignIn (provider): auth.json, config import path and
  daemon home are CODEX_HOME's; two accounts listed from it; SwitchLogin
  writes it; ~/.codex never created. Old account.go: FAIL "sign-in in
  $CODEX_HOME not read"; old codexAuthPath: FAIL "auth.json at
  …/.codex/auth.json".
- TestRestartCodexDaemon and gui's TestCodexDaemonRestartRoute asserted the
  old ~/.codex daemon under CODEX_HOME=/somewhere/else; they now want
  /somewhere/else. TestFolderVarsAreListed scans appdir/codex.go too, so
  its CODEX_HOME canary still finds the read.

Real use, sandbox HOME + CODEX_HOME=<sb>/custom-codex, MAGPIE_ADDR on a
free port with a stand-in listener: `magpie codex fakeup/m1` (this build)
wrote custom-codex/config.toml + magpie-models.json, no <sb>/home/.codex;
real codex 0.162.0 with that CODEX_HOME: `codex debug models` listed
fakeup/m1, `codex exec` sent POST /v1/responses model=fakeup/m1 to magpie's
address. The origin/main build in the same sandbox wrote
<sb>/home/.codex/{config.toml,magpie-models.json} and left
custom-codex/config.toml at model = "gpt-5.5" (the report). The GUI app
was not run.

#1513 (sunxwei, native Windows 0.1.1157, CODEX_HOME=F:\codex-home) is the
same bug. Windows has no shell to borrow from: a user-level variable is in
the environment Explorer hands the Start-menu app, which is what
appdir.LookupEnv reads, and a drive-letter path is rooted. On the Windows
box: the agent, provider and appdir test binaries (GOOS=windows) pass
TestCodexHomeEnvTakesThePick and TestCodexHomeEnvSignIn with CODEX_HOME a
C:\ temp folder; this build's magpie.exe codex fakeup/m1 in a sandbox
USERPROFILE with CODEX_HOME=D:\codexhome-sb\custom-codex wrote config.toml
(model, magpie provider, catalog) and magpie-models.json there and created
no %USERPROFILE%\.codex. Codex itself isn't installed there, so it was
not run on Windows.

Run: go test -tags nogui ./... in a temp HOME (all ok after the three test
updates above; re-ran agent, provider, gui, catalog, sessions, library,
appdir, usage, codexcat after rebase; gateway after rebase hit the 10m
default timeout at load ~150 and passed with -timeout 25m in 656s),
gofmt -l clean, go vet +
GOOS=linux + GOOS=windows go vet -tags nogui on the touched packages.
2026-10-10 22:36:28 +08:00
yetone 5fb75d26cf agents: WorkBuddy AI, the international build, gets magpie's models in its own ~/.workbuddy-ai/models.json (#1494, ysicing)
WorkBuddy AI (www.workbuddy.ai, bundle com.workbuddy.workbuddy-ai) keeps
its data in ~/.workbuddy-ai: its cli/product.json sets dataFolderName
".workbuddy-ai", and the custom-models reader (getUserConfigPath in
5.6.2's app.asar) takes ~/<dataFolderName>/models.json when
WORKBUDDY_CONFIG_DIR isn't set. magpie only wrote ~/.workbuddy/models.json,
the China build's, so the reporter's WorkBuddy AI never listed magpie's
models although magpie said it was wired.

WorkBuddy AI is now its own agent, workbuddy-ai, built from the same code
as WorkBuddy (workbuddyBuild): its models.json in ~/.workbuddy-ai, a bare
list as WorkBuddy writes one, under its own key (magpie-workbuddy-ai).
WORKBUDDY_CONFIG_DIR stays WorkBuddy's, so the two rows never write one
file. Its MCP servers and skills go to its own folder too (library target),
and the library's "trust it in WorkBuddy" note names WorkBuddy AI when a
server is given to it. README agent lists and docs/reference.md list it.

Run: go test -tags nogui ./internal/agent ./internal/library
./internal/usage ./internal/gateway (sandbox HOME); new
TestWorkBuddyAIWritesItsOwnFolder (writes ~/.workbuddy-ai only, China
file untouched, env var ignored); GUI library-workbuddy-trust in Chromium
and WebKit, en/zh/zh-TW/ja/de, red on the old library.js for the
WorkBuddy AI case. A built magpie in a sandbox HOME lists "WorkBuddy AI
~/.workbuddy-ai/models.json", and `magpie workbuddy-ai provider magpie`
wrote deepseek/deepseek-chat there with key magpie-workbuddy-ai and no
~/.workbuddy. Not tried in the WorkBuddy AI app itself (needs a signed-in
account); the path is read from the installed 5.6.2's own code. gofmt -l,
GOOS=linux/windows go vet clean.
2026-10-10 19:55:29 +08:00
yetone 69c47c9e57 library, gui: the Library page is drawn at once from a glance, and the agents' own skills and out-of-date copies come in after it (#541)
Even with the memo, the first read after skills change still reads
them through, and before this the page showed only its outline until
the whole read was done (0day404, #541: minutes on Windows).

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

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

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

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

Run: go test -tags nogui ./internal/library ./internal/gui; node --test
for library-*.test.cjs, skill*.test.cjs, gui-ja, gui-de and i18n-keys in
both engines; gofmt; vet on darwin, linux and windows.
2026-10-10 19:53:02 +08:00
yetone 3a80ce7fa0 library: reading the Library page no longer reads every byte of the agents' skills each time; a folder unchanged since the last read isn't opened again (#541)
0day404 (#541, Windows): the Library page spins for minutes each time it
is opened. The page waits on GET /api/library, and library.Read, under
the library lock, compared every skill an agent has of its own with the
same name in each other agent byte by byte (foundSkills -> sameTree ->
sameFile) and hashed every library skill given as a copy (behind ->
libHash -> hashDir). Skills with node_modules or templates, given to
several agents, are hundreds of MB per read; on Windows each file opened
is scanned.

What sameTree and hashFiles found is now kept against a stamp of the
folders: each file's and link's path, type, size and mtime (stamper in
treememo.go). The walk that compares or hashes a folder stamps it as it
goes, before opening a file, so a folder seen for the first time is
walked once, as before; a later read walks it without opening a file, and
while the stamps match, the answer is reused. In foundSkills a skill held
by several agents is walked once per read, not once per pair.

What is never taken as unchanged:
- a folder that can't be walked, or a file in it that can't be read
  (compareTrees and sameFile now say whether they read everything): it is
  unknown, not the same, and compared again next time;
- a folder with a file written in the last 3s (a rewrite within a file
  system's time granularity can keep size and mtime);
- any change of a file's size or mtime, or a file added or removed.
A rewrite that keeps both size and mtime (cp -p of a same-size file) is
not seen, as with rsync's quick check. .git, .DS_Store and magpie's mark
aren't part of a stamp, as they aren't part of the compare. hashFiles'
hashes are byte-for-byte what they were (they are kept in library.json
and each copy's mark).

Measured on the Windows box (Windows 11 x64, test binary, 20 library
skills given as copies to 4 agents and 40 own skills in 3 agents, each
300 files of 8KB under node_modules), library.Read:
  before:  5.5-6.3s every read
  after:   5.0s the first read after start, then 2.0s
(Glance, the next commit, is 80ms.) The Mac was under load average ~118
from other work, so its timings weren't comparable.

Tests:
- TestPageReadDoesntReadUnchangedSkillsAgain: aged folders, the second
  read finds codex's copy the same with its files made unreadable; an
  edit afterwards is read again and found to differ.
- TestJustWrittenSkillIsReadAgain: a folder written a moment ago isn't
  taken from the memo.
- TestUnreadableSkillIsntRememberedAsDifferent (scripts/run.sh made
  unreadable; SKILL.md unreadable leaves the skill unlisted).
- TestEditedLibrarySkillIsHashedAgain: a library skill edited to the same
  size and aged an hour after a read: its copies are behind.
- TestHashUnchangedByTheMemo: hashFiles' value for files, a link,
  .DS_Store and .git; passes on the old code too.
Broken by hand, each goes red: stamp without mtime (PageRead,
EditedLibrarySkill), memo never hit (PageRead), unsure compares kept
(Unreadable), unsettled folders kept (JustWritten).

Run: go test -tags nogui ./internal/library ./internal/gui (macOS); the
library package's tests on the Windows box; gofmt; vet on darwin, linux
and windows.
2026-10-10 19:53:02 +08:00
yetone 61aa681e60 library: an MCP server, or the servers picked, are copied as an agent's project file has them, to paste into a project magpie doesn't keep (#1478, xiaozhu1337)
A project's MCP servers could only be given by adding the project to
magpie first. For a one-off (add them, then let the project keep them),
that is a detour. Now the servers page's Select bar, and a server's
editor, have Copy config…: a menu of the agents that read a project's
servers from a file (Claude Code .mcp.json, Codex .codex/config.toml,
Gemini, Cursor, OpenCode, ZCode, Pi), each with its file. A pick puts
that file's text on the clipboard and the status says where to paste it.

What changed:
- library.ConfigOfServers(agent, names): the servers written by the same
  code a project of magpie's is written with (mcpFile.put, through() for
  one magpie is signed in to, the agent's own variable syntax) into a
  fresh file in a temp folder, read back and removed. Nothing in the
  user's files is written. A server the agent can't take there (SSE for
  Codex or Pi, a ${VAR} it can't read) is left out and named, as a
  project's sync leaves it out.
- POST /api/library/mcp/config answers {file, text, skipped}.
- library.js: copyConfigButton in the pick bar and the editor's bar;
  strings in zh, zh-TW, ja, de.
- docs/subsystems/library.md says so.

Run:
- TestConfigOfServersIsTheProjectFile: for every agent in
  projectMCPFiles, the copied text equals byte for byte the file magpie
  writes into a fresh project with the same servers, the servers left out
  are those supports() refuses, a signed-in server is the gateway's
  /mcp/<name>; with through() taken out it fails.
- library-mcp-copy-config.test.cjs in Chromium and WebKit, en/zh/ja/de at
  440px: the menu's agents and files, the post, the clipboard text, the
  left-out status, nothing copied when nothing fits, the editor's button;
  no sideways scroll. The library and project GUI tests that draw the
  pick bar or the editor (18 files) pass in both engines.
- go test -tags nogui ./internal/library/ ./internal/gui/ under a temp
  HOME; gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui.
- Not clicked in a running magpie window; the page against a faked API
  and the library code under a sandbox HOME only.
2026-10-10 18:35:17 +08:00
yetoneandggbdpq 91581fca27 library: a WSL agent under NAT is given a signed-in MCP server with the LAN key, so the gateway no longer answers its every call 401 (#1488, ggbdpq)
A server magpie signed in to (#615) is given to the agents at the
gateway's /mcp/<name>, at the address each reaches the gateway at. A WSL
distro under NAT reaches it at Windows' address, so its requests come
from another machine, and lanGuard refuses such a request without an
enabled gateway key with a 401, which an MCP client takes for the server
asking it to sign in. through() gave it no key. Its models already carry
the LAN sharing key there (keyAt, whqtian on Discord); the relay didn't.
The gateway's checks are unchanged: a request from another machine still
needs the key, and mcpProxy still lends a sign-in beyond loopback only
to a request that carried it (sharedWith).

What changed:
- agent.KeyAt exports keyAt: the LAN sharing key for an agent that
  reaches the gateway from another machine while sharing is on, else
  gateway.Token.
- through() gives such an agent Authorization: Bearer <that key>. The
  gateway takes it in lanGuard, and mcpProxy drops Authorization for
  magpie's token, so the server never sees it. An agent on loopback, and
  one in WSL while nothing is shared, stay keyless.
- access.LANChanged runs after sharing is turned on or off or its key is
  made anew; the library syncs again then when it relays any server, so
  the entry carries the key there is now without a visit to the Library.
- docs/subsystems/library.md says so.

Run:
- TestSignedInServerCarriesKeyBeyondLoopback (library: a FakeWSL distro
  routed via 172.20.0.1, LAN on) fails on the old through() ("claude@wsl:
  Ubuntu under NAT is given headers map[X-Team:acme], want the LAN key as
  its Authorization") and passes now; with the LANChanged call commented
  out it fails at "after a new key ... is given" the old key.
- TestMCPProxyFromWSLWithLANKey (gateway, through lanGuard as the server
  runs it): 401 without the key and the server not called, 200 with it,
  the server gets magpie's token and never the key.
- go test -tags nogui ./... under a temp HOME; gofmt -l; GOOS=linux and
  GOOS=windows go vet -tags nogui on the touched packages.
- Not tried on a real Windows + WSL NAT machine with a real OAuth MCP
  server; FakeWSL and httptest only.

Patch by ggbdpq in #1488; the LANChanged resync added on top.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-10 18:09:59 +08:00
yetone c78974407b library: an MCP server's check gives each step its own budget, 60s for a URL, says which step went unanswered and for how long, and doesn't keep a timeout for the session (#1467, xiaozhu1337)
xiaozhu1337's remote MCP servers are slow but healthy: initialize took
0.6-12s, notifications/initialized 0.7-3.5s and tools/list 38-53s. The
check had one 15s budget for all of it (checkTimeout), so every such
server showed "no answer", and CheckServers kept that first result for
the session.

Now each step (initialize, notifications/initialized, tools/list; connect
for an SSE server's stream) has a budget of its own: remoteStep 60s for a
URL, stdioStep 30s for a command (was 15s for the whole check). The timer
is reset as each step starts (stepTo). A timeout says its Step and how
long it Waited (ms), and the row reads "no answer to tools/list", the
tooltip "No answer to tools/list in 60 seconds". A timeout isn't kept,
and it drops an earlier answer kept for the server, so the next look (or
a click on the status, as before) asks again. Strings in en, zh, zh-TW,
ja and de; the old "No answer in 15 seconds" is gone. No per-server
setting: the per-step budget covers the reported timings.

Run:
- TestCheckSlowRemoteServer, TestCheckTimeoutNamesTheStep,
  TestCheckTimeoutAskedAgain (new): fail on the old code (one budget:
  the 2.9s server times out at initialize; the step is always
  initialize; a timeout, and an earlier ok after a fresh timeout, are
  served from the cache), pass now. The rest of TestCheck* pass.
- go test -tags nogui ./... under a temp HOME: all ok.
- gofmt -l: clean. go vet (darwin, GOOS=linux, GOOS=windows) on
  internal/library and internal/gui: clean.
- GUI: library-mcp-health (status names the step, stays one line within
  220px), i18n-keys, gui-ja, gui-de in Chromium and WebKit: 13/13 pass.
- Real use: `magpie web` on 127.0.0.1:3783 under a scratch HOME, a
  library server on a fake streamable HTTP MCP on 3784.
  POST /api/library/mcp/check: at 8s/2s/45s it is ok with 7 tools
  (55s); with tools/list at 70s it is timeout, step tools/list, waited
  60000 (62s); then at the reporter's slowest 12s/3.5s/53s a non-fresh
  check asked it again and got ok with 7 tools (68s).
2026-10-10 17:49:07 +08:00
yetone e04824714d library: a skill's templates and other big files go with a backup and a sync (Crispin)
Crispin on Discord (#help): a skill's template files, a PPT among them,
didn't reach the other computer. Collect read each skill file with a 2 MB
cap and left everything bigger out, so a .pptx template with its pictures
never travelled. Links, copies and WSL copies on one computer already carry
every file (copyDir and hashFiles have no filter); only the backup/sync
carry dropped them.

- A file goes up to 16 MiB, all skills together up to 32 MiB. A sealed
  backup is JSON with the bytes base64'd twice (~x16/9), and a sync reads
  at most 64 MiB of one, so 32 MiB raw is what still fits.
- readSkills fills that budget smallest file first across every skill, so
  one skill's big file never keeps another skill's SKILL.md from coming.
- What is left out (Left) and the computer being put to already has is
  kept (keepLeft): a Put no longer sets the folder aside without it. A Left
  name is checked like a carried one.

Run:
- New tests fail on the old code: TestCarryTemplates (template left),
  TestCarrySmallFirst (zzz's notes.md left), TestCarryKeepsWhatWasLeft
  (the local file went), TestSkillTemplatesTravel (0 bytes of 6291456).
  Pass on the new. TestSkillTemplateReachesEveryAgent covers link, copy
  and WSL copies of a pptx.
- Break check: maxCarriedAll = 48 MiB makes TestSkillTemplatesTravel fail
  ("the backup is 64 MiB, more than a sync reads").
- Real use: built nogui binary, sandbox HOMEs, a real 2.8 MB and a real
  14 MB .pptx in a library skill, `magpie backup` then `restore
  --no-agents` on another HOME: sha256 identical both times.
- go test -tags nogui ./... (temp HOME, pinned caches): all ok.
- go vet (darwin, GOOS=linux, GOOS=windows) on internal/library and
  internal/backup; gofmt -l clean.
2026-10-10 14:52:17 +08:00
yetone 282c9feb23 agent: a packaged Claude Desktop gets magpie's gateway in the real %LOCALAPPDATA%\Claude-3p too, which 2.31226 reads, not only the package's (bg5eau on X)
bg5eau on X: Claude Desktop 2.31226.1, installed as an MSIX package on
Windows, never reached magpie. magpie wrote deploymentMode and its
configLibrary profile only into the package's
LocalCache\Local\Claude-3p, and that build reads the real
%LOCALAPPDATA%\Claude-3p. Copying configLibrary there and setting
deploymentMode 3p fixed it for them.

What the build does: 2.31226.1's asar (index.chunk-Cyt2WTko.js) resolves
the 3p userData with Ou() = path.join(LOCALAPPDATA, "Claude-3p"). 2.7032.0
has the same code (GY()). It reads deploymentMode from
Ou()/claude_desktop_config.json and the gateway from Ou()/configLibrary.
The path didn't change; the package stopped redirecting it into
LocalCache. An install's folders don't say which build it is, so:

- desktopdir.Sets returns every set of folders: Find's choice first, then
  the other one for an MSIX install. Everywhere lists every set's folders.
- Claude Desktop's switch writes and removes deploymentMode, the profile
  and _meta.json in each set. The package's set keeps its own stash keys
  (".package"). A stash that an older magpie wrote for the package's
  folders moves onto those keys, so turning it off still restores them.
- The check runs on each set, names the folder when there are two, and
  checks Claude-3p's deploymentMode as well.
- The siblings: the library's MCP servers go into every Claude-3p file
  that exists, and Cowork skills and Desktop sessions are read from every
  set.

Run:
- go test ./internal/{desktopdir,agent,library,sessions,usage}: green.
- The new tests (TestClaudeDesktopMSIX, TestClaudeDesktopMSIXStashBefore,
  TestClaudeDesktopMSIXBoth3p) and TestCallsCoworkMSIX are red against
  the old code. StashBefore also goes red with desktopAdoptStash disabled.
- gofmt; go vet for darwin, linux and windows.
- On the Windows box, Windows test binaries for the four packages:
  - desktopdir and library pass.
  - agent and sessions fail exactly the set that main's binaries fail
    there (#1388, and newly filed #1468).
  - Every Desktop test passes.
2026-10-10 14:13:05 +08:00
yetone 16539c2ea9 imagemcp: generate_video and the Magpie Image card name every video model the gateway makes videos with, not a Grok subscription alone (#1399)
shen-joe (#1399) wants images and videos from magpie in PI-Desktop and
WorkBuddy. Neither app sends video generation to a custom provider: PI-Desktop
has no video generation at all, and WorkBuddy's VideoGen/ImageGen post to
copilot.tencent.com's /v2/videos|images/generations with the account token.
So the way those agents get videos is Library → MCP → Magpie Image
(`magpie mcp image`). Its generate_video tool told the agent it works only
"with a Grok subscription signed in to Magpie (it has no other video model
yet)", and the Library card said the same, while gateway.Videomakers also
makes videos with a preset plan's videos (Volcengine Ark Agent Plan's
Seedance), another magpie, and a custom provider whose model list marks video
models (#1446). An agent reading that can tell a Seedance user they need Grok.

- imagemcp.go: generate_video's description and the package doc name each
  kind of video model.
- library/market.go: the Magpie Image card says "a video model set up in
  Magpie (Grok Imagine, Seedance)"; zh, zh-TW, ja and de follow.
- Tests: TestVideoToolSaysEveryVideoModel and TestMagpieImageSaysVideoModels
  fail on the old text and pass now.

Run: go test -tags nogui ./internal/imagemcp ./internal/library ./internal/gui
./internal/gateway (ok) and ./... (only TestNoCommandBypassesProc red, from
2da8fbe4, fixed on main by b934d64a); gofmt -l; GOOS=linux and GOOS=windows
go vet of imagemcp and library. A built magpie's `mcp image` answered
tools/list with the new description. A sandbox gateway (scratch HOME,
127.0.0.1:3591, a real OpenRouter key) answered PI-Desktop's exact request,
POST /v1/images/generations {"model":"openrouter/google/gemini-2.5-flash-image",
"prompt":…,"n":1}, with 200 and data[0].b64_json, a PNG.
2026-10-10 10:58:31 +08:00
yetone 47a313f618 library: Pi's MCP servers go to ~/.pi/agent/mcp.json, the file Pi 0.99+ loads, unless pi-mcp-adapter is really loaded; an adapter left installed but not listed no longer sends them to mcp-adapter.json (sydney on Discord)
sydney reported that the Library wrote Pi's MCP servers to
~/.pi/agent/mcp-adapter.json while Pi 1.0 loads ~/.pi/agent/mcp.json.

Pi's own source (npm @earendil-works/pi-coding-agent):
- 0.99.0 to 1.1.0 have built-in MCP: dist/extensions/mcp/config.js
  loadMcpConfig reads <agentDir>/mcp.json (and a trusted project's
  .pi/mcp.json). An extension registering /mcp (pi-mcp-adapter) replaces
  it; "extensions": ["-builtin:mcp"] turns it off.
- 0.87.1 and earlier have no MCP; pi-mcp-adapter 3.x/4.x reads
  mcp-adapter.json only, adapter 5.0.0+ also reads Pi's mcp.json on a Pi
  with registerMcpServer.
- core/package-manager.js resolve() loads only settings.json "packages",
  "extensions" entries and <agentDir>/extensions/. npm/node_modules, git/
  and the global npm root are install places, not loaded on their own.

magpie counted any pi-mcp-adapter folder (npm/node_modules, git, global
root) as loaded, so an adapter left behind with "packages": [] made it
write mcp-adapter.json, which nothing reads, and move mcp.json away
(heliar-k's #1097 is the same case). It also fell back to the adapter file
when Pi's version was unknown.

Now:
- piDetect follows Pi's loader: a package is loaded only when listed (an
  object entry with "extensions": [] loads none), "-"/"!" entries turn one
  off, and <agentDir>/extensions/<name> loads; the other folders only give
  the version.
- An unknown Pi version is taken as one with built-in MCP.
- With no adapter loaded, servers in mcp-adapter.json are moved into
  mcp.json (both backed up first); nothing in either file is dropped.
- With adapter 5+ loaded on a Pi with built-in MCP, mcp.json is left
  where it is (the adapter reads it) and new servers go to the adapter's
  file; with adapter 3/4, or on Pi before 0.99, the old move is kept.

Tests: TestPiMCPUnloadedAdapter, TestPiDetectLoaded and
TestPiMCPAdapter5KeepsPiFile fail on the old pimcp.go and pass now;
older tests that relied on an unlisted adapter now list it.

Run: gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui
./internal/library/; go test -tags nogui ./internal/library/
./internal/agent/ under a temp HOME. Real Pi in a sandbox HOME:
- Pi 1.0.4, reporter's layout (adapter 5.2.0 in npm/node_modules,
  "packages": []): `magpie library mcp add` wrote mcp.json and `pi mcp
  list` shows both the user's server and the new one connected. The old
  binary wrote mcp-adapter.json and Pi listed no servers. `magpie library
  sync` with pi off PATH (version unknown) moved that home's
  mcp-adapter.json back into mcp.json, with backups, and Pi connected both.
- Pi 1.0.4 with `pi install npm:pi-mcp-adapter@5.2.0`: mcp.json is kept,
  the new server goes to mcp-adapter.json, and `pi-mcp-adapter doctor`
  connects both.
- Pi 0.87.1: still mcp-adapter.json, as before.
Not run: Windows or WSL Pi, project-level .pi/settings.json, a real
interactive Pi session.

Reported by sydney on Discord; same cause as #1097 (heliar-k).
2026-10-10 10:18:16 +08:00
yetone c4476d5658 library: skills from GitHub are checked as the skills page opens, and one changed here is marked and asked about before an update replaces it (#1449)
YangZhiqiang98 asked (#1449) that the Library find which skills have
updates and update them. magpie already checked skills from GitHub (a
market install among them) by hand and could update them, but an update
deleted the library's folder, so a skill the user had changed (by hand,
through an agent's link, or in an agent's copy not yet taken in) was lost
without a word, and nothing checked unless the user pressed Check.

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

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

Verified:
- go test -tags nogui ./... (sandbox HOME); new TestUpdateKeepsASkillChangedHere,
  TestUpdateKeepsACopyEditedInAnAgent, TestUpdateKeepsWhatItCantTell,
  TestCheckDue, TestCheckSkillsMarksItDone, all from httptest. With
  editState forced to "not changed" the first three fail.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui on
  ./internal/library ./internal/gui ./internal/tui .
- GUI: new skill-update-edited.test.cjs (Chromium and WebKit, 860 and
  400px, en and zh; no scroll on click; fails with the row's ask removed),
  plus the 22 other library skill tests, gui-ja, gui-de, gui-zh-tw,
  i18n-keys and click-scroll: 262 pass.
- Real use in a sandbox HOME with github.com/anthropics/skills: installed
  pdf and docx, the real check said both current; an edit through Claude
  Code's link was refused by `skill update pdf`, skipped by `skill update`
  (docx updated), replaced by `--replace-edits` with the edit in
  backups/<time>/library/skills/pdf; docx edited later shows edited, a
  .DS_Store doesn't.
2026-10-10 09:14:35 +08:00
yetone 599d784f59 library: magpie-image runs this computer's magpie, whatever path another computer or an old install saved (#1439, dawn1095)
magpie-image was kept in library.json with one computer's magpie by full
path (os.Executable at install). A WebDAV sync carried
C:\Users\...\Downloads\magpie-windows-amd64.exe to a Mac (and a Mac's app
to Windows), and a magpie moved out of Downloads left its old path behind:
the Library page said it couldn't start, and agents were given a program
that isn't there.

- heal (self_here.go): a server that is magpie's own -- `mcp ...` run by a
  program named magpie (magpie, magpie.exe, magpie-<os>-<arch>[.exe]) --
  whose program isn't an existing absolute path here is pointed at this
  magpie, as the library is read (load) and after every change (so a
  bundle Put from another computer is healed before it is written into
  the agents). Every agent writer, project MCP files, the WSL side and
  CheckServers read through load, so all of them get it. A magpie program
  that does exist here (another build) and any server run by another
  program are left as they are.
- Collect carries magpie's own server as plain "magpie": two computers
  with the same library carry the same bundle, so davsync's library hash
  matches and a sync doesn't write one's path over the other's.
- The path given is update.Program (exported cliProgram): the AppImage
  rather than its mount, Homebrew's opt link rather than the Cellar.
- TestWSLMagpieImage now says which magpie this (simulated Windows)
  computer runs.

Verified:
- New tests: TestOwnServerFromElsewhereRunsThisMagpie (Windows path read
  on macOS, a Mac path, an exe moved out of Downloads, a bare "magpie"),
  TestUsersOwnServerStaysAsItIs, TestCarriedOwnServerIsEachComputersMagpie.
  Broken by hand five ways (heal off; no heal in change; no marker in
  Collect; ownServer matching every server; existing magpie builds not
  kept) -- each went red with a FAIL naming the behaviour, green restored.
- gofmt -l clean; go vet -tags nogui ./...; GOOS=linux and GOOS=windows
  go vet (library, update, davsync); go build, GOOS=linux -tags nogui and
  GOOS=windows builds; go test -tags nogui ./... green in a sandbox HOME.
- Sandbox app (own HOME, ports 3561/3562) seeded with a library.json
  holding the reporter's Windows path for magpie-image plus a user's own
  missing Windows tool: on start library.json, Codex's config.toml and
  Claude Code's .claude.json got the running binary; /api/library/mcp/check
  answered magpie-image ok with 3 tools, the user's server unchanged and
  notfound.
Not verified: on the Windows box, or a real two-computer WebDAV sync.
2026-10-10 01:30:40 +08:00
yetone 059171006b library: DeepSeek Harness is given a server's ${NAME} as a !!js expression it reads from its environment (#1435, CnsMaple)
A Library MCP server whose headers or env named a variable as ${NAME}
(#1250) was refused for dsh, because dsh had no reference syntax in
refsOf. dsh does have one: a YAML !!js value is evaluated as the row
activates (dsh 0.2.0-rc.2: cordis-plugin-include's entryListSchema
reads the tag, quoted or not; cordis-plugin-loader's interpolate
evaluates it across the whole config), and dsh-mcp-client's README uses
GITHUB_TOKEN: !!js process.env.GITHUB_TOKEN. A stdio server needs it so:
it inherits dsh's environment without credential-shaped names
(scrubbedParentEnv).

What magpie writes now (refsOf fmtDsh -> refDsh, dshRef):
- a whole ${NAME}: !!js process.env.NAME (bare, as the README has it)
- text mixed with variables: the text as JSON string literals joined
  with (process.env.NAME ?? ""), YAML-quoted. The user's text is only
  ever inside a JSON string literal, so nothing in it runs as code, and
  NAME is the envRef pattern [A-Za-z_][A-Za-z0-9_]*. An unset variable
  inside a mixed value is "", not "undefined".
dshUnref reads exactly those forms back as ${NAME}, so an entry magpie
wrote reads as same and a sync changes nothing; any other !!js still
keeps the entry the user's (hasJS), as before.

The reporter asked for the value to be resolved into a literal when the
file is written. This writes a reference instead, keeping #1250's rule
that the token never lands in an agent's file as plain text. dsh
evaluates it from its own environment at load time. Their side note
that a quoted !!js isn't evaluated is not what dsh 0.2.0-rc.2 does: its
own --dump-config prints !!js quoted, and the quoted forms evaluated in
the run below.

Since AgentView.NoEnvRefs comes from refsOf, dsh's chip is no longer
greyed and the GUI notice drops it with no string change.
docs/subsystems/library.md says what dsh gets.

Run:
- real dsh 0.2.0-rc.2 `dsh headless` in a sandbox (HOME and DSH_HOME
  under a scratch dir, never ~/.dsh), on a cordis.patch.yml written by
  magpie's mcpFile: a stdio fixture got T1435_A=<token> (whole) and
  "Bearer <token>" (mixed); an injection string with quotes, backticks,
  ${, backslashes and "'); process.exit(3); ('" arrived verbatim; an
  unset variable in a mixed value gave "pre--post"; a streamable-http
  fixture received Authorization: Bearer <token>, the whole-variable
  header and the literal header. magpie read every entry back as same.
  A whole !!js process.env.UNSET makes dsh leave the server out as an
  invalid config.
- go test -tags nogui ./... (temp HOME, pinned caches): green.
- break by hand: refsOf without fmtDsh, encode writing raw values, and
  decode not unref'ing each make TestEnvRefsDsh fail (decode also
  TestDshImportKeepsJS).
- gofmt -l; go vet ./...; GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/library; go build for darwin, linux and windows (nogui).

Not run: dsh on Windows (the reporter's system), and a real LLM turn
calling a tool through the server (no dsh account in the sandbox; the
MCP servers had connected before dsh stopped for its missing LLM
credential). No GUI test was run, as no GUI file changed.
2026-10-10 00:43:26 +08:00
yetone 2c1b593675 library: Zed takes MCP servers, in its settings.json context_servers (lc on Discord)
lc on Discord ("agent未识别到zed"): the MCP server editor's agent chips
had no Zed. magpie already edits Zed's settings.json for its model, and
Zed reads its MCP servers from context_servers in that same file, so Zed
is now an MCP target like the other agents.

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

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

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

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

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

Not verified: a real Zed reading the written file (the live
~/.config/zed was never touched); Linux and Windows beyond vet/build;
Zed found in WSL (not in ownFolder, so no MCP target there); a
project's .zed/settings.json (not added).
2026-10-10 00:37:32 +08:00
yetoneandClaude 3bf88948b5 library: a skill in a private GitHub repository installs with the GitHub token set in Settings → Network and sharing (or GITHUB_TOKEN/GH_TOKEN), asked of GitHub's API, which alone gets the token; without one the error says where it is set (37FlowAI on X)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-08 23:58:22 +08:00