cc-safe-setup 29.6.2 → 29.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,15 @@
1
1
  #!/bin/bash
2
2
  # auto-answer-question.sh — Auto-answer AskUserQuestion for headless/autonomous mode
3
3
  #
4
- # NOTE: updatedInput schema (question/answer vs questions/answers array)
5
- # may vary. Verify with your Claude Code version before production use.
6
- #
7
4
  # TRIGGER: PreToolUse
8
5
  # MATCHER: AskUserQuestion
9
6
  #
10
- # v2.1.85+: PreToolUse hooks can satisfy AskUserQuestion by returning
11
- # updatedInput alongside permissionDecision: "allow".
7
+ # v2.1.85+: PreToolUse hooks can return updatedInput with pre-filled answers
8
+ # alongside permissionDecision: "allow" to auto-answer questions.
9
+ #
10
+ # AskUserQuestion schema:
11
+ # tool_input.questions[] = { question: string, options?: string[] }
12
+ # updatedInput.answers = { "question text": "answer text" }
12
13
  #
13
14
  # Usage:
14
15
  # {
@@ -28,7 +29,11 @@
28
29
  # Unknown questions → pass through to human
29
30
 
30
31
  INPUT=$(cat)
31
- QUESTION=$(echo "$INPUT" | jq -r '.tool_input.question // empty' 2>/dev/null)
32
+
33
+ # Extract first question text from questions array
34
+ QUESTION=$(echo "$INPUT" | jq -r '.tool_input.questions[0].question // empty' 2>/dev/null)
35
+ # Fallback: try singular form for compatibility
36
+ [ -z "$QUESTION" ] && QUESTION=$(echo "$INPUT" | jq -r '.tool_input.question // empty' 2>/dev/null)
32
37
  [ -z "$QUESTION" ] && exit 0
33
38
 
34
39
  # Log all auto-answered questions for audit
@@ -42,7 +47,9 @@ if echo "$QUESTION" | grep -qiE 'delete|削除|drop|truncate|destroy|remove.*all
42
47
  hookSpecificOutput: {
43
48
  hookEventName: "PreToolUse",
44
49
  permissionDecision: "allow",
45
- updatedInput: { question: $q, answer: "No. This operation is too risky for unattended mode." }
50
+ updatedInput: {
51
+ answers: { ($q): "No. This operation is too risky for unattended mode." }
52
+ }
46
53
  }
47
54
  }'
48
55
  echo "$(date -u '+%Y-%m-%dT%H:%M:%SZ') A: NO (dangerous)" >> "$LOG_DIR/auto-answers.log"
@@ -55,7 +62,9 @@ if echo "$QUESTION" | grep -qiE 'test|テスト|build|ビルド|lint|format|chec
55
62
  hookSpecificOutput: {
56
63
  hookEventName: "PreToolUse",
57
64
  permissionDecision: "allow",
58
- updatedInput: { question: $q, answer: "Yes, proceed." }
65
+ updatedInput: {
66
+ answers: { ($q): "Yes, proceed." }
67
+ }
59
68
  }
60
69
  }'
61
70
  echo "$(date -u '+%Y-%m-%dT%H:%M:%SZ') A: YES (safe op)" >> "$LOG_DIR/auto-answers.log"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cc-safe-setup",
3
- "version": "29.6.2",
4
- "description": "One command to make Claude Code safe. 412 example hooks + 8 built-in. 52 CLI commands. 5601 tests. Works with Auto Mode.",
3
+ "version": "29.6.3",
4
+ "description": "One command to make Claude Code safe. 412 example hooks + 8 built-in. 52 CLI commands. 5605 tests. Works with Auto Mode.",
5
5
  "main": "index.mjs",
6
6
  "bin": {
7
7
  "cc-safe-setup": "index.mjs"