add-coder 0.3.27 → 0.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +246 -145
- package/package.json +2 -1
- package/templates/.add-coder-src-hash.json +126 -148
- package/templates/adapters/claude/hooks/doc-format-guard.ts +32 -0
- package/templates/adapters/claude/hooks/lib/claude-env.ts +7 -0
- package/templates/adapters/claude/hooks/notification.ts +24 -0
- package/templates/adapters/claude/hooks/permission-denied.ts +33 -0
- package/templates/adapters/claude/hooks/permission-gate.ts +12 -0
- package/templates/adapters/claude/hooks/post-tool-failure.ts +4 -0
- package/templates/adapters/claude/hooks/post-tool-use.ts +17 -0
- package/templates/adapters/claude/hooks/pre-compact.ts +10 -0
- package/templates/adapters/claude/hooks/pre-tool-use.ts +81 -0
- package/templates/adapters/claude/hooks/prompt-submit.ts +82 -0
- package/templates/adapters/claude/hooks/review-checklist.ts +4 -0
- package/templates/adapters/claude/hooks/session-end.ts +10 -0
- package/templates/adapters/claude/hooks/session-start.ts +24 -0
- package/templates/adapters/claude/hooks/stop-check.ts +15 -0
- package/templates/adapters/claude/hooks/stop-failure.ts +34 -0
- package/templates/adapters/claude/hooks/subagent-guard.ts +25 -0
- package/templates/adapters/claude/hooks/subagent-stop.ts +12 -0
- package/templates/adapters/claude/settings.json +13 -13
- package/templates/adapters/codex/hooks/doc-format-guard.ts +30 -0
- package/templates/adapters/codex/hooks/notification.ts +26 -0
- package/templates/adapters/codex/hooks/permission-gate.ts +15 -0
- package/templates/adapters/codex/hooks/post-tool-failure.ts +14 -0
- package/templates/adapters/codex/hooks/post-tool-use.ts +85 -0
- package/templates/adapters/codex/hooks/pre-compact.ts +20 -0
- package/templates/adapters/codex/hooks/pre-tool-use.ts +141 -0
- package/templates/adapters/codex/hooks/prompt-submit.ts +38 -0
- package/templates/adapters/codex/hooks/review-checklist.ts +5 -0
- package/templates/adapters/codex/hooks/session-end.ts +19 -0
- package/templates/adapters/codex/hooks/session-start.ts +45 -0
- package/templates/adapters/codex/hooks/stop-check.ts +59 -0
- package/templates/adapters/codex/hooks/subagent-guard.ts +22 -0
- package/templates/adapters/codex/hooks/subagent-stop.ts +20 -0
- package/templates/adapters/codex/hooks.json +5 -5
- package/templates/adapters/qoder/hooks/doc-format-guard.ts +34 -0
- package/templates/adapters/qoder/hooks/lib/context-inject.ts +61 -0
- package/templates/adapters/qoder/hooks/lib/qoder-env.ts +23 -0
- package/templates/adapters/qoder/hooks/lib/review-checklist.ts +5 -0
- package/templates/adapters/qoder/hooks/notification.ts +34 -0
- package/templates/adapters/qoder/hooks/permission-gate.ts +26 -0
- package/templates/adapters/qoder/hooks/post-tool-failure.ts +30 -0
- package/templates/adapters/qoder/hooks/post-tool-use.ts +32 -0
- package/templates/adapters/qoder/hooks/pre-compact.ts +16 -0
- package/templates/adapters/qoder/hooks/pre-tool-use.ts +112 -0
- package/templates/adapters/qoder/hooks/prompt-submit.ts +66 -0
- package/templates/adapters/qoder/hooks/review-checklist.ts +24 -0
- package/templates/adapters/qoder/hooks/session-end.ts +27 -0
- package/templates/adapters/qoder/hooks/session-start.ts +83 -0
- package/templates/adapters/qoder/hooks/stop-check.ts +69 -0
- package/templates/adapters/qoder/hooks/subagent-guard.ts +16 -0
- package/templates/adapters/qoder/hooks/subagent-stop.ts +33 -0
- package/templates/adapters/qoder/settings.json +13 -13
- package/templates/adapters/trae/hooks/doc-format-guard.ts +30 -0
- package/templates/adapters/trae/hooks/notification.ts +22 -0
- package/templates/adapters/trae/hooks/permission-gate.ts +15 -0
- package/templates/adapters/trae/hooks/post-tool-failure.ts +14 -0
- package/templates/adapters/trae/hooks/post-tool-use.ts +24 -0
- package/templates/adapters/trae/hooks/pre-compact.ts +15 -0
- package/templates/adapters/trae/hooks/pre-tool-use.ts +40 -0
- package/templates/adapters/trae/hooks/prompt-submit.ts +29 -0
- package/templates/adapters/trae/hooks/review-checklist.ts +5 -0
- package/templates/adapters/trae/hooks/session-end.ts +16 -0
- package/templates/adapters/trae/hooks/session-start.ts +15 -0
- package/templates/adapters/trae/hooks/stop-check.ts +20 -0
- package/templates/adapters/trae/hooks/subagent-guard.ts +22 -0
- package/templates/adapters/trae/hooks/subagent-stop.ts +15 -0
- package/templates/adapters/trae/hooks.json +1 -1
- package/templates/adapters/vscode/hooks/doc-format-guard.ts +27 -0
- package/templates/adapters/vscode/hooks/notification.ts +22 -0
- package/templates/adapters/vscode/hooks/permission-gate.ts +15 -0
- package/templates/adapters/vscode/hooks/post-tool-failure.ts +32 -0
- package/templates/adapters/vscode/hooks/post-tool-use.ts +25 -0
- package/templates/adapters/vscode/hooks/pre-compact.ts +15 -0
- package/templates/adapters/vscode/hooks/pre-tool-use.ts +78 -0
- package/templates/adapters/vscode/hooks/prompt-submit.ts +74 -0
- package/templates/adapters/vscode/hooks/review-checklist.ts +5 -0
- package/templates/adapters/vscode/hooks/session-end.ts +16 -0
- package/templates/adapters/vscode/hooks/session-start.ts +24 -0
- package/templates/adapters/vscode/hooks/stop-check.ts +21 -0
- package/templates/adapters/vscode/hooks/subagent-guard.ts +21 -0
- package/templates/adapters/vscode/hooks/subagent-stop.ts +15 -0
- package/templates/core/docs/ADD-governance-claude-code.md +3 -3
- package/templates/core/docs/ADD-governance-codex.md +5 -5
- package/templates/core/docs/ADD-governance-qoder-cn.md +4 -4
- package/templates/core/docs/ADD-governance-trae.md +2 -2
- package/templates/core/docs/ADD-governance-vscode-copilot.md +21 -22
- package/templates/core/governance/audit-bridge.ts +47 -0
- package/templates/core/governance/common.ts +299 -0
- package/templates/core/governance/context-inject.ts +53 -0
- package/templates/core/governance/doc-format-guard.ts +440 -0
- package/templates/core/governance/notification-router.ts +62 -0
- package/templates/core/governance/notify.ts +66 -0
- package/templates/core/governance/permission-gate-router.ts +42 -0
- package/templates/core/governance/post-tool-failure-router.ts +56 -0
- package/templates/core/governance/post-tool-router.ts +212 -0
- package/templates/core/governance/pre-compact-guard.ts +41 -0
- package/templates/core/governance/pre-tool-guard.ts +309 -0
- package/templates/core/governance/preload-templates.ts +241 -0
- package/templates/core/governance/prompt-router.ts +222 -0
- package/templates/core/governance/review-checklist-guard.ts +186 -0
- package/templates/core/governance/rules.ts +720 -0
- package/templates/core/governance/session-end.ts +88 -0
- package/templates/core/governance/session-start-guard.ts +99 -0
- package/templates/core/governance/state-detect.ts +6 -0
- package/templates/core/governance/stop-router.ts +140 -0
- package/templates/core/governance/subagent-guard-router.ts +35 -0
- package/templates/core/governance/subagent-stop-router.ts +93 -0
- package/templates/core/governance/subagent-stop.ts +75 -0
- package/templates/core/governance/vocabulary.ts +109 -0
- package/templates/core/hooks/doc-format-guard.ts +21 -0
- package/templates/core/hooks/notification.ts +11 -0
- package/templates/core/hooks/permission-gate.ts +7 -0
- package/templates/core/hooks/post-tool-failure.ts +7 -0
- package/templates/core/hooks/post-tool-use.ts +23 -0
- package/templates/core/hooks/pre-compact.ts +9 -0
- package/templates/core/hooks/pre-tool-use.ts +30 -0
- package/templates/core/hooks/prompt-submit.ts +11 -0
- package/templates/core/hooks/review-checklist.ts +4 -0
- package/templates/core/hooks/session-end.ts +10 -0
- package/templates/core/hooks/session-start.ts +9 -0
- package/templates/core/hooks/stop-check.ts +14 -0
- package/templates/core/hooks/subagent-guard.ts +8 -0
- package/templates/core/hooks/subagent-stop.ts +9 -0
- package/templates/core/scripts/mcp-server/tools/gateway/check_rahs.ts +12 -1
- package/templates/core/scripts/mcp-server/tools/plan.ts +12 -2
- package/templates/adapters/claude/hooks/doc-format-guard.sh +0 -283
- package/templates/adapters/claude/hooks/lib/common.sh +0 -220
- package/templates/adapters/claude/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/claude/hooks/lib/notify.sh +0 -36
- package/templates/adapters/claude/hooks/lib/preload-templates.sh +0 -212
- package/templates/adapters/claude/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/claude/hooks/lib/state-detect.sh +0 -13
- package/templates/adapters/claude/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/claude/hooks/lib/vocabulary.sh +0 -62
- package/templates/adapters/claude/hooks/notification.sh +0 -45
- package/templates/adapters/claude/hooks/permission-denied.sh +0 -42
- package/templates/adapters/claude/hooks/permission-gate.sh +0 -18
- package/templates/adapters/claude/hooks/post-tool-failure.sh +0 -10
- package/templates/adapters/claude/hooks/post-tool-use.sh +0 -35
- package/templates/adapters/claude/hooks/pre-compact.sh +0 -37
- package/templates/adapters/claude/hooks/pre-tool-use.sh +0 -153
- package/templates/adapters/claude/hooks/prompt-submit.sh +0 -99
- package/templates/adapters/claude/hooks/review-checklist.sh +0 -10
- package/templates/adapters/claude/hooks/session-end.sh +0 -21
- package/templates/adapters/claude/hooks/session-start.sh +0 -36
- package/templates/adapters/claude/hooks/stop-check.sh +0 -54
- package/templates/adapters/claude/hooks/stop-failure.sh +0 -44
- package/templates/adapters/claude/hooks/subagent-guard.sh +0 -36
- package/templates/adapters/claude/hooks/subagent-stop.sh +0 -20
- package/templates/adapters/codex/hooks/doc-format-guard.sh +0 -343
- package/templates/adapters/codex/hooks/lib/common.sh +0 -209
- package/templates/adapters/codex/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/codex/hooks/lib/notify.sh +0 -36
- package/templates/adapters/codex/hooks/lib/preload-templates.sh +0 -208
- package/templates/adapters/codex/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/codex/hooks/lib/state-detect.sh +0 -8
- package/templates/adapters/codex/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/codex/hooks/lib/vocabulary.sh +0 -51
- package/templates/adapters/codex/hooks/notification.sh +0 -30
- package/templates/adapters/codex/hooks/permission-gate.sh +0 -18
- package/templates/adapters/codex/hooks/post-tool-failure.sh +0 -10
- package/templates/adapters/codex/hooks/post-tool-use.sh +0 -43
- package/templates/adapters/codex/hooks/pre-compact.sh +0 -37
- package/templates/adapters/codex/hooks/pre-tool-use.sh +0 -130
- package/templates/adapters/codex/hooks/prompt-submit.sh +0 -92
- package/templates/adapters/codex/hooks/review-checklist.sh +0 -10
- package/templates/adapters/codex/hooks/session-end.sh +0 -38
- package/templates/adapters/codex/hooks/session-start.sh +0 -63
- package/templates/adapters/codex/hooks/stop-check.sh +0 -71
- package/templates/adapters/codex/hooks/subagent-guard.sh +0 -15
- package/templates/adapters/codex/hooks/subagent-stop.sh +0 -47
- package/templates/adapters/qoder/hooks/doc-format-guard.sh +0 -341
- package/templates/adapters/qoder/hooks/lib/common.sh +0 -223
- package/templates/adapters/qoder/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/qoder/hooks/lib/notify.sh +0 -36
- package/templates/adapters/qoder/hooks/lib/preload-templates.sh +0 -212
- package/templates/adapters/qoder/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/qoder/hooks/lib/state-detect.sh +0 -13
- package/templates/adapters/qoder/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/qoder/hooks/lib/vocabulary.sh +0 -62
- package/templates/adapters/qoder/hooks/notification.sh +0 -25
- package/templates/adapters/qoder/hooks/permission-gate.sh +0 -8
- package/templates/adapters/qoder/hooks/post-tool-failure.sh +0 -8
- package/templates/adapters/qoder/hooks/post-tool-use.sh +0 -121
- package/templates/adapters/qoder/hooks/pre-compact.sh +0 -37
- package/templates/adapters/qoder/hooks/pre-tool-use.sh +0 -154
- package/templates/adapters/qoder/hooks/prompt-submit.sh +0 -96
- package/templates/adapters/qoder/hooks/review-checklist.sh +0 -157
- package/templates/adapters/qoder/hooks/session-end.sh +0 -24
- package/templates/adapters/qoder/hooks/session-start.sh +0 -45
- package/templates/adapters/qoder/hooks/stop-check.sh +0 -59
- package/templates/adapters/qoder/hooks/subagent-guard.sh +0 -27
- package/templates/adapters/qoder/hooks/subagent-stop.sh +0 -26
- package/templates/adapters/trae/hooks/doc-format-guard.sh +0 -343
- package/templates/adapters/trae/hooks/lib/common.sh +0 -220
- package/templates/adapters/trae/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/trae/hooks/lib/notify.sh +0 -36
- package/templates/adapters/trae/hooks/lib/preload-templates.sh +0 -212
- package/templates/adapters/trae/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/trae/hooks/lib/state-detect.sh +0 -10
- package/templates/adapters/trae/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/trae/hooks/lib/vocabulary.sh +0 -62
- package/templates/adapters/trae/hooks/notification.sh +0 -45
- package/templates/adapters/trae/hooks/permission-gate.sh +0 -18
- package/templates/adapters/trae/hooks/post-tool-failure.sh +0 -10
- package/templates/adapters/trae/hooks/post-tool-use.sh +0 -138
- package/templates/adapters/trae/hooks/pre-compact.sh +0 -37
- package/templates/adapters/trae/hooks/pre-tool-use.sh +0 -223
- package/templates/adapters/trae/hooks/prompt-submit.sh +0 -87
- package/templates/adapters/trae/hooks/review-checklist.sh +0 -10
- package/templates/adapters/trae/hooks/session-end.sh +0 -38
- package/templates/adapters/trae/hooks/session-start.sh +0 -53
- package/templates/adapters/trae/hooks/stop-check.sh +0 -54
- package/templates/adapters/trae/hooks/subagent-guard.sh +0 -15
- package/templates/adapters/trae/hooks/subagent-stop.sh +0 -47
- package/templates/adapters/vscode/hooks/doc-format-guard.sh +0 -282
- package/templates/adapters/vscode/hooks/lib/common.sh +0 -220
- package/templates/adapters/vscode/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/vscode/hooks/lib/notify.sh +0 -36
- package/templates/adapters/vscode/hooks/lib/preload-templates.sh +0 -212
- package/templates/adapters/vscode/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/vscode/hooks/lib/state-detect.sh +0 -13
- package/templates/adapters/vscode/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/vscode/hooks/lib/vocabulary.sh +0 -62
- package/templates/adapters/vscode/hooks/notification.sh +0 -43
- package/templates/adapters/vscode/hooks/permission-gate.sh +0 -18
- package/templates/adapters/vscode/hooks/post-tool-failure.sh +0 -28
- package/templates/adapters/vscode/hooks/post-tool-use.sh +0 -35
- package/templates/adapters/vscode/hooks/pre-compact.sh +0 -37
- package/templates/adapters/vscode/hooks/pre-tool-use.sh +0 -153
- package/templates/adapters/vscode/hooks/prompt-submit.sh +0 -99
- package/templates/adapters/vscode/hooks/review-checklist.sh +0 -10
- package/templates/adapters/vscode/hooks/session-end.sh +0 -13
- package/templates/adapters/vscode/hooks/session-start.sh +0 -35
- package/templates/adapters/vscode/hooks/stop-check.sh +0 -62
- package/templates/adapters/vscode/hooks/subagent-guard.sh +0 -37
- package/templates/adapters/vscode/hooks/subagent-stop.sh +0 -12
- package/templates/core/hooks/doc-format-guard.sh +0 -343
- package/templates/core/hooks/lib/common.sh +0 -220
- package/templates/core/hooks/lib/context-inject.sh +0 -96
- package/templates/core/hooks/lib/notify.sh +0 -36
- package/templates/core/hooks/lib/preload-templates.sh +0 -212
- package/templates/core/hooks/lib/session-end.sh +0 -76
- package/templates/core/hooks/lib/state-detect.sh +0 -10
- package/templates/core/hooks/lib/subagent-stop.sh +0 -90
- package/templates/core/hooks/lib/vocabulary.sh +0 -62
- package/templates/core/hooks/notification.sh +0 -45
- package/templates/core/hooks/permission-gate.sh +0 -18
- package/templates/core/hooks/post-tool-failure.sh +0 -10
- package/templates/core/hooks/post-tool-use.sh +0 -138
- package/templates/core/hooks/pre-compact.sh +0 -37
- package/templates/core/hooks/pre-tool-use.sh +0 -223
- package/templates/core/hooks/prompt-submit.sh +0 -87
- package/templates/core/hooks/review-checklist.sh +0 -10
- package/templates/core/hooks/session-end.sh +0 -38
- package/templates/core/hooks/session-start.sh +0 -53
- package/templates/core/hooks/stop-check.sh +0 -54
- package/templates/core/hooks/subagent-guard.sh +0 -15
- package/templates/core/hooks/subagent-stop.sh +0 -47
- package/templates/shared/hooks-lib/common.sh +0 -22
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# review-checklist.sh — 验收 Review 模式:检查 checklist 质量
|
|
3
|
-
# 被 prompt-submit.sh 的"验收"幂等检查后调用
|
|
4
|
-
#
|
|
5
|
-
# 输入: handoff_path add_route_path
|
|
6
|
-
# 输出: checklist 质量问题清单
|
|
7
|
-
|
|
8
|
-
handoff="$1"
|
|
9
|
-
add_route="$2"
|
|
10
|
-
[ -z "$handoff" ] && exit 0
|
|
11
|
-
|
|
12
|
-
# 从 handoff 关联找到 spec 目录
|
|
13
|
-
plan_dir=$(dirname "$handoff")
|
|
14
|
-
plan_kw=$(basename "$handoff" | sed 's/-handoff.*//')
|
|
15
|
-
|
|
16
|
-
# 找 checklist
|
|
17
|
-
spec_dir=".qoder/specs/${plan_kw}"
|
|
18
|
-
checklist=""
|
|
19
|
-
[ -d "$spec_dir" ] && checklist="$spec_dir/checklist.md"
|
|
20
|
-
# fallback: 搜索
|
|
21
|
-
[ ! -f "$checklist" ] && checklist=$(find .qoder/specs -name "checklist.md" -path "*${plan_kw}*" 2>/dev/null | head -1)
|
|
22
|
-
|
|
23
|
-
tasks_file=""
|
|
24
|
-
[ -d "$spec_dir" ] && tasks_file="$spec_dir/tasks.md"
|
|
25
|
-
[ ! -f "$tasks_file" ] && tasks_file=$(find .qoder/specs -name "tasks.md" -path "*${plan_kw}*" 2>/dev/null | head -1)
|
|
26
|
-
|
|
27
|
-
issues=""
|
|
28
|
-
|
|
29
|
-
# ══════════════════════════════════════════════════════════════════════
|
|
30
|
-
# 0. Step 0 准入: ADD 核心文档存在性(BLOCKING)
|
|
31
|
-
# ══════════════════════════════════════════════════════════════════════
|
|
32
|
-
_missing_docs=""
|
|
33
|
-
if [ ! -f "$handoff" ]; then
|
|
34
|
-
_missing_docs="${_missing_docs} Handoff"
|
|
35
|
-
else
|
|
36
|
-
# 章节完整性: 至少要有 spec 文件/你要改的文件/验证标准/完成后记录 四个关键小节
|
|
37
|
-
_h_sections=0
|
|
38
|
-
grep -q "spec 文件" "$handoff" 2>/dev/null && _h_sections=$((_h_sections + 1))
|
|
39
|
-
grep -q "你要改的文件" "$handoff" 2>/dev/null && _h_sections=$((_h_sections + 1))
|
|
40
|
-
grep -q "验证标准" "$handoff" 2>/dev/null && _h_sections=$((_h_sections + 1))
|
|
41
|
-
grep -q "完成后记录 ADD-7 审计" "$handoff" 2>/dev/null && _h_sections=$((_h_sections + 1))
|
|
42
|
-
if [ "$_h_sections" -lt 4 ]; then
|
|
43
|
-
_missing_docs="${_missing_docs} Handoff(缺章节:${_h_sections}/4)"
|
|
44
|
-
fi
|
|
45
|
-
fi
|
|
46
|
-
if [ ! -f "$add_route" ]; then
|
|
47
|
-
_missing_docs="${_missing_docs} add-route"
|
|
48
|
-
else
|
|
49
|
-
# add-route 至少要有 Task 映射表 + 文件清单
|
|
50
|
-
if ! grep -q "Task 映射表" "$add_route" 2>/dev/null && ! grep -q "文件清单" "$add_route" 2>/dev/null; then
|
|
51
|
-
_missing_docs="${_missing_docs} add-route(缺Task映射/文件清单)"
|
|
52
|
-
fi
|
|
53
|
-
fi
|
|
54
|
-
if [ ! -f "$checklist" ]; then
|
|
55
|
-
_missing_docs="${_missing_docs} checklist"
|
|
56
|
-
else
|
|
57
|
-
# checklist 至少要有 [T] 项
|
|
58
|
-
if ! grep -q '\[T\]' "$checklist" 2>/dev/null; then
|
|
59
|
-
_missing_docs="${_missing_docs} checklist(无[T]项)"
|
|
60
|
-
fi
|
|
61
|
-
fi
|
|
62
|
-
if [ ! -f "$tasks_file" ]; then
|
|
63
|
-
_missing_docs="${_missing_docs} tasks"
|
|
64
|
-
else
|
|
65
|
-
# tasks 至少要有 Task 列表 + 验证
|
|
66
|
-
if ! grep -q 'Task\|\- \[ \]' "$tasks_file" 2>/dev/null; then
|
|
67
|
-
_missing_docs="${_missing_docs} tasks(无Task项)"
|
|
68
|
-
fi
|
|
69
|
-
fi
|
|
70
|
-
if [ -n "$_missing_docs" ]; then
|
|
71
|
-
echo " ❌ Step 0 未完成:$(echo $_missing_docs | sed 's/ /, /g') 文件缺失。回退 Step 0.5/Step 1 补建后再进入代码实现。"
|
|
72
|
-
exit 1
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
|
-
# 1. checklist [x] 数 vs tasks.md [x] 数 是否一致
|
|
76
|
-
if [ -f "$checklist" ] && [ -f "$tasks_file" ]; then
|
|
77
|
-
cl_ck=$(grep -c '\[x\]' "$checklist" 2>/dev/null || true); cl_ck=${cl_ck:-0}
|
|
78
|
-
cl_open=$(grep -c '\[ \]' "$checklist" 2>/dev/null || true); cl_open=${cl_open:-0}
|
|
79
|
-
tk_ck=$(grep -c '\[x\]' "$tasks_file" 2>/dev/null || echo "0")
|
|
80
|
-
|
|
81
|
-
if [ "$cl_open" -gt 0 ]; then
|
|
82
|
-
issues="${issues} ⚠️ checklist 有 ${cl_open} 项未勾选\n"
|
|
83
|
-
fi
|
|
84
|
-
|
|
85
|
-
# 2. [T] 项是否都有 [x](编译期验证项)
|
|
86
|
-
t_items=$(grep -c '\[T\]' "$checklist" 2>/dev/null || true); t_items=${t_items:-0}
|
|
87
|
-
t_checked=$(grep '\[T\]' "$checklist" 2>/dev/null | grep -c '\[x\]' || true); t_checked=${t_checked:-0}
|
|
88
|
-
if [ "$t_items" -gt "$t_checked" ]; then
|
|
89
|
-
issues="${issues} ⚠️ [T] 编译期验证: ${t_checked}/${t_items} 通过\n"
|
|
90
|
-
fi
|
|
91
|
-
|
|
92
|
-
# 3. 证据缺失检测:[x] 但缺 — 证据: 标记
|
|
93
|
-
_no_evidence=0
|
|
94
|
-
while IFS= read -r line; do
|
|
95
|
-
[ -z "$line" ] && continue
|
|
96
|
-
# 有证据: — 证据: 字段 + 具体内容(tsc/vitest/grep/审计ID 等)
|
|
97
|
-
if echo "$line" | grep -qE '—\s*证据:\s*\S' 2>/dev/null; then
|
|
98
|
-
continue
|
|
99
|
-
fi
|
|
100
|
-
# 有验证结果描述也行
|
|
101
|
-
if echo "$line" | grep -qE 'npx|tsc|vitest|grep|✅|cmq[0-9a-z]{10}|18/18|exit.*0' 2>/dev/null; then
|
|
102
|
-
continue
|
|
103
|
-
fi
|
|
104
|
-
_no_evidence=$((_no_evidence + 1))
|
|
105
|
-
done < <(grep '\[x\]' "$checklist" 2>/dev/null)
|
|
106
|
-
|
|
107
|
-
if [ "$_no_evidence" -gt 0 ]; then
|
|
108
|
-
issues="${issues} ❌ ${_no_evidence} 项 [x] 缺少验收证据(需附 — 证据: tsc/vitest/grep/审计ID 等)\n"
|
|
109
|
-
fi
|
|
110
|
-
|
|
111
|
-
# 4. 审计链:[x] 项引用 audit ID 的比例
|
|
112
|
-
# 初验: 有证据即可,审计ID是证据产出物
|
|
113
|
-
# 复验: 有审计ID + 证据仍有效 → 不重复落库;证据失效 → 追写新审计
|
|
114
|
-
_with_audit=$(grep '\[x\]' "$checklist" 2>/dev/null | grep -cE 'cmq[a-z0-9]{10,}' || true); _with_audit=${_with_audit:-0}
|
|
115
|
-
_fake_audit=$(grep '\[x\]' "$checklist" 2>/dev/null | grep -cE 'cmq\.\.\.|cmqxxx|审计.*cmq\.\.' || true); _fake_audit=${_fake_audit:-0}
|
|
116
|
-
if [ "$_fake_audit" -gt 0 ]; then
|
|
117
|
-
issues="${issues} ❌ ${_fake_audit} 项 [x] 使用了占位符审计ID(cmq.../cmqxxx),必须调 record_dev_operation 获取真实 cuid 后替换\n"
|
|
118
|
-
fi
|
|
119
|
-
_with_evidence=$(grep '\[x\]' "$checklist" 2>/dev/null | grep -cE 'tsc|vitest|npx|grep|✅|验证|确认|compgen|审计.*cmq[a-z0-9]{10}' || true); _with_evidence=${_with_evidence:-0}
|
|
120
|
-
if [ "$_with_evidence" -gt 0 ] && [ "$_with_audit" -eq 0 ]; then
|
|
121
|
-
issues="${issues} 📎 初验: ${_with_evidence}/${cl_ck} 项有证据但未写审计 ID(需调 record_dev_operation 落库)\n"
|
|
122
|
-
elif [ "$_with_audit" -gt 0 ] && [ "$_with_audit" -lt "$cl_ck" ]; then
|
|
123
|
-
issues="${issues} 📎 复验: ${_with_audit}/${cl_ck} 项引用审计 ID。${_with_evidence}/${cl_ck} 项有证据。证据一致则不需追写 devlog日志(走mcp)\n"
|
|
124
|
-
fi
|
|
125
|
-
fi
|
|
126
|
-
|
|
127
|
-
# 5. add-route Step 闭环
|
|
128
|
-
if [ -f "$add_route" ]; then
|
|
129
|
-
ar_ck=$(grep -c '\[x\]' "$add_route" 2>/dev/null || true); ar_ck=${ar_ck:-0}
|
|
130
|
-
ar_open=$(grep -c '\[ \]' "$add_route" 2>/dev/null || true); ar_open=${ar_open:-0}
|
|
131
|
-
if [ "$ar_open" -gt 0 ]; then
|
|
132
|
-
issues="${issues} ⚠️ add-route ${ar_open} Step 未闭环\n"
|
|
133
|
-
fi
|
|
134
|
-
fi
|
|
135
|
-
|
|
136
|
-
# 6. handoff 审计表同步:checklist 中的 cuid 是否在 handoff 中有记录
|
|
137
|
-
if [ -f "$handoff" ] && [ -f "$checklist" ]; then
|
|
138
|
-
_new_cuids=""
|
|
139
|
-
while IFS= read -r cuid; do
|
|
140
|
-
[ -z "$cuid" ] && continue
|
|
141
|
-
if ! grep -q "$cuid" "$handoff" 2>/dev/null; then
|
|
142
|
-
[ -n "$_new_cuids" ] && _new_cuids="${_new_cuids}, "
|
|
143
|
-
_new_cuids="${_new_cuids}${cuid}"
|
|
144
|
-
fi
|
|
145
|
-
done < <(grep -oE 'cmq[a-z0-9]{10,}' "$checklist" 2>/dev/null | sort -u)
|
|
146
|
-
if [ -n "$_new_cuids" ]; then
|
|
147
|
-
_new_count=$(echo "$_new_cuids" | tr ',' '\n' | wc -l)
|
|
148
|
-
issues="${issues} ❌ handoff 审计表未同步: ${_new_count} 个 cuid 在 checklist 中存在但 handoff 中缺失(需更新 handoff ADD-7 表 + query_audit_logs 命令)\n"
|
|
149
|
-
fi
|
|
150
|
-
fi
|
|
151
|
-
|
|
152
|
-
if [ -z "$issues" ]; then
|
|
153
|
-
echo " ✅ Review: checklist 质量检查通过"
|
|
154
|
-
else
|
|
155
|
-
echo " 📋 Review 发现问题:"
|
|
156
|
-
echo -e "$issues"
|
|
157
|
-
fi
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# SessionEnd — Qoder CN 专用(独立实现,stdout JSON additionalContext 注入)
|
|
3
|
-
# 治理卡位 #2: 标记清理 + 会话审计结算 + Stop未触发兜底
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
export CURRENT_MAGIC=$(basename "$(dirname "$HOOK_DIR")")
|
|
8
|
-
export PROJECT_DIR="${QODER_PROJECT_DIR:-${QODERCN_PROJECT_DIR:-$PWD}}"
|
|
9
|
-
source "$HOOK_DIR/lib/common.sh" 2>/dev/null || true
|
|
10
|
-
|
|
11
|
-
# ── ① 清理标记文件 ──
|
|
12
|
-
project_hash=$(echo "${PROJECT_DIR:-$PWD}" | md5sum 2>/dev/null | cut -c1-8 || echo "default")
|
|
13
|
-
rm -f "/tmp/add_tpl_${project_hash}" 2>/dev/null || true
|
|
14
|
-
rm -f "/tmp/add_dev_${project_hash}" 2>/dev/null || true
|
|
15
|
-
|
|
16
|
-
# ── ② Stop 未触发兜底 ──
|
|
17
|
-
fallback_msg=""
|
|
18
|
-
if has_dev_action 2>/dev/null; then
|
|
19
|
-
fallback_msg="⚠️ 检测到 dev action 标记未清除——Stop 可能未触发验收检查"
|
|
20
|
-
fi
|
|
21
|
-
|
|
22
|
-
# ── ③ stdout JSON additionalContext ──
|
|
23
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"SessionEnd\",\"additionalContext\":\"[ADD SessionEnd] 会话结束 — $(date -Iseconds)。标记已清理。${fallback_msg}\"}}"
|
|
24
|
-
exit 0
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# SessionStart — ADD 上下文恢复 + 模板索引注入(Qoder CN 适配,stdout additionalContext 注入)
|
|
3
|
-
# 治理卡位 #1: ADD状态恢复 + 模板索引注入
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
export CURRENT_MAGIC=$(basename "$(dirname "$HOOK_DIR")")
|
|
8
|
-
export PROJECT_DIR="${QODER_PROJECT_DIR:-${QODERCN_PROJECT_DIR:-$PWD}}"
|
|
9
|
-
source "$HOOK_DIR/lib/common.sh"
|
|
10
|
-
source "$HOOK_DIR/lib/state-detect.sh" 2>/dev/null || true
|
|
11
|
-
source "$HOOK_DIR/lib/context-inject.sh" 2>/dev/null || true
|
|
12
|
-
|
|
13
|
-
# ── ① ADD 状态恢复 ──
|
|
14
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
15
|
-
if [ -n "$state" ]; then
|
|
16
|
-
IFS='::' read -r plan step rounds handoff add_route <<< "$state"
|
|
17
|
-
add_ctx="ADD: ${plan} Step${step} Round${rounds}"
|
|
18
|
-
# §代办刷新:提醒加载 IDE 代办清单
|
|
19
|
-
add_ctx="${add_ctx}\n[代办] 如有未加载的 IDE 代办清单,请从 tasks.md §IDE JSON 刷新 TodoWrite"
|
|
20
|
-
cat <<EOJSON
|
|
21
|
-
{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"${add_ctx}"}}
|
|
22
|
-
EOJSON
|
|
23
|
-
fi
|
|
24
|
-
|
|
25
|
-
# ── ② 模板索引注入 ──
|
|
26
|
-
TPL_SCRIPT="$HOOK_DIR/lib/preload-templates.sh"
|
|
27
|
-
if [ -f "$TPL_SCRIPT" ]; then
|
|
28
|
-
lines=$(bash "$TPL_SCRIPT" --index 2>/dev/null | wc -l)
|
|
29
|
-
cat <<EOJSON
|
|
30
|
-
{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"${lines} ADD templates available. Use preload-templates.sh --index for list."}}
|
|
31
|
-
EOJSON
|
|
32
|
-
fi
|
|
33
|
-
|
|
34
|
-
# ── ③ §HITL 待审批检测 ──
|
|
35
|
-
PLANS_DIR="${PROJECT_DIR}/${MAGIC_DIR}/plans"
|
|
36
|
-
if [ -d "$PLANS_DIR" ]; then
|
|
37
|
-
hitl_count=$(find "$PLANS_DIR" -name "*.hitl.md" -mtime -7 -type f 2>/dev/null | wc -l)
|
|
38
|
-
if [ "$hitl_count" -gt 0 ] 2>/dev/null; then
|
|
39
|
-
cat <<EOJSON
|
|
40
|
-
{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"[HITL 待审批] 检测到 ${hitl_count} 个待审批 HITL 提案,请检查并处理"}}
|
|
41
|
-
EOJSON
|
|
42
|
-
fi
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
exit 0
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# stop-check.sh — Qoder CN Stop:四象限分流 + 验收检查(保留 few-shot 上下文注入)
|
|
3
|
-
# 治理卡位 #7: 验收检查 + devlog + 阻断
|
|
4
|
-
# DB lifecycle 真相源(协议层):DB 不可用时 fail-closed,禁止回退 Handoff/add-route 猜测
|
|
5
|
-
# Qoder stdout 规范: stdout 只输出合法 JSON(hookSpecificOutput);非 JSON 一律走 stderr
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
input=$(cat)
|
|
9
|
-
stop_active=$(echo "$input" | jq -r '.stop_hook_active // false' 2>/dev/null || echo "false")
|
|
10
|
-
[ "$stop_active" = "true" ] && exit 0
|
|
11
|
-
|
|
12
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
13
|
-
export CURRENT_MAGIC=$(basename "$(dirname "$HOOK_DIR")")
|
|
14
|
-
export MAGIC_DIR=$(basename "$(dirname "$HOOK_DIR")")
|
|
15
|
-
export PROJECT_DIR="${QODER_PROJECT_DIR:-${QODERCN_PROJECT_DIR:-$PWD}}"
|
|
16
|
-
source "$HOOK_DIR/lib/common.sh" 2>/dev/null || true
|
|
17
|
-
source "$HOOK_DIR/lib/context-inject.sh" 2>/dev/null || true
|
|
18
|
-
|
|
19
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
20
|
-
has_dev=$(has_dev_action 2>/dev/null && echo "true" || echo "false")
|
|
21
|
-
|
|
22
|
-
# ═══════ Q0: DB 不可用 → fail closed(禁止当“无 Plan”;stdout 保持 JSON 规范) ═══════
|
|
23
|
-
if [ "${state%%::*}" = "__STATUS_UNAVAILABLE__" ]; then
|
|
24
|
-
reason=$(echo "$state" | awk -F'::' '{print $2}')
|
|
25
|
-
echo "[ADD Stop] ⛔ Plan status 暂不可用(${reason})。未回退 Handoff/add-route 猜测,请恢复数据库或 MCP resolver 后重试。" >&2
|
|
26
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"Stop\",\"additionalContext\":\"[ADD Stop] Plan status 暂不可用(${reason}),fail-closed 阻断\"}}"
|
|
27
|
-
exit "${EXIT_BLOCK:-2}"
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
# ═══════ Q1: 无 ADD + 无 dev → 正常停 ═══════
|
|
31
|
-
if [ -z "$state" ] && [ "$has_dev" != "true" ]; then
|
|
32
|
-
exit 0
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
# ═══════ Q2: 无 ADD + 有 dev → 严重违规,few-shot 注入 ═══════
|
|
36
|
-
if [ -z "$state" ] && [ "$has_dev" = "true" ]; then
|
|
37
|
-
build_stop_context "no_add_has_dev" >&2
|
|
38
|
-
exit $EXIT_BLOCK
|
|
39
|
-
fi
|
|
40
|
-
|
|
41
|
-
# 解析 state
|
|
42
|
-
IFS='::' read -r plan step rounds handoff add_route <<< "$state"
|
|
43
|
-
|
|
44
|
-
# ═══════ Q3: 有 ADD + 无 dev → 注入状态(stdout JSON) ═══════
|
|
45
|
-
if [ "$has_dev" != "true" ]; then
|
|
46
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"Stop\",\"additionalContext\":\"[ADD Stop] Plan: ${plan}, 轮次: ${rounds}, Step: ${step}。本次无代码改动,下次继续时执行 session-init 恢复上下文。\"}}"
|
|
47
|
-
exit 0
|
|
48
|
-
fi
|
|
49
|
-
|
|
50
|
-
# ═══════ Q4: 有 ADD + 有 dev → 验收检查 ═══════
|
|
51
|
-
issues=$(check_add_completeness "$handoff" "$add_route" 2>/dev/null || true)
|
|
52
|
-
if [ -n "$issues" ]; then
|
|
53
|
-
build_stop_context "has_add_dev_unclosed" "$issues" >&2
|
|
54
|
-
exit $EXIT_BLOCK
|
|
55
|
-
fi
|
|
56
|
-
|
|
57
|
-
clear_dev_action 2>/dev/null || true
|
|
58
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"Stop\",\"additionalContext\":\"[ADD Stop] ✅ 验收通过——checklist 全部勾选,devlog 已记录。\"}}"
|
|
59
|
-
exit 0
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
###
|
|
3
|
-
# @Author : xiaomingming wujixmm@gmail.com
|
|
4
|
-
# @Date : 2026-07-07 17:44:23
|
|
5
|
-
# @LastEditors : xiaomingming wujixmm@gmail.com
|
|
6
|
-
# @LastEditTime : 2026-07-17 18:04:31
|
|
7
|
-
# @FilePath : /add-coder/templates/adapters/qoder/hooks/subagent-guard.sh
|
|
8
|
-
# @Description :
|
|
9
|
-
###
|
|
10
|
-
# SubagentStart — 子代理 ADD 上下文注入(Qoder CN 适配)
|
|
11
|
-
# 治理卡位 #10: ADD上下文注入子agent + 审计初始化
|
|
12
|
-
set -euo pipefail
|
|
13
|
-
|
|
14
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
15
|
-
export CURRENT_MAGIC=$(basename "$(dirname "$HOOK_DIR")")
|
|
16
|
-
export PROJECT_DIR="${QODER_PROJECT_DIR:-${QODERCN_PROJECT_DIR:-$PWD}}"
|
|
17
|
-
source "$HOOK_DIR/lib/common.sh" 2>/dev/null || true
|
|
18
|
-
|
|
19
|
-
if type detect_active_add >/dev/null 2>&1; then
|
|
20
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
21
|
-
if [ -n "$state" ]; then
|
|
22
|
-
IFS='::' read -r plan step rounds handoff add_route <<< "$state"
|
|
23
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"SubagentStart\",\"additionalContext\":\"[ADD SubagentStart] Plan: ${plan}, Step: ${step}, Round: ${rounds}, handoff: ${handoff}。遵循 ADD 规范,完成后检查 checklist。\"}}"
|
|
24
|
-
fi
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
exit 0
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# SubagentStop — Qoder CN 专用(独立实现,stdout JSON additionalContext 注入)
|
|
3
|
-
# 治理卡位 #11: 子agent边界校验 + 审计聚合 + 阻断
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
export CURRENT_MAGIC=$(basename "$(dirname "$HOOK_DIR")")
|
|
8
|
-
export PROJECT_DIR="${QODER_PROJECT_DIR:-${QODERCN_PROJECT_DIR:-$PWD}}"
|
|
9
|
-
source "$HOOK_DIR/lib/common.sh" 2>/dev/null || true
|
|
10
|
-
|
|
11
|
-
input=$(cat)
|
|
12
|
-
agent_name=$(echo "$input" | jq -r '.agent_type // .subagent_name // "unknown"' 2>/dev/null || echo "unknown")
|
|
13
|
-
|
|
14
|
-
# ── ① 边界校验 ──
|
|
15
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
16
|
-
if [ -z "$state" ]; then
|
|
17
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"SubagentStop\",\"additionalContext\":\"[ADD SubagentStop] ⚠️ ${agent_name} 已完成,但无活跃 ADD Plan 无法校验边界。\"}}"
|
|
18
|
-
exit 0
|
|
19
|
-
fi
|
|
20
|
-
|
|
21
|
-
plan_kw=$(echo "$state" | awk -F'::' '{print $1}')
|
|
22
|
-
handoff=$(echo "$state" | awk -F'::' '{print $4}')
|
|
23
|
-
|
|
24
|
-
# ── ② stdout JSON additionalContext ──
|
|
25
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"SubagentStop\",\"additionalContext\":\"[ADD SubagentStop] ${agent_name} 子代理结束。Plan: ${plan_kw}, handoff: ${handoff}。边界校验通过,审计已聚合。\"}}"
|
|
26
|
-
exit 0
|