cc-safe-setup 29.6.5 → 29.6.7

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.
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+ # ================================================================
3
+ # daily-usage-tracker.sh — Track daily tool call count
4
+ # ================================================================
5
+ # PURPOSE:
6
+ # Records each tool call with a timestamp. At session end (or on
7
+ # demand), shows how many tool calls were made today vs yesterday.
8
+ # Helps detect abnormal usage patterns early.
9
+ #
10
+ # TRIGGER: PostToolUse
11
+ # MATCHER: (any — leave matcher empty)
12
+ #
13
+ # CONFIGURATION:
14
+ # CC_DAILY_WARN=500 (warn if daily count exceeds this, default: 500)
15
+ #
16
+ # Output: logs to ~/.claude/daily-usage/YYYY-MM-DD.log
17
+ # ================================================================
18
+
19
+ DAILY_DIR="${HOME}/.claude/daily-usage"
20
+ mkdir -p "$DAILY_DIR"
21
+
22
+ TODAY=$(date +%Y-%m-%d)
23
+ TODAY_FILE="${DAILY_DIR}/${TODAY}.log"
24
+ WARN_THRESHOLD="${CC_DAILY_WARN:-500}"
25
+
26
+ INPUT=$(cat)
27
+ TOOL=$(echo "$INPUT" | jq -r '.tool_name // "unknown"' 2>/dev/null)
28
+
29
+ # Record the call
30
+ echo "$(date +%H:%M:%S) $TOOL" >> "$TODAY_FILE"
31
+
32
+ # Count today's calls
33
+ TODAY_COUNT=$(wc -l < "$TODAY_FILE" 2>/dev/null || echo 0)
34
+
35
+ # Warn at milestones
36
+ case "$TODAY_COUNT" in
37
+ 100|250|500|1000)
38
+ echo "📊 Daily usage: $TODAY_COUNT tool calls today ($TODAY)" >&2
39
+ ;;
40
+ esac
41
+
42
+ # Warn if threshold exceeded
43
+ if [ "$TODAY_COUNT" -eq "$WARN_THRESHOLD" ]; then
44
+ YESTERDAY=$(date -d "yesterday" +%Y-%m-%d 2>/dev/null || date -v-1d +%Y-%m-%d 2>/dev/null)
45
+ YESTERDAY_FILE="${DAILY_DIR}/${YESTERDAY}.log"
46
+ YESTERDAY_COUNT=0
47
+ [ -f "$YESTERDAY_FILE" ] && YESTERDAY_COUNT=$(wc -l < "$YESTERDAY_FILE")
48
+ echo "⚠ Daily usage warning: $TODAY_COUNT calls today (yesterday: $YESTERDAY_COUNT)" >&2
49
+ fi
50
+
51
+ exit 0
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+ # ================================================================
3
+ # json-syntax-check.sh — Validate JSON files after editing
4
+ # ================================================================
5
+ # PURPOSE:
6
+ # Claude Code sometimes writes invalid JSON to settings.json,
7
+ # package.json, or tsconfig.json. This hook validates JSON
8
+ # syntax immediately after an edit, before it causes errors.
9
+ #
10
+ # TRIGGER: PostToolUse
11
+ # MATCHER: "Edit|Write"
12
+ # ================================================================
13
+
14
+ INPUT=$(cat)
15
+ TOOL=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
16
+ FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
17
+
18
+ [ -z "$FILE" ] && exit 0
19
+
20
+ # Only check JSON files
21
+ echo "$FILE" | grep -qiE '\.json$|\.jsonc$' || exit 0
22
+
23
+ # Skip if file doesn't exist (Write to new file hasn't completed yet)
24
+ [ -f "$FILE" ] || exit 0
25
+
26
+ # Validate JSON
27
+ if ! jq empty "$FILE" 2>/dev/null; then
28
+ echo "⚠ Invalid JSON syntax in: $FILE" >&2
29
+ # Show the specific error
30
+ ERROR=$(jq empty "$FILE" 2>&1)
31
+ echo " Error: $ERROR" >&2
32
+ echo " Fix this before continuing — broken JSON will cause runtime errors." >&2
33
+ fi
34
+
35
+ exit 0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cc-safe-setup",
3
- "version": "29.6.5",
4
- "description": "One command to make Claude Code safe. 415 example hooks + 8 built-in. 52 CLI commands. 5627 tests. Works with Auto Mode.",
3
+ "version": "29.6.7",
4
+ "description": "One command to make Claude Code safe. 417 example hooks + 8 built-in. 52 CLI commands. 5639 tests. Works with Auto Mode.",
5
5
  "main": "index.mjs",
6
6
  "bin": {
7
7
  "cc-safe-setup": "index.mjs"