Repository navigation
Backlog
Labels
difficulty: mediumLeaderboard: 6 points when the PR closing this is mergedenhancementNew feature or requesthelp wantedExtra attention is needed
Description
Part of #240. Builds on #242 and #241. Related: PR #207 (OpenCode adapter), #227 (OpenCode row).
What OpenCode offers (checked against the docs on 2026-12-03)
Sources: Plugins, Build plugins, Server plugin hooks.
OpenCode has no JSON hook config. Automations are JS/TS plugins.
- Locations:
.opencode/plugins/(project, auto-discovered),~/.config/opencode/plugins/(global), or apluginsarray inopencode.json(c). - Hooks: tool hooks (
execute.before,execute.after), session hooks, a permission hook (evaluate), shellcreate.before, and others.⚠️ The older V1 docs and many blog posts use event names likesession.idle,file.editedandtool.execute.after. The current docs use a different hook layout. Check the installed version's docs and record it. The shim must target the current API.
- Talking back to the session:
ctx.session.prompt({sessionID, text}),ctx.session.synthetic(...)andctx.session.command(...). This is how findings go back to the agent.
Design
Ship a thin plugin, for example @secfoo/opencode-plugin, or a single file that secfoo automations enable --tool opencode drops into .opencode/plugins/secfoo.ts.
- It spawns
secfoo hook <recipe> --host opencodewith no shell (spawnwith an argv array), passing a JSON event on stdin. - It then applies the JSON result: block the tool, or inject a message.
- All logic stays in Python (
secfoo hook+secfoo automations: one tested entrypoint for every AI tool, recipes enabled on the fly #242). The plugin only maps events.
Recipe mapping
| Recipe | OpenCode hook | Behaviour |
|---|---|---|
commit-guard |
tool execute.before on the shell/bash tool |
Throw/deny with the findings summary |
turn-review |
session idle/complete hook (name per current docs) | ctx.session.prompt with findings, loop-guarded |
dependency-watch etc. |
tool execute.after on edit/write tools |
Background; inject when ready |
session-brief |
session start hook | ctx.session.synthetic with open High+ findings |
Gotchas
- secfoo's
opencodeadapter (PR fix(agents): verify opencode 2.3.0 adapter against real CLI (#116) #207) runsopencode run --purefor nested reviews. Check whether--pureskips plugins. If it doesn't, the recursion guard (SECFOO_AUTOMATION_DEPTH) must be checked in the shim before spawning. - Plugin code runs inside the user's OpenCode process. Keep it dependency-free and small, and never
evalanything from the event.
Tasks
- Determine the current plugin hook names for the installed OpenCode version (record the version)
-
hosts/opencode.py(Python side) + the TS shim + fixtures of the JSON the shim sends -
enable --tool opencode(project/global),disableremoves only our file - Optional: publish the shim to npm and document
plugins: ["@secfoo/opencode-plugin"] - Verification row: OpenCode version, recipes, portal shows
trigger.host = "opencode"
Done when
The recipes work in a real OpenCode session. The shim is tested (unit tests for the event mapping) and documented. Every run reports back.
Metadata
Metadata
Assignees
Labels
difficulty: mediumLeaderboard: 6 points when the PR closing this is mergedenhancementNew feature or requesthelp wantedExtra attention is needed
Activity