Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
agent: PenguinHarness's desktop app is detected without its CLI (rankyurky_80676)
yetone2f00fa64209b
diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.mdindex 9349aeac2..e1d04a8f1 100644--- a/docs/subsystems/agent-wiring.md+++ b/docs/subsystems/agent-wiring.md@@ -121,7 +121,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. Turning the plugin off or removing it (`provider.SetPluginOff`, `provider.RemovePlugin`, from the CLI or the Plugins page) first disconnects its agent as `magpie <agent> default` does (`provider.PluginAgentGoing`, set to `agent.UnwirePlugin` in [`plugged_gone.go`](../../internal/agent/plugged_gone.go)), since without the plugin magpie no longer knows the agent (#3810); a plugin already off is read from its module as it is, and one whose module is gone puts back each file whose stash names its spec. A failure keeps the plugin as it was. On again, the agent stays as the user had it, and connecting it puts back the model it was on (Disconnect's `.reconnect`). The stash records the plugin's spec and the file's format, so `magpie <id> default` for the agent of a plugin deleted on disk puts the file back from the stash alone (`agent.RestoreGone`; an older stash's format is its file's name, `agentplug.FormatOf`); a file that no longer holds the gateway's key is the user's and left alone, and one that can't be read is put back over by nothing; with the plugin only switched off, it says the agent is off magpie already, not "unknown agent" (`TestPluginOffPutsItsAgentBack`, `TestRestoreGoneAgent`, `TestGoneAgentDefault`).- 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.-- PenguinHarness's file is `$PENGUIN_HOME` (else `~/.penguin/data`, on Windows too) `/<project>/.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 file is `$PENGUIN_HOME` (else `~/.penguin/data`, on Windows too) `/<project>/.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`).- 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 (`~/.<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`).diff --git a/internal/agent/desktopapp.go b/internal/agent/desktopapp.goindex 96a56eaa2..ca3b7e957 100644--- a/internal/agent/desktopapp.go+++ b/internal/agent/desktopapp.go@@ -53,6 +53,20 @@ var desktopApps = map[string]desktopApp{// registers it under HKCU\Software\1bf39983-… (#2279, read from// 0.2.0-rc.2's dsh-latest-windows-x64.exe installer script)."dsh": {id: "com.deepseek.dsh", names: []string{"DeepSeek Harness.app"}, win: filepath.Join("DeepSeek Harness", "DeepSeek Harness.exe"), guid: "1bf39983-50d0-5fe0-9ef4-cece76f67c5e"},+ // PenguinHarness's desktop app (packages/desktop's electron-builder.yml,+ // desktop 0.2.17: appId com.prismshadow.penguinharness, productName+ // PenguinHarness) runs its own server on the CLI's data root,+ // ~/.penguin/data (app-identity.ts: "the release profile shares the+ // CLI's root by design"), and needs no CLI: it links+ // /usr/local/bin/penguin only when the user lets it (cli-install.ts),+ // and with no such link magpie took ~/.penguin for a leftover+ // (rankyurky_80676 on Discord: the app not detected). On Windows its+ // assisted NSIS installer puts it under %LOCALAPPDATA%\Programs by+ // default and lets the folder be changed; guid is the key+ // electron-builder registers it under, the UUID v5 of the appId in its+ // 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"},}// appFolders are where apps are installed; a var so tests can point itdiff --git a/internal/agent/penguin.go b/internal/agent/penguin.goindex d9b74859e..2c80d6787 100644--- a/internal/agent/penguin.go+++ b/internal/agent/penguin.go@@ -191,6 +191,9 @@ func penguinIn(at place) *Agent {ID: "penguin", Name: "PenguinHarness", Icon: "penguin-color", Bin: "penguin",Aliases: []string{"penguin-harness", "penguinharness"}, Spelled: prefixed,Dir: filepath.Dir(root), Path: path,+ // the desktop app, on this machine (a distro has none): installed+ // and not opened yet, it has made no ~/.penguin+ sign: func() bool { return at.spell == nil && (&Agent{ID: "penguin"}).HasApp() },Sync: func() error {t, err := edit.GetTOMLTable(path, providerTable)if err != nil || t == nil {diff --git a/internal/agent/penguin_desktop_test.go b/internal/agent/penguin_desktop_test.gonew file mode 100644index 000000000..6a106737b--- /dev/null+++ b/internal/agent/penguin_desktop_test.go@@ -0,0 +1,172 @@+package agent++import (+ "os"+ "path/filepath"+ "strings"+ "testing"+)++// penguinAppPlist is the Info.plist electron-builder writes for+// PenguinHarness's desktop app, from its packages/desktop/electron-builder.yml+// (appId com.prismshadow.penguinharness, productName PenguinHarness) and+// package.json (0.2.17), cut to the keys around the ones read. Not read+// from a downloaded build.+const penguinAppPlist = `<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+ <dict>+ <key>CFBundleDisplayName</key>+ <string>PenguinHarness</string>+ <key>CFBundleExecutable</key>+ <string>PenguinHarness</string>+ <key>CFBundleIdentifier</key>+ <string>com.prismshadow.penguinharness</string>+ <key>CFBundleName</key>+ <string>PenguinHarness</string>+ <key>CFBundlePackageType</key>+ <string>APPL</string>+ <key>CFBundleShortVersionString</key>+ <string>0.2.17</string>+ <key>CFBundleVersion</key>+ <string>0.2.17</string>+ </dict>+</plist>+`++// rankyurky_80676 on Discord (2026-10-27): PenguinHarness's desktop app on+// a Mac, and magpie didn't detect it. The app needs no penguin CLI (it+// links one only when the user lets it), so ~/.penguin with no CLI was+// taken for a leftover, and an app not opened yet had no ~/.penguin at+// all. With the app installed it is listed, its version shown, and no CLI+// install offered.+func TestPenguinDesktopAppDetected(t *testing.T) {+ judgeFor(t, "darwin")+ home := t.TempDir()+ t.Setenv("HOME", home)+ t.Setenv("USERPROFILE", home)+ t.Setenv("PENGUIN_HOME", "")+ t.Setenv("PATH", t.TempDir()) // no penguin CLI+ apps, userApps := t.TempDir(), t.TempDir()+ was := appFolders+ appFolders = func() []string { return []string{apps, userApps} }+ t.Cleanup(func() { appFolders = was })+ a := penguin(home)+ // a name no machine has: proc.FindTool also looks where users' tools go+ a.Bin = "magpie-test-gone-penguin"+ offered := func() bool {+ for _, x := range installsOf([]*Agent{a}, "darwin", true) {+ if x.ID == "penguin" {+ return true+ }+ }+ return false+ }++ // nothing here+ if a.Detected() {+ t.Fatal("detected with nothing installed")+ }+ // the app in /Applications, never opened: no ~/.penguin yet+ installApp(t, apps, "PenguinHarness.app", penguinAppPlist)+ if !a.Detected() || a.CLIMissing() || offered() {+ t.Fatalf("app only: detected %v, missing %v, offered %v", a.Detected(), a.CLIMissing(), offered())+ }+ if c, ok := a.CLI(); !ok || c.App != "0.2.17" || c.Version != "" {+ t.Fatalf("the desktop app's version: %+v %v", c, ok)+ }+ // opened: its server made ~/.penguin/data, and that is no leftover+ if err := os.MkdirAll(filepath.Join(home, ".penguin", "data", "default_project"), 0o700); err != nil {+ t.Fatal(err)+ }+ if !a.Detected() || a.CLIMissing() || offered() {+ t.Fatalf("app opened: detected %v, missing %v, offered %v", a.Detected(), a.CLIMissing(), offered())+ }++ // another app of that name is not Penguin's: ~/.penguin without its+ // CLI is said again (#843)+ os.RemoveAll(filepath.Join(apps, "PenguinHarness.app"))+ installApp(t, userApps, "PenguinHarness.app", strings.Replace(penguinAppPlist, "com.prismshadow.penguinharness", "com.example.other", 1))+ if !a.CLIMissing() || !offered() {+ t.Fatalf("another bundle id: missing %v, offered %v", a.CLIMissing(), offered())+ }+ os.RemoveAll(filepath.Join(userApps, "PenguinHarness.app"))+ // in ~/Applications+ installApp(t, userApps, "PenguinHarness.app", penguinAppPlist)+ if a.CLIMissing() {+ t.Fatal("the app in ~/Applications not found")+ }+ os.RemoveAll(filepath.Join(userApps, "PenguinHarness.app"))++ // Windows: the per-user installer's PenguinHarness.exe+ exe := filepath.Join(apps, "PenguinHarness", "PenguinHarness.exe")+ if err := os.MkdirAll(filepath.Dir(exe), 0o755); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(exe, []byte("MZ"), 0o755); err != nil {+ t.Fatal(err)+ }+ if a.CLIMissing() || offered() {+ t.Fatalf("with the Windows app: missing %v, offered %v", a.CLIMissing(), offered())+ }++ // Penguin in a WSL distro is not the Windows app's+ if (&Agent{ID: "penguin@wsl:Ubuntu", WSL: "Ubuntu", Bin: "penguin"}).HasApp() {+ t.Fatal("WSL twin has the Windows app")+ }+}++// The app installed elsewhere on Windows is found through the key its+// installer registers, electron-builder's UUID v5 of the appId: the same+// derivation gives dsh's 1bf39983-…, read from its installer (#2279).+func TestPenguinDesktopAppRegistered(t *testing.T) {+ app := desktopApps["penguin"]+ if app.guid != "8bb9acb7-2bdc-596b-9669-7b014ab1c47f" || app.id != "com.prismshadow.penguinharness" {+ t.Fatalf("%+v", app)+ }+ dir := filepath.Join(t.TempDir(), "tools", "PenguinHarness")+ if err := os.MkdirAll(dir, 0o755); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(filepath.Join(dir, "PenguinHarness.exe"), []byte("MZ"), 0o755); err != nil {+ t.Fatal(err)+ }+ was, wasFolders := windowsRegisteredApp, appFolders+ t.Cleanup(func() { windowsRegisteredApp, appFolders = was, wasFolders })+ appFolders = func() []string { return nil }+ windowsRegisteredApp = func(guid string) (string, string) {+ if guid == app.guid {+ return dir, "0.2.17"+ }+ return "", ""+ }+ if !app.installed() || app.version() != "0.2.17" {+ t.Fatalf("registered app: installed %v, version %q", app.installed(), app.version())+ }+}++// With only the app installed, never opened, Connect writes the Project+// the app's server adopts on its first start without overwriting+// (provisionInitialProject: default_project under ~/.penguin/data).+func TestPenguinDesktopOnlyConnects(t *testing.T) {+ home := syncHome(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, "PenguinHarness.app", penguinAppPlist)+ a := penguinOf(t)+ if !a.Detected() {+ t.Fatal("the app alone isn't detected")+ }+ if err := a.Connect(); err != nil {+ t.Fatal(err)+ }+ if want := filepath.Join(home, ".penguin", "data", "default_project", ".project_config.toml"); a.Path != want {+ t.Fatalf("writes %s, not %s", a.Path, want)+ }+ if !a.Wired() || a.Check() != "" {+ t.Fatalf("not connected: %q\n%s", a.Check(), readFile(a.Path))+ }+}