Commit Graph
56 Commits
Author SHA1 Message Date
yetone aa6a0d6b20 library: one skill over 200 MB is left out, not the whole repository (#2062)
mikubaka88/CCFA-Skills couldn't be installed at all: "the skills in ... are
too big to install (over 200 MB)". The repository is over the 200 MB
tarball cap, so fetchSkillFiles fetched it file by file, and that refused
the whole repository once the files summed past 200 MB. One skill,
ccf-paper-writer, is 297 MB on its own (exemplar paper PDFs, llava-4d.pdf
alone 46.8 MB); the other 16 are small.

The 200 MB limit per skill stays: a skill is copied into every agent that
gets one as a copy, and treeOf stops comparing at 256 MB, so a 297 MB skill
can't be told current or edited. What changes is that one such skill no
longer blocks the rest:
- fetchSkillFiles sums each skill's files (the deepest skill folder a file
  is under) and leaves out a skill over maxFetch; its files are never
  asked for. Only when every skill is over it does it fail as before.
- The left-out skills reach ProbeSkills as Probe.Left (path, size), kept
  per temp folder and taken once (tookLeftOut).
- The GUI's probe names each under the list ("{name} is too big to
  install: 283 MB, over the 200 MB a skill may be"), or in place of "No
  skills there" when nothing else is left; zh, zh-TW, ja, de. The TUI says
  it in its flash.
- docs/subsystems/library.md says how a big repository is fetched.

Run:
- Real: probe of mikubaka88/CCFA-Skills under a sandbox HOME lists 16
  skills and leaves out ccf-paper-writer (296736735 bytes). Not installed
  into a real agent.
- gofmt -l internal/: clean. go vet ./internal/gateway ./internal/library
  ./internal/tui on darwin, GOOS=linux -tags nogui, GOOS=windows (set -o
  pipefail): clean.
- go test -count=1 ./internal/library ./internal/tui: ok.
- TestOneSkillTooBigLeavesTheOthers (new): fails with the per-skill
  leave-out turned off by hand, passes with it.
  TestTooBigRepositoryChecksWhatArrives now makes every skill too big.
- skill-too-big.test.cjs (new), chromium and webkit, en 980 and zh,
  zh-TW, ja 440, de 420, plus every-skill-too-big: 14/14; red (0/7 in
  chromium) with client.js at origin/main. skill-*.test.cjs 190/190 and
  library-*.test.cjs 484/484 in both engines.
2026-10-14 09:32:21 +08:00
yetone 8da304767a gui: Library is a plugin's page, its script, style and words in plugins/library
P2 of docs/subsystems/plugin-runtime.md, the second page after Sessions.

- library.js and library.css move to assets/plugins/library/ (client.js,
  library.css). The script registers with the kernel
  (magpie.plugin("library")) and adds its page to the "page" slot. Its
  hooks: open and relang load, redraw, close (its modal), dirty, discard.
  What it set up at load (list scroll and resize, the modal's backdrop
  and Escape, beforeunload, the stuck header, a quiet reload on focus)
  runs in mount.
- app.js calls those through magpie.call instead of window.loadLibrary,
  redrawLibrary, closeLibraryModal, libraryDirty and discardLibrary. It
  no longer lists library in its title map, hide loop or OPEN_VIEWS; the
  kernel's pages are in them.
- index.html: <main id="view-library"> goes, the kernel makes it.
  library.css keeps its place in the cascade.
- The 560 strings only Library says move from i18n.js to
  plugins/library/i18n.js (4 languages). i18n.js: 18826 → 16584 lines.
- plugins/library/library.go lists the client files.
- Tests that read i18n.js for a Library string read strings.cjs (i18n.js
  and the plugins'): 8 library tests and mcp-editor-cancel,
  mcp-oauth-app, mcp-signin-health. font-cascade, win-fonts and
  assets_revalidate_test.go name the new paths.
- "Check again" stays in i18n.js: Library said it alone when the words
  were split, and a5d72a095 (Settings' search keys) says it too since.
  i18n-keys has a new test, "a plugin's words are its own": a key in a
  plugin's i18n.js that any file outside the plugin's folder says fails
  it, naming the file. It was red on this key, and search-keys.test.cjs
  said "Check again" had no zh translation.
- docs: library.md, gui-shell.md, plugin-runtime.md.

Run, at this tree:
- 101 GUI test files touching Library, skills, MCP, the plugins, the
  shell and every language (gui-de/ja/zh-tw, i18n-keys, page-width,
  view-no-sideways, mobile-web, text-size, …): Chromium and WebKit, 4 at
  a time, all green but one. text-size's "zh: 100% picked at the foot"
  failed once in Chromium under load ("scrolled from 160 to 109 (max
  115)"); it passed alone, 6 at once here and on origin/main 8f34bbcd1,
  and at 6× and 12× CPU throttling. It's the Settings page, already
  "fixed" by 50dd39104, so I filed it as #2058.
- After rebasing onto origin/main 75cbc7e1e: i18n-keys, search-keys,
  library-mcp-tools, library-all, gui-de, mono-icon-redraw,
  group-first-token, Chromium and WebKit, green.
- go test ./internal/gui/ ./internal/pluginrt/ ./plugins/...; gofmt;
  go vet on darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
2026-10-14 08:33:25 +08:00
fjrtdk 8f34bbcd11 library: Grok Build and Grok App can be given hooks (#1790)
The Hooks tab said "Grok App has no hooks magpie can write" and RTK said
"No rtk hook". RTK stays correct for now (rtk init has no Grok agent), but
the hooks message was wrong: the Grok CLI keeps hooks as [[hooks.<Event>]]
array tables in its config.toml, which Grok App reads from agent-home on a
custom route. Hindsight already ships three hooks into both configs.

Add grok and grok-app to hookAgents with a TOML hook spec. A hook is written
as a [[hooks.<Event>]] table with a [[hooks.<Event>.hooks]] child, the same
find/claim/drop logic as a JSON agent's: the block text is recorded entry by
entry, so only a block still exactly as magpie wrote it is ever taken out,
and the user's own blocks around it stay as they are. Portable events map to
Stop / PostToolUse / PreToolUse / UserPromptSubmit / SessionStart; a tool
matcher uses Grok's own tool names (run_terminal_command, search_replace).
Grok Build and Grok App run the one CLI, so a grok:<Event> own event goes to
both (sameHookFamily).

edit gains WriteTOMLFile and SplitLines so the library can round-trip a
config's lines through the same validating write the other TOML editors use.

Verification (branch grokapp-hooks):
- TestHooksGrokConfigTables fails on the pre-change code with a real FAIL
  ("Grok Build has no hooks magpie can write"); passes with the change.
  Broke the matcher map, the drop and the event map by hand; each break is
  caught by the test.
- go test ./internal/library ./internal/edit: 811 passed (was 828 before the
  two new grok cases and the hookAgents additions).
- gofmt -l clean; go vet on mac, GOOS=linux -tags nogui, and GOOS=windows all
  clean; go build, GOOS=linux go build -tags nogui and GOOS=windows go build
  all succeed.
- go test -tags nogui ./... has three pre-existing failures on base cdb7b5ff
  (internal/gateway TestGrokCallsGiveCodexIntegers, internal/library
  TestRTKCheckLatestDoesNotWaitForThePackageManager, internal/proc
  TestNoCommandBypassesProc); none is in a file this change touches, and each
  reproduces without it.
- Real use: confirmed against the local Grok App 0.2.40 / grok 1.0.55 install
  that agent-home/config.toml already carries Hindsight's [[hooks.*]] tables,
  so the shape matches what magpie now writes. The GUI Hooks tab is driven by
  the backend hookAgents view, which now lists grok and grok-app; the Tauri
  window itself was not clicked through.

Reviewed before landing (fu13-pt, on e297a8ab2 + #1889/#1897/#1900/#1989):
- The shape is Grok's own: grok 1.0.50's binary carries its user guide
  (10-hooks.md), which reads hooks from ~/.grok/config.toml as
  [[hooks.<Event>]] with an optional matcher and an inner hooks array,
  the [[hooks.<Event>.hooks]] form accepted; handler fields type, command,
  url, timeout, env; run_terminal_command and search_replace are its tool
  names (Bash and Edit|Write|MultiEdit are aliases of them).
- A scratch test (not committed) on a config holding a user's inline
  `hooks = [ {...} ]` Stop block, a comment, [mcp_servers.x], a user
  PreToolUse block and [ui]: add (Stop, PreToolUse on shell), edit the
  timeout, remove both. The file parsed as TOML at each step with the
  arrays as Grok reads them, and came back byte for byte. A config with a
  plain [hooks] table (Stop = [...]) is refused as a problem ("key value
  already exists as a Stop, but should be an array table"), file unchanged.
- Drop broken by hand (never drops a block): TestHooksGrokConfigTables and
  TestHooksGrokOwnEventBoth both FAIL with the blocks left; restored, pass.
- Not tried: the Grok App window, and a running grok reading the result.
  Grok App in shared mode reads ~/.grok, not agent-home, as its MCP row
  already does.
2026-10-14 05:43:48 +08:00
ggbdpqandfactory-droid[bot] 1a7aa76b4b mcpauth: an MCP sign-in canceled while its token is being fetched no longer saves the late token or replaces the server's sign-in (#1750, ggbdpq)
Cancel set the flow canceled, but a callback already trading its code
went on to write mcp-signins.json and call Changed when the token came
back, so a sign-in the user had ended was saved, and an existing
sign-in to that server was replaced. The callback's write now happens
under the flow's lock only while the flow is live (flow.keep), so
Cancel or the timeout and the commit can't both win; a commit that wins
still tells the agents before the flow says done.

ggbdpq's patch (46440adc), cherry-picked unchanged.

Run (reviewer): TestCanceledMCPCallbackDoesNotSave (real discovery,
registration, PKCE and loopback callback against mcpauthtest, the token
reply held until Cancel) fails on the old mcpauth.go in both cases
("saved credentials", "redistributed credentials 1 times") and passes
with it, -race -count=5; go test -race ./internal/mcpauth/... ok.
Not tried with a real MCP server's OAuth.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-10-14 04:59:08 +08:00
yetone 17d4283a5a library, gui: a hook has a description in any language, shown under its name (#2011, emo172)
A hook's name is letters, digits, - and _ (checkName), so a Chinese user
had to translate "auto-format-queue" back in their head; 编辑后格式化 was
refused. Hook now has an optional Description: one line (whitespace and
line breaks folded into single spaces) of at most 200 characters, kept
in library.json only and never written into an agent's hooks file. The
Hooks tab shows it under the name; the editor has a Description field
(maxlength 200) under Name. The library's text fields no longer save or
close on an Enter or Escape that only ends an input method's composition
(isComposing / keyCode 229), which a Chinese description would hit.
Strings in zh, zh-TW, ja and de; docs/subsystems/library.md says it.

The reporter's other option, non-ASCII names, wasn't taken: the
description says more than a name can, and names stay one rule across
servers, skills and hooks.

Run: TestHookDescription (kept through a save, an agents change and a
rename, read by the page, no agent file has it, 201 characters refused,
200 kept) fails with the folding and the length check removed.
library-hooks.test.cjs (a description under the name, none for a hook
without, the field's placeholder and hint, an IME Enter posts nothing,
Save posts the description) fails on the old library.js and with the IME
guard removed. library-*, gui-de, gui-ja, gui-zh-tw, i18n-keys and
click-scroll pass in Chromium and WebKit (263/263 each). go test -tags
nogui ./internal/library ./internal/gui under a temp HOME, gofmt -l,
GOOS=linux and GOOS=windows go vet -tags nogui ./internal/library pass.
2026-10-14 04:18:36 +08:00
yetone 692a779d3d library: an instruction set can be kept in a file of your own, such as ~/.agents/AGENTS.md (新v学员 on Discord)
新v学员 keeps one user-level ~/.agents/AGENTS.md by hand and wants every
agent to follow it. Only Factory Droid, omp and Cline CLI read that file
natively; Codex, Claude Code, Gemini, OpenCode, Pi, Amp and the rest
don't. Rather than teach magpie a new agent target, a set of shared
instructions can now be kept in that file instead of a copy in the
library, and the library writes it into every agent that is on, as it
does any set.

What changed:
- InstrSet.File: a set kept in a file of the user's own. Its text is
  read from that file, Save writes to it (kept aside in the backups
  first, written atomically, never removed: emptied, it stays empty),
  and Remove lets go of the set without touching the file.
- The file is refused when it is relative, a folder, an agent's own
  instructions or override file (magpie writes into those), a file
  holding magpie's marked block, inside the library, or another set's.
  A file not there yet is made on the first save.
- The GUI checks the active linked file every 30s (KeepLinked) and
  writes a change made in an editor into the agents.
- Carried by davsync or a backup, a linked set goes as its text; where
  the file is stays this computer's. Put back, the set keeps its file
  and the file gets the carried text, never emptied for a text not
  carried. A profile restored with no text doesn't empty it either.
- GUI: New set has "Keep in a file…" (filled with ~/.agents/AGENTS.md);
  a linked set is tagged "Your file", says where it is kept, and warns
  when Droid or omp is on, as they read ~/.agents/AGENTS.md themselves
  and would get it twice. Strings in zh, zh-TW, ja and de.

Run:
- gofmt -l; go vet for darwin, linux/amd64 -tags nogui and
  windows/amd64 on ./internal/library ./internal/gui.
- go test ./internal/library ./internal/gui -count=1: ok.
- New TestLinkedSet, TestLinkRefused, TestLinkedSetCarried. Each was
  broken by hand and went red: putText writing a linked file like a
  library one, Collect not stripping File, Put not restoring it,
  SyncLinked not syncing, linkable not checking agents' own files.
- library-linked-set.test.cjs in chromium and webkit, at 1100 and 420,
  in en, zh, zh-TW, ja, de: 22 pass; red with the file left out of
  create. library-instr-sets and i18n-keys still pass.

Not done or tried:
- No CLI to link a set (`magpie library instructions set <file>` still
  copies once), and the headless `magpie serve` doesn't watch the file:
  after an edit there, `magpie library sync` writes it out.
- Not tried with real Droid or omp reading the same file.
2026-10-13 17:28:26 +08:00
yetone a894559e23 library: a project's skills and MCP servers reach Qoder, CodeBuddy, Droid, Cline and Command Code (eirc on Discord)
eirc could give Qoder and other agents skills and MCP servers only
user-wide; Library's project page didn't offer them. Each agent now gets
the project folder or file its own source or docs say it reads:

- Qoder, Qoder CN: skills in .qoder/skills, servers in
  .qoder/settings.json's mcpServers (@qoder-ai/qodercli and
  @qodercn-ai/qoderclicn 1.1.69: projectConfigDirName ".qoder",
  getProjectSkillsDir = <config>/skills; docs.qoder.com/cli/mcp-reference).
- CodeBuddy Code: skills in .codebuddy/skills, servers in .mcp.json, or
  mcp.json when the project has only that (2.164.0 reads the first of
  [.mcp.json, mcp.json]).
- Droid: servers in .factory/mcp.json, skills in .agents/skills
  (docs.factory.com).
- Cline: skills in .agents/skills (CLI 3.0.70 reads .clinerules, .cline
  and .agents /skills).
- Command Code: skills in .commandcode/skills (commandcode.ai/docs/skills).

Left out, unconfirmed: Command Code's project MCP (.mcp.json in its own
transport shape, which would clash with Claude's), Copilot CLI's project
MCP, Zed's .zed/settings.json, WorkBuddy. docs/subsystems/library.md gets
a Projects row.

Run: go test -tags nogui ./internal/library (temp HOME, pinned module
cache); the three new tests in project_targets_test.go fail with the map
entries reverted ("magpie knows of no folder qoder reads a project's
skills from"), and the CodeBuddy mcp.json test fails with that fallback
turned off. gofmt -l clean; go vet -tags nogui on darwin, linux and
windows. No GUI asset changed (the page takes both from sync.go). Not
tried with the real Qoder, CodeBuddy or Droid CLIs.
2026-10-13 16:16:24 +08:00
Zhizhen He 97751188ea library: an unreadable skill copy stays in place during sync (#1102)
An unreadable subfolder in an agent's copy of a skill hid edits from the
timestamp scan, which ignored read and stat errors. So switching copy/link
mode, refreshing the skill, or removing a duplicate copy could replace the
copy and lose those edits. Shared-folder deduplication could remove
SKILL.md before failing on the unreadable subtree. changedAt and
copyIsFresh now return the scan error. The copy is kept in place for that
sync (Library.blockedSkills) and reported as a Problem naming the path.
This covers agent copies, shared-folder deduplication, project copies and
Claude Desktop copies. Other agents still sync, and a later sync tries
again once the copy can be read.

Merged onto main. #1449 added two callers of changedAt in
skill_changed.go:
- libraryHash doesn't remember a hash for a folder it couldn't wholly read.
- editState says unknown for an agent's copy it couldn't wholly read, so
  an update from GitHub keeps the library's version aside.
TestEditStateUnknownForAnUnreadableCopy covers editState.
docs/subsystems/library.md keeps both new rules.

Run:
- go test -tags nogui ./internal/library/ and ./... (see the PR), go vet
  for darwin, linux with nogui, and windows, and gofmt.
- With changedAt ignoring walk errors again, the four ScanError and
  EditState tests go red.
- With editState ignoring the error, the new test goes red
  (edited true, known true).
- Checked with Unix permissions on macOS only, not as root and not on
  Windows.
2026-10-13 15:44:02 +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
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
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 9a34a784dc library: Collapse all / Expand all for the skill groups (#1862)
WardLu (#1862) asked for a way to fold every skill group at once in a
library of many groups. Library > Skills now has a Collapse all / Expand
all button beside the sort (foldAllButton in library.js):

- without a filter it sets every shown group's kept fold
  (magpie.libSkillFolds), the same as clicking each heading;
- while filtering it folds or opens only the groups the filter shows,
  until the filter changes (unfiltered), and leaves the kept folds alone;
- it says Collapse all while any shown group is open, else Expand all;
- it is hidden with fewer than two groups (A->Z, or a filter only one
  group matches);
- a part inside a group keeps its own fold, and nothing is sent.

skillHits/groupFolded pull out the rules drawSkills already used, so the
button and the headings can't disagree. Strings in en, zh, zh-TW, ja, de.
docs/subsystems/library.md's Skill groups row describes it.

Run:
- new internal/gui/tests/skill-fold-all.test.cjs: chromium and webkit,
  en/zh/zh-TW/ja/de, at 640 and 1180. 22/22 pass, three times. With
  origin/main's assets it fails in every case (no button).
- the skill-*, library-* (skills side), pick/remove/import skill tests
  and i18n-keys, at concurrency 4: everything passes except
  pick-skills.test.cjs in WebKit. That test is red with main's own assets
  too (#1672, being fixed separately).
- screenshots in German at 640 and 1180: the button sits in the heading
  row and wraps with it.

Not run: a real library with many groups in the app window. I didn't
check by hand that the scroll check fails when something scrolls.
2026-10-13 04:32:20 +08:00
yetone 76c6580ea6 gui: a skill group's agent chips count only the skills magpie decides, and a row's chip for one an agent reads from ~/.agents/skills itself is locked (#1862, WardLu)
A skill kept in ~/.agents/skills is had by every agent that reads that
folder itself (SkillView.Always), whatever is ticked. Its row's chip said
so only on a click, greyed like a chip that can't take the skill, while
the group's chip counted s.agents alone. Turning the group off for Codex
then said "off for Codex" and left the row lit.

What changed:
- groupChips (group headings, parts and the Select bar) counts, gives and
  takes only the skills magpie decides for each agent. agents-some is
  sent, per agent, the names it doesn't read itself, so a skill Codex
  reads from the shared folder is never sent for Codex.
- A chip whose agent reads only some of them itself says how many, in its
  tooltip. After a click, the status says "Codex still reads 1 of them
  from ~/.agents/skills itself".
- An agent that reads every one of them itself has a lit, locked chip, as
  the row's is. It sends nothing, and a click says why.
- The group's heading says "N in ~/.agents/skills", with a tooltip naming
  the agents that read it, before any click.
- A row's locked chip is lit, with a small lock on its corner, rather
  than greyed out at .35.
- Nothing deletes from the shared folder or touches another agent's
  config. Servers and hooks keep their own reach rules unchanged.
- Strings in zh, zh-TW, ja and de. docs/subsystems/library.md (Skill
  groups) says it.

What was run:
- New skill-group-shared.test.cjs, in Chromium and WebKit; en, zh, zh-TW,
  ja and de; 640px and 1180px:
  - heading note;
  - partial chip tooltip;
  - the locked row chip's opacity and its lock;
  - the post sent, the status, and parents and rows agreeing after a
    click;
  - All;
  - a fully locked group chip sends nothing;
  - no sideways scroll.
  22/22 pass, twice. It fails on the old code (no heading note; Codex is
  sent mango too).
- group-skill-chips, skill-parts, skill-groups, shared-skills,
  every-skill, library-all, i18n-keys, library-own-folder,
  skill-repo-groups, library-pick-remove and library-null-agents pass in
  both engines.
- pick-skills is red in WebKit on origin/main's own assets too, the same
  as here. It is out of date since 18e82adc6, and the GUI-triage session
  is fixing it (#1672).
- Looked at in WebKit screenshots, light.

What wasn't run:
- Not tried with a real Codex reading a real ~/.agents/skills. The
  backend (SkillView.Always, agents-some) is unchanged.
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 55e81bce40 gui: Cancel in an MCP server's editor leaves the server as saved, after a Sign in too (新v学员 on Discord)
GitHub's remote MCP server, brought in from CC Switch with its token as an
Authorization header: removing the header, picking Sign in, then Cancel
(even with Discard asked and picked) left the header removed in
library.json and every agent's file.

Cause: Sign in calls ready(), which saved the whole form whenever its name,
transport, URL or headers differed from the saved server. The sign-in
(mcpauth.Start) uses only the name and URL, so the headers never needed
saving for it. Now ready saves only when the sign-in is to another server
than the saved one (new, name, transport or URL changed); the button then
reads "Save and sign in" (zh, zh-TW, ja, de), and what it saved becomes
the form's saved state, so Cancel doesn't offer to discard what is already
written.

Audited the page's other sheets for the same thing: the hook editor,
paste-many, the server sheet, the skill how-to, By agent (Done only) and
the confirm dialogs save nothing before their own Save. Env and command
arguments in this editor only ever saved through Save; the new test
covers them too.

Run:
- New mcp-editor-cancel.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de,
  1100 and 390 wide, 22/22 twice. Broken by hand each: the old
  headers-count rule, the saved state not updated after the save, and
  the button not saying it saves; each 0/11 in Chromium.
- mcp-signin (updated for the new label), mcp-signin-health,
  library-mcp-health, library-mcp-copy-config, library-servers-bulk,
  library-env-refs, i18n-keys, ux-safety: pass.
- library-mcp-tools and library-mcp-tool-switch have WebKit reds (the
  footer over the clicked switch) that come and go, 1 to 7 per run, the
  same with this commit's parent's assets.
- Sandbox HOME, rebuilt magpie web: header removed, Sign in (GitHub
  answered with its no-registration refusal), Cancel, Discard: the
  header is still in library.json and ~/.claude.json, and no save
  request was sent.
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 a4385e0999 gui: the Library's Select bar removes the skills, servers or hooks picked, a whole group at once with its header's box (#1852)
What: Select's bar on the skills, servers and hooks pages gets Remove…
(red, beside Clear). It asks first, as Remove all does, naming the count
("Remove 3 skills?", or "Remove pack-a?" for one), and posts only the
picked names to the existing remove-all endpoints (RemoveSkills /
RemoveServers / RemoveHooks), so each goes exactly as its row's Remove
would: same backups, only magpie's own copies. A group's or part's header
box (already there in Select) picks the whole group, so an outdated group
goes in one step. Groups have no menu, so no "Delete group…" item was
added.

A name that wasn't removed stays picked, its row's second line shows
"Not removed: <error>" in red, the status names it ("notes removed ·
stuck wasn't removed: …"), and nothing reports success for it. When every
name fails the endpoint answers 400: the sheet stays open with its button
enabled again. The label stays "Remove…" whatever the count (the count is
beside it and in the sheet): "Remove 3…" rewrapped the bar at 440px in
ja and moved the box under the pointer (library-servers-bulk caught it).
No Go change: the batch removals already reported Unremoved per name.

Strings in zh, zh-TW, ja, de. docs/subsystems/library.md says it.

Run: new internal/gui/tests/library-pick-remove.test.cjs (Playwright
1.62.0, chromium and webkit, en/zh/zh-TW/ja/de, 1100 and 390 px): group
box picks 3, Cancel posts nothing, Remove takes 3 and leaves the rest, a
partial failure keeps the failed one picked with its error, a total
failure keeps the sheet; every click checked for no scroll and nothing
moving. Red by hand: dropping every name from picked after a partial
failure, and dropping the partial-failure status. With it, both engines:
library-servers-bulk, library-hooks, i18n-keys, gui-de, gui-ja,
gui-zh-tw, click-scroll, group-pick-filter, remove-found-skill,
library-items, remove-all-skills: 60/60 pass. library-servers-bulk
chromium failed once in a parallel run, then passed 3/3 alone and 2/2 in
the same parallel run on this tree and on origin/main.

Not run: pick-skills.test.cjs is red in webkit (en, zh: the click on the
"pdf" row times out) on origin/main 6669d497d without this change too,
the same as before; chromium passes. Not tried in the real app.
2026-10-13 02:48:46 +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 6ccf23efa6 gui: the Library's Backups button is at the top of every tab, after Library folder (Dade on Discord)
Dade: each Library tab's 备份 (Backups) sat at the very foot of the page,
under the whole list, and was hard to find. It is now a button in the
Library's head strip, on every tab (Instructions, MCP servers, Skills,
RTK). That strip stays at the top as the page scrolls. The button sits
right after 资源库文件夹 (Library folder) and looks the same: a small
glyph (a clock with a turning arrow, as macOS draws backups) and a label.
- It opens magpie's backups folder.
- Its tooltip keeps the sentence the foot had ("magpie keeps a copy of
  every file before it writes it.") with the folder's path.
- It is disabled until the library has loaded, as Library folder is.
The foot line and its .lib-foot/.lib-link styles are removed. Two
messages that pointed to "Backups, at the foot of the Library" now say
"at the top", in all five languages. The page with no agents, which had
no foot, now has Backups too.

Run:
- library-backups-top.test.cjs covers chromium and webkit,
  en/zh/zh-TW/ja/de, each of the four tabs, and browser 1000/420px plus
  window 1000/800/560px. It checks the button comes right after Library
  folder on the same line and looks the same, waits for the library, has
  a label that doesn't wrap, has no left border, causes no sideways
  scroll and nothing at the foot, opens the backups folder, and doesn't
  move the page on click. 10/10 pass. Without the button appended, red.
- library-loading, library-discover-jump, library-all, library-items,
  library-rtk-gain and library-own-folder pass (138).
- go test ./internal/gui -count=1 under a sandbox HOME: ok.
- mobile-web.test.cjs: the phone widths pass. Its desktop 900/1280
  comparison with origin/main fails only on the library page (about 650
  pixels: the new button in the strip). Its before/after screenshots show
  nothing else changed, and it matches again once this is on main.
2026-10-12 23:30:08 +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 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 16b5c8700f gui: a library MCP server no agent or project has isn't checked on its own; its status says "not checked" and a click checks it (#1597, xiaozhu1337)
Opening the Library's MCP tab started (or reached) every server in the
library once a session to list its tools, the ones switched off for
every agent too. Some users keep many servers in the library and turn on
a few, and each unused one was still started.

A server that no agent has, here or in a project magpie keeps (inUse),
is now left out of that check. Its status reads "not checked", with the
reason in its tooltip, and a click checks it, as a click already checks
any other server again. Once an agent is given it, the page renders again
and the server is checked as before. New strings in zh, zh-TW, ja and de.

Verified:
- library-mcp-health.test.cjs: a server on for no agent shows "not
  checked" and is not in the first check; one on only in a project still
  is; a click on it checks it alone (fresh) and opens no editor. Chromium
  and WebKit, en and zh. Without the library.js change it fails: the
  first check asks for "idle" too.
- library-mcp-tools and library-mcp-tool-switch: their padding servers
  were on for no agent and relied on the old check, so they are on for
  Claude Code now; the tests are otherwise unchanged.
- library-servers-bulk, mcp-signin, library-mcp-copy-config,
  project-servers, library-zed-mcp, search-mcp, gui-ja, gui-de pass in
  both engines. library-mcp-tool-switch times out in WebKit at load ~180
  on some languages with and without this change (#1609, filed earlier).
2026-10-11 21:00:29 +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 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 177fbdfe28 library, gui: the agents a skill is installed for have an All chip, one click takes them all off (#1531, liuweifeng)
Installing a skill from a repository starts with every agent lit, so
installing it for one agent alone meant unticking each of the others.
The picker now has the All chip the library's skill and server rows
already have (allChip): lit while every agent that can take it is lit,
a click takes them all off, another puts them all back. Only this one
is then All + that agent's chip, two clicks, with the same control as
the rows rather than a new idiom.

The same fix reaches every sibling picker that chooses agents before an
item is added: the market's skill install, the MCP server editor (add
and edit), pasting several servers, and the market's server install.
No new strings: All and its tooltips are already in every language.
The CSS sets All a little apart from the icons outside a row.
docs/subsystems/library.md says so.

Run:
- new internal/gui/tests/skill-install-agents-all.test.cjs: Chromium and
  WebKit, en/zh/zh-TW/ja/de at 1100px and 420px, with the reporter's
  repository: All lit at first, All -> none, Codex -> install posts
  agents ["codex"]; All puts every agent back; the server editor's All
  too. 28/28 pass; on the old library.js/css 0/28.
- the library's sibling GUI tests (by-agent, every-skill,
  group-skill-chips, library-*, market-have, market-featured-skill,
  pick-skills, project-servers, skill-install-skip,
  skill-name-many-agents, mcp-signin, import-all-skills) in both
  engines: all pass, except library-servers-bulk's known 2px flake
  (#1322), which fails the same way with this change reverted.
- screenshots of the picker in zh at 1100px and de at 420px.
No Go changed.
2026-10-11 01:45:47 +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 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 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 d9caa3dd13 library: Hermes Agent in a WSL distro takes skills and MCP servers there, and so does every other WSL agent that keeps them in its own folder (omp, OpenCode, MiMo Code, Droid, Grok Build, Command Code, AtomCode, Qoder, MiniMax Code, fx, dsh) (#1323, Kevinzz224)
wslTargetOf knew only Claude Code, Codex, Pi and OmO, so hermes@wsl:Ubuntu
was never a Library target and a skill meant for it could only go to
Windows' ~/.hermes. An agent whose places are all its own folder (a.Dir,
or beside a.Path) now gets the target targetOf makes on this machine, at
the distro's home the agent was found with: copies for skills, its MCP
file marked as WSL's (a Windows program is refused, magpie's own image
server goes by its WSL path), and the skills it reads besides its own are
the same distro's agents'. Agents whose places depend on this machine's
variables or home (Kimi Code, Crush, Cline, CodeBuddy, Goose) stay out.

Run: TestWSLOwnFolderTargets fails without the change (hermes@wsl,
omp@wsl, droid@wsl, opencode@wsl aren't targets; no copy of the skill),
passes with it. go test -tags nogui ./internal/library ./internal/agent
under a temp HOME on macOS (library ok; agent's TestFolderVarsAreListed is
red on main since 10578ce6, fixed in its own commit next), and
./internal/library in golang:1.26.8 Docker (Linux) ok; go vet -tags nogui
for darwin, linux and windows. Not run: a real Windows box with Hermes in
WSL.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-08 23:03:19 +08:00
yetone 56d1665251 library: a skill an agent has of its own is removed from every agent that has it, from its row under "In your agents" (trash) or with d twice in the TUI, without bringing it into the library first (#1303, sxwedo)
Until now the only action on such a row was Bring in: removing it meant
bringing it in and then removing it from the library. RemoveFoundSkill
(skills/remove-found) takes out of each agent that has it its folder, or
its copy of the very same files, and its links; its entry in the shared
~/.agents/skills, which agents read too, and a folder of it in the
library's own folder go as well. Nothing is deleted: folders go to the
backups (setAside), links are taken away, and a folder elsewhere that the
agents only linked to stays where it is. Another skill by that name
(Others) is a different skill and stays. The page asks first and says
which agents it leaves and what stays.

TestRemoveFoundSkill (library), TestLibraryPage's new part (TUI) and
remove-found-skill.test.cjs (GUI) fail without the change. The GUI test
fails 4 of 4 with library.js from before it, and passes in Chromium and
WebKit, in en, zh, ja and de, and at 440px wide.

Run: go test -tags nogui ./internal/library ./internal/tui ./internal/gui,
and go vet for linux, windows and darwin with -tags nogui, in Docker
(golang:1.26.8, a temporary HOME). The Mac's syspolicyd held test binaries
at launch. On the Mac, in Chromium and WebKit: remove-found-skill, gui-ja,
gui-de, i18n-keys, import-all-skills, own-skill, shared-skills,
library-own-folder, library-items, remove-all-skills,
library-desktop-skills, skill-name-many-agents and mobile-web, 133 of 133.
In one earlier run of that set at load ~40, mobile-web's WebKit "idle
scripts cannot scroll" failed once. It passed 3 of 3 alone with this
change, and passed in the full rerun. Not tried: the reporter's own agents,
and a WSL agent's folder.
2026-10-08 20:00:49 +08:00
yetone e387c5a2ed library: Alma takes the Library's MCP servers, in ~/.config/alma/mcp.json as its own MCP settings write them (#1292)
Alma 0.4.164 (read from a copy of its app.asar, out/main/index.js) reads
its servers from <home>/.config/alma/mcp.json on every system, as
{mcpServers:{name:{command,args,env} | {url,headers,transport?}}}: a
server with a url is streamable HTTP falling back to SSE, and SSE only
when transport is "sse". It has no ${VAR} expansion, so a server naming
a variable is refused for Alma as for Kimi or Devin. Alma reads the file
as it starts and when its MCP settings refresh; there is no watcher.

The user's own servers (the real file's computer-use entry with
ELECTRON_RUN_AS_NODE) are kept: TestAgentMCP's alma case writes one
first. Without the change TestAgentMCP/alma fails ("alma has no MCP
target") and TestTakesRefusesAlma refuses mcp.

Run: HOME=<temp> go test -tags nogui ./internal/library ./internal/agent;
go vet for darwin, linux and windows. Not tried with a running Alma.
2026-10-08 18:45:45 +08:00
yetone c28a819a8e library: an agent that can't be given instructions, skills or MCP servers says where they go instead and lists the agents here that take them: OpenChamber has OpenCode's (give them to opencode), Claude Desktop keeps its instructions in its own settings and its Code tab reads Claude Code's (MOMO on Discord)
OpenChamber's server reads the global AGENTS.md, skills folder and
opencode.json from OpenCode's config folder (openchamber/openchamber
packages/web/server/lib/opencode/shared.js at 866dffd), so no path of its
own is added; a second target on the same files would write them twice.

Verified: TestTakesSaysWhereInstead fails on the old Takes with "Claude
Desktop has no user-wide place for instructions that magpie knows of";
internal/library passes in a sandbox HOME.
2026-10-08 18:13:11 +08:00
yetone d1fca72f69 library: the Library's MCP servers go to WorkBuddy and CodeBuddy Code (#1266)
WorkBuddy had skills only, and CodeBuddy Code had no library target at all,
so their MCP chips could not be switched on.

WorkBuddy 5.5.6 (app.asar) reads ConnectorService.customMcpConfigPath:
$WORKBUDDY_CONFIG_DIR, then $CODEBUDDY_CONFIG_DIR, then ~/.workbuddy, plus
mcp.json, as {"mcpServers": {...}} in Claude's shape. It connects a server
only once the user has switched it on in its MCP settings
(mcp-approvals.json, module.app-server.js). magpie doesn't write that
approval. Instead, the servers page tells the user to switch it on once,
in en/zh/zh-TW/ja/de.

CodeBuddy Code 2.162.0 (PathUtils.resolveMcpFilePath) reads the first of
<dir>/.mcp.json, <dir>/mcp.json and <base>/.codebuddy.json that exists.
<dir> is $CODEBUDDY_CONFIG_DIR or ~/.codebuddy. The file holds mcpServers
in Claude's shape, and ${NAME} is expanded (McpConfigEnvExpandService).
User scope needs no approval. Skills go in <dir>/skills.

Verified: the real CodeBuddy Code 2.162.0 CLI, in a sandbox HOME, read
SaveServer's file back with `mcp get` and `mcp list`. That covered stdio
with ${MY_TOKEN} expanded, http and sse, and the user's own entry and
disabledMcpServers were kept. WorkBuddy.app was not run; its side is
from its code.

Tests: TestAgentMCPFiles (4 new cases) and TestCodeBuddyMCPFile fail
without targets.go. library-workbuddy-trust fails without library.js.
Run: go test ./internal/library ./internal/gui; go vet for darwin, linux
and windows; in Chromium and WebKit: gui-ja, gui-de, gui-zh-tw, i18n-keys,
click-scroll and all library-* GUI tests.
2026-10-08 17:12:07 +08:00
yetone db0feb3615 library, gui: a remote MCP server's headers and a command's env can name ${NAME}: the library keeps the placeholder and each agent gets its own syntax, so the token is never written into an agent's settings (#1250)
The library keeps `${NAME}` as typed. refsOf (internal/library/envref.go)
gives each MCP format the agent's own syntax, with the source beside each:
${NAME} for Claude Code, Droid, Grok, Gemini, Crush, Copilot, Pi, OmO, omp,
Qoder, AtomCode, Hermes and Command Code; {env:NAME} for OpenCode and MiMo;
${env:NAME} for Cursor; Codex's bearer_token_env_var, env_http_headers and
env_vars; Goose's ${NAME} plus env_keys. An agent with no syntax (Claude
Desktop, Antigravity, Kimi, Cline, ZCode, dsh, Devin, Pi with
pi-mcp-extension) is never given such a server: supports() refuses it with
the reason, an entry magpie wrote before is taken out, and its chip is
greyed with the reason on the row and in the editor. Codex's and Goose's
extra keys are magpie's only while the server names a variable, so the
user's own env_vars / env_keys stay. The editor says how to write one under
Headers and Environment; a check whose variable isn't set where magpie runs
says which one ("GH_TOKEN not set").

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

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

Verified (temp HOME, pinned caches):
- go vet -tags nogui ./internal/library ./internal/tui ./internal/gui .;
  GOOS=windows go build and GOOS=linux go build -tags nogui of
  internal/library and internal/tui: clean
- go test -tags nogui ./internal/library ./internal/tui ./internal/gui: ok
- with the old skills.go, market.go and skillnew.go, TestInstallSetSkipsOneInTheWay,
  TestInstallListsItsOwnLeftoverFolder (fails with lc's exact "the library's
  folder already has a caveman-commit in it") and
  TestInstallSetSkipsAnotherByTheSameName FAIL; TestSkillsFromGitHub's
  reinstall now asserts Had
- skill-install-skip.test.cjs (Chromium + WebKit, en and zh at 440px) fails
  on the old library.js ("status ok", no names) and passes now; with
  gui-ja, gui-de and 11 library GUI files, 99/100 passed, and the one that
  failed (by-agent, Chromium, at load average ~150) passes 3 times in a row
  in both engines when run alone
- not tried in the real app, or with lc's library
2026-10-08 04:57:40 +08:00