@@ -847,17 +847,18 @@ STUB
847847 # Write verdict + optional rule JSON, then exit 0. The hook reads
848848 # \$PASSTHRU_OVERLAY_RESULT_FILE afterwards.
849849 local rule_literal=" "
850+ local scope_literal=" "
850851 if [ -n " $rule_json " ]; then
851- # Pass the rule JSON through printf as a literal string (escape \$ so
852- # the stub itself does not try to expand it).
853852 rule_literal=" printf '%s\\ n' '$rule_json ' >> \"\$ PASSTHRU_OVERLAY_RESULT_FILE\" "
853+ scope_literal=" printf '%s\\ n' 'project' >> \"\$ PASSTHRU_OVERLAY_RESULT_FILE\" "
854854 fi
855855 cat > " $stub_overlay " << STUB
856856#!/usr/bin/env bash
857857: "\$ {PASSTHRU_OVERLAY_RESULT_FILE:?}"
858858mkdir -p "\$ (dirname "\$ PASSTHRU_OVERLAY_RESULT_FILE")" 2>/dev/null || true
859859printf '%s\\ n' '${verdict} ' > "\$ PASSTHRU_OVERLAY_RESULT_FILE"
860860${rule_literal}
861+ ${scope_literal}
861862# Touch a log file so tests can assert the stub ran.
862863if [ -n "\$ {PASSTHRU_OVERLAY_STUB_LOG:-}" ]; then
863864 {
@@ -1183,7 +1184,7 @@ EOF
11831184 [[ " $reason " == * " overlay" * ]]
11841185}
11851186
1186- @test " overlay: yes_always verdict writes rule to user /allow AND emits allow" {
1187+ @test " overlay: yes_always verdict writes rule to project /allow AND emits allow" {
11871188 rule_json=' {"tool":"Bash","match":{"command":"^gh "},"reason":"overlay yes_always"}'
11881189 setup_overlay_stub " yes_always" 0 " $rule_json "
11891190 export TMUX=" mock/0"
@@ -1204,15 +1205,15 @@ EOF
12041205 [ -n " $json_line " ]
12051206 decision=" $( jq -r ' .hookSpecificOutput.permissionDecision' <<< " $json_line" ) "
12061207 [ " $decision " = " allow" ]
1207- # Rule landed in user -scope passthru.json under allow[].
1208- [ -f " $USER_ROOT /.claude/passthru.json" ]
1209- match_cmd=" $( jq -r ' .allow[-1].match.command' " $USER_ROOT /.claude/passthru.json" ) "
1208+ # Rule landed in project -scope passthru.json under allow[] (default scope) .
1209+ [ -f " $PROJ_ROOT /.claude/passthru.json" ]
1210+ match_cmd=" $( jq -r ' .allow[-1].match.command' " $PROJ_ROOT /.claude/passthru.json" ) "
12101211 [ " $match_cmd " = " ^gh " ]
1211- tool_val=" $( jq -r ' .allow[-1].tool' " $USER_ROOT /.claude/passthru.json" ) "
1212+ tool_val=" $( jq -r ' .allow[-1].tool' " $PROJ_ROOT /.claude/passthru.json" ) "
12121213 [ " $tool_val " = " Bash" ]
12131214}
12141215
1215- @test " overlay: no_always verdict writes rule to user /deny AND emits deny" {
1216+ @test " overlay: no_always verdict writes rule to project /deny AND emits deny" {
12161217 rule_json=' {"tool":"Bash","match":{"command":"^curl "},"reason":"overlay no_always"}'
12171218 setup_overlay_stub " no_always" 0 " $rule_json "
12181219 export TMUX=" mock/0"
@@ -1233,8 +1234,8 @@ EOF
12331234 [ -n " $json_line " ]
12341235 decision=" $( jq -r ' .hookSpecificOutput.permissionDecision' <<< " $json_line" ) "
12351236 [ " $decision " = " deny" ]
1236- [ -f " $USER_ROOT /.claude/passthru.json" ]
1237- match_cmd=" $( jq -r ' .deny[-1].match.command' " $USER_ROOT /.claude/passthru.json" ) "
1237+ [ -f " $PROJ_ROOT /.claude/passthru.json" ]
1238+ match_cmd=" $( jq -r ' .deny[-1].match.command' " $PROJ_ROOT /.claude/passthru.json" ) "
12381239 [ " $match_cmd " = " ^curl " ]
12391240}
12401241
0 commit comments