diff --git a/README.md b/README.md index f4fb50aa8..ef0db3308 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ magpie finds the subscriptions your agents are signed in to by reading their sig
-Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · PenguinHarness · 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 · NewMax · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · 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 · PenguinHarness · 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 · Pencil · OpenPencil · NewMax · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Ante · AstrBot
diff --git a/README.zh-CN.md b/README.zh-CN.md index 53f4b923e..540c40d5f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -79,7 +79,7 @@ magpie 通过读取智能体的登录信息(Claude Code 和 Codex 的文件、
-Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · PenguinHarness · 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 · NewMax · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · 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 · PenguinHarness · 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 · Pencil · OpenPencil · NewMax · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Ante · AstrBot
diff --git a/docs/reference.md b/docs/reference.md index 6ec9a036d..c6122ad2d 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -140,7 +140,7 @@ line; agents connected to magpie lose it when it quits. | ZCode | `~/.zcode/v2/provider_config.json` and `config.json`, under the data folder moved in ZCode's settings (`dataBaseDir`); `~` is `$HOME` when set, on Windows too, as ZCode reads it before `%USERPROFILE%` | provider (magpie's models in ZCode's picker) | | WorkBuddy | `~/.workbuddy/models.json` (`$WORKBUDDY_CONFIG_DIR`) | provider (magpie's models in WorkBuddy's picker) | | WorkBuddy AI | `~/.workbuddy-ai/models.json` (the international build) | provider (magpie's models in WorkBuddy AI's picker) | -| CodeBuddy Code | `~/.codebuddy/models.json` (`$CODEBUDDY_CONFIG_DIR`), `settings.json` | model (magpie's models in its list; the session model) | +| CodeBuddy (CodeBuddy Code CLI, CodeBuddy IDE) | `~/.codebuddy/models.json` (`$CODEBUDDY_CONFIG_DIR` for the CLI), `settings.json` | model (magpie's models in its list; the CLI session's model; the IDE picks from the list) | | Raycast | `~/.config/raycast/ai/providers.yaml` in the user's folder, on Mac and Windows | provider (a `magpie` entry in Raycast AI's Custom Providers, magpie's models in its model picker; Raycast Pro; the user's providers, `tools` and comments kept) | | Kiro Crew | `~/.kiro/crew/config.json` (`$KIROCREW_HOME`; `config.local.json` over it is left alone) | provider, harness (`agent.acp_backend`, and `agent.member_acp_backend` for a harness that can dispatch: an agent connected to magpie, so its models are magpie's: the one Crew is set to is connected along with it when it isn't yet, and disconnected with it again; the user's value is put back on Disconnect) | | OpenPencil | `openpencil/settings.json` in the config folder: `~/Library/Application Support` (macOS), `$XDG_CONFIG_HOME` or `~/.config` (Linux), `%APPDATA%` (Windows) | provider (a `magpie` entry in its `builtin_agents`, magpie's models in its chat's model picker; the user's entries and settings kept; refused while OpenPencil runs, as it writes the file back when it quits) | diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.md index 749291232..f06a49ff4 100644 --- a/docs/subsystems/agent-wiring.md +++ b/docs/subsystems/agent-wiring.md @@ -125,6 +125,7 @@ something else shows up as drift. - 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//` 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. - PenguinHarness's file is `$PENGUIN_HOME` (else `~/.penguin/data`, on Windows too) `//.project_config.toml`, the Project `$PENGUIN_PROJECT_ID` when it is a folder's name (`agentenv.NotPaths`, so a relative name isn't dropped as a path), else `default_project`; a WSL distro's is its `~/.penguin/data/default_project` ([`penguin.go`](../../internal/agent/penguin.go)). Magpie's models are `[[models]]` array entries with `provider = "magpie"`, replaced together where the first one was by `edit.SetTOMLArrayTables`, which leaves the user's entries, the blank lines between them and the file's time alone when nothing changed (Penguin's server reads the file again on every mtime change). `default_model` is spelled `{ provider = …, model_id = … }` as Penguin's own writer (smol-toml) spells it; that writer rewrites the whole file, so Disconnect takes out magpie's provider, entries and a vision model on them rather than putting back a copy. A default naming no entry is refused by Penguin, so entries go in before `default_model` and out after it. PenguinHarness's desktop app (`PenguinHarness.app`, bundle id `com.prismshadow.penguinharness`; on Windows `PenguinHarness\PenguinHarness.exe` under `%LOCALAPPDATA%\Programs` or the folder its installer registered, `desktopApps`) runs its server on the same root and needs no CLI, so with it installed the agent is detected before the app is first opened (`sign`) and never shown as gone; Connect then writes `default_project`, which the app's server adopts without overwriting (rankyurky_80676 on Discord, `TestPenguinDesktopAppDetected`, `TestPenguinDesktopOnlyConnects`). +- CodeBuddy is one row for the CodeBuddy Code CLI and the CodeBuddy IDE (Tencent's VS Code fork; 4.12.2's `CodeBuddy.app`, `com.tencent.codebuddy`, from codebuddy.ai, and `CodeBuddy CN.app`, `com.tencent.codebuddycn`, from codebuddy.cn; both are `desktopApps["codebuddy"]`, the second as one of its `more` builds) ([`codebuddy.go`](../../internal/agent/codebuddy.go)). The IDE's genie extension (`CustomModelsProductProvider`, with `CustomModelsJSON` on in its `product.json`) reads `/.codebuddy/models.json`, the file magpie writes for the CLI, skips an entry without a string `id` and `url`, takes `availableModels` as a whitelist when it has one, and lists each model in its own picker; it ignores `$CODEBUDDY_CONFIG_DIR` and settings.json's `model`. With only the IDE installed the row is detected (`sign`), shows the IDE's version and is never "CLI not found" (bjzhangwn on X; `TestCodeBuddyIDEIsCodeBuddy`, `TestCodeBuddyIDEReadsMagpieModels`). The IDE's Windows and Linux install folders aren't known, so there it is found by `~/.codebuddy` alone (never gone on Windows, as every `desktopApps` agent). - 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, ...; on Windows the registry's PATH plus the Node fnm's default alias names, `%APPDATA%\fnm\aliases\default` or under `FNM_DIR`, which fnm puts on a terminal's PATH from the shell profile and never in the registry, #2685), 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 (`~/./extensions/-*`: `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`). diff --git a/internal/agent/codebuddy.go b/internal/agent/codebuddy.go index 3387abfc5..0ba3ad041 100644 --- a/internal/agent/codebuddy.go +++ b/internal/agent/codebuddy.go @@ -16,6 +16,16 @@ package agent // a session starts on is settings.json's "model" (an id from that list, or // one of CodeBuddy's own), read when a session starts. Its requests say // "CLI/ CodeBuddy/", so they are told apart by their key. +// +// The CodeBuddy IDE (CodeBuddy.app and CodeBuddy CN.app, 4.12.2; see +// desktopApps) reads the same file: its genie extension's +// CustomModelsProductProvider loads ~/.codebuddy/models.json's "models" +// (an entry with no string id or url is skipped) and "availableModels", +// watches the file and syncs its model list on a change, and lists each one +// in its own model picker. It needs no CLI, so one row, CodeBuddy, stands +// for both (bjzhangwn on X: only the CLI was supported, not the IDE). The +// IDE reads /.codebuddy whatever CODEBUDDY_CONFIG_DIR says, and not +// settings.json's "model": its model is picked in the IDE. import ( "encoding/json" @@ -46,10 +56,12 @@ func codebuddyIn(at place) *Agent { d, _ := workbuddyRead(path) return slices.ContainsFunc(d.models, func(raw json.RawMessage) bool { e, ok := workbuddyMine(raw); return ok && e.ID == id }) } + // the IDE alone is CodeBuddy here, its CLI not installed + ide := func() bool { return at.spell == nil && (&Agent{ID: "codebuddy"}).HasApp() } return &Agent{ - ID: "codebuddy", Name: "CodeBuddy Code", Icon: "codebuddy-color", Aliases: []string{"codebuddy-code", "cbc"}, + ID: "codebuddy", Name: "CodeBuddy", Icon: "codebuddy-color", Aliases: []string{"codebuddy-code", "cbc"}, UA: []string{"codebuddy"}, Spelled: prefixed, - Bin: "codebuddy", Dir: dir, Path: path, + Bin: "codebuddy", Dir: dir, Path: path, sign: ide, Sync: func() error { if !workbuddyWired(path) { return nil diff --git a/internal/agent/codebuddy_ide_test.go b/internal/agent/codebuddy_ide_test.go new file mode 100644 index 000000000..bf5810212 --- /dev/null +++ b/internal/agent/codebuddy_ide_test.go @@ -0,0 +1,151 @@ +package agent + +import ( + "encoding/json" + "os" + "path/filepath" + "slices" + "strings" + "testing" +) + +// codebuddyIDEPlist is the CodeBuddy IDE's Info.plist as its 4.12.2 macOS +// arm64 build for codebuddy.cn ships it (CodeBuddy CN.app, from +// www.codebuddy.cn/v2/update?platform=ide-darwin-arm64), cut to its first +// keys, in their order and indentation. codebuddy.ai's build +// (CodeBuddy-darwin-arm64-4.12.2.41207131-425ab70e.zip) differs only in the +// names, CodeBuddy, and its bundle id, com.tencent.codebuddy. +const codebuddyIDEPlist = ` + + + + CFBundleDisplayName + CodeBuddy CN + CFBundleExecutable + Electron + CFBundleIconFile + CodeBuddy CN.icns + CFBundleIdentifier + com.tencent.codebuddycn + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + CodeBuddy CN + CFBundlePackageType + APPL + CFBundleShortVersionString + 4.12.2 + CFBundleVersion + 4.12.2 + + +` + +// codebuddyIntlPlist is the same for codebuddy.ai's CodeBuddy.app. +var codebuddyIntlPlist = strings.NewReplacer("CodeBuddy CN", "CodeBuddy", "com.tencent.codebuddycn", "com.tencent.codebuddy").Replace(codebuddyIDEPlist) + +// bjzhangwn on X: magpie listed CodeBuddy only as its CLI, not the IDE. +// The CodeBuddy IDE, either build, reads the CLI's ~/.codebuddy/models.json +// and needs no CLI, so with only the IDE installed CodeBuddy is listed, +// with the IDE's version and no "CLI not found", and its CLI isn't offered. +func TestCodeBuddyIDEIsCodeBuddy(t *testing.T) { + judgeFor(t, "darwin") + home := codebuddyHome(t) + t.Setenv("PATH", t.TempDir()) // no codebuddy CLI + apps, userApps := t.TempDir(), t.TempDir() + was := appFolders + appFolders = func() []string { return []string{apps, userApps} } + t.Cleanup(func() { appFolders = was }) + a := codebuddy(home) + // a name no machine has: proc.FindTool also looks where users' tools go + a.Bin = "magpie-test-gone-codebuddy" + if a.Name != "CodeBuddy" { + t.Fatalf("the row is %q, not the CLI's and the IDE's both", a.Name) + } + offered := func() bool { + for _, x := range installsOf([]*Agent{a}, "darwin", true) { + if x.ID == "codebuddy" { + return true + } + } + return false + } + + if a.Detected() { + t.Fatal("detected with neither the CLI nor the IDE") + } + + for _, c := range []struct{ dir, name, plist string }{ + {apps, "CodeBuddy CN.app", codebuddyIDEPlist}, + {userApps, "CodeBuddy.app", codebuddyIntlPlist}, + } { + installApp(t, c.dir, c.name, c.plist) + if !a.Detected() || a.CLIMissing() || offered() { + t.Fatalf("%s alone: detected %v, missing %v, offered %v", c.name, a.Detected(), a.CLIMissing(), offered()) + } + if v, ok := a.CLI(); !ok || v.App != "4.12.2" || v.Version != "" { + t.Fatalf("%s's version: %+v %v", c.name, v, ok) + } + os.RemoveAll(filepath.Join(c.dir, c.name)) + } + + // another app under its name is not CodeBuddy's + installApp(t, apps, "CodeBuddy.app", strings.Replace(codebuddyIntlPlist, "com.tencent.codebuddy", "com.example.other", 1)) + if a.Detected() || a.HasApp() { + t.Fatal("another bundle id taken for the CodeBuddy IDE") + } + + // CodeBuddy Code in a WSL distro is not the IDE's + if (&Agent{ID: "codebuddy@wsl:Ubuntu", WSL: "Ubuntu", Bin: "codebuddy"}).HasApp() { + t.Fatal("WSL twin has the IDE") + } +} + +// With only the IDE, connecting writes magpie's models where the IDE reads +// them, in the form its loader takes: genie's CustomModelsProductProvider +// (4.12.2's extensions/genie/out/extension/index.js) reads +// /.codebuddy/models.json's "models", keeps an entry only with a +// non-blank string id and url, and takes "availableModels", when it has +// any, as a whitelist of the models it shows (AvailableModelsFilterProvider; +// none is no filter). +func TestCodeBuddyIDEReadsMagpieModels(t *testing.T) { + home := codebuddyHome(t) + t.Setenv("PATH", t.TempDir()) + apps := t.TempDir() + was := appFolders + appFolders = func() []string { return []string{apps} } + t.Cleanup(func() { appFolders = was }) + installApp(t, apps, "CodeBuddy CN.app", codebuddyIDEPlist) + a := codebuddy(home) + a.Bin = "magpie-test-gone-codebuddy" + if err := a.Field("model").Set("magpie/deepseek/pro"); err != nil { + t.Fatal(err) + } + b, err := os.ReadFile(filepath.Join(home, ".codebuddy", "models.json")) + if err != nil { + t.Fatal(err) + } + // as the IDE's loader reads it + var file struct { + Models []struct { + ID any `json:"id"` + URL any `json:"url"` + } `json:"models"` + AvailableModels []string `json:"availableModels"` + } + if err := json.Unmarshal(b, &file); err != nil { + t.Fatalf("%v\n%s", err, b) + } + var kept []string + for _, m := range file.Models { + id, _ := m.ID.(string) + url, _ := m.URL.(string) + if strings.TrimSpace(id) != "" && strings.TrimSpace(url) != "" { + kept = append(kept, id) + } + } + shown := len(file.AvailableModels) == 0 || slices.Contains(file.AvailableModels, "deepseek/pro") + if len(kept) != 1 || kept[0] != "deepseek/pro" || !shown { + t.Fatalf("the IDE would load %v, show %v:\n%s", kept, file.AvailableModels, b) + } +} diff --git a/internal/agent/desktopapp.go b/internal/agent/desktopapp.go index ca3b7e957..b0e5f1eab 100644 --- a/internal/agent/desktopapp.go +++ b/internal/agent/desktopapp.go @@ -30,7 +30,9 @@ import ( // Store package by its package name and publisher id. guid is the key an // electron-builder installer registers the app under for the current user // (HKCU\Software\'s InstallLocation, and its Uninstall entry's -// DisplayVersion): its installer lets the user pick another folder. +// DisplayVersion): its installer lets the user pick another folder. more +// are the app's other builds, each under a bundle id of its own (CodeBuddy's +// China build beside its international one). type desktopApp struct { id string names []string @@ -38,6 +40,7 @@ type desktopApp struct { store string publisher string guid string + more []desktopApp } var desktopApps = map[string]desktopApp{ @@ -67,6 +70,14 @@ var desktopApps = map[string]desktopApp{ // namespace, as dsh's above is of com.deepseek.dsh. Linux's deb links // /usr/bin/penguin, so Bin finds it there. "penguin": {id: "com.prismshadow.penguinharness", names: []string{"PenguinHarness.app"}, win: filepath.Join("PenguinHarness", "PenguinHarness.exe"), guid: "8bb9acb7-2bdc-596b-9669-7b014ab1c47f"}, + // The CodeBuddy IDE (Tencent's VS Code fork, 4.12.2: CodeBuddy.app, + // com.tencent.codebuddy, from codebuddy.ai; CodeBuddy CN.app, + // com.tencent.codebuddycn, from codebuddy.cn) reads the CodeBuddy Code + // CLI's ~/.codebuddy/models.json for models of one's own (codebuddy.go) + // and needs no CLI. Its Windows install folder isn't known here, so on + // Windows only the rule that a desktop app's folder is never gone holds. + "codebuddy": {id: "com.tencent.codebuddy", names: []string{"CodeBuddy.app"}, + more: []desktopApp{{id: "com.tencent.codebuddycn", names: []string{"CodeBuddy CN.app"}}}}, } // appFolders are where apps are installed; a var so tests can point it @@ -297,7 +308,17 @@ func (a *Agent) AppVersion() string { if !ok || a.WSL != "" { return "" } - return app.version() + for _, b := range app.builds() { + if v := b.version(); v != "" { + return v + } + } + return "" +} + +// builds are app and its other builds (more), the first one first. +func (app desktopApp) builds() []desktopApp { + return append([]desktopApp{app}, app.more...) } // version is the version of app installed here, "" when it isn't or doesn't @@ -379,7 +400,7 @@ func storeAppVersion(packages []string, name, publisher string) string { // %LOCALAPPDATA%\Programs, or in the folder its installer registered. func (a *Agent) HasApp() bool { app, ok := desktopApps[a.ID] - return ok && a.WSL == "" && app.installed() + return ok && a.WSL == "" && slices.ContainsFunc(app.builds(), desktopApp.installed) } // installed reports whether app is installed on this machine (see HasApp). diff --git a/internal/gui/sessions_codebuddy_test.go b/internal/gui/sessions_codebuddy_test.go index 634ff0198..5c7c998ca 100644 --- a/internal/gui/sessions_codebuddy_test.go +++ b/internal/gui/sessions_codebuddy_test.go @@ -68,8 +68,8 @@ func TestCodeBuddySessionsListedUnderTheirName(t *testing.T) { continue } n++ - if s.Name != "CodeBuddy Code" || s.Icon != "codebuddy-color" { - t.Errorf("listed as %q (%s), want CodeBuddy Code (codebuddy-color)", s.Name, s.Icon) + if s.Name != "CodeBuddy" || s.Icon != "codebuddy-color" { + t.Errorf("listed as %q (%s), want CodeBuddy (codebuddy-color)", s.Name, s.Icon) } if !strings.Contains(s.Resume, "codebuddy --resume ") { t.Errorf("resume %q", s.Resume) @@ -89,8 +89,8 @@ func TestCodeBuddySessionsListedUnderTheirName(t *testing.T) { for _, a := range manage.Agents { if a.Agent == "codebuddy" { found = true - if a.Name != "CodeBuddy Code" { - t.Errorf("the Sessions page's agent is %q, want CodeBuddy Code", a.Name) + if a.Name != "CodeBuddy" { + t.Errorf("the Sessions page's agent is %q, want CodeBuddy", a.Name) } if !a.Deletable { t.Error("the Sessions page offers no trash for CodeBuddy Code's sessions") @@ -104,7 +104,7 @@ func TestCodeBuddySessionsListedUnderTheirName(t *testing.T) { Agents map[string]string `json:"agents"` } get("/api/sessions/stats?days=0", &stats) - if stats.Agents["codebuddy"] != "CodeBuddy Code" { + if stats.Agents["codebuddy"] != "CodeBuddy" { t.Errorf("Usage > Sessions' agent strip names it %q: %v", stats.Agents["codebuddy"], stats.Agents) } }