Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

agent: Zoo Code (VS Code) through its autoImportSettingsPath (wani on Discord)

yetone3c38fe5c99df
diff --git a/README.md b/README.md
index bcd0466d0..41e72e1f6 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@ magpie finds the subscriptions your agents are signed in to by reading their sig
<table>
<tr><td>
-Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · OpenPencil · Raycast · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · Ante · AstrBot
+Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · OpenPencil · Raycast · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · Ante · AstrBot
</td></tr>
</table>
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 8235a4c81..56a6ee54e 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -75,7 +75,7 @@ magpie 通过读取智能体的登录信息(Claude Code 和 Codex 的文件、
<table>
<tr><td>
-Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · OpenPencil · Raycast · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · Ante · AstrBot
+Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · OpenPencil · Raycast · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · Ante · AstrBot
</td></tr>
</table>
diff --git a/docs/reference.md b/docs/reference.md
index 13f87b436..018fc58d2 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -109,6 +109,7 @@ line; agents connected to magpie lose it when it quits.
| VS Code (Chat) | `~/Library/Application Support/Code/User/settings.json` + `chatLanguageModels.json` (`~/.config/Code/User` on Linux, `%APPDATA%\Code\User` on Windows) | model (`chat.defaultModel`; a `magpie` Custom Endpoint group, its catalog in Chat's model picker; VS Code 1.122+, no Copilot sign-in or key needed). Each profile's own pair under `User/profiles/<id>/` (listed in `globalStorage/storage.json`) gets the same, unless the profile uses the default's |
| VS Code Insiders (Chat) | the same files under `Code - Insiders/User` in place of `Code/User` | as VS Code, a row of its own; its models send the token `magpie-vscode-insiders`, since its chat's User-Agent is VS Code's |
| VSCodium (Chat) | the same files under `VSCodium/User` in place of `Code/User` | as VS Code, a row of its own; its models send the token `magpie-vscodium`, so Usage counts them as VSCodium; its Chat features must be turned on (`chat.disableAIFeatures=false`, and `defaultChatAgent` plus `trustedExtensionAuthAccess` for GitHub.copilot-chat in its product.json). With the Marketplace's GitHub Copilot Chat 0.48.1, which has no Custom Endpoint provider, the group is written for its OpenAI Compatible provider (`customoai`, the token sent as `x-api-key`), which lists models only while Copilot Chat is signed in to GitHub with a personal Copilot plan |
+| Zoo Code (VS Code) | VS Code's `Code/User/settings.json` (and each profile's): `zoo-code.autoImportSettingsPath` names `globalStorage/zoocodeorganization.zoo-code/settings/magpie-import.json` beside it | model (one provider profile `magpie`, OpenAI Compatible, imported by Zoo Code at start-up) |
| Copilot (JetBrains) | `byok.json` in `~/.config/github-copilot` (`$XDG_CONFIG_HOME/github-copilot` when set, `%USERPROFILE%\AppData\Local\github-copilot` on Windows), the Copilot language server's own file, which Xcode's and Eclipse's Copilot read too | provider (a `magpie` custom endpoint provider beside the user's: every magpie model at the gateway's `/v1/chat/completions`, sent with `magpie-copilot-jetbrains`; a model hidden in Manage Models stays hidden through a sync; off removes magpie's three keys alone). Found by the `github-copilot-intellij` plugin in a JetBrains IDE or Android Studio. Listed after the IDE restarts, and only while Copilot is signed in to GitHub on a plan with Bring Your Own Key (Free, Pro, Pro+; Business and Enterprise when the organisation allows it); the model is picked in Copilot Chat |
| JetBrains Air | `acp.json` in `~/Library/Application Support/JetBrains/Air` (`~/.config/JetBrains/Air` on Linux, `%APPDATA%\JetBrains\Air` on Windows) + `magpie-opencode.json` beside it | model (a `Magpie` ACP agent: OpenCode's `opencode acp` on magpie's provider alone, its models and routing groups in Air's model menu; needs OpenCode installed) |
| Copilot CLI | `~/.copilot/settings.json` | model |
@@ -201,6 +202,23 @@ not normally provide Microsoft's extension. Restart VSCodium, or run
**Developer: Reload Window**, after changing these files. Magpie's models
then appear under the `magpie` custom endpoint group.
+#### Zoo Code
+
+Zoo Code (the VS Code extension `ZooCodeOrganization.zoo-code`) keeps its
+provider profiles in VS Code's encrypted secret storage, which magpie can't
+write. Magpie uses Zoo Code's own `zoo-code.autoImportSettingsPath` setting
+instead: it writes a settings file, `magpie-import.json` in Zoo Code's
+`globalStorage/zoocodeorganization.zoo-code/settings` folder, with one OpenAI Compatible profile named `magpie` (the
+gateway's `/v1`, the key `magpie-zoo-code`, the model picked), and points the
+setting at it in VS Code's `settings.json` and each profile's. Zoo Code imports
+that file each time it starts, so run **Developer: Reload Window** after a
+change. While connected, every start switches Zoo Code back to the `magpie`
+profile. Disconnect puts the setting back as it was and deletes the file, but
+the imported `magpie` profile stays in Zoo Code: pick another profile there, or
+delete it in Zoo Code's settings. Only VS Code (Stable) is wired. Zoo Code for
+JetBrains starts its extension with an empty configuration, so the setting
+can't reach it there.
+
#### Zed-compatible Agent paths
Magpie can use a Zed-compatible fork or installation whose executable or
diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.md
index b73ad1767..97445d127 100644
--- a/docs/subsystems/agent-wiring.md
+++ b/docs/subsystems/agent-wiring.md
@@ -110,6 +110,7 @@ something else shows up as drift.
- A plugin's agent writes each key in place (JSON, YAML or env), the user's comments and other keys kept. An object or array `connect` returns is taken as its JSON text (`agentplug.keys`), so it is written in the order the plugin gave it, not sorted as a Go map would be: Kilo lists its effort variants in key order (#1890, `TestPluggedKeepsPluginOrder`). What each key held before the first write is stashed under `plugin:<id>:<path>`, typed, and its own model or Disconnect puts every key back and takes out the ones that weren't there; the file is never written whole. A `connect` that throws or takes over a second writes nothing and says why. Its gateway key is `magpie-<id>` (`agentKeyAt`), and usage names its requests by that key or by its `ua` words (`usage.PluginAgents`). Its `agent.library` (instructions, `mcp` with `mcpFormat`, skills) gives it the Library's three as well, written by `internal/library` as any agent's are ([library](library.md)); a `mcpFormat` outside `agentplug.MCPFormats`, or an `mcp` without one, keeps the plugin from loading.
- StepCode config root resolves to the parent of an absolute `STEP_CODING_AGENT_DIR` (agent resources directory differs from config root; relative values ignored), or `STEPCODE_CONFIG_DIR` under home when native, defaulting to `~/.stepcode` ([`stepcode.go`](../../internal/agent/stepcode.go)). Project configs override global configs in StepCode, but magpie manages global configuration only (`config.toml` and `models.json`). Detection is strictly directory-only via `agentDir`, avoiding collision with Smallstep's bare `step` command on `PATH`. Wiring performs an atomic two-file edit (`models.json` provider block and `config.toml` top-level defaults/scope) backed by `stash.json`. Custom fields within `providers.magpie` are preserved during sync, and the original provider block is restored on disconnect. A renamed provider's `magpie/<old>/` entries in `enabledModels` follow it, a glob or a thinking level included, and the scope remembered for disconnect follows too; the user's other entries stay. Disconnect restores original defaults, preserves user native changes and custom scope edits, and removes newly created files only when empty.
- MothX's folder is `$MOTHX_DIR` as it is (no `~`), else `%APPDATA%\mothx` on Windows, else `~/.mothx`; a WSL distro's is its `~/.mothx` ([`mothx.go`](../../internal/agent/mothx.go)). Its `thinkingFormat` is `openai` unless the user set one: with it empty, MothX picks Qwen's `enable_thinking`, DeepSeek's `thinking` or Doubao's levels by the model id, which for magpie's ids says nothing of the vendor that serves them. MothX's `/model` and `/statusline … global` rewrite the whole file, so Disconnect after one takes out magpie's provider, the pick and a `providers` left empty (MothX omits an empty one), and keeps the rest.
+- Zoo Code's provider profiles are in VS Code's secret storage, so magpie writes a settings file for it (`magpie-import.json` in Zoo Code's `globalStorage/zoocodeorganization.zoo-code/settings`, not magpie's folder, so a sync keeps an address the user moved it to) and points Zoo Code's `zoo-code.autoImportSettingsPath` at it in VS Code's `settings.json` and each profile's, a user's own path stashed and put back ([`zoocode.go`](../../internal/agent/zoocode.go)). Zoo Code imports it on each start (`importSettingsFromPath`), merging it over the user's profiles and making `magpie` the current one. Disconnect stops the import and deletes the file; the profile already imported stays in Zoo Code, where magpie can't reach it.
- An agent is detected by its config file, its folder, or its command on magpie's PATH (`Detected`). That PATH is the login shell's plus the folders users' tools go in (`proc.UserPath`: `~/.local/bin`, npm's prefixes, the Node nvm's default alias resolves to (the highest installed when it names none), bun, Homebrew, ...), so a CLI a terminal doesn't find can still be found and listed: an npm install under a Node the terminal no longer uses. `/api/agents/cli` then gives where it is (`path`) and `offPath` when the login shell's PATH (`proc.LoginPath`) lacks its folder, and the Agents row says "Not on your terminal's PATH", its tip naming the file (悠悠哥 on Discord: Codex 0.162.1 listed with no codex on PATH and no `~/.codex`). An unknown login PATH says nothing. A folder another tool writes too doesn't count (`dirShared`): Pi's for omp, `~/.copilot` for the Copilot CLI, which GitHub Copilot's JetBrains and VS Code plugins also write, and Qoder's and Qoder CN's, which Qoder's JetBrains plugin fills, and `~/.cursor` for Cursor CLI, which the Cursor editor makes on its own (`TestCursorFolderFromTheEditorIsNotTheCLI`, @G_Z_Y on X); only `cli-config.json` or `cursor-agent` finds Cursor CLI. A config file another tool writes first counts only when `pathOwn` says it is the agent's: Qoder's `settings.json` holding `enabledPlugins` alone is the plugin's (`qoderPluginOnly`; #1495, `TestCopilotFolderFromAnIDEPluginIsNotTheCLI`, `TestQoderSettingsFromAnIDEPluginIsNotTheCLI`). The Qoder app (the desktop app, which runs Qoder's CLI as its agent with the same folder) is found by the `.qoder-app-status.json` it writes there (`sign`, `qoderApp`; #2138, `TestQoderAppIsQoder`), as its `settings.json` can be its bundled plugin's `enabledPlugins` alone. Only the GUI and `daemon install` widen the PATH so; `magpie serve`, `web`, `tui` and the CLI keep the one they were started with, so an agent's CLI (`cliBin`, which its version and `omp`'s max effort are read from) is looked for in those folders (`proc.FindTool`) on every system when it isn't on the PATH, not only on Windows (whqtian on Discord: omp under `~/.bun/bin` on Ubuntu read as no version and offered xhigh in place of max; `TestOmpVersionOffPath`).
- Detection goes by an agent's folder, which an uninstall leaves behind, so an agent found by that alone is shown as gone (`CLIMissing`; #843, #2177, #2173): its CLI is on no PATH and in none of `proc.FindTool`'s folders nor where its own installer puts it (`~/.claude/local`, `~/.codex/packages/standalone`, `~/.opencode/bin`, Hermes' `hermes-agent` checkout), and nothing else that reads the folder is here (`cliHeld`): its desktop app (`HasApp`), an editor's extension (`~/.<editor>/extensions/<id>-*`: `anthropic.claude-code`, `openai.chatgpt`, `saoudrizwan.claude-dev`), Claude.app, OpenCode.app and Goose.app on a Mac, a JetBrains IDE's settings (its AI Assistant's agents and Cline's plugin) or Zed's `external_agents` (its Claude Code and Codex adapters). Where magpie can't tell (every shared folder, `cliShared`, on Windows, whose readers can be a Store app, a portable editor or a PATH only a shell profile sets, #1482, and there too one a desktop app of the agent's reads, `desktopApps`: DeepSeek Harness Desktop installs to any folder and puts its `dsh.cmd` in one the user picks, #2300, #2304; OpenCode and Goose off a Mac, Gemini, an agent detected its own way or by a command name other tools share, one with no install command but `cliOnly`'s Hermes), it is never gone. A gone row in the GUI shows "CLI not found" and none of its settings, nor Apply again; while connected it keeps its switch and Disconnect, and it folds under Not set up once not. Get started never offers it (`connectKind` is "no"). The TUI leaves it out and `magpie ls` says "CLI not found" (`TestCLIMissing*`, `agent-cli-missing.test.cjs`, `getting-started.test.cjs`).
- Tests never touch the real machine. `TestMain` uses `testenv`, which points HOME, USERPROFILE, the XDG folders and APPDATA into a temporary folder, clears `agentenv.Vars` and puts failing stand-ins for keychain tools and agent CLIs on PATH. Agent-specific side effects (Aside, the Zed keychain, Codex's usage check) are also stubbed in `TestMain`.
diff --git a/internal/agent/agents.go b/internal/agent/agents.go
index 6061e4eca..4a4d1e26a 100644
--- a/internal/agent/agents.go
+++ b/internal/agent/agents.go
@@ -111,6 +111,7 @@ func builtins(home, cfg string) []*Agent {
vscode(home, cfg),
vscodeInsidersAgent(home, cfg),
vscodium(home, cfg),
+ zooCode(home, cfg),
copilotJetBrains(home),
air(home, cfg),
copilot(home),
diff --git a/internal/agent/useragent_test.go b/internal/agent/useragent_test.go
index 5089f5764..ae8e1e4a0 100644
--- a/internal/agent/useragent_test.go
+++ b/internal/agent/useragent_test.go
@@ -29,9 +29,10 @@ func TestAgentOf(t *testing.T) {
"atomcode/5.2.1": "atomcode",
"cline ai-sdk/openai-compatible/3.0.37": "cline",
"Vibecoding Client/1.3.104 (darwin; arm64; go1.26.2)": "mothx",
- "minimax-code": "minimax-code", // what magpie's entry sends
- "MiniMaxCode": "minimax-code", // 0.6.8's own (#1605)
- "": "other",
+ "ZooCode/3.90.0": "zoo-code",
+ "minimax-code": "minimax-code", // what magpie's entry sends
+ "MiniMaxCode": "minimax-code", // 0.6.8's own (#1605)
+ "": "other",
}
for ua, want := range cases {
if got := usage.AgentOf(ua); got != want {
diff --git a/internal/agent/vscode.go b/internal/agent/vscode.go
index 755b81a64..ba4b91893 100644
--- a/internal/agent/vscode.go
+++ b/internal/agent/vscode.go
@@ -122,6 +122,15 @@ func vscodeInsidersAgent(home, cfg string) *Agent { return vscodeOf(vscodeInside
func vscodium(home, cfg string) *Agent { return vscodeOf(vscodiumKind, home, cfg) }
func vscodeOf(k vscodeKind, home, cfg string) *Agent {
+ if k.exts != "" {
+ k.extDir = filepath.Join(home, k.exts, "extensions")
+ }
+ return vscodeKindAt(k, vscodeUserDir(k, home, cfg))
+}
+
+// vscodeUserDir is the User folder of the VS Code k, where its settings.json
+// is: its extensions' (Zoo Code's) settings too.
+func vscodeUserDir(k vscodeKind, home, cfg string) string {
switch runtime.GOOS {
case "darwin":
cfg = filepath.Join(home, "Library", "Application Support")
@@ -131,10 +140,7 @@ func vscodeOf(k vscodeKind, home, cfg string) *Agent {
cfg = filepath.Join(home, "AppData", "Roaming")
}
}
- if k.exts != "" {
- k.extDir = filepath.Join(home, k.exts, "extensions")
- }
- return vscodeKindAt(k, filepath.Join(cfg, k.folder, "User"))
+ return filepath.Join(cfg, k.folder, "User")
}
func vscodeAt(dir string) *Agent { return vscodeKindAt(vscodeStable, dir) }
diff --git a/internal/agent/zoocode.go b/internal/agent/zoocode.go
new file mode 100644
index 000000000..90e73db6e
--- /dev/null
+++ b/internal/agent/zoocode.go
@@ -0,0 +1,263 @@
+package agent
+
+// Zoo Code (Zoo-Code-Org/Zoo-Code, the VS Code extension
+// ZooCodeOrganization.zoo-code; a fork of Roo Code) keeps its provider
+// profiles in VS Code's secret storage, encrypted and out of reach. What it
+// does read from a file is the one its zoo-code.autoImportSettingsPath
+// setting names: on every start of the extension (autoImportSettings,
+// src/utils/autoImportSettings.ts, Zoo Code 3.90.0) it imports that file as
+// its own Settings → Import does (importSettingsFromPath,
+// src/core/config/importExport.ts):
+//
+// {"providerProfiles":{"currentApiConfigName":"magpie",
+// "apiConfigs":{"magpie":{"id":"magpie","apiProvider":"openai",
+// "openAiBaseUrl":"http://127.0.0.1:3425/v1","openAiApiKey":"magpie-zoo-code",
+// "openAiModelId":"<model>","openAiCustomModelInfo":{…}}}}}
+//
+// Imported profiles are merged over the user's own, which stay, and the
+// imported currentApiConfigName becomes the profile Zoo Code uses. magpie
+// writes that file in Zoo Code's own folder of VS Code's
+// (zooCodeImportPath) and points the setting at it in VS Code's settings.json, the default profile's and
+// each other profile's (vscodeProfiles), a value of the user's own kept
+// aside and put back by Disconnect. Its OpenAI Compatible provider asks
+// the gateway's Chat Completions under Bearer openAiApiKey, its requests
+// saying "ZooCode/<version>" as their User-Agent.
+//
+// What this route can't do: Zoo Code reads the file only when it starts
+// (the Notice asks for a window reload), and imports it again on each
+// start, so while connected each start puts Zoo Code back on magpie's
+// profile. A profile once imported lives in Zoo Code's secret storage,
+// which magpie can't write, so Disconnect stops the import and leaves the
+// profile "magpie" there for the user to switch from or delete. Which
+// profile the user picks inside Zoo Code magpie can't see either.
+//
+// Zoo Code for JetBrains runs the same extension in its own extension
+// host, which is handed an empty configuration on every start
+// (RPCManager.startInitialize), so the setting can't reach it there, and
+// keeps its secrets in ~/.zoo-code/secrets.json, a store of its own with
+// no lock and no documented format. magpie doesn't write either.
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+
+ "github.com/tidwall/gjson"
+ "github.com/yetone/magpie/internal/catalog"
+ "github.com/yetone/magpie/internal/edit"
+)
+
+// zooImport is the setting naming the file Zoo Code imports at start-up,
+// a key with a dot in it, escaped for edit's key paths.
+const zooImport = `zoo-code\.autoImportSettingsPath`
+
+// zooExtension is Zoo Code's extension id, as the folder it is installed
+// in begins: zoocodeorganization.zoo-code-<version>.
+const zooExtension = "zoocodeorganization.zoo-code"
+
+var noticeZoo = newNotice("Zoo Code reads magpie's profile when it starts — run Developer: Reload Window in VS Code to use this.")
+
+func zooCode(home, cfg string) *Agent {
+ return zooCodeAt(vscodeUserDir(vscodeStable, home, cfg), filepath.Join(home, ".vscode", "extensions"))
+}
+
+// zooCodeImportPath is the file magpie has Zoo Code import, in the VS Code
+// User folder dir: in Zoo Code's own folder there, beside the settings
+// files it keeps itself (globalStorage/<extension>/settings). It is the
+// agent's config, not magpie's: one the user points at a magpie on another
+// machine keeps that address through a sync (kept.away), which skips
+// magpie's own folder.
+func zooCodeImportPath(dir string) string {
+ return filepath.Join(dir, "globalStorage", zooExtension, "settings", "magpie-import.json")
+}
+
+// zooCodeAt is Zoo Code in the VS Code whose User folder is dir and whose
+// extensions are in exts.
+func zooCodeAt(dir, exts string) *Agent {
+ path := filepath.Join(dir, "settings.json")
+ file := zooCodeImportPath(dir)
+ key := func(p string) string { return "zoo-code:" + p + ":import" }
+ getAt := func(p string) string { v, _ := edit.GetJSON(p, zooImport); return v }
+ ours := func(p string) bool { return getAt(p) == file }
+ // profile is magpie's profile in the file, "" when there's none
+ profile := func() string {
+ b, err := os.ReadFile(file)
+ if err != nil || !gjson.ValidBytes(b) {
+ return ""
+ }
+ return gjson.GetBytes(b, "providerProfiles.apiConfigs."+magpieID).Raw
+ }
+ joined := func() bool { return ours(path) && profile() != "" }
+ model := func() string {
+ if !joined() {
+ return ""
+ }
+ if id := gjson.Get(profile(), "openAiModelId").String(); id != "" {
+ return magpieID + "/" + id
+ }
+ return ""
+ }
+ // restore puts back the setting a settings.json had before magpie's
+ restore := func(p string) error {
+ if was := unstash(key(p)); was != "" {
+ return edit.SetJSON(p, edit.KV{Path: zooImport, Value: was})
+ }
+ return edit.DelJSON(p, zooImport)
+ }
+ // each runs fn on the default's settings.json and each profile's, put
+ // back as they were if it fails
+ each := func(fn func(p string) error) error {
+ s, _ := vscodeProfiles(dir)
+ all := append([]string{path}, s...)
+ return edit.Atomically(func() error {
+ for _, p := range all {
+ if err := fn(p); err != nil {
+ return err
+ }
+ }
+ return nil
+ }, append(all, file)...)
+ }
+ write := func(ref string) error {
+ return edit.SetJSON(file, edit.KV{Path: "providerProfiles", Value: zooCodeProfiles(ref)})
+ }
+ off := func() error {
+ err := each(func(p string) error {
+ if ours(p) {
+ if err := restore(p); err != nil {
+ return err
+ }
+ }
+ forget(key(p))
+ return nil
+ })
+ if err != nil {
+ return err
+ }
+ if err := os.Remove(file); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ return nil
+ }
+ return atomic(&Agent{
+ ID: "zoo-code", Name: "Zoo Code", Icon: "zoo-code", Spelled: prefixed,
+ // its requests say "ZooCode/<version>" (DEFAULT_HEADERS,
+ // src/api/providers/constants.ts): usage names them by the word
+ // before the slash
+ Aliases: []string{"zoocode", "zoo"},
+ Dir: dir, Path: path,
+ detect: func() bool { return !Taken(dir) && zooCodeInstalled(exts) },
+ Notice: func() string {
+ if joined() {
+ return noticeZoo.String()
+ }
+ return ""
+ },
+ Unwire: off,
+ // the file is read again at every start: it follows the catalog and
+ // the key, and a profile made since is pointed at it too
+ Sync: func() error {
+ if !joined() {
+ return nil
+ }
+ ref := gjson.Get(profile(), "openAiModelId").String()
+ if cur, ok := edit.GetJSON(file, "providerProfiles"); !ok || !sameJSON(cur, zooCodeProfiles(ref)) {
+ if err := write(ref); err != nil {
+ return err
+ }
+ }
+ return each(func(p string) error {
+ if ours(p) {
+ return nil
+ }
+ stash(map[string]string{key(p): getAt(p)})
+ return edit.SetJSON(p, edit.KV{Path: zooImport, Value: file})
+ })
+ },
+ Check: func() string {
+ if !joined() {
+ return ""
+ }
+ return wiringOff("Zoo Code", file, func(k string) (string, bool) {
+ r := gjson.Get(profile(), k)
+ return r.String(), r.Exists()
+ }, "openAiBaseUrl", gatewayV1(), "openAiApiKey", agentKey("zoo-code"))
+ },
+ Fields: []Field{{
+ Key: "model", Label: "model", Get: model,
+ Set: func(v string) error {
+ ref, ok := strings.CutPrefix(v, magpieID+"/")
+ if !ok || !isMagpie(ref) {
+ // Zoo Code's own profiles are in its secret storage:
+ // magpie stops the import and leaves them to it
+ return off()
+ }
+ if err := write(ref); err != nil {
+ return err
+ }
+ return each(func(p string) error {
+ if !ours(p) {
+ stash(map[string]string{key(p): getAt(p)})
+ }
+ return edit.SetJSON(p, edit.KV{Path: zooImport, Value: file})
+ })
+ },
+ Options: func(map[string]string) []Option {
+ return viaMagpie("zoo-code", magpieID+"/")
+ },
+ }},
+ }, path, file, stashPath())
+}
+
+// zooCodeInstalled reports whether Zoo Code is in an extensions folder.
+func zooCodeInstalled(exts string) bool {
+ xs, err := os.ReadDir(exts)
+ if err != nil {
+ return false
+ }
+ for _, x := range xs {
+ if x.IsDir() && strings.HasPrefix(strings.ToLower(x.Name()), zooExtension+"-") {
+ return true
+ }
+ }
+ return false
+}
+
+// zooCodeProfiles is magpie as Zoo Code's provider profiles to import: one
+// profile, "magpie", on the gateway's Chat Completions with model ref, the
+// one Zoo Code uses after the import.
+func zooCodeProfiles(ref string) map[string]any {
+ p := map[string]any{
+ "id": magpieID, "apiProvider": "openai",
+ "openAiBaseUrl": gatewayV1(), "openAiApiKey": agentKey("zoo-code"),
+ "openAiModelId": ref, "openAiStreamingEnabled": true,
+ }
+ for _, m := range magpieModels("zoo-code") {
+ if m.ID == ref {
+ p["openAiCustomModelInfo"] = zooCodeModelInfo(m)
+ break
+ }
+ }
+ return map[string]any{
+ "currentApiConfigName": magpieID,
+ "apiConfigs": map[string]any{magpieID: p},
+ }
+}
+
+// zooCodeModelInfo is a model of magpie's as Zoo Code's modelInfo: the
+// window it trims a conversation to, what a reply may take, and whether it
+// sends images. contextWindow and supportsPromptCache are the two its
+// schema requires.
+func zooCodeModelInfo(m catalog.Model) map[string]any {
+ info := map[string]any{"supportsPromptCache": false, "supportsImages": m.Images}
+ // Zoo Code's own default for a model it isn't told about
+ // (openAiModelInfoSaneDefaults)
+ info["contextWindow"] = 128_000
+ if m.Context > 0 {
+ info["contextWindow"] = m.Context
+ }
+ if m.Output > 0 {
+ info["maxTokens"] = maxTokens(m)
+ }
+ return info
+}
diff --git a/internal/agent/zoocode_test.go b/internal/agent/zoocode_test.go
new file mode 100644
index 000000000..c3a0bfc19
--- /dev/null
+++ b/internal/agent/zoocode_test.go
@@ -0,0 +1,192 @@
+package agent
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "github.com/tidwall/gjson"
+ "github.com/yetone/magpie/internal/edit"
+ "github.com/yetone/magpie/internal/provider"
+ "github.com/yetone/magpie/internal/usage"
+)
+
+// zooCodeHere is Zoo Code in a VS Code User folder under home, the
+// extension installed as the Marketplace installs it.
+func zooCodeHere(t *testing.T, home string) (*Agent, string) {
+ t.Helper()
+ dir := filepath.Join(home, "vscode", "User")
+ exts := filepath.Join(home, ".vscode", "extensions")
+ writeFile(t, filepath.Join(exts, "zoocodeorganization.zoo-code-3.90.0", "package.json"), `{"name":"zoo-code","version":"3.90.0"}`)
+ return zooCodeAt(dir, exts), dir
+}
+
+// switched on, magpie's file is what zoo-code.autoImportSettingsPath names,
+// in the shape Zoo Code's importSettingsFromPath takes, its profile on the
+// gateway with Zoo Code's key; switched off, settings.json is as it was,
+// the user's own import path back, and magpie's file gone
+func TestZooCode(t *testing.T) {
+ home := syncHome(t)
+ a, _ := zooCodeHere(t, home)
+ settings := `{
+ // my editor
+ "editor.fontSize": 14,
+ "zoo-code.autoImportSettingsPath": "~/zoo-team.json",
+}
+`
+ writeFile(t, a.Path, settings)
+ f := a.Field("model")
+ if !a.Detected() || a.Wired() || f.Get() != "" || a.Notice() != "" {
+ t.Fatalf("before: %v %v %q", a.Detected(), a.Wired(), f.Get())
+ }
+ if err := a.Connect(); err != nil {
+ t.Fatal(err)
+ }
+ file := zooCodeImportPath(filepath.Dir(a.Path))
+ if f.Get() != "magpie/relay/glm-4.6" || !a.Wired() || a.Check() != "" || a.Notice() == "" {
+ t.Fatalf("connected: %q %v %q %q", f.Get(), a.Wired(), a.Check(), a.Notice())
+ }
+ if v, _ := edit.GetJSON(a.Path, zooImport); v != file {
+ t.Fatalf("import path %q, want %q\n%s", v, file, readFile(a.Path))
+ }
+ for _, keep := range []string{"// my editor", `"editor.fontSize": 14`} {
+ if !strings.Contains(readFile(a.Path), keep) {
+ t.Fatalf("settings lost %q:\n%s", keep, readFile(a.Path))
+ }
+ }
+ b := readFile(file)
+ if !gjson.Valid(b) {
+ t.Fatalf("not JSON:\n%s", b)
+ }
+ // what providerProfilesSchema and the openai provider's schema need:
+ // a current profile that is one of apiConfigs, and a modelInfo with
+ // contextWindow and supportsPromptCache
+ for k, want := range map[string]string{
+ "providerProfiles.currentApiConfigName": "magpie",
+ "providerProfiles.apiConfigs.magpie.apiProvider": "openai",
+ "providerProfiles.apiConfigs.magpie.openAiBaseUrl": gatewayV1(),
+ "providerProfiles.apiConfigs.magpie.openAiApiKey": agentKey("zoo-code"),
+ "providerProfiles.apiConfigs.magpie.openAiModelId": "relay/glm-4.6",
+ "providerProfiles.apiConfigs.magpie.openAiCustomModelInfo.contextWindow": "204800",
+ "providerProfiles.apiConfigs.magpie.openAiCustomModelInfo.supportsPromptCache": "false",
+ } {
+ if got := gjson.Get(b, k).String(); got != want {
+ t.Errorf("%s = %q, want %q", k, got, want)
+ }
+ }
+ if gjson.Get(b, "globalSettings").Exists() {
+ t.Fatalf("magpie's import sets Zoo Code's own settings:\n%s", b)
+ }
+ // the catalog gives glm-4.6 no output limit: Zoo Code's own default
+ // stands, not a 0 that would cap every reply
+ if r := gjson.Get(b, "providerProfiles.apiConfigs.magpie.openAiCustomModelInfo.maxTokens"); r.Exists() {
+ t.Fatalf("maxTokens %s with no output limit known", r.Raw)
+ }
+
+ // another model: the file follows, the setting stays magpie's
+ if err := provider.Save(provider.Provider{ID: "relay", Name: "Relay", Key: "k", Chat: "http://127.0.0.1:1/v1", Models: []string{"glm-4.6", "other"}}); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Apply("model", "magpie/relay/other"); err != nil {
+ t.Fatal(err)
+ }
+ if f.Get() != "magpie/relay/other" {
+ t.Fatalf("other: %q\n%s", f.Get(), readFile(file))
+ }
+
+ // the key in the file written over: Sync writes it again, as Zoo Code
+ // reads the file on each start
+ writeFile(t, file, strings.ReplaceAll(readFile(file), agentKey("zoo-code"), "stale"))
+ if c := a.Check(); !strings.Contains(c, "magpie-import.json") {
+ t.Fatalf("check: %q", c)
+ }
+ if err := a.Sync(); err != nil {
+ t.Fatal(err)
+ }
+ if c := a.Check(); c != "" {
+ t.Fatalf("synced, check: %q\n%s", c, readFile(file))
+ }
+
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if readFile(a.Path) != settings || a.Wired() || f.Get() != "" {
+ t.Fatalf("disconnected: %v %q\n%s", a.Wired(), f.Get(), readFile(a.Path))
+ }
+ if _, err := os.Stat(file); !os.IsNotExist(err) {
+ t.Fatalf("magpie's import file left: %v", err)
+ }
+}
+
+// with no settings.json: made, and emptied of magpie's setting again
+func TestZooCodeFresh(t *testing.T) {
+ home := syncHome(t)
+ a, _ := zooCodeHere(t, home)
+ if err := a.Connect(); err != nil {
+ t.Fatal(err)
+ }
+ if a.Field("model").Get() != "magpie/relay/glm-4.6" || a.Check() != "" {
+ t.Fatalf("fresh: %q\n%s", a.Field("model").Get(), readFile(a.Path))
+ }
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if v, ok := edit.GetJSON(a.Path, zooImport); ok || a.Wired() {
+ t.Fatalf("disconnected: %q\n%s", v, readFile(a.Path))
+ }
+}
+
+// a VS Code profile reads its own settings.json: the setting goes in each
+// profile's, one made later is given it on Sync, and each is put back
+func TestZooCodeProfiles(t *testing.T) {
+ home := syncHome(t)
+ a, dir := zooCodeHere(t, home)
+ work := filepath.Join(dir, "profiles", "-5f1c2a")
+ writeFile(t, filepath.Join(dir, "globalStorage", "storage.json"), `{"userDataProfiles": [{"location": "-5f1c2a", "name": "Work"}]}`)
+ workSettings := "{\n\t// work\n\t\"zoo-code.autoImportSettingsPath\": \"/srv/zoo.json\"\n}\n"
+ writeFile(t, filepath.Join(work, "settings.json"), workSettings)
+ if err := a.Connect(); err != nil {
+ t.Fatal(err)
+ }
+ if v, _ := edit.GetJSON(filepath.Join(work, "settings.json"), zooImport); v != zooCodeImportPath(dir) {
+ t.Fatalf("work profile's import path %q", v)
+ }
+ writeFile(t, filepath.Join(dir, "globalStorage", "storage.json"), `{"userDataProfiles": [{"location": "-5f1c2a", "name": "Work"}, {"location": "new1", "name": "New"}]}`)
+ writeFile(t, filepath.Join(dir, "profiles", "new1", "keybindings.json"), "[]\n")
+ if err := a.Sync(); err != nil {
+ t.Fatal(err)
+ }
+ newSettings := filepath.Join(dir, "profiles", "new1", "settings.json")
+ if v, _ := edit.GetJSON(newSettings, zooImport); v != zooCodeImportPath(dir) {
+ t.Fatalf("new profile's import path %q", v)
+ }
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if readFile(filepath.Join(work, "settings.json")) != workSettings {
+ t.Fatalf("work profile not as it was:\n%s", readFile(filepath.Join(work, "settings.json")))
+ }
+ if _, ok := edit.GetJSON(newSettings, zooImport); ok {
+ t.Fatalf("new profile kept magpie's import path:\n%s", readFile(newSettings))
+ }
+}
+
+// listed only with the extension installed; its requests name it
+func TestZooCodeDetectAndUA(t *testing.T) {
+ home := syncHome(t)
+ dir := filepath.Join(home, "vscode", "User")
+ writeFile(t, filepath.Join(dir, "settings.json"), "{}\n")
+ exts := filepath.Join(home, ".vscode", "extensions")
+ writeFile(t, filepath.Join(exts, "rooveterinaryinc.roo-cline-3.30.0", "package.json"), "{}")
+ if zooCodeAt(dir, exts).Detected() {
+ t.Fatal("detected without Zoo Code installed")
+ }
+ writeFile(t, filepath.Join(exts, "zoocodeorganization.zoo-code-3.90.0", "package.json"), "{}")
+ if !zooCodeAt(dir, exts).Detected() {
+ t.Fatal("not detected with Zoo Code installed")
+ }
+ if got := usage.AgentOf("ZooCode/3.90.0"); got != "zoo-code" {
+ t.Fatalf("AgentOf = %q", got)
+ }
+}
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 48cb7061c..e6c3c0851 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -293,7 +293,7 @@ function maskSpan(src, failed) {
if (failed) load.then((ok) => ok || failed());
return m;
}
-const pngIcons = new Set(["crush", "zcode", "alma", "hanako", "cindy", "lody", "typesafe", "atomcode", "snow", "mlx-serve", "mothx"]);
+const pngIcons = new Set(["crush", "zcode", "alma", "hanako", "cindy", "lody", "typesafe", "atomcode", "snow", "mlx-serve", "mothx", "zoo-code"]);
function icon(name) {
const kept = keptIcons?.get(name || "")?.shift();
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 0ebea1d46..9288950c2 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -3682,6 +3682,7 @@ const I18N = {
"It reads its settings at start-up — restart open Command Code sessions to use this.": "它启动时读取设置,需重启已打开的 Command Code 会话才会生效。",
"Kimi Code reads its settings at start-up — restart open kimi sessions to use this.": "Kimi Code 启动时读取设置,需重启已打开的 kimi 会话才会生效。",
"MothX reads its settings at start-up — restart open mothx sessions to use this.": "MothX 启动时读取设置,需重启已打开的 mothx 会话才会生效。",
+ "Zoo Code reads magpie's profile when it starts — run Developer: Reload Window in VS Code to use this.": "Zoo Code 启动时读取 magpie 的配置档,需在 VS Code 中运行 Developer: Reload Window 才会生效。",
"jcode reads its settings at start-up — restart open jcode sessions to use this.": "jcode 启动时读取设置,需重启已打开的 jcode 会话才会生效。",
"Magpie is a custom provider in Grok App's Settings › Account. A chat can pick magpie's models in its model picker, and Grok App stays on its current route until you press Use on magpie there.": "Magpie 是 Grok App「设置 › 账户」里的一个自定义供应商。对话可以在模型选择器里选 magpie 的模型;在你于该处对 magpie 点「使用」之前,Grok App 保持当前路线。",
"MiniMax Code reads its settings at start-up — restart open mcode sessions to use this.": "MiniMax Code 启动时读取设置,需重启已打开的 mcode 会话才会生效。",
@@ -7502,6 +7503,7 @@ const I18N = {
"It reads its settings at start-up — restart open Command Code sessions to use this.": "它啟動時讀取設定,需重啟已打開的 Command Code 會話才會生效。",
"Kimi Code reads its settings at start-up — restart open kimi sessions to use this.": "Kimi Code 啟動時讀取設定,需重啟已打開的 kimi 會話才會生效。",
"MothX reads its settings at start-up — restart open mothx sessions to use this.": "MothX 啟動時讀取設定,需重啟已打開的 mothx 會話才會生效。",
+ "Zoo Code reads magpie's profile when it starts — run Developer: Reload Window in VS Code to use this.": "Zoo Code 啟動時讀取 magpie 的設定檔,需在 VS Code 中執行 Developer: Reload Window 才會生效。",
"jcode reads its settings at start-up — restart open jcode sessions to use this.": "jcode 啟動時讀取設定,需重啟已打開的 jcode 會話才會生效。",
"Magpie is a custom provider in Grok App's Settings › Account. A chat can pick magpie's models in its model picker, and Grok App stays on its current route until you press Use on magpie there.": "Magpie 是 Grok App「設定 › 帳戶」裡的一個自訂供應商。對話可以在模型選擇器裡選 magpie 的模型;在你於該處對 magpie 按「使用」之前,Grok App 維持目前的路線。",
"MiniMax Code reads its settings at start-up — restart open mcode sessions to use this.": "MiniMax Code 啟動時讀取設定,需重啟已打開的 mcode 會話才會生效。",
@@ -11324,6 +11326,7 @@ const I18N = {
"It reads its settings at start-up — restart open Command Code sessions to use this.": "起動時に設定を読み込むため、反映するには開いている Command Code セッションを再起動してください。",
"Kimi Code reads its settings at start-up — restart open kimi sessions to use this.": "Kimi Code は起動時に設定を読み込みます。反映するには開いている kimi セッションを再起動してください。",
"MothX reads its settings at start-up — restart open mothx sessions to use this.": "MothX は起動時に設定を読み込みます。反映するには開いている mothx セッションを再起動してください。",
+ "Zoo Code reads magpie's profile when it starts — run Developer: Reload Window in VS Code to use this.": "Zoo Code は起動時に magpie のプロファイルを読み込みます。反映するには VS Code で Developer: Reload Window を実行してください。",
"jcode reads its settings at start-up — restart open jcode sessions to use this.": "jcode は起動時に設定を読み込みます。反映するには開いている jcode セッションを再起動してください。",
"Magpie is a custom provider in Grok App's Settings › Account. A chat can pick magpie's models in its model picker, and Grok App stays on its current route until you press Use on magpie there.": "Magpie は Grok App の「設定 › アカウント」にあるカスタムプロバイダーです。チャットはモデル選択から magpie のモデルを選べます。そこで magpie の「使う」を押すまで、Grok App は今のルートのままです。",
"MiniMax Code reads its settings at start-up — restart open mcode sessions to use this.": "MiniMax Code は起動時に設定を読み込みます。反映するには開いている mcode セッションを再起動してください。",
@@ -15146,6 +15149,7 @@ const I18N = {
"It reads its settings at start-up — restart open Command Code sessions to use this.": "Es liest seine Einstellungen beim Start – offene Command-Code-Sitzungen neu starten, damit es gilt.",
"Kimi Code reads its settings at start-up — restart open kimi sessions to use this.": "Kimi Code liest seine Einstellungen beim Start – offene kimi-Sitzungen neu starten, damit es gilt.",
"MothX reads its settings at start-up — restart open mothx sessions to use this.": "MothX liest seine Einstellungen beim Start – offene mothx-Sitzungen neu starten, damit es gilt.",
+ "Zoo Code reads magpie's profile when it starts — run Developer: Reload Window in VS Code to use this.": "Zoo Code liest das Profil von magpie beim Start – in VS Code Developer: Reload Window ausführen, damit es gilt.",
"jcode reads its settings at start-up — restart open jcode sessions to use this.": "jcode liest seine Einstellungen beim Start – offene jcode-Sitzungen neu starten, damit es gilt.",
"Magpie is a custom provider in Grok App's Settings › Account. A chat can pick magpie's models in its model picker, and Grok App stays on its current route until you press Use on magpie there.": "Magpie ist ein eigener Anbieter unter Einstellungen › Konto in Grok App. Ein Chat kann magpies Modelle in seiner Modellauswahl wählen, und Grok App bleibt auf seiner aktuellen Route, bis du dort bei magpie auf Verwenden drückst.",
"MiniMax Code reads its settings at start-up — restart open mcode sessions to use this.": "MiniMax Code liest seine Einstellungen beim Start – offene mcode-Sitzungen neu starten, damit es gilt.",
@@ -15335,6 +15339,7 @@ const NOTICES = [
"It reads its settings at start-up — restart open Command Code sessions to use this.",
"Kimi Code reads its settings at start-up — restart open kimi sessions to use this.",
"MothX reads its settings at start-up — restart open mothx sessions to use this.",
+ "Zoo Code reads magpie's profile when it starts — run Developer: Reload Window in VS Code to use this.",
"jcode reads its settings at start-up — restart open jcode sessions to use this.",
"Magpie is a custom provider in Grok App's Settings › Account. A chat can pick magpie's models in its model picker, and Grok App stays on its current route until you press Use on magpie there.",
"MiniMax Code reads its settings at start-up — restart open mcode sessions to use this.",
diff --git a/internal/gui/assets/icons/zoo-code.png b/internal/gui/assets/icons/zoo-code.png
new file mode 100644
index 000000000..e6715973b
Binary files /dev/null and b/internal/gui/assets/icons/zoo-code.png differ