Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds native permission requests to OpenCode 2 image saves.
No actionable issues were found. The previous review commit was unavailable, so the full PR diff was reviewed. No previous review threads were supplied. Tests were inspected but not run.
|
OpenCode 2 image saves wrote after containment without any prompt, although Cursor's default assets folder is outside the workspace. Use the public plugin ctx.permission.assert when the host offers it: ask external_directory, then edit, with the resources and tool-call source OpenCode's own write tool uses. Hosts without the domain keep catalog edit gating plus containment. A plain decline is rethrown unchanged so OpenCode ends the step as it does for native tools. Deny rules and rejections with feedback keep the CursorImagePermissionDenied marker so Cursor still receives write_result.permission_denied. Based on moritzWa#1. Co-authored-by: Moritz Wallawitsch <42035131+moritzWa@users.noreply.github.com>
oakimov
force-pushed
the
fix/opencode2-image-permission
branch
from
October 18, 2026 18:43
cacf0d2 to
43ac233
Compare
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.
Problem
On OpenCode 2,
cursor_image_savewrote generated images after the containment check without asking anything. Cursor's defaultassets/folder is outside the workspace, so OpenCode 1.x asksexternal_directoryand theneditfor the same write, but OpenCode 2 asked for neither. OpenCode 2 now gives pluginsctx.permission.assert(added in v2.0.29), so the plugin can ask the same way.Fix
ctx.permission, image save asksexternal_directoryand thenedit, using the same resources as OpenCode's ownwrite:<dir>/*for the external folder, and the absolute path for an external file (a relative path inside the workspace). The session, agent and tool call are sent as the source, so saved "always" answers and session rules apply.CursorImagePermissionDenied:marker, so Cursor still receiveswrite_result.permission_denied. The fork PR this is based on rethrew every refusal raw, which turned those into generic tool errors for Cursor.ctx.permissionkeep the previous behaviour: catalogeditgating plus containment.Based on moritzWa#1 by @moritzWa. That PR's event-subscription cleanup is already on
main; its parity report and packed-host script are not included.OpenCode 1.x is unchanged: it already asks through the tool context's
ask.Verification
test/plugin-opencode2.test.tscover: order and request shape; a target inside the workspace; a decline at each step keeping its identity and writing nothing; deny and feedback keeping the marker. Each test fails if the decline handling is removed or replaced with the fork's version.cursor/composer-2.5and explicitaskrules. The defaultbuildagent allows everything, so there is no prompt without them:external_directoryfor<assets>/*; Cursor reportedpermission denied (operation=write …); no fileeditfor<assets>/*permission denied … Permission denied: edit; no fileedit, no feedbackrejected (reason=The user declined this tool call); no fileThe "Before" column follows from the code on
main, which never asks on OpenCode 2; I didn't run it live.Prompt caching: unaffected. The change only touches the image-save tool's execution; RequestContext and checkpoints are unchanged.