forked from bchanot/claude
fix(rtk-hook): rtk ask (rc 3) passes the original command to the native rules; re-pin
This commit is contained in:
1 parent
d8b9a97980
commit
60ee4a996e
3 files changed
+33
-13
No files matched your search
@@ -1 +1 @@
|
||||
82369e32905a8de6dc6b2566c5992f686794a826b2310b15a96e4bd9d25ac7b6 rtk-rewrite.sh
|
||||
d4bd3a68b0bf203a0b79806d03217bf39264a41ffa37c5ff37441c74c29a8f3b rtk-rewrite.sh
|
||||
+6
-12
@@ -21,7 +21,7 @@
|
||||
# 1 No RTK equivalent → command continues unchanged into the
|
||||
# redaction check below (still may be rewritten there)
|
||||
# 2 Deny rule matched → pass through (Claude Code native deny handles it)
|
||||
# 3 + stdout Ask rule matched → rewrite but let Claude Code prompt the user
|
||||
# 3 + stdout Ask rule matched → pass the original through (native ask sees it)
|
||||
#
|
||||
# Independent of the above: any command whose FINAL form is a single-pipeline
|
||||
# `printenv`/`env` dump gets a redaction pipe appended (job7 — see below).
|
||||
@@ -86,18 +86,12 @@ case $EXIT_CODE in
|
||||
# check below still runs on it.
|
||||
REWRITTEN="$CMD"
|
||||
;;
|
||||
2)
|
||||
# Deny rule matched (rtk's own registry — not necessarily backed by a
|
||||
# matching settings.json deny rule, so the original command can still
|
||||
# reach native evaluation and run: e.g. bare `env`/`printenv` hits this
|
||||
# exit code with no settings.json rule behind it). Keep the original
|
||||
# command so the redaction check below still runs on it.
|
||||
2|3)
|
||||
# 2 = rtk deny, 3 = rtk ask: keep the ORIGINAL command so Claude Code's
|
||||
# native deny/ask judges it as typed (a `rtk <cmd>` rewrite matched no
|
||||
# native rule: bench 2026-10-25), and the redaction check still runs.
|
||||
REWRITTEN="$CMD"
|
||||
;;
|
||||
3)
|
||||
# Ask rule matched — rewrite the command but do NOT auto-allow so that
|
||||
# Claude Code prompts the user for confirmation.
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
@@ -140,7 +134,7 @@ fi
|
||||
ORIGINAL_INPUT=$(echo "$INPUT" | jq -c '.tool_input')
|
||||
UPDATED_INPUT=$(echo "$ORIGINAL_INPUT" | jq --arg cmd "$REWRITTEN" '.command = $cmd')
|
||||
|
||||
# Rewrite WITHOUT a permissionDecision (exit 0 and exit 3 alike): the
|
||||
# Rewrite WITHOUT a permissionDecision (rtk exit 0 only): the
|
||||
# rewritten command goes through Claude Code's native allow/deny/ask
|
||||
# evaluation. Permission control lives in settings.json, not in rtk.
|
||||
jq -n \
|
||||
|
||||
Reference in new issue
Block a user