Repository navigation
fix(ai-hook): support OpenCode v2 plugin lifecycle - #298
Conversation
Use a single default definition with V1.18.29+ server and V2 setup entries. Adapt durable V2 execution and permission events to the existing bridge, including unlocated session events. Keep serialized, bounded, shell-free helper delivery and dispose owned subscriptions and processes. Add regression coverage and Node/Bun CI on Linux, Windows and macOS. Fixes Kuddev#297
Kuddev
left a comment
There was a problem hiding this comment.
Review 结论:未发现阻塞项。已核对 OpenCode v1.18.29 的 server 入口、v2.0.18 默认导出校验/事件 schema/按 location 路由,检查单一导出、turn 去重、permission 上下文、无 shell 的 helper 调用、3 秒超时与独立 watchdog、AbortController/计时器/订阅清理。现有串行发送和最多 512 个会话的边界保留;没有新增 Pebrel 常驻线程、轮询或终端绘制开销。已在隔离 worktree 的本次精确 head 上运行 node --test scripts/tests/opencode-notification-bridge.test.mjs:Node 24.13.0,18/18 通过,含真实 helper 进程参数往返。Bun/Node 22 和其他平台结果以 PR CI 为准;未重跑完整 OpenCode UI/SSH 端到端。合并前仍需在最新 main 上通过全部必需检查。
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Fix the subscription API usage and undefined test helper, align the test double, and add the required architecture note.
Review effort: Lite
Findings: 2
Open (3)
What changed in this PR
Adds OpenCode V2 plugin lifecycle support while preserving V1 compatibility.
Changes:
- Adds dual-version plugin exports and event translation.
- Improves subprocess cancellation and cleanup.
- Adds Node/Bun regression tests and cross-platform CI.
| File | Summary |
|---|---|
scripts/tests/opencode-notification-bridge.test.mjs |
V1/V2 lifecycle and helper regression tests |
nebula_app/res/hooks/opencode.js |
Dual-version bridge and lifecycle handling |
.github/workflows/opencode-bridge.yml |
Node/Bun tests across platforms |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Kuddev
left a comment
There was a problem hiding this comment.
Verified the V2 default plugin definition and single-argument event.subscribe API against the official OpenCode v2.0.18 sources. Reviewed the shared V1/V2 adapter, serialized helper delivery, timeout and cleanup ownership. All 18 Node bridge regressions pass locally, including the real helper process and literal argument delivery.


Result / 用户结果
Fixes #297.
The generated OpenCode bridge now exposes the default plugin definition required by V2. Its setup adapter translates V2 execution, permission, tool and deletion events into the existing Pebrel notification lifecycle. The V1 implementation remains available through server for OpenCode 1.18.29 and newer.
The failure is confirmed against upstream d60ac70: the installed source has no default export, whereas OpenCode v2.0.18's loader requires default.id and default.setup or default.effect. A real ESM-import regression fails on that source and passes after this change.
Design / 设计边界
Evidence / 验证依据
References: OpenCode migration guide, v2.0.18 loader, V2 session events, V2 bus routing, v2.0.18 event.subscribe signature.
Required Review / 必须确认
These checks do not replace maintainer review or the upstream native CI results. Post-sync snapshot for head
241ede06d7446242036efa3455cd86df032f857c(base77e6470a9d1c938b9ee044df90f5524bf6d0d505):pr-sizepassed;architecture-contracts,lint, and the Linux, Windows, and macOS OpenCode bridge jobs were pending. Native Tests jobs were not reported in this snapshot. See live PR checks.AI assistance for this review and follow-up: GPT-6 Luna (max reasoning effort). Earlier implementation model metadata is unavailable in this continuation.