[PR #7077] fix(permission): trigger permission.ask plugin hook in PermissionNext #12237

Closed
opened 2026-02-16 18:17:09 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7077

State: closed
Merged: No


Summary

Implements the permission.ask plugin hook that was defined but never triggered in PermissionNext.ask().

Problem

Issue #7006: Plugins cannot intercept permission requests because Plugin.trigger("permission.ask", ...) is never called in the permission system.

This prevents plugins like oh-my-opencode from implementing PreToolUse hooks for:

  • Auto-approving safe operations
  • Auto-denying restricted file patterns
  • Delegation enforcement for orchestrator agents

Solution

Add Plugin.trigger("permission.ask", info, { status: "ask" }) call in PermissionNext.ask() before showing the UI prompt:

  • If plugin returns "allow" → auto-approve (continue)
  • If plugin returns "deny" → throw DeniedError
  • If plugin returns "ask" or unchanged → proceed with existing UI prompt flow

Testing

This change follows the exact same pattern used in permission/index.ts which already has working Plugin.trigger("permission.ask", ...) integration.

Impact

  • Enables oh-my-opencode and other plugins to implement PreToolUse hooks
  • Backward compatible - no behavior change if no plugin handles the hook
  • Unblocks delegation enforcement patterns for orchestrator agents

Fixes #7006

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7077 **State:** closed **Merged:** No --- ## Summary Implements the `permission.ask` plugin hook that was defined but never triggered in `PermissionNext.ask()`. ## Problem Issue #7006: Plugins cannot intercept permission requests because `Plugin.trigger("permission.ask", ...)` is never called in the permission system. This prevents plugins like oh-my-opencode from implementing PreToolUse hooks for: - Auto-approving safe operations - Auto-denying restricted file patterns - Delegation enforcement for orchestrator agents ## Solution Add `Plugin.trigger("permission.ask", info, { status: "ask" })` call in `PermissionNext.ask()` before showing the UI prompt: - If plugin returns `"allow"` → auto-approve (continue) - If plugin returns `"deny"` → throw DeniedError - If plugin returns `"ask"` or unchanged → proceed with existing UI prompt flow ## Testing This change follows the exact same pattern used in `permission/index.ts` which already has working `Plugin.trigger("permission.ask", ...)` integration. ## Impact - Enables oh-my-opencode and other plugins to implement PreToolUse hooks - Backward compatible - no behavior change if no plugin handles the hook - Unblocks delegation enforcement patterns for orchestrator agents Fixes #7006
yindo added the pull-request label 2026-02-16 18:17:09 -05:00
yindo closed this issue 2026-02-16 18:17:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12237