Skip to content

fix: port the OpenCode plugin to the v2 plugin API (INC-481) - #587

Merged
arzafran merged 2 commits into
mainfrom
franco/inc-481-opencode-v2
Nov 12, 2026
Merged

arzafran merged 2 commits into
mainfrom
franco/inc-481-opencode-v2

Conversation

@arzafran

Copy link
Copy Markdown
Member

Fixes INC-481. The Programa OpenCode plugin now loads on both OpenCode 1.x (1.3.4 and later) and 2.x, and subagent sessions no longer mark the pane idle or become the session programa resume reopens.

Limit on OpenCode 2: by default, v2 runs plugins in one background service shared by every terminal, started with whichever terminal's environment launched it. A plugin there can't tell which pane a session belongs to, so on v2 the plugin only reports under opencode --standalone (or opencode service set disabled true). Otherwise it stays silent rather than reporting to the wrong pane. docs/notifications.md says so.

  • Rewrote openCodePluginJS as one default export with server (v1) and setup (v2) entry points. It calls programa through child_process, one call at a time, with errors swallowed.
  • v2 events: session.execution.started / .succeeded|.failed|.interrupted, permission.asked, session.created.
  • A subagent's permission prompt is reported on its root session. A session whose parent lookup fails is skipped, never treated as a root.

Verified: node --check passes, and a mock v1/v2 host harness passes. Live loads ran on isolated OpenCode 1.19.5 and 2.2.7 (serve --stdio): root prompt-submit and stop fire, the child is skipped, and session-end carries the root id. A plain serve makes no calls. The tagged build succeeds and the structural budgets pass.

Not verified: permission.asked with a live provider, a real TUI exit, and sidebar status against the running app.

… out of resume (INC-481)

One default export now serves both APIs: setup(ctx) for OpenCode v2 and server() for v1 (1.3.4+). v2 reports turns from session.execution.* events and only runs on a private server, since the shared background service has another terminal's environment. Child sessions no longer report turns, a subagent's permission prompt is reported on its root session, and session-end carries the last root session id (INC-301).
@arzafran
arzafran merged commit 1bc80c4 into main Nov 12, 2026
12 checks passed
@arzafran
arzafran deleted the franco/inc-481-opencode-v2 branch November 12, 2026 20:13
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