From 3ab88232f7de06c0a9441a0f5fede4fc5e6ada56 Mon Sep 17 00:00:00 2001 From: lzkk <956449176@qq.com> Date: Tue, 26 May 2026 12:34:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(hooks):=20Stop=20hook=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=99=BA=E8=83=BD=E6=A3=80=E6=B5=8B=E2=80=94=E2=80=94=E4=BB=85?= =?UTF-8?q?=E5=9C=A8=20src/=20=E6=9C=89=E6=9C=AA=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E6=97=B6=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/hooks/stop-guard.sh | 11 +++++++++++ .claude/settings.json | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 .claude/hooks/stop-guard.sh diff --git a/.claude/hooks/stop-guard.sh b/.claude/hooks/stop-guard.sh new file mode 100755 index 00000000..6db2e014 --- /dev/null +++ b/.claude/hooks/stop-guard.sh @@ -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 diff --git a/.claude/settings.json b/.claude/settings.json index f93334d4..c6f00da4 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -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 } ] }