Commit Graph
7 Commits
Author SHA1 Message Date
yetone 56de2d1928 hermes: a model picked in magpie reaches the profile hermes starts in, and Off then On leaves every bot a model (tjhhhh)
tjhhhh on Discord (0.1.1673): switching the model of a Hermes profile
other than the default didn't take, and turning magpie's takeover Off and
On again lost the default model, so the hermes CLI failed at start.

Causes, read from Hermes' source (hermes_cli/main.py
_apply_profile_override, profiles.py):
- `hermes profile use X` writes <root>/active_profile, and every later
  `hermes` runs profiles/X. magpie always wrote <root>/config.yaml, the
  profile hermes no longer started in.
- At Off, hermesUnwireProfile deleted model.provider and model.default
  from every profile on magpie and put nothing back. On rewrote only the
  connected config, so the profile hermes ran had no model.

Now:
- hermesActive: the config magpie connects is the profile hermes starts
  in: HERMES_HOME when it names a profile, else active_profile's (BOM and
  whitespace trimmed) when it is a live profile (not "default", a valid
  name, no tombstone, its folder there), else the root.
- Off leaves each bot on magpie on a model it can start with: its own
  stashed model if it had one, else the connected config's own model,
  with that provider's providers.<name> entry copied in when the bot
  lacks it. What magpie put there is kept as hermes:<path>:off.
- On puts magpie back on each bot still on what Off left (hermesBack); a
  bot the user moved while Off keeps theirs; a bot with no model at all
  gets magpie's.
- Bots on the model magpie or hermes last picked follow a new pick
  (hermesFollow now also follows the connected config's current default).
- gone.go: a profile folder's Agent finds the root's hermes-agent
  checkout, so it counts as installed.

Run:
- go test -tags nogui -count=1 -run 'CLIMissingHermes|Hermes'
  ./internal/agent: ok.
- New tests red on the old code: TestHermesStickyProfile
  (hermes_test.go:811 'active_profile "coder\n": connects .../.hermes,
  want .../.hermes/profiles/coder'), TestHermesOffAndOnKeepsEveryBotsModel
  (hermes_test.go:698 'off: writer is on {Provider: Default:}, want
  {Provider:mine Default:kimi-k3}'), TestHermesBotsFollowTheModelHermesPicked
  (hermes_test.go:768 'writer stayed'); TestHermesProfiles' writer after
  disconnect now expects the root's own model, not nothing.
- Whole internal/agent (-timeout 45m, logged): the disk filled (other
  sessions' temp files, under 1 GB free) and 43 tests failed on "no space
  left on device"; each of them, and every Hermes test, passed on a rerun
  (131s). TestFolderVarsAreListed is red on main since e4552cca9 (#3884),
  not touched here.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  ./internal/agent: clean.

Broken by hand: without the hermesBack call TestHermesOffAndOn fails at
hermes_test.go:716 'on: writer is on {mine kimi-k3}, want {magpie
deepseek/pro}'; following only the recorded pick fails
TestHermesBotsFollow at 768; gone.go reverted fails TestCLIMissingHermes
at install_missing_test.go:132.

Not tried: the real hermes binary (it rewrites the live ~/.hermes launcher
under a temp HERMES_HOME); a real Off/On in the reporter's setup; the full
go test ./... (disk full).
2026-10-27 18:15:16 +08:00
yetone 6e2aa8e321 agent: on Windows DeepSeek Harness is never taken for uninstalled by ~\.dsh alone, so it no longer shows "CLI not found" with no model to pick (#2300, yangkai2; #2304, wlj521)
From v0.1.1239 (d0fcb8bcd, #2177) an agent whose folder is here and whose
CLI isn't found shows "CLI not found" with its settings hidden. On Windows
dsh's folder is read by DeepSeek Harness Desktop too, which installs to any
folder and puts its dsh.cmd in one the user picks, and a dsh installed
through fnm sits on a PATH only a shell profile sets: magpie can't tell
those readers are gone, so ~\.dsh was taken for a leftover and the row
hid its model picker (both screenshots: 未找到 CLI). #1482 already made a
shared folder unknown on Windows; a folder an agent's desktop app reads
(desktopApps: dsh, and codex, already shared) is one too. On macOS and
Linux ~/.dsh with no dsh and no app is still gone (#843); Hermes, whose
folder only its CLI keeps, is still gone on Windows.

TestCLIMissingDshWindows: ~\.dsh as the desktop app leaves it, no dsh,
no app found; judged for Windows it isn't gone nor offered again, judged
for a Mac it is. It fails on the old gone.go (put back by hand: "dsh taken
for uninstalled on Windows, its settings hidden").

Run on this tree, on 6b7ea178d (#2279) over origin/main 707fbb249:
- gofmt -l: clean; go vet -tags nogui for darwin, windows, linux
- go test -p 1 -tags nogui ./internal/agent/: ok (857s)
Full suite: SUITE_LINE

Not tried: the reporters' own machines (how their dsh is installed is
asked on both issues); not run on the Windows box (the test forces the OS
switch, goneOS).
2026-10-15 23:08:02 +08:00
yetone 226222118a agent: on Windows Claude Code and Codex are never taken for uninstalled by their folder, so neither shows "CLI not found" with its settings hidden (#1482, edussss)
edussss (Windows 11) on 10-15: "昨天早上的版本还能找到,今天早上更新后又找不到了".
Their screenshot shows both Claude Code and Codex marked "CLI not found",
with no model or effort pickers. v0.1.1231 listed both.

Cause: d0fcb8bcd (#2177, in v0.1.1238). It made cliHeld declare a shared
folder (~/.claude, ~/.codex, ~/.cline) a leftover when neither the CLI nor
a known reader is here. The known readers are editor extensions under
~/.<editor>/extensions, Claude.app, Claude Desktop, JetBrains and Zed. Before
that commit a shared folder was never gone. The list was checked on a Mac
only. On Windows, other programs read these folders too: a Store app, an
editor run portable or with --extensions-dir, or a CLI on a PATH that only
a shell profile sets (fnm). The Agents page, the TUI, `magpie ls`, Install
another agent and the Library targets (all through CLIMissing) treated both
of the reporter's agents as uninstalled.

Fix: on Windows, cliHeld says "can't tell" for a shared folder whose CLI
isn't found. A shared folder is then never gone, as before v0.1.1238, and
as OpenCode and Goose already are off a Mac. A found CLI still holds it.
Agents whose folder only their CLI keeps (dsh, Hermes) are still gone on
Windows. The Windows-only branches in that path became unreachable and are
dropped: desktopdir.Installed in the claude case, and the Windows dirs of
jetBrainsHere and zedAgentsHere. goneOS lets a test judge for Windows on
any host. docs/subsystems/agent-wiring.md says so.

What was run:
- Windows box (Windows 11 x64), sandbox USERPROFILE/APPDATA/LOCALAPPDATA
  holding only ~\.claude\settings.json and ~\.codex\config.toml, PATH
  C:\Windows\system32 (the registry PATH has the box's real
  ~\.local\bin\claude.exe; there is no codex on the box):
  - `magpie ls` at v0.1.1231 lists Codex "gpt-5 · effort".
  - At origin/main 69d7ee33a it lists "Codex  CLI not found". That is the
    regression.
  - With this fix it lists "Codex gpt-5 · effort" again.
  - At main, a fake openai.chatgpt extension in ~\.vscode or ~\.cursor
    also kept Codex listed. So the extension check works on Windows, and
    the reporter's reader is something cliHeld doesn't list.
- agent.test.exe -test.run TestCLIMissing on the Windows box: all four
  pass (TestCLIMissing, Hermes, SharedFolders, SharedFoldersWindows).
- Broken by hand: with the Windows branch disabled,
  TestCLIMissingSharedFoldersWindows goes red for claude, codex and cline.
  Each is taken for gone and offered again as missing.
- gofmt -l clean. go vet -tags nogui passes for GOOS darwin, linux and
  windows.
- set -o pipefail; go test -p 4 -timeout 40m ./... on macOS at base
  69d7ee33a plus this change: all 55 packages ok, exit 0 (internal/agent,
  cli, gui, library and tui among them).

Not tried: the reporter's own setup. Their screenshot doesn't say what
reads their folders. The reply on #1482 asks for `where.exe claude`, the
install method and the magpie version.
2026-10-15 09:29:57 +08:00
yetone d0fcb8bcdf 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.
2026-10-14 22:50:46 +08:00
yetone ee3f83b59d agents: DeepSeek Harness Desktop installed is no missing dsh CLI — its version shows instead of 未找到 CLI (star on Discord)
star on Discord: "DeepSeek Harness 就是现在已经有桌面版了,但是他还是非要找CLI".
With DeepSeek Harness Desktop in use and no dsh on PATH, the Agents page
said 未找到 CLI and Install another agent offered npm's dsh: CLIMissing
(#843) took ~/.dsh without a CLI for an uninstall. The desktop app
(DeepSeek Harness.app, com.deepseek.dsh, 0.2.0-rc.2 from
download.deepseek.com) keeps the same ~/.dsh — its own profile,
profiles/desktop/cordis.patch.yml, and .credentials.yaml — and needs no
CLI; its terminal command (Manage dsh Command…) is optional.

- desktopapp.go: dsh's app is known by its bundle id on macOS and by
  %LOCALAPPDATA%\Programs\DeepSeek Harness\DeepSeek Harness.exe on
  Windows (electron-builder per-user NSIS, productName DeepSeek Harness,
  getWindowsInstallationDirName); HasApp says either is installed.
- install.go: CLIMissing is false with the agent's desktop app installed,
  so the GUI row, Install another agent and /api all follow; the app's
  version shows through the existing CLI().App path.
- dsh.go: the restart notice also sees DeepSeek Harness.app running.

The red "已不经过 magpie" line in the report is a separate dshCheck
finding, not caused by the missing CLI: a desktop-only ~/.dsh shaped
from the app's real new-profile template wires cleanly (Check "", no
Drift; TestDshDesktopOnlyWired). The reporter's exact detail is cut off
in the screenshot and is not reproduced.

Run: TestDshDesktopAppIsNoMissingCLI fails on the old code ("with the
desktop app: missing true, offered true"; with the Windows path removed,
"with the Windows app: missing true, offered true"), passes with the
fix. go test -tags nogui ./internal/agent ./internal/gui under a temp
HOME with pinned caches: ok. gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui, GOOS=windows on both packages; go build darwin,
GOOS=linux -tags nogui, GOOS=windows: ok. Not tried: the real desktop
app running live (not installed here; its userData isn't redirected by
a sandbox HOME), a real Windows install.
2026-10-09 12:56:08 +08:00
yetone 06420a7121 tests: a fake program is a file macOS has already let run (testenv.Program), so a fake's first start no longer eats a test's wait under load
macOS checks a newly written executable before its first exec: 0.27s
alone, 2-5s while other new programs start (a go test ./... starting its
test binaries). The same file again takes 0.009s, and the pass is kept
across a rename and an in-place rewrite. 108852b4 worked round this for one
test with /bin/sh -c; the class was every test that writes a `#!/bin/sh`
fake and times its answer.

testenv.Program(t, path, script) replaces os.WriteFile(path, script, 0o755)
for fakes. On macOS it renames a file that has run once from a pool to path
and writes the script into it in place; at the test's cleanup the file goes
back to the pool (only a path the test created; a stand-in it wrote over
stays). Fakes still end with their tests: nothing about how they are
started or waited on changed. Run (and gateway's TestMain) remove the pool
at the end. TestMain's PATH stand-ins are run once in the background
(testenv.StandIns). Other systems write the file as before.

Converted every `#!/bin/sh` fake written by tests under internal/ (agent,
gateway, gui, library, plugin, proc, provider, update). Windows, binary
and node/bun fakes are unchanged.

Under the same load (3 loops each starting 8 freshly written scripts at a
time), 4 rounds each, before (108852b4 / origin/main) vs after:
- provider TestSavedButSignedOutClaudeServed: 4/4 fail (8.01s) -> 4/4 pass
- provider TestClaudeSignInOverStaleCredentials: 4/4 fail (5.00s) -> 4/4 pass
- provider TestDevinSignedInOnlyInMagpie: 3/4 fail ("CLI's own []") -> 4/4 pass
- gateway TestClaudeRunEndsWhenTheClientLeaves: 4/4 fail -> 4/4 pass
  (and 3/3 fail -> 3/3 pass at a third of that load)
- gateway TestClientGoneRecordedAsCanceled: 4/4 fail -> 4/4 pass
- gui TestProvidersAnswerWhileListsComeIn ("cursor found false" at 3.03s):
  4/4 fail -> 4/4 pass. The same class, not bfe8bcaf's test order.
- proc TestUserPath (login shell's PATH never came, 7.01s): 4/4 fail ->
  4/4 pass
Unloaded, every touched package passes; no pool directory or process is
left after a run.
2026-10-07 03:00:47 +08:00
yetone 5268a3308e agent, gui: an agent whose CLI is gone while its settings are left says so, and Install another agent offers it again (evilgaoshu, #843: 卸载了 DeepSeek Harness,但 ~/.dsh 还在,Agents 页面依然把它当作已安装列出来,也不会出现在 Install another agent 里) — an agent was here when its config or folder was, so dsh, uninstalled with ~/.dsh kept, was listed as installed, and Install another agent left out every agent listed. Agent.CLIMissing: its folder or config is here, its CLI isn't, neither on PATH nor where users' tools go (proc.FindTool, as #839's Claude Code is found on Windows); only for an agent that is its CLI and has an install command magpie knows, not one whose folder an app or editor extension keeps too (Codex, Claude Code, Gemini CLI, OpenCode, Cline, Goose), nor a WSL one. Its row stays, settings kept and nothing deleted, with "CLI not found" where its version goes (its tooltip names the folder and points to the install command), and Install another agent lists it, marked "CLI not found" under its name. dsh now has its npm package, @deepseek-ai/dsh, so it is offered with npm install -g @deepseek-ai/dsh, and its version and updates show like the other CLIs'. zh, ja, de strings. TestCLIMissing (dsh with ~/.dsh and no dsh is missing and offered; codex's folder, an agent not here, a WSL one aren't; dsh in ~/.local/bin off PATH isn't) fails on the old code; agent-cli-missing.test.cjs (WebKit, en and zh: the row's note, its height kept, Install another agent lists it with its command) fails on the old code. agent-update-all, agent-layout, agent-start-pick, click-scroll, gui-ja, gui-de and import-row pass on WebKit. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-05 09:25:01 +08:00