Skip to content

Automations for OpenCode: a thin TS plugin that calls secfoo hook #250

Backlog

Description

@vsn411

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 a plugins array in opencode.json(c).
  • Hooks: tool hooks (execute.before, execute.after), session hooks, a permission hook (evaluate), shell create.before, and others.
    • ⚠️ The older V1 docs and many blog posts use event names like session.idle, file.edited and tool.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(...) and ctx.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.

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 opencode adapter (PR fix(agents): verify opencode 2.3.0 adapter against real CLI (#116) #207) runs opencode run --pure for nested reviews. Check whether --pure skips 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 eval anything 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), disable removes 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.

Activity

  1. added
    enhancement
    help wanted
    difficulty: medium
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: mediumenhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions