Skip to content

feat(opencode): install OpenCode v2 from GitHub releases - #288

Merged
vossiman merged 3 commits into
mainfrom
feat/opencode-v2
Nov 22, 2026
Merged

vossiman merged 3 commits into
mainfrom
feat/opencode-v2

Conversation

@vossiman

@vossiman vossiman commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • The updater installed npm opencode-ai, which only carries v1 (latest 1.19.6). v2 is published as GitHub release archives of anomalyco/opencode, on npm as @opencode/cli, and in a Homebrew tap. Owner decision: switch to v2; the blueprint chose the GitHub archives (one self-contained binary plus SHA256SUMS).
  • New lib/update-opencode.sh, modeled on the Cursor adapter:
    • Target: highest plain v2.x.y tag from the GitHub releases API, following the Link header for up to 5 pages, skipping drafts, prereleases, v1 and the repo's other tools (its "Latest" flag points at v1.19.6, so it is not used).
    • Asset: opencode-linux-{x64,arm64}, with -baseline on x64 CPUs without AVX2 and -musl on musl hosts.
    • Downloads the archive plus SHA256SUMS, refuses a checksum mismatch (new reason archive_checksum_mismatch), refuses any archive that is not exactly one regular opencode file, probes --version, then the usual integrity marker and immutable activation.
    • The binary sits at node_modules/.bin/opencode, the path npm v1 releases used, so an active managed v1 release hands over to v2 (activation only accepts a changed launcher whose executable exists in the old release).
    • A failed download keeps curl's last error in ~/.local/state/aicoding/diagnostics/opencode-download.log; the archive_download_failed reason text points there.
  • The managed OpenCode launcher (lib/runtime.sh) always exports OPENCODE_DISABLE_AUTOUPDATE=1. A bare opencode update/upgrade runs aicoding-auto-update --once, --help/-h passes through, and a version or other flag is refused without changes. The Claude launcher is byte-identical to main. The blueprint also owns "autoupdate": false in opencode.json as a fallback for launches that bypass the launcher (v1 accepts that key too).
  • Devbox image: seeds v2 from the checksum-verified release archive instead of opencode.ai/install (which installs v1 and prepends ~/.opencode/bin in .bashrc). The smoke test asserts a v2 seed and no ~/.opencode/bin. On containers from older images, the managed env.sh moves ~/.opencode/bin to the end of PATH.
  • ensure_opencode (fresh installs) calls the same adapter instead of the opencode.ai/install script, which put v1 in ~/.opencode/bin. Gated behind AICODINGSETUP_SKIP_NETWORK.
  • The OpenCode config probe runs opencode debug config --standalone on v2 (the plain command starts or reuses the shared background server) with throwaway state, cache and data dirs, OPENCODE_DB and OPENCODE_PTY_SOCKET_DIR in its scratch dir and OPENCODE_TEST_HOME dropped; plain debug config on v1; nothing offline.
  • Transcript redaction (lib/redact-sqlite.py) recognises the v2 store (session_part + session_v2) next to v1 (message + part) and scrubs both in a migrated database. Every TEXT column of the fresh 2.3.2 schema was audited and the user-content ones are scrubbed. Before this, a fresh v2 store exited 5 (unrecognised) and was never scrubbed. blob (binary, content-addressed) and OpenCode's own credentials are not rewritten.
  • Docs: README update-path table, docs/agent-release-audits.md entry.
  • Out of scope: the desktop has a hand-installed Homebrew opencode-v2 ahead of ~/.local/bin on PATH. It keeps shadowing the managed copy until it is uninstalled.

Independent review

Codex gpt-6.2-sol, effort high, review-only, on 83e508a. Both P1s were confirmed against the code by the coordinator; all findings fixed in 8347cf2:

  • P1, v1 to v2 migration fails (lib/runtime.sh only publishes a changed launcher whose executable exists in the old release, and v1 keeps it at node_modules/.bin/opencode): fixed. The v2 binary is staged at that same path. New test starts from an active npm-layout v1 release and ends with v2 active.
  • P1, transcript redaction misses v2 (session_part.data and friends, and a fresh v2 store exits 5): fixed. Schemas read from a fresh 2.3.2 store and this desktop's migrated store (schema only). Tests for fresh v2, migrated (both generations), and v1. On a real fresh 2.3.2 store, main exits 5 and this branch exits 0.
  • P2, config probe starts or reuses the shared v2 server: fixed (--standalone, isolated dirs, skipped offline; v1 rejects --standalone, so it keeps the plain command). No opencode process left behind by the probe or the suite.
  • P2, {64} in awk unsupported by older mawk: fixed (length($1) == 64 plus a non-hex check).
  • P2, archive rejection tests depend on host arch: fixed (uname stubbed to x86_64 in setup).
  • P3, a personal "update": "auto" beats autoupdate: fixed. Verified in the 2.3.2 binary that OPENCODE_DISABLE_AUTOUPDATE is checked before the update policy; the launcher exports it. README claim scoped to what is enforced.
  • P3, v2 is also on npm as @opencode/cli: fixed in docs and the ensure_opencode comment (verified @opencode/cli 2.3.2 on npm).
  • P3, GitHub API pagination: fixed (Link header, at most 5 pages, only api.github.com URLs). Test with the only v2 tag on page 2.
  • P3, no curl diagnostic for download failures: fixed (bounded log, test checks it and the reason text).

Round 2

Codex gpt-6.2-sol, effort high, review-only, on 8347cf2. The redaction, launcher and Dockerfile findings were confirmed by the coordinator; all fixed in 0e539c2:

  • P2, job.recovery and automation.state not scrubbed: fixed. Re-audited every TEXT column of a fresh 2.3.2 store (schema only) and also added session_v2.permission/idle_outcome, automation.name/last_outcome, kv.value, permission.resource, project.commands. Test: a secret in job.title, job.recovery.command and automation.state is removed and the JSON still decodes.
  • P2, the standalone config probe could open a live DB: fixed. From the 2.3.2 binary, OPENCODE_DB (absolute path wins) and OPENCODE_PTY_SOCKET_DIR now point into the scratch dir and OPENCODE_TEST_HOME is dropped. Test with an inherited absolute OPENCODE_DB.
  • P2, any opencode update/upgrade ... ran the updater: fixed. Only a bare update/upgrade runs aicoding-auto-update --once; --help/-h passes through (verified on 2.3.2: prints usage, binary unchanged); a version or other flag exits 2 with a message. Claude's launcher is byte-identical to main. Tests for both launchers.
  • P2, the image still seeded v1 via opencode.ai/install: fixed. v2 seeded from the archive with SHA256SUMS (checked locally under dash: checksum OK, opencode v2.3.2); smoke test and image test updated. env.sh moves a leftover ~/.opencode/bin to the end of PATH on older containers, with a test.
  • P3, OPENCODE_DISABLE_AUTOUPDATE could be overridden: fixed (always 1).
  • P3, checksum guidance pointed at worker.log: fixed (--once prints to the terminal, scheduled runs go to journalctl --user -u aicoding-auto-update, worker.log is only the fallback worker; same for the download reason).
  • P3, extractor tolerated any ././ entry: fixed (only a root marker that is a real directory; test covers file, link, duplicate and subdirectory cases).

Test plan

  • tests/bats/update-opencode.bats (12 tests, curl and uname stubbed): target selection, pagination, verified reuse and tamper refusal, checksum mismatch, unsafe archive, version mismatch, no v2 release, network guard, asset selection, download diagnostic, v1 to v2 migration, launcher routing upgrade
  • tests/bats/redact-sqlite.bats: 23/23 including fresh v2, migrated and v1 stores
  • Full suite: 1721/1721 ok on 0e539c2; no leaked opencode process
  • Live (on 83e508a): the adapter downloaded, verified and activated the real v2.3.2 in a throwaway HOME
  • Live: the v2 config probe with --standalone and isolated dirs passes on 2.3.2 and the v1 branch passes on 1.19.6, with no new process
  • Not verified: a real devbox moving from v1 to v2 on its next pass

🤖 Generated with Claude Code

vossiman and others added 3 commits November 22, 2026 23:12
npm opencode-ai only carries v1. The new lib/update-opencode.sh adapter
picks the newest plain v2.x.y release, verifies the archive against the
release SHA256SUMS, safely extracts the single binary, probes its version
and activates it like Cursor. Fresh installs use the same adapter instead
of the v1 install script, and the blueprint owns "autoupdate": false so
OpenCode never updates itself inside an immutable release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex review (gpt-6.2-sol) on 83e508a. The v2 binary now sits at the v1
launcher path so an active npm v1 release can hand over; transcript
redaction recognises and scrubs the v2 store; the config probe no longer
touches the shared background server; the launcher disables the v2
updater and routes update/upgrade to aicoding; release lookup follows
pagination; failed downloads keep curl's error; checksum parsing works
on mawk; asset tests no longer depend on the host arch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex review (gpt-6.2-sol) on 8347cf2. Redaction covers every
user-content TEXT column of the 2.3.2 store (job.recovery,
automation.state and others); the config probe points OPENCODE_DB and
the PTY socket dir into its scratch dir; the launcher sends only a bare
update/upgrade to aicoding, passes --help through, refuses versions and
flags, and always disables the v2 updater, with Claude's launcher left
as on main; the image seeds v2 from the checksum-verified archive
instead of the v1 installer, and env.sh moves a leftover ~/.opencode/bin
behind ~/.local/bin; reason texts name the real log locations; the
extractor accepts only a real root directory marker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vossiman
vossiman merged commit b9feb3c into main Nov 22, 2026
2 checks passed
@vossiman
vossiman deleted the feat/opencode-v2 branch November 22, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant