feat: first-class OpenCode integration via a local plugin#156
Merged
Conversation
OpenCode has no shell-hook config; its extension surface is a JS plugin. A small local plugin (embedded in the CLI, installed to OPENCODE_CONFIG_DIR/plugins/programa.js, else ~/.config/opencode/plugins/) shells out to programa opencode-hook at five lifecycle points: plugin boot (session-start), chat.message (prompt-submit), session.idle (stop), permission.asked (notification), dispose (session-end). Every call is quiet().nothrow() so a CLI hiccup can never take down the user's OpenCode session. No opencode.json edit, no npm install. - opencode-hook handler mirrors codex-hook: PID keys opencode/opencode.<sessionId>, Running/Needs-input statuses, completion + attention notifications, guaranteed session-end cleanup. Mirrors codex-hook's quiet-on-missing-socket guard (claude-hook, verified, has no such guard and exits 1 there). - programa opencode install-integration / uninstall-integration with the house diff+confirm pattern. Uninstall refuses to delete the file if the managed-by marker is missing (a user-customized file is never destroyed). - Install OpenCode Integration... menubar item, en+ja strings. - tests_v2/test_opencode_install_integration.py: 6 tests including the marker-refusal path and modified-file restore. Verified: build green; all 6 CLI tests pass against the built binary.
This was referenced Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Completes #139: OpenCode gets the same first-class treatment as Claude Code and Codex. OpenCode sessions now register with Programa, show Running and "Needs input" status in the sidebar, send completion and attention notifications, and clean up properly when the session ends. Installed the same way as the others: "Install OpenCode Integration…" in the File menu (or
programa opencode install-integration), which shows exactly what will be written and asks first.Closes #139.
Summary
~/.config/opencode/plugins/programa.js(respectsOPENCODE_CONFIG_DIR). Local plugin files auto-load: noopencode.jsonedit, no npm install — simpler than the existingomomachinery. Design validated against opencode.ai docs and sst/opencode source; event mapping: plugin boot → session-start,chat.message→ prompt-submit,session.idle→ stop,permission.asked→ needs-input,dispose→ session-end..quiet().nothrow()— a programa CLI failure can never crash the user's OpenCode session.programa opencode-hookmirrors the codex handler:opencode/opencode.<sessionId>PID keys, statuses, notifications, guaranteed session-end cleanup. It deliberately mirrors codex-hook's quiet-on-missing-socket guard; verification showed claude-hook lacks that guard and exits 1, so codex's is the pattern that matches the plugin's fire-and-forget contract.session.idleandpermission.askedcan fire close together; status application is idempotent like the other agents' handlers, so no dedupe machinery was added.Test Plan
tests_v2/test_opencode_install_integration.py6/6 against the built CLI, no app required (fresh install, idempotent reinstall, modified-file diff + restore, uninstall delete, marker-refusal with file intact, decline-untouched)