kensenzhao asked for magpie's routing and quota in Claude Code's status
line. Claude Code runs the statusLine command on every update and cancels
the run that is still going, so the command must answer fast. It must never
make a vendor read.
- `magpie statusline [<provider|account>]` reads Claude Code's statusLine
JSON from stdin. It prints "→ <served model>" from
/v1/magpie/route?session=<session_id>, then each subscription account's
windows ("claude a@x* 5h 62% 7d 41%"). `*` marks the account that served
last. A window whose reset has passed shows 0%. With the gateway off it
prints an empty line. Each request times out after 1s.
- /v1/magpie/quotas?kept=1 (provider.KeptQuotaReport) builds the same
report from the kept cards (CachedCards) and never starts a vendor read.
The plain endpoint can take up to 12s.
- magpie never writes statusLine into Claude Code's settings. The user
adds `"statusLine": {"type": "command", "command": "magpie statusline"}`
themselves (magpie statusline's help, docs/reference.md).
Run: go test -tags nogui ./internal/cli ./internal/provider
./internal/gateway in a sandbox HOME; gofmt -l; go vet natively and with
GOOS=linux and GOOS=windows.
Broken by hand, each went red:
- the CLI asking without kept=1 (TestStatuslineTellsRouteAndEveryAccount);
- dropping the route line (same test);
- KeptQuotaReport calling QuotaReport (TestKeptQuotaReportAsksNobody).
Real use: a built binary against a sandbox gateway on 127.0.0.1:3517.
- kept=1 answered in 0.07s and route in under 1ms.
- `magpie statusline` with Claude-style stdin printed an empty line, since
the sandbox has no accounts.
- Its ~1.1s wall time matches `magpie version`, so that is process start.
Not tried: real accounts, or the line inside a real Claude Code statusLine.