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.
The reporter clicked Update all. npm 11.19.0 ran
`npm install -g --prefix /opt/homebrew @anthropic-ai/claude-code@latest`,
logged "reify failed optional dependency …claude-code-darwin-arm64" and
exited 0. Claude Code 2.1.299's postinstall soft-fails without its native
package, so bin/claude.exe was left as the stub that says "Error: claude
native binary not installed." and exits 1. UpdateCLI saw npm succeed and
read the new version from package.json (proc.Version never runs an npm
CLI), so the update was reported as done.
Now, after an update that succeeds, UpdateCLI runs `<cli> --version` once
(runsBroken). It uses a 30s timeout, the update's env (npm's folder first
on PATH) and no stdin. Only a run that exits non-zero and prints no version
counts as broken. A run that didn't start, timed out, or exited 127
(interpreter not found) is unknown, not broken.
- npm installs that magpie runs as the user: the version just installed is
installed once more with --include=optional, which is how the reporter
mended theirs, and the check runs again.
- npm installs needing administrator rights get no second prompt.
- If the CLI still fails, or it was installed some other way (bun, pnpm,
brew, self), the update fails. The message carries what the CLI said and
how to reinstall it, e.g. `npm install -g --prefix /opt/homebrew
@anthropic-ai/claude-code@2.1.299 --include=optional`.
Both Update all and a row's Update pill go through UpdateCLI, so both are
covered. The GUI already shows an update's error, so it is unchanged.
What was run:
- TestUpdateCLIChecksItRuns: a fake Homebrew prefix with Claude Code's
package and the stub as the reporter found them. It covers the update
mended by the second install, a working update that runs nothing more,
and an update left broken that fails with the reinstall command. With
the check disabled it fails ("not mended: <nil>").
- TestRunsBrokenOnlyWhenSure: a version said with a non-zero exit, exit 127
and a silent exit 0 are not broken.
- gofmt -l; go vet for darwin, linux (nogui) and windows.
- go test ./internal/agent/ -timeout 45m passes (856s). The first run hit
the default 10m timeout at load ~290 while in TestOmo, with no failure.
- go test ./internal/proc/ passes, TestNoCommandBypassesProc included.
Not tried: a real npm install that drops the native package, and Windows,
where the new tests skip because their CLIs are shell scripts.