Commit Graph
15 Commits
Author SHA1 Message Date
yetone 4e85cac01d agent: OpenCode installs as OpenCode 2 (@opencode/cli, opencode.ai/v2/install) (math_milian)
math_milian on Discord: magpie's npm command for OpenCode installs
OpenCode 1, and OpenCode 2 isn't installed that way. On 2026-11-05
opencode-ai's latest is 1.19.5 and it has no 2.x; OpenCode 2 is
@opencode/cli (2.2.5, anomalyco/opencode's README), and
opencode.ai/install refuses a 2.x ("not an OpenCode 1 release") and
points to opencode.ai/v2/install.

- Install: opencode.ai/v2/install on a Mac or Linux, then
  npm install -g --allow-scripts=@opencode/cli @opencode/cli. Air's
  "OpenCode isn't installed" notice says the same, in every language.
- Update: an install from either package is updated within it (npm,
  bun, pnpm by where it sits; brew's opencode or anomalyco/tap's
  opencode-v2). An installer copy in ~/.opencode/bin is offered its
  own line's newest: OpenCode 2 @opencode/cli's, OpenCode 1
  opencode-ai's, since OpenCode 1's opencode upgrade runs the v1-only
  installer. An unreadable version promises none.
- An existing opencode-ai install isn't moved to OpenCode 2: its
  config differs, and npm needs --force over the other package's bin.

Run (mote): gofmt -l, go vet ./internal/agent, GOOS=linux/windows go
vet, go test ./internal/agent -run 'Install|UpdateCLI|HowInstalled|Mend|
Npm|Bun|Pnpm|Shim|Scripts|CLI|OpenCode|Air' ok; node --test i18n-keys,
i18n-en-no-cjk, agent-air-own, agent-notice-lang, agent-cli-missing: 82
pass. Real, sandbox HOME on mote: curl -fsSL opencode.ai/v2/install |
bash gave ~/.opencode/bin/opencode and opencode2, "opencode v2.2.5";
`opencode upgrade 2.2.4` from there went to v2.2.4 (magpie's target
form); npm 10.9.4 and 11.21.2 with magpie's exact command gave v2.2.5,
opencode2 too; `opencode acp` is in 2.2.5 for Air.
Broken by hand: opencode-ai first in npm turns TestInstallCommands red;
without the line hook TestUpdateCLIOpenCodeKeepsItsLine/1.19.4 is
offered 2.2.5 and TestUpdateCLIOpenCodeTakesVersion goes red.
Not tried: Windows npm install for real, Homebrew's opencode-v2 tap,
moving a real opencode-ai user to OpenCode 2.
2026-11-05 11:50:13 +08:00
yetone 06808ad308 agent: an agent's npm package that needs its install script gets it run on npm 12, bun and pnpm
npm 12 runs a package's install script only when told to
(--allow-scripts=<pkg>), and bun (--trust) and pnpm 10 (--allow-build)
do the same. A package whose postinstall puts its binary in place then
installs a stub: @opencode/cli 2.2.5 from npm 12.2.2 or bun 1.4.2 without
the flag prints "@opencode/cli's postinstall script was not run" and
exits 1 (mote, sandbox HOME). OpenCode's own v2 updater passes the same
flags.

cliSpec.scripts marks the agents whose npm package has an install
script: `npm view <pkg> scripts` on 2026-11-05 named one for claude,
cline, crush, deveco, mothx, omo, opencode and snow, and none for the
rest. Their install command, their npm/bun/pnpm update and the mend
hint now carry the manager's flag. npm 10 and 11 run scripts anyway and
take --allow-scripts as an unknown config.

Run (mote): gofmt -l, go vet ./internal/agent, go test ./internal/agent
-run 'Install|UpdateCLI|HowInstalled|Mend|Npm|Bun|Pnpm|Shim|Scripts|CLI|
OpenCode|Air' ok, and GOOS=linux/windows go vet ok. Real: on mote, npm
10.9.4, 11.21.2 and 12.2.2 with --allow-scripts=@opencode/cli each gave
a working opencode v2.2.5; npm 12 without it and bun without --trust the
stub; bun with --trust a working one.
Broken by hand: withScripts never adding the flag turns
TestInstallLetsScriptsRun, TestUpdateLetsScriptsRun and
TestUpdateCLIChecksItRuns red.
Not tried: pnpm and yarn for real (mote has neither), the other seven
agents' packages on npm 12.
2026-11-05 11:50:13 +08:00
yetone 3fd7e16983 agent: PenguinHarness is installed from the Agents page and served by magpie with nothing to set up
rankyurky asked on Discord #feedback for PenguinHarness (npm
@prismshadow/penguin-cli, command penguin). Every value comes from
Penguin's own source (0.2.17):

- Config: $PENGUIN_HOME (else ~/.penguin/data, every OS) /
  $PENGUIN_PROJECT_ID (else default_project) /.project_config.toml.
  magpie writes [providers.magpie] (base_url, client_type, api_key),
  one [[models]] entry per magpie model (context_window, vision,
  max_tokens, [models.pricing] in usd_per_mtok) and default_model in
  Penguin's own inline spelling. Penguin's server reads the file again
  when its mtime changes, so no restart; a default naming no entry is
  refused by Penguin, so Check fails when one is missing.
- A file magpie creates is 0600 in a 0700 folder, as Penguin keeps it.
  Disconnect restores the user's own default_model (or none), drops a
  magpie vision model, and removes the file when magpie made it.
  Penguin's own entries, providers and command_policy rules are kept.
- A sync that changes nothing writes nothing (bytes and mtime kept), so
  Penguin's watcher isn't woken.
- Install: curl -fsSL https://penguin.ooo/install.sh | sh, or
  irm https://penguin.ooo/install.ps1 | iex on Windows; update: npm, or
  penguin update --yes for the tarball, except on Windows where
  update.ts refuses it.
- WSL: a penguin kind with no restart notice; the WSL test now expects
  an empty Notice for a kind with no restart.
- agentenv: PENGUIN_HOME, PENGUIN_PROJECT_ID; the project id is in
  NotPaths, or appdir dropped a value like "work" as a relative path.
- edit.SetTOMLArrayTables: replaces every [[name]] entry with key =
  value (with child tables) by blocks, or removes them; blank lines
  between replaced entries go with them, and an unchanged result isn't
  written.
- GUI: penguin-color.svg icon; README (en, zh-CN), docs/reference.md
  and docs/subsystems/agent-wiring.md.

Run (worktree at ca9b5048e, GOMODCACHE/GOCACHE pinned):
- go test -tags nogui -timeout 45m ./internal/agent ./internal/edit
  ./internal/agentenv ./internal/appdir ./internal/usage: all ok but
  TestWSLMoreAgentsPick (penguin has no restart notice), fixed in the
  test; rerun -run 'TestWSL|TestPenguin|TestEveryAgent|TestFolderVars|
  TestEveryNotice' ok.
- internal/gui: TestCoreScriptBudget, TestAssetTypesHoldAgainstTheRegistry,
  icon and i18n guards ok; no budget raised.
- GUI Playwright, chromium and webkit: i18n-keys, getting-started,
  agent-cli-missing, agent-update-all, gui-ja, gui-de, gui-zh-tw:
  123 tests, 123 pass. The icon renders in colour in both engines.
- gofmt -l internal/ clean; go vet -tags nogui ./... with GOOS linux,
  windows and darwin clean.
- Real Penguin 0.2.17 (npm, Node 25) in a sandbox HOME against a sandbox
  magpie serve and a fake upstream: penguin run -m "Say PONG" answered
  "PONG from fake" through magpie (usage agent "penguin",
  /v1/responses -> /v1/chat/completions); switching the model in magpie
  took effect with no Penguin restart; a no-op sync kept bytes and
  mtime; magpie penguin default restored the user's custom/my-own and
  left no magpie line; with no prior file it was created 0600 and
  removed on disconnect. The fixture is the file Penguin itself wrote.

- Rebased on origin/main d9a8148d7 and run again there: internal/agent -run
  'TestPenguin|TestWSL|TestEveryAgent|TestFolderVars|TestEveryNotice|
  TestSync', internal/edit, internal/agentenv and the internal/gui
  guards ok; gofmt clean.

Broken by hand, each went red: the no-op skip (mtime test), the 0600
create, the inline default_model spelling, the own-default restore,
removing magpie's file, dropping the vision model, the NotPaths entry,
and both SetTOMLArrayTables fixes (blank-line growth, unchanged write).

Not tried: the full ./... suite (machine load ~190-200, as asked); a
Windows or WSL real binary; Penguin's desktop app; a real vendor key
through Penguin. Penguin sends the openai SDK's User-Agent, so the
agent is named from its key, not its UA.
2026-10-27 01:38:45 +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 e528aeb3ce agent: DevEco Code, Huawei's OpenCode, as an agent (#1885)
foobra asked for DevEco Code (npm @deveco/deveco-code), Huawei's
HarmonyOS coding agent. It is OpenCode underneath, so it joins through
openCodeLike as MiMo Code did (03a01a548):

- Config in ~/.config/deveco. magpie writes the first of deveco.jsonc,
  deveco.json, config.json there (the one DevEco reads last wins its
  merge), or DEVECO_CONFIG_DIR when that is an absolute folder; agentenv
  carries DEVECO_CONFIG_DIR. Auth at ~/.local/share/deveco/auth.json.
- Its provider block carries the key magpie-deveco, not the plain one.
  0.2.3 sends "deveco/0.2.3 ai-sdk/provider-utils/4.0.23 runtime/bun/1.4.2"
  on chat, but parts of its code still send opencode/<version>, so the key
  keeps its usage DevEco's whichever it sends. Check flags the plain key,
  and Sync writes DevEco's back. OpenCode's own key is unchanged.
- The user's own provider, small_model, $schema and comments stay; the
  model they were on comes back on Disconnect.
- Library: AGENTS.md instructions (with the "reads Claude Code's
  CLAUDE.md" note, as OpenCode and MiMo Code), MCP in OpenCode's shape,
  skills. No WSL folder.
- Install/update: npm @deveco/deveco-code on macOS and Windows only, as the
  package has no Linux binary (new cliSpec.only); the self installer under
  ~/.local/share/deveco/versions updates with `deveco upgrade`.
- Icon: DevEco's own logo, byte for byte from its IntelliJ plugin's
  pluginIcon.svg. Model picker /models. Route hue, READMEs (en, zh), site
  agent lists (en, zh, ja), docs/reference.md, subsystem pages, CLI help.

What was run
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -tags nogui: internal/library, agentenv, proc, cli, gui, usage
  pass; internal/agent passes in 559s with -timeout 40m;
  its first run, at the default 10m with load average ~40 from other
  sessions, was cut off by the timeout (no test had failed).
- New deveco_test.go: config lookup and DEVECO_CONFIG_DIR, the key, and
  Connect/Check/Sync/Disconnect against a deveco.jsonc holding the user's
  own model, provider, small_model, $schema and a comment. Made
  openCodeKeyAt return the plain key by hand: TestDevEcoKeyNamesIt and
  TestDevEcoConnectKeepsTheUsersOwn go red.
- GUI: new library-deveco.test.cjs (the note in en, zh, zh-TW, ja, de,
  and the icon draws), chromium and webkit; red with deveco taken out of
  library.js's note. library-instr-sets, library-instr-busy,
  panel-routing, agent-connect, library-desktop-skills, getting-started,
  filter-ime, routing-account-identity pass in both engines.
- Real use, sandbox HOME: npm-installed @deveco/deveco-code 0.2.3,
  `deveco auth consent --accept` (sandbox only, no Huawei sign-in). magpie
  serve on 127.0.0.1:3592 with a fake upstream; `magpie deveco fake/fake-1`
  wrote provider magpie (magpie-deveco, http://127.0.0.1:3592/v1) beside
  the user's own and kept the file's comment; `deveco run "Reply with one
  word: ping"` answered from the fake, and `magpie usage today` counted it
  under DevEco Code. The User-Agent above is what it sent.

Not tried
- Windows, and DevEco Studio's plugin mode; a Huawei-signed-in DevEco.
- `magpie deveco <model>` then `magpie deveco default` doesn't bring back
  the model the user was on before: the CLI set path doesn't stash. It is
  the same for OpenCode today; Connect/Disconnect in the GUI does.

Reported-by: foobra
2026-10-13 10:57:32 +08:00
yetone 2221b63f93 agent, provider: tests no longer read the machine's /Applications or Program Files, so a Mac with DeepSeek Harness.app installed keeps TestAsideOfflineDisconnectRestoresWithoutDaemon green (#1823)
What: every place magpie looks for installed apps outside the home folder
now goes through proc.SystemDirs, which in a test binary testenv isolated
puts the path under the test's home (as it already does for Homebrew's
bin, #1525):
- agent: a new macAppFolders(home) (/Applications via SystemDirs, plus
  ~/Applications) is used by appFolders (desktop apps: Codex, dsh),
  pencilApp, t3App and reasonixDetected;
- cursorLocalRoots: macOS through macAppFolders, Windows' ProgramFiles and
  Linux's /opt, /usr/share, /usr/lib through SystemDirs;
- zedAppPath's /Applications/Zed*.app, npmGlobalPrefix's ProgramFiles npm
  fallback, and provider's /Applications/ZCode.app builtin config.
Production behaviour is unchanged: SystemDirs returns paths as they are
outside a sandboxed test.

Why: HasApp/AppVersion read the real /Applications, so on a Mac with
DeepSeek Harness.app the dsh fixture's CLI was never "missing" and the test
failed every time; CI has no such app, so nobody else saw it. The same
shape was in five other readers.

Test: TestAppFoldersStayInTheTestHome checks every app folder lies under
testenv's home (all OSes), and on macOS that an app installed in the
sandbox's /Applications is the one found.

Run (go1.26.8, sandbox HOME, private GOCACHE):
- repro on old code: appFolders pointed at a temp folder holding a fake
  "DeepSeek Harness.app/Contents/Info.plist" (com.deepseek.dsh) ->
  TestAsideOfflineDisconnectRestoresWithoutDaemon FAIL "native fixture must
  report missing CLI".
- break check: macAppFolders put back to the literal /Applications ->
  TestAppFoldersStayInTheTestHome FAIL (appFolders, macAppFolders,
  cursorLocalRoots look in /Applications; sandbox app not found). Restored:
  pass.
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean.
- go test -tags nogui ./internal/agent ./internal/proc ./internal/provider: ok.
- -race -count=5 on the touched agent tests: ok.
Not run: the full go test ./...; Windows and Linux test runs (vet only);
reasonix's Windows registry lookup and Zed's mdfind fallback still ask
the machine (not folder paths) and are left as they are.

Reported-by: mdwsk88
2026-10-12 23:56:20 +08:00
yetone 8bfe33f1f4 agent, proc: where each command is on PATH is looked up once while its folders are unchanged, so a Windows page doesn't stat PATH per agent and per session (#1771)
oxyuan profiled every page's first load on Windows at seconds (4-7s), and
Sessions, Usage → Sessions and Context at 26-45s: 96-98% of the samples
were os.Stat under exec.LookPath and proc.FindTool. A failed lookup stats
every PATHEXT candidate in every PATH folder (111ms there), and the pages
asked once per known agent (Detected → binAt) and once per Pi session
(sessions.carries → ompThere) on every request.

proc.Look (new, look.go) is exec.LookPath with its answers kept. The
proc.LookPath that 1bf722e28 added (exec.LookPath, then Unwrap of a mise
wrapper script) is now Look then Unwrap, and FindTool keeps its PATH
answer the same way before Unwrap. Unwrap keeps its own answer by the
script's size and time, and on Windows it returns at once. The PATH
answers are keyed on PATH and PATHEXT,
and dropped when a looked-in folder's modification time changes (an
install or removal), checked at most every 2s, every time in a test binary
testenv isolated. proc.Forget drops them all and agent.Rescan (the Agents
page's refresh) calls it. Every exec.LookPath that a page or the gateway
reaches now goes through one of them. The sites 1bf722e28 made unwrap keep
LookPath: agent (agent, air, nativemodels) and provider (codex models,
cursor, devin, kiro). The rest keep exec.LookPath's answer as it was,
through Look: agent (agents, cliupdate, the shim, gemini, install,
reasonix, vscode, zed), sessions/carry and library/rtk. Those left
on exec.LookPath run once per user action (update's pkexec, the
secret-tool read, installers, rtk upgrade) or in tests.

Run:
- look_test.go: asks once while folders are unchanged, sees an install and
  a removal, a changed PATH and Forget, concurrent lookups under -race. The
  first goes red with LookPath calling exec.LookPath directly.
- On the Windows box (yeton@10.0.0.132, amd64 probe, sandbox USERPROFILE):
  Detected with 4 agents 252ms → 7ms per call after the first, 297x
  LookPath(omp) 879ms → 1.1ms; drift over Detected 274ms → 42ms; Titles
  for 6 sessions 23ms → 4ms. The first call is the same (it looks).
- gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., sandboxed go test ./... at the rebased head.
Not run: the reporter's own machine (47 PATH folders, 59 agents).
2026-10-12 22:55:22 +08:00
yetone e2b3eb7406 agent: an npm -g agent under mise's Node says its version and updates with that Node's npm, not "can't tell how it was installed" (flp on Discord)
On Windows with Node managed by mise, the Agents page read "无法判断安装方式"
for an agent installed with npm install -g. howInstalled decided from the
binary's path, and a mise shim leads nowhere near node_modules: on a Mac
or Linux it is a symlink to the mise binary; on Windows a copy of
mise-shim.exe (exe mode, the default), a .cmd plus a bash script running
`mise x --` (file), or a hard or symbolic link to mise.exe.

A shim is now recognised (a link to mise, or a file in mise's shims
folder: parent "mise", a .mode file, or MISE_DATA_DIR/shims) and mise is
asked which program it runs, `mise which <cmd>` from the home folder; how
it was installed is read from that program. On Windows mise names npm's
extensionless sh script, so the .cmd beside it is used. The update runs
that Node version's own npm with --prefix, then `mise reshim`: on Windows
npm install -g makes no shim for a new command (seen on the box), mise's
Unix npm wrapper reshims itself, so it is harmless there.

Siblings:
- asdf shims (scripts with "# asdf-plugin:" and `exec asdf exec`) are
  asked with `asdf which` the same way; asdf-nodejs's npm reshims itself
  and asdf has no Windows build.
- proc.UserBinDirs on Windows also looks in mise's shims folder
  (MISE_DATA_DIR, else XDG_DATA_HOME\mise, which mise follows on Windows,
  else %LOCALAPPDATA%\mise) for an agent PATH doesn't reach.
- Install side: npmIn accepts npm.exe beside node as well as npm.cmd.
- WSL agents get no update path (CLI skips them) and wsl.go's probe
  already lists mise/asdf shims: unchanged.
- MISE_DATA_DIR and ASDF_DIR join agentenv.Vars, so a test sandbox
  clears them (TestFolderVarsAreListed).

Fixtures are real bytes: internal/agent/testdata/mise-windows from mise
2026.10.7 on the Windows box (file-mode snow.cmd and snow, .mode files,
npm's snow.cmd/snow in the Node folder); the Mac layout and the asdf
shim's text from mise 2026.10.7 and asdf 0.20.2 release binaries in a
sandbox home.

Run:
- flp's own layout (where.exe claude: installs\node\24.20.0\claude,
  claude.cmd, shims\claude.exe; mise which claude names the extensionless
  script): TestMiseShimWindowsFiveAgents covers claude, pi, codex,
  opencode and codebuddy through shims\<cmd>.exe; run on the Windows box,
  red with the fix removed by hand, green restored.
- go test -tags nogui ./internal/agent ./internal/proc -run
  'Shim|HowInstalled|UpdateCLI|NpmIn|InstalledVersion'; with installedAt
  skipping the shim by hand TestMiseShimIsNodesNpm,
  TestUpdateCLIThroughMiseShim and TestAsdfShimIsNodesNpm go red, green
  again restored.
- Real mise on the Mac (sandbox home, mise 2026.10.7, node 22.23.3,
  snow-ai): detection through the real shim and `mise which`, and a real
  update 0.9.1 -> 0.9.2 through UpdateCLI.
- Real mise on Windows (the box, sandbox USERPROFILE/LOCALAPPDATA, mise
  2026.10.7, node 22.23.3, snow-ai): the Windows test binary's unit tests
  (TestMiseShimWindows, TestHowInstalledWindowsShim, TestNpmIn) pass;
  a temporary test through the real shim in exe, file and hardlink modes
  found npm.cmd --prefix <node>, version 0.9.2; after npm install -g
  snow-ai@0.9.1 a real UpdateCLI took it to 0.9.2 and reshimmed; snow.exe
  ran 0.9.2. Symlink mode was not tried (needs developer mode); it is
  the link-to-mise case the Mac covers. flp's own machine was not tried.
- go test -tags nogui -timeout 40m ./...; gofmt -l; GOOS=linux and
  GOOS=windows go vet -tags nogui ./...
2026-10-11 12:45:31 +08:00
yetone 6876125a19 agent, library: an npm agent or winget's RTK under Program Files updates after Windows' administrator prompt, and says why when it can't (新v学员 on Discord)
On Windows the official Node.js installer leaves npm's global prefix at
C:\Program Files\nodejs, which only an administrator can change. magpie
runs as the user, and writable() on Windows always said true, so the
Agents page offered the update and npm failed with EPERM (mkdir
...\node_modules\@scope), with nothing saying why. The same user then
reported RTK and other actions needing elevation all failing, and asked
for a setting to run magpie as administrator. There is no such setting:
an elevated magpie would write the agents' configs as the administrator,
couldn't start with Windows without a UAC prompt at each login, and
widens what can go wrong. Instead each action that needs an administrator
asks Windows for one, alone.

- agent: writable() on Windows makes and removes a file in the folder
  (update.Writable) instead of always saying yes. An npm CLI in a folder
  the user can't write in is still offered on Windows, marked Admin, and
  its update runs through update.RunElevated, never as the user. Elsewhere
  (/usr/lib, would want sudo) nothing is offered, as before.
- update: RunElevated (Windows) runs the command through
  ShellExecuteEx "runas" on a .cmd script that sets the env that differs
  from an elevated process's own plus PATH, cds to the folder, and sends
  output to a log read back; the exit code comes from GetExitCodeProcess
  (a non-zero one is update.ExitError, for its code). A declined prompt is
  ErrCanceled; no prompt to be had is the new ErrNoAdmin. Other systems:
  CanRunElevated false.
- library: RTK installed by winget for every user (under Program Files)
  is upgraded through the same prompt when only an administrator can
  change rtk's folder; the card's Upgrade title says Windows asks first.
  Install, and an upgrade whose folder looked writable, run winget as the
  user and go through the prompt only when winget answers 0x8A150019
  (command requires admin). winget's codes from the elevated run are read
  as before (0x8A15002B: no newer RTK, no failure).
- A declined or impossible prompt is agent.AdminError (Via npm or
  winget); the GUI answers it with code needs_admin and says, in the
  reader's language, what needs an administrator and what to do: try
  again and allow it, or run the command in a terminal opened as
  administrator, and for npm also moving npm's prefix
  (npm config set prefix "%APPDATA%\npm") and reinstalling.
- Install another agent: its npm commands note when npm's prefix
  (npm prefix -g, memoized) is such a folder.
- Checked, not changed: autostart uses HKCU's Run key, no admin needed;
  magpie never runs npm uninstall; plugins install into magpie's own
  folder with bun; agent CLIs update only on a click; RTK's PATH fix
  writes HKCU's Environment and rtk init -g the user's own agent folders;
  the library's only other exec is the MCP server check.

Run:
- go test -tags nogui ./internal/agent ./internal/update ./internal/library
  (and the full ./... under the lock). TestNPMUpdateNeedsAdmin fails with
  the admin branch removed and with runAdmin bypassed;
  TestRTKUpgradeAsksForAdmin and TestRTKInstallRetriesAsAdmin fail with
  runRTKInstaller never elevating (checked by hand).
- gofmt -l; go vet (darwin), GOOS=linux and GOOS=windows go vet.
- GUI, Chromium and WebKit: cli-update-admin (en, zh), library-rtk-admin
  (en, zh exact; ja, de, zh-TW translated, no npm advice; fails with the
  old Upgrade title), library-rtk-upgrade/-path/-nohook/-gain, gui-ja,
  gui-de, gui-zh-tw, cli-update, i18n-keys.
- Windows box (10.0.0.132): TestWritableSeesDeniedFolder passes, and fails
  on the old writable(). A portable Node 22 with Program Files' ACL
  (Users RX, Administrators F): as a non-elevated token (runas
  /trustlevel:0x20000) npm install -g failed with the reporter's EPERM,
  Writable said false, and dsh's CLI() said Via npm, Admin true; elevated
  it said Admin false. RunElevated from the elevated ssh session installed
  @deepseek-ai/dsh into that folder for real, and a missing version came
  back as exit status 1 with npm's ETARGET output. The library's RTK tests
  ran there too (TestRTKInstallRetriesAsAdmin passes; the shell-fake ones
  skip on Windows).
- Not tried: the UAC prompt itself, allowing or declining it, as nobody
  sits at the box; the ErrNoAdmin path on a real system; a real
  machine-scope winget RTK (none is installed on the box).
2026-10-11 05:33:23 +08:00
yetone 81cf081f04 proc: a test that empties PATH means a machine without the tool, not one with Homebrew's (#1525, BUKOWSKIREAL)
TestFindTakesTheMachinesOwnFirst, TestClaudeSubscriptionRunsTheDownloadedClaudeCode
and TestClaudeSubscriptionWithoutClaudeCodeSaysHowToGetIt set PATH to an
empty folder to stand for a machine with no Claude Code, but
proc.FindTool falls back to proc.UserBinDirs, which lists the machine's
own /opt/homebrew/bin and /usr/local/bin. A Mac with
/opt/homebrew/bin/claude made Find() return it instead of the download.

proc.SystemDirs now gives every path of the machine's own that discovery
looks in. Outside tests it gives them as they are. In a test binary
testenv isolated (MAGPIE_TEST_SANDBOX set), each one is under the test's
home, at <home>/system/<path>, so the tests decide what is installed
there. The same leak was in the sibling finders, which now go through
it too:
- proc.UserBinDirs (Homebrew, /usr/local/bin), used by FindTool, the
  agents' install check (proc.FindTool(a.Bin) in internal/agent) and codexExecutable;
- FindTool's and nodeHere's Windows fallback to the registry PATH and
  %ProgramFiles%\nodejs;
- KiroExecutable, CursorExecutable and DevinExecutable's /usr/local/bin,
  /opt/homebrew/bin and /Applications/Kiro CLI.app paths.
Production discovery doesn't change.

Not changed: update's and rtk's choice of a PATH folder to link into
(they only take a folder already on PATH, which the test sets) and
FindShell (a test that runs a shell needs the real one).

Reproduced on this Mac, which has /opt/homebrew/bin/gemini, npm, node and
opencode but no claude there: under testenv with PATH emptied,
FindTool("gemini") gave /opt/homebrew/bin/gemini. The new
TestSystemDirsLieInTheTestsHome checks that no tool is found with an
empty PATH, and that a claude put at SystemDirs("/opt/homebrew/bin") in
the test's home is still found. Making SystemDirs return its paths
unchanged turns it red (gemini, npm, node and opencode found on the
host).

Run: go test -tags nogui -count=1 ./internal/proc ./internal/claudecode
./internal/provider ./internal/agent . (all ok); the three tests from
the issue -run by name in ./internal/claudecode ./internal/gateway (pass);
gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on the touched
packages.
2026-10-11 00:52:57 +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 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
TryWorld f24ee8b06d fix(agent): installs without Node ask for it the way that works (#774)
* fix(agent): installs without Node ask for it the way that works

The commands that install Node first, for a machine without it (#727),
failed in ways that say nothing about the real problem.

On a Mac or Linux, `curl -o- … | bash` keeps going when the download
fails: a pipe's status is the last command's, so blocked or 404'd
(raw.githubusercontent.com is commonly unreachable), bash reads nothing,
still exits 0, and the user is told `nvm.sh: No such file or directory`
— the network's fault told as a missing file. The vendor commands beside
it all curl with -f (install.go's own scripts do); this one now does too,
so a failed download stops the line with curl's own words.

On Windows, winget asks to accept the msstore source's agreements the
first time it runs, which waits for input a copy-pasted command can't
give: Node isn't installed, and npm.cmd isn't found. The command now
carries --accept-source-agreements and --accept-package-agreements, the
flags Microsoft documents for unattended installs; they are idempotent
where the source is already accepted.

TestInstallCommandsWithoutNode expects the two commands as they now
stand, and fails on the old ones ("curl -o- …" and the winget line
without the flags, on darwin, linux and windows alike);
TestInstallWithoutNodeParses still reads each line with `bash -n`.
Validation on Windows: go test ./internal/agent under a temp HOME leaves
the three Unix-only failures the base commit leaves (TestCodexStaleOnly
ForMagpiesChange, TestSuffixModesReachAgentFiles, TestWSLProbeScript
SaysWhere); go vet ./internal/... and the darwin, linux and windows
builds pass.

* fix(agent): a failed Node download stops the line where it failed

yetone's review of the first cut: `curl -fsSL … | bash` doesn't stop at a
failed download either, and my claim that -f alone fixes it was wrong — a
pipe's status is the shell's, bash reading nothing exits 0, and the &&
chain goes on to source nvm.sh, which reports the missing file exactly as
before. Reproduced against a 404 server on this machine: `curl: (22) …
404` then `bash: …/.nvm/nvm.sh: No such file or directory`.

The command downloads to a file now and runs that: a failed download ends
the chain at curl, with curl's own words about why. pipefail isn't an
option — the line is pasted into the user's own shell, and not every one
of them sets it.

TestInstallWithoutNodeStopsWhenTheDownloadFails runs the real line,
against a local 404 server with a temporary HOME, on each POSIX shell
here: the old line failed with the download's error *and* nvm.sh missing,
the new one stops at curl's own error and never mentions nvm.sh. It is
skipped where there is no curl. TestInstallCommandsWithoutNode expects
the line as it now stands.

Validation on Windows: go test ./internal/agent under a temp HOME leaves
the three Unix-only failures the base commit leaves (TestCodexStaleOnly
ForMagpiesChange, TestSuffixModesReachAgentFiles, TestWSLProbeScript
SaysWhere); go vet ./internal/..., the darwin, GOOS=linux and GOOS=windows
builds pass.
2026-10-04 19:49:29 +08:00
yetone d51d314ac5 agent: with no Node.js on the machine, Install another agent's npm commands install Node first, in the same line (#727, Sun1090 on v0.1.801: "没写curl的命令… curl xxx && npm xxxx", confirmed as option 1 — Pi, Copilot CLI, Crush and the rest had only npm install -g …, which a new machine without Node can't run) — installCommands now takes whether npm is here (nodeHere: exec.LookPath("npm"), then the folders proc.UserBinDirs knows — nvm's, fnm's, mise's, volta's, Homebrew's, the ~/.npmrc prefix — and on Windows also the registry's PATH (proc.LoginPath) and %ProgramFiles%\nodejs; npm.cmd there), and where it isn't, npmInstall gives on a Mac or Linux export NVM_DIR="$HOME/.nvm" && mkdir -p "$NVM_DIR" && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash && . "$NVM_DIR/nvm.sh" && nvm install --lts && npm install -g <pkg> (nodejs.org's nvm route; NVM_DIR is set because the installer goes by $XDG_CONFIG_HOME/nvm when that is set, and nvm.sh is read in the same shell since the profile line only reaches new terminals; nvm's Node is the user's, so no sudo), and on Windows, for PowerShell, winget install -e --id OpenJS.NodeJS.LTS; $env:Path = <Machine + User Path from the registry>; npm.cmd install -g <pkg> (";" as Windows PowerShell 5.1 has no "&&", PATH re-read since the MSI only adds Node to new terminals, npm.cmd since npm.ps1 is refused under the default execution policy). Each such command carries node (nvm, nvm-mac or winget); the row labels it "Node.js + npm" and the note says the npm commands install Node with nvm/winget first — on a Mac that nvm's installer stops without Xcode's Command Line Tools (run xcode-select --install), on Windows to run them in PowerShell and open a new terminal if npm still isn't found. With Node here everything is as before. magpie still only shows commands to copy (the list never had a one-click install; the page's Update all/update pill run only for CLIs already installed, unchanged). The via column is 84px so "Node.js + npm" stays on one line. TestInstallCommandsWithoutNode (Pi on darwin/linux/windows, Claude's installer untouched, npm alone with Node), TestNpmIn and TestInstallWithoutNodeParses (bash/zsh/sh -n read the line) are new; agent-update-all.test.cjs gains "no Node.js here" (label, note with/without Xcode, the whole line copied, no sideways scroll, winget note in Chinese) and passes in WebKit (8 tests). go vet ./internal/..., builds (darwin, GOOS=linux -tags nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass but for TestCursorSignInJoinsAWrappedLink, which timed out under load and passes alone. Nothing was installed: the commands were only parsed, not run, and not tried on a machine without Node. 2026-10-04 10:13:55 +08:00
yetone e85886c760 gui: the Agents page updates every agent's CLI at once, and lists the agents not on this machine with their vendors' install commands (#727, Sun1090: on a new machine with no agent installed magpie gave no install commands or how-to, and agents updated only one at a time, where cc-switch has both) — Update all: with two or more CLIs behind (#202's cliInfo update), a line above the list says which and offers Update all, which runs the existing per-agent update (POST /api/agents/cli/{id}, updateCLI, now returning why it failed and quiet for the run) for each, one after another (two global npm installs at once can trip over each other's folders), each row's pill busy in its turn, then says how it went ("2 of 3 agents updated · 1 didn't: Gemini CLI", the errors in its tooltip and the status pill). Once shown the line stays until the agents are read again (load), saying what is left ("Crush has an update", "Every agent is up to date"), so neither its click nor a row's own pill moves the list under the reader. Install: agent.Installs (internal/agent/install.go) lists the agents magpie knows that aren't detected (not WSL twins) with their commands: the vendor's installer first where its docs give one (Claude Code's claude.ai/install.sh, install.ps1 on Windows; Codex's chatgpt.com/codex/install.sh, install.ps1, and brew --cask codex on a Mac; OpenCode's opencode.ai/install; Gemini CLI's brew formula), then npm install -g of the package cliSpecs already updates from (pi, omp, copilot, crush, cline, omo too); GET /api/agents/install serves it. Under the list, "Install another agent (n)" unrolls them (open when no agent is here at all), each command with a copy button and a note that npm needs Node.js and magpie lists the agent once installed. magpie doesn't run the installs: a new machine may have no Node.js or Homebrew yet and the update machinery derives its command from where an installed binary is, so the commands are to copy. zh strings for every new one. TestInstallCommands and TestInstallsOnlyMissing pass; agent-update-all.test.cjs (webkit: Update all runs three in order never two at once, a failure named, the page and list not moved, a row's own pill leaves the line in place, one behind gets no Update all, the install list folded under the list without the installed Codex, copy sends the command, open with no agents, Chinese) passes and fails on the old code. Webkit agent-connect, agent-connected-unfolded, agent-disconnect, agent-grip, agent-layout, agent-tweak-fold, click-scroll, copy-command, show-unset-agent, panel-fold, cli-behind pass; cli-update's tight-row subtest fails the same on the old code. go vet ./internal/..., go build -tags nogui ./..., GOOS=windows and GOOS=linux builds pass; the full go test under a temp HOME was not run here (the sandbox refused the HOME override) — internal/agent's install/version tests and internal/gui's asset tests pass. Not tried in the reporter's app. 2026-10-04 07:58:09 +08:00