新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.
On Windows 11 the Library's Instructions tab took 30s+ to show, and each
instruction made, saved or removed took about a minute with nothing on
the page to say so; a second click made a second set or removed twice.
What an instruction change cost:
- SaveInstructions and ImportInstructions went through change(), which
gives every agent its MCP servers and skills again too (takeEdits and
syncSkills look through every skill folder, and the projects), and
the API then answered with a whole library.Read, which reads every
agent's skill folders through again (foundSkills, behind: minutes on
a machine with many skills, #541).
- Every read of the library found the agents (Targets: every agent's
folders, WSL too) three times: ReadInstructions, readView, and
foundServers.
Now:
- library: changeInstructions writes only the instructions into the
agents (with backups as before); readView finds the agents once and
passes them to instructionsView and foundServersOf. ReadInstructions
stays for the TUI.
- gui: an instructions/* action answers {part: "instructions",
instructions, result, problems}; the problems the last change had with
servers and skills stay, those with the instructions are the new
change's.
- library.js change(): one change at a time; while one is out the
page's (and the Library dialog's) buttons are disabled, the page is
aria-busy, the button pressed says "Saving…" and so does the status.
An answer with part "instructions" is merged into the page's library.
Timed on the Windows test box (sandbox profile, 1 agent, 80 skills, copy
mode): an instruction create was ~170ms + a ~460ms Read, now ~80ms + a
~70ms instructions read; Glance 350 -> 200ms, Read 480 -> 320ms. The
30s/1min the reporter sees wasn't reproduced there.
Tests (each fails on the old code):
- TestInstructionChangeWritesOnlyInstructions: a server taken out of
codex's config by hand stays out through instruction create, switch,
save and remove, and comes back with a server change.
- TestInstructionChangeAnswersInstructions: the instructions answer and
the problems kept.
- library-instr-busy.test.cjs: a double click on Add sends one create,
every page button is disabled and the pressed one says Saving… while
the answer is held, the page keeps the rest of the library after an
instructions-only answer; the sure Remove double-clicked sends one.
Chromium and WebKit, en/zh/zh-TW/ja/de.
Also run: go test ./internal/library ./internal/gui ./internal/tui;
gofmt; GOOS=linux and windows go vet; every library*.test.cjs plus the
30 other GUI tests that reach the Library, Chromium and WebKit: all pass
but library-mcp-tool-switch in WebKit, which fails the same alone on
origin/main (#1609), and mobile-web's desktop-vs-main check, which needs
a git checkout the scratch copy it ran in hadn't.