Skip to content

feat(opencode): model-gated approver plugin (permission reviewer) - #243

Merged
st0nefish-ci[bot] merged 1 commit into
masterfrom
worktree-enhancement-opencode-approver-plugin
Nov 12, 2026
Merged

st0nefish-ci[bot] merged 1 commit into
masterfrom
worktree-enhancement-opencode-approver-plugin

Conversation

@St0nefish

Copy link
Copy Markdown
Owner

Summary

New OpenCode plugin plugins-opencode/approver/: a model-gated permission reviewer built on ctx.permission.hook("evaluate").

  • A static allow/ask pre-filter handles routine calls with no model call. It handles several resources per shell action: any ask match escalates, and allow needs every resource to match.
  • Everything else is judged by a cheap model (ctx.experimental.generate.decisions) given a layered policy prompt (project .opencode/approver.md > options.prompt > user file > built-in) and the latest user message, bounded.
  • The model either lets the action through or escalates it to a human prompt. By default the plugin only ever makes a decision stricter.
  • Configurable model/tier (same modelTiers convention as session), probability threshold, onError, timeoutMs, shadow mode, JSONL audit log, subagent escalation and a headless option.
  • Hook wiring is isolated in src/hook.ts, so moving to experimental.review is a single-file change.
  • Registered in the opencode validator and plugins-opencode/README.md.

Review fixes after two review passes:

  • One deadline over the whole judged path.
  • A failed subagent lookup fails closed.
  • Resources are JSON-quoted and labelled untrusted in the judge input.
  • headless: allow never loosens a configured ask.
  • Accurate audit source labels (rule-deny, rule-ask).
  • The message window is clamped.

Test plan

  • bash tests/opencode/test-approver-core.sh (28 tests)
  • bash .github/scripts/validate-all.sh (all 7 checks; local rumdl 0.2.78 vs CI pin 0.2.69)
  • Not exercised against a live OpenCode. Shapes were checked against the published @opencode/plugin / @opencode/client 2.2.7 types only. Suggest running with shadow: true first.

Caveats

  • A project .opencode/approver.md overrides the user-level prompt, as the issue specifies, so an untrusted checkout can ship a permissive policy.
  • headless is an explicit option defaulting to prompt; the event exposes no signal to detect an unattended session.
  • With onError: allow, a hung session lookup lets a subagent action through (opt-in setting only).
  • The judge returns a probability with no reason text, so escalation messages are the generic askMessage.

Closes #241

🤖 Generated with Claude Code

A permission reviewer for OpenCode V2 built on
ctx.permission.hook("evaluate"). A static allow/ask pre-filter handles
routine calls; the rest are judged by a cheap model using a layered policy
prompt and the latest user message, and either pass or escalate to a human.

- plugins-opencode/approver: pure core (options, prompt layering, multi-
  resource pre-filter, decide, audit entry) + hook.ts as the only file that
  touches the permission hook
- configurable model/tier, threshold, onError, timeoutMs, shadow mode,
  JSONL audit log, subagent escalation, headless handling
- judge input JSON-quotes resources and labels them untrusted; one deadline
  covers the whole judged path; subagent lookup failure fails closed
- 28 unit tests; register the plugin in the opencode validator and README

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@st0nefish-ci
st0nefish-ci Bot enabled auto-merge November 12, 2026 20:32
@st0nefish-ci
st0nefish-ci Bot merged commit 4bb1a11 into master Nov 12, 2026
8 checks passed
@st0nefish-ci
st0nefish-ci Bot deleted the worktree-enhancement-opencode-approver-plugin branch November 12, 2026 20:35
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.

feat(opencode): model-gated auto-approval plugin (permission reviewer)

1 participant