Skip to content

feat(opencode): wire permission.ask plugin hook#19470

Open
jacobprall wants to merge 3 commits intoanomalyco:devfrom
jacobprall:feat/permission-ask-plugin-hook
Open

feat(opencode): wire permission.ask plugin hook#19470
jacobprall wants to merge 3 commits intoanomalyco:devfrom
jacobprall:feat/permission-ask-plugin-hook

Conversation

@jacobprall
Copy link
Copy Markdown

@jacobprall jacobprall commented Mar 27, 2026

Issue for this PR

Closes #19469

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The permission.ask hook is declared in the Hooks interface (@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 sets status:"allow" → resolve without prompting. "deny"DeniedError. "ask" or error → normal prompt flow.

The hook + deferred await are wrapped in Effect.ensuring so pending.delete always runs, including on abort/dispose.

~40 lines in permission/index.ts, 3 new tests in test/permission/next.test.ts.

How did you verify your code works?

All 77 permission tests pass (74 existing + 3 new), typecheck clean:

bun test test/permission/next.test.ts
77 pass, 0 fail, 108 expect() calls

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 a permission.ask hook in a tmpdir and verifies the behavior end-to-end through Permission.ask.

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #19453: fix(opencode): add permission.ask plugin hook back
#19453

Why it's related: This PR appears to be addressing the same issue (wiring up the permission.ask plugin hook that was declared but not triggered). Both PRs likely aim to fix issue #19469 and involve the same functionality in the permission module.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 27, 2026
@github-actions
Copy link
Copy Markdown
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
nickdavies pushed a commit to nickdavies/opencode that referenced this pull request Mar 30, 2026
@nickdavies
Copy link
Copy Markdown

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
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.

[FEATURE]: Wire the permission.ask plugin hook

2 participants