fix(hook): handle AskRewrite in Cursor hook when no rules configured#2609
Merged
Conversation
KuSh
requested changes
Jun 28, 2026
When no explicit permission rules exist in ~/.cursor/cli-config.json (the default for fresh installs), every command gets Default verdict which maps to AskRewrite. The Cursor hook only handled AllowRewrite, silently dropping all rewrites and making RTK non-functional. Now treat AskRewrite as allow when no rules are configured — Cursor has no ask-the-user UX, so deferring is indistinguishable from dropping. When explicit rules exist, preserve the conservative behavior of deferring mixed/unmatched commands. Also fix the legacy shell script (rtk-rewrite.sh) which treated exit code 3 (ask) as failure via || short-circuit. Fixes rtk-ai#2372
Align cursor_has_explicit_rules() with the inline has_rules check in run_cursor_inner_with_rules() — both now consider deny, ask, and allow rules when determining whether the user has configured explicit permission policies.
Address PR rtk-ai#2609 review feedback: - RC=3 in shell script now emits "permission": "ask" (future-proof) - Add cursor_ask() and use it for all AskRewrite decisions - Remove has_rules guard (unnecessary with ask semantics) - Remove dead cursor_has_explicit_rules() function
e69ee78 to
c30b302
Compare
Contributor
Author
|
thank you for the review : ) |
KuSh
requested changes
Jun 29, 2026
KuSh
left a comment
Collaborator
There was a problem hiding this comment.
A minor change is needed here; otherwise, LGTM, thanks!
Contributor
Author
|
All review feedback has been addressed:
Note: This PR (#2609) was opened before issue #2719 and PR #2720 were created, and is a superset of #2720. #2720 only fixes the shell script ( |
KuSh
approved these changes
Jun 29, 2026
KuSh
pushed a commit
that referenced
this pull request
Jun 29, 2026
Address PR #2609 review feedback: - RC=3 in shell script now emits "permission": "ask" (future-proof) - Add cursor_ask() and use it for all AskRewrite decisions - Remove has_rules guard (unnecessary with ask semantics) - Remove dead cursor_has_explicit_rules() function
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
~/.cursor/cli-config.jsonAskRewriteverdict — but the hook only handledAllowRewrite, silently dropping all rewritesAskRewriteas allow when no rules are configured (Cursor has no ask-the-user UX); preserve conservative defer behavior when explicit rules existrtk-rewrite.sh) which treated exit code 3 (ask) as failure via||short-circuitcursor_has_explicit_rules()to include ask rules, matching the inline check inrun_cursor_inner_with_rules()Fixes #2372
Test plan
cargo fmt --all && cargo clippy --all-targets && cargo testtest_cursor_default_verdict_rewritesverifies that with no rules,git statusrewrites tortk git statuswithpermission: allowcli-config.jsonrules — commands should rewrite tortkprefixed versions