Pi set up by hand on a provider of its own named magpie (magpie/<model>
at the gateway) read as connected in magpie: every catalog change wrote
magpie's list over that provider, RenameProvider rewrote its refs, Drift
offered Reconnect, and Disconnect took the provider out.
0911a65e7 (yyddbds, MiMo) already holds a ListOnly agent's sync until
it is Wired; that still let a hand-written config that names a magpie
model (JFunfunfun's Pi) read as Wired. Both gates now apply.
Its test's last case said a magpie model picked by hand on MiMo's own
magpie provider connects it; that is JFunfunfun's case, so it now
stays the user's until connected in magpie (listonly_test.go, and the
doc's ListOnly line says so).
An agent whose magpie is a provider of its own config (Spelled, not
Native) is now connected only when magpie set it up (setUp): a field in
applied.json, the new applied.Kept that Keep leaves instead of deleting
the record, or the <id>.connect.was stash Connect has written since
10-03. Otherwise (handWired) it isn't Wired, has no Drift, and
SyncCatalog, RenameProvider and renameRefs skip it; Disconnect is a
no-op as it is for any unwired agent. Connecting it in magpie takes it
on as before; Disconnect after that skips putting back "was" values
that were themselves magpie's (dsh errored on them). RenameLegacy
records the dial/ -> magpie/ values it writes, and moveEfforts (the
Cursor/Antigravity effort ids, at start-up) leaves a hand-written
magpie/<ref> alone. Aside keeps its own
key-based ownership. OpenCode's own-gateway-provider test now connects
through Apply as `magpie opencode` does.
Run (on mote, at this head, rebased on f2c6831a3): go test -tags nogui
-count=1 ./internal/agent ./internal/cli ./internal/library
./internal/gui; go vet darwin/linux/windows of internal/agent and
internal/cli; gofmt -l. internal/agent again after the ListOnly test
change: ok. Pushed on ceef9e943, whose five commits since touch usage,
sessions, library, provider movers and gui only.
New tests: TestPiHandWiredMagpieProviderIsTheirs (pi's literal
settings.json/models.json in a sandbox HOME, files byte-identical after
SyncCatalog, RenameProvider and Disconnect), TestPiConnectedBefore-
StaysConnected (applied record, gone model, connect.was, applied then
Keep), TestHandWiredMagpieProviderSiblings (29 Spelled agents). All fail
on the old code.
Tests that wrote a connected agent's files by hand (Pi, OpenCode,
Hermes, omp, dsh, the Kilo plugin, Cursor efforts, and the cli's
save-then-sync test) now also mark it as Connect leaves it
(setUpInMagpie, the connect.was stash); without it they read as
hand-written, which is what this change is about.
Broken by hand, each red: the Sync gate, the rename gates, the Drift
gate, Keep deleting the record, the was-skip in Disconnect, the
moveEfforts gate (TestMoveCursorEfforts' hand-wired case).
Not tried: a real pi binary against the gateway. Users connected
between 09-23 and 10-03 who pressed Keep (record deleted before this)
read as not connected; one Connect brings them back and pi keeps
working meanwhile. Agents without Spelled (Claude Code, Codex, Gemini
and others) decide by their own checks and are unchanged.
An agent a plugin adds is known only while the plugin is on. Turning
the plugin off or removing it (CLI `magpie plugin off/rm`, or the
Plugins page) left the agent's config on magpie, and `magpie <agent>
default` then said `unknown agent`, with nothing to put it back.
- provider.SetPluginOff (off) and provider.RemovePlugin first call
provider.PluginAgentGoing, set by internal/agent to UnwirePlugin: the
agent is disconnected as `magpie <agent> default` does (Disconnect),
while the plugin still loads. A plugin off already is read from its
module as it is; one whose module is gone puts back each file whose
stash names its spec. If that fails, the plugin is left as it was
and the error says why.
- The stash now records the plugin's spec and the file's format, so
`magpie <id> default` for the agent of a plugin deleted on disk puts
the file back from the stash alone (agent.RestoreGone; an older
stash's format comes from its file's name, agentplug.FormatOf). A
file that no longer holds magpie's gateway key is the user's and is
left alone; one that can't be read is unknown: nothing is written,
the stash is kept. With the plugin only switched off, `default` says
the agent is off magpie already instead of "unknown agent".
- Turning the plugin back on (or installing it again) does not rewire
the agent by itself: its config stays as the user had it. Connecting
it (its switch on the Agents page) puts back the model it was on,
through Disconnect's `.reconnect`. The CLI says so when it turns off
or removes a plugin whose agent was on magpie.
Run (this change on origin/main f3c4d7b7a, then rebased onto
0fb0bfda3, which changes only an internal/gateway test; provider and
cli run again at the pushed head):
- gofmt -l: none; go vet -tags nogui on darwin, linux, windows for
agent, agentplug, cli, provider, gui, plugin: ok.
- go test -tags nogui -timeout 45m -count=1 ./internal/agent
./internal/agentplug ./internal/cli ./internal/provider
./internal/plugin ./internal/gui: agent, agentplug, cli, plugin, gui
ok; provider crashes in TestUnreadLoginsWriteErrorsKeepCredentials
("close of synctest channel from outside bubble", filememo.Forget),
the same on origin/main 0fb0bfda3 run alone: #3632, open, not this
change. At the pushed head: cli ok; provider with -skip
TestUnreadLogins ok.
- Real use, sandbox HOME, magpie built from this tree, gateway on
127.0.0.1:3491, web on 3492: `magpie plugin add agent-kilo`
(@magpie-community/agent-kilo 0.1.0, not on npm, from the plugins
repo's dist branch), a kilo.jsonc with comments and a provider of its
own, `magpie kilo magpie/deepseek/deepseek-chat` (wired, provider
block added). Then, each time from wired: `magpie plugin off` -> cmp
byte-identical; `plugin on` -> still the user's; `plugin rm` ->
byte-identical; POST /api/plugins/off and /api/plugins/remove (the
Plugins page's calls) -> byte-identical; plugin dir deleted and
plugins.json emptied by hand, then `magpie kilo default` -> put back,
byte-identical. `magpie kilo default` with the plugin off says it is
off magpie already.
Broken by hand, each red, then restored:
- PluginAgentGoing left nil: the four off/remove tests fail.
- the SetPluginOff call removed: Off and ModuleGone tests fail; the
RemovePlugin call removed: Remove and RemovedWhileOff fail.
- Spec not stashed: ModuleGone fails. pluggedOff disabled:
RemovedWhileOff fails. FormatOf fallback removed: TestRestoreGoneAgent
fails. The gateway-key check removed: LeavesAFileOffMagpie fails.
- Unwire instead of Disconnect: the Off test fails (How "first", not
"again"). The off-plugin check in RestoreGone skipped: the Off test
fails. RestoreGone not called from the CLI: TestGoneAgentDefault
fails with `unknown agent "kilo"`.
Not tried: the Windows box; a real Kilo CLI reading the restored file;
the GUI suite (no Plugins page code changed: the page's calls reach the
same provider functions, tried above through the web API). Not changed:
an inline JSON object magpie wrote into comes back reformatted (same
values) on any plugin agent's Disconnect, `default` included: #3814.