[FEATURE]: Add askPermission to plugin ToolContext #3794

Open
opened 2026-02-16 17:41:30 -05:00 by yindo · 0 comments
Owner

Originally created by @nielpattin on GitHub (Dec 23, 2025).

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

What

Plugins can now request permission from users before performing sensitive operations via ctx.askPermission().

Why

Currently, plugins have no way to prompt users for confirmation before destructive actions (file deletions, external API calls, etc). This makes it risky to use plugins in automated or YOLO mode.

With this change, plugin authors can:

  • Request explicit user consent before dangerous operations
  • Provide clear descriptions of what will happen
  • Respect the user's permission preferences

Changes

  • packages/plugin/src/tool.ts - Added optional askPermission to ToolContext type
  • packages/opencode/src/tool/registry.ts - Injects permission wrapper into plugin context

Backward Compatibility

The property is optional (askPermission?:), so existing plugins continue to work without modification.

Plugins that want to use this feature can check for its existence:

if (ctx.askPermission) {
  await ctx.askPermission({
    tool: "my-plugin",
    message: "Delete all temp files?",
  })
}

Demo: PR: 6042

(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

Originally created by @nielpattin on GitHub (Dec 23, 2025). ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request ## What Plugins can now request permission from users before performing sensitive operations via `ctx.askPermission()`. ## Why Currently, plugins have no way to prompt users for confirmation before destructive actions (file deletions, external API calls, etc). This makes it risky to use plugins in automated or YOLO mode. With this change, plugin authors can: - Request explicit user consent before dangerous operations - Provide clear descriptions of what will happen - Respect the user's permission preferences ## Changes - `packages/plugin/src/tool.ts` - Added optional `askPermission` to `ToolContext` type - `packages/opencode/src/tool/registry.ts` - Injects permission wrapper into plugin context ## Backward Compatibility The property is optional (`askPermission?:`), so existing plugins continue to work without modification. Plugins that want to use this feature can check for its existence: ```typescript if (ctx.askPermission) { await ctx.askPermission({ tool: "my-plugin", message: "Delete all temp files?", }) } ``` ## Demo: PR: [6042](https://github.com/sst/opencode/pull/6042) (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
yindo added the discussion label 2026-02-16 17:41:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3794