`magpie snow --help` printed "✓ Snow CLI model --help" and did what
`magpie snow default` does. It deleted profiles/magpie.json, put back the
active profile, and wrote "--help" as advancedModel into the profile it
went back to. There were two causes:
- run's agent forms took any second argument as a model. The `len(args)==2`
branch special-cased only `default`.
- Snow's model Set, on magpie's profile, treated a value no profile of the
user's is on as "leave, and write it into the profile left for".
The arguments were the class, not Snow alone. Under the old code, `magpie
claude --help` and `magpie codex --help` wrote "--help" as Claude Code's
and Codex's model, and `magpie save --help` saved a profile named
"--help" (the new guard test caught each of these).
What changed:
- help_cli.go and run: -h or --help anywhere in the arguments, or help as
the word after the command, prints that command's usage and returns
first, before run reads, moves or starts anything. It prints the
command's own usage where it has one (model, group, group rule, library,
plugin, quota, sessions, search, visible, webdav, s3, claude-code), its
lines of magpie's usage otherwise, and for an agent its forms and
fields. The usage gains a `magpie <command> --help` line.
- `magpie <agent> …` refuses any other argument starting with "-"
(negative numbers aside): "unknown flag X: nothing was changed".
- snow.go: on magpie's profile, a model that is neither through magpie
nor any profile's model is refused, and the files stay as they were.
A `magpie/<x>` that isn't in the catalog is refused on or off magpie's
profile; it used to fall through to the same leave. A model of one of
the user's profiles still switches Snow there, and empty still goes
back to the profile they were on.
- gemini.go, a sibling found by auditing every agent's Set: provider is
Gemini CLI's first field, so `magpie gemini <a model with no option>`
reached it. It unrouted Gemini CLI (stashed key, sign-in and model put
back) and only then said "unknown provider". An auth it doesn't know is
now refused before unroute. The audit found no other Set that leaves
on an unknown value. The other model Sets write an unknown value as the
agent's own model, which is the intended own-model pick. The on/off
provider fields of ante, claudedesktop, copilotjetbrains, cursorlocal,
pencil, t3code, workbuddy and zcode take any non-empty value as "on".
Both are left as they are.
- docs/subsystems/agent-wiring.md says the above.
Tests:
- TestHelpOnEveryCommandDoesNothing reads the commands from run's switch
in main.go's AST, so a new command is covered without a list to keep.
It adds every agent id. For each one it runs --help, -h and help in
several positions under a sandbox home, and checks that nothing is
written, the run returns within 20s and usage is printed.
- TestAgentHelpLeavesSnowWired is the reporter's case: Snow wired, then
`snow --help`, `-h`, `help`, `model --help` and `snow-cli --help`,
unknown flags, and `snow nonsense`. Snow's files must stay the same.
- TestSnowUnknownModelChangesNothing and TestGeminiUnknownAuthChangesNothing
cover the Sets.
What was run:
- Each test was run against the old code. Old main.go: the save, snow,
claude and codex subtests FAIL ("✓ saved profile --help" with
profiles.json written; "✓ Snow CLI model --help"; "✓ Claude Code model
--help"; "✓ Codex model --help"), and so does TestAgentHelpLeavesSnowWired.
- Old snow.go with old main.go: TestAgentHelpLeavesSnowWired FAILs with
Snow's files changed, and TestSnowUnknownModelChangesNothing FAILs with
`"--help" taken`.
- Old gemini.go: TestGeminiUnknownAuthChangesNothing FAILs with
`"nonsense-model" changed Gemini CLI`.
- All pass with the fix.
- In a sandbox HOME with pinned Go caches, at origin/main 4dd2112ef + this
change: `go test -tags nogui -timeout 40m ./...` is green (48 packages ok, no FAIL).
- gofmt -l is clean. go vet, GOOS=linux go vet -tags nogui and
GOOS=windows go vet -tags nogui pass on . and ./internal/agent.
- Not tried: the real Snow CLI on Windows, the reporter's setup. The fix
returns before anything is read, so nothing of Snow is run.
Subsystem design references
These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.
| Subsystem | Reference |
|---|---|
| Built-in subscriptions moving to plugins | Provider and plugin ownership |
| Plugins that run on the gateway's requests and replies | Gateway middleware |
| Claude subscription turns across Claude Code runs | Claude subscription bridge |
| How the gateway picks a provider, key or account, and falls back | Gateway routing and fallback |
| Gateway Session Aggregation | Gateway Session Aggregation |
| Connecting an agent's config to the gateway, drift, disconnect, WSL twins | Agent wiring |
| Providers, keys, subscription accounts, refresh and allowance | Providers and accounts |
| Instructions, MCP servers, skills and RTK written into agents | Library |
Tray, panel, window, magpie web and the page's JSON API |
GUI app shell |
A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.
Maintain a reference
Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.
Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.
For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.
Describe a PR's semantic changes
For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.
For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.
This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.
Review a change
- Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
- Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
- Check that changed contracts appear in the owning reference and that source links still resolve.
- Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.
A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.