Files
magpie/internal/cli
yetone fdc96dfe4d library: a billion-context tab switches its plugin on per agent and restores each file exactly
@Kling__Lab on X asked for billion-context (npm billion-context, CLI bili,
github.com/ranxianglei/billion-context) beside RTK. The Library gets a
billion-context tab after RTK, a card like RTK's:

- No bili: its README's `npm install -g billion-context --prefix=~/.local`
  and Install billion-context (InstallBili; biliPath finds bili in
  ~/.local/bin when it isn't on PATH).
- Installed: its version, a note that an agent switched on here can't also
  run billion-context-pi or opencode-acp, and a switch per agent that runs
  `bili plugin install|remove <agent>` (SetBili), read back from
  `bili plugin list`.
- Offered for Pi, omp, OpenCode and Claude Code, the lanes that keep
  magpie in front: Pi/omp/OpenCode load it in process and still send to
  magpie; Claude Code goes through bili's proxy, which forwards to
  magpie's gateway. Not offered: Codex (MCP only), ZCode (routes only its
  own provider), Kimi Code (renames default_model to bili-kimi), dsh (its
  install failed through dsh's pnpm), Hermes (can't be tried in a sandbox
  HOME), and agents in WSL.

bili's remove doesn't restore a file: it leaves `"packages": []` in Pi's
settings and `extensions:` in omp's config, and after magpie rewrote
Claude Code's settings.json it deleted ANTHROPIC_BASE_URL (Claude Code
then went to Anthropic, not magpie) and put back DISABLE_AUTO_COMPACT.
So switching on records each file before and after (bili-plugins.json in
magpie's config folder), and off writes the before bytes back when the
file is unchanged since, else merges JSON three ways; with no record
(bili set up outside magpie) only a Claude Code ANTHROPIC_BASE_URL the
remove took out is put back. bili's .bili-bak/.bili-last files go too.
`GET/POST /api/library/bili`, `POST /api/library/bili/install` are
named in the CLI parity list beside RTK's. Docs: site library pages
(en, zh, ja) and docs/subsystems/library.md.

Run:
- go test ./internal/library -run 'TestBili|TestParseBiliList' on mote:
  ok (a fake bili mimicking pi/claude lanes, .bili-bak re-backup and
  claude's buggy remove; a fake npm for the install).
- Full `go test -timeout 45m ./...` on mote at 16c67965f (this commit
  before the body was written, same tree): every package ok but
  internal/gateway's TestBurstTellsNoSpeed/responses_from_chat_burst
  (804ms burst read as a speed, load ~50 after a mote reboot); passes
  -count=3 alone at the same head; recorded on #2719, same test. An
  earlier full run at 8c8c63537 was all ok.
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...,
  go vet ./... at 16c67965f: ok. gofmt -l: nothing.
- GUI at 16c67965f: library-bili, i18n-keys, i18n-en-no-cjk,
  library-memory, library-rtk-gain, library-pi-extensions, Chromium and
  WebKit (library-bili: every language, 1100 and 420 wide).
  80 of 80 pass.
- The whole GUI suite is still running on mote at this head, started
  before the tag; two earlier whole-suite runs were cut short (mote ran
  out of disk mid-run, then rebooted), so their reds are not a record.
  Its result goes in a follow-up.
- Real, in a sandbox HOME (named dir, bili 0.1.213 installed there,
  magpie web built from this branch on 3486/3487): through magpie's API,
  Pi and Claude Code switched on; `claude -p` and `pi -p` each answered
  "pong" through magpie's gateway (Claude Code via bili's proxy on
  18788 -> 127.0.0.1:3486); switched off: Pi's settings.json, Claude
  Code's settings.json and .claude.json byte-identical to before, no
  .bili-* files left, commands/acp-cache.md gone; claude -p answered
  again straight to the gateway. Earlier, with bili run by hand, Pi,
  OpenCode, omp, Claude Code and Kimi each sent a request through a
  recording relay with bili's tools/headers on it.

Broken by hand: skipping biliRestore turned TestBiliOnOffExact,
TestBiliClaudeKeepsMagpiesRoute and TestBiliOffWithoutRecord red;
dropping the no-record URL fix turned TestBiliOffWithoutRecord red;
removing the tab turned all 22 library-bili cases red; removing the zh
note string turned the zh cases red in both engines. Each put back.

Not tried: Kimi, dsh, Hermes, Codex, ZCode lanes (not offered); WSL;
Windows (the %APPDATA%\npm lookup and npm without --prefix are untried
on the Windows box); OpenCode and omp switched through magpie's API
(switched by hand with bili before); a real npm install from the button
(sandbox had bili already; the test fakes npm).
2026-11-10 07:24:26 +08:00
..