Skip to content

Fix ask for permissions#268

Merged
mrsimpson merged 3 commits intomainfrom
fix-ask-for-permissions
Apr 22, 2026
Merged

Fix ask for permissions#268
mrsimpson merged 3 commits intomainfrom
fix-ask-for-permissions

Conversation

@mrsimpson
Copy link
Copy Markdown
Collaborator

@mrsimpson mrsimpson commented Apr 22, 2026

Root Cause

OpenCode PR #21986 (merged April 10, 2026, commit bfef334b) deliberately changed ToolContext.ask in the plugin SDK from returning Promise<void> to Effect.Effect<void>:

-  ask(input: AskInput): Promise<void>
+  ask(input: AskInput): Effect.Effect<void>

This broke the previous fix from commit 9e92eb3 (April 1, 2026), which used await context.ask(...) and worked correctly at the time. After the opencode change, await-ing an Effect object is a no-op — the Effect is never executed, so the permission prompt was silently skipped.

Fix

Add effect as a peer dependency (it is always present in the process since the plugin runs inside opencode) and a dev dependency for local type checking. Use Effect.runPromise() to bridge the Effect into the async/await context of the plugin's execute functions.

The ask call is centralised in the wrap() decorator in plugin.ts so all five tools get permission enforcement without duplicating the call in each handler.

Changes

  • package.json: add effect >=3.0.0 as peer + dev dependency
  • src/types.ts: fix local ToolContext.ask type to match real SDK (Effect.Effect<void>)
  • src/plugin.ts: use Effect.runPromise(ctx.ask(...)) in the wrap() decorator; import Effect from effect
  • test/e2e/plugin.test.ts: update createMockToolContext() helper; mock ask returns Effect.void instead of a resolved Promise

mrsimpson and others added 3 commits April 23, 2026 00:12
The plugin SDK types ctx.ask() as returning Effect.Effect<void>, not
Promise<void>. Awaiting an Effect object directly is a no-op — the
permission prompt was never triggered.

Fix by importing effect as a peer/dev dependency and running the Effect
via Effect.runPromise(). Update types.ts to match the real SDK type and
fix test mocks to return Effect.void instead of a resolved Promise.
@mrsimpson mrsimpson merged commit 3fb824c into main Apr 22, 2026
3 checks passed
@mrsimpson mrsimpson deleted the fix-ask-for-permissions branch April 22, 2026 22:51
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.

1 participant