agent: an agent uninstalled with its folder left behind shows "CLI not found" with no live settings, Hermes and the shared-folder agents too (#2177, mengyianx; #2173, SkyTodInfi)

Detection goes by an agent's folder, and an uninstall leaves the folder
behind. Before this commit, Hermes with only its 37-byte
~/.hermes/config.yaml (custom_providers: [], mcp_servers: {}) was listed as
installed in `magpie ls`, the GUI and the TUI, with model and effort pickers
that no program reads. CLIMissing (#843) covered only agents that have an
install command and their own folder. Hermes and the agents whose folder
something else keeps too (claude, codex, cline, opencode, goose) were never
gone.

What changes:
- internal/agent/gone.go adds cliHeld, which asks whether anything here still
  reads the folder:
  - the CLI on PATH or in proc.FindTool's folders (for goose, a binary that
    isn't pressly's Go goose);
  - its desktop app (HasApp) or sign;
  - the vendor installer's own place: ~/.claude/local, ~/.opencode/bin,
    ~/.codex/packages/standalone, Hermes' <home>/hermes-agent checkout;
  - for the shared folders, an editor extension under
    ~/.<editor>/extensions (anthropic.claude-code, openai.chatgpt,
    saoudrizwan.claude-dev), Claude.app or Claude Desktop, OpenCode.app or
    Goose.app on a Mac, a JetBrains IDE's settings (its agents bring their
    own program) or Zed's external_agents.
  When magpie can't tell, the agent is never gone. That covers OpenCode and
  Goose off a Mac, Gemini (its folder is Antigravity's and Code Assist's
  too), agents with their own detect, and WSL and plugin agents. It also
  covers Bin agents with no install command, except Hermes (cliOnly), since
  their installers' paths aren't verified.
- GUI: a gone row shows "CLI not found" and none of its settings, and the
  tag's tip says why. It offers no Apply again. While it is still wired it
  keeps its switch and Disconnect. Once it isn't wired it folds under Not
  set up, and Get started doesn't offer it (connectKind is "no"; the sandbox
  run showed Hermes offered there before). The panel shows the words only.
  The new tip is translated into zh, zh-TW, ja and de.
- The TUI leaves the agent out. `magpie ls` says "CLI not found" beside its
  path.
- docs/subsystems/agent-wiring.md describes all of the above.
- aside-native.test.cjs drops cliMissing from an Aside fixture. That state
  can't happen (Aside has no install command and isn't in cliOnly), and
  that test is about runtime_unavailable.

What was run:
- Sandbox HOME holding only the reporter's ~/.hermes/config.yaml (37 bytes)
  and a bare ~/.codex, with env -i and PATH=/usr/bin:/bin:
  - `magpie ls` at base 331c27703 lists "Hermes Agent — · effort —".
  - The fix lists "Hermes Agent  CLI not found  ~/.hermes/config.yaml".
  - Codex stays listed, because this Mac has ChatGPT.app's Codex (HasApp),
    so a really installed agent is kept.
- `magpie web` from the same sandbox, screenshot in Chromium: the Hermes row
  shows "CLI not found" and no pickers. That run found Get started still
  offering Hermes, which this commit fixes.
- go test ./internal/agent (2255s under load ~250 on 14 cores) and
  ./internal/cli and ./internal/tui pass. ./internal/gui fails only
  TestMainWindowCorners/macOS_26_SDK, killed at its 40s deadline under the
  same load. That is #1936; it has nothing from this change in its path, and
  it passed on base once and failed on it twice.
- GUI in Chromium and WebKit:
  - agent-cli-missing.test.cjs covers 5 languages, widths 1100 and 420, and
    the panel.
  - getting-started.test.cjs adds a gone Hermes to the fixture; the chips
    stay codex, claude and opencode.
  - Also run: i18n-keys, aside-native, agent-*, panel-* and click-scroll.
- gofmt -l is clean. go vet passes on darwin, linux (-tags nogui) and
  windows for the touched packages.

Broken by hand, and the tests went red each time:
- Dropping the openai.chatgpt check made TestCLIMissingSharedFolders' codex
  case red.
- Dropping the hermes-agent case made TestCLIMissingHermes red.
- Dropping the GUI gone branch, or the agentUsed change ("the one not
  connected stayed up"), made agent-cli-missing red.
- Dropping connectKind's cliMissing line made getting-started red
  (30 of 60 failed: chips gained hermes).

Not covered:
- library.Targets (Skills/MCP) still lists a gone agent as a place to give
  skills to.
This commit is contained in:
yetone
2026-10-14 22:50:46 +08:00
parent 019199e0f7
commit d0fcb8bcdf
13 changed files with 574 additions and 57 deletions
+1
View File
@@ -93,6 +93,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.
- 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. 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 or Claude Desktop on Windows, 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 (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`.
## Verification
+196
View File
@@ -0,0 +1,196 @@
package agent
import (
"os"
"path/filepath"
"runtime"
"strings"
"github.com/yetone/magpie/internal/appdir"
"github.com/yetone/magpie/internal/desktopdir"
"github.com/yetone/magpie/internal/proc"
)
// An agent uninstalled outside magpie leaves its folder behind (~/.dsh,
// ~/.hermes/config.yaml, ~/.claude), and detection, which goes by that
// folder, still lists it. Such an agent is shown as its CLI gone, with
// nothing of its settings offered, since nothing would read them (#2177,
// mengyianx; #2173, SkyTodInfi: Hermes listed by its config.yaml alone).
// Only where magpie can tell the folder holds nothing a program still
// reads: an agent whose folder an app, an editor's extension or another
// program keeps too is gone only when none of those is here either.
// cliOnly are the agents with no install command magpie offers whose
// folder only their CLI keeps, and whose installer puts it where
// cliHeld looks: Hermes' install.sh clones itself into <home>/hermes-agent
// and links ~/.local/bin/hermes to it.
var cliOnly = map[string]bool{"hermes": true}
// cliHeld reports whether something here is the agent, or reads its
// folder as the agent does, so the folder is no leftover; known is false
// when magpie can't tell, which never counts as gone.
func (a *Agent) cliHeld() (held, known bool) {
if a.Bin != "" && (binAt(a.Bin) != "" || proc.FindTool(a.Bin) != "") {
if a.ID != "goose" {
return true, true
}
// pressly's goose, a Go program, is not Block's (see goose's detect)
for _, bin := range []string{binAt(a.Bin), proc.FindTool(a.Bin)} {
if bin != "" && !goProgram(bin) {
return true, true
}
}
}
if a.HasApp() {
return true, true
}
if a.sign != nil && a.sign() {
return true, true
}
home, err := os.UserHomeDir()
if err != nil {
return false, false
}
// where the vendor's own installer puts it, off PATH until a new shell
var at []string
switch a.ID {
case "claude":
at = []string{filepath.Join(home, ".claude", "local", exe("claude"))}
case "opencode":
at = []string{filepath.Join(home, ".opencode", "bin", exe("opencode"))}
case "codex":
at = []string{filepath.Join(home, ".codex", "packages", "standalone")}
case "hermes":
at = []string{filepath.Join(a.Dir, "hermes-agent")}
}
for _, p := range at {
if _, err := os.Stat(p); err == nil {
return true, true
}
}
if !cliShared[a.ID] {
return false, true
}
// the others that keep a shared folder: editors' extensions, desktop
// apps, and the IDEs and editors whose agents bring their own copy of
// the program
switch a.ID {
case "claude":
if extensionHere(home, "anthropic.claude-code") || appHere("Claude.app") ||
desktopdir.Installed(desktopdir.OS, home, appdir.Getenv) {
return true, true
}
return false, !jetBrainsHere(home) && !zedAgentsHere(home)
case "codex":
if extensionHere(home, "openai.chatgpt") {
return true, true
}
return false, !jetBrainsHere(home) && !zedAgentsHere(home)
case "cline":
if extensionHere(home, "saoudrizwan.claude-dev") {
return true, true
}
return false, !jetBrainsHere(home)
case "opencode":
// its desktop app: known by its bundle on a Mac only
if runtime.GOOS != "darwin" {
return false, false
}
return appHere("OpenCode.app", "OpenCode Beta.app", "OpenCode Dev.app"), true
case "goose":
// Goose Desktop: known by its bundle on a Mac only
if runtime.GOOS != "darwin" {
return false, false
}
return appHere("Goose.app"), true
}
// Gemini CLI's folder is Antigravity's and Gemini Code Assist's too,
// and Gemini is listed only by its program (gemini.go)
return false, false
}
// extensionHere reports whether an editor here has the extension id
// installed: VS Code's ~/.vscode/extensions/<id>-<version>, and the same
// in each fork's (~/.cursor, ~/.windsurf, ~/.vscode-oss, ~/.trae, …) and
// in VS Code Server's.
func extensionHere(home, id string) bool {
es, err := os.ReadDir(home)
if err != nil {
return false
}
for _, e := range es {
if !strings.HasPrefix(e.Name(), ".") {
continue
}
xs, err := os.ReadDir(filepath.Join(home, e.Name(), "extensions"))
if err != nil {
continue
}
for _, x := range xs {
if n := strings.ToLower(x.Name()); x.IsDir() && strings.HasPrefix(n, id+"-") {
return true
}
}
}
return false
}
// appHere reports whether one of the bundles names is in a Mac's app
// folders.
func appHere(names ...string) bool {
if runtime.GOOS != "darwin" {
return false
}
for _, dir := range appFolders() {
for _, n := range names {
if isDir(filepath.Join(dir, n)) {
return true
}
}
}
return false
}
// jetBrainsHere reports whether a JetBrains IDE has kept its settings here:
// its AI Assistant's agents (Claude Agent, Codex) and Cline's plugin read
// the agents' folders, with a program of their own.
func jetBrainsHere(home string) bool {
var dirs []string
switch runtime.GOOS {
case "darwin":
dirs = []string{filepath.Join(home, "Library", "Application Support", "JetBrains")}
case "windows":
if d := appdir.Getenv("APPDATA"); d != "" {
dirs = append(dirs, filepath.Join(d, "JetBrains"))
}
dirs = append(dirs, filepath.Join(home, "AppData", "Roaming", "JetBrains"))
default:
dirs = []string{filepath.Join(home, ".config", "JetBrains"), filepath.Join(home, ".local", "share", "JetBrains")}
}
for _, d := range dirs {
if isDir(d) {
return true
}
}
return false
}
// zedAgentsHere reports whether Zed has fetched an external agent: its
// Claude Code and Codex adapters run their own copy of the program, which
// reads ~/.claude or ~/.codex.
func zedAgentsHere(home string) bool {
var d string
switch runtime.GOOS {
case "darwin":
d = filepath.Join(home, "Library", "Application Support", "Zed")
case "windows":
local := appdir.Getenv("LOCALAPPDATA")
if local == "" {
local = filepath.Join(home, "AppData", "Local")
}
d = filepath.Join(local, "Zed")
default:
d = filepath.Join(home, ".local", "share", "zed")
}
return isDir(filepath.Join(d, "external_agents"))
}
+17 -10
View File
@@ -257,25 +257,32 @@ func installsOf(all []*Agent, goos string, node bool) []Install {
// Codex app), ~/.claude (Claude Desktop's Code, the editors' extensions),
// ~/.gemini (Antigravity, Gemini Code Assist), OpenCode's (its desktop
// app), ~/.cline (Cline's extensions), Goose's (Goose Desktop). Their
// folder without the CLI is no sign it was uninstalled.
// folder without the CLI is no sign it was uninstalled while one of those
// is here (cliHeld).
var cliShared = map[string]bool{"codex": true, "claude": true, "gemini": true, "opencode": true, "cline": true, "goose": true}
// CLIMissing reports an agent that is here by its settings alone: its
// folder or config is, its command-line program isn't — not on PATH nor
// where users' tools go (proc.FindTool), as after an uninstall that left
// ~/.dsh behind (#843). Only for an agent that is its CLI and that magpie
// knows an install command for, so the Agents page can offer it again; one
// whose desktop app is installed (HasApp) is that app's settings, which need
// no CLI (DeepSeek Harness Desktop, star on Discord).
// where users' tools go (proc.FindTool) nor where its own installer puts
// it — and nothing else that reads the folder is either (cliHeld): no
// desktop app of its (DeepSeek Harness Desktop, star on Discord), no
// editor extension, no IDE. That is an uninstall that left ~/.dsh (#843),
// ~/.claude (#2177) or ~/.hermes/config.yaml (#2173) behind. The Agents
// page shows it as gone, with none of its settings, and Install another
// agent offers it again where magpie knows how. Only for an agent that is
// its CLI: one magpie knows an install command for, or cliOnly; never one
// detected its own way (detect), but for Goose, whose is its folder or its
// program.
func (a *Agent) CLIMissing() bool {
if a.WSL != "" || a.detect != nil || a.Bin == "" || cliShared[a.ID] {
if a.WSL != "" || a.Plugin != "" || a.Bin == "" || a.detect != nil && a.ID != "goose" {
return false
}
if a.HasApp() {
if len(installCommands(a.ID, runtime.GOOS, true)) == 0 && !cliOnly[a.ID] {
return false
}
if len(installCommands(a.ID, runtime.GOOS, true)) == 0 {
if !a.Detected() {
return false
}
return a.Detected() && proc.FindTool(a.Bin) == ""
held, known := a.cliHeld()
return known && !held
}
+177 -5
View File
@@ -12,7 +12,8 @@ import (
// An agent whose settings are left but whose CLI is gone (#843: dsh
// uninstalled, ~/.dsh kept) is still listed, and Install another agent
// offers it again, marked; one found where users' tools go though not on
// PATH (#839) isn't missing, nor one whose folder an app keeps too.
// PATH (#839) isn't missing. Codex's folder with neither its CLI nor
// anything else that reads it is a leftover too (#2177).
func TestCLIMissing(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
@@ -34,8 +35,11 @@ func TestCLIMissing(t *testing.T) {
if !dsh.Detected() || !dsh.CLIMissing() {
t.Fatalf("dsh with ~/.dsh and no dsh: detected %v, missing %v", dsh.Detected(), dsh.CLIMissing())
}
if codex.CLIMissing() || never.CLIMissing() || wsl.CLIMissing() {
t.Fatalf("missing: codex %v, crush not here %v, wsl %v", codex.CLIMissing(), never.CLIMissing(), wsl.CLIMissing())
if !codex.CLIMissing() {
t.Fatal("codex's folder alone, nothing reading it, not taken for missing")
}
if never.CLIMissing() || wsl.CLIMissing() {
t.Fatalf("missing: crush not here %v, wsl %v", never.CLIMissing(), wsl.CLIMissing())
}
got := installsOf([]*Agent{dsh, codex, never, wsl}, "darwin", true)
ids := map[string]Install{}
@@ -48,8 +52,8 @@ func TestCLIMissing(t *testing.T) {
if x, ok := ids["crush"]; !ok || x.Missing {
t.Fatalf("crush, not here at all, offered as %+v", x)
}
if _, ok := ids["codex"]; ok {
t.Fatal("codex, its folder here, offered")
if x, ok := ids["codex"]; !ok || !x.Missing {
t.Fatalf("codex, its folder left, offered as %+v", x)
}
// installed in ~/.local/bin, which magpie's PATH hasn't: found
@@ -69,3 +73,171 @@ func TestCLIMissing(t *testing.T) {
t.Fatalf("installed dsh offered: %+v", x)
}
}
// noApps points the app folders at an empty folder of the test's, so
// whatever this machine has installed counts for nothing.
func noApps(t *testing.T) string {
t.Helper()
apps := t.TempDir()
was := appFolders
appFolders = func() []string { return []string{apps} }
t.Cleanup(func() { appFolders = was })
return apps
}
func mkdirT(t *testing.T, p string) {
t.Helper()
if err := os.MkdirAll(p, 0o755); err != nil {
t.Fatal(err)
}
}
func writeT(t *testing.T, p, body string) {
t.Helper()
mkdirT(t, filepath.Dir(p))
if err := os.WriteFile(p, []byte(body), 0o600); err != nil {
t.Fatal(err)
}
}
// #2173 (SkyTodInfi): Hermes uninstalled, ~/.hermes/config.yaml left with
// 37 bytes, no hermes anywhere: listed, as gone. Its own install.sh's
// checkout, or hermes in ~/.local/bin, is Hermes installed.
func TestCLIMissingHermes(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("PATH", t.TempDir())
noApps(t)
dir := filepath.Join(home, ".hermes")
writeT(t, filepath.Join(dir, "config.yaml"), "custom_providers: []\nmcp_servers: {}\n")
h := &Agent{ID: "hermes", Name: "Hermes Agent", Bin: "magpie-test-gone-hermes", Dir: dir, Path: filepath.Join(dir, "config.yaml")}
if !h.Detected() || !h.CLIMissing() {
t.Fatalf("hermes by its config.yaml alone: detected %v, missing %v", h.Detected(), h.CLIMissing())
}
// no install command magpie knows: not offered, though gone
for _, x := range installsOf([]*Agent{h}, runtime.GOOS, true) {
t.Fatalf("hermes offered: %+v", x)
}
mkdirT(t, filepath.Join(dir, "hermes-agent"))
if h.CLIMissing() {
t.Fatal("hermes with its checkout taken for missing")
}
if err := os.RemoveAll(filepath.Join(dir, "hermes-agent")); err != nil {
t.Fatal(err)
}
name := h.Bin
if runtime.GOOS == "windows" {
name += ".exe"
}
local := filepath.Join(home, ".local", "bin")
mkdirT(t, local)
testenv.Program(t, filepath.Join(local, name), "#!/bin/sh\n")
if h.CLIMissing() {
t.Fatal("hermes in ~/.local/bin taken for missing")
}
}
// An agent whose folder isn't only its CLI's is gone only when nothing
// else that reads it is here: an editor's extension, a desktop app, an
// IDE whose agents bring their own program. Never one magpie can't tell
// about (OpenCode off a Mac, Gemini, detected its own way).
type goneCase struct {
id string
folder string
with func(t *testing.T, home, apps string)
missing bool
}
func TestCLIMissingSharedFolders(t *testing.T) {
cases := []goneCase{
{"claude", ".claude", nil, true},
{"claude", ".claude", func(t *testing.T, home, _ string) {
mkdirT(t, filepath.Join(home, ".vscode", "extensions", "anthropic.claude-code-2.1.3-darwin-arm64"))
}, false},
{"claude", ".claude", func(t *testing.T, home, _ string) {
mkdirT(t, filepath.Join(home, ".cursor", "extensions", "anthropic.claude-code-2.1.3"))
}, false},
{"claude", ".claude", func(t *testing.T, home, _ string) {
writeT(t, filepath.Join(home, ".claude", "local", exe("claude")), "")
}, false},
{"claude", ".claude", func(t *testing.T, home, _ string) {
mkdirT(t, jetBrainsDirFor(home))
}, false},
{"codex", ".codex", nil, true},
{"codex", ".codex", func(t *testing.T, home, _ string) {
mkdirT(t, filepath.Join(home, ".vscode-server", "extensions", "openai.chatgpt-26.5.1"))
}, false},
{"codex", ".codex", func(t *testing.T, home, _ string) {
mkdirT(t, filepath.Join(home, ".codex", "packages", "standalone"))
}, false},
{"codex", ".codex", func(t *testing.T, home, _ string) {
mkdirT(t, zedAgentsDirFor(home))
}, false},
// another extension's folder of the same prefix is not Codex's
{"codex", ".codex", func(t *testing.T, home, _ string) {
mkdirT(t, filepath.Join(home, ".vscode", "extensions", "openai.chatgpt.other"))
}, true},
{"cline", ".cline", nil, true},
{"cline", ".cline", func(t *testing.T, home, _ string) {
mkdirT(t, filepath.Join(home, ".windsurf", "extensions", "saoudrizwan.claude-dev-3.40.0"))
}, false},
}
if runtime.GOOS == "darwin" {
cases = append(cases,
goneCase{"claude", ".claude", func(t *testing.T, _, apps string) { mkdirT(t, filepath.Join(apps, "Claude.app")) }, false},
goneCase{"opencode", ".opencode-config", nil, true},
goneCase{"opencode", ".opencode-config", func(t *testing.T, _, apps string) { mkdirT(t, filepath.Join(apps, "OpenCode.app")) }, false},
)
} else {
cases = append(cases, goneCase{"opencode", ".opencode-config", nil, false})
}
for i, c := range cases {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("APPDATA", filepath.Join(home, "AppData", "Roaming"))
t.Setenv("LOCALAPPDATA", filepath.Join(home, "AppData", "Local"))
t.Setenv("PATH", t.TempDir())
apps := noApps(t)
dir := filepath.Join(home, c.folder)
writeT(t, filepath.Join(dir, "settings.json"), "{}")
a := &Agent{ID: c.id, Name: c.id, Bin: "magpie-test-gone-" + c.id, Dir: dir, Path: filepath.Join(dir, "settings.json")}
if c.with != nil {
c.with(t, home, apps)
}
if got := a.CLIMissing(); got != c.missing {
t.Errorf("case %d (%s): missing %v, want %v", i, c.id, got, c.missing)
}
}
// detected its own way: never taken for gone
home := t.TempDir()
t.Setenv("HOME", home)
g := &Agent{ID: "gemini", Bin: "magpie-test-gone-gemini", Dir: home, Path: filepath.Join(home, "x"), detect: func() bool { return true }}
if g.CLIMissing() {
t.Fatal("gemini, detected its own way, taken for missing")
}
}
// jetBrainsDirFor and zedAgentsDirFor are where jetBrainsHere and
// zedAgentsHere look on this system.
func jetBrainsDirFor(home string) string {
switch runtime.GOOS {
case "darwin":
return filepath.Join(home, "Library", "Application Support", "JetBrains")
case "windows":
return filepath.Join(home, "AppData", "Roaming", "JetBrains")
}
return filepath.Join(home, ".config", "JetBrains")
}
func zedAgentsDirFor(home string) string {
switch runtime.GOOS {
case "darwin":
return filepath.Join(home, "Library", "Application Support", "Zed", "external_agents")
case "windows":
return filepath.Join(home, "AppData", "Local", "Zed", "external_agents")
}
return filepath.Join(home, ".local", "share", "zed", "external_agents")
}
+5
View File
@@ -614,6 +614,11 @@ func list(agents []*agent.Agent, detectedOnly bool, dimFrom int) error {
r.name = faint.Render(a.Name)
r.vals = faint.Render("not detected")
r.path = ""
} else if a.CLIMissing() {
// its folder left by an uninstall (#2173): what it holds is
// read by nothing
r.name = faint.Render(a.Name)
r.vals = faint.Render("CLI not found")
} else {
vals := a.Values()
dim := dimFrom >= 0 && i >= dimFrom
+2 -1
View File
@@ -220,7 +220,8 @@ type agentJSON struct {
// account failover alone (agent.Agent.FailingOver, #1385)
Failover bool `json:"failover,omitempty"`
// CLIMissing: its settings are here, its CLI isn't (#843), which
// the row says, and Install another agent offers it again
// the row says with none of its settings offered (#2177), and Install
// another agent offers it again where magpie knows how
CLIMissing bool `json:"cliMissing,omitempty"`
Native *agent.NativeState `json:"native,omitempty"`
}
+3
View File
@@ -3714,6 +3714,9 @@ body.window .row.agent .who.with-models { flex-wrap: wrap; row-gap: 0; }
(claude-direct.test.cjs); the page holds the reader itself */
#view-agents { overflow-anchor: none; }
body.window .row.agent > .ag-conn { margin-left: 12px; align-self: center; cursor: pointer; }
/* a row whose CLI is gone (#2177) has no pickers: its switch, while it is
connected, sits at the row's end */
body.window .row.agent.gone > .ag-conn { margin-left: auto; }
.ag-conn-row { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.ag-conn-row .ag-conn-said { flex: 1; min-width: 0; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-conn-row .lib-switch { cursor: pointer; }
+45 -6
View File
@@ -564,6 +564,27 @@ function renderAgents() {
back.onclick = (e) => { e.stopPropagation(); setAgentHidden(a, false); };
who.append(back);
}
// its CLI uninstalled, its folder left behind (#2177, #2173): none of
// its settings is offered, as nothing would read them, only that it is
// gone; one still connected keeps its switch, which puts back what it
// had before magpie (its menu's Disconnect too)
if (a.cliMissing) {
row.classList.add("gone");
row.classList.remove("open");
row.removeAttribute("aria-expanded");
row.onclick = null;
row.append(agentHandle(a, row, inFold), who);
if (mode === "panel") {
const gone = el("span", "ag-sum");
gone.append(el("span", "v empty", t("CLI not found")), el("span"), el("span"));
gone.onmouseenter = () => { gone.title = goneSaid(a); };
row.append(gone);
return row;
}
who.append(cliTag(a));
if (a.wired && connectable(a)) row.append(connectSwitch(a));
return row;
}
// on the name's own line, so the row keeps its height and the pickers
// their columns
// a row with 「接入」 says it on its line under the name instead
@@ -607,9 +628,11 @@ function renderAgents() {
};
// the extras column is there for every row once any agent has one, so the
// pickers keep lining up down the list
list.classList.toggle("extras", state.agents.some((a) => a.fields.some(extra) || tierMenu(a) || a.launch));
// (a row whose CLI is gone has none)
const setUp = state.agents.filter((a) => !a.cliMissing);
list.classList.toggle("extras", setUp.some((a) => a.fields.some(extra) || tierMenu(a) || a.launch));
// as wide as the row with the most squares
list.style.setProperty("--extras", Math.max(1, ...state.agents.map((a) => a.fields.filter((f) => extra(f) && !grouped(a, f)).length + (tierMenu(a) ? 1 : 0) + (a.launch ? 1 : 0))));
list.style.setProperty("--extras", Math.max(1, ...setUp.map((a) => a.fields.filter((f) => extra(f) && !grouped(a, f)).length + (tierMenu(a) ? 1 : 0) + (a.launch ? 1 : 0))));
if (!folded.length) {
for (const a of used) list.append(agentRow(a));
} else {
@@ -1174,8 +1197,10 @@ const anyMagpieModels = () => state.agents.some((a) => connectField(a)?.options.
// connectKind: "ok" (a switch), "empty" (a switch for when magpie has
// models), "no" (never), "link" (an app magpie is added to by a link of its
// own: Cindy), "" (the row as it was)
// own: Cindy), "" (the row as it was); an agent whose CLI is gone is
// offered to no one: only its own row keeps the switch while it is wired
function connectKind(a) {
if (a.cliMissing) return "no";
if (a.import) return "link";
if (connectable(a)) return "ok";
if (NATIVE_ONLY[a.id]) return "no";
@@ -2102,7 +2127,10 @@ function cliTag(a) {
// behind (#843); Install another agent has it again
if (a.cliMissing) {
const m = el("span", "ag-missing", t("CLI not found"));
m.title = t("{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Install another agent, below the list, has its install command.", { agent: a.name, path: a.path });
// said as the pointer comes: Install another agent's list comes after
// the rows
m.title = goneSaid(a);
m.onmouseenter = () => { m.title = goneSaid(a); };
box.append(m);
return box;
}
@@ -2305,6 +2333,15 @@ function updatedSay() {
// for things in the terminal. Folded unless no agent is here at all.
let installInfo = []; // [{ id, name, icon, commands: [{ via, command }] }]
// goneSaid: why an agent whose CLI is gone has nothing to set, and where
// it is installed again, when Install another agent knows (Hermes has no
// command there)
function goneSaid(a) {
return installInfo.some((x) => x.id === a.id)
? t("{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Install another agent, below the list, has its install command.", { agent: a.name, path: a.path })
: t("{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Its settings are offered here again once it is installed.", { agent: a.name, path: a.path });
}
let installsOpen = null; // null: as the list has it (open with no agents)
const VIA = { script: "Installer", powershell: "PowerShell", brew: "Homebrew", npm: "npm" };
@@ -2420,7 +2457,9 @@ const tweak = (f) => f.key === "ultracode" || f.key === "effort" || f.key.endsWi
const onMagpie = (a) => !!(a.added || a.wired || a.drift);
// one whose only control is its launch command (Cursor Private Inference)
// has nothing set to tell by, and stays up while it is there
const agentUsed = (a) => onMagpie(a) || (!connectable(a) && a.fields.some((f) => f.value && !tweak(f))) || (!!a.launch && !a.fields.length && !a.import);
// one whose CLI is gone has nothing to set, and stays up only while
// it is connected, to be disconnected
const agentUsed = (a) => a.cliMissing ? onMagpie(a) : onMagpie(a) || (!connectable(a) && a.fields.some((f) => f.value && !tweak(f))) || (!!a.launch && !a.fields.length && !a.import);
// importButton: the one control of an app magpie is added to by its import
// link: magpie, once the app has it, or an offer to add it
@@ -3478,7 +3517,7 @@ function openAgentMenu(anchor, a, inFold) {
if (again) return;
const { shown } = arrangeAgents();
const i = shown.findIndex((x) => x.id === a.id);
const reapply = a.drift || a.fields.some((f) => optionFor(f, f.value)?.ref);
const reapply = !a.cliMissing && (a.drift || a.fields.some((f) => optionFor(f, f.value)?.ref));
const acts = inFold && isHidden(a)
? [{ name: "Show", icon: EYE, run: () => setAgentHidden(a, false) }]
: inFold
+4
View File
@@ -675,6 +675,7 @@ const I18N = {
"Not on your terminal's PATH": "不在终端的 PATH 里",
"magpie found {agent} {v} at {path}. That folder is one magpie looks in, but your terminal's PATH doesn't have it, so a terminal won't find {agent} there. If it was left behind by an uninstall, delete it.": "magpie 在 {path} 找到了 {agent} {v}。这个文件夹 magpie 会去找,但终端的 PATH 里没有它,所以终端里找不到这个 {agent}。如果它是卸载时没删干净留下的,把它删掉即可。",
"{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Install another agent, below the list, has its install command.": "{agent} 的配置还在({path}),但找不到它的命令行程序,可能已被卸载。列表下方的「安装其他 Agent」里有它的安装命令。",
"{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Its settings are offered here again once it is installed.": "{agent} 的配置还在({path}),但找不到它的命令行程序,可能已被卸载。重新安装后,这里会再显示它的设置。",
"{agent}'s settings are still here, but its command-line program isn't found": "{agent} 的配置还在,但找不到它的命令行程序",
"Run a command in a terminal, then come back: magpie lists the agent here once it is installed. The npm commands need Node.js (nodejs.org).": "在终端运行任一命令,安装后会列在这里。npm 命令需要 Node.js(nodejs.org)。",
"Run a command in a terminal, then come back: magpie lists the agent here once it is installed.": "在终端运行任一命令,安装后会列在这里。",
@@ -4908,6 +4909,7 @@ const I18N = {
"Not on your terminal's PATH": "不在終端機的 PATH 裡",
"magpie found {agent} {v} at {path}. That folder is one magpie looks in, but your terminal's PATH doesn't have it, so a terminal won't find {agent} there. If it was left behind by an uninstall, delete it.": "magpie 在 {path} 找到了 {agent} {v}。這個資料夾 magpie 會去找,但終端機的 PATH 裡沒有它,所以終端機裡找不到這個 {agent}。如果它是解除安裝時沒刪乾淨留下的,把它刪掉即可。",
"{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Install another agent, below the list, has its install command.": "{agent} 的設定還在({path}),但找不到它的命令列程式,可能已被解除安裝。列表下方的「安裝其他 Agent」裡有它的安裝命令。",
"{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Its settings are offered here again once it is installed.": "{agent} 的設定還在({path}),但找不到它的命令列程式,可能已被解除安裝。重新安裝後,這裡會再顯示它的設定。",
"{agent}'s settings are still here, but its command-line program isn't found": "{agent} 的設定還在,但找不到它的命令列程式",
"Run a command in a terminal, then come back: magpie lists the agent here once it is installed. The npm commands need Node.js (nodejs.org).": "在終端機執行任一命令,安裝後會列在這裡。npm 命令需要 Node.js(nodejs.org)。",
"Run a command in a terminal, then come back: magpie lists the agent here once it is installed.": "在終端機執行任一命令,安裝後會列在這裡。",
@@ -9085,6 +9087,7 @@ const I18N = {
"Not on your terminal's PATH": "ターミナルの PATH にありません",
"magpie found {agent} {v} at {path}. That folder is one magpie looks in, but your terminal's PATH doesn't have it, so a terminal won't find {agent} there. If it was left behind by an uninstall, delete it.": "magpie は {agent} {v} を {path} で見つけました。このフォルダは magpie が探す場所ですが、ターミナルの PATH には含まれていないため、ターミナルではこの {agent} は見つかりません。アンインストール時に残ったものなら削除してください。",
"{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Install another agent, below the list, has its install command.": "{agent} の設定は残っています({path})が、コマンドラインプログラムが見つかりません。アンインストールされた可能性があります。リストの下の「他のエージェントをインストール」にインストールコマンドがあります。",
"{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Its settings are offered here again once it is installed.": "{agent} の設定は残っています({path})が、コマンドラインプログラムが見つかりません。アンインストールされた可能性があります。再インストールすると、ここに設定が再び表示されます。",
"{agent}'s settings are still here, but its command-line program isn't found": "{agent} の設定は残っていますが、コマンドラインプログラムが見つかりません",
"Run a command in a terminal, then come back: magpie lists the agent here once it is installed. The npm commands need Node.js (nodejs.org).": "ターミナルでコマンドを実行してから戻ってください。インストールされると magpie がここにエージェントを表示します。npm コマンドには Node.js(nodejs.org)が必要です。",
"Run a command in a terminal, then come back: magpie lists the agent here once it is installed.": "ターミナルでコマンドを実行してから戻ってください。インストールされると magpie がここにエージェントを表示します。",
@@ -13291,6 +13294,7 @@ const I18N = {
"Not on your terminal's PATH": "Nicht im PATH des Terminals",
"magpie found {agent} {v} at {path}. That folder is one magpie looks in, but your terminal's PATH doesn't have it, so a terminal won't find {agent} there. If it was left behind by an uninstall, delete it.": "magpie hat {agent} {v} unter {path} gefunden. magpie sucht in diesem Ordner, aber der PATH deines Terminals enthält ihn nicht, daher findet ein Terminal {agent} dort nicht. Ist es ein Rest einer Deinstallation, lösche es.",
"{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Install another agent, below the list, has its install command.": "Die Einstellungen von {agent} sind noch da ({path}), aber sein Kommandozeilenprogramm wird nicht gefunden: Es wurde vielleicht deinstalliert. Unter „Weiteren Agenten installieren“ unterhalb der Liste steht sein Installationsbefehl.",
"{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Its settings are offered here again once it is installed.": "Die Einstellungen von {agent} sind noch da ({path}), aber sein Kommandozeilenprogramm wird nicht gefunden: Es wurde vielleicht deinstalliert. Sobald es wieder installiert ist, sind seine Einstellungen hier wieder da.",
"{agent}'s settings are still here, but its command-line program isn't found": "Die Einstellungen von {agent} sind noch da, aber sein Kommandozeilenprogramm wird nicht gefunden",
"Run a command in a terminal, then come back: magpie lists the agent here once it is installed. The npm commands need Node.js (nodejs.org).": "Führen Sie einen Befehl im Terminal aus und kehren Sie dann zurück: magpie listet den Agenten nach der Installation hier auf. Die npm-Befehle benötigen Node.js (nodejs.org).",
"Run a command in a terminal, then come back: magpie lists the agent here once it is installed.": "Führen Sie einen Befehl im Terminal aus und kehren Sie dann zurück: magpie listet den Agenten nach der Installation hier auf.",
+118 -32
View File
@@ -1,9 +1,14 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// #843 (evilgaoshu): DeepSeek Harness uninstalled, its ~/.dsh left behind,
// was listed on the Agents page as if it were installed, and Install
// another agent didn't offer it. Now its row says its CLI isn't found (its
// settings are kept, the row stays), and Install another agent has it with
// its install command, marked the same. No backend: the API is faked here.
// another agent didn't offer it. Its row says its CLI isn't found, and
// Install another agent has it with its install command, marked the same.
// #2177 (mengyianx), #2173 (SkyTodInfi): such a row still offered every
// setting, and Hermes, left as its config.yaml alone, looked installed. A
// row whose CLI is gone offers none of its settings now, nor Apply again;
// one still connected keeps its switch and Disconnect, and one that isn't
// folds under Not set up. In the window, wide and narrow, and the tray
// panel, in every language. No backend: the API is faked here.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
@@ -12,15 +17,26 @@ const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
const models = ["model-a", "model-b"].map((m) => ({ value: m, label: m }));
const refs = ["magpie/relay/glm-4.6"].map((m) => ({ value: m, label: m, ref: m }));
const agent = (id, name, more = {}) => ({
id, name, path: "~/." + id + "/config.yaml", fields: [{ key: "model", label: "model", value: "model-a", options: models }], ...more,
});
const AGENTS = [agent("crush", "Crush"), agent("dsh", "DeepSeek Harness", { cliMissing: true })];
const AGENTS = [
agent("crush", "Crush"),
agent("dsh", "DeepSeek Harness", { cliMissing: true }),
// left connected to magpie before it was uninstalled
agent("hermes", "Hermes Agent", {
cliMissing: true, wired: true,
fields: [{ key: "model", label: "model", value: "magpie/relay/glm-4.6", options: refs }, { key: "effort", label: "effort", value: "high", options: ["low", "high"].map((value) => ({ value })) }],
}),
];
const CLIS = { crush: { version: "0.3.0", latest: "0.3.0", via: "brew", command: "brew upgrade crush" } };
const INSTALLS = [
{ id: "dsh", name: "DeepSeek Harness", icon: "deepseek-color", missing: true, commands: [{ via: "npm", command: "npm install -g @deepseek-ai/dsh" }] },
{ id: "opencode", name: "OpenCode", icon: "opencode", commands: [{ via: "npm", command: "npm install -g opencode-ai" }] },
];
const OFFERED = "{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Install another agent, below the list, has its install command.";
const NOT_OFFERED = "{agent}'s settings are still here ({path}), but its command-line program isn't found: it may have been uninstalled. Its settings are offered here again once it is installed.";
function server(lang) {
return async (route) => {
@@ -32,6 +48,7 @@ function server(lang) {
if (url.pathname === "/api/agents/install") return route.fulfill({ json: INSTALLS });
if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });
if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } });
if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], gateway: { running: true } } });
if (url.pathname.startsWith("/api/")) return route.fulfill({ json: {} });
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
@@ -41,9 +58,16 @@ function server(lang) {
}
const row = (id) => `.row.agent[data-id="${id}"]`;
// the language's own words for an English key, failing for one it hasn't
const said = (page, lang, key, vars = {}) => page.evaluate(([lang, key, vars]) => {
const s = lang === "en" ? key : I18N[lang]?.[key];
if (!s) return null;
return s.replace(/\{(\w+)\}/g, (_, k) => vars[k]);
}, [lang, key, vars]);
const noSideScroll = (page) => page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1);
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
test(engine + ": an agent whose CLI is gone says so, and is offered again", async (t) => {
test(engine + ": an agent whose CLI is gone says so, offers nothing to set, and is offered again", async (t) => {
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const errors = [];
@@ -51,36 +75,98 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
if (errors.length) console.log(errors);
await browser.close();
});
for (const [lang, said, also] of [["en", "CLI not found", "Install another agent (2)"], ["zh", "未找到 CLI", "安装其他 Agent(2)"]]) {
await t.test(lang, async () => {
const page = await (await browser.newContext({ viewport: { width: 980, height: 700 } })).newPage();
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
for (const width of [1100, 420]) {
await t.test(`${lang} ${width}`, async () => {
const page = await (await browser.newContext({ viewport: { width, height: 760 } })).newPage();
page.setDefaultTimeout(5000);
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", server(lang));
await page.goto("http://magpie.test/");
await page.locator(`${row("crush")} .ag-ver`).waitFor();
await page.locator("#agentsInstall .ag-install-head").waitFor();
const gone = await said(page, lang, "CLI not found");
assert(gone, "CLI not found has no " + lang);
// each gone row says so, with nothing of its settings to pick
for (const id of ["dsh", "hermes"]) {
const tag = page.locator(`${row(id)} .ag-missing`);
assert.equal(await tag.textContent(), gone, id);
assert.equal(await page.locator(`${row(id)} .field`).count(), 0, id + " offers a setting");
assert.equal(await page.locator(`${row(id)} .ag-ver`).count(), 0);
assert(await page.locator(row(id)).evaluate((r) => r.classList.contains("gone")));
}
assert.equal(await page.locator(`${row("crush")} .ag-missing`).count(), 0, "an installed one says nothing of it");
assert(await page.locator(`${row("crush")} .field`).count() > 0, "an installed one lost its settings");
// where it is installed again: Install another agent for dsh,
// nowhere magpie knows for Hermes
await page.locator(`${row("hermes")} .ag-missing`).hover();
const tip = (id) => page.locator(`${row(id)} .ag-missing`).getAttribute("title");
const dshTip = await said(page, lang, OFFERED, { agent: "DeepSeek Harness", path: "~/.dsh/config.yaml" });
const hermesTip = await said(page, lang, NOT_OFFERED, { agent: "Hermes Agent", path: "~/.hermes/config.yaml" });
assert(dshTip && hermesTip, "a tip has no " + lang);
assert.equal(await tip("hermes"), hermesTip);
await page.locator(`${row("dsh")} .ag-missing`).evaluate((m) => m.dispatchEvent(new MouseEvent("mouseenter")));
assert.equal(await tip("dsh"), dshTip);
// still connected: its switch stays, on, to put back what it had
const sw = page.locator(`${row("hermes")} .ag-conn`);
assert.equal(await sw.count(), 1);
assert.equal(await sw.getAttribute("aria-checked"), "true");
assert.equal(await page.locator(`${row("dsh")} .ag-conn`).count(), 0, "a gone one not connected has a switch");
// the switch on the row's own line, inside it
const box = (sel) => page.locator(sel).evaluate((e) => { const r = e.getBoundingClientRect(); return { l: r.left, r: r.right, t: r.top, b: r.bottom }; });
const r = await box(row("hermes")), s = await box(`${row("hermes")} .ag-conn`), n = await box(`${row("hermes")} .name`);
assert(s.r <= r.r + 0.5 && s.l >= n.r, "the switch is off its row");
assert(s.t < n.b && s.b > n.t, "the switch is not on the name's line");
// its menu: Disconnect, no Apply again
await page.locator(row("hermes")).click({ button: "right" });
const items = await page.locator(".row-menu .rm-item .rm-name").allTextContents();
assert(items.includes(await said(page, lang, "Disconnect from magpie")), items.join(", "));
assert(!items.includes(await said(page, lang, "Apply again")), items.join(", "));
await page.keyboard.press("Escape");
// the one not connected folds under Not set up, the connected one stays up
assert.equal(await page.locator(`#agents > ${row("hermes")}`).count(), 1, "the connected one folded");
assert.equal(await page.locator(`.agent-fold ${row("dsh")}`).count(), 1, "the one not connected stayed up");
assert(await noSideScroll(page), "the page scrolls sideways");
// Install another agent offers dsh, though it is listed above
const inst = page.locator("#agentsInstall");
assert.equal(await inst.locator(".ag-install-head").textContent(), await said(page, lang, "Install another agent ({n})", { n: 2 }));
await inst.locator(".ag-install-head").click();
assert.deepEqual(await inst.locator(".ag-install-row").evaluateAll((rs) => rs.map((r) => r.dataset.id)), ["dsh", "opencode"]);
const dsh = inst.locator('.ag-install-row[data-id="dsh"]');
assert.equal(await dsh.locator(".ag-install-missing").textContent(), gone);
assert.equal(await dsh.locator("code").textContent(), "npm install -g @deepseek-ai/dsh");
assert(await dsh.locator("b").evaluate((b) => b.scrollWidth <= b.clientWidth + 1), "name cut");
// the tag isn't cut, nor the name beside it
for (const id of ["dsh", "hermes"]) {
assert(await page.locator(`${row(id)} .name`).evaluate((b) => b.scrollWidth <= b.clientWidth + 1), id + "'s name cut");
}
assert(await page.locator(`${row("hermes")} .ag-missing`).evaluate((b) => b.scrollWidth <= b.clientWidth + 1), "the tag cut");
await page.screenshot({ path: path.join(process.env.SHOTS || "/tmp", `cli-missing-${engine}-${lang}-${width}.png`), fullPage: true }).catch(() => {});
await page.context().close();
});
}
await t.test(`${lang} panel`, async () => {
const page = await (await browser.newContext({ viewport: { width: 400, height: 640 } })).newPage();
page.setDefaultTimeout(5000);
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", server(lang));
await page.goto("http://magpie.test/");
await page.locator(`${row("crush")} .ag-ver`).waitFor();
// the row stays, its settings kept, and says its CLI isn't found
const tag = page.locator(`${row("dsh")} .ag-missing`);
assert.equal(await tag.textContent(), said);
assert.match(await tag.getAttribute("title"), /~\/\.dsh\/config\.yaml/);
assert.equal(await page.locator(`${row("dsh")} .ag-ver`).count(), 0);
assert.equal(await page.locator(`${row("crush")} .ag-missing`).count(), 0, "an installed one says nothing of it");
// on its name's line, not pushing the row taller than crush's
const h = (id) => page.locator(row(id)).evaluate((r) => r.getBoundingClientRect().height);
assert(Math.abs(await h("dsh") - await h("crush")) < 0.5, "the row grew");
// Install another agent offers it, though it is listed above
const box = page.locator("#agentsInstall");
assert.equal(await box.locator(".ag-install-head").textContent(), also);
await box.locator(".ag-install-head").click();
assert.deepEqual(await box.locator(".ag-install-row").evaluateAll((rs) => rs.map((r) => r.dataset.id)), ["dsh", "opencode"]);
const dsh = box.locator('.ag-install-row[data-id="dsh"]');
assert.equal(await dsh.locator("b").textContent(), "DeepSeek Harness");
assert.equal(await dsh.locator(".ag-install-missing").textContent(), said);
assert.equal(await dsh.locator("code").textContent(), "npm install -g @deepseek-ai/dsh");
assert.equal(await box.locator('.ag-install-row[data-id="opencode"] .ag-install-missing').count(), 0);
// the name isn't cut by the note under it
assert(await dsh.locator("b").evaluate((b) => b.scrollWidth <= b.clientWidth + 1), "name cut");
await page.screenshot({ path: path.join(process.env.SHOTS || "/tmp", `cli-missing-${engine}-${lang}.png`), fullPage: true }).catch(() => {});
await page.goto("http://magpie.test/?mode=panel");
await page.locator(`${row("crush")} .ag-sum`).waitFor();
const gone = await said(page, lang, "CLI not found");
const sum = page.locator(`${row("hermes")} .ag-sum`);
assert.equal(await sum.locator(".v").textContent(), gone);
// nothing to open: a click opens no settings
await page.locator(`${row("hermes")} .name`).click();
assert.equal(await page.locator(`${row("hermes")}.open`).count(), 0);
assert.equal(await page.locator(`${row("hermes")} .field, ${row("hermes")} .ag-open`).count(), 0);
await sum.hover();
assert.equal(await sum.getAttribute("title"), await said(page, lang, NOT_OFFERED, { agent: "Hermes Agent", path: "~/.hermes/config.yaml" }));
// in words in the same column as the others'
const right = (id) => page.locator(`${row(id)} .ag-sum`).evaluate((e) => e.getBoundingClientRect().right);
assert(Math.abs(await right("hermes") - await right("crush")) < 1, "not in the column");
assert(await sum.locator(".v").evaluate((b) => b.scrollWidth <= b.clientWidth + 1), "the words cut");
assert(await noSideScroll(page), "the panel scrolls sideways");
await page.screenshot({ path: path.join(process.env.SHOTS || "/tmp", `cli-missing-${engine}-${lang}-panel.png`), fullPage: true }).catch(() => {});
await page.context().close();
});
}
+1 -1
View File
@@ -76,7 +76,7 @@ for (const engine of ['chromium', 'webkit']) {
let revision = 'confirmed-plan';
let failPreview = false, releasePreview = null, blockPreview = false;
const a = {
id: 'aside', name: 'Aside', icon: 'aside', wired: true, cliMissing: true, path: '~/.aside/u/0/settings.json',
id: 'aside', name: 'Aside', icon: 'aside', wired: true, path: '~/.aside/u/0/settings.json',
native: { provider: 'connected', runtime: 'applied', fields: {} },
fields: [{ key: 'model', label: 'model', value: 'native/current', options: [{ value: 'native/current', label: 'Current model' }, { value: 'magpie/relay/m1', ref: 'relay/m1', label: 'New model' }] }],
};
@@ -33,6 +33,8 @@ function agents(w) {
{ id: "opencode", name: "OpenCode", icon: "generic", path: "/fixture/opencode", fields: field("", []) },
// never connectable: not offered on the card
{ id: "cursor", name: "Cursor", icon: "generic", path: "/fixture/cursor", fields: [] },
// its folder left behind with the CLI uninstalled (#2173): not offered
{ id: "hermes", name: "Hermes Agent", icon: "generic", path: "/fixture/hermes", cliMissing: true, fields: field("", [{ value: "hermes-own", label: "Own" }]) },
];
}
+3 -2
View File
@@ -176,10 +176,11 @@ func Run(ready func()) error {
func newModel() model {
// in the order the app lists them, those hidden there last
// an app magpie has no fields in (Cindy, which takes it by a link) has
// nothing to pick here
// nothing to pick here, nor one whose CLI is gone, its folder left
// behind (#2177): nothing would read what is picked
var set []*agent.Agent
for _, a := range agent.Detected() {
if len(a.Fields) > 0 {
if len(a.Fields) > 0 && !a.CLIMissing() {
set = append(set, a)
}
}