feat(harness): add opencode hook bridge plugin and dialect - #1365
Open
ptone wants to merge 2 commits into
Open
Conversation
added 2 commits
August 29, 2026 14:37
Add a Scion hook bridge for the OpenCode harness, enabling hook-based event visibility (status, logging, hub, limits, telemetry) for OpenCode agents. Three changes: - Plugin (scion-bridge.js): ESM module loaded by OpenCode at startup. Subscribes to session, tool, message, permission, and error events, piping each as JSON to `sciontool hook --dialect=opencode`. Uses node child_process.execSync (no bun dependency). All calls are best-effort with try/catch to never crash the plugin. - Dialect (dialect.yaml): Data-driven mapping from OpenCode plugin event names to normalized Scion events. Covers 8 of 12 non-internal scion events; unmapped: agent-start, subagent-end, response-complete, model-start (no OpenCode hooks available). - Config update: max_turns upgraded to "yes", max_model_calls to "partial" (message.updated proxies model-end; no model-start hook).
Address R1 review findings on PR #1365: - R1 (Required): Add 500ms debounce to message.updated handler to prevent per-chunk firing during streaming, which caused execSync blocking and inflated model-end counts - O2 (Optional): Add conditional debug logging (SCION_HOOK_DEBUG) to catch block instead of silently swallowing errors - O3 (Optional): Add comment documenting field name assumptions and opencode plugin API version basis - O1 (Optional): Skipped — Go test changes deferred as follow-up to avoid CI risk from unrelated build issues
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.
Summary
harnesses/opencode/home/.config/opencode/plugins/scion-bridge.js): ESM module that subscribes to OpenCode lifecycle events (session, tool, message, permission, error) and pipes JSON payloads tosciontool hook --dialect=opencode. Usesnode:child_process.execSync(no bun dependency). All calls are best-effort with try/catch.harnesses/opencode/dialect.yaml): Data-driven mapping from 8 OpenCode plugin events to normalized Scion events (session-start, session-end, agent-end, tool-start, tool-end, model-end, notification, prompt-submit).harnesses/opencode/config.yaml): Upgradesmax_turnstoyesandmax_model_callstopartial(message.updated proxies model-end; no model-start hook available).Event Coverage
Test plan
python3 -c "import yaml; yaml.safe_load(open('harnesses/opencode/dialect.yaml'))"python3 -c "import yaml; yaml.safe_load(open('harnesses/opencode/config.yaml'))"node --checkwith.mjsextension ornode -efallbackLoadMappingDialect/DiscoverMappingDialectsciontool hook --dialect=opencode