Repository navigation
feat(opencode): add CLI-only v2 integration - #370
Conversation
umputun
left a comment
There was a problem hiding this comment.
one blocking issue, the rest is small. The session rules from #369 are all in the code, except that v1 stays as it was (second item).
blocking
plugins/opencode/v2/launcher.ts:66-79, tui.ts:212-233, tui.ts:340 - when a review is cancelled (new execution or agent change in the reviewed session, session.deleted, plugin unload), the plugin kills the launcher's process group and removes the temp dir. On zellij, kitty, wezterm, cmux, ghostty, iTerm2, emacs and herdr revdiff is a child of the terminal, so the pane stays open with its --output dir gone: O shows "Flush failed", quit saves to revdiff history only, nothing reaches OpenCode, and with no notes flushed before the cancel there is no alert either.
Fix: keep the invalidation and the cancel of pending lookups, but a review still running at that point should either keep its reader until it ends and then show the notes in the "not delivered" alert, or be reported at cancel time as detached with the notes recoverable from revdiff history. README lines 68 and 70 should say whichever it is. Pls add a test where the fake revdiff runs outside the launcher's process group, the current one at launcher.test.ts:171-181 execs it inside the group and can't see this.
minor
plugins/opencode/setup.sh:25-26 - the v1 install now refuses when only opencode.jsonc exists. The old script created opencode.json next to it and installed, and that works on OpenCode 1.18: the global loader merges both files and picks up plugins/*.ts on its own. Fix: drop the refusal and change the case at setup.test.ts:486-507 to "jsonc untouched, install succeeds".
plugins/opencode/v2/tui.test.ts:287-342, :355 - nothing asserts that the client which lost the claim stays silent, and first.session.agent is a field of the fake that the plugin can't change, so that check can't fail. Fix: assert empty alerts and prompts on both clients after the competing emits and after the replay.
plugins/opencode/v2/tui.ts:264 - the command returns without a message when it runs from a subagent session view. Fix: throw there, so the existing toast path reports it, plus one test case.
plugins/opencode/v2/runtimepty/main.go:81 - golangci-lint 2.14 flags errors.As here (modernize, errorsastype). CI pins 2.12.2 and won't show it. Fix: errors.AsType[*exec.ExitError](waitErr), same as app/diff/diff.go:737.
plugins/opencode/v2/tui.ts:124 - the comment says the idle marker is absent from the SDK union, but SessionMessageIdle is in SessionMessageInfo at 2.0.18. Fix: drop the comment and the local IdleMarker type.
site/llms.txt:12, :63-65 - still describes the tool call and the plan-mode exit trigger, which is v1 only. Fix: same v1/v2 split as in README.
.github/workflows/ci.yml:55-74 - setup.test.ts needs jq and the new job has no install step. Fix: copy the install jq step from the build job.
Go helper
all Go source in this repo is under app/, and plugins/opencode/v2/runtimepty is a package main outside of it. Pls move it under app/ and update the go build path in runtime-check.ts. The runtime check itself is worth keeping.
umputun
left a comment
There was a problem hiding this comment.
last round's items check out. What is left is small.
installer
plugins/opencode/setup.sh:59-61 - a v2 install stops with "Invalid opencode.json." and copies nothing when the file has a comment or a trailing comma. OpenCode v2 reads opencode.json as JSONC, so that config is valid for it. Fix: when jq can't parse the file, print the same manual-cleanup notice as the opencode.jsonc branch, naming opencode.json, and go on to the copy.
plugins/opencode/setup.sh:20 - the v1 install asks for jq before anything else, but with no opencode.json it only runs printf. The old script installed there without jq. Fix: move the check into the if [[ -f "$config_file" ]] block at line 23, and README line 7 to match.
plugins/opencode/setup.sh:54, plugins/opencode/README.md:34, :45 - "experimental server plugin" and "early experimental v2 package" describe something that was never released. Fix: say what the check found, e.g. "$target contains index.* or server.*, which OpenCode would load as a server plugin".
tests
plugins/opencode/v2/tui.test.ts:728-746, :204-220, :748-781 - these can't fail. assert.fail in the mocked review is thrown inside run(), the catch there turns it into a toast, and nothing asserts on alerts. With the parentID check in planFor removed, or the throw at tui.ts:264, all of them still pass, and :216 matches the word "subagent" from the mock's own message. Fix: count launches in the mock and assert 0, assert empty alerts in the :728 cases, match only /root session/i at :216, and drop line 772 so the abort is the only thing that stops the launch.
plugins/opencode/v2/setup.test.ts:67 - the v2 install case checks tui.ts and the two scripts only, while the file list at setup.sh:78 is hardcoded. A new module imported from tui.ts and missing from that list breaks the installed plugin with green tests. Fix: assert launcher.ts and claims.ts too.
app/opencode-runtime-pty/main_test.go:21-28 - both tests re-exec the test binary and main() runs in the child only, so the package reports 0% coverage and lowers the coveralls total. Fix: call terminalBridge.run in-process and cancel the context instead of sending SIGTERM.
other
plugins/opencode/v2/package-lock.json:2250 - http-cache-semantics 4.2.0 has GHSA-ch52-4w7c-c8xp, fixed in 4.3.0. Fix: npm update http-cache-semantics.
app/opencode-runtime-pty - every other directory under app/ is a single lowercase word. Pls rename to match and update runtime-check.ts:211 and plugins/opencode/README.md:92.
|
Thanks, addressed in f9edaa8. Installer
Tests
Go helper and dependency
|
umputun
left a comment
There was a problem hiding this comment.
lgtm, last round's items check out.
one thing left, not blocking: plugins/opencode/setup.sh:22-25 - the v1 install stops with "Invalid opencode.json or plugin array." and copies nothing when opencode.json has a comment or a trailing comma. OpenCode 1.18 reads that file as JSONC, and the old script updated the files there and left the config alone. Fix: same as the v2 branch at line 61. When jq empty fails, copy the files, skip the registration block at lines 37-46 and print a notice to make sure ./plugins/revdiff-plan-review.ts is in plugin.
up to you whether it goes in this PR, I can do it after the merge.
the v1 install stopped with "Invalid opencode.json or plugin array." and copied nothing when opencode.json had a comment or a trailing comma. OpenCode reads that file as JSONC, so the config is valid. The installer now copies the files, leaves the config byte-identical and prints a notice to check the registration by hand. A parseable config of the wrong shape still fails before any copy. also documents app/ptybridge and the OpenCode plugin in CLAUDE.md and docs/ARCHITECTURE.md. Related to #370
Summary
Adds OpenCode v2 support while retaining the existing v1 integration.
/revdiffand automatic plan review using theshared launcher in the client's terminal environment.
session.execution.succeededevents for thedisplayed root session. Local atomic claims use the event ID, with markers
older than one day removed when claiming.
reviewed snapshot with line numbers, so it does not depend on a deleted
temporary file. A clean exit sends no prompt and leaves plan mode unchanged.
/revdiffworks from both home and an existing session.V1 runtime files and shared launchers remain unchanged.
Refs #369 and #211.
Validation
session creation, automatic plan review and revision, and in-session commands.
git diff --checkpassed.The runtime fixture runs the real OpenCode CLI in a PTY with deterministic
model, terminal-control, and revdiff fixtures.
Limitations
Review ownership is local-only and at-most-once: clients must share the same
state directory, and there is no takeover after a crash. The winning client
may be in a window the user is not currently looking at.