[PR #6042] feat(plugin): add optional askPermission to ToolContext #11710

Open
opened 2026-02-16 18:16:39 -05:00 by yindo · 0 comments
Owner

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

State: open
Merged: No


Add optional askPermission to plugin ToolContext

Summary

  • Plugins can now call ctx.askPermission() to request user confirmation before sensitive operations
  • Made the property optional to avoid breaking existing plugins

Details

This hooks into the existing Permission.ask() system so plugins get the same permission UX as built-in tools.

Example usage in a plugin:

execute: async (ctx, input) => {
  if (ctx.askPermission) {
    await ctx.askPermission({
      tool: "dangerous-tool",
      message: `About to delete ${input.path}`,
    })
  }
  // proceed with operation
}

Testing

  • Existing plugins (without askPermission) still work
  • New plugins can opt-in to permission prompts

Checklist

  • Types are backward compatible (optional property)
  • No breaking changes for existing plugins

Demo:

(Ignore the skill tool mention, it's just a plugin that use the same format as the native skill support)

https://github.com/user-attachments/assets/78a8b453-8815-4973-bfa8-2e8588d1a9bd

Used locally on nielpattin/opencode-skillful

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6042 **State:** open **Merged:** No --- # Add optional `askPermission` to plugin ToolContext ## Summary - Plugins can now call `ctx.askPermission()` to request user confirmation before sensitive operations - Made the property optional to avoid breaking existing plugins ## Details This hooks into the existing `Permission.ask()` system so plugins get the same permission UX as built-in tools. Example usage in a plugin: ```typescript execute: async (ctx, input) => { if (ctx.askPermission) { await ctx.askPermission({ tool: "dangerous-tool", message: `About to delete ${input.path}`, }) } // proceed with operation } ``` ## Testing - Existing plugins (without askPermission) still work - New plugins can opt-in to permission prompts ## Checklist - [x] Types are backward compatible (optional property) - [x] No breaking changes for existing plugins ## Demo: (Ignore the skill tool mention, it's just a plugin that use the same format as the native skill support) https://github.com/user-attachments/assets/78a8b453-8815-4973-bfa8-2e8588d1a9bd Used locally on [nielpattin/opencode-skillful](https://github.com/nielpattin/opencode-skillful)
yindo added the pull-request label 2026-02-16 18:16:39 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11710