add-coder 0.3.26 → 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 +282 -155
- package/dist/index.js +481 -209
- package/package.json +15 -4
- package/templates/.add-coder-src-hash.json +186 -185
- 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/config.toml.example +12 -0
- 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 +67 -1
- 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 +4 -4
- package/templates/core/docs/ADD-governance-codex.md +6 -6
- package/templates/core/docs/ADD-governance-qoder-cn.md +5 -5
- package/templates/core/docs/ADD-governance-trae.md +3 -3
- package/templates/core/docs/ADD-governance-vscode-copilot.md +22 -23
- 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/prisma/add.prisma +140 -82
- package/templates/core/rules/project_rules.md +27 -24
- package/templates/core/scripts/db-ensure.sh +8 -0
- package/templates/core/scripts/gen-plan-index.sh +4 -15
- package/templates/core/scripts/mcp-server/notifications/hitl.ts +9 -1
- package/templates/core/scripts/mcp-server/notifications/hook.ts +25 -9
- package/templates/core/scripts/mcp-server/resources/hitl-approval-widget.ts +34 -0
- package/templates/core/scripts/mcp-server/resources/hook-events-report.ts +14 -2
- package/templates/core/scripts/mcp-server/resources/index.ts +2 -0
- package/templates/core/scripts/mcp-server/sampling/review.ts +25 -10
- package/templates/core/scripts/mcp-server/shared/db-types.ts +33 -8
- package/templates/core/scripts/mcp-server/shared/dps-scoring.strategy.ts +1 -1
- package/templates/core/scripts/mcp-server/shared/env.ts +28 -8
- package/templates/core/scripts/mcp-server/shared/fs.ts +3 -0
- package/templates/core/scripts/mcp-server/shared/hitl-interaction.strategy.ts +2 -3
- package/templates/core/scripts/mcp-server/shared/hitl-lifecycle-mutation.ts +129 -0
- package/templates/core/scripts/mcp-server/shared/hitl-proposal-mutation.ts +98 -0
- package/templates/core/scripts/mcp-server/shared/hitl-ui.ts +3 -0
- package/templates/core/scripts/mcp-server/shared/plan-lifecycle-events.ts +62 -0
- package/templates/core/scripts/mcp-server/shared/plan-lifecycle-mutation.ts +78 -0
- package/templates/core/scripts/mcp-server/shared/plan-lifecycle-subscriber.ts +145 -0
- package/templates/core/scripts/mcp-server/shared/plan-lifecycle.ts +153 -0
- package/templates/core/scripts/mcp-server/shared/plan-round-events.ts +56 -0
- package/templates/core/scripts/mcp-server/shared/plan-round-mutation.ts +143 -0
- package/templates/core/scripts/mcp-server/shared/plan-round-store.ts +47 -0
- package/templates/core/scripts/mcp-server/shared/plan-round-subscriber.ts +99 -0
- package/templates/core/scripts/mcp-server/shared/plan-status-store.ts +37 -0
- package/templates/core/scripts/mcp-server/shared/plan-tracking-mutation.ts +71 -0
- package/templates/core/scripts/mcp-server/shared/prisma.ts +12 -6
- package/templates/core/scripts/mcp-server/shared/project-root-strategy.ts +1 -2
- package/templates/core/scripts/mcp-server/shared/quant-recheck.strategy.ts +16 -0
- package/templates/core/scripts/mcp-server/shared/redact.ts +28 -0
- package/templates/core/scripts/mcp-server/shared/response.ts +3 -2
- package/templates/core/scripts/mcp-server/shared/runtime-context.ts +77 -0
- package/templates/core/scripts/mcp-server/shared/schema-topology.ts +159 -0
- package/templates/core/scripts/mcp-server/tools/audit.ts +49 -7
- package/templates/core/scripts/mcp-server/tools/context.ts +117 -121
- package/templates/core/scripts/mcp-server/tools/contract.ts +34 -9
- package/templates/core/scripts/mcp-server/tools/gateway/check_add_route_status.ts +50 -3
- package/templates/core/scripts/mcp-server/tools/gateway/check_doc_similarity.ts +218 -0
- package/templates/core/scripts/mcp-server/tools/gateway/check_dps.ts +22 -7
- package/templates/core/scripts/mcp-server/tools/gateway/check_rahs.ts +86 -4
- package/templates/core/scripts/mcp-server/tools/gateway/check_spec_sync.ts +19 -6
- package/templates/core/scripts/mcp-server/tools/gateway/index.ts +2 -0
- package/templates/core/scripts/mcp-server/tools/hitl.ts +160 -75
- package/templates/core/scripts/mcp-server/tools/hook-event-report.ts +9 -2
- package/templates/core/scripts/mcp-server/tools/index.ts +69 -3
- package/templates/core/scripts/mcp-server/tools/plan.ts +152 -17
- package/templates/core/scripts/mcp-server/tools/review.ts +44 -15
- package/templates/core/scripts/mcp-server.ts +60 -1
- package/templates/core/scripts/plan-status-bridge.ts +26 -0
- package/templates/core/skills/add-paradigm/SKILL.md +2 -2
- package/templates/core/templates/add-route-template.schema.json +24 -56
- package/templates/core/templates/collab-contract-template.md +1 -1
- package/templates/core/templates/handoff-multi-round-template.schema.json +48 -0
- package/templates/core/templates/handoff-single-round-template.schema.json +92 -0
- package/templates/core/templates/handoff-single-round.schema.json +1 -1
- package/templates/core/templates/hitl-approval-widget.html +222 -37
- package/templates/core/templates/spec-template.schema.json +9 -46
- package/templates/core/templates/standard-plan-template.schema.json +1 -1
- package/templates/core/templates/tasks-template.schema.json +13 -54
- package/templates/adapters/claude/hooks/doc-format-guard.sh +0 -202
- package/templates/adapters/claude/hooks/lib/common.sh +0 -261
- package/templates/adapters/claude/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/claude/hooks/lib/notify.sh +0 -34
- package/templates/adapters/claude/hooks/lib/preload-templates.sh +0 -187
- package/templates/adapters/claude/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/claude/hooks/lib/state-detect.sh +0 -117
- package/templates/adapters/claude/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/claude/hooks/lib/vocabulary.sh +0 -56
- 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 -45
- 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 -261
- package/templates/adapters/codex/hooks/lib/common.sh +0 -261
- package/templates/adapters/codex/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/codex/hooks/lib/notify.sh +0 -34
- package/templates/adapters/codex/hooks/lib/preload-templates.sh +0 -187
- package/templates/adapters/codex/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/codex/hooks/lib/state-detect.sh +0 -117
- package/templates/adapters/codex/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/codex/hooks/lib/vocabulary.sh +0 -56
- package/templates/adapters/codex/hooks/notification.sh +0 -45
- 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 -138
- package/templates/adapters/codex/hooks/pre-compact.sh +0 -37
- package/templates/adapters/codex/hooks/pre-tool-use.sh +0 -217
- package/templates/adapters/codex/hooks/prompt-submit.sh +0 -87
- 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 -53
- package/templates/adapters/codex/hooks/stop-check.sh +0 -45
- 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 -260
- package/templates/adapters/qoder/hooks/lib/common.sh +0 -261
- package/templates/adapters/qoder/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/qoder/hooks/lib/notify.sh +0 -34
- package/templates/adapters/qoder/hooks/lib/preload-templates.sh +0 -187
- package/templates/adapters/qoder/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/qoder/hooks/lib/state-detect.sh +0 -117
- package/templates/adapters/qoder/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/qoder/hooks/lib/vocabulary.sh +0 -56
- 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 -48
- 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 -261
- package/templates/adapters/trae/hooks/lib/common.sh +0 -261
- package/templates/adapters/trae/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/trae/hooks/lib/notify.sh +0 -34
- package/templates/adapters/trae/hooks/lib/preload-templates.sh +0 -187
- package/templates/adapters/trae/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/trae/hooks/lib/state-detect.sh +0 -117
- package/templates/adapters/trae/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/trae/hooks/lib/vocabulary.sh +0 -56
- 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 -217
- 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 -45
- 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 -201
- package/templates/adapters/vscode/hooks/lib/common.sh +0 -261
- package/templates/adapters/vscode/hooks/lib/context-inject.sh +0 -96
- package/templates/adapters/vscode/hooks/lib/notify.sh +0 -34
- package/templates/adapters/vscode/hooks/lib/preload-templates.sh +0 -187
- package/templates/adapters/vscode/hooks/lib/session-end.sh +0 -76
- package/templates/adapters/vscode/hooks/lib/state-detect.sh +0 -117
- package/templates/adapters/vscode/hooks/lib/subagent-stop.sh +0 -90
- package/templates/adapters/vscode/hooks/lib/vocabulary.sh +0 -56
- package/templates/adapters/vscode/hooks/notification.sh +0 -45
- 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 -53
- 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 -261
- package/templates/core/hooks/lib/common.sh +0 -261
- package/templates/core/hooks/lib/context-inject.sh +0 -96
- package/templates/core/hooks/lib/notify.sh +0 -34
- package/templates/core/hooks/lib/preload-templates.sh +0 -187
- package/templates/core/hooks/lib/session-end.sh +0 -76
- package/templates/core/hooks/lib/state-detect.sh +0 -117
- package/templates/core/hooks/lib/subagent-stop.sh +0 -90
- package/templates/core/hooks/lib/vocabulary.sh +0 -56
- 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 -217
- 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 -45
- 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,138 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# post-tool-use.sh — PostToolUse:格式化 + 文档守卫 + 审计提醒 + DPS 自动化
|
|
3
|
-
# 治理卡位 #5: 格式化 + ADD文档守卫 + 审计落库 + 结果增强 + 哨兵自动化
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
COMMON_LIB="$HOOK_DIR/lib/common.sh"
|
|
8
|
-
[ -f "$COMMON_LIB" ] && source "$COMMON_LIB"
|
|
9
|
-
|
|
10
|
-
input=$(parse_input)
|
|
11
|
-
tool_name=$(json_get "$input" "tool_name")
|
|
12
|
-
[ -z "$tool_name" ] && tool_name=$(echo "$input" | grep -o '"tool_name"[[:space:]]*:[[:space:]]*"[^"]*"' 2>/dev/null | sed 's/.*: *"\([^"]*\)".*/\1/' || echo "")
|
|
13
|
-
|
|
14
|
-
# ═══════════════ §1: HITL DPS 自动化 — check_dps ≥ 80 → 自动建哨兵 ═══════════════
|
|
15
|
-
# 检测 MCP check_dps 调用结果,DPS ≥ 80 自动 touch .tongyi-{plan} 哨兵
|
|
16
|
-
if echo "$input" | grep -q '"check_dps"'; then
|
|
17
|
-
tool_output=$(echo "$input" | grep -o '"output"[[:space:]]*:[[:space:]]*"[^"]*"\|"content"[[:space:]]*:[[:space:]]*"[^"]*"' 2>/dev/null || echo "")
|
|
18
|
-
dps_score=$(echo "$tool_output" | grep -oP 'DPS\s*=\s*\K\d+' 2>/dev/null || echo "")
|
|
19
|
-
plan_keyword=$(echo "$input" | grep -oP '"planKeyword"\s*:\s*"\K[^"]+' 2>/dev/null || echo "")
|
|
20
|
-
|
|
21
|
-
if [ -n "$dps_score" ] && [ -n "$plan_keyword" ]; then
|
|
22
|
-
if [ "$dps_score" -ge 80 ] 2>/dev/null; then
|
|
23
|
-
sentinel="${PROJECT_DIR:-$PWD}/${MAGIC_DIR:-.qoder}/hitl/.tongyi-${plan_keyword}"
|
|
24
|
-
if [ ! -f "$sentinel" ]; then
|
|
25
|
-
touch "$sentinel" 2>/dev/null && echo "[ADD PostToolUse] ✅ DPS=${dps_score} ≥80, HITL 自动通过 → ${sentinel}" >&2 || true
|
|
26
|
-
echo "[ADD PostToolUse] DPS=${dps_score} ≥80, 已自动建哨兵 ${sentinel}" >&2
|
|
27
|
-
else
|
|
28
|
-
echo "[ADD PostToolUse] DPS=${dps_score} ≥80, 哨兵已存在 → ${sentinel}" >&2
|
|
29
|
-
fi
|
|
30
|
-
else
|
|
31
|
-
echo "[ADD PostToolUse] ⚠️ DPS=${dps_score} <80, 需 Review 后手动建哨兵 .tongyi-${plan_keyword}" >&2
|
|
32
|
-
echo "[ADD PostToolUse] 修复文档后重新 check_dps,通过即自动放行。" >&2
|
|
33
|
-
fi
|
|
34
|
-
fi
|
|
35
|
-
fi
|
|
36
|
-
|
|
37
|
-
# ═══════════════ §2: Edit/Write matcher: 格式化 + 文档守卫 + 自动 plan_track ═══════════════
|
|
38
|
-
if [ "$tool_name" = "Edit" ] || [ "$tool_name" = "Write" ]; then
|
|
39
|
-
file_path=$(echo "$input" | grep -o '"file_path"[[:space:]]*:[[:space:]]*"[^"]*"' 2>/dev/null | sed 's/.*: *"\([^"]*\)".*/\1/' || echo "")
|
|
40
|
-
[ -z "$file_path" ] && exit 0
|
|
41
|
-
|
|
42
|
-
# §2a: ADD 文档结构守卫
|
|
43
|
-
if echo "$file_path" | grep -qE '\.(qoder|claude|add)/(plans|specs|reviews)/'; then
|
|
44
|
-
echo "[ADD PostToolUse] ADD 文档已写入: ${file_path}。请确保章节完整、双向链接齐全。" >&2
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
# §2b: plan_track 自动触发 — specs/ 或 add-route 写入后自动落库
|
|
48
|
-
if echo "$file_path" | grep -qE '/(specs|plans)/.*add-route'; then
|
|
49
|
-
plan_name=$(basename "$file_path" | sed 's/-add-route.*//' | sed 's/-plan-v[0-9]*$//')
|
|
50
|
-
# 从路径提取完整 planName(含 -plan-vN 后缀)
|
|
51
|
-
if echo "$file_path" | grep -qE 'add-route'; then
|
|
52
|
-
# add-route 写入:从文件名反推 planName
|
|
53
|
-
plan_prefix=$(basename "$file_path" | sed 's/-add-route-v[0-9]*\.md$//')
|
|
54
|
-
plan_dir=$(dirname "$file_path")
|
|
55
|
-
if [ -d "$plan_dir" ]; then
|
|
56
|
-
plan_file=$(ls "$plan_dir"/*-plan-v*.md 2>/dev/null | head -1 || echo "")
|
|
57
|
-
if [ -n "$plan_file" ]; then
|
|
58
|
-
plan_name=$(basename "$plan_file" .md)
|
|
59
|
-
fi
|
|
60
|
-
fi
|
|
61
|
-
fi
|
|
62
|
-
if [ -n "$plan_name" ]; then
|
|
63
|
-
echo "[ADD PostToolUse] 📊 自动同步 PlanRecord: plan_track({ planName: \"${plan_name}\" }) — 请执行" >&2
|
|
64
|
-
fi
|
|
65
|
-
fi
|
|
66
|
-
|
|
67
|
-
# §2c: devlog 自动提醒 — add-route Step 8 全 [x] 时提醒
|
|
68
|
-
if echo "$file_path" | grep -qE 'add-route.*\.md$'; then
|
|
69
|
-
if [ -f "$file_path" ]; then
|
|
70
|
-
step8_content=$(sed -n '/## Step 8/,/^## /p' "$file_path" 2>/dev/null || echo "")
|
|
71
|
-
unchecked=$(echo "$step8_content" | grep -c '^\- \[ \]' 2>/dev/null || echo "0")
|
|
72
|
-
checked=$(echo "$step8_content" | grep -c '^\- \[x\]' 2>/dev/null || echo "0")
|
|
73
|
-
if [ "$unchecked" = "0" ] && [ "$checked" -gt 0 ]; then
|
|
74
|
-
echo "[ADD PostToolUse] ⚠️ Step 8 全部收敛完成!请写 devlog日志(走mcp) → 更新 handoff" >&2
|
|
75
|
-
fi
|
|
76
|
-
fi
|
|
77
|
-
fi
|
|
78
|
-
|
|
79
|
-
# §2d: schema.json 自动 regen — 模板 .md 修改后更新对应 schema
|
|
80
|
-
if echo "$file_path" | grep -qE 'templates/.*\.md$'; then
|
|
81
|
-
schema_file="${file_path%.md}.schema.json"
|
|
82
|
-
if [ -f "$schema_file" ]; then
|
|
83
|
-
# 扫描模板实际 ## 标题,更新 schema sections
|
|
84
|
-
headings=$(grep -oP '^## \K.+' "$file_path" 2>/dev/null | head -20 || echo "")
|
|
85
|
-
if [ -n "$headings" ]; then
|
|
86
|
-
echo "[ADD PostToolUse] 🔄 模板已修改,请检查 ${schema_file} 是否需更新(§ sections)" >&2
|
|
87
|
-
echo "[ADD PostToolUse] 模板标题: $(echo "$headings" | tr '\n' ' ')" >&2
|
|
88
|
-
fi
|
|
89
|
-
fi
|
|
90
|
-
fi
|
|
91
|
-
|
|
92
|
-
# §2e: 审计提醒
|
|
93
|
-
echo "[ADD PostToolUse] 文件已写入: ${file_path}。请执行 record_dev_operation 落库审计(ADD-7)。" >&2
|
|
94
|
-
exit 0
|
|
95
|
-
fi
|
|
96
|
-
|
|
97
|
-
# ═══════════════ §3: Bash matcher: 结果增强 ═══════════════
|
|
98
|
-
if [ "$tool_name" = "Bash" ]; then
|
|
99
|
-
echo "[ADD PostToolUse] 命令执行完成。如有 lint/tsc 错误请修复。" >&2
|
|
100
|
-
exit 0
|
|
101
|
-
fi
|
|
102
|
-
|
|
103
|
-
exit 0
|
|
104
|
-
#!/bin/bash
|
|
105
|
-
# post-tool-use.sh — Claude Code PostToolUse:格式化 + 文档守卫 + 审计提醒
|
|
106
|
-
# 治理卡位 #5: 格式化 + ADD文档守卫 + 审计落库 + 结果增强
|
|
107
|
-
set -euo pipefail
|
|
108
|
-
|
|
109
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
110
|
-
COMMON_LIB="$HOOK_DIR/lib/common.sh"
|
|
111
|
-
[ -f "$COMMON_LIB" ] && source "$COMMON_LIB"
|
|
112
|
-
|
|
113
|
-
input=$(parse_input)
|
|
114
|
-
tool_name=$(json_get "$input" "tool_name")
|
|
115
|
-
[ -z "$tool_name" ] && tool_name=$(echo "$input" | grep -o '"tool_name"[[:space:]]*:[[:space:]]*"[^"]*"' 2>/dev/null | sed 's/.*: *"\([^"]*\)".*/\1/' || echo "")
|
|
116
|
-
|
|
117
|
-
# ── Edit/Write matcher: 格式化 + ADD文档守卫 ──
|
|
118
|
-
if [ "$tool_name" = "Edit" ] || [ "$tool_name" = "Write" ]; then
|
|
119
|
-
file_path=$(echo "$input" | grep -o '"file_path"[[:space:]]*:[[:space:]]*"[^"]*"' 2>/dev/null | sed 's/.*: *"\([^"]*\)".*/\1/' || echo "")
|
|
120
|
-
[ -z "$file_path" ] && exit 0
|
|
121
|
-
|
|
122
|
-
# ADD 文档结构守卫:写入 plans/specs/reviews 后提示
|
|
123
|
-
if echo "$file_path" | grep -qE '\.(qoder|claude|add)/(plans|specs|reviews)/'; then
|
|
124
|
-
echo "[ADD PostToolUse] ADD 文档已写入: ${file_path}。请确保章节完整、双向链接齐全、增量修订格式正确。" >&2
|
|
125
|
-
fi
|
|
126
|
-
|
|
127
|
-
# 审计提醒(所有文件写入)
|
|
128
|
-
echo "[ADD PostToolUse] 文件已写入: ${file_path}。请执行 record_dev_operation 落库审计(ADD-7)。" >&2
|
|
129
|
-
exit 0
|
|
130
|
-
fi
|
|
131
|
-
|
|
132
|
-
# ── Bash matcher: 结果增强 ──
|
|
133
|
-
if [ "$tool_name" = "Bash" ]; then
|
|
134
|
-
echo "[ADD PostToolUse] 命令执行完成。如有 lint/tsc 错误请修复。" >&2
|
|
135
|
-
exit 0
|
|
136
|
-
fi
|
|
137
|
-
|
|
138
|
-
exit 0
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# pre-compact.sh — 上下文压缩前 ADD 状态保存(Claude Code 适配)
|
|
3
|
-
# 治理卡位 #9: ADD状态保存 + 恢复清单导出 + tpl标记清理
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
export CURRENT_MAGIC=$(basename "$(dirname "$HOOK_DIR")")
|
|
8
|
-
COMMON_LIB="$HOOK_DIR/lib/common.sh"
|
|
9
|
-
[ -f "$COMMON_LIB" ] && source "$COMMON_LIB"
|
|
10
|
-
|
|
11
|
-
export PROJECT_DIR="$PWD"
|
|
12
|
-
|
|
13
|
-
# ── ① 获取 ADD 状态并保存到标记文件 ──
|
|
14
|
-
if type detect_active_add >/dev/null 2>&1; then
|
|
15
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
16
|
-
if [ -n "$state" ]; then
|
|
17
|
-
IFS='::' read -r plan step rounds handoff add_route <<< "$state"
|
|
18
|
-
|
|
19
|
-
# 写入恢复标记文件(SessionStart 恢复时读取)
|
|
20
|
-
RECOVERY_FILE="/tmp/add_recovery_$(echo "${PROJECT_DIR}" | md5sum 2>/dev/null | cut -c1-8 || echo "default")"
|
|
21
|
-
cat > "$RECOVERY_FILE" <<EOF
|
|
22
|
-
plan=${plan}
|
|
23
|
-
step=${step}
|
|
24
|
-
rounds=${rounds}
|
|
25
|
-
handoff=${handoff}
|
|
26
|
-
add_route=${add_route}
|
|
27
|
-
EOF
|
|
28
|
-
|
|
29
|
-
echo "[ADD PreCompact] ADD 状态已保存: Plan=${plan}, Step=${step}" >&2
|
|
30
|
-
fi
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
# ── ② 清理 tpl-injected 标记(compact 后上下文丢失,下次需重注) ──
|
|
34
|
-
TPL_FLAG="/tmp/add_tpl_$(echo "${PROJECT_DIR}" | md5sum 2>/dev/null | cut -c1-8 || echo "default")"
|
|
35
|
-
rm -f "$TPL_FLAG" 2>/dev/null || true
|
|
36
|
-
|
|
37
|
-
exit 0
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# pre-tool-use.sh — PreToolUse §A§B(阻断模式,通用适配版)
|
|
3
|
-
# §A: Bash 裸写保护 — 拦截所有绕过 IDE 追踪的文件写操作
|
|
4
|
-
# §B: Write/Edit 写入前置守卫 — Plan/Spec/Review 需要活跃 ADD Plan + 敏感文件保护
|
|
5
|
-
# 治理卡位 #4: 危险命令拦截 / 模板路径兜底 / 写入前置守卫 / 敏感文件保护
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
input=$(cat)
|
|
9
|
-
|
|
10
|
-
# 探测 MAGIC_DIR 和 PROJECT_DIR(兼容多种 adapter)
|
|
11
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
12
|
-
PARENT="$(dirname "$HOOK_DIR")"
|
|
13
|
-
MAGIC_DIR="$(basename "$PARENT")"
|
|
14
|
-
PROJECT_DIR="$PWD"
|
|
15
|
-
|
|
16
|
-
# ── Hook 通知: 拦截事件写入 jsonl(旁路,失败不阻断 exit 2)──
|
|
17
|
-
source "${HOOK_DIR}/lib/notify.sh" 2>/dev/null || true
|
|
18
|
-
ACTIVE_PLAN=$(detect_active_add 2>/dev/null || true)
|
|
19
|
-
if [ -n "$ACTIVE_PLAN" ]; then
|
|
20
|
-
PLAN_KEYWORD="${ACTIVE_PLAN%%::*}"
|
|
21
|
-
PLAN_STATUS="active"
|
|
22
|
-
else
|
|
23
|
-
PLAN_KEYWORD="no-active-plan"
|
|
24
|
-
PLAN_STATUS="none"
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
# ── §A 辅助函数: 阻断日志 ──
|
|
28
|
-
_log_block() {
|
|
29
|
-
local rule="$1" cmd="$2"
|
|
30
|
-
mkdir -p "$PROJECT_DIR/$MAGIC_DIR/debug-dump"
|
|
31
|
-
cat >> "$PROJECT_DIR/$MAGIC_DIR/debug-dump/stdin.log" <<BLOCKLOG
|
|
32
|
-
=== $(date) [BLOCKED by §A: ${rule}] ===
|
|
33
|
-
command: ${cmd:0:300}
|
|
34
|
-
=== DONE ===
|
|
35
|
-
BLOCKLOG
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
# ═══════════════ §A: Bash 工具写入保护 ═══════════════
|
|
39
|
-
# 任何通过 Bash 修改文件内容的操作都会绕过 IDE 工具层(Write/SearchReplace),
|
|
40
|
-
# 导致 Plan 关联检查、doc-format-guard、审计追踪全部失效。
|
|
41
|
-
# 因此全局阻断所有可写文件的 Bash 命令,强制走 IDE 工具通道。
|
|
42
|
-
command=$(echo "$input" | jq -r '.tool_input.command // empty')
|
|
43
|
-
if [ -n "$command" ]; then
|
|
44
|
-
|
|
45
|
-
# 检测 1: 脚本解释器 — 可写任意文件,无法解析脚本内容做细粒度拦截
|
|
46
|
-
if echo "$command" | grep -qE '(^|;|\|\||&&|\|)\s*(python3?|node|ruby|perl|php)(\s|$)'; then
|
|
47
|
-
_reason="禁止通过脚本解释器直接修改文件。请使用 Write 或 SearchReplace 工具操作文件。"
|
|
48
|
-
cat >&2 <<'EOF'
|
|
49
|
-
⛔ [ADD PreToolUse §A] 阻断: 禁止通过脚本解释器直接修改文件。
|
|
50
|
-
|
|
51
|
-
python/node/ruby/perl/php 可在脚本中写入任意文件,绕过:
|
|
52
|
-
· Plan 关联检查(哪个文件属于哪个 ADD Plan?)
|
|
53
|
-
· doc-format-guard(章节/占位符/禁止词校验)
|
|
54
|
-
· 审计追踪(agentAudit 无法感知 Bash 内部的文件变更)
|
|
55
|
-
|
|
56
|
-
→ 请改用 Write 或 SearchReplace 工具操作文件。
|
|
57
|
-
→ 如需运行构建/测试脚本,使用 npx/pnpm/npm 命令。
|
|
58
|
-
EOF
|
|
59
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
60
|
-
_log_block "脚本解释器" "$command"
|
|
61
|
-
write_hook_event "pre-tool-use" "deny" "$command" "禁止通过脚本解释器直接修改文件" "$PLAN_KEYWORD" "$PLAN_STATUS" 2>/dev/null || true
|
|
62
|
-
exit 2
|
|
63
|
-
fi
|
|
64
|
-
|
|
65
|
-
# 检测 2: sed -i 原地编辑
|
|
66
|
-
if echo "$command" | grep -qE '\bsed\b.*-i'; then
|
|
67
|
-
_reason="禁止通过 sed -i 直接编辑文件。请使用 SearchReplace 工具。"
|
|
68
|
-
cat >&2 <<'EOF'
|
|
69
|
-
⛔ [ADD PreToolUse §A] 阻断: 禁止通过 sed -i 原地编辑文件。
|
|
70
|
-
|
|
71
|
-
sed -i 直接写入文件,绕过 IDE 工具层的所有校验。
|
|
72
|
-
→ 请改用 SearchReplace 工具。
|
|
73
|
-
EOF
|
|
74
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
75
|
-
_log_block "sed -i" "$command"
|
|
76
|
-
write_hook_event "pre-tool-use" "deny" "$command" "禁止通过 sed -i 原地编辑" "$PLAN_KEYWORD" "$PLAN_STATUS" 2>/dev/null || true
|
|
77
|
-
exit 2
|
|
78
|
-
fi
|
|
79
|
-
|
|
80
|
-
# 检测 3: 输出重定向 (>/>>) 写入文件
|
|
81
|
-
if echo "$command" | grep -qE '[>]{1,2}\s+\S'; then
|
|
82
|
-
_reason="禁止通过重定向写入文件。请使用 Write 工具。"
|
|
83
|
-
cat >&2 <<'EOF'
|
|
84
|
-
⛔ [ADD PreToolUse §A] 阻断: 禁止通过重定向(>/>>)写入文件。
|
|
85
|
-
|
|
86
|
-
重定向写入绕过 IDE 工具层,变更无法追踪。
|
|
87
|
-
→ 请改用 Write 工具。
|
|
88
|
-
EOF
|
|
89
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
90
|
-
_log_block "重定向" "$command"
|
|
91
|
-
write_hook_event "pre-tool-use" "deny" "$command" "禁止通过重定向写入文件" "$PLAN_KEYWORD" "$PLAN_STATUS" 2>/dev/null || true
|
|
92
|
-
exit 2
|
|
93
|
-
fi
|
|
94
|
-
|
|
95
|
-
# 检测 4: tee / dd 写入
|
|
96
|
-
if echo "$command" | grep -qE '\btee\b|\bdd\b.*of='; then
|
|
97
|
-
_reason="禁止通过 tee/dd 写入文件。请使用 Write 或 SearchReplace 工具。"
|
|
98
|
-
cat >&2 <<'EOF'
|
|
99
|
-
⛔ [ADD PreToolUse §A] 阻断: 禁止通过 tee/dd 写入文件。
|
|
100
|
-
|
|
101
|
-
→ 请改用 Write 或 SearchReplace 工具。
|
|
102
|
-
EOF
|
|
103
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
104
|
-
_log_block "tee/dd" "$command"
|
|
105
|
-
write_hook_event "pre-tool-use" "deny" "$command" "禁止通过 tee/dd 写入文件" "$PLAN_KEYWORD" "$PLAN_STATUS" 2>/dev/null || true
|
|
106
|
-
exit 2
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
# 检测 5: cp / mv / touch — 可创建或覆盖文件
|
|
110
|
-
if echo "$command" | grep -qE '(^|;|\|\||&&|\|)\s*(cp|mv|touch)\b'; then
|
|
111
|
-
_reason="禁止通过 cp/mv/touch 操作文件。请使用 Write 或 SearchReplace 工具。"
|
|
112
|
-
cat >&2 <<'EOF'
|
|
113
|
-
⛔ [ADD PreToolUse §A] 阻断: 禁止通过 cp/mv/touch 操作文件。
|
|
114
|
-
|
|
115
|
-
→ 请改用 Write 或 SearchReplace 工具。
|
|
116
|
-
EOF
|
|
117
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
118
|
-
_log_block "cp/mv/touch" "$command"
|
|
119
|
-
write_hook_event "pre-tool-use" "deny" "$command" "禁止通过 cp/mv/touch 操作文件" "$PLAN_KEYWORD" "$PLAN_STATUS" 2>/dev/null || true
|
|
120
|
-
exit 2
|
|
121
|
-
fi
|
|
122
|
-
|
|
123
|
-
# 放行: 构建工具(npx/pnpm/npm/yarn)、版本控制(git)、
|
|
124
|
-
# 只读操作(ls/cat/grep/find/head/tail/wc)、目录操作(mkdir/rmdir) 等
|
|
125
|
-
exit 0
|
|
126
|
-
fi
|
|
127
|
-
|
|
128
|
-
# ═══════════════ §B: Write/Edit 文件写入前置守卫 ═══════════════
|
|
129
|
-
# 非 Bash 工具(Write/Edit)的文件写入需要经过:
|
|
130
|
-
# 1. Plan/Spec/Review 文档写入 → 需要活跃 ADD Plan
|
|
131
|
-
# 2. 敏感文件保护 → 阻断写入
|
|
132
|
-
# 3. Dev Action 标记 → 用于 Stop 检查
|
|
133
|
-
# 注意: 不再对 src/**/*.ts 做 Plan 白名单放行,避免绕过 skill/rules 规定的 HITL。
|
|
134
|
-
tool_name=$(echo "$input" | jq -r '.tool_name // empty')
|
|
135
|
-
if [ "$tool_name" = "Write" ] || [ "$tool_name" = "Edit" ] || [ "$tool_name" = "SearchReplace" ]; then
|
|
136
|
-
file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
|
|
137
|
-
[ -z "$file_path" ] && exit 0
|
|
138
|
-
|
|
139
|
-
if echo "$file_path" | grep -qE '\.(qoder|claude|add)/(plans|specs|reviews)/'; then
|
|
140
|
-
if type detect_active_add >/dev/null 2>&1; then
|
|
141
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
142
|
-
if [ -z "$state" ]; then
|
|
143
|
-
echo "[ADD 提示] 正在写入 Plan/Spec/Review 文档但无活跃 ADD Plan——首次创建场景放行,建议先执行 add-paradigm 生成 Plan+add-route" >&2
|
|
144
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"allow\",\"permissionDecisionReason\":\"无活跃 ADD Plan 但为 Plan/Spec/Review 写入(首次创建场景),提示而非拦截\"}}"
|
|
145
|
-
write_hook_event "pre-tool-use" "info" "$tool_name $file_path" "无活跃 ADD Plan 下写入 Plan/Spec/Review(首次创建放行)" "$PLAN_KEYWORD" "$PLAN_STATUS" 2>/dev/null || true
|
|
146
|
-
exit 0
|
|
147
|
-
fi
|
|
148
|
-
fi
|
|
149
|
-
fi
|
|
150
|
-
|
|
151
|
-
if echo "$file_path" | grep -qE '\.env$|\.env\.production$|\.env\.local$|credentials|secrets'; then
|
|
152
|
-
echo "⛔ 敏感文件受保护,禁止写入: $file_path" >&2
|
|
153
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"敏感文件受保护\"}}"
|
|
154
|
-
exit 2
|
|
155
|
-
fi
|
|
156
|
-
|
|
157
|
-
# §C: 模板类型前置注入 — plans/ 写入前提示应选模板
|
|
158
|
-
if echo "$file_path" | grep -qE '\.(qoder|claude|add|vscode|trae)/(plans)/'; then
|
|
159
|
-
fname=$(basename "$file_path")
|
|
160
|
-
if echo "$fname" | grep -qE 'plan-v[0-9]'; then
|
|
161
|
-
echo "💡 [ADD PreToolUse] 写入 Plan → 模板: standard-plan-template.md(标准)或 simple-plan-template.md(≤3文件)" >&2
|
|
162
|
-
elif echo "$fname" | grep -qE 'add-route'; then
|
|
163
|
-
echo "💡 [ADD PreToolUse] 写入 ADD Route → 模板: add-route-template.md" >&2
|
|
164
|
-
elif echo "$fname" | grep -qE 'handoff'; then
|
|
165
|
-
echo "💡 [ADD PreToolUse] 写入 Handoff → 模板: handoff-single-round-template.md(单轮)或 handoff-multi-round-template.md(多轮)" >&2
|
|
166
|
-
fi
|
|
167
|
-
# Write 大文件适配 — 已存在大文件建议用 SearchReplace 分块
|
|
168
|
-
if echo "$tool_name" | grep -qE 'Write' && [ -f "$file_path" ]; then
|
|
169
|
-
fsize=$(wc -c < "$file_path" 2>/dev/null || echo "0")
|
|
170
|
-
if [ "$fsize" -gt 2000 ] 2>/dev/null; then
|
|
171
|
-
echo "⚠️ [ADD PreToolUse] 文件已有 ${fsize} 字节,Write 全量覆盖可能触发工具 payload 限制。建议用 SearchReplace 分块追加。" >&2
|
|
172
|
-
fi
|
|
173
|
-
fi
|
|
174
|
-
fi
|
|
175
|
-
|
|
176
|
-
# §C: HITL tongyi 检查 — plans/ + PLAN_REVIEW reviews/ 写入前必须有 .hitl-tongyi-{planName} 哨兵
|
|
177
|
-
# implementation/runtime review 不需要 HITL,走 §B 活跃 Plan 检查
|
|
178
|
-
# handoff 是 Step 8 收敛产物(多轮交接手册),不经 HITL 审批,同样豁免
|
|
179
|
-
# TODO 应该caijuehub管理
|
|
180
|
-
if echo "$file_path" | grep -qE '\.(qoder|claude|add|vscode|trae)/(plans)/'; then
|
|
181
|
-
if echo "$file_path" | grep -qE '\-handoff'; then
|
|
182
|
-
_do_hitl=false # handoff 不被 HITL 拦截(Step 8 产物,无独立审批)
|
|
183
|
-
else
|
|
184
|
-
_do_hitl=true
|
|
185
|
-
fi
|
|
186
|
-
elif echo "$file_path" | grep -qE '\.(qoder|claude|add|vscode|trae)/(reviews)/'; then
|
|
187
|
-
if echo "$file_path" | grep -qE '-(implementation|runtime)'; then
|
|
188
|
-
_do_hitl=false # implementation/runtime review 不被 HITL 拦截
|
|
189
|
-
else
|
|
190
|
-
_do_hitl=true # PLAN_REVIEW 需要 HITL
|
|
191
|
-
fi
|
|
192
|
-
else
|
|
193
|
-
_do_hitl=false
|
|
194
|
-
fi
|
|
195
|
-
|
|
196
|
-
if [ "$_do_hitl" = true ]; then
|
|
197
|
-
_relative=$(echo "$file_path" | sed 's|.*/\.\(qoder\|claude\|add\|vscode\|trae\)/\(plans\|reviews\)/||')
|
|
198
|
-
_planName=$(basename "$_relative" .md | sed 's/\.hitl$//;s/-plan-v[0-9]*$//;s/-add-route-v[0-9]*$//;s/-review-v[0-9]*$//;s/-review-implementation$//;s/-review-runtime$//')
|
|
199
|
-
if [ -n "$_planName" ]; then
|
|
200
|
-
_tongyi_marker="${PROJECT_DIR}/${MAGIC_DIR}/hitl/.tongyi-${_planName}"
|
|
201
|
-
if [ ! -f "$_tongyi_marker" ]; then
|
|
202
|
-
echo "⛔ [ADD PreToolUse §C] HITL 未 tongyi: $file_path" >&2
|
|
203
|
-
echo " 原因: 哨兵文件 $_tongyi_marker 不存在" >&2
|
|
204
|
-
echo " 操作: 请先调用 create_hitl 创建审批,再 update_hitl({ status: \"TONGYI\" })" >&2
|
|
205
|
-
_reason="HITL 未 tongyi: 哨兵 ${_tongyi_marker} 不存在。请先 create_hitl → 人工 tongyi → update_hitl 后再写入"
|
|
206
|
-
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"${_reason}\",\"additionalContext\":\"${_reason}\"}}"
|
|
207
|
-
write_hook_event "pre-tool-use" "deny" "$tool_name $file_path" "HITL 未 tongyi: $_tongyi_marker" "$PLAN_KEYWORD" "$PLAN_STATUS" 2>/dev/null || true
|
|
208
|
-
exit 0
|
|
209
|
-
fi
|
|
210
|
-
fi
|
|
211
|
-
fi
|
|
212
|
-
|
|
213
|
-
mark_dev_action 2>/dev/null || true
|
|
214
|
-
exit 0
|
|
215
|
-
fi
|
|
216
|
-
|
|
217
|
-
exit 0
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# prompt-submit.sh — UserPromptSubmit 触发词智能路由(通用适配版)
|
|
3
|
-
# 治理卡位 #3: Layer 1 精准触发 → Layer 2 阻断 → Layer 3 状态注入
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
input=$(cat)
|
|
7
|
-
prompt=$(echo "$input" | jq -r '.prompt // empty')
|
|
8
|
-
[ -z "$prompt" ] && exit 0
|
|
9
|
-
|
|
10
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
11
|
-
source "$HOOK_DIR/lib/vocabulary.sh" 2>/dev/null || true
|
|
12
|
-
source "$HOOK_DIR/lib/state-detect.sh" 2>/dev/null || true
|
|
13
|
-
source "$HOOK_DIR/lib/notify.sh" 2>/dev/null || true
|
|
14
|
-
|
|
15
|
-
# ─── Layer 1: 精准 P0 触发词 ───
|
|
16
|
-
matched=$(match_trigger "$prompt" 2>/dev/null || true)
|
|
17
|
-
if [ -n "$matched" ]; then
|
|
18
|
-
# 验收幂等保护: 如果已验收,提示不重复
|
|
19
|
-
if echo "$prompt" | grep -qiE '验收|收敛' 2>/dev/null; then
|
|
20
|
-
add_state=$(detect_active_add 2>/dev/null || true)
|
|
21
|
-
if [ -n "$add_state" ]; then
|
|
22
|
-
_handoff=$(echo "$add_state" | awk -F'::' '{print $4}')
|
|
23
|
-
_add_route=$(echo "$add_state" | awk -F'::' '{print $5}')
|
|
24
|
-
if is_already_accepted "$_add_route" "$_handoff" 2>/dev/null; then
|
|
25
|
-
cat <<EOF
|
|
26
|
-
[ADD 验收] ⚠️ 已验收。进入 Review 模式:
|
|
27
|
-
① 重新检查 checklist [T]/[R] 项
|
|
28
|
-
② 审查 audit 记录完整性
|
|
29
|
-
③ 如有差异 → Review 回流至 handoff(增量更新,不覆盖已有结论)
|
|
30
|
-
④ 无差异 → 记录 'Review 已确认,无新发现'
|
|
31
|
-
★ 同步检查: 如 checklist 有新 cuid 但 handoff 审计表缺失 → 更新 handoff ADD-7 表 + query_audit_logs 命令
|
|
32
|
-
EOF
|
|
33
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
34
|
-
"$HOOK_DIR/review-checklist.sh" "$_handoff" "$_add_route" 2>/dev/null || true
|
|
35
|
-
exit 0
|
|
36
|
-
fi
|
|
37
|
-
fi
|
|
38
|
-
fi
|
|
39
|
-
echo "$matched"
|
|
40
|
-
exit 0
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
# ─── 开发关键词检测(动态加载) ───
|
|
44
|
-
dev_kw=$(load_dev_keywords 2>/dev/null || true)
|
|
45
|
-
if [ -z "$dev_kw" ]; then
|
|
46
|
-
exit 0
|
|
47
|
-
fi
|
|
48
|
-
|
|
49
|
-
if ! echo "$prompt" | grep -qiE "$dev_kw"; then
|
|
50
|
-
exit 0
|
|
51
|
-
fi
|
|
52
|
-
|
|
53
|
-
# ─── Layer 2/3: 按活跃 ADD 分流 ───
|
|
54
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
55
|
-
if [ -z "$state" ]; then
|
|
56
|
-
# Layer 2: 无活跃 ADD → 提示启动(不阻断)
|
|
57
|
-
cat >&2 <<'EOF'
|
|
58
|
-
[ADD 提示] 检测到开发任务,但无活跃 ADD Plan。建议先执行 add-paradigm SKILL:
|
|
59
|
-
Step 0: 文档先行 (Plan → Review → Specs)
|
|
60
|
-
Step 3: 代码实现 + 审计植入
|
|
61
|
-
Step 8: 收敛判断
|
|
62
|
-
EOF
|
|
63
|
-
write_hook_event "prompt-submit" "info" "$prompt" "无活跃 ADD Plan 下检测到开发任务" "no-active-plan" "none" 2>/dev/null || true
|
|
64
|
-
exit 0
|
|
65
|
-
fi
|
|
66
|
-
|
|
67
|
-
# Layer 3: 有活跃 ADD → 注入状态
|
|
68
|
-
plan=$(echo "$state" | awk -F'::' '{print $1}')
|
|
69
|
-
step=$(echo "$state" | awk -F'::' '{print $2}')
|
|
70
|
-
rounds=$(echo "$state" | awk -F'::' '{print $3}')
|
|
71
|
-
handoff=$(echo "$state" | awk -F'::' '{print $4}')
|
|
72
|
-
echo "[ADD 状态] Plan: ${plan}, 轮次: ${rounds}, Step: ${step}, handoff: ${handoff}"
|
|
73
|
-
|
|
74
|
-
# ─── Hook 治理日报(注入 AI 上下文)───
|
|
75
|
-
HOOK_JSONL="${MAGIC_DIR:-.qoder}/reports/hook-events.jsonl"
|
|
76
|
-
if [ -f "$HOOK_JSONL" ]; then
|
|
77
|
-
TODAY="$(date +%Y-%m-%d)"
|
|
78
|
-
TOTAL=$(grep -c "\"ts\":\"${TODAY}" "$HOOK_JSONL" 2>/dev/null || echo 0)
|
|
79
|
-
NO_PLAN=$(grep "\"ts\":\"${TODAY}" "$HOOK_JSONL" 2>/dev/null | grep -c '"planKeyword":"no-active-plan"' || echo 0)
|
|
80
|
-
if [ "$TOTAL" -gt 0 ] 2>/dev/null; then
|
|
81
|
-
echo "[Hook 治理] 今日提示: ${TOTAL} 次 | 无 Plan 提示: ${NO_PLAN} 次"
|
|
82
|
-
if [ "$NO_PLAN" -ge 10 ] 2>/dev/null; then
|
|
83
|
-
echo "[Hook ⚠️] 无 Plan 提示已达 ${NO_PLAN} 次(≥10),建议创建 Plan 或检查 hooks 误报"
|
|
84
|
-
fi
|
|
85
|
-
fi
|
|
86
|
-
fi
|
|
87
|
-
exit 0
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# review-checklist.sh — Review 检查清单校验(Claude Code 适配)
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
|
|
5
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
6
|
-
SHARED_LIB="$HOOK_DIR/../../shared/hooks-lib/common.sh"
|
|
7
|
-
[ -f "$SHARED_LIB" ] && source "$SHARED_LIB"
|
|
8
|
-
|
|
9
|
-
echo "[ADD ReviewChecklist] 请在提交前确认 checklist.md 全部项已勾选。"
|
|
10
|
-
exit 0
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# SessionEnd — 通用版(核心模板,Trae 等适配器继承)
|
|
3
|
-
# 治理卡位 #2: 标记清理 + 会话审计结算 + Stop未触发兜底
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
COMMON_LIB="$HOOK_DIR/lib/common.sh"
|
|
8
|
-
[ -f "$COMMON_LIB" ] && source "$COMMON_LIB"
|
|
9
|
-
|
|
10
|
-
export PROJECT_DIR="$PWD"
|
|
11
|
-
|
|
12
|
-
# ── ① 清理 tpl-injected 标记 ──
|
|
13
|
-
project_hash=$(echo "${PROJECT_DIR:-$PWD}" | md5sum 2>/dev/null | cut -c1-8 || echo "default")
|
|
14
|
-
rm -f "/tmp/add_tpl_${project_hash}" 2>/dev/null || true
|
|
15
|
-
|
|
16
|
-
# ── ② 清理 dev action 标记 ──
|
|
17
|
-
rm -f "/tmp/add_dev_${project_hash}" 2>/dev/null || true
|
|
18
|
-
|
|
19
|
-
# ── ③ Stop 未触发兜底: 如果 dev action 标记还在,补执行 checklist 快照 ──
|
|
20
|
-
if has_dev_action 2>/dev/null; then
|
|
21
|
-
echo "[ADD SessionEnd] ⚠️ 检测到 dev action 标记未清除——Stop 可能未触发验收检查" >&2
|
|
22
|
-
|
|
23
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
24
|
-
if [ -n "$state" ]; then
|
|
25
|
-
handoff=$(echo "$state" | awk -F'::' '{print $4}')
|
|
26
|
-
add_route=$(echo "$state" | awk -F'::' '{print $5}')
|
|
27
|
-
if [ -f "$handoff" ]; then
|
|
28
|
-
echo "[ADD SessionEnd] 补执行 checklist 快照(best-effort,不阻断)" >&2
|
|
29
|
-
if type check_add_completeness >/dev/null 2>&1; then
|
|
30
|
-
check_add_completeness "$handoff" "$add_route" >&2 2>/dev/null || true
|
|
31
|
-
fi
|
|
32
|
-
fi
|
|
33
|
-
fi
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
# ── ④ 审计结算 ──
|
|
37
|
-
echo "[ADD SessionEnd] 会话结束 — $(date -Iseconds)" >&2
|
|
38
|
-
exit 0
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# SessionStart — ADD 上下文恢复 + 模板索引注入(Claude Code 适配)
|
|
3
|
-
# 治理卡位 #1: ADD状态恢复 + 模板索引注入
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
export CURRENT_MAGIC=$(basename "$(dirname "$HOOK_DIR")")
|
|
8
|
-
|
|
9
|
-
# 加载四端通用函数(路径统一后: .claude/hooks/lib/common.sh)
|
|
10
|
-
COMMON_LIB="$HOOK_DIR/lib/common.sh"
|
|
11
|
-
[ -f "$COMMON_LIB" ] && source "$COMMON_LIB"
|
|
12
|
-
|
|
13
|
-
# 设置项目目录
|
|
14
|
-
export PROJECT_DIR="$PWD"
|
|
15
|
-
|
|
16
|
-
# ── ① ADD 状态恢复 ──
|
|
17
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
18
|
-
if [ -n "$state" ]; then
|
|
19
|
-
IFS='::' read -r plan step rounds handoff add_route <<< "$state"
|
|
20
|
-
cat <<EOF
|
|
21
|
-
[ADD SessionStart] 检测到活跃 ADD Plan:
|
|
22
|
-
Plan: ${plan}
|
|
23
|
-
轮次: ${rounds}
|
|
24
|
-
当前 Step: ${step}
|
|
25
|
-
handoff: ${handoff}
|
|
26
|
-
恢复命令: query_audit_logs({ planKeyword: '${plan}' })
|
|
27
|
-
EOF
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
# ── ② 模板索引注入 ──
|
|
31
|
-
TPL_SCRIPT="$HOOK_DIR/lib/preload-templates.sh"
|
|
32
|
-
if [ -f "$TPL_SCRIPT" ]; then
|
|
33
|
-
bash "$TPL_SCRIPT" --index
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
# ── ③ §代办刷新:活跃 Plan 时提醒加载 IDE 代办 ──
|
|
37
|
-
# session-init Step 2.6 依赖 IDE resume invoke SKILL,本段作为兜底
|
|
38
|
-
if [ -n "$state" ]; then
|
|
39
|
-
IFS='::' read -r plan step rounds handoff add_route <<< "$state"
|
|
40
|
-
cat <<EOF
|
|
41
|
-
[代办] 检测到活跃 Plan: ${plan}。如有未加载的 IDE 代办清单,请从 tasks.md §IDE JSON 刷新 TodoWrite。
|
|
42
|
-
EOF
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
# ── ④ §HITL 待审批检测 ──
|
|
46
|
-
if [ -d "$PLANS_DIR" ]; then
|
|
47
|
-
hitl_count=$(find "$PLANS_DIR" -name "*.hitl.md" -mtime -7 -type f 2>/dev/null | wc -l)
|
|
48
|
-
if [ "$hitl_count" -gt 0 ] 2>/dev/null; then
|
|
49
|
-
echo "[HITL 待审批] 检测到 ${hitl_count} 个待审批 HITL 提案,请检查并处理"
|
|
50
|
-
fi
|
|
51
|
-
fi
|
|
52
|
-
|
|
53
|
-
exit 0
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# stop-check.sh — Claude Code Stop:四象限分流 + 验收检查(few-shot 上下文注入)
|
|
3
|
-
# 治理卡位 #7: 验收检查 + devlog + 阻断
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
export CURRENT_MAGIC=$(basename "$(dirname "$HOOK_DIR")")
|
|
8
|
-
COMMON_LIB="$HOOK_DIR/lib/common.sh"
|
|
9
|
-
[ -f "$COMMON_LIB" ] && source "$COMMON_LIB"
|
|
10
|
-
|
|
11
|
-
export PROJECT_DIR="$PWD"
|
|
12
|
-
|
|
13
|
-
state=$(detect_active_add 2>/dev/null || true)
|
|
14
|
-
has_dev=$(has_dev_action 2>/dev/null && echo "true" || echo "false")
|
|
15
|
-
|
|
16
|
-
# ═══════ Q1: 无 ADD + 无 dev → 正常停 ═══════
|
|
17
|
-
if [ -z "$state" ] && [ "$has_dev" != "true" ]; then
|
|
18
|
-
exit 0
|
|
19
|
-
fi
|
|
20
|
-
|
|
21
|
-
# ═══════ Q2: 无 ADD + 有 dev → 严重违规,few-shot 注入 ═══════
|
|
22
|
-
if [ -z "$state" ] && [ "$has_dev" = "true" ]; then
|
|
23
|
-
build_stop_context "no_add_has_dev" >&2
|
|
24
|
-
exit $EXIT_BLOCK
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
IFS='::' read -r plan step rounds handoff add_route <<< "$state"
|
|
28
|
-
|
|
29
|
-
# ═══════ Q3: 有 ADD + 无 dev → 注入状态 ═══════
|
|
30
|
-
if [ "$has_dev" != "true" ]; then
|
|
31
|
-
echo "[ADD Stop] Plan: ${plan}, 轮次: ${rounds}, Step: ${step}"
|
|
32
|
-
echo "本次无代码改动。下次继续时执行 session-init 恢复上下文。"
|
|
33
|
-
exit 0
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
# ═══════ Q4: 有 ADD + 有 dev → 验收检查 ═══════
|
|
37
|
-
issues=$(check_add_completeness "$handoff" "$add_route" 2>/dev/null || true)
|
|
38
|
-
if [ -n "$issues" ]; then
|
|
39
|
-
build_stop_context "has_add_dev_unclosed" "$issues" >&2
|
|
40
|
-
exit $EXIT_BLOCK
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
clear_dev_action 2>/dev/null || true
|
|
44
|
-
echo "[ADD Stop] ✅ 验收通过——checklist 全部勾选,devlog 已记录。"
|
|
45
|
-
exit 0
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# SubagentStart/SubagentStop — 子代理门禁(Claude Code 适配)
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
|
|
5
|
-
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
6
|
-
SHARED_LIB="$HOOK_DIR/../../shared/hooks-lib/common.sh"
|
|
7
|
-
[ -f "$SHARED_LIB" ] && source "$SHARED_LIB"
|
|
8
|
-
|
|
9
|
-
input=$(parse_input)
|
|
10
|
-
event=$(echo "$input" | jq -r '.hook_event_name // empty')
|
|
11
|
-
|
|
12
|
-
if [ "$event" = "SubagentStart" ]; then
|
|
13
|
-
echo "[ADD SubagentGuard] 子代理启动,请确认其遵循 ADD 规范。"
|
|
14
|
-
fi
|
|
15
|
-
exit 0
|