diff --git a/hooks/01-hldp-guard.sh b/hooks/01-hldp-guard.sh index 02a96f1..c386db0 100755 --- a/hooks/01-hldp-guard.sh +++ b/hooks/01-hldp-guard.sh @@ -7,30 +7,32 @@ set -e REQ_TAGS='@guardian|@sovereign|HLDP-ZY://' CHK_DIR='agents/|brain/|mcp-servers/|gatekeeper/|exe-engine/|hldp/' -CHK_EXT='\\.js$|\\.py$|\\.sh$|\\.hdlp$' -SKIP='package\\.json$|package-lock\\.json$|ecosystem\\.config\\.js$|\\.json$' +CHK_EXT='\.js$|\.py$|\.sh$|\.hdlp$' +SKIP='package\.json$|package-lock\.json$|ecosystem\.config\.js$' BLOCKED=0 while read old new ref; do - [ \"$new\" = \"0000000000000000000000000000000000000000\" ] && continue - if [ \"$old\" = \"0000000000000000000000000000000000000000\" ]; then - changed=$(git diff-tree --no-commit-id --name-only -r \"$new\" 2>/dev/null) + [ "$new" = "0000000000000000000000000000000000000000" ] && continue + if [ "$old" = "0000000000000000000000000000000000000000" ]; then + changed=$(git diff-tree --no-commit-id --name-only -r "$new" 2>/dev/null) else - changed=$(git diff-tree --no-commit-id --name-only -r \"$old..$new\" 2>/dev/null) + changed=$(git diff-tree --no-commit-id --name-only -r "$old..$new" 2>/dev/null) fi for f in $changed; do - mdir=$(echo \"$f\" | grep -E \"^($CHK_DIR)\" 2>/dev/null || true) - mext=$(echo \"$f\" | grep -E \"($CHK_EXT)\" 2>/dev/null || true) - mskip=$(echo \"$f\" | grep -E \"($SKIP)\" 2>/dev/null || true) - if [ -n \"$mdir\" ] && [ -n \"$mext\" ] && [ -z \"$mskip\" ]; then - c=$(git show \"$new:$f\" 2>/dev/null | head -100) - has=$(echo \"$c\" | grep -E \"($REQ_TAGS)\" 2>/dev/null || true) - if [ -z \"$has\" ]; then + mdir=$(echo "$f" | grep -E "^($CHK_DIR)" 2>/dev/null || true) + mext=$(echo "$f" | grep -E "($CHK_EXT)" 2>/dev/null || true) + mskip=$(echo "$f" | grep -E "($SKIP)" 2>/dev/null || true) + if [ -n "$mdir" ] && [ -n "$mext" ] && [ -z "$mskip" ]; then + c=$(git show "$new:$f" 2>/dev/null | head -100) + has=$(echo "$c" | grep -E "($REQ_TAGS)" 2>/dev/null || true) + if [ -z "$has" ]; then + echo '' echo '=== HLDP GUARD: BLOCKED ===' - echo 'File: '\"$f\" + echo "File: $f" echo 'Missing HLDP @tags (@guardian/@sovereign/HLDP-ZY://)' echo 'This is a consciousness checkpoint.' echo 'Re-read: brain/copyright-sovereignty-brain.hdlp' + echo '' BLOCKED=1 fi fi