fix(hooks): Stop hook 改为智能检测——仅在 src/ 有未提交改动时提醒

lzk
lzkk 5 days ago
parent 6f14ee1a7a
commit 3ab88232f7

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# 智能 Stop hook仅 src/ 有未提交改动时提醒门禁
cd "$(dirname "$0")/../.." 2>/dev/null || true
count=$( (git diff --name-only HEAD; git diff --cached --name-only) 2>/dev/null | grep -c '^src/')
if [ "${count:-0}" = "0" ]; then
echo '{"continue": true}'
else
echo "{\"continue\": true, \"hookSpecificOutput\": {\"hookEventName\": \"Stop\", \"additionalContext\": \"## ${count} 个源文件未提交\\n\\n快门禁通过\"}}"
fi

@ -45,9 +45,9 @@
"matcher": "",
"hooks": [
{
"type": "prompt",
"prompt": "在结束本次会话之前,请确认以下事项:\n1. 快门禁是否通过?(./2026test.sh -c functional -x && ./2026test.sh -c h_functional -x\n2. 指令数是否有退化?(如有优化改动,跑 ./count_asm.sh\n3. 本次有效的优化是否已记录到 优化记录.md\n4. 是否有未提交的改动需要处理?\n5. 如有重要经验教训,是否已写入 memory\n\n请简要回答每个问题是/否/不适用),然后正常结束。",
"timeout": 15000
"type": "command",
"command": "bash .claude/hooks/stop-guard.sh",
"timeout": 3000
}
]
}

Loading…
Cancel
Save