#!/usr/bin/env bash
# M-6: Commit size + parallel-path verification reminder (soft warning)
# Triggers on git commit when staged diff exceeds 200 net insertions.
set -uo pipefail
INPUT=$(cat)
CMD=$(echo "$INPUT" | python -c 'import sys,json; print(json.load(sys.stdin).get("tool_input",{}).get("command",""))')
echo "$CMD" | grep -Eq '^\s*git\s+commit(\s|$)' || { echo '{}'; exit 0; }
NET=$(cd "$CLAUDE_PROJECT_DIR" && git diff --cached --shortstat 2>/dev/null | grep -oE '[0-9]+ insertion' | head -1 | grep -oE '[0-9]+' || echo 0)
[[ "$NET" -lt 200 ]] && { echo '{}'; exit 0; }
cat <<EOF
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow","additionalContext":"Commit size >200 lines ($NET insertions). Per RETRO-AGENT-FAILURE-PATTERNS M-6: include 'parallel sites checked' list in commit body or link to PLAN.md parallel-sites section."}}
EOF
