feat(opencode): wire permission.ask plugin hook#19470
Open
jacobprall wants to merge 3 commits intoanomalyco:devfrom
Open
feat(opencode): wire permission.ask plugin hook#19470jacobprall wants to merge 3 commits intoanomalyco:devfrom
jacobprall wants to merge 3 commits intoanomalyco:devfrom
Conversation
The `permission.ask` hook was declared in the Hooks interface but never
fired from the permission engine. Plugins implementing it were silently
ignored.
After built-in rules evaluate to "ask", `Plugin.trigger("permission.ask")`
now runs inside `Effect.ensuring` (so pending cleanup always fires).
If the plugin sets status to "allow" or "deny", the request short-circuits
before prompting the user. Errors fall back to normal prompt flow.
Fixes anomalyco#19469
Made-with: Cursor
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #19453: fix(opencode): add permission.ask plugin hook back Why it's related: This PR appears to be addressing the same issue (wiring up the |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
nickdavies
pushed a commit
to nickdavies/opencode
that referenced
this pull request
Mar 30, 2026
Saw on anomalyco#19470 that they do similar
nickdavies
pushed a commit
to nickdavies/opencode
that referenced
this pull request
Mar 30, 2026
Saw on anomalyco#19470 that they do similar
|
Hey I put up what looks like a very similar PR: #19453 I'd love to get in the full command path so that it matches the tool.execute.before/after |
nickdavies
pushed a commit
to nickdavies/opencode
that referenced
this pull request
Apr 1, 2026
Saw on anomalyco#19470 that they do similar
6 tasks
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.
Issue for this PR
Closes #19469
Type of change
What does this PR do?
The
permission.askhook is declared in theHooksinterface (@opencode-ai/plugin) but never triggered from the permission engine. Plugins implementing it are silently ignored.This wires it: after built-in rules evaluate to "ask" and the request enters the pending queue,
Plugin.trigger("permission.ask", ...)fires. If the plugin setsstatus:"allow"→ resolve without prompting."deny"→DeniedError."ask"or error → normal prompt flow.The hook + deferred await are wrapped in
Effect.ensuringsopending.deletealways runs, including on abort/dispose.~40 lines in
permission/index.ts, 3 new tests intest/permission/next.test.ts.How did you verify your code works?
All 77 permission tests pass (74 existing + 3 new), typecheck clean:
The 3 new tests cover: plugin allows without prompting, plugin denies before prompting, plugin errors fall back to prompt flow. Each creates a
file://plugin with apermission.askhook in a tmpdir and verifies the behavior end-to-end throughPermission.ask.Screenshots / recordings
N/A — no UI changes.
Checklist