refactor(plugin): return Effect from ToolContext.ask#21986
Merged
kitlangton merged 2 commits intodevfrom Apr 11, 2026
Merged
Conversation
mrsimpson
pushed a commit
to mrsimpson/opencode
that referenced
this pull request
Apr 14, 2026
mrsimpson
added a commit
to codemcp/workflows
that referenced
this pull request
Apr 22, 2026
## Root Cause OpenCode PR [#21986](anomalyco/opencode#21986) (merged **April 10, 2026**, commit `bfef334b`) deliberately changed `ToolContext.ask` in the plugin SDK from returning `Promise<void>` to `Effect.Effect<void>`: ```diff - 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
xywsxp
pushed a commit
to xywsxp/opencode
that referenced
this pull request
Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ToolContext.askreturn type fromPromise<void>toEffect.Effect<void>in@opencode-ai/pluginEffect.runPromisebridge inregistry.tsthat was converting between the twoeffectas a dependency of the plugin packageTest plan
bun run typecheckpasses for bothpackages/pluginandpackages/opencodebun run test test/tool/— all 167 tests pass