diff --git a/docs/subsystems/library.md b/docs/subsystems/library.md index 99083f510..74fd15fcb 100644 --- a/docs/subsystems/library.md +++ b/docs/subsystems/library.md @@ -37,7 +37,7 @@ Pi's extensions and packages. | Backups | Before a change first writes an agent file, `backups` copies it to `BackupDir`, one folder per change. The last `keepBackups` (30) changes are kept. The Backups button at the top of every tab, beside Library folder, opens that folder (`libHead`; Dade on Discord found it at the foot of a long page). | [`backup.go`](../../internal/library/backup.go) | | RTK | `SetRTK` runs rtk's own installer (`rtk init -g …`) for an agent being switched on. For one being switched off, it removes exactly what the installer wrote, using magpie's own code, which works even with rtk gone. `ReadRTK` reads each agent's files to say which have the hook. An agent gone for its CLI (`CLIMissing`, #2254) isn't offered rtk, but one that still has the hook is listed so it can be taken out. `rtkSpec.blocked` stops the installer where it would break an agent. `rtkSpec.env` tells the installer the agent's folder where rtk would pick another: Hermes Agent's is `appdir.HermesHome` (`%LOCALAPPDATA%\hermes` on Windows), which rtk is given as `HERMES_HOME`, since rtk 0.51 knows only `$HERMES_HOME` and `~/.hermes`. Antigravity CLI (`agy`, #2202) gets rtk 0.51's own plugin for Antigravity, `plugins/rtk` in its global customization folder `~/.gemini/config` (`plugin.json`, `hooks.json` with `PreToolUse` → `rtk hook antigravity`, `rules/AGENTS.md`), which `agy plugin list` lists; switching it off takes that one folder out. rtk 0.50 knows Antigravity only per project and fails `rtk init -g --agent antigravity`, so an older rtk is `blocked` (`agyBlocked`) and the row says to update RTK. OpenCode 2 loads only the plugin rtk 0.52 on writes (one default object with `id` and `setup()`, rtk-ai/rtk#4187); an older rtk's plugin is for OpenCode 1 and OpenCode 2 refuses it, so with an OpenCode 2 here an older rtk is `blocked` (`openCodeBlocked`) and the row says to update RTK (#2295). Under OpenCode 2, an old plugin left from before an rtk update counts as off once the rtk here can write the new one (`openCodeHas`), so switching it on writes the new one over it; with an older rtk it counts as on, so it can be switched off. Factory's Droid (lml0664 on Discord) gets rtk's own `rtk init -g --agent droid`, given Droid's folder as `FACTORY_HOME_OVERRIDE`; rtk puts its `Execute` group (`rtk hook droid`) in the root `hooks.json`, or in `settings.json`'s `hooks.PreToolUse` where Droid's hooks already are, so `droidHookFiles` reads and switches off all three places rtk 1.1.0 may use (`hooks.json`, `hooks/hooks.json`, `settings.json`), leaving the user's own hooks. rtk before 0.44 has no Droid agent, so it is `blocked` (`droidBlocked`). A detected agent RTK has no hook for at all is still listed, from `rtkNoHook`, with the reason and a switch that can't be turned on (dsh: its hooks can allow or deny a command but not rewrite it, and `rtk init` has no `--agent dsh`; Grok Build and Grok App: `rtk init` has no Grok or Grok App agent, so both are listed with the switch off; Qoder and Qoder CN: rtk 1.1.0 has no Qoder agent; Cline and Kimi Code: `rtk init --agent cline|kimi` writes only one project's `.clinerules` or `AGENTS.md`, instructions with no hook, and Kimi's refuses `-g`). RTK 1.1.0's Trae, Windsurf, Kilo Code and Mistral Vibe have no magpie agent. The page's No RTK hook tag gives each agent's own reason and rtk-ai/rtk issue (`rtkNoHookWhy` in plugins/library/client.js: dsh #3847, Grok Build and Grok App #2136, Qoder and Qoder CN #1327, Cline #3841), and an agent with no entry gets no link; `TestRTKNoHookIssuesAreEachAgents` fails when the page and `rtkNoHook` cite different issues, or two agents cite the same ones without a reason in `sharedRTKIssues`. | [`rtk.go`](../../internal/library/rtk.go) | | RTK in WSL | An agent in a WSL distro (`claude@wsl:Ubuntu`) is listed by its kind (`rtkKind`), and its hook runs in the distro, where Windows' rtk.exe is no command, so it gets the distro's own rtk (lex on Discord). `rtkDistroOf` asks the distro with `wsl.exe -d -e sh -lc` where rtk is (a login or interactive shell's PATH; else `~/.local/bin` or `~/.cargo/bin`, `offPath`), kept 15s; `ReadRTK` lists one `RTKDistro` for each distro its agents are in. Install RTK in WSL `` (`InstallRTKIn`, `POST /api/library/rtk/install` with `distro`, `magpie library rtk install `) runs RTK's own Linux installer in the distro (`curl -fsSL …/install.sh \| sh`, wget where there's no curl). Switching an agent on runs the distro's rtk there (`rtkInstallWSL`: `rtk init -g …` with its folder on PATH, Claude Code pointed at a folder of its own for the OpenCode and Cursor installers), and reads and edits its files under the distro's home as magpie opens it (`rtkClaudeDir`, `rtkCodexDir`, `rtkHome`). A distro that isn't running is never started (#3896): `rtkWSLLive` and `rtkDistroOf` check `agent.WSLRunning` first, its agents are listed `asleep` with the switch off, and switching or installing says to start it (`TestRTKWSLAsleep`). The page gives each distro a card (`rtkDistroCard` in plugins/library/client.js; library-rtk-wsl.test.cjs). | [`rtk_wsl.go`](../../internal/library/rtk_wsl.go) | -| billion-context | `SetBili` runs bili's own `bili plugin install ` for an agent switched on and `bili plugin remove ` for one switched off; `ReadBili` reads `bili plugin list` (the agent column, then the status; `installed…` is on, `not installed` off, anything else shown as it is). `InstallBili` runs its README's `npm install -g billion-context --prefix=~/.local` (`npm install -g billion-context` on Windows), and `biliPath` finds bili there when it isn't on PATH. Offered only where bili's plugin works with magpie in front (`biliLanes`): Pi, omp and OpenCode load it in process and still send to magpie, and Claude Code goes through bili's proxy, which forwards to the gateway (`ANTHROPIC_BASE_URL` `…/bili/`). Codex's lane is an MCP server only, ZCode's routes only its own provider, Kimi Code's renames `default_model` to `bili-kimi` at every start, dsh's install failed through dsh's pnpm and Hermes' can't be tried in a sandbox HOME, so none of those is offered; neither is an agent 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) and put back its own `DISABLE_AUTO_COMPACT`. So switching on keeps each file it writes as it was before and after (`bili-plugins.json` in magpie's config folder), and `biliRestore` after the remove writes the file before back byte for byte when nothing changed it since, else merges JSON (`biliMergeJSON`): what the install changed and is still as installed goes back, a value changed since stays, and what the remove changed beyond the install is put back. Without a record (bili installed outside magpie), only a Claude Code `ANTHROPIC_BASE_URL` the remove took out goes back to the address bili forwarded to. The `.bili-bak` and `.bili-last` files bili leaves beside each file go with it. bili's Claude Code install also writes `DISABLE_AUTO_COMPACT` "1" into the shared settings.json, so a session bili doesn't fold (the Claude desktop app's Code tab, which sets its own `ANTHROPIC_BASE_URL`, bili's #2290, or a window larger than the one magpie serves) has no compaction left and Claude Code answers every message with "Prompt is too long" without sending it. `biliKeepCompact` writes "0" in its place after the install (bili's own reinstall keeps a value that isn't "1"), unless the file had a `DISABLE_AUTO_COMPACT` of the user's own before; `keepBiliCompact`, from `KeepLinked` at start, does the same for a plugin installed before and has the record say "0", so switching off still takes it away. Zed has no plugin of bili's; bili's README lists it through the launcher (`bili zed`, Linux only, which leaves a provider on loopback direct, so it never passes magpie's gateway) and, on every system, the `/bili/` prefix its docs give for a client whose model address can be edited. So Zed is a URL lane (`biliURLLanes`, [`bili_url.go`](../../internal/library/bili_url.go)): switched on, `biliServe` has `bili start --port 8787` answer (`GET /__bili/health` says `{"ok":true}`; one the user runs is used as it is, else magpie runs its own under `KeepLinked`'s context, logging to `bili-start.log`), then `agent.ZedThrough` puts the magpie provider's `api_url` at `http://127.0.0.1:8787/bili//v1` and saves the key for that address in the system's credential store, where Zed looks it up by the address. Zed must be on magpie first. A pick and a sync keep the prefix while magpie answers through it (`zedReach`, the proxy recognition of #1985); switched off, `api_url` goes back to the gateway and magpie's `bili start` ends when no agent goes through the prefix. `keepBiliServe`, from `KeepLinked`, starts it again at magpie's start while Zed is on. `TestBiliZedThroughPrefix`, `TestZedThroughBili`. What bili saved is its own count ([`bili_saved.go`](../../internal/library/bili_saved.go)): bili 0.1.213 has no command that prints it, and its running proxy serves its dashboard's numbers at `GET /__bili/overview`, summed over every session in its one store for every agent and lane. `readBiliSaved` asks the bilis registered in `/instances/.json` (`$XDG_STATE_HOME` or `~/.local/state`, then `billion-context`, on every system), newest `startedAt` first, loopback `http` origins only, within 3s in all; a file a crashed bili left behind just fails. The first answer is `BiliView.Saved` (`netSavedTotal` as `net`, only with `hasFoldData`; `grossSavedTotal`, which bili calls an upper bound; `foldsTotal`, `sessions`, `requests`) and is kept in `bili-saved.json` in magpie's config folder, shown with `live: false` and its time when no bili answers. magpie never starts a bili to ask (it would auto-update and start watchers). `TestBiliSavedFromRunningBili` (the literal overview in `testdata/bili`), `TestBiliSavedNoFolds`, `TestBiliSavedNoneYet`, `TestBiliSavedOnThePage`, `TestBiliLoopback`. `TestBiliClaudeKeepsAutoCompact`, `TestBiliOnOffExact`, `TestBiliClaudeKeepsMagpiesRoute`, `TestBiliOffWithoutRecord`; the page's tab is `renderBili` (library-bili.test.cjs). | [`bili.go`](../../internal/library/bili.go) | +| billion-context | `SetBili` runs bili's own `bili plugin install ` for an agent switched on and `bili plugin remove ` for one switched off; `ReadBili` reads `bili plugin list` (the agent column, then the status; `installed…` is on, `not installed` off, anything else shown as it is). `InstallBili` runs its README's `npm install -g billion-context --prefix=~/.local` (`npm install -g billion-context` on Windows), and `biliPath` finds bili there when it isn't on PATH. Offered only where bili's plugin works with magpie in front (`biliLanes`): Pi, omp and OpenCode load it in process and still send to magpie, and Claude Code goes through bili's proxy, which forwards to the gateway (`ANTHROPIC_BASE_URL` `…/bili/`). Codex's lane is an MCP server only, ZCode's routes only its own provider, Kimi Code's renames `default_model` to `bili-kimi` at every start and dsh's install failed through dsh's pnpm, so none of those is offered; neither is an agent 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) and put back its own `DISABLE_AUTO_COMPACT`. So switching on keeps each file it writes as it was before and after (`bili-plugins.json` in magpie's config folder), and `biliRestore` after the remove writes the file before back byte for byte when nothing changed it since, else merges JSON (`biliMergeJSON`): what the install changed and is still as installed goes back, a value changed since stays, and what the remove changed beyond the install is put back. Without a record (bili installed outside magpie), only a Claude Code `ANTHROPIC_BASE_URL` the remove took out goes back to the address bili forwarded to. The `.bili-bak` and `.bili-last` files bili leaves beside each file go with it. bili's Claude Code install also writes `DISABLE_AUTO_COMPACT` "1" into the shared settings.json, so a session bili doesn't fold (the Claude desktop app's Code tab, which sets its own `ANTHROPIC_BASE_URL`, bili's #2290, or a window larger than the one magpie serves) has no compaction left and Claude Code answers every message with "Prompt is too long" without sending it. `biliKeepCompact` writes "0" in its place after the install (bili's own reinstall keeps a value that isn't "1"), unless the file had a `DISABLE_AUTO_COMPACT` of the user's own before; `keepBiliCompact`, from `KeepLinked` at start, does the same for a plugin installed before and has the record say "0", so switching off still takes it away. Zed has no plugin of bili's; bili's README lists it through the launcher (`bili zed`, Linux only, which leaves a provider on loopback direct, so it never passes magpie's gateway) and, on every system, the `/bili/` prefix its docs give for a client whose model address can be edited. So Zed is a URL lane (`biliURLLanes`, [`bili_url.go`](../../internal/library/bili_url.go)): switched on, `biliServe` has `bili start --port 8787` answer (`GET /__bili/health` says `{"ok":true}`; one the user runs is used as it is, else magpie runs its own under `KeepLinked`'s context, logging to `bili-start.log`), then `agent.ZedThrough` puts the magpie provider's `api_url` at `http://127.0.0.1:8787/bili//v1` and saves the key for that address in the system's credential store, where Zed looks it up by the address. Zed must be on magpie first. A pick and a sync keep the prefix while magpie answers through it (`zedReach`, the proxy recognition of #1985); switched off, `api_url` goes back to the gateway and magpie's `bili start` ends when no agent goes through the prefix. `keepBiliServe`, from `KeepLinked`, starts it again at magpie's start while Zed is on. `TestBiliZedThroughPrefix`, `TestZedThroughBili`. Hermes is a URL lane too: bili's Hermes plugin (`bili plugin install hermes`, `hermes-plugin/__init__.py` `apply_env`) routes Hermes by setting `HTTPS_PROXY` in its process and nothing else, so magpie's provider at `http://127.0.0.1` never passes it and nothing would fold. Switched on, `agent.HermesThrough` puts the `base_url` of magpie's entries (`magpie`, `magpie-anthropic`) behind the prefix in the connected config and every profile that has them; `hermesEntries` keeps a prefix on loopback with a path (`hermesPrefix`) across a pick and a sync, and `wiringOff` takes it as magpie's (`reachesMagpie`). A profile that gets magpie's entries later goes to the gateway until Hermes is switched on again. `TestBiliHermesThroughPrefix`, `TestHermesThroughBili`. What bili saved is its own count ([`bili_saved.go`](../../internal/library/bili_saved.go)): bili 0.1.213 has no command that prints it, and its running proxy serves its dashboard's numbers at `GET /__bili/overview`, summed over every session in its one store for every agent and lane. `readBiliSaved` asks the bilis registered in `/instances/.json` (`$XDG_STATE_HOME` or `~/.local/state`, then `billion-context`, on every system), newest `startedAt` first, loopback `http` origins only, within 3s in all; a file a crashed bili left behind just fails. The first answer is `BiliView.Saved` (`netSavedTotal` as `net`, only with `hasFoldData`; `grossSavedTotal`, which bili calls an upper bound; `foldsTotal`, `sessions`, `requests`) and is kept in `bili-saved.json` in magpie's config folder, shown with `live: false` and its time when no bili answers. magpie never starts a bili to ask (it would auto-update and start watchers). `TestBiliSavedFromRunningBili` (the literal overview in `testdata/bili`), `TestBiliSavedNoFolds`, `TestBiliSavedNoneYet`, `TestBiliSavedOnThePage`, `TestBiliLoopback`. `TestBiliClaudeKeepsAutoCompact`, `TestBiliOnOffExact`, `TestBiliClaudeKeepsMagpiesRoute`, `TestBiliOffWithoutRecord`; the page's tab is `renderBili` (library-bili.test.cjs). | [`bili.go`](../../internal/library/bili.go) | | Pi extensions | Each Pi here, this computer's and each WSL distro's (`piPlaces`), with the extensions and packages it loads, read by Pi's own rules (`@earendil-works/pi-coding-agent` 1.4: `resolveExtensionEntries`, `isEnabledByOverrides`, `applyPatterns`). An extension is a `.ts`/`.js` file or a folder (package.json `pi.extensions`, else `index.ts`, else `index.js`) in `/extensions`, or a path its settings.json `extensions` lists; a package is an entry of settings.json `packages`. Built-in extensions (`builtin:mcp` and the rest) aren't listed: `builtin:mcp` carries the MCP servers magpie gives Pi. `SetPiExtension` writes what `pi config` writes (`-path` off; the `-` taken out and `+path` only where still excluded, on); `SetPiPackage` sets a package's four filters to `[]` (off) or takes them out (on), and refuses an entry that already picks some parts (`filtered`, changed in `pi config`). `CopyPi` gives a package to another Pi as its settings.json entry, which Pi installs itself when it next starts (npm into `/npm`, git into `/git`), never as copied files; it refuses a local package, and one the other Pi has already by Pi's identity (npm name, git host/path). An extension is copied as its file or folder into the other's `extensions`, leaving out `node_modules`, `.git` and symlinks, never over one of the same name, and the page says to run `npm install` there when it has dependencies (leokon3 on Discord). A settings.json that can't be parsed lists nothing and is never written; a stopped distro is never started (`asleep`); every write is backed up first. `GET`/`POST /api/library/pi`, `POST /api/library/pi/copy`; the Library's Pi packages tab, shown while a Pi is here (`renderPi` in plugins/library/client.js; library-pi-extensions.test.cjs). | [`piext.go`](../../internal/library/piext.go) | ## Runtime path diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 2095b478e..16b75480b 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -341,6 +341,10 @@ type Agent struct { // that is known yet, and the proxy and where it is set; ok with no // proxy when it sends them straight there (see codex_proxy.go). viaProxy func() (ok, known bool, proxy, from string) + // through, when set, puts magpie's provider in the agent's config at + // the gateway behind a proxy's prefix ("" for the gateway itself): + // Hermes's, through billion-context's /bili/ (HermesThrough) + through func(prefix string) error // dirShared says Dir is a folder another agent keeps its files in too // (omp's, when PI_CODING_AGENT_DIR points it at Pi's): that it is there // says nothing of this agent. diff --git a/internal/agent/hermes.go b/internal/agent/hermes.go index d1271b1de..e110fdd1d 100644 --- a/internal/agent/hermes.go +++ b/internal/agent/hermes.go @@ -33,6 +33,7 @@ package agent import ( "encoding/json" "errors" + "fmt" "os" "path/filepath" "slices" @@ -245,9 +246,77 @@ func hermesIn(at place) *Agent { }}, } a.Fields = append(a.Fields, hermesProfileFields(at, dir)...) + a.through = func(prefix string) error { return hermesThrough(at, dir, path, prefix) } return a } +// HermesThrough points magpie's providers in Hermes's configs (a, Hermes) +// at the gateway through prefix, an address a local proxy takes the +// gateway's after (billion-context's http://127.0.0.1:8787/bili/), "" for +// the gateway itself. Hermes must be on magpie already. bili's own plugin +// for Hermes (bili plugin install hermes) sets HTTPS_PROXY in Hermes's +// process and nothing else, so a provider at http://127.0.0.1 (magpie's) +// never passes it; its docs' /bili/ prefix, which bili start answers, +// takes any client whose address can be edited. +func HermesThrough(a *Agent, prefix string) error { + if a == nil || a.ID != "hermes" || a.through == nil { + return fmt.Errorf("not Hermes") + } + return a.through(prefix) +} + +// HermesURL is the base_url of magpie's provider in Hermes's connected +// config (a, Hermes), "" without one. +func HermesURL(a *Agent) string { + u, _ := edit.GetYAML(a.Path, "providers."+magpieID+".base_url") + return u +} + +// hermesPrefix is the prefix magpie's entries in the config at path reach +// the gateway behind: a local proxy's route on loopback before the +// gateway's address (billion-context's http://127.0.0.1:8787/bili/, +// HermesThrough), which a sync and a pick keep; "" when they go to the +// gateway itself or anywhere else. +func hermesPrefix(at place, path string) string { + gw := at.gw() + for _, name := range []string{magpieID, hermesAnthropicID} { + v, ok := edit.GetYAML(path, "providers."+name+".base_url") + if !ok { + continue + } + mode, _ := hermesModeIn(path, name) + p, ok := strings.CutSuffix(strings.TrimSuffix(strings.TrimSpace(v), "/"), hermesBase(gw, mode)) + if ok && p != "" && loopbackWithPath(strings.TrimSuffix(p, "/")) { + return p + } + } + return "" +} + +// hermesThrough is HermesThrough for Hermes at a place, connected in the +// config at path (in dir): magpie's entries there and in every other +// profile's config that has them go to the gateway through prefix. +func hermesThrough(at place, dir, path, prefix string) error { + if edit.GetYAMLMap(path, "providers."+magpieID) == nil { + return fmt.Errorf("connect Hermes to magpie first: pick one of magpie's models for it on the Agents page") + } + var errs []error + for _, p := range append([]string{path}, hermesOthers(at, dir)...) { + var kvs []edit.KV + for _, name := range []string{magpieID, hermesAnthropicID} { + if edit.GetYAMLMap(p, "providers."+name) == nil { + continue + } + mode, _ := hermesModeIn(p, name) + kvs = append(kvs, edit.KV{Path: "providers." + name + ".base_url", Value: prefix + hermesBase(at.gw(), mode)}) + } + if len(kvs) > 0 { + errs = append(errs, edit.SetYAML(p, kvs...)) + } + } + return errors.Join(errs...) +} + // hermesProfileKey begins the key of a profile's model field // (hermesProfileFields): "profile:" const hermesProfileKey = "profile:" @@ -735,10 +804,12 @@ func hermesRoute(path, ref string) string { // entry's api_mode the user set stays, and its address follows it. func hermesEntries(at place, path string) [][2]any { gw := at.gw() + // a local proxy's prefix the entries go through stays (HermesThrough) + pre := hermesPrefix(at, path) anth, split := hermesSplit(path) chat := hermesProviderAt(gw) mode, _ := hermesModeIn(path, magpieID) - chat.APIMode, chat.BaseURL = mode, hermesBase(gw, mode) + chat.APIMode, chat.BaseURL = mode, pre+hermesBase(gw, mode) if split { chat.Models = slices.DeleteFunc(chat.Models, func(id string) bool { return slices.Contains(anth, id) }) } @@ -748,7 +819,7 @@ func hermesEntries(at place, path string) [][2]any { } mode, _ = hermesModeIn(path, hermesAnthropicID) e := hermesProviderAt(gw) - e.Name, e.APIMode, e.BaseURL, e.Models = hermesAnthropicID, mode, hermesBase(gw, mode), anth + e.Name, e.APIMode, e.BaseURL, e.Models = hermesAnthropicID, mode, pre+hermesBase(gw, mode), anth // the key as "magpie" has it: a reference to a variable the user // keeps there goes into this one too e.APIKey = hermesKeptKey(at, path, magpieID, e.APIKey) diff --git a/internal/agent/hermes_anthropic_test.go b/internal/agent/hermes_anthropic_test.go index fd426a1f4..c3563eed8 100644 --- a/internal/agent/hermes_anthropic_test.go +++ b/internal/agent/hermes_anthropic_test.go @@ -4,6 +4,7 @@ import ( "os" "path/filepath" "slices" + "strings" "testing" "github.com/yetone/magpie/internal/appdir" @@ -224,3 +225,74 @@ func TestHermesKeepsTheUsersAPIMode(t *testing.T) { t.Fatalf("openai alias:\n%s", raw) } } + +// Duckb7si on X: Hermes was on magpie, and billion-context's Library page +// had no Hermes to switch on. bili's own plugin for Hermes sets +// HTTPS_PROXY alone, which magpie's http://127.0.0.1 provider never takes, +// so Hermes goes through bili's /bili/ prefix: HermesThrough puts both of +// magpie's entries, in every bot that has them, behind it; a pick and a +// sync keep it (each rewrites base_url), Check takes it as magpie's, and +// off puts the gateway back. +func TestHermesThroughBili(t *testing.T) { + home, path := hermesAnthropicHome(t) + os.WriteFile(path, []byte("model:\n default: kimi-k3\n provider: moonshot\n"), 0o644) + bot := filepath.Join(filepath.Dir(path), "profiles", "coder", "config.yaml") + os.MkdirAll(filepath.Dir(bot), 0o755) + os.WriteFile(bot, []byte("model:\n default: kimi-k3\n provider: moonshot\n"), 0o644) + const prefix = "http://127.0.0.1:8787/bili/" + gw := gateway.URL() + fakeMagpieAt(t, map[string]bool{prefix + gw: true}) + a := hermes(home) + if err := HermesThrough(a, prefix); err == nil { + t.Fatal("put a Hermes not on magpie through bili") + } + setUpInMagpie("hermes") + if err := a.Apply("model", "magpie/relay/claude-opus-5-5"); err != nil { + t.Fatal(err) + } + if err := HermesThrough(a, prefix); err != nil { + t.Fatal(err) + } + through := func(when string, want string) { + t.Helper() + for _, p := range []string{path, bot} { + c, raw := readHermes(t, p) + if c.Providers[magpieID] == nil || c.Providers[hermesAnthropicID] == nil || + c.Providers[magpieID].BaseURL != want+gw+"/v1" || c.Providers[hermesAnthropicID].BaseURL != want+gw { + t.Fatalf("%s: %s:\n%s", when, p, raw) + } + } + if HermesURL(a) != want+gw+"/v1" { + t.Fatalf("%s: HermesURL %q", when, HermesURL(a)) + } + if c := a.Check(); c != "" { + t.Fatalf("%s: %s", when, c) + } + } + through("on", prefix) + // a pick, onto the other entry, and a sync keep it + if err := a.Apply("model", "magpie/deepseek/pro"); err != nil { + t.Fatal(err) + } + through("after a pick", prefix) + if err := a.Sync(); err != nil { + t.Fatal(err) + } + through("after a sync", prefix) + // one at an address that isn't a local proxy's route goes back to the + // gateway on a sync, as before + for _, wrong := range []string{"http://127.0.0.1:9999", "https://elsewhere.example/bili/"} { + os.WriteFile(path, []byte(strings.ReplaceAll(readFile(path), prefix, wrong)), 0o644) + if err := a.Sync(); err != nil { + t.Fatal(err) + } + if c, raw := readHermes(t, path); c.Providers[magpieID].BaseURL != gw+"/v1" { + t.Fatalf("%s kept:\n%s", wrong, raw) + } + HermesThrough(a, prefix) + } + if err := HermesThrough(a, ""); err != nil { + t.Fatal(err) + } + through("off", "") +} diff --git a/internal/gui/assets/plugins/library/client.js b/internal/gui/assets/plugins/library/client.js index 6778c8066..0fb2d3488 100644 --- a/internal/gui/assets/plugins/library/client.js +++ b/internal/gui/assets/plugins/library/client.js @@ -1699,7 +1699,7 @@ magpie.plugin("library", (ctx) => { row.append(sw); list.append(row); } - if (!rows.length) list.append(el("div", "lib-none", t("None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed."))); + if (!rows.length) list.append(el("div", "lib-none", t("None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed."))); body.append(list); } // What billion-context saved, in its own count: what its running proxy diff --git a/internal/gui/assets/plugins/library/i18n.js b/internal/gui/assets/plugins/library/i18n.js index 2c121f0e1..cd2164526 100644 --- a/internal/gui/assets/plugins/library/i18n.js +++ b/internal/gui/assets/plugins/library/i18n.js @@ -910,7 +910,7 @@ magpie.strings({ "Not whole": "不完整", "bili plugin list says: {status}. Switch it off to take out what is there.": "bili plugin list 显示:{status}。关闭此开关可移除已有的部分。", "{agent} folds its context with billion-context": "{agent} 用 billion-context 折叠上下文", - "None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed.": "你的 Agent 里没有能配合 magpie 使用 billion-context 的:Pi、omp、OpenCode、Claude Code 或 Zed。", + "None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed.": "你的 Agent 里没有能配合 magpie 使用 billion-context 的:Pi、omp、OpenCode、Claude Code、Hermes 或 Zed。", "billion-context is on for {agent} — restart it to use it": "{agent} 已打开 billion-context — 重启后生效", "billion-context is off for {agent} — restart it to see it": "{agent} 已关闭 billion-context — 重启后生效", "billion-context is installed — switch it on for your agents below": "billion-context 已安装 — 在下方为你的 Agent 打开它", @@ -1831,7 +1831,7 @@ magpie.strings({ "Not whole": "不完整", "bili plugin list says: {status}. Switch it off to take out what is there.": "bili plugin list 顯示:{status}。關閉此開關可移除已有的部分。", "{agent} folds its context with billion-context": "{agent} 用 billion-context 摺疊上下文", - "None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed.": "你的 Agent 裡沒有能配合 magpie 使用 billion-context 的:Pi、omp、OpenCode、Claude Code 或 Zed。", + "None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed.": "你的 Agent 裡沒有能配合 magpie 使用 billion-context 的:Pi、omp、OpenCode、Claude Code、Hermes 或 Zed。", "billion-context is on for {agent} — restart it to use it": "{agent} 已開啟 billion-context — 重啟後生效", "billion-context is off for {agent} — restart it to see it": "{agent} 已關閉 billion-context — 重啟後生效", "billion-context is installed — switch it on for your agents below": "billion-context 已安裝 — 在下方為你的 Agent 開啟它", @@ -2752,7 +2752,7 @@ magpie.strings({ "Not whole": "不完全", "bili plugin list says: {status}. Switch it off to take out what is there.": "bili plugin list の表示:{status}。オフにすると残っている部分を取り除きます。", "{agent} folds its context with billion-context": "{agent} のコンテキストを billion-context で畳み込む", - "None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed.": "billion-context を magpie と使えるエージェントがありません:Pi、omp、OpenCode、Claude Code、Zed。", + "None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed.": "billion-context を magpie と使えるエージェントがありません:Pi、omp、OpenCode、Claude Code、Hermes、Zed。", "billion-context is on for {agent} — restart it to use it": "{agent} で billion-context をオンにしました — 再起動すると使えます", "billion-context is off for {agent} — restart it to see it": "{agent} で billion-context をオフにしました — 再起動すると反映されます", "billion-context is installed — switch it on for your agents below": "billion-context をインストールしました — 下でエージェントごとにオンにしてください", @@ -3673,7 +3673,7 @@ magpie.strings({ "Not whole": "Unvollständig", "bili plugin list says: {status}. Switch it off to take out what is there.": "bili plugin list sagt: {status}. Schalte es aus, um zu entfernen, was da ist.", "{agent} folds its context with billion-context": "{agent} faltet seinen Kontext mit billion-context", - "None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed.": "Keiner deiner Agenten kann billion-context mit magpie nutzen: Pi, omp, OpenCode, Claude Code oder Zed.", + "None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed.": "Keiner deiner Agenten kann billion-context mit magpie nutzen: Pi, omp, OpenCode, Claude Code, Hermes oder Zed.", "billion-context is on for {agent} — restart it to use it": "billion-context ist für {agent} an — starte ihn neu, um es zu nutzen", "billion-context is off for {agent} — restart it to see it": "billion-context ist für {agent} aus — starte ihn neu, damit es wirkt", "billion-context is installed — switch it on for your agents below": "billion-context ist installiert — schalte es unten für deine Agenten ein", diff --git a/internal/library/bili.go b/internal/library/bili.go index 3cc9634eb..18ddf57cc 100644 --- a/internal/library/bili.go +++ b/internal/library/bili.go @@ -37,12 +37,13 @@ import ( // bili's local proxy, which forwards to the gateway (ANTHROPIC_BASE_URL // .../bili/). Codex's lane is an MCP server only, ZCode's // routes only its own provider, Kimi Code's renames the default model in -// config.toml at each start (bili-kimi), dsh's installs through dsh's -// package manager, and Hermes' can't be tried without touching its -// launcher: none of those is offered. +// config.toml at each start (bili-kimi) and dsh's installs through dsh's +// package manager: none of those is offered. // -// Zed has no plugin of bili's: its magpie provider goes through bili's -// /bili/ prefix with bili start answering there (biliURLLanes, bili_url.go). +// Zed has no plugin of bili's, and Hermes' sets HTTPS_PROXY alone, which +// magpie's http://127.0.0.1 provider never takes: their magpie provider +// goes through bili's /bili/ prefix with bili start answering there +// (biliURLLanes, bili_url.go). // // bili's remove doesn't put a file back as it was: it leaves "packages": [] // in Pi's settings.json and "extensions:" in omp's config.yml, and after diff --git a/internal/library/bili_test.go b/internal/library/bili_test.go index ece5b537e..8477c3f3e 100644 --- a/internal/library/bili_test.go +++ b/internal/library/bili_test.go @@ -13,6 +13,7 @@ import ( "time" "github.com/yetone/magpie/internal/agent" + "github.com/yetone/magpie/internal/appdir" "github.com/yetone/magpie/internal/gateway" "github.com/yetone/magpie/internal/proc" "github.com/yetone/magpie/internal/testenv" @@ -542,6 +543,65 @@ func TestBiliZedThroughPrefix(t *testing.T) { } } +// TestBiliHermesThroughPrefix (Duckb7si on X): Hermes on magpie had no +// row on billion-context's page. bili's plugin for Hermes sets HTTPS_PROXY +// alone, which magpie's http://127.0.0.1 provider never takes, so Hermes +// goes through the /bili/ prefix as Zed does: switched on, bili start +// answers and magpie's provider's base_url is behind the prefix; off, it is +// on the gateway again and magpie's bili start ends. bili's plugin +// installer never runs for it. +func TestBiliHermesThroughPrefix(t *testing.T) { + h := sandbox(t) + f := newFakeBili(t, h) + t.Setenv("HERMES_HOME", "") + holdCLI(t, h, "hermes") + cfg := filepath.Join(appdir.HermesHome(), "config.yaml") + gw := gateway.URL() + "/v1" + write(t, cfg, "# mine\nmodel:\n default: deepseek/pro\n provider: magpie\nproviders:\n magpie:\n name: magpie\n base_url: "+gw+"\n api_key: magpie\n api_mode: chat_completions\n") + + serving, served, stopped := false, 0, 0 + was := []any{biliServe, biliStop, biliServing} + biliServe = func(string) error { served++; serving = true; return nil } + biliStop = func() { stopped++; serving = false } + biliServing = func() bool { return serving } + t.Cleanup(func() { + biliServe = was[0].(func(string) error) + biliStop = was[1].(func()) + biliServing = was[2].(func() bool) + }) + + if on, ok := biliOnFor(t)["hermes"]; !ok || on { + t.Fatalf("Hermes offered %v, on %v", ok, on) + } + v, err := SetBili("hermes", true) + if err != nil { + t.Fatal(err) + } + if !slices.Equal(v.Restart, []string{"hermes"}) || v.Backup == "" { + t.Fatalf("restart %v, backup %q", v.Restart, v.Backup) + } + if !strings.Contains(read(t, cfg), "base_url: "+biliPrefix+gw+"\n") || !strings.Contains(read(t, cfg), "# mine") || served != 1 { + t.Fatalf("served %d, config:\n%s", served, read(t, cfg)) + } + if !biliOnFor(t)["hermes"] { + t.Fatal("Hermes isn't shown on") + } + serving = false + keepBiliServe(context.Background()) + if served != 2 { + t.Fatalf("bili start run %d times, want 2", served) + } + if _, err := SetBili("hermes", false); err != nil { + t.Fatal(err) + } + if !strings.Contains(read(t, cfg), "base_url: "+gw+"\n") || stopped != 1 || biliOnFor(t)["hermes"] { + t.Fatalf("stopped %d, config:\n%s", stopped, read(t, cfg)) + } + if len(filter(f.runs, "plugin install", "plugin remove")) != 0 { + t.Fatalf("ran %v", f.runs) + } +} + // TestBiliVersionPastItsWarnings: `bili --version` is read with stderr, // and bili 0.1.213 on mote wrote a config warning before the version; the // card said "2026-11-09T23:44:06.211" for the version. diff --git a/internal/library/bili_url.go b/internal/library/bili_url.go index d17181026..3fe9fe328 100644 --- a/internal/library/bili_url.go +++ b/internal/library/bili_url.go @@ -48,11 +48,24 @@ type biliURLLane struct { // zedThrough is agent.ZedThrough; a var for tests, which save no key. var zedThrough = agent.ZedThrough +// Hermes has a plugin of bili's (bili plugin install hermes), but it +// routes Hermes's traffic by setting HTTPS_PROXY in Hermes's process +// alone (hermes-plugin/__init__.py apply_env), and magpie's provider is at +// http://127.0.0.1, which that never takes: the plugin would add its +// tools while nothing folds. So Hermes goes through the /bili/ prefix as +// Zed does: agent.HermesThrough puts the base_url of magpie's entries, in +// every profile that has them, behind it, which a sync and a pick keep +// (Duckb7si on X). + var biliURLLanes = map[string]biliURLLane{ "zed": { on: func(a *agent.Agent) bool { return strings.HasPrefix(agent.ZedURL(a), biliPrefix) }, set: func(a *agent.Agent, prefix string) error { return zedThrough(a, prefix) }, }, + "hermes": { + on: func(a *agent.Agent) bool { return strings.HasPrefix(agent.HermesURL(a), biliPrefix) }, + set: agent.HermesThrough, + }, } // biliServing says bili start answers at biliOrigin: its health is diff --git a/site/public/docs/ja/library.html b/site/public/docs/ja/library.html index 550cfff18..2cbda5945 100644 --- a/site/public/docs/ja/library.html +++ b/site/public/docs/ja/library.html @@ -237,9 +237,9 @@ magpie library sync # エージェントに書き直す

RTK タブでは RTK をエージェントごとにオンにします。エージェントのシェルコマンドが RTK を通り、出力が短くなってトークンを節約します。magpie は RTK をインストールでき、RTK がなくてもオフにできます。

billion-context

-

billion-context タブでは billion-context のプラグインをエージェントごとにオンにします。長いセッションの古いやり取りを、モデルが再び開ける要約に畳み込み、セッションをモデルのコンテキストウィンドウに収めます。対象は Pi、omp、OpenCode、Claude Code、Zed で、オンにしてもリクエストは magpie を通ります。magpie はインストールでき(npm install -g billion-context --prefix=~/.local)、billion-context 自身のインストーラーとリムーバーを実行します。オフにすると、インストールで変わったエージェントの設定を元に戻します。ここでオンにしたエージェントでは billion-context-pi や opencode-acp を併用できません。

+

billion-context タブでは billion-context のプラグインをエージェントごとにオンにします。長いセッションの古いやり取りを、モデルが再び開ける要約に畳み込み、セッションをモデルのコンテキストウィンドウに収めます。対象は Pi、omp、OpenCode、Claude Code、Hermes、Zed で、オンにしてもリクエストは magpie を通ります。magpie はインストールでき(npm install -g billion-context --prefix=~/.local)、billion-context 自身のインストーラーとリムーバーを実行します。オフにすると、インストールで変わったエージェントの設定を元に戻します。ここでオンにしたエージェントでは billion-context-pi や opencode-acp を併用できません。

Claude Code では、billion-context のインストールが Claude Code 自身の自動コンパクトをオフにします。magpie はそれをオンに戻すので、billion-context が畳み込まないセッション(Claude デスクトップアプリの Code タブなど)は「Prompt is too long」で止まらずにコンパクトされます。自分で設定した DISABLE_AUTO_COMPACT はそのままです。

-

Zed には billion-context のプラグインがありません。オンにすると、magpie は bili start を実行し、Zed の magpie プロバイダーのアドレスを http://127.0.0.1:8787/bili/ に magpie のアドレスを続けたものにします。billion-context があらゆるクライアント向けに案内している接続方法です。先に Agents ページで Zed に magpie のモデルを選んでください。オン・オフの後は Zed を再起動します。

+

Zed には billion-context のプラグインがなく、Hermes のプラグインは HTTPS の通信しか扱いませんが、magpie のローカルアドレスは HTTPS ではありません。オンにすると、magpie は bili start を実行し、エージェントの magpie プロバイダーのアドレスを http://127.0.0.1:8787/bili/ に magpie のアドレスを続けたものにします。billion-context があらゆるクライアント向けに案内している接続方法です。Hermes では magpie のプロバイダーがあるすべてのプロファイルが対象です。先に Agents ページでそのエージェントに magpie のモデルを選んでください。オン・オフの後はエージェントを再起動します。

カードには billion-context が節約したトークン数を、billion-context 自身の集計で表示します。ダッシュボードと同じ純節約量(折りたたみ後の再構築と要約のコストを差し引いた値)に、折りたたみ回数とセッション数を添え、このコンピューターで動いたすべてのセッションが対象です。magpie は動いている billion-context から読み取ります(/__bili/overview)。動いていないときは、最後に読んだ数と時刻を表示します。billion-context がエージェントで動くまでは数は表示されません。

magpie が触るもの

diff --git a/site/public/docs/library.html b/site/public/docs/library.html index f05a821a8..018a8dcfa 100644 --- a/site/public/docs/library.html +++ b/site/public/docs/library.html @@ -237,9 +237,9 @@ magpie library sync # write it into the agents again

The RTK tab turns on RTK per agent: the agent’s shell commands run through RTK, which shortens their output to save tokens. magpie can install RTK for you; turning it off works with RTK gone.

billion-context

-

The billion-context tab turns on billion-context’s plugin per agent: it folds older turns of a long session into summaries the model can open again, so the session stays inside the model’s window. It is offered for Pi, omp, OpenCode, Claude Code and Zed, whose requests still go through magpie with it on. magpie can install it for you (npm install -g billion-context --prefix=~/.local) and runs its own installer and remover; turning it off puts back what the install changed in the agent’s settings. An agent turned on here can’t also run billion-context-pi or opencode-acp.

+

The billion-context tab turns on billion-context’s plugin per agent: it folds older turns of a long session into summaries the model can open again, so the session stays inside the model’s window. It is offered for Pi, omp, OpenCode, Claude Code, Hermes and Zed, whose requests still go through magpie with it on. magpie can install it for you (npm install -g billion-context --prefix=~/.local) and runs its own installer and remover; turning it off puts back what the install changed in the agent’s settings. An agent turned on here can’t also run billion-context-pi or opencode-acp.

For Claude Code, billion-context’s install turns Claude Code’s own auto-compaction off. magpie turns it back on, so a session billion-context doesn’t fold, such as one in the Claude desktop app’s Code tab, compacts instead of stopping at “Prompt is too long”. A DISABLE_AUTO_COMPACT you set yourself is left as it is.

-

Zed has no billion-context plugin. Turned on, magpie runs bili start and points Zed’s magpie provider at http://127.0.0.1:8787/bili/ followed by magpie’s address, the route billion-context documents for any client. Pick one of magpie’s models for Zed on the Agents page first, and restart Zed after turning it on or off.

+

Zed has no billion-context plugin, and Hermes’ plugin only catches HTTPS traffic, which magpie’s local address isn’t. Turned on, magpie runs bili start and points the agent’s magpie provider at http://127.0.0.1:8787/bili/ followed by magpie’s address, the route billion-context documents for any client; for Hermes, in every profile that has magpie’s provider. Pick one of magpie’s models for the agent on the Agents page first, and restart it after turning it on or off.

The card shows how many tokens billion-context saved, in its own count: the net savings its dashboard shows, after the rebuilds a fold causes and the summaries’ cost, with how many folds and sessions, over every session it ran on this computer. magpie asks a running billion-context for it (/__bili/overview); when none runs, the card shows the last count it read and when. It shows nothing until billion-context has run for an agent.

What magpie touches

diff --git a/site/public/docs/zh/library.html b/site/public/docs/zh/library.html index 9340aa4a2..3cbed1ed8 100644 --- a/site/public/docs/zh/library.html +++ b/site/public/docs/zh/library.html @@ -237,9 +237,9 @@ magpie library sync # 重新写进各个 Agent

RTK 标签可以按 Agent 打开 RTK:Agent 的 shell 命令经过 RTK 运行,输出被压短以节省 token。magpie 可以帮你安装 RTK;RTK 卸掉后也能关闭。

billion-context

-

billion-context 标签可以按 Agent 打开 billion-context 的插件:它把长会话里较早的对话折叠成模型可以再展开的摘要,让会话始终留在模型的上下文窗口内。支持 Pi、omp、OpenCode、Claude Code 和 Zed,打开后它们的请求仍经过 magpie。magpie 可以帮你安装(npm install -g billion-context --prefix=~/.local),并运行它自己的安装和卸载命令;关闭时会把安装改动过的 Agent 设置恢复原样。在这里打开的 Agent 不能再同时使用 billion-context-pi 或 opencode-acp。

+

billion-context 标签可以按 Agent 打开 billion-context 的插件:它把长会话里较早的对话折叠成模型可以再展开的摘要,让会话始终留在模型的上下文窗口内。支持 Pi、omp、OpenCode、Claude Code、Hermes 和 Zed,打开后它们的请求仍经过 magpie。magpie 可以帮你安装(npm install -g billion-context --prefix=~/.local),并运行它自己的安装和卸载命令;关闭时会把安装改动过的 Agent 设置恢复原样。在这里打开的 Agent 不能再同时使用 billion-context-pi 或 opencode-acp。

对 Claude Code,billion-context 的安装会关掉 Claude Code 自带的自动压缩。magpie 会把它重新打开,这样 billion-context 没有折叠的会话(比如 Claude 桌面版 Code 标签里的会话)会自动压缩,而不是停在 “Prompt is too long”。你自己设置的 DISABLE_AUTO_COMPACT 保持不变。

-

Zed 没有 billion-context 插件。打开后,magpie 会运行 bili start,并把 Zed 里 magpie 提供方的地址改成 http://127.0.0.1:8787/bili/ 加上 magpie 的地址,这是 billion-context 为任意客户端给出的接法。请先在 Agents 页给 Zed 选一个 magpie 的模型;打开或关闭后重启 Zed。

+

Zed 没有 billion-context 插件;Hermes 的插件只接管 HTTPS 流量,而 magpie 的本机地址不是 HTTPS。打开后,magpie 会运行 bili start,并把 Agent 里 magpie 提供方的地址改成 http://127.0.0.1:8787/bili/ 加上 magpie 的地址,这是 billion-context 为任意客户端给出的接法;Hermes 的每个配置了 magpie 提供方的 profile 都会改。请先在 Agents 页给这个 Agent 选一个 magpie 的模型;打开或关闭后重启它。

卡片会显示 billion-context 节省了多少 token,用的是它自己的统计:它的面板上的净节省,已扣除折叠后的重建和摘要的开销,并附上折叠次数和会话数,覆盖这台电脑上它运行过的所有会话。magpie 向正在运行的 billion-context 读取这些数字(/__bili/overview);它没在运行时,卡片显示上次读到的数字和时间。billion-context 为 Agent 运行过之前,这里不显示数字。

magpie 会改什么

diff --git a/site/public/llms-full.txt b/site/public/llms-full.txt index 0c2bf866d..cdb66d4ba 100644 --- a/site/public/llms-full.txt +++ b/site/public/llms-full.txt @@ -2916,11 +2916,11 @@ The RTK tab turns on [RTK](https://www.rtk-ai.app/) per agent: the agent’s she ## billion-context -The billion-context tab turns on [billion-context](https://github.com/ranxianglei/billion-context)’s plugin per agent: it folds older turns of a long session into summaries the model can open again, so the session stays inside the model’s window. It is offered for Pi, omp, OpenCode, Claude Code and Zed, whose requests still go through magpie with it on. magpie can install it for you (`npm install -g billion-context --prefix=~/.local`) and runs its own installer and remover; turning it off puts back what the install changed in the agent’s settings. An agent turned on here can’t also run billion-context-pi or opencode-acp. +The billion-context tab turns on [billion-context](https://github.com/ranxianglei/billion-context)’s plugin per agent: it folds older turns of a long session into summaries the model can open again, so the session stays inside the model’s window. It is offered for Pi, omp, OpenCode, Claude Code, Hermes and Zed, whose requests still go through magpie with it on. magpie can install it for you (`npm install -g billion-context --prefix=~/.local`) and runs its own installer and remover; turning it off puts back what the install changed in the agent’s settings. An agent turned on here can’t also run billion-context-pi or opencode-acp. For Claude Code, billion-context’s install turns Claude Code’s own auto-compaction off. magpie turns it back on, so a session billion-context doesn’t fold, such as one in the Claude desktop app’s Code tab, compacts instead of stopping at “Prompt is too long”. A `DISABLE_AUTO_COMPACT` you set yourself is left as it is. -Zed has no billion-context plugin. Turned on, magpie runs `bili start` and points Zed’s magpie provider at `http://127.0.0.1:8787/bili/` followed by magpie’s address, the route billion-context documents for any client. Pick one of magpie’s models for Zed on the Agents page first, and restart Zed after turning it on or off. +Zed has no billion-context plugin, and Hermes’ plugin only catches HTTPS traffic, which magpie’s local address isn’t. Turned on, magpie runs `bili start` and points the agent’s magpie provider at `http://127.0.0.1:8787/bili/` followed by magpie’s address, the route billion-context documents for any client; for Hermes, in every profile that has magpie’s provider. Pick one of magpie’s models for the agent on the Agents page first, and restart it after turning it on or off. The card shows how many tokens billion-context saved, in its own count: the net savings its dashboard shows, after the rebuilds a fold causes and the summaries’ cost, with how many folds and sessions, over every session it ran on this computer. magpie asks a running billion-context for it (`/__bili/overview`); when none runs, the card shows the last count it read and when. It shows nothing until billion-context has run for an agent.