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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// notification.ts — Notification 入口薄壳(Task 2.2/3.1 继承体系)
|
|
2
|
+
// 治理逻辑: governance/notification-router.js(NotificationRouter 探测循环 + reviews 提醒)
|
|
3
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { readHookInput } from "../governance/common.js"
|
|
6
|
+
import { NotificationRouter } from "../governance/notification-router.js"
|
|
7
|
+
|
|
8
|
+
const input = readHookInput()
|
|
9
|
+
const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd()
|
|
10
|
+
|
|
11
|
+
process.exit(new NotificationRouter(PROJECT_DIR, ".add").run(input))
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// permission-gate.ts — PermissionRequest 入口薄壳(Task 5.1 继承体系)
|
|
2
|
+
// 治理逻辑: governance/permission-gate-router.js(PermissionGateRouter——jq 语义解析 + emit 输出)
|
|
3
|
+
// 入口职责: 仅进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { runPermissionGate } from "../governance/permission-gate-router.js"
|
|
6
|
+
|
|
7
|
+
runPermissionGate()
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// post-tool-failure.ts — PostToolUseFailure 入口薄壳(Task 5.1 继承体系)
|
|
2
|
+
// 治理逻辑: governance/post-tool-failure-router.js(PostToolFailureRouter——jq 语义解析 + emit 输出)
|
|
3
|
+
// 入口职责: 仅进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { runPostToolFailure } from "../governance/post-tool-failure-router.js"
|
|
6
|
+
|
|
7
|
+
runPostToolFailure()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// post-tool-use.ts — PostToolUse 入口薄壳(Task 2.2 薄壳化)
|
|
2
|
+
// 治理逻辑: lib/post-tool-router.ts(PostToolRouter §1 DPS 哨兵 / §2 文档守卫 / §3 Bash 增强)
|
|
3
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { jsonGet, readHookInput } from "../governance/common.js"
|
|
6
|
+
import { PostToolRouter } from "../governance/post-tool-router.js"
|
|
7
|
+
|
|
8
|
+
const input = readHookInput()
|
|
9
|
+
let toolName = jsonGet(input, "tool_name")
|
|
10
|
+
if (toolName === "") {
|
|
11
|
+
// bash 版此处 grep 兜底失败触发 set -e 崩溃(exit 1)——缺陷行为,
|
|
12
|
+
// TS 版修复:无 tool_name 的 PostToolUse 事件静默放行(冒烟契约 ∈ {0,2})。
|
|
13
|
+
const fallback = input.match(/"tool_name"\s*:\s*"([^"]*)"/)?.[1] ?? ""
|
|
14
|
+
if (fallback === "") {
|
|
15
|
+
process.exit(0)
|
|
16
|
+
}
|
|
17
|
+
toolName = fallback
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd()
|
|
21
|
+
const MAGIC_DIR = process.env.MAGIC_DIR || ".qoder"
|
|
22
|
+
|
|
23
|
+
process.exit(new PostToolRouter(PROJECT_DIR, MAGIC_DIR).run(input, toolName))
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// pre-compact.ts — 上下文压缩前 ADD 状态保存(入口薄壳,Task 2.2/3.1 继承体系)
|
|
2
|
+
// 治理逻辑: governance/pre-compact-guard.js(PreCompactGuard 状态保存 + tpl 标记清理)
|
|
3
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { PreCompactGuard } from "../governance/pre-compact-guard.js"
|
|
6
|
+
|
|
7
|
+
process.env.PROJECT_DIR = process.env.PROJECT_DIR || process.cwd()
|
|
8
|
+
|
|
9
|
+
process.exit(new PreCompactGuard().run())
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// pre-tool-use.ts — PreToolUse 入口薄壳(Task 2.2 薄壳化)
|
|
2
|
+
// 治理逻辑: lib/pre-tool-guard.ts(PreToolUseGuard 服务类,规则消费 hook-guard-rules.toml)
|
|
3
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { jsonGet, readHookInput, tryResolveMagicDir } from "../governance/common.js"
|
|
6
|
+
import { PreToolUseGuard } from "../governance/pre-tool-guard.js"
|
|
7
|
+
|
|
8
|
+
const input = readHookInput()
|
|
9
|
+
const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd()
|
|
10
|
+
|
|
11
|
+
// 探测 MAGIC_DIR(唯一解析链:注入优先 → 物理位置推导)
|
|
12
|
+
let MAGIC_DIR = process.env.MAGIC_DIR
|
|
13
|
+
if (!MAGIC_DIR) {
|
|
14
|
+
MAGIC_DIR = tryResolveMagicDir() || ".qoder"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const guard = new PreToolUseGuard(PROJECT_DIR, MAGIC_DIR)
|
|
18
|
+
|
|
19
|
+
const toolName = jsonGet(input, "tool_name")
|
|
20
|
+
const command = jsonGet(input, "command")
|
|
21
|
+
|
|
22
|
+
let exitCode = 0
|
|
23
|
+
if (command !== "") {
|
|
24
|
+
exitCode = guard.runSectionA(input)
|
|
25
|
+
if (exitCode !== 0) process.exit(exitCode)
|
|
26
|
+
} else {
|
|
27
|
+
exitCode = guard.runSectionB(input, toolName)
|
|
28
|
+
if (exitCode !== 0) process.exit(exitCode)
|
|
29
|
+
}
|
|
30
|
+
process.exit(0)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// prompt-submit.ts — UserPromptSubmit 入口薄壳(Task 2.2 薄壳化)
|
|
2
|
+
// 治理逻辑: lib/prompt-router.ts(PromptRouter L1/L2/L3 分流,日报阈值消费 hook-event-rules.toml)
|
|
3
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { readHookInput } from "../governance/common.js"
|
|
6
|
+
import { PromptRouter } from "../governance/prompt-router.js"
|
|
7
|
+
|
|
8
|
+
const input = readHookInput()
|
|
9
|
+
const MAGIC_DIR = process.env.MAGIC_DIR || ".qoder"
|
|
10
|
+
|
|
11
|
+
process.exit(new PromptRouter(MAGIC_DIR).run(input))
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// session-end.ts — SessionEnd 入口薄壳(Task 2.2 薄壳化)
|
|
2
|
+
// 治理逻辑: lib/session-end.ts(SessionEndGuard 清理 + 结算 + 兜底)
|
|
3
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { SessionEndGuard } from "../governance/session-end.js"
|
|
6
|
+
|
|
7
|
+
const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd()
|
|
8
|
+
process.env.PROJECT_DIR = PROJECT_DIR
|
|
9
|
+
|
|
10
|
+
process.exit(new SessionEndGuard(PROJECT_DIR).run())
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// session-start.ts — SessionStart 入口薄壳(Task 2.2 薄壳化)
|
|
2
|
+
// 治理逻辑: lib/session-start-guard.ts(SessionStartGuard 状态恢复 + 模板索引 + 代办 + HITL)
|
|
3
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { SessionStartGuard } from "../governance/session-start-guard.js"
|
|
6
|
+
|
|
7
|
+
const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd()
|
|
8
|
+
|
|
9
|
+
process.exit(new SessionStartGuard(PROJECT_DIR).run())
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// stop-check.ts — Stop 入口薄壳(Task 2.2 薄壳化)
|
|
2
|
+
// 治理逻辑: lib/stop-router.ts(StopRouter 四象限分流,象限文本消费 hook-context-rules.toml)
|
|
3
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { tryResolveMagicDir } from "../governance/common.js"
|
|
6
|
+
import { StopRouter } from "../governance/stop-router.js"
|
|
7
|
+
|
|
8
|
+
// 对齐 bash: MAGIC_DIR 从物理位置推导并 export(入口注入优先)
|
|
9
|
+
const inferredMagicDir = tryResolveMagicDir()
|
|
10
|
+
if (inferredMagicDir && !process.env.MAGIC_DIR) {
|
|
11
|
+
process.env.MAGIC_DIR = inferredMagicDir
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
process.exit(new StopRouter().run())
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// subagent-guard.ts — SubagentStart 入口薄壳(Task 3.1 能力对齐)
|
|
2
|
+
// 治理逻辑: governance/subagent-guard-router.js(SubagentGuardRouter 状态注入——对齐强版语义)
|
|
3
|
+
// 能力对齐注: 原 core 为弱版(事件提示空话),已对齐 claude/vscode/qoder 强版(状态注入)
|
|
4
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
5
|
+
|
|
6
|
+
import { SubagentGuardRouter } from "../governance/subagent-guard-router.js"
|
|
7
|
+
|
|
8
|
+
process.exit(new SubagentGuardRouter().run())
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// subagent-stop.ts — SubagentStop 入口薄壳(Task 2.2 薄壳化)
|
|
2
|
+
// 治理逻辑: lib/subagent-stop-router.ts(SubagentStopRouter 边界校验 + 审计聚合)
|
|
3
|
+
// 入口职责: 仅解析 + 进程语义(<50 行),治理 0 复制。
|
|
4
|
+
|
|
5
|
+
import { readHookInput } from "../governance/common.js"
|
|
6
|
+
import { SubagentStopRouter } from "../governance/subagent-stop-router.js"
|
|
7
|
+
|
|
8
|
+
const input = readHookInput()
|
|
9
|
+
process.exit(new SubagentStopRouter().run(input))
|
|
@@ -1,43 +1,54 @@
|
|
|
1
1
|
// add.prisma — ADD 治理模型,独立于用户业务表
|
|
2
2
|
|
|
3
3
|
model AddUser {
|
|
4
|
-
id
|
|
5
|
-
username
|
|
6
|
-
email
|
|
7
|
-
devOperations
|
|
8
|
-
auditLogs
|
|
4
|
+
id String @id @default(cuid())
|
|
5
|
+
username String @unique
|
|
6
|
+
email String?
|
|
7
|
+
devOperations DevOperation[]
|
|
8
|
+
auditLogs AuditLog[]
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
model DevOperation {
|
|
12
|
-
id
|
|
13
|
-
userId
|
|
14
|
-
user
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
id String @id @default(cuid())
|
|
13
|
+
userId String
|
|
14
|
+
user AddUser @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
15
|
+
projectKey String @default("legacy-unknown")
|
|
16
|
+
producerAdapterKey String @default("legacy-unknown")
|
|
17
|
+
contextId String @default("legacy-unknown")
|
|
18
|
+
toolName String @default("record_dev_operation")
|
|
19
|
+
operationKey String @default(cuid())
|
|
20
|
+
planKeyword String
|
|
21
|
+
action String
|
|
22
|
+
targetType String
|
|
23
|
+
targetId String
|
|
24
|
+
beforeState Json?
|
|
25
|
+
afterState Json?
|
|
26
|
+
reason String?
|
|
27
|
+
createdAt DateTime @default(now())
|
|
23
28
|
|
|
29
|
+
@@unique([projectKey, producerAdapterKey, toolName, operationKey])
|
|
24
30
|
@@index([planKeyword])
|
|
31
|
+
@@index([projectKey, producerAdapterKey, planKeyword])
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
model AuditLog {
|
|
28
|
-
id
|
|
29
|
-
userId
|
|
30
|
-
user
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
id String @id @default(cuid())
|
|
36
|
+
userId String
|
|
37
|
+
user AddUser @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
38
|
+
projectKey String @default("legacy-unknown")
|
|
39
|
+
producerAdapterKey String @default("legacy-unknown")
|
|
40
|
+
contextId String @default("legacy-unknown")
|
|
41
|
+
action String
|
|
42
|
+
targetType String
|
|
43
|
+
targetId String
|
|
44
|
+
traceId String?
|
|
45
|
+
beforeState Json?
|
|
46
|
+
afterState Json?
|
|
47
|
+
reason String?
|
|
48
|
+
createdAt DateTime @default(now())
|
|
39
49
|
|
|
40
50
|
@@index([traceId])
|
|
51
|
+
@@index([projectKey, producerAdapterKey, contextId])
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
// ===== HITL 人机审核架构 =====
|
|
@@ -61,65 +72,85 @@ enum ReviewType {
|
|
|
61
72
|
RUNTIME
|
|
62
73
|
}
|
|
63
74
|
|
|
75
|
+
enum PlanLifecycleStatus {
|
|
76
|
+
DRAFT
|
|
77
|
+
ACTIVE
|
|
78
|
+
BLOCKED
|
|
79
|
+
REJECTED
|
|
80
|
+
CLOSED
|
|
81
|
+
ABANDONED
|
|
82
|
+
}
|
|
83
|
+
|
|
64
84
|
model HitlRecord {
|
|
65
|
-
id String
|
|
85
|
+
id String @id @default(cuid())
|
|
86
|
+
projectKey String @default("legacy-unknown")
|
|
87
|
+
adapterKey String @default("legacy-unknown")
|
|
66
88
|
planName String
|
|
67
|
-
plan PlanRecord
|
|
68
|
-
round Int
|
|
69
|
-
type HitlType
|
|
70
|
-
status HitlStatus
|
|
89
|
+
plan PlanRecord @relation(fields: [projectKey, adapterKey, planName], references: [projectKey, adapterKey, planName], onDelete: Cascade)
|
|
90
|
+
round Int @default(1)
|
|
91
|
+
type HitlType @default(PLAN)
|
|
92
|
+
status HitlStatus @default(DRAFT)
|
|
71
93
|
proposalPath String?
|
|
72
94
|
approvedAt DateTime?
|
|
73
95
|
rejectedAt DateTime?
|
|
74
96
|
rejectReason String?
|
|
75
|
-
createdBy String
|
|
76
|
-
createdAt DateTime
|
|
77
|
-
updatedAt DateTime
|
|
97
|
+
createdBy String @default("ai-assistant")
|
|
98
|
+
createdAt DateTime @default(now())
|
|
99
|
+
updatedAt DateTime @updatedAt
|
|
78
100
|
|
|
79
|
-
@@unique([planName, round])
|
|
80
|
-
@@index([planName])
|
|
101
|
+
@@unique([projectKey, adapterKey, planName, type, round])
|
|
102
|
+
@@index([projectKey, adapterKey, planName])
|
|
81
103
|
@@index([status])
|
|
82
104
|
}
|
|
83
105
|
|
|
84
106
|
model PlanRecord {
|
|
85
|
-
id
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
id String @id @default(cuid())
|
|
108
|
+
projectKey String @default("legacy-unknown")
|
|
109
|
+
adapterKey String @default("legacy-unknown")
|
|
110
|
+
planName String
|
|
111
|
+
lifecycle PlanLifecycleStatus @default(DRAFT)
|
|
112
|
+
revision Int @default(0)
|
|
113
|
+
planPath String
|
|
114
|
+
specPath String?
|
|
115
|
+
tasksPath String?
|
|
116
|
+
checklistPath String?
|
|
117
|
+
addRoutePath String?
|
|
118
|
+
totalTasks Int @default(0)
|
|
119
|
+
doneTasks Int @default(0)
|
|
120
|
+
checklistT Int @default(0)
|
|
121
|
+
checklistTDone Int @default(0)
|
|
122
|
+
checklistR Int @default(0)
|
|
123
|
+
planKeyword String?
|
|
98
124
|
// 并发协作契约:该 Plan 在契约中的角色(MASTER=总控 / SUB=子 Plan)
|
|
99
|
-
contractRole
|
|
125
|
+
contractRole ContractRole?
|
|
100
126
|
// 所属契约名(与 CollabContract.contractName 对应,反查用)
|
|
101
|
-
contractName
|
|
127
|
+
contractName String?
|
|
102
128
|
// 作为总控 Plan 持有的契约(masterPlanName 外键方向)
|
|
103
|
-
masterContract
|
|
129
|
+
masterContract CollabContract? @relation("MasterPlan")
|
|
130
|
+
contractBindings CollaborationPlanBinding[]
|
|
104
131
|
// DPS 四维评分历史(check_dps 调用后回写,供 FFT 自适应权重消费)
|
|
105
|
-
dpsSemScore
|
|
106
|
-
dpsEntropyScore
|
|
107
|
-
dpsCpmScore
|
|
108
|
-
dpsStructScore
|
|
109
|
-
dpsComposite
|
|
110
|
-
hitls
|
|
111
|
-
reviews
|
|
112
|
-
createdAt
|
|
113
|
-
updatedAt
|
|
114
|
-
|
|
132
|
+
dpsSemScore Int? // 语义相关性 0-100
|
|
133
|
+
dpsEntropyScore Int? // 信息熵匹配 0-100
|
|
134
|
+
dpsCpmScore Int? // CPM 关键路径 0-100
|
|
135
|
+
dpsStructScore Int? // 结构完整度 0-100
|
|
136
|
+
dpsComposite Int? // 加权 DPS 总分 0-100
|
|
137
|
+
hitls HitlRecord[]
|
|
138
|
+
reviews ReviewRecord[]
|
|
139
|
+
createdAt DateTime @default(now())
|
|
140
|
+
updatedAt DateTime @updatedAt
|
|
141
|
+
|
|
142
|
+
@@unique([projectKey, adapterKey, planName])
|
|
115
143
|
@@index([planKeyword])
|
|
116
144
|
@@index([contractName])
|
|
145
|
+
@@index([projectKey, adapterKey, lifecycle])
|
|
117
146
|
}
|
|
118
147
|
|
|
119
148
|
model ReviewRecord {
|
|
120
149
|
id String @id @default(cuid())
|
|
150
|
+
projectKey String @default("legacy-unknown")
|
|
151
|
+
adapterKey String @default("legacy-unknown")
|
|
121
152
|
planName String
|
|
122
|
-
plan PlanRecord @relation(fields: [planName], references: [planName], onDelete: Cascade)
|
|
153
|
+
plan PlanRecord @relation(fields: [projectKey, adapterKey, planName], references: [projectKey, adapterKey, planName], onDelete: Cascade)
|
|
123
154
|
type ReviewType @default(PLAN_REVIEW)
|
|
124
155
|
reviewPath String?
|
|
125
156
|
p0Count Int @default(0)
|
|
@@ -128,33 +159,60 @@ model ReviewRecord {
|
|
|
128
159
|
createdAt DateTime @default(now())
|
|
129
160
|
updatedAt DateTime @updatedAt
|
|
130
161
|
|
|
131
|
-
@@index([planName])
|
|
162
|
+
@@index([projectKey, adapterKey, planName])
|
|
132
163
|
@@index([type])
|
|
133
164
|
}
|
|
134
165
|
|
|
135
166
|
enum ContractRole {
|
|
136
|
-
MASTER
|
|
137
|
-
SUB
|
|
167
|
+
MASTER // 总控 Plan(契约持有者)
|
|
168
|
+
SUB // 子 Plan(契约实施单元)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
enum CollaborationBindingRole {
|
|
172
|
+
MASTER
|
|
173
|
+
MEMBER
|
|
138
174
|
}
|
|
139
175
|
|
|
140
176
|
// 并发协作契约(多智能体并行实施规则集,对应 collab-contract 文档)
|
|
141
177
|
model CollabContract {
|
|
142
|
-
id String
|
|
143
|
-
|
|
178
|
+
id String @id @default(cuid())
|
|
179
|
+
projectKey String @default("legacy-unknown")
|
|
180
|
+
ownerAdapterKey String @default("legacy-unknown")
|
|
181
|
+
contractName String
|
|
144
182
|
contractPath String
|
|
145
183
|
// 外键:总控 Plan(契约持有者,ContractRole=MASTER,一对一)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
184
|
+
masterProjectKey String @default("legacy-unknown")
|
|
185
|
+
masterAdapterKey String @default("legacy-unknown")
|
|
186
|
+
masterPlanName String
|
|
187
|
+
masterPlan PlanRecord @relation("MasterPlan", fields: [masterProjectKey, masterAdapterKey, masterPlanName], references: [projectKey, adapterKey, planName], onDelete: Restrict)
|
|
188
|
+
bindings CollaborationPlanBinding[]
|
|
189
|
+
participants Json // [{role, platformEntity, boundPlan, planKeyword, description}]
|
|
190
|
+
abilityMatrix Json? // {能力: {专家: boolean}}
|
|
191
|
+
stages Json // [{stage, expert, trigger, parallelism}]
|
|
192
|
+
dependencyGraph String? // ASCII 图 + 机器可读声明
|
|
193
|
+
fileBoundaries Json // [{expert, exclusiveDomain, forbidden, isolationMode}] isolationMode: file/worktree
|
|
194
|
+
completionCriteria Json? // {专家: 完成标志}
|
|
195
|
+
status String @default("ACTIVE") // ACTIVE / SUPERSEDED
|
|
196
|
+
version Int @default(1)
|
|
197
|
+
createdAt DateTime @default(now())
|
|
198
|
+
updatedAt DateTime @updatedAt
|
|
199
|
+
|
|
200
|
+
@@unique([projectKey, contractName])
|
|
201
|
+
@@unique([masterProjectKey, masterAdapterKey, masterPlanName])
|
|
202
|
+
@@index([projectKey, ownerAdapterKey])
|
|
203
|
+
}
|
|
158
204
|
|
|
159
|
-
|
|
205
|
+
model CollaborationPlanBinding {
|
|
206
|
+
id String @id @default(cuid())
|
|
207
|
+
contractId String
|
|
208
|
+
contract CollabContract @relation(fields: [contractId], references: [id], onDelete: Cascade)
|
|
209
|
+
projectKey String
|
|
210
|
+
adapterKey String
|
|
211
|
+
planName String
|
|
212
|
+
plan PlanRecord @relation(fields: [projectKey, adapterKey, planName], references: [projectKey, adapterKey, planName], onDelete: Cascade)
|
|
213
|
+
role CollaborationBindingRole @default(MEMBER)
|
|
214
|
+
createdAt DateTime @default(now())
|
|
215
|
+
|
|
216
|
+
@@unique([contractId, projectKey, adapterKey, planName])
|
|
217
|
+
@@index([projectKey, adapterKey, planName])
|
|
160
218
|
}
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
| P2 | ADD-13 DPS 上游文档质量闸门 | Plan 概括度 → Review 注意力稀释 → Specs 遗漏 → 实现偏差。`check_dps`(DPS ≥ {{dpsPass}})在 Step 0 末尾量化阻断 | ✅ 已实现 | 2026-06-11 引入 |
|
|
27
27
|
| P2 | ADD-14 RAHS 下游执行健康度闸门 | 范围保真度 + 类型安全 + 审计完整度 + Spec 合规 + 阶段对称性。`check_rahs`(RAHS ≥ 90)在 Step 4/8 量化阻断 | ✅ 已实现 | 2026-06-11 引入 |
|
|
28
28
|
| P2 | ADD-15 add-route 闭环自检 | Step 3 代码完成后必须调用 `check_add_route_completeness` 扫描 add-route Step 完成度,防止执行遗漏。返回 complete 方可进入 Step 3.5 | ✅ 已实现 | 2026-06-11 引入 |
|
|
29
|
-
| P2 | ADD-17 HITL
|
|
30
|
-
| P2 | ADD-18 HITL 人机审核强制规则 | Plan
|
|
29
|
+
| P2 | ADD-17 HITL 提案载体与状态机 | `create_hitl` 接收 `dimensions`,创建 `HitlRecord(DRAFT)` 与 `*.hitl.md` 提案;人工拍板后由 `update_hitl` 写入终态,正式文档仅在 `status_hitl=TONGYI` 后生成 | ✅ 已实现 | 2026-07-23 引入,2026-08-12 对齐 MCP 实现 |
|
|
30
|
+
| P2 | ADD-18 HITL 人机审核强制规则 | Plan、方案 Review、实现 Review 必须经过 `create_hitl` → 人工 tongyi/bohui → `update_hitl`;`TONGYI` 同步写 DB、提案状态和 `.tongyi-{planName}` 哨兵 | ✅ 已实现 | 2026-07-27 引入 |
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
### P0 规则:不可跳过
|
|
@@ -68,7 +68,7 @@ AI 助手必须先恢复到基线、找到对应的 SKILL 文件并按步骤执
|
|
|
68
68
|
| ADD-14 | `add-paradigm` Step 4 末端 + Step 8 收敛 + MCP `check_rahs` | Step 4 合规检查 / Step 8 收敛判定 |
|
|
69
69
|
| ADD-15 | `add-paradigm` Step 3.6 + MCP `check_add_route_completeness` | Step 3 代码完成后自检 |
|
|
70
70
|
| ADD-16 | `add-paradigm` Step 9 | runtime-fix plan 收敛后,关闭 gateway.md 运行时发现 |
|
|
71
|
-
| ADD-17 | `add-paradigm` 独立能力:生成 Plan / Step 0 | Plan/Review HITL
|
|
71
|
+
| ADD-17 | `add-paradigm` 独立能力:生成 Plan / Step 0 / Step 3.5 | Plan/Review HITL:整理 dimensions → create_hitl 生成提案 → update_hitl 拍板 → status_hitl 校验终态 |
|
|
72
72
|
| ADD-18 | `add-paradigm` 独立能力:生成 Plan + Step 0 + pre-tool-use §C | HITL 审批强制:create_hitl → 人工 tongyi/bohui → update_hitl 确认;hook 哨兵检查 |
|
|
73
73
|
|
|
74
74
|
---
|
|
@@ -783,45 +783,47 @@ ADD-0.1 要求"文档先行"(先改文档再改代码)。ADD-16 是对 ADD-0
|
|
|
783
783
|
|
|
784
784
|
---
|
|
785
785
|
|
|
786
|
-
## ADD-17:HITL
|
|
786
|
+
## ADD-17:HITL 提案载体与状态机
|
|
787
787
|
|
|
788
|
-
**Plan
|
|
788
|
+
**Plan、方案 Review 和实现 Review 在写入正式文件前,必须通过 `create_hitl` 建立结构化审批提案。`*.hitl.md` 与 `HitlRecord` 是同一轮审批的文件/数据库双通道载体;正式文档不得替代审批提案。**
|
|
789
789
|
|
|
790
790
|
### 流程
|
|
791
791
|
|
|
792
792
|
```
|
|
793
|
-
① AI
|
|
794
|
-
②
|
|
795
|
-
③
|
|
796
|
-
④
|
|
793
|
+
① AI 读取对应模板并将待拍板发现整理为 dimensions
|
|
794
|
+
② create_hitl({ planName, type, dimensions }) → HitlRecord(DRAFT) + plans/{YYYY-MM}/{DD}/{planName}.hitl.md
|
|
795
|
+
③ 人类审阅提案并逐项拍板 → update_hitl({ planName, type, status })
|
|
796
|
+
④ status_hitl 确认 TONGYI → 生成完整 Plan/Review 并写入正式路径
|
|
797
|
+
⑤ BOHUI → 修订 dimensions 后调用 create_hitl 创建 round+1
|
|
797
798
|
```
|
|
798
799
|
|
|
799
800
|
### 适用范围
|
|
800
801
|
|
|
801
|
-
| 文档类型 |
|
|
802
|
+
| 文档类型 | HITL type | 正式写入路径 |
|
|
802
803
|
|---------|:---:|------|
|
|
803
|
-
| Plan(标准版/精简版) |
|
|
804
|
-
| Review(方案/实现) |
|
|
805
|
-
|
|
|
806
|
-
|
|
|
804
|
+
| Plan(标准版/精简版) | `PLAN` | `{{magicDir}}/plans/{YYYY-MM}/{DD}/` |
|
|
805
|
+
| Review(方案/实现) | `PLAN_REVIEW` | `{{magicDir}}/reviews/` |
|
|
806
|
+
| Runtime Review | 不需要 | `[T]` 全部通过后直接写入 `{{magicDir}}/reviews/` |
|
|
807
|
+
| Spec / Tasks / Checklist | 不需要 | 直接写入 `{{magicDir}}/specs/` |
|
|
808
|
+
| Handoff | 不需要 | 直接写入 `{{magicDir}}/plans/` |
|
|
807
809
|
|
|
808
810
|
### 与 ADD-0.1 的关系
|
|
809
811
|
|
|
810
|
-
ADD-0.1
|
|
812
|
+
ADD-0.1 要求“文档先行”。`create_hitl` 先持久化决策维度与审批状态,再展开正式文档,使“先拍板、后展开”具备可查询、可追溯的事实源。
|
|
811
813
|
|
|
812
814
|
---
|
|
813
815
|
|
|
814
816
|
## ADD-18:HITL 人机审核强制规则
|
|
815
817
|
|
|
816
|
-
**Plan
|
|
818
|
+
**Plan、方案 Review 和实现 Review 在写入正式文件前,必须经过 HITL 审批。** 审批通过后,`update_hitl` 更新数据库与 `*.hitl.md` 状态,并在 `{{magicDir}}/hitl/` 生成 `.tongyi-{planName}` 哨兵。pre-tool-use hook 对 Plan/方案 Review 执行哨兵门禁;实现 Review 由 `add-paradigm` Step 3.5 与 `status_hitl` 门禁约束。
|
|
817
819
|
|
|
818
820
|
### 强制流程
|
|
819
821
|
|
|
820
822
|
```
|
|
821
|
-
① create_hitl({ planName, type }) → HitlRecord DRAFT,生成 hitl.md 提案文件
|
|
822
|
-
② 人类审阅 hitl.md → 逐行拍板
|
|
823
|
-
③ update_hitl({ planName, status: "TONGYI" }) →
|
|
824
|
-
或 update_hitl({ planName, status: "BOHUI", reason }) →
|
|
823
|
+
① create_hitl({ planName, type, dimensions }) → HitlRecord DRAFT,生成 *.hitl.md 提案文件
|
|
824
|
+
② 人类审阅 *.hitl.md → 逐行拍板
|
|
825
|
+
③ update_hitl({ planName, type, status: "TONGYI" }) → 更新 DB/提案并写 .tongyi-{planName} 哨兵
|
|
826
|
+
或 update_hitl({ planName, type, status: "BOHUI", reason }) → 更新 DB/提案并写 .bohui-{planName} 哨兵
|
|
825
827
|
④ TONGYI 后:正式写入 Plan/Review 文件(hook §C 放行)
|
|
826
828
|
⑤ BOHUI 后:create_hitl 新建 round+1,重新审批
|
|
827
829
|
```
|
|
@@ -830,15 +832,16 @@ ADD-0.1 要求"文档先行"——HITL 磋商本身就是文档先行的一种
|
|
|
830
832
|
|
|
831
833
|
| 文档类型 | HITL 审批 | 依据 |
|
|
832
834
|
|---------|:--------:|------|
|
|
833
|
-
| Plan | ✅ 必须 | pre-tool-use §C
|
|
834
|
-
| Review
|
|
835
|
-
| Review
|
|
835
|
+
| Plan | ✅ 必须 | pre-tool-use §C 哨兵门禁 |
|
|
836
|
+
| 方案 Review | ✅ 必须 | pre-tool-use §C 哨兵门禁 |
|
|
837
|
+
| Implementation Review | ✅ 必须 | `add-paradigm` Step 3.5 + `status_hitl` |
|
|
838
|
+
| Runtime Review | ❌ 不需要 | `[T]` 全部通过后直接生成 |
|
|
836
839
|
| Spec / Tasks / Checklist | ❌ 不需要 | 直接写 |
|
|
837
840
|
| Handoff | ❌ 不需要 | 直接写 |
|
|
838
841
|
|
|
839
842
|
### 与 ADD-17 的关系
|
|
840
843
|
|
|
841
|
-
ADD-17
|
|
844
|
+
ADD-17 定义审批提案的载体、维度和状态流转;ADD-18 定义哪些正式文档必须先取得 `TONGYI`。两者共同以 `create_hitl → update_hitl → status_hitl` 为事实链,文件、数据库和哨兵相互校验。
|
|
842
845
|
|
|
843
846
|
---
|
|
844
847
|
|
|
@@ -156,6 +156,14 @@ apply_atlas_diff() {
|
|
|
156
156
|
# ⑦ Atlas 同步主流程(探测 → dev-url → 目标 → baseline → diff → apply)
|
|
157
157
|
atlas_sync() {
|
|
158
158
|
[ "$ENGINE" = "sqlite" ] && return 0
|
|
159
|
+
# 迁移锁(进程层契约 v2 §6):多 IDE 并发 init 时仅一个进程执行迁移
|
|
160
|
+
# 非阻塞拿锁(pg_try_advisory_lock),会话级锁——脚本退出连接断开自动释放
|
|
161
|
+
LOCK_KEY="0xADD001"
|
|
162
|
+
LOCKED="$(podman exec "${PROJECT_NAME:-add-project}-postgres" psql -U "${DATABASE_USER:-admin}" -d "${PROJECT_NAME:-add-project}" -tAc "SELECT pg_try_advisory_lock(${LOCK_KEY});" 2>/dev/null || true)"
|
|
163
|
+
if [ "$LOCKED" != "t" ]; then
|
|
164
|
+
echo "!!! 另一个进程正在迁移,请稍后重试"
|
|
165
|
+
return 1
|
|
166
|
+
fi
|
|
159
167
|
if ! atlas_cmd version > /dev/null 2>&1; then
|
|
160
168
|
echo "!!! Atlas 不可用。add-coder sync --patch 可自动安装 @ariga/atlas;或手动: pnpm add -D @ariga/atlas"
|
|
161
169
|
echo " 降级路径: prisma-diff(免 shadow)→ db-push + 强制备份;文档: README「Atlas 数据库同步能力」"
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
# 生成 {MAGIC_DIR}/plans/index.md 总览清单 — 按日期分层,每日自动更新
|
|
3
|
-
#
|
|
3
|
+
# MAGIC_DIR 由脚本自身的物理目录确定,各 adapter 自治。
|
|
4
4
|
set -e
|
|
5
5
|
|
|
6
|
-
# 探测 MAGIC_DIR:在当前目录向上查找包含 plans/ 的隐藏目录
|
|
7
6
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
-
|
|
9
|
-
MAGIC_DIR=""
|
|
10
|
-
while [ "$CURRENT" != "/" ]; do
|
|
11
|
-
for d in "$CURRENT"/.qoder "$CURRENT"/.claude "$CURRENT"/.vscode "$CURRENT"/.trae "$CURRENT"/.codex "$CURRENT"/.add; do
|
|
12
|
-
if [ -d "$d/plans" ]; then
|
|
13
|
-
MAGIC_DIR="$d"
|
|
14
|
-
break 2
|
|
15
|
-
fi
|
|
16
|
-
done
|
|
17
|
-
CURRENT="$(dirname "$CURRENT")"
|
|
18
|
-
done
|
|
7
|
+
MAGIC_DIR="$(dirname "$SCRIPT_DIR")"
|
|
19
8
|
|
|
20
|
-
if [ -
|
|
21
|
-
echo "❌
|
|
9
|
+
if [ ! -d "$MAGIC_DIR/plans" ]; then
|
|
10
|
+
echo "❌ 当前 adapter 不存在 plans/: $MAGIC_DIR" >&2
|
|
22
11
|
exit 1
|
|
23
12
|
fi
|
|
24
13
|
|