Commit Graph
2 Commits
Author SHA1 Message Date
yetone afabb7f90f library: a skill the router lists stays a /name of Claude Code's
RoyShen on X (yuushabu_buyinn): with the skill router on, / in the agent
no longer picks a skill. A listed skill has no link of its own in the
skills folder, so Claude Code had no /name for it.

For each skill the router lists for Claude Code (any profile; not a
plugin agent or WSL), routerCommands writes <claude dir>/commands/
<name>.md: the skill's description, disable-model-invocation: true, and
a body that has the agent read the skill's SKILL.md at the router's path
and follow it, with $ARGUMENTS. The flag keeps the description out of
the model's prompt, so the router still saves what it saved. The stubs
go in the commands folder, not the skills folder, because Crush, DevEco
Code and Kimi Code read ~/.claude/skills too and ignore the flag.

Applied.RouterCommands records the files with their hash (syncOwnFiles):
one the user changed is theirs. A user's own command file by that name,
or a Library command of that name given to Claude Code, means no stub;
syncCommands takes a stub's file over when such a command is added. The
command import leaves the stubs out. Router off, or the skill kept
direct: the stub goes.

Run:
- mica-run go test -tags nogui ./internal/library -count=1 -timeout 45m: ok
  (277s); GOOS=linux and GOOS=windows go vet ./internal/library: ok;
  gofmt -l clean. Base 18fe1e2dc (fetch failed at commit time).
- Broken by hand: routerCommandsDir returning "" (the old behaviour)
  turns TestSkillRouterKeepsSlashCommands red.
- Real Claude Code 2.1.316 in a sandbox HOME, magpie built from this
  tree placing two skills (okapi, zebu) with the router on, through a
  recording proxy to the gateway (auto/claude-haiku-5-5): the / menu
  lists /okapi and /zebu with their descriptions; "/okapi" answered the
  codeword from okapi's SKILL.md; "Use my zebu skill." went through
  magpie-skills and answered zebu's; every run's first request has each
  description once, in the router's own line, none from a stub. Router
  off: both stubs gone, links back, settings.json's rules gone.

Not tried: Windows and Linux Claude Code (the path is the same
filepath.Join; Windows rules use claudePath already). The Library's
"keep direct" tooltip still says "to type it as /name", which stays
true for the other agents.
2026-11-18 13:43:49 +08:00
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