GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): optional plugin gate in PermissionV2 for allow→ask by thomaslwang · Pull Request #34329 · anomalyco/opencode

Conversation

@thomaslwang

@thomaslwang thomaslwang commented Jun 28, 2026

Copy link
Copy Markdown

Issue for this PR

Implements the consultation point requested in #34327.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

PermissionV2 is where every tool (bash, edit, webfetch, read, …) resolves a
permission to allow/ask/deny. A plugin today can only observe a tool call
via tool.execute.before, which runs after permission resolution and can deny
only by throwing — there's no way for a plugin to turn a would-auto-approve
call into an interactive prompt.

This adds an optional Gate service that evaluateInput consults right after the
effect resolves (and only on the non-hard-deny path). A provider can downgrade an
allow to ask/deny, or upgrade an ask to allow. It's read via
Effect.serviceOption, so PermissionV2 keeps no hard dependency on it and
the behavior is unchanged when nothing provides a Gate (the common case). The
service is defined in core and consumed in core; a host wires a provider.

Scope note: this is intentionally just the core hook point. Wiring a concrete
provider — e.g. one backed by the already-declared permission.ask plugin hook —
into PermissionV2's location-scoped runtime touches the location-service
composition, so I've left that out for maintainer guidance rather than guess at
the layering. Happy to follow up with the provider once the approach is agreed.

Motivation: I maintain an external OGR guardrails plugin that evaluates tool calls
against agent-configured rules; today it can only block (via tool.execute.before)
and a first-class ask from a plugin would let it request human confirmation.

How did you verify your code works?

tsgo --noEmit is clean for @opencode-ai/core. The change is additive and
no-op without a registered Gate (verified the serviceOption path leaves the
existing effect untouched). No existing behavior changes.

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ThinkDonk, ReduxST, zaldnoay, fredericoo, eliottness, BadBastion, and llucax reacted with thumbs up emoji ThinkDonk, ReduxST, fredericoo, and BadBastion reacted with rocket emoji
All reactions
  • 👍 7 reactions
  • 🚀 4 reactions
Thomas and others added 2 commits June 29, 2026 00:23
Thomas @claude
feat(core): optional plugin gate in PermissionV2 (allow → ask)
932de7e
Add an optional Gate service that PermissionV2 consults (via
Effect.serviceOption, so it stays a no-op with no hard dependency) right after a
permission effect resolves. A provider can downgrade a would-auto-approve
`allow` to `ask`/`deny`, or upgrade an `ask` to `allow`. Hard `deny` rules are
not routed through it.

This is the consultation point requested in anomalyco#34327; it lets a guardrails plugin
turn a would-auto-approve tool call into an interactive prompt — something
tool.execute.before cannot do (it can only throw to deny).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thomaslwang
Merge branch 'dev' into feat/permission-v2-plugin-gate
93d0136
@thomaslwang thomaslwang mentioned this pull request Jun 29, 2026
LLM-based bash command auto-approval (inspired by Claude Code "auto mode" / legacy kilo "gatekeeper") Kilo-Org/kilocode#9138
Closed
@thomaslwang

thomaslwang commented Jun 29, 2026

Copy link
Copy Markdown
Author

@jlongster gentle nudge on this one (you're assigned to the tracking issue #34327) — no rush.

Quick recap of the ask: this adds an optional Gate service in PermissionV2's evaluateInput, consulted right after the effect resolves, so a plugin can turn a would-auto-approve into an interactive ask. It's a no-op with no hard dependency when no provider is registered, so it's inert unless something opts in. The PR is honestly scoped to just the core hook point — wiring the permission.ask plugin hook through it touches core's location-service layering, which I left as a maintainer call.

Context for why it's useful: it's the one interception tool.execute.before can't do (block-only, no human prompt). I'm using it to drive a vendor-neutral guardrail layer (OpenGuardrails) — same enforcement point I'm wiring into Kilo CLI (Kilo-Org/kilocode#11619).

State: mergeable, checks green, conventional title + compliance template in place. Happy to adjust the seam (naming, where it's consulted, the provider contract) if you'd prefer a different shape.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ThinkDonk

ThinkDonk commented Jul 6, 2026

Copy link
Copy Markdown

Thanks for this — this is exactly the hook point I've been looking for.

I discovered the same gap while exploring how to build a plugin that auto-approves external_directory requests when the target is a git-managed repo (and injects git-commit reminders afterwards). #7006 describes the V1 path issue, but the V2 path was the real dead end.

One architectural suggestion: would it simplify the wiring if Gate were defined as a global-scoped service rather than location-scoped? Effect.serviceOption resolves upward through layers, so a Gate provided at the global level (in opencode's server.ts) would be visible inside evaluateInput without needing to touch the locationServices monolith or wrestle with the hoist/compile machinery. This also cleanly separates concerns: core defines the contract, opencode provides the plugin-backed implementation.

Once this merges, I'd be happy to submit the follow-up PR wiring the permission.ask plugin hook through Gate. Happy to coordinate or defer to whatever approach the maintainers prefer.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Jul 29, 2026
fix(plugin): restore permission ask hook #39442
Closed
3 of 6 tasks
@kevholmes kevholmes mentioned this pull request Jul 29, 2026
permission.ask plugin hook is defined but not triggered #7006
Closed
@github-actions github-actions Bot mentioned this pull request Aug 14, 2026
feat(permission): restore permission ask hook safely #42633
Closed
3 of 6 tasks
@WebReflection

WebReflection commented Aug 18, 2026

Copy link
Copy Markdown

any update on this? it looks like it's blocking other PRs too, happy to help moving forward if needed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BadBastion

BadBastion commented Sep 1, 2026

Copy link
Copy Markdown

Is there a path to getting this reviewed and merged?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Sep 6, 2026
fix(opencode): run the documented permission.ask plugin hook #47675
Closed
3 of 6 tasks
@llucax llucax mentioned this pull request Sep 14, 2026
Permission rules match rewritten shell commands after tool.execute.before hooks #35882
Open
1 task done
@llucax

llucax commented Sep 14, 2026

Copy link
Copy Markdown

One more use case for this gate: regex-style bash guardrails from a plugin. Today an allow returns before any plugin can intervene (https://github.com/anomalyco/opencode/blob/v1.18.30/packages/opencode/src/permission/index.ts#L84), and permission.ask is never called (#47674), so a plugin can only fail a tool call from tool.execute.before, never turn it into a prompt. With a gate, something like gh api .*--method (POST|PUT|PATCH|DELETE) → ask becomes a small plugin instead of a fork. It would also help with #35882 if the gate received the pre-hook command. Happy to test a build.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thdxr thdxr closed this Oct 10, 2026
@St0nefish St0nefish mentioned this pull request Nov 11, 2026
feat(opencode): model-gated auto-approval plugin (permission reviewer) St0nefish/agent-toolkit#241
Closed
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@thomaslwang @ThinkDonk @WebReflection @BadBastion @llucax @thdxr
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.