What changed: an opencode 1.19.0 that its own installer put at
~/.opencode/bin/opencode (method curl) asks GitHub's API
GET /repos/anomalyco/opencode/releases/latest for the newest release before
installing. That request carries no token, so it spends the 60 an hour GitHub
answers an address without one. Once those are spent the answer is a 403 and
the update stops before its installer runs (ggbdpq: "opencode upgrade: ...
403 GET https://api.github.com/repos/anomalyco/opencode/releases/latest").
cliSpec gains target, for a CLI whose own updater takes the version to
install, and opencode sets it. When opencode's own updater is what runs
(via "self"), UpdateCLI appends the version it already knows, the row's
Latest from npm's opencode-ai, if that is newer than the installed one.
The run is then "opencode upgrade 1.19.3". In opencode's source
(packages/cli/src/commands/handlers/upgrade.ts) a given target skips
latest(), and the curl method passes it to the installer as --version. A
stale npm answer appends nothing (Newer), so an update can never become a
downgrade. When the lookup fails, the command stays "opencode upgrade".
Changed in review: the patch as sent appended the version for every
install method. An opencode installed by npm, bun, pnpm or brew then ran
`npm install -g --prefix P opencode-ai@latest 1.19.3`, which also asks npm
to install a package named "1.19.3", or `brew upgrade opencode 1.19.3`.
The append is now limited to via "self". TestUpdateCLIOpenCodeByNpmTakesNoVersion
(npm prefix install) guards it. The target comment no longer says 1.19.3
asks npm: opencode's current source asks opencode.ai.
Run:
- Breaks: without the via guard (the patch as sent),
TestUpdateCLIOpenCodeByNpmTakesNoVersion fails with "ran [[.../npm install
-g --prefix ... opencode-ai@latest 1.19.3]]". Without the target block,
TestUpdateCLIOpenCodeTakesVersion fails at cliupdate_test.go:411 with
`ran [[".../bin/opencode" "upgrade"]]`. Both pass restored.
- gofmt -l clean; go vet darwin, linux (nogui) and windows ok; go build
for all three ok.
- Full `go test -tags nogui -timeout 45m ./...` on origin/main d783df46c +
this: every package ok except internal/agent and internal/gateway, which
hit 45m mid-test under a load average of about 200, and internal/gui's
TestSetAnswersWhileDevinAndProvidersHang (10.8s, filed as #1375, output
added there). Rerun of agent, gateway and gui with -timeout 120m: all
three ok (4061s, 3393s, 564s). After the comment-only edit, `go test
./internal/agent -run TestUpdateCLI` passed again.
Not tried: a real opencode 1.19.0 update against GitHub's rate limit.
Co-authored-by: yetone <yetone@users.noreply.github.com>