Files
magpie/internal/library/testdata
yetone ec1a1a7a55 library: import the slash commands the agents already have
miantiao_me on X (after v0.1.4189): 「之前在 Pi 定义的可以导入吗?」. Library ›
Slash commands now has a "Find in agents" card at the top. It reads the
command files each agent already has, from the same places magpie writes
them (Pi prompts/*.md, Claude commands/*.md, OpenCode command/ and
commands/, Gemini and Qwen .toml, Qwen .md, Droid), and lists them to
import, the way Subagents' import does.

- Parsing: frontmatter description plus body; for TOML, description and
  prompt. Arguments go back to magpie's form: Claude's $ARGUMENTS[n] and
  $n (0-based) become $n+1, Gemini/Qwen {{args}} becomes $ARGUMENTS,
  Pi's $@ becomes $ARGUMENTS (${@:N} is left as written).
- Files magpie wrote itself are skipped. The same content in several
  agents is one command; a name with different bodies per agent shows
  "Differs by agent" and one of them is picked; a name the library has
  with other content is "Name taken" and can't be picked.
- An imported command keeps its source agents ticked, and magpie adopts
  each original file byte for byte (Command.Taken): sync writes the same
  bytes at the same path, so the file is never doubled or rewritten.
  After an edit the agent gets magpie's render at that path; a rename
  drops Taken. Taken never leaves the machine (Collect strips it, Put
  keeps the local one).
- API: POST /api/library/commands/probe, and commands/import through
  the library change route. internal/cli's parity test names the probe
  as stage 3, like subagents/probe.
- Docs: docs/subsystems/library.md has the new row.

Run at 039e25752 (on origin/main dd89f1255), on mote:
- go test ./internal/library/ ./internal/cli/: ok. ./internal/gui/: only
  TestCoreScriptBudget red (app.js 10 bytes over), red on main, #6733;
  this commit doesn't touch app.js.
- gofmt clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...: ok
  (at fb01ae2bb, base 028b07b4b; the two later main commits are Windows
  hook code in internal/gui).
- GUI: library-commands-import (new: chromium + webkit, en/zh/zh-TW/ja/de,
  420 and 1100 wide, no sideways scroll, press stays in place),
  library-commands, library-subagents-import, i18n-keys, i18n-en-no-cjk:
  64 of 64.
Earlier, at 1a70f31b6 (base 6af327e2b):
- go test -timeout 45m ./...: every package ok except internal/cli's
  TestEveryRouteHasACommandOrIsNamed, which named the missing probe route;
  fixed here and green since.
- Whole GUI suite (--test-concurrency=8, mote at load 17 to 44 with
  another session's go suite and GUI runs): 26887 pass, 1005 fail in 109
  files, none of them library-commands. The 109 files run alone at
  99719df19 and at origin/main 5bd41301b: 1145/996 vs 1144/997, the
  same tests red apart from language/width variants that flip between
  runs. Recorded on #6709.
Tests use a sandbox HOME with real Pi prompt files from Pi's repo
(internal/library/testdata/pi-prompts). Broken by hand: with syncCommands'
Taken branch off, all four import tests go red ("has a slash command of
its own"); with Put's Taken keep off, TestCommandImportNotCarried goes red.
Not tried: a real Pi install on a live HOME (by rule), or Windows/Linux
runs of the Go tests.
2026-11-15 12:59:12 +08:00
..