Skip to content

feat(opencode): one-command installer for OpenCode and context-guru - #1296

Merged
amiddavid merged 5 commits into
mainfrom
feat/opencode-one-command-installer
Nov 26, 2026
Merged

amiddavid merged 5 commits into
mainfrom
feat/opencode-one-command-installer

Conversation

@vz-ibm

@vz-ibm vz-ibm commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

This PR uses the concept of the Pi installer (#1294, in v0.7.7). Its base is main.

Behavior change: none for existing users. The release gets 3 new files. The plugin and the proxy do not change.
Data dependence: none. The installer reads version numbers and the plugin lists of OpenCode's 2 config files. It reads, asks for and stores no key. See the new row in docs/data-dependence.md.

Summary

One command installs context-guru for OpenCode, on macOS and Linux:

curl -fsSL https://github.com/rossoctl/context-guru/releases/latest/download/install-opencode.sh | bash
curl -fsSL https://github.com/rossoctl/context-guru/releases/latest/download/install-opencode.sh | bash -s uninstall

Today a user clones the repo and edits opencode.json and tui.json by hand. A second clone makes a second entry, and then 2 copies of the plugin load.

What changed

  • opencode-plugin/release/install-opencode.sh: downloads the plugin tarball, checks its SHA-256, and runs the installer. It is the same as install-pi.sh, with other names.
  • opencode-plugin/scripts/install_opencode.py: the installer.
    1. OpenCode: as the Pi installer does for Pi. Missing → it installs the latest with npm, after a yes. Older than the latest → it asks to update. It never uses sudo. The plugin is tested on 1.19.5 only, and the installer says so for another version. A pre-release counts as its release, so it is never downgraded.
    2. Consent: it says what turns on: routing, and keep-alive on the user's own login. Then it asks once (default no).
    3. Plugin: a copy goes to ~/.local/share/context-guru-opencode/plugin/, and the global opencode.json and tui.json get its entries. It removes another copy of the plugin and keeps that copy's options. Other entries stay. A JSONC file stops the install, and the installer prints the entries to add by hand.
    4. Check (optional): one test prompt in a temp folder, then the plugin's own status script.
    • Uninstall: it stops each project's proxy and removes only the entries and files it added. It removes OpenCode only when it installed OpenCode.
  • opencode-plugin/release/package.sh: builds the tarball and its SHA-256 list.
  • release.yaml: builds the tarball and attaches it with the 2 other files. .gitignore gets /opencode-dist/.
  • opencode-plugin.yaml (CI): also runs the 2 Python test files.
  • Docs: the one command comes first in docs/how-to/install-opencode-plugin.md and in the plugin README.

How it was tested

  • test_install_opencode.py: 25 tests. npm, opencode and the plugin scripts are fakes. The config files are real, in a temp HOME.
  • test_release.py: 11 tests. The bootstrap goes through bash against a local release server. They cover a SHA mismatch, unsafe names, and no terminal.
  • The 113 plugin Node tests pass. The datadep Go tests pass. Ruff is clean.
  • One real run on macOS with a temp HOME and npm folder. The real OpenCode 1.19.5 installed. The plugin loaded, and the proxy started. Uninstall removed all of ours, and no proxy process stayed. The run found 2 bugs, which are now fixed:
    • The check said "it works" when OpenCode failed.
    • Uninstall left an empty folder.

Not tested: a real model answer through the proxy (the temp HOME had no login), Linux, and the release workflow (it runs only on a tag).

Open questions

  • The latest OpenCode (1.19.6 today) is not tested with the plugin. The installer says so.

@vz-ibm
vz-ibm marked this pull request as ready for review November 23, 2026 10:42

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 2 of 2 1 of 2 fa1dd3608643 blocking

Verdict: blocking

Findings

  1. opencode-plugin/scripts/install_opencode.py:214-221 — after npm install, the installer does not check which OpenCode now runs

    • What fails: a user has OpenCode 1.17 from the official curl installer (~/.opencode/bin, first on PATH) or from Homebrew. The installer asks "Update OpenCode 1.17.0 to 1.19.5?", the user says yes, and npm puts 1.19.5 in npm's global bin. The old opencode still comes first on PATH. The same happens on a fresh install when npm's global bin is not on PATH. The installer prints "✓ OpenCode 1.19.5 updated", writes both config files, and says "start OpenCode with: opencode". That opencode cannot load the plugin (README: older 1.x is not supported). The test prompt then fails with a misleading "run: opencode auth login" hint.
    • Proof: lines 214-221 check only out.returncode of npm. Nothing calls opencode --version again. FakeShell.run (test line 69) changes its own self.opencode on npm install, so the tests assume the new version is the one on PATH.
    • Fix: after npm succeeds, run which opencode and opencode --version again. If it is missing or older than 1.18.29, stop before the consent step, and name the path that shadows it (or npm's global bin to add to PATH). Add a test where the fake shell keeps the old version after npm install.
  2. opencode-plugin/scripts/test_install_opencode.py:290 — the assertion can never fail, and the "exit 0 with Error:" rule has no test

    • What fails: assertNotIn("OpenCode goes through it", text) checks a string that no branch of finish() prints. The success text is "OpenCode answered through it" (install_opencode.py:274). If answered were wrong and the success branch ran, this test still passes. The spec (step 6) and the code comment at line 271 name a second case: opencode run prints a provider error and exits 0. No test covers it; run_fails returns exit 1, so the "Error:" not in ... part of line 272 is never driven.
    • Proof: grep of install_opencode.py for "goes through it" finds nothing. FakeShell.run (test line 79-81) has only an exit-1 failure.
    • Fix: assert assertNotIn("✓ The proxy started, and OpenCode answered", text). Add a test where opencode run exits 0 with Error: ... in stdout, and assert the "could not answer" text.
  3. docs/data-dependence/features/opencode-installer.md:10 — the row says the record lists the entries the installer removed; the code does not record them

    • What fails: the row says "It records which config files it created and which entries it removed". The design (step 5) says the same. install_plugin stores only plugin and, per file, created and had_plugin (lines 239-244). The removed entries (for example a hand-made clone entry with {"preset": "medium"}) go nowhere, and uninstall cannot put them back. CLAUDE.md asks for a correct data-dependence row; this one states a stored item that does not exist.
    • Proof: install_opencode.py:239-256 — ours is used for options and a log line, never written to self.record.
    • Fix: either record the removed entries (and say what uninstall does with them), or change the row, docs/data-dependence.md (via go run ./cmd/gen-datadep) and the design to "which config files it created and whether each had a plugin list".

Non-blocking

  • install_opencode.py:287 — uninstall calls read_configs() first. With an opencode.jsonc, or a comment added to opencode.json after install, uninstall stops before it stops any proxy or removes the plugin copy. The message then prints "To install it by hand…", which is the wrong advice for uninstall. Consider stopping proxies and removing the copy anyway, and printing the entries to remove by hand.
  • install_opencode.py:110-118, 328 — is_ours needs the file to exist. If the stable copy is gone (the user deleted ~/.local/share), uninstall leaves the stable-path entry in both configs. Matching record["plugin"] paths too would remove it.
  • install_opencode.py:229 — the consent text says "The preset is off", but line 252 carries old options such as {"preset": "medium"} onto the new entry. The text is then wrong for that user.
  • install_opencode.py:197-199 — when opencode --version fails or prints a pre-release (1.19.5-beta), version_tuple gives None. The installer then says OpenCode "is not installed", installs it with npm, and sets opencode_installed, so uninstall offers to remove it.
  • install_opencode.py:245-247 — a second install overwrites installer-backup/ with the already-changed file. Nothing reads the backup today, so this has no effect yet.

What I checked

  • The full diff, all 13 files, one commit (fa1dd360).
  • install_opencode.py line by line: install flow, the record, entry match (is_ours, tuple options), atomic writes, uninstall flow, the test-prompt check.
  • index.js stateRoot/stateDirectory (lines 76-82): the installer's state_root and project_state hash match the plugin's.
  • index.js and tui.js carry the marker opencode-context-guru (index.js:1424, tui.js:147). The plugin copy needs only index.js, tui.js, README.md; leaving out scripts/ is safe.
  • install-opencode.sh against pi-package/release/install-pi.sh: the same logic, other names. Name check, SHA-256 check, /dev/tty open check, trap cleanup.
  • package.sh: tarball content and sums format. test_release.py covers them.
  • release.yaml (build before GoReleaser, upload on tags, snapshot artifacts) and opencode-plugin.yaml (path filter opencode-plugin/** covers the new files).
  • Python 3.9 compatibility (removeprefix, missing_ok) for the macOS system python3.
  • No behavior change for the plugin or the proxy. No live tests were run (not approved).

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 1 of 2 1 of 2 fa1dd3608643 blocking

Verdict: blocking

Findings

  1. opencode-plugin/scripts/install_opencode.py:264-280 — the test prompt leaves a proxy running for a deleted temp project, for up to 24 hours

    • What fails: the user says yes to the test prompt. opencode run in the temp folder loads the plugin. The plugin starts a detached proxy for that folder (index.js:1162, spawn(..., { detached: true }), child.unref()), with --idle-exit 24h (index.js:1160). The with tempfile.TemporaryDirectory() block then deletes the folder. Nothing stops the proxy or removes <state root>/<hash>/.
    • Result: one orphan proxy process per test run stays up to 24 h. With the default 5-min-ping strategy it can also send keep-alive pings (default max 2, config/config.go:290) with the user's credential, for a conversation that nobody will continue. The consent text describes keep-alive "while you are away", not for the installer's own test.
    • Proof: finish() runs only context-guru-status (line 270). It never runs context-guru-reset. Each run uses a new random temp folder, so each run makes a new state folder and a new proxy.
    • Fix: after the status read, run sh <project_state(folder)>/context-guru-reset when it exists, and remove that state folder. Add a test that asserts the reset call for the temp project.
  2. docs/data-dependence/features/opencode-installer.md:10 and the design spec step 5 — "records ... which entries it removed" is false

    • What fails: the data-dependence row and the spec say the record lists the entries the installer removed. install_plugin() (lines 239-244) records only plugin, created and had_plugin per file. The removed entries (for example a git-clone path with its options) are printed (line 259) and then lost. The only copy is in installer-backup/, and line 247 overwrites that backup on each install, so after a second install the backup holds the installer's own output.
    • Proof: grep for a key such as removed in install_opencode.py finds nothing. test_install_replaces_a_cloned_copy_and_keeps_its_options does not check the record.
    • Fix: either record the removed entries (and keep the first backup only, for example do not overwrite an existing backup file), or correct the row and the spec. The data-dependence row is the statement the owner confirms, so it must match the code. Then rerun go run ./cmd/gen-datadep.
  3. opencode-plugin/scripts/test_install_opencode.py:290 — the assertion cannot fail, and the Error: rule has no test

    • What fails: assertNotIn("OpenCode goes through it", text) checks a string the installer never prints. The success line is "✓ The proxy started, and OpenCode answered through it." (line 274). So the test does not prove that a failed prompt is not reported as working.
    • Line 272 adds a new rule: exit code 0 with Error: in the output counts as no answer. No test covers it. FakeShell returns exit 1 for run_fails, so the Error: branch is never the deciding one.
    • Fix: assert assertNotIn("✓ The proxy started, and OpenCode answered", text) and assert the "could not answer" line. Add a case where opencode run exits 0 and prints Error: ....
  4. opencode-plugin/scripts/install_opencode.py:287 — uninstall stops on a JSONC file and prints install steps

    • What fails: uninstall() calls read_configs() first. When opencode.jsonc exists, or opencode.json / tui.json has a comment, it raises Stop with manual_steps(): "To install it by hand, add these entries ...". The user wants to remove the plugin. Uninstall does nothing: no proxy stops, the plugin copy stays, the record stays.
    • Proof: lines 190-194 and 72-79; uninstall() line 287 is before the proxy stop at line 290. A user can add a comment or a opencode.jsonc after the install, so this state is reachable.
    • Fix: in uninstall, stop the proxies first. For a file it cannot parse, print the entry to remove by hand (not the install steps), and go on with the other steps.

Non-blocking

  • write_json (line 88): mkstemp makes the temp file with mode 0600, so os.replace changes the user's opencode.json from 0644 to 0600. Copy the old mode when the file exists.
  • ensure_opencode (lines 198-221): when opencode --version prints no parsable version, installed is None. The installer then installs with npm and records opencode_installed: True, so uninstall offers to remove an OpenCode the user had before.
  • After an npm update (line 214), the installer does not run opencode --version again. If an older OpenCode from another source (Homebrew, ~/.opencode/bin) is first on PATH, the plugin still does not load and the installer says "✓ updated".
  • remove_entries finds our entries only by reading the file at the path. If the plugin copy is already gone, the stale stable-path entry stays in both config files. Matching record["plugin"] too would remove it.
  • Uninstall also removes git-clone entries the user added by hand (test_uninstall_removes_a_cloned_copy_entry_too). That conflicts with "uninstall removes only what install added" in the spec and in the how-to. Say it in the docs, or limit it.
  • The data-dependence row says the installer "reads only the proxy's up or down answer". It also prints the last 200 characters of the model's answer or error (line 268). It stores nothing, but the row could say so.
  • .github/workflows/opencode-plugin.yaml line 3 is now longer than the other comment lines (style only).

What I checked

  • CLAUDE.md rules: data-dependence row added and generated page updated; no Go change; no proxy behavior change (the release gets 3 new files).
  • Every changed line of all 13 files in eeefd62a..fa1dd360.
  • install_opencode.py against index.js: stateRoot() and stateDirectory() hashing (sha256, first 16 hex), the context-guru-status and context-guru-reset scripts, the marker opencode-context-guru, startProxy() detach and --idle-exit 24h.
  • install-opencode.sh: the SHA-256 check, the file-name checks, set -u, the tty check, the EXIT trap, the exit code pass-through.
  • package.sh: what goes into the tarball; the installer's copy skips scripts, test and release.
  • release.yaml: build before GoReleaser, upload only on v* tags, snapshot artifacts; /opencode-dist/ is in .gitignore.
  • Both Python test files, for what each test can and cannot prove. I did not run them (live tests not approved).
  • Python 3.9 compatibility (str.removeprefix, unlink(missing_ok=True)), for the macOS system python3.

vz-ibm added a commit that referenced this pull request Nov 23, 2026
- The test prompt stops its own proxy and deletes its state folder.
  OpenCode reads PWD too, so the check sets PWD to its folder; else a
  second proxy started for the installer's own folder.
- After npm, the installer runs opencode --version again. When an older
  OpenCode comes first on PATH, or none is on PATH, it stops before the
  consent step and names it.
- A version it cannot read no longer counts as "not installed".
- Uninstall stops the proxies first. A file with comments or a JSONC
  file stays unchanged; the installer names the entry to remove by hand,
  does the other steps, and exits 1.
- Uninstall also removes the recorded entry when the copy is gone.
- The consent text names a preset that an old entry carries over.
- Config writes keep the file mode.
- The tests: a failed prompt (exit 1, and exit 0 with Error:) is never
  reported as working.
- The data-dependence row, the design and the how-to say what the
  record holds, and that uninstall also removes a hand-made entry.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@vz-ibm

vz-ibm commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Replies to round 1 (fixed in d0c52f7)

Reviewer 1

  1. Test prompt leaves a proxy for 24 h: fixed. After the status read, the check runs that project's context-guru-reset and deletes its state folder. A real run also found a second proxy: OpenCode takes its project folder from PWD as well, so it started a proxy for the installer's own folder. The check now sets PWD to its folder. Real run on macOS: no state folder and no proxy process stay. Test: test_test_prompt_stops_its_own_proxy_and_removes_its_state.
  2. The row says the installer records removed entries: fixed in the docs. The row, the design and the how-to now say what the record holds, and that uninstall also removes an entry added by hand. The table is generated again.
  3. An assertion that cannot fail, and no test for Error: with exit 0: fixed. The test asserts that the success line is absent and the "could not answer" line is present, for both exit 1 and exit 0 with Error:.
  4. JSONC stops uninstall: fixed. Uninstall stops the proxies first. It does not change a file it cannot parse; it names the entry to remove by hand, does the other steps, and exits 1. Test: test_uninstall_with_a_jsonc_file_still_stops_proxies_and_removes_the_copy.

Non-blocking:

  • File mode: fixed (test_install_keeps_the_config_file_mode).
  • A version that cannot be read: fixed. It is "of an unknown version", not "not installed", so the installer does not record opencode_installed.
  • No version check after npm: fixed (see reviewer 2, item 1).
  • Stale stable-path entry: fixed. Uninstall also matches the recorded path.
  • Uninstall removes hand-made clone entries: now stated in the docs. Two copies must not load, and a clone entry left behind still routes OpenCode through context-guru.
  • The row now says that the answer's last 200 characters are shown and not stored.
  • Comment line length in opencode-plugin.yaml: left as is (style only).

Reviewer 2

  1. No check after npm install: fixed. The installer runs opencode --version again. When opencode is missing from PATH, or an older one comes first, it stops before the consent step and names the path. Test: test_an_opencode_first_on_path_that_is_still_old_stops_before_consent.
  2. Weak test: fixed (reviewer 1, item 3).
  3. Data-dependence row: fixed (reviewer 1, item 2).

Non-blocking:

  • JSONC uninstall and stale entry: fixed (above).
  • Consent text with carried options: fixed. It names the preset of the old entry (test_carried_options_with_a_preset_change_the_consent_text).
  • Unknown or pre-release version: fixed (above).
  • Backup overwrite: left as is. Nothing reads the backup, and the design now says so.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 2 of 2 2 of 2 d0c52f7610bd approve

Verdict: approve

Findings

None.

Earlier findings

Reviewer 2 (mine):

  1. No check after npm install: fixed. ensure_opencode calls opencode_version() again after npm (lines 235-243). It stops before consent when opencode is missing from PATH or older than 1.18.29, and names the path. test_an_opencode_first_on_path_that_is_still_old_stops_before_consent drives it: the fake keeps 1.17.0 after npm, and the test asserts exit 1, the path, and no config.
  2. The assertion that could not fail: fixed. The test now asserts that the success line is absent and the "could not answer" line is present. It runs for exit 1 and for exit 0 with Error: in stdout. The second case makes line 272's "Error:" not in ... the deciding check.
  3. The data-dependence row: fixed in the docs. The row file and the generated page have the same new text. The text matches the code: the record holds plugin, files.<name>.created, files.<name>.had_plugin, opencode_installed. The design and the how-to agree.

Reviewer 1:

  1. Orphan proxy after the test prompt: fixed. finish() runs context-guru-reset for the check's state folder, then removes the folder. Shell.run sets PWD to cwd, so OpenCode uses the temp folder as its project. The fake shell does not check PWD; the author reports a real macOS run for that part. I did not run it.
  2. Row text: fixed (see my item 3).
  3. Weak test: fixed (see my item 2).
  4. JSONC stops uninstall: fixed. Uninstall stops the proxies first, then handles each file on its own. A file it cannot parse goes to by_hand, the other steps run, and it exits 1. test_uninstall_with_a_jsonc_file_still_stops_proxies_and_removes_the_copy covers it.

Non-blocking items from round 1 (both reviewers): file mode, unknown version, stale stable-path entry and the consent preset are all fixed, and each has a test. The author left two items as they are: the backup overwrite (nothing reads the backup, and the design now says so) and the comment line length. I accept both.

Non-blocking

  • install_opencode.py:252 — for a file it cannot parse, the hand-removal message always names the stable path (plugin_dir() / file). The file may instead hold a clone entry, or no context-guru entry at all. The message could say "any context-guru entry, for example …".
  • install_opencode.py:253-255 — any opencode.jsonc makes every uninstall exit 1, also when that file never had a context-guru entry. A user who runs uninstall again gets exit 1 each time.
  • install_opencode.py:154-176 — when opencode --version gives text the installer cannot read (for example a dev or pre-release build), the user cannot install. The update question gets a yes, npm runs, and the second version check stops the install because it still cannot read the version. This fails closed, so it is safe. It could offer to go on when the version is unknown.
  • install_opencode.py:182-184 — the consent text takes the preset from the old entry's options. The plugin lets a per-project saved preset win over options (index.js:1105), and it treats a name it does not know as off. The text is right for the common case.

What I checked

  • Last review: round 1, fa1dd36, 2026-11-23T10:46:10Z
  • New commits read: 1 (d0c52f76 fix(opencode): the review findings on #1296)
  • Read in full: 3 reviews (2 entries with an empty body, and reviewer 1's round 1; my own round 1 is in this session), 1 comment, 0 inline comments
  • New items since my last review: the author's reply comment (2026-11-23T10:52:45Z). It answers each finding of both reviewers. I checked each claimed fix against the code and the tests (see "Earlier findings"). Reviewer 1's round-1 review (10:46:18Z) I read for the first time; I checked each of its findings in this round.
  • The full diff fa1dd360..d0c52f76: 6 files. I read install_opencode.py around every change (write_json, is_ours, Shell.run, ensure_opencode, carried_options, consent, install_plugin, finish, uninstall, remove_entries).
  • index.js effectiveSettings (option name preset), stateDirectory, and the reset script, against the new check cleanup.
  • The generated docs/data-dependence.md row is the same as the row file.
  • No behavior change in the plugin or the proxy. No live tests were run (not approved).

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 1 of 2 2 of 2 d0c52f7610bd blocking

Verdict: blocking

Findings

  1. opencode-plugin/scripts/install_opencode.py:204-215 — a pre-release OpenCode is taken as too old, and the default answer replaces it with 1.19.5
    • What fails: the user has a newer pre-release or dev build, for example opencode --version prints 1.20.0-beta.1 or 1.19.5-beta. version_tuple returns None: "1.20.0-beta.1".split(".") has 4 parts, and "5-beta".isdigit() is false. The new opencode_version() returns "of an unknown version". ensure_opencode then asks "The plugin needs OpenCode 1.18.29 or later. Update OpenCode of an unknown version to 1.19.5? [Y/n]". The default is yes. When that OpenCode came from npm, npm install -g [email protected] downgrades it. A "no" stops the install with "context-guru needs OpenCode 1.18.29 or later", which is false for this user. With no npm, the user sees "OpenCode is too old".
    • Proof: lines 63-69 (version_tuple), 204-215 (new opencode_version/ensure_opencode), yes(question, default=True). test_an_opencode_whose_version_cannot_be_read_is_not_taken_as_missing covers only the record. It answers "y" to the update and expects exit 1. No test covers a pre-release string.
    • Fix: parse the leading X.Y.Z and ignore a -suffix (for example a regex ^v?(\d+)\.(\d+)\.(\d+)), so 1.20.0-beta.1 counts as 1.20.0. For a version that is still unreadable, do not offer npm. Keep it, say the plugin needs 1.18.29 or later, and ask to go on. Or at least make the default "no" and do not say "needs" or "too old". Add a test with 1.20.0-beta.1.

Status of round-1 findings

  • Reviewer 1, finding 1 (test-prompt proxy left for 24 h): fixed. finish() runs the project's context-guru-reset, then deletes its state folder (lines 301-307). Shell.run now sets PWD to cwd, so OpenCode uses the temp folder as the project. The new test checks the reset call and that the folder is gone.
  • Reviewer 1, finding 2 (the row claims removed entries are recorded): fixed in the docs. The row, the generated page and the design now list what the record holds and say the replaced entries are not recorded. The two copies of the row text are the same.
  • Reviewer 1, finding 3 (vacuous assertion, no Error: exit-0 test): fixed. The test now asserts that the success line is absent and the "could not answer" line is present, for exit 1 and for exit 0 with Error:.
  • Reviewer 1, finding 4 (JSONC blocks uninstall): fixed. Uninstall stops the proxies first, catches Stop per file, names the entry to remove, does the other steps, and returns 1. The new test covers it.
  • Reviewer 2, finding 1 (no version check after npm): fixed. Lines 236-244 check which and --version again and stop before consent. The new test with npm_shadowed covers it. I agree with this fix.
  • Reviewer 2, findings 2 and 3: the same as my 3 and 2. Fixed.
  • Non-blocking items: file mode kept (line 88-92, tested); the recorded stable path also matches in uninstall (tested); the consent text names a carried preset (tested); the docs say uninstall removes entries added by hand. The backup overwrite is left as is. The author's reason (nothing reads the backup, the design says so) is right. The pre-release part of reviewer 2's non-blocking point is only half fixed: see finding 1.

Non-blocking

  • finish() and the shared binary: on a fresh machine the test prompt downloads the proxy. The check's context-guru-reset then runs release_shared (index.js:281-292). No other project uses the copy, so the reset deletes it. The first real OpenCode session downloads it again. This is only a second download, not a defect. Say it, or skip the release for this one reset.
  • write_json uses os.replace. When opencode.json is a symlink into a dotfiles repo, the rename replaces the link with a regular file. The dotfiles copy does not get the entry, and later edits there do not reach OpenCode. This was in round 1 code too. Consider writing to the resolved path (path.resolve()).
  • The uninstall message for an unparsable file always names the stable path. When the entry there is a git-clone path, the message names the wrong path. Naming "the entry with opencode-context-guru" would be more exact.

What I checked

  • Last review: round 1, fa1dd36, 2026-11-23T10:46:18Z
  • New commits read: 1 (d0c52f76 fix(opencode): the review findings on #1296)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review: 1 comment by vz-ibm at 2026-11-23T10:52:45Z, the replies to both round-1 reviews. I checked each reply against the code and the tests (see "Status of round-1 findings"). Reviewer 2's round-1 review (10:46:10Z) was posted before mine; I read it in full in this round.
  • The whole diff fa1dd3608643..d0c52f76 (6 files) and the code around each change in install_opencode.py.
  • index.js resetScript (lines 294-321) and RELEASE_SHARED (281-292), to check what the new reset call in finish() does.
  • version_tuple traced by hand on 1.19.5, opencode 1.19.5, 1.20.0-beta.1, 1.19.5-beta, opencode dev build.
  • The new tests, for what each one can and cannot prove. The subTest loop runs two installs in one HOME; the second install starts from the first one's record, and its assertions still hold.
  • I did not run the tests (live tests not approved).

One curl command installs context-guru for OpenCode, on macOS and
Linux. It uses the pattern of the Pi installer (#1294).

- install-opencode.sh downloads the plugin tarball from the release,
  checks its SHA-256, and runs install_opencode.py.
- The installer installs OpenCode 1.19.5 (the tested version) with npm
  when OpenCode is missing or older than 1.18.29, after a yes. It never
  uses sudo.
- It shows what turns on (routing, keep-alive on the user's own login)
  and asks once.
- It adds the plugin to the global opencode.json and tui.json, and
  removes another copy of the plugin. A JSONC file stops it, with the
  entries to add by hand.
- It asks for no key. The plugin uses OpenCode's own login.
- uninstall removes only what install added, and OpenCode only when the
  installer installed it.
- The release workflow builds and attaches the tarball, its SHA-256
  list and install-opencode.sh.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
- The test prompt stops its own proxy and deletes its state folder.
  OpenCode reads PWD too, so the check sets PWD to its folder; else a
  second proxy started for the installer's own folder.
- After npm, the installer runs opencode --version again. When an older
  OpenCode comes first on PATH, or none is on PATH, it stops before the
  consent step and names it.
- A version it cannot read no longer counts as "not installed".
- Uninstall stops the proxies first. A file with comments or a JSONC
  file stays unchanged; the installer names the entry to remove by hand,
  does the other steps, and exits 1.
- Uninstall also removes the recorded entry when the copy is gone.
- The consent text names a preset that an old entry carries over.
- Config writes keep the file mode.
- The tests: a failed prompt (exit 1, and exit 0 with Error:) is never
  reported as working.
- The data-dependence row, the design and the how-to say what the
  record holds, and that uninstall also removes a hand-made entry.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
The owner wants the same concept as the Pi installer: install the
latest release, and offer an update when the installed one is older.

- The latest version comes from npm view. A no to the update keeps an
  OpenCode of 1.18.29 or later.
- A pre-release counts as its release (1.20.0-beta.1 is 1.20.0), so it
  is never downgraded (review round 2, reviewer 1).
- A version that cannot be read never gets an npm offer. The installer
  asks to go on with it.
- No npm: a supported OpenCode stays.
- CG_OC_OPENCODE_VERSION is gone. 1.19.5 stays only in the "tested on"
  note.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@vz-ibm
vz-ibm force-pushed the feat/opencode-one-command-installer branch from d0c52f7 to b393bda Compare November 24, 2026 06:51
@vz-ibm
vz-ibm changed the base branch from feat/pi-one-command-installer to main November 24, 2026 06:52
@vz-ibm

vz-ibm commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Replies to round 2 (b393bda)

The branch is now on main. #1294 merged, and I rebased onto it.

Reviewer 1, finding 1 (a pre-release taken as too old and downgraded): fixed.

  • version_tuple reads the leading X.Y.Z and ignores a suffix, so 1.20.0-beta.1 is 1.20.0. Test: test_a_newer_pre_release_is_never_downgraded.
  • A version that the installer cannot read never gets an npm offer. The installer asks "Go on with this OpenCode?". Tests: test_an_opencode_whose_version_cannot_be_read_stays_after_a_yes and ..._and_a_no_stops.

A change of concept, by the owner's decision: the installer now installs the latest OpenCode, as the Pi installer does for Pi. It asks to update an older one. A "no" keeps an OpenCode of 1.18.29 or later. 1.19.5 stays only in the "tested on" note. CG_OC_OPENCODE_VERSION is gone. The design, the how-to and the data-dependence row say this. A real run on macOS installed 1.19.6 and then uninstalled it, and no process stayed.

Non-blocking items:

  • The check's reset deletes the shared proxy binary on a fresh machine: true. The first real session downloads it again. That is one more download, not a defect. Left as is.
  • A symlinked opencode.json becomes a regular file: true. Left for a follow-up. It is rare, and writing through the link changes a file in another repo.
  • The hand-removal message names the stable path: left as is. A clone entry is the less common case.
  • An opencode.jsonc makes each uninstall exit 1: by design. The installer cannot tell whether that file has an entry.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 1 of 2 3 of 3 b393bda6654f blocking

Verdict: blocking

Findings

  1. opencode-plugin/scripts/install_opencode.py:217-222, 241 — a broken npm registry now stops the install, also when a supported OpenCode is already there
    • What fails: the user has OpenCode 1.19.5 (from npm, Homebrew or the curl installer) and npm on PATH. npm view opencode-ai version fails: a corporate .npmrc with an expired token (E401), a blocked registry, or no network to npm. ensure_opencode calls latest_opencode() (line 241) before it looks at the installed version. That raises Stop, so the install ends with exit 1. The user cannot turn context-guru on, even though nothing needs npm.
    • The same user without npm gets "OpenCode 1.19.5 is installed" and goes on (lines 235-239). A broken npm is now worse than no npm.
    • This is new in b393bda6. At d0c52f76, a supported OpenCode returned before any npm call.
    • Proof: test_npm_that_cannot_read_the_latest_version_names_the_registry_setting pins it. FakeShell starts with opencode = "1.19.6" (a supported, installed OpenCode), and the test expects exit 1 and no config.
    • Fix: when npm view fails and the installed version is 1.18.29 or later, say that the installer cannot check for an update, name CG_OC_NPM_REGISTRY, and keep that OpenCode. Stop only when OpenCode is missing or too old. Change the test to a missing OpenCode, and add one for the supported case. install_pi.py:188-199 has the same pattern; the owner may want the same change there in a follow-up.

Status of earlier findings

  • Reviewer 1, round 2, finding 1 (pre-release taken as too old and downgraded): fixed. version_tuple (lines 64-71) reads the leading X.Y.Z with (?![.\d]). I traced 1.20.0-beta.1 → (1, 20, 0), v1.19.5 → (1, 19, 5), 1.2.3.4 → None, opencode dev build → None. An unreadable version never gets an npm offer (lines 227-233). The new tests cover both cases.
  • Reviewer 1, round 1, findings 1-4, and reviewer 2, round 1, findings 1-3: still fixed. 8b2f2fea is the same commit as d0c52f76 (git range-diff shows =). c6775b18 differs from fa1dd360 only in the rebase: the .gitignore context and the proxy version v0.7.6 → v0.7.7 in the how-to.
  • Round-2 non-blocking items that the author left as they are (the shared binary download again, the symlinked opencode.json, the stable path in the hand-removal message, exit 1 with any opencode.jsonc): I accept each reason.
  • The change to "install the latest OpenCode" is the owner's decision, as the reply comment says. I did not review whether it is right, only the code.

Non-blocking

  • Lines 254-271: an older OpenCode from Homebrew or ~/.opencode/bin that is still 1.18.29 or later. The default yes runs npm install -g, and the old one still comes first on PATH. The second check passes, because the old version is supported. The installer then says "✓ OpenCode 1.19.5 updated." That is false: npm put 1.19.6 in a second place, and 1.19.5 still runs. When now_shown is not target, say which opencode still runs and where npm put the new one.
  • Line 239 and 244: when the installed version is the tested one, tested_note is empty, so the line ends with a space ("… is installed. "). Style only.
  • test_install_opencode.py:111 still pops CG_OC_OPENCODE_VERSION, which no code reads now.

What I checked

  • Last review: round 2, d0c52f7, 2026-11-23T10:54:43Z
  • New commits read: 3 (c6775b18 feat(opencode): one-command installer for OpenCode and context-guru, the rebased fa1dd360; 8b2f2fea fix(opencode): the review findings on #1296, the rebased d0c52f76; b393bda6 feat(opencode): install the latest OpenCode, as the Pi installer does). The other commits in d0c52f76..HEAD (07afd6b9, bcd35b61, 23a4b03a, d0dea8bb, 30a80767) come from main. git diff --name-only 30a80767..HEAD shows only the 13 PR files.
  • Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-2 review (2026-11-23T10:54:26Z, approve). I read it. Its non-blocking point about an unknown version is now handled by b393bda6. Its other points match the ones the author answered.
    • The author's reply comment (2026-11-24T06:53:29Z): the rebase, the fix for my round-2 finding, the owner's "install the latest" decision, and answers to my non-blocking items. I checked each one against the code (see "Status of earlier findings").
  • git range-diff eeefd62a..d0c52f76 30a80767..8b2f2fea, to confirm that the rebase changed nothing else.
  • The whole b393bda6 diff (6 files), and install_opencode.py around ensure_opencode, latest_opencode, opencode_version and tested_note.
  • pi-package/scripts/install_pi.py:188-210, to compare with the Pi installer that the new concept copies.
  • The row file and the generated docs/data-dependence.md row have the same text, and both name the new npm view read.
  • I did not run the tests (live tests not approved).

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 2 of 2 3 of 3 b393bda6654f approve

Verdict: approve

Findings

None.

Earlier findings

  • Reviewer 1, round 2, finding 1 (a pre-release is taken as too old and downgraded): fixed. version_tuple now matches a leading X.Y.Z (re.match(r"v?(\d+)\.(\d+)\.(\d+)(?![.\d])", word)). I traced it by hand: 1.20.0-beta.1 → (1, 20, 0), opencode v1.19.5 → (1, 19, 5), 1.2.3.4 → None, opencode dev build → None. A version the installer cannot read no longer gets an npm offer. The installer asks "Go on with this OpenCode?" instead. The new tests cover the pre-release, the yes and the no.
  • All round 1 findings of both reviewers stay fixed. git range-diff shows that the rebase changed only context lines in .gitignore and the how-to (/pi-dist/, proxy v0.7.7). d0c52f76 and 8b2f2fea are the same.
  • Round 2 non-blocking items that the author left as they are: I accept each reason.
    • The reset deletes the shared binary: the cost is one more download.
    • A symlinked config becomes a regular file: rare, and it is left for a follow-up.
    • The hand-removal message names the stable path: a clone entry is the less common case.
    • Each uninstall with a opencode.jsonc exits 1: the installer cannot know what that file holds.

Non-blocking

  • install_opencode.py:217-221, 240 — when npm view fails (for example an npm registry that a firewall blocks), the install stops. This also happens when the installed OpenCode is already 1.18.29 or later. test_npm_that_cannot_read_the_latest_version_names_the_registry_setting pins this, with the default OpenCode 1.19.6. When there is no npm at all, the same OpenCode stays (line 235-237). The Pi installer does the same (install_pi.py:188-199), so this follows the owner's "same concept". A supported OpenCode could stay with a note when npm view fails.
  • install_opencode.py:241 — target drops a suffix from npm's latest (for example 1.21.0-rc.1 becomes 1.21.0). If the latest tag ever names a pre-release, npm install [email protected] asks for a version that may not exist. npm then fails with its own message, and nothing changes. Using latest as npm printed it avoids this.
  • test_install_opencode.py:111 — os.environ.pop("CG_OC_OPENCODE_VERSION", None) cleans up an environment variable that the installer no longer reads. It is an orphan from this commit.

What I checked

  • Last review: round 2, d0c52f7, 2026-11-23T10:54:26Z
  • New commits read: 3 on the PR branch after the rebase onto 30a80767.
    • c6775b18 feat(opencode): one-command installer for OpenCode and context-guru. This is the rebased fa1dd360. I compared the two with git range-diff.
    • 8b2f2fea fix(opencode): the review findings on #1296. This is the rebased d0c52f76; range-diff shows =.
    • b393bda6 feat(opencode): install the latest OpenCode, as the Pi installer does. I read it in full: 6 files.
  • Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-2 review (2026-11-23T10:54:43Z). I checked its finding 1 and its 3 non-blocking points against b393bda6 (see "Earlier findings").
    • The author's comment (2026-11-24T06:53:29Z). It replies to round 2 and names the owner's decision: install the latest OpenCode, as the Pi installer does. I checked each reply against the code and the tests. The new concept is the owner's decision, and the design, the how-to and the data-dependence row all state it.
  • ensure_opencode traced for each path: missing, too old, supported but older than the latest, latest, pre-release, unreadable version, no npm, npm view failure, npm shadowed after install. self.target is set before each use (lines 253-268).
  • install_pi.py latest_pi/ensure_pi, to compare with the "same concept".
  • The data-dependence row file text appears once, unchanged, in the generated docs/data-dependence.md.
  • No change to the plugin or the proxy. No live tests were run (not approved).

Review round 3 on #1296.

- When npm view fails (E401, a blocked registry) and OpenCode 1.18.29
  or later is installed, the installer says it cannot check for a
  newer one and keeps it. It stops only when OpenCode is missing or
  too old.
- npm install uses the latest version as npm prints it, so a
  pre-release tag keeps its suffix.
- When an older but supported OpenCode still comes first on PATH after
  npm, the installer says so, and not "updated".
- No trailing space after the "is installed." line.
- The tests no longer clean up the removed CG_OC_OPENCODE_VERSION.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@vz-ibm

vz-ibm commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Replies to round 3 (fixed in 02d0d01)

Reviewer 1, finding 1 (a broken npm registry stops the install of a supported OpenCode): fixed.

  • When npm view fails and OpenCode 1.18.29 or later is installed, the installer says that it cannot check for a newer OpenCode, names CG_OC_NPM_REGISTRY, and keeps that OpenCode. It stops only when OpenCode is missing or too old.
  • Tests: test_npm_that_cannot_read_the_latest_version_keeps_a_supported_opencode (new). ..._names_the_registry_setting now uses a missing OpenCode.
  • install_pi.py has the same pattern. That is for a follow-up PR, if the owner wants it.

Non-blocking items (both reviewers): fixed.

  • An older but supported OpenCode first on PATH after npm: the installer now says which one still runs, not "updated" (test_an_older_opencode_first_on_path_is_not_reported_as_updated).
  • npm install uses the latest version as npm prints it, with its suffix (test_the_install_uses_the_latest_version_as_npm_prints_it).
  • The trailing space is gone (test_the_tested_opencode_line_has_no_trailing_space).
  • The orphan CG_OC_OPENCODE_VERSION cleanup in the tests is gone.

A real run on macOS (OpenCode 1.19.6, install and uninstall) passes again, and no process stays.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 2 of 2 4 of 4 02d0d01632aa approve

Verdict: approve

Findings

None.

Earlier findings

  • Reviewer 1, round 3, finding 1 (a broken npm registry stops the install of a supported OpenCode): fixed. ensure_opencode catches the Stop from latest_opencode(). When the installed version is 1.18.29 or later, it says "The installer cannot check for a newer OpenCode", names CG_OC_NPM_REGISTRY, and keeps it. A missing or too-old OpenCode still stops, with "Nothing was changed." The new test ..._keeps_a_supported_opencode covers the supported case. ..._names_the_registry_setting now uses a missing OpenCode. This also fixes my round-3 non-blocking point 1.
  • My round-3 non-blocking point 2 (the suffix of latest dropped): fixed. target = latest, as npm prints it. The comparison still uses version_tuple(latest), so a final 1.21.0 against latest 1.21.0-rc.1 stays and is not downgraded. test_the_install_uses_the_latest_version_as_npm_prints_it checks [email protected].
  • My round-3 non-blocking point 3 (the orphan CG_OC_OPENCODE_VERSION cleanup): fixed. The line is gone.
  • Reviewer 1, round 3, non-blocking points:
    • An older but supported OpenCode is still first on PATH: fixed. The installer now says which opencode still runs, and does not print "updated". The new test covers it.
    • The trailing space: fixed. tested_note now starts with the space. The new test checks the exact line.
    • The orphan cleanup: fixed (see above).
  • All earlier findings of both reviewers stay fixed. This commit does not touch the code of those fixes.
  • The same npm view pattern in install_pi.py: the author leaves it for a follow-up PR. I accept that. It is outside this PR.

Non-blocking

  • install_opencode.py:278-282 — when an older but supported OpenCode still runs after the npm install, npm has put a second OpenCode in its global folder. The record does not set opencode_installed, so uninstall does not offer to remove that second copy. The message tells the user about it. This is acceptable.

What I checked

  • Last review: round 3, b393bda, 2026-11-24T06:55:17Z
  • New commits read: 1 (02d0d016 fix(opencode): a broken npm registry keeps a supported OpenCode)
  • Read in full: 6 reviews, 3 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-3 review (2026-11-24T06:55:17Z, blocking). I checked its finding 1 and its 3 non-blocking points against 02d0d016 (see "Earlier findings").
    • The author's reply comment (2026-11-24T06:57:45Z). It answers round 3 of both reviewers. I checked each claimed fix against the code and the tests. The author reports a real macOS run; I did not repeat it.
  • The full diff b393bda6..02d0d016: 3 files (the design, install_opencode.py, test_install_opencode.py). I read ensure_opencode, latest_opencode and tested_note in full after the change.
  • I traced ensure_opencode again for each path: missing, too old, supported but older, latest, a pre-release latest, an unreadable version, no npm, npm view failure with a missing, too-old or supported OpenCode, npm not on PATH, and an older OpenCode still first on PATH (unsupported and supported).
  • I checked each new test for what it can prove: the answer counts match the questions on each path, and assertIn(..., self.terminal.shown) checks the exact line.
  • The design text matches the new code.
  • No change to the plugin or the proxy. No live tests were run (not approved).

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 1 of 2 4 of 4 02d0d01632aa approve

Verdict: approve

Findings

None.

Status of earlier findings

  • Reviewer 1, round 3, finding 1 (a broken npm registry stops the install of a supported OpenCode): fixed. ensure_opencode (lines 240-248) catches the Stop from latest_opencode(). With OpenCode 1.18.29 or later, it says "cannot check for a newer OpenCode", shows npm's message with CG_OC_NPM_REGISTRY, and keeps that OpenCode. With a missing or too-old OpenCode, it stops with "Nothing was changed." The new test test_npm_that_cannot_read_the_latest_version_keeps_a_supported_opencode drives the supported case. The old test now uses a missing OpenCode. The design says the same.
  • Reviewer 1, round 3, non-blocking: all fixed.
    • Shadowed but supported OpenCode: lines 278-282 now say which opencode still runs, not "updated". test_an_older_opencode_first_on_path_is_not_reported_as_updated covers it.
    • Trailing space: tested_note now starts with the space. The test checks the exact line in terminal.shown, so it can fail.
    • The orphan CG_OC_OPENCODE_VERSION cleanup is gone. grep finds no other use.
  • Reviewer 2, round 3, non-blocking: npm view failure (the same as my finding 1), fixed. target now keeps npm's suffix (line 249). test_the_install_uses_the_latest_version_as_npm_prints_it asserts [email protected]. Fixed.
  • All findings of rounds 1 and 2 (both reviewers) stay fixed. 02d0d016 changes only ensure_opencode, latest_opencode and tested_note.
  • The follow-up for the same npm view pattern in install_pi.py is out of scope for this PR. I accept that.

Non-blocking

  • None new.

What I checked

  • Last review: round 3, b393bda, 2026-11-24T06:55:17Z
  • New commits read: 1 (02d0d016 fix(opencode): a broken npm registry keeps a supported OpenCode)
  • Read in full: 6 reviews, 3 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-3 review (2026-11-24T06:55:17Z, approve). I read it. Its three non-blocking points are fixed in 02d0d016 (see above).
    • The author's reply comment (2026-11-24T06:57:45Z). It answers my round-3 finding and the non-blocking items of both reviewers. I checked each claim against the code and the tests.
  • The whole 02d0d016 diff (3 files), and all of ensure_opencode (lines 224-283) after it.
  • ensure_opencode traced for each case. Missing: with npm, with no npm, and with a failed npm view. Too old, with a yes and a no. Supported, with a failed npm view. Latest. Pre-release. Unreadable version. After npm: opencode not on PATH, shadowed and too old, shadowed and supported. self.target is set before each use.
  • Each new test, for what it proves and whether it can fail.
  • git diff --name-only 30a80767..HEAD still shows only the 13 PR files.
  • I did not run the tests (live tests not approved).

amiddavid pushed a commit that referenced this pull request Nov 24, 2026
fix(pi): a registry that fails keeps an installed Pi

When npm view fails (E401, a blocked registry) and Pi is installed,
install-pi.sh stopped. Nothing in that case needs npm. The installer
now shows npm's message, keeps that Pi, and goes on. With no Pi, it
still stops and changes nothing.

The OpenCode installer (#1296) does the same; review round 3 there
found it.


Pi behavior change: the PR author (Vitaly) gave his yes on the PR; Pi changes are FYI to the owner (owner rule 2026-11-20). The owner (David Amid, 2026-11-24, integrator session) asked the integrator to merge the Pi set "as you see fit". Integrator check on current main + #1326 + #1330: the Pi unittest suites, the release tests and go test ./pi-package/... pass.

Assisted-By: Claude Opus 5.5
Signed-off-by: Vitaly Zabershinsky <[email protected]>
A config file that links into a dotfiles repo became a regular file:
the atomic rename replaced the link. The write now goes to the file the
link points to, so the link and the dotfiles copy both stay right.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 1 of 2 5 of 5 516276f949a9 approve

Verdict: approve

Findings

None.

Status of earlier findings

  • My round-2 non-blocking point (a symlinked opencode.json becomes a regular file): fixed in 516276f9. write_json now resolves the path with os.path.realpath before mkstemp and os.replace. The temp file is in the target's folder, so the rename stays on one file system and the link stays. The mode is read from the target. The new test test_install_writes_through_a_symlinked_config_and_keeps_the_link checks that the link stays and that the dotfiles file gets the entry. It fails on the old code, because os.replace would put a regular file in place of the link.
  • All findings of rounds 1 to 4 (both reviewers) stay fixed. This commit changes only write_json.
  • Reviewer 2's round-4 non-blocking point (npm's second copy is not in the record): I agree that this is acceptable. The message names it.

Non-blocking

  • A dangling symlink (the dotfiles file is gone): load_json sees no file, so the record says created: true. write_json then creates the target file, and its folder, in the dotfiles location. On uninstall, remove_entries calls path.unlink() on the config path. That removes the link, and the new dotfiles file stays. This is a rare case and loses no user data.

What I checked

  • Last review: round 4, 02d0d01, 2026-11-24T07:02:06Z
  • New commits read: 1 (516276f9 fix(opencode): keep a symlinked opencode.json a link)
  • Read in full: 8 reviews, 3 comments, 0 inline comments (from the three files)
  • New items since my last review: none in the conversation. Reviewer 2's round-4 review (07:02:02Z) was posted 4 seconds before mine. I read it in full in this round (see above). The newest author comment is from 06:57:45Z, and I read it in round 4. The new commit has no reply comment; its message names the fix.
  • The whole 516276f9 diff (2 files). I checked every caller of write_json: the two config files in install_plugin, remove_entries, and save_record. Each one works with a resolved path. shutil.copy2 for the backup follows the link, so the backup holds the content.
  • remove_entries with a symlinked config: write_json writes through the link. path.unlink() (only for a file the installer created) removes the link, not the target.
  • git diff --name-only 30a80767..HEAD still shows only the 13 PR files.
  • I did not run the tests (live tests not approved).

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 2 of 2 5 of 5 516276f949a9 approve

Verdict: approve

Findings

None.

Earlier findings

  • Reviewer 1, round 2, non-blocking point (a symlinked opencode.json becomes a regular file): fixed. The author first left it for a follow-up, and now fixes it in this PR. write_json resolves the path with os.path.realpath before the write. The temp file goes into the target's folder, and os.replace replaces the target, not the link. The mode check reads the target's mode. test_install_writes_through_a_symlinked_config_and_keeps_the_link checks both: the link stays a link, and the dotfiles file gets the new entry. Both assertions can fail with the old code.
  • All earlier findings of both reviewers (rounds 1 to 4) stay fixed. 516276f9 changes only write_json and adds one test.
  • My round-4 non-blocking point (a second OpenCode from npm stays after uninstall): no change. The message tells the user, so I still accept it.

Non-blocking

  • install_opencode.py:244, 368-371 — a rare case with a dangling symlink (the link exists, its target does not). At install, path.exists() is false, so the record says created: true. write_json then creates the target file in the dotfiles folder. At uninstall, when only $schema is left, path.unlink() removes the link, and the target file stays in the dotfiles folder with only $schema. No user data is lost. Checking path.is_symlink() for created would avoid it.

What I checked

  • Last review: round 4, 02d0d01, 2026-11-24T07:02:02Z
  • New commits read: 1 (516276f9 fix(opencode): keep a symlinked opencode.json a link)
  • Read in full: 8 reviews, 3 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-4 review (2026-11-24T07:02:06Z, approve, no new findings). I read it. It agrees with my round-4 status of each finding.
    • No new comment from the author after 2026-11-24T06:57:45Z. The commit message says what changed. I checked it against the code.
  • The full diff 02d0d016..516276f9: 2 files. I read write_json and each caller after the change: install_plugin (both config files), save_record (the record), and remove_entries (uninstall).
  • shutil.copy2 for the backup follows the link, so the backup holds the target's content.
  • A symlinked config folder (~/.config/opencode as a link) also resolves to the right target.
  • No change to the plugin or the proxy. No live tests were run (not approved).

@amiddavid
amiddavid merged commit 25580ca into main Nov 26, 2026
11 of 17 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 26, 2026
@amiddavid

Copy link
Copy Markdown
Collaborator

Merged as 25580ca into main, for the next release. The release workflow dry run will run as part of that release.

#1414 now targets main. Its branch still has the original #1296 commits, so the integrator is merging main into it now. The result is main plus the #1414 change only.

amiddavid added a commit that referenced this pull request Nov 26, 2026
#1296 squash-merged into main as 25580ca. The conflicts are its own
files; the result is main plus this PR's own change (516276f..66ec58e).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
amiddavid pushed a commit that referenced this pull request Nov 26, 2026
… it works (#1414)

docs(opencode): design and plan for the installer's provider setup

The installer will set up the model connection (direct, or a custom
gateway URL), start OpenCode's own login, and pass only when the proxy
counted a request. The owner approved the design on 2026-11-25.

feat(opencode): ask how the user reaches the models, before any change

The installer now says first that context-guru routes Anthropic and
OpenAI models only. The user picks a direct connection, a custom base
URL (a company gateway), or exits with no change. A gateway gets its
own provider id (anthropic-gateway or openai-gateway), so a direct
login's key never goes to it. CG_OC_GATEWAY_URL, CG_OC_API, CG_OC_MODEL
and CG_OC_SMALL_MODEL answer the questions for a scripted install.

feat(opencode): set up a gateway connection, and restore it key by key

On the gateway path the installer writes the gateway provider, its 2
models, model and small_model into opencode.json. The record keeps each
key's value from before the first install. Uninstall puts a key back
only while it still has the installer's value, so a later edit by the
user stays. A second run with the same answers changes nothing.

feat(opencode): start OpenCode's login, and undo when it cannot route

A new Login step reads `opencode auth list`. Without a login for the
provider, it runs `opencode auth login` on the user's terminal, so
OpenCode stores the key and the installer never sees it. For a
gateway it says first: pick Other, then type the gateway id, because
`-p` refuses custom ids. A failed login, or a login to a provider that
context-guru cannot route, offers to undo the install and exits 1.
Uninstall logs out only a login that the installer started.

feat(opencode): pass the check only when the proxy counted the request

The test prompt is now default yes, and it decides the exit code. It
passes only when OpenCode answered, the proxy is up, and the proxy
counted at least 1 request. Each failure names its cause: the proxy
did not start (with the log path), no answer (key, URL or model), or 0
requests (the provider is not routed). The consent text names the
connection: directly, or the gateway's host.

The test that expected "opencode auth login" when the proxy is down is
removed. That hint was wrong for gateway users (#1384); the new test
for that case expects the proxy's log path.

docs(opencode): the gateway setup, its data use, and a key canary test

The how-to guide gets the new steps and a "company gateway" section:
the questions, the gateway provider ids and why, the login's "Other"
choice, and the CG_OC_* variables. The data-dependence row names the 2
new reads (provider names from `opencode auth list`, and the proxy's
request count) and what the record keeps.

The canary test drives a fake key through install, check and
uninstall, and asserts that it is in no output, record or config file.
A version of the installer that prints OpenCode's key file fails it.

fix(opencode): refuse a key in the gateway base URL, and never echo it

A pasted base URL such as https://user:token@gw/v1, or one with a
query or fragment, went into opencode.json and the install record, and
the error text repeated it. The installer now refuses a user name,
password, query or fragment, and its messages never repeat the URL.

docs(opencode): amend the design: the installer asks the gateway key

In the owner's test, OpenCode's login menu started from the installer
showed nothing, and the menu lists no provider from opencode.json, so a
user had to pick Other and type the id. The owner picked "base URL,
then key": the installer asks for the key, checks it with the model
list, and writes it to OpenCode's own key file only.

feat(opencode): ask the gateway key, check it, and list the models

On the gateway path the installer asks: the base URL, the API format,
then the key (hidden input), with an example for each. It checks the
key with GET /v1/models, asks again when the gateway refuses it, and
lets the user pick the model and the small model from the list. The
key goes to OpenCode's own auth.json (mode 0600, other entries stay).
It is never shown, logged or recorded, and only the gateway gets it.

Also from the owner's test: the first step shows the config folder,
the consent names the choice, the direct path says what to pick in
OpenCode's list, and Ctrl-C stops with exit 130 and no traceback.

feat(opencode): an install turns context-guru on again in every project

/context-guru-uninstall leaves a marker in that project's state folder,
and a re-run of the installer never looked at it, so the project stayed
off. The owner decided: running the installer means "turn it on". After
the consent, the installer removes each marker and names the project
folders. An undo of the run puts the markers back.

feat(opencode): the installer names projects that are off, keeps them so

Owner decision (2026-11-25), which replaces b9279ce: a project where
the user ran /context-guru-uninstall stays off after a re-run of the
installer, because that was the user's choice there. The installer
names those project folders (only folders that still exist) and says
to run /context-guru-install in a project to turn it on again.

chore(opencode): mark OpenCode 1.19.6 as tested

The owner's end-to-end run on macOS passed on OpenCode 1.19.6: the
gateway install with a real key, the check through the proxy, the
uninstall inside OpenCode, and the way back with /context-guru-install.
The Linux Docker run passed on 1.19.6 too.

fix(opencode): the review findings of round 1 on #1414

- The key check does not follow a redirect: urllib copied the key
  headers to the redirect target, also over http.
- The one-upstream check also counts agent.*.model, as the plugin does.
- Uninstall and undo remove the gateway key from auth.json directly,
  instead of an unchecked `opencode auth logout`. A key that was there
  before the install stays. A symlinked auth.json stays a link.
- Ctrl-C at the direct login offers the undo, instead of "nothing more
  was changed" with the plugin on.
- A key with a control character is refused; http.client's error would
  have held the key.
- The small-model default without a haiku model is the model.

Behavior change (the installer asks how the user reaches the models; the gateway path asks for the URL and key, checks the key and lists the models; the test prompt defaults to yes) decided by the plugin owner (vz-ibm) and approved by the owner in the integrator session: "1414 and 1291 I agree on the change". Approvals at 66ec58e carried over: the merge of main after #1296 left exactly this PR's change.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants