fix: extract denied commands from correct JSON path (Issue #143)

The permission_denials array from Claude CLI has commands nested under
tool_input.command, not directly as .command:

Before: jq '[.permission_denials[].command]'
After:  jq '[.permission_denials[].tool_input.command]'

This fixes the "Permission denied for N command(s)" message to actually
display the denied commands instead of showing empty/unknown.

Also updated test fixture to match real Claude CLI output structure.
This commit is contained in:
Test User 2026-02-01 13:43:47 -07:00
parent 2e6026aced
commit 627ad7d9a5
2 changed files with 5 additions and 3 deletions

View file

@ -982,12 +982,13 @@ EOF
@test "parse_json_response extracts denied_commands list" {
local output_file="$LOG_DIR/test_output.log"
# Use real Claude CLI output structure with tool_input.command
cat > "$output_file" << 'EOF'
{
"result": "Permission denied for npm install",
"sessionId": "session-extract-cmds",
"permission_denials": [
{"tool": "Bash", "command": "npm install express", "reason": "Not allowed"}
{"tool_name": "Bash", "tool_use_id": "toolu_123", "tool_input": {"command": "npm install express"}}
]
}
EOF
@ -998,7 +999,7 @@ EOF
local result_file="$RALPH_DIR/.json_parse_result"
[[ -f "$result_file" ]]
# Should extract the denied commands
# Should extract the denied commands from tool_input.command
local denied_cmds=$(jq -r '.denied_commands[0]' "$result_file")
[[ "$denied_cmds" == *"npm install"* ]]
}