From 6cb03400a5f35f324843aa81226106dde87bc712 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 30 May 2026 19:58:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20HLDP=20guard=20=E8=BD=AC=E4=B9=89?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=C2=B7=20=E5=8F=8C=E5=8F=8D=E6=96=9C?= =?UTF-8?q?=E6=9D=A0=E2=86=92=E5=8D=95=E5=8F=8D=E6=96=9C=E6=9D=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/01-hldp-guard.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) 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