coding-agent-harness 1.0.0

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.
Files changed (139) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +141 -0
  4. package/SKILL.md +423 -0
  5. package/docs-release/README.md +30 -0
  6. package/docs-release/architecture/overview.md +52 -0
  7. package/docs-release/guides/agent-installation.md +139 -0
  8. package/examples/minimal-project/.harness-capabilities.json +8 -0
  9. package/examples/minimal-project/AGENTS.md +4 -0
  10. package/examples/minimal-project/CLAUDE.md +3 -0
  11. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/execution_strategy.md +10 -0
  12. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/progress.md +11 -0
  13. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/review.md +27 -0
  14. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/task_plan.md +14 -0
  15. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/visual_roadmap.md +11 -0
  16. package/examples/minimal-project/docs/Harness-Ledger.md +6 -0
  17. package/package.json +34 -0
  18. package/references/adversarial-review-standard.md +173 -0
  19. package/references/agents-md-pattern.md +140 -0
  20. package/references/cadence-ledger.md +55 -0
  21. package/references/ci-cd-standard.md +90 -0
  22. package/references/delivery-operating-model-standard.md +145 -0
  23. package/references/docs-directory-standard.md +125 -0
  24. package/references/harness-ledger.md +148 -0
  25. package/references/lessons-governance.md +157 -0
  26. package/references/long-running-task-standard.md +209 -0
  27. package/references/module-parallel-standard.md +292 -0
  28. package/references/planning-loop.md +192 -0
  29. package/references/project-onboarding-audit.md +167 -0
  30. package/references/regression-system.md +89 -0
  31. package/references/repo-governance-standard.md +131 -0
  32. package/references/review-routing-standard.md +103 -0
  33. package/references/ssot-governance.md +111 -0
  34. package/references/walkthrough-closeout.md +135 -0
  35. package/references/worktree-parallel.md +184 -0
  36. package/scripts/check-harness.mjs +728 -0
  37. package/scripts/harness.mjs +201 -0
  38. package/scripts/lib/dashboard-writer.mjs +95 -0
  39. package/scripts/lib/harness-core.mjs +1318 -0
  40. package/scripts/smoke-dashboard.mjs +70 -0
  41. package/scripts/test-harness.mjs +482 -0
  42. package/templates/AGENTS.md.template +82 -0
  43. package/templates/CLAUDE.md.template +12 -0
  44. package/templates/dashboard/assets/app.css +399 -0
  45. package/templates/dashboard/assets/app.js +435 -0
  46. package/templates/dashboard/assets/i18n.js +47 -0
  47. package/templates/dashboard/assets/markdown-reader.js +116 -0
  48. package/templates/dashboard/assets/mermaid-renderer.js +59 -0
  49. package/templates/dashboard/index.html +18 -0
  50. package/templates/ledger/Harness-Ledger.md +39 -0
  51. package/templates/lessons/lesson-arch-process-change.md +47 -0
  52. package/templates/lessons/lesson-new-doc.md +50 -0
  53. package/templates/lessons/lesson-ref-change.md +45 -0
  54. package/templates/planning/execution_strategy.md +40 -0
  55. package/templates/planning/findings.md +24 -0
  56. package/templates/planning/long-running-task-contract.md +69 -0
  57. package/templates/planning/module_plan.md +36 -0
  58. package/templates/planning/module_session_prompt.md +39 -0
  59. package/templates/planning/optional/artifacts/INDEX.md +12 -0
  60. package/templates/planning/optional/references/INDEX.md +13 -0
  61. package/templates/planning/optional/slices/_slice-template/brief.md +27 -0
  62. package/templates/planning/optional/slices/_slice-template/evidence.md +9 -0
  63. package/templates/planning/optional/slices/_slice-template/review.md +31 -0
  64. package/templates/planning/progress.md +33 -0
  65. package/templates/planning/review.md +48 -0
  66. package/templates/planning/task_plan.md +86 -0
  67. package/templates/planning/visual_roadmap.md +28 -0
  68. package/templates/reference/adversarial-review-standard.md +28 -0
  69. package/templates/reference/ci-cd-standard.md +28 -0
  70. package/templates/reference/delivery-operating-model-standard.md +28 -0
  71. package/templates/reference/docs-library-standard.md +28 -0
  72. package/templates/reference/engineering-standard.md +29 -0
  73. package/templates/reference/execution-workflow-standard.md +29 -0
  74. package/templates/reference/harness-ledger-standard.md +26 -0
  75. package/templates/reference/long-running-task-standard.md +28 -0
  76. package/templates/reference/regression-ssot-governance.md +28 -0
  77. package/templates/reference/repo-governance-standard.md +29 -0
  78. package/templates/reference/review-routing-standard.md +29 -0
  79. package/templates/reference/testing-standard.md +28 -0
  80. package/templates/reference/walkthrough-standard.md +28 -0
  81. package/templates/reference/worktree-standard.md +28 -0
  82. package/templates/regression/Cadence-Ledger.md +41 -0
  83. package/templates/ssot/Delivery-SSoT.md +43 -0
  84. package/templates/ssot/Feature-SSoT.md +43 -0
  85. package/templates/ssot/Lessons-SSoT.md +44 -0
  86. package/templates/ssot/Module-Registry.md +43 -0
  87. package/templates/ssot/Regression-SSoT.md +51 -0
  88. package/templates/verifier/verifier-output.md +43 -0
  89. package/templates/walkthrough/Closeout-SSoT.md +43 -0
  90. package/templates/walkthrough/walkthrough-template.md +63 -0
  91. package/templates-zh-CN/AGENTS.md.template +92 -0
  92. package/templates-zh-CN/CLAUDE.md.template +12 -0
  93. package/templates-zh-CN/dashboard/assets/app.css +399 -0
  94. package/templates-zh-CN/dashboard/assets/app.js +435 -0
  95. package/templates-zh-CN/dashboard/assets/i18n.js +47 -0
  96. package/templates-zh-CN/dashboard/assets/markdown-reader.js +116 -0
  97. package/templates-zh-CN/dashboard/assets/mermaid-renderer.js +59 -0
  98. package/templates-zh-CN/dashboard/index.html +18 -0
  99. package/templates-zh-CN/ledger/Harness-Ledger.md +50 -0
  100. package/templates-zh-CN/lessons/lesson-arch-process-change.md +47 -0
  101. package/templates-zh-CN/lessons/lesson-new-doc.md +49 -0
  102. package/templates-zh-CN/lessons/lesson-ref-change.md +59 -0
  103. package/templates-zh-CN/planning/execution_strategy.md +37 -0
  104. package/templates-zh-CN/planning/findings.md +24 -0
  105. package/templates-zh-CN/planning/long-running-task-contract.md +118 -0
  106. package/templates-zh-CN/planning/module_plan.md +43 -0
  107. package/templates-zh-CN/planning/module_session_prompt.md +70 -0
  108. package/templates-zh-CN/planning/optional/artifacts/INDEX.md +13 -0
  109. package/templates-zh-CN/planning/optional/references/INDEX.md +13 -0
  110. package/templates-zh-CN/planning/optional/slices/_slice-template/brief.md +35 -0
  111. package/templates-zh-CN/planning/optional/slices/_slice-template/evidence.md +12 -0
  112. package/templates-zh-CN/planning/optional/slices/_slice-template/review.md +37 -0
  113. package/templates-zh-CN/planning/progress.md +29 -0
  114. package/templates-zh-CN/planning/review.md +69 -0
  115. package/templates-zh-CN/planning/task_plan.md +116 -0
  116. package/templates-zh-CN/planning/visual_roadmap.md +24 -0
  117. package/templates-zh-CN/reference/adversarial-review-standard.md +89 -0
  118. package/templates-zh-CN/reference/ci-cd-standard.md +72 -0
  119. package/templates-zh-CN/reference/delivery-operating-model-standard.md +79 -0
  120. package/templates-zh-CN/reference/docs-library-standard.md +59 -0
  121. package/templates-zh-CN/reference/engineering-standard.md +80 -0
  122. package/templates-zh-CN/reference/execution-workflow-standard.md +81 -0
  123. package/templates-zh-CN/reference/harness-ledger-standard.md +91 -0
  124. package/templates-zh-CN/reference/long-running-task-standard.md +156 -0
  125. package/templates-zh-CN/reference/regression-ssot-governance.md +82 -0
  126. package/templates-zh-CN/reference/repo-governance-standard.md +84 -0
  127. package/templates-zh-CN/reference/review-routing-standard.md +82 -0
  128. package/templates-zh-CN/reference/testing-standard.md +72 -0
  129. package/templates-zh-CN/reference/walkthrough-standard.md +83 -0
  130. package/templates-zh-CN/reference/worktree-standard.md +116 -0
  131. package/templates-zh-CN/regression/Cadence-Ledger.md +48 -0
  132. package/templates-zh-CN/ssot/Delivery-SSoT.md +60 -0
  133. package/templates-zh-CN/ssot/Feature-SSoT.md +49 -0
  134. package/templates-zh-CN/ssot/Lessons-SSoT.md +49 -0
  135. package/templates-zh-CN/ssot/Module-Registry.md +48 -0
  136. package/templates-zh-CN/ssot/Regression-SSoT.md +51 -0
  137. package/templates-zh-CN/verifier/verifier-output.md +38 -0
  138. package/templates-zh-CN/walkthrough/Closeout-SSoT.md +42 -0
  139. package/templates-zh-CN/walkthrough/walkthrough-template.md +62 -0
@@ -0,0 +1,52 @@
1
+ # Architecture Overview
2
+
3
+ Coding Agent Harness is a document-governed operating layer for long-running coding
4
+ agent work. It uses repository-native files, state contracts, role boundaries, and
5
+ checks to keep agent sessions auditable and recoverable.
6
+
7
+ ## Public Architecture
8
+
9
+ ```mermaid
10
+ flowchart TB
11
+ Skill["Skill / Agent Entry"]
12
+ Docs["Public Standards<br/>references/"]
13
+ Templates["Install Templates<br/>templates/"]
14
+ Target["Target Project Docs<br/>AGENTS.md + docs/"]
15
+ Check["Checker / Status CLI"]
16
+
17
+ Skill --> Docs
18
+ Skill --> Templates
19
+ Templates --> Target
20
+ Docs --> Target
21
+ Check --> Target
22
+ ```
23
+
24
+ ## Operating Principle
25
+
26
+ The harness separates three concerns:
27
+
28
+ | Layer | Responsibility |
29
+ | --- | --- |
30
+ | Public package | Ships reusable standards, templates, and checker logic. |
31
+ | Target project docs | Store the project's live plans, SSoTs, ledgers, and evidence. |
32
+ | Private operations | Store repository-local review drafts, handoffs, and release decisions. |
33
+
34
+ The public package should describe the system. It should not publish private
35
+ operating ledgers from this repository or from any target project.
36
+
37
+ ## Worker / Coordinator Boundary
38
+
39
+ ```mermaid
40
+ flowchart LR
41
+ Worker["Worker<br/>local module files"]
42
+ Handoff["Coordinator Handoff"]
43
+ Coordinator["Coordinator<br/>global facts"]
44
+ Check["Strict Check"]
45
+
46
+ Worker --> Handoff
47
+ Handoff --> Coordinator
48
+ Coordinator --> Check
49
+ ```
50
+
51
+ Workers own local task and module facts. Coordinators own global projections such
52
+ as registries, ledgers, closeout indexes, and regression state.
@@ -0,0 +1,139 @@
1
+ # Agent 安装指南
2
+
3
+ 这份指南写给在目标项目里执行安装或升级的 coding agent。README 只保留给人看的定位、
4
+ 快速开始和最小命令;安装细则放在这里和 `SKILL.md`。
5
+
6
+ ## 操作合同
7
+
8
+ 这套 CLI 的主要操作者通常是目标项目里的 agent,不是最终用户。Agent 不应该要求用户
9
+ 研究命令参数、模板目录或 capability 选择;这些决策必须在 Diagnose / Decide 阶段完成,
10
+ 并在交付 summary 中说明依据。
11
+
12
+ 使用 v1.0 六阶段流程:
13
+
14
+ 1. Diagnose:扫描项目结构、语言、现有文档、CI、协作方式和风险面。
15
+ 2. Decide:确定 locale、delivery model 和 capability packs。
16
+ 3. Scaffold:运行 `harness init` 或 `harness add-capability`。
17
+ 4. Configure:把生成文档改成项目事实;不要把模板假装成已定制标准。
18
+ 5. Verify:运行 CLI 检查和项目原生证据。
19
+ 6. Deliver:输出 residual、owner 和下一步。
20
+
21
+ ## 语言规则
22
+
23
+ - 用户在场时,先问 harness 文档使用中文还是英文。
24
+ - 非交互安装必须显式传 `--locale zh-CN` 或 `--locale en-US`,不要依赖默认值。
25
+ - 中文用户或中文优先项目使用 `zh-CN`。
26
+ - 英文团队、英文优先仓库或用户明确要求英文时使用 `en-US`。
27
+ - 同一个目标项目不要混用 `templates/` 和 `templates-zh-CN/`;只有 schema 字段、
28
+ 文件名、状态枚举、命令和跨工具协议 token 可以保留英文。
29
+
30
+ ## 新项目初始化
31
+
32
+ 目标项目没有旧 harness 时使用这条路径:
33
+
34
+ ```bash
35
+ node scripts/harness.mjs init \
36
+ --locale zh-CN \
37
+ --capabilities core,dashboard \
38
+ /path/to/project
39
+ ```
40
+
41
+ Capability 要保守选择:
42
+
43
+ | Capability | 默认 | 何时选择 |
44
+ | --- | --- | --- |
45
+ | `core` | 是 | 永远安装。这是 document kernel。 |
46
+ | `dashboard` | 否 | 用户或 agent 需要本地只读状态页。 |
47
+ | `safe-adoption` | 否 | 旧 harness 项目接入 v1.0,需要保留历史文档。 |
48
+ | `adversarial-review` | 否 | 发布、架构、安全、数据或策略风险需要独立 review artifact。 |
49
+ | `long-running-task` | 否 | Agent 需要连续多轮执行,不能每步都询问用户。 |
50
+ | `module-parallel` | 否 | 两个以上独立模块需要 owner、registry 和同步规则。 |
51
+ | `subagent-worker` | 否 | 会改代码的 subagent 需要独立 worktree 和 commit-backed handoff;依赖 `module-parallel`。 |
52
+
53
+ `init` 的 JSON 输出会包含 `report`。交付 summary 必须包含:
54
+
55
+ - locale
56
+ - selected capabilities,以及每个可选 capability 的选择理由
57
+ - created / skipped files
58
+ - Configure 阶段做了哪些项目化改动
59
+ - verification commands 和结果
60
+ - residual owner / action / status
61
+ - 是否提交;如果只是 dogfood 测试,是否已清理测试产物
62
+
63
+ ## 用户级注册
64
+
65
+ 如果用户已经通过 npm 或源码拿到了 `harness` CLI,可以把本 Skill 注册到用户级
66
+ agent 目录,避免每个项目重复拷贝:
67
+
68
+ ```bash
69
+ harness install-user --agent codex --global
70
+ harness doctor-user --agent codex
71
+ ```
72
+
73
+ 支持的 agent target:
74
+
75
+ | Agent | 用户级目录 |
76
+ | --- | --- |
77
+ | `codex` | `~/.codex/skills/coding-agent-harness` |
78
+ | `claude` | `~/.claude/skills/coding-agent-harness` |
79
+ | `gemini` | `~/.gemini/skills/coding-agent-harness` |
80
+ | `openclaw` | `~/.openclaw/skills/coding-agent-harness` |
81
+ | `agents` | `~/.agents/skills/coding-agent-harness` |
82
+ | `all` | 安装到以上所有目录 |
83
+
84
+ 安全规则:
85
+
86
+ - 默认交互确认;非交互场景必须传 `--yes` 或先用 `--dry-run`。
87
+ - 默认不覆盖已有文件,只补缺失文件。
88
+ - 需要强制更新时显式传 `--force`。
89
+ - `doctor-user` 会检查 `SKILL.md`、模板、references、CLI scripts 和本指南是否存在。
90
+
91
+ ## 旧 Harness 迁移
92
+
93
+ 目标项目已经有旧版 harness 时使用这条路径。不要把旧文档重建一遍:
94
+
95
+ ```bash
96
+ node scripts/harness.mjs add-capability safe-adoption \
97
+ --locale zh-CN \
98
+ /path/to/old-project
99
+ ```
100
+
101
+ 规则:
102
+
103
+ - 不覆盖已有 `AGENTS.md`、`CLAUDE.md`、`docs/Harness-Ledger.md`、SSoT、
104
+ walkthrough、task progress 和历史 task plan。
105
+ - 只补齐缺失的 v1.0 模板和 capability registry。
106
+ - 已有项目事实只能 merge、append 或记录 residual;不能用泛化模板替换。
107
+ - 历史合同缺口在普通模式下进入 `adoption-needed` warning。
108
+ - `--strict` 必须仍然能因为旧 checker 失败或历史合同缺口而失败。
109
+
110
+ ## 验证命令
111
+
112
+ 安装或升级收口前,至少运行:
113
+
114
+ ```bash
115
+ node scripts/harness.mjs check --profile target-project /path/to/project
116
+ node scripts/harness.mjs status --json /path/to/project
117
+ node scripts/harness.mjs dashboard --out /tmp/harness-dashboard.html /path/to/project
118
+ ```
119
+
120
+ 开发本仓 v1.0 kernel 时,release gate 是:
121
+
122
+ ```bash
123
+ npm test
124
+ npm run smoke:dashboard
125
+ node scripts/harness.mjs check --profile source-package .
126
+ node scripts/harness.mjs check --profile private-harness .harness-private
127
+ node scripts/harness.mjs check --profile target-project examples/minimal-project
128
+ ```
129
+
130
+ ## 必跑回归路径
131
+
132
+ 任何 v1.0 kernel 改动都必须覆盖两条路径:
133
+
134
+ | 路径 | 必须证明 |
135
+ | --- | --- |
136
+ | 新项目初始化 | 空项目 `init --locale zh-CN\|en-US --capabilities core,...` 后,模板语言一致、registry 正确、`status --json` 不误报 `safe-adoption`。 |
137
+ | 旧 harness 迁移 | 旧项目 `add-capability safe-adoption --locale ...` 后,旧文件不被覆盖,缺失 v1.0 模板被补齐,普通模式 warning,strict 模式能阻塞历史缺口。 |
138
+
139
+ 真实项目 dogfood 默认清理测试产物,除非用户明确要求保留并提交。
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": 1,
3
+ "capabilities": [
4
+ {"name": "core", "state": "configured"},
5
+ {"name": "review-contract", "state": "verified"},
6
+ {"name": "dashboard", "state": "verified"}
7
+ ]
8
+ }
@@ -0,0 +1,4 @@
1
+ # Minimal Harness Example
2
+
3
+ Use `docs/11-REFERENCE/` for project rules and `docs/09-PLANNING/TASKS/` for
4
+ task execution records.
@@ -0,0 +1,3 @@
1
+ # Claude Entry
2
+
3
+ Read `AGENTS.md` first.
@@ -0,0 +1,10 @@
1
+ # Execution Strategy
2
+
3
+ | Decision | Choice | Notes |
4
+ | --- | --- | --- |
5
+ | Primary executor | coordinator | Example task only. |
6
+ | Subagents | none | No parallel work needed. |
7
+ | Review model | self-check | Demonstrates the contract shape. |
8
+ | Worktree strategy | same checkout | Public example fixture. |
9
+ | Conflict control | coordinator owns shared files | No shared-file contention. |
10
+ | Evidence depth | L0 | Fixture-level evidence only. |
@@ -0,0 +1,11 @@
1
+ # Demo Task - Progress
2
+
3
+ ## Status
4
+
5
+ in-progress
6
+
7
+ ## Updates
8
+
9
+ | Date | Update | Evidence |
10
+ | --- | --- | --- |
11
+ | 2026-05-18 | Created example roadmap | report:TARGET:docs/09-PLANNING/TASKS/demo-task/visual_roadmap.md:example phase table |
@@ -0,0 +1,27 @@
1
+ # Demo Task - Review
2
+
3
+ ## Reviewer Identity
4
+
5
+ | Reviewer | Type | Scope |
6
+ | --- | --- | --- |
7
+ | coordinator | self-check | example |
8
+
9
+ ## Confidence Challenge
10
+
11
+ No material finding for this example.
12
+
13
+ ## Evidence Checked
14
+
15
+ | Evidence ID | Type | Path | Summary |
16
+ | --- | --- | --- | --- |
17
+ | E-001 | review | TARGET:docs/09-PLANNING/TASKS/demo-task/task_plan.md | Visual roadmap table exists |
18
+
19
+ ## Findings
20
+
21
+ | ID | Severity | Finding | Evidence Checked | Required Action | Open | Disposition | Blocks Release | Follow-up |
22
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- |
23
+ | R-001 | P3 | Example only | E-001 | none | no | closed | no | none |
24
+
25
+ ## Final Confidence Basis
26
+
27
+ self-check only; example is not a release approval.
@@ -0,0 +1,14 @@
1
+ # Demo Task
2
+
3
+ ## Goal
4
+
5
+ Show the v1.0 visual roadmap contract.
6
+
7
+ ## Scope
8
+
9
+ Public example only.
10
+
11
+ ## Execution & Visualization Files
12
+
13
+ - `execution_strategy.md`
14
+ - `visual_roadmap.md`
@@ -0,0 +1,11 @@
1
+ # Visual Roadmap
2
+
3
+ ```mermaid
4
+ flowchart LR
5
+ P1["Plan"] --> P2["Verify"]
6
+ ```
7
+
8
+ | Phase ID | Depends On | State | Completion | Output | Required Evidence | Evidence Status | Blocking Risk | Owner / Handoff |
9
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- |
10
+ | P1 | none | done | 100 | Example plan | review | present | none | coordinator |
11
+ | P2 | P1 | planned | 0 | Example verification | command | missing | none | coordinator |
@@ -0,0 +1,6 @@
1
+ # Harness Ledger
2
+
3
+ | ID | Task | Status | Review State | Next Action | Owner |
4
+ | --- | --- | --- | --- | --- | --- |
5
+ | LED-001 | demo-task | in_progress | review-ready | Verify rendered roadmap and evidence | coordinator |
6
+ | LED-002 | escaped-pipe-demo | planned | pending | Confirm parser keeps alpha\|beta notes | coordinator |
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "coding-agent-harness",
3
+ "version": "1.0.0",
4
+ "description": "Document governance kernel for long-running coding agents.",
5
+ "type": "module",
6
+ "bin": {
7
+ "harness": "scripts/harness.mjs"
8
+ },
9
+ "scripts": {
10
+ "check": "node scripts/harness.mjs check --profile source-package .",
11
+ "check:private": "node scripts/harness.mjs check --profile private-harness .harness-private",
12
+ "status": "node scripts/harness.mjs status --json .",
13
+ "dashboard": "node scripts/harness.mjs dashboard --out tmp/harness-dashboard.html examples/minimal-project",
14
+ "dashboard:folder": "node scripts/harness.mjs dashboard --out-dir tmp/harness-dashboard examples/minimal-project",
15
+ "smoke:dashboard": "node scripts/smoke-dashboard.mjs",
16
+ "test": "node scripts/test-harness.mjs"
17
+ },
18
+ "files": [
19
+ "README.md",
20
+ "CHANGELOG.md",
21
+ "SKILL.md",
22
+ "LICENSE",
23
+ "references/",
24
+ "templates/",
25
+ "templates-zh-CN/",
26
+ "scripts/",
27
+ "docs-release/",
28
+ "examples/"
29
+ ],
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "license": "MIT"
34
+ }
@@ -0,0 +1,173 @@
1
+ # Adversarial Review Standard
2
+
3
+ ## 核心思路
4
+
5
+ 对抗性审查不是普通总结,也不是 walkthrough。它是任务完成前的独立挑战环节:
6
+ 主动寻找错误假设、边界遗漏、回归风险、证据缺口和过早收口。
7
+
8
+ 每个需要 reviewer agent、subagent、外部审查者或多轮 hardening 的任务,都必须写
9
+ `review.md`。这是 reviewer 的一等交付物,不应只散落在 `progress.md` 或对话记录里。
10
+
11
+ ## 存放位置
12
+
13
+ 标准位置:
14
+
15
+ ```text
16
+ docs/09-PLANNING/TASKS/<YYYY-MM-DD-任务名>/review.md
17
+ ```
18
+
19
+ 任务目录中的文件职责:
20
+
21
+ - `task_plan.md`:目标、范围、步骤、验收标准
22
+ - `findings.md`:研究发现和技术决策
23
+ - `progress.md`:执行过程和验证记录
24
+ - `review.md`:对抗性审查报告、findings、no-finding 结论和残余风险
25
+ - `long-running-task-contract.md`:连续执行合同(仅长程任务需要)
26
+
27
+ ## 何时必须写
28
+
29
+ 以下情况必须写 `review.md`:
30
+
31
+ - 使用 reviewer agent、subagent 或外部审查者
32
+ - 长程任务合同中包含 review loop
33
+ - 任务触及共享架构、数据、安全、权限、部署、迁移或跨模块契约
34
+ - regression gate、live smoke、browser inspection 或 release 前验证暴露过问题
35
+ - 用户明确要求“review”“审查”“对抗性审查”“再挑一遍问题”
36
+
37
+ 轻量单文件修复可以在 `progress.md` 写自审结论,但如果发现 material risk,应升级为
38
+ `review.md`。
39
+
40
+ ## 审查姿态
41
+
42
+ Reviewer 必须以找问题为目标,而不是证明实现正确。
43
+
44
+ 每轮对抗性审查必须先使用 Confidence Challenge:
45
+
46
+ > 你对这个方案、实现和策略有 100% 的信心吗?如果没有,找出所有可能的漏洞,提出适当的修复建议,并运行这个循环,直到你对新策略事实上有 100% 的信心。
47
+
48
+ 这里的“100% 信心”不是主观自信,而是基于当前 scope、证据和已知风险的工程判断:
49
+
50
+ - 不允许直接回答“有信心”来跳过审查。
51
+ - 如果存在任何可验证的漏洞、证据缺口或未处理的 material risk,必须写入 findings。
52
+ - 修复建议必须具体到代码、测试、文档、回归或后续任务路由。
53
+ - 每轮修复后必须重新运行 Confidence Challenge,直到没有 open material finding。
54
+
55
+ 审查重点:
56
+
57
+ 1. **Goal / Scope Drift**:实现是否偏离任务目标,是否偷偷扩大或遗漏 scope
58
+ 2. **Behavioral Regression**:已有行为是否被破坏,尤其是调用方契约和状态流转
59
+ 3. **Boundary / Security Risk**:权限、输入、路径、网络、数据边界是否有漏洞
60
+ 4. **Evidence Gap**:测试、smoke、日志、截图或 trace 是否不足以支持结论
61
+ 5. **Operational Risk**:部署、回滚、配置、迁移、并发、定时任务是否有未验证风险
62
+ 6. **Maintainability Risk**:实现是否引入难以维护的耦合、重复或隐藏状态
63
+
64
+ ## 报告结构
65
+
66
+ `review.md` 必须包含:
67
+
68
+ ```markdown
69
+ # [任务名称] - Review
70
+
71
+ ## Review Scope
72
+ - Reviewer:
73
+ - Review type:
74
+ - Reviewed refs:
75
+ - Out of scope:
76
+
77
+ ## Confidence Challenge
78
+ - Question: 你对这个方案、实现和策略有 100% 的信心吗?
79
+ - Answer:
80
+ - If not 100%, remaining vulnerabilities:
81
+ - Fix loop count:
82
+ - Final confidence basis:
83
+
84
+ ## Material Findings
85
+ | ID | Severity | Area | Finding | Evidence | Required Action | Status |
86
+ |----|----------|------|---------|----------|-----------------|--------|
87
+
88
+ ## Non-Material Notes
89
+ - [不阻塞但值得记录的问题;如无写"无"]
90
+
91
+ ## Evidence Checked
92
+ - [ ] [测试 / smoke / 日志 / 截图 / PR / diff / runtime evidence]
93
+
94
+ ## No-Finding Statement
95
+ [如果没有 material finding,明确写:本轮未发现阻塞目标的 material finding。]
96
+
97
+ ## Residual Risk
98
+ - [已知残余风险;如无写"无"]
99
+
100
+ ## Follow-Up Routing
101
+ - Task Plan:
102
+ - Progress:
103
+ - Findings:
104
+ - Regression SSoT:
105
+ - Lessons SSoT:
106
+ - Walkthrough:
107
+ ```
108
+
109
+ ## Severity 分级
110
+
111
+ | 级别 | 含义 | 处理规则 |
112
+ |------|------|----------|
113
+ | P0 | 会导致数据损坏、安全事故、生产不可用或错误发布 | 必须停下,不能继续收口 |
114
+ | P1 | 会破坏核心路径、关键契约或主要验收标准 | 必须修复并重跑证据 |
115
+ | P2 | 有明确回归或维护风险,但不阻塞主目标 | 记录并判断是否本轮修复 |
116
+ | P3 | 质量建议、命名、文档或轻微改进 | 可记录为 follow-up |
117
+
118
+ Material finding 指 P0/P1,以及任何会改变 stop condition 的 P2。
119
+
120
+ ## 状态规则
121
+
122
+ 每条 finding 的 `Status` 使用以下值:
123
+
124
+ - `open`
125
+ - `fixed`
126
+ - `accepted-residual`
127
+ - `not-reproducible`
128
+ - `out-of-scope`
129
+
130
+ `accepted-residual` 必须说明为什么不阻塞本轮目标,并路由到后续任务或 SSoT。
131
+
132
+ ## Confidence Loop
133
+
134
+ Review loop 的固定执行形态:
135
+
136
+ 1. 提出 Confidence Challenge。
137
+ 2. 如果不是 100% 有信心,列出所有可能漏洞和证据缺口。
138
+ 3. 将会影响 stop condition 的漏洞写入 Material Findings。
139
+ 4. 提出具体修复建议,并路由到本轮修复、accepted residual 或后续任务。
140
+ 5. 修复后重跑相关证据。
141
+ 6. 再次提出 Confidence Challenge。
142
+ 7. 直到没有 open material finding,才能写 no-finding statement 或 final confidence basis。
143
+
144
+ 不能把“accepted residual”当作 100% 信心。accepted residual 只表示该风险不阻塞本轮目标,
145
+ 仍然必须写明原因和后续路由。
146
+
147
+ ## 与其他文档的关系
148
+
149
+ - `review-routing-standard.md` 决定 reviewer / subagent / external agent / human review 何时触发
150
+ - `progress.md` 记录审查发生的时间和处理结果摘要
151
+ - `findings.md` 记录审查中产生的技术决策或研究发现
152
+ - `Regression-SSoT.md` 记录新增或调整的 regression surface
153
+ - `Lessons-SSoT.md` 记录可复用的流程、架构或标准改进建议
154
+ - `walkthrough` 收口时引用 `review.md` 的 material finding 状态和 no-finding 结论
155
+ - `Harness Ledger` 记录本轮是否完成 review report
156
+
157
+ ## 停止与收口规则
158
+
159
+ 任务不能在以下状态收口:
160
+
161
+ - 存在 `open` 的 P0/P1 finding
162
+ - reviewer 没有写 `review.md`,但任务合同要求 review loop
163
+ - Confidence Challenge 缺失,或没有记录 final confidence basis
164
+ - no-finding statement 缺失
165
+ - material finding 修复后没有重跑对应证据
166
+ - accepted residual 没有后续路由
167
+
168
+ 任务可以收口的最低条件:
169
+
170
+ - P0/P1 全部 `fixed`、`not-reproducible` 或有明确 `out-of-scope` 理由
171
+ - P2 material risk 已修复或 `accepted-residual` 并路由
172
+ - `Evidence Checked` 足以支撑 no-finding 或 residual 结论
173
+ - walkthrough 和 Harness Ledger 已引用 review report
@@ -0,0 +1,140 @@
1
+ # AGENTS.md / CLAUDE.md 入口设计模式
2
+
3
+ ## 核心思路
4
+
5
+ AGENTS.md 是跨 agent 的 canonical 入口;CLAUDE.md 是 Claude Code 的兼容入口。两者都应该是**目录和宪章**,不是百科全书。
6
+
7
+ 推荐默认生成:
8
+
9
+ - `AGENTS.md`:唯一事实源,包含硬规则和 Task-Type Reading Matrix
10
+ - `CLAUDE.md`:轻量 shim,只要求 Claude Code 先读 `AGENTS.md`,不复制完整规范
11
+
12
+ ## 反模式:百科全书式
13
+
14
+ 把所有规则塞进一个文件:架构原则、开发规范、测试标准、文档治理、协作纪律、环境配置……
15
+
16
+ 结果:文件越长,agent 表现越差。不相关的约束互相干扰,该关注的重点被淹没。
17
+
18
+ ## 正确模式:宪章 + 索引
19
+
20
+ AGENTS.md 只包含两类内容:
21
+
22
+ 1. **硬规则(宪章)** — 核心架构原则、绝对不能违反的约束
23
+ 2. **导航矩阵(索引)** — 做什么类型的任务,先读哪个文件
24
+
25
+ ### Task-Type Reading Matrix 示例
26
+
27
+ ```markdown
28
+ ## Task-Type Reading Matrix
29
+
30
+ - 架构 / adapter / runtime 相关任务:
31
+ 先读 docs/11-REFERENCE/core-decoupling-standard.md
32
+
33
+ - 测试 / scenario / 冒烟:
34
+ 先读 docs/11-REFERENCE/testing-standard.md
35
+
36
+ - 文档治理 / planning / walkthrough:
37
+ 先读 docs/11-REFERENCE/docs-library-standard.md
38
+
39
+ - Harness Ledger / 上下文回写:
40
+ 先读 docs/11-REFERENCE/harness-ledger-standard.md
41
+
42
+ - Walkthrough / Closeout / Lessons 收口:
43
+ 先读 docs/11-REFERENCE/walkthrough-standard.md,然后读 docs/01-GOVERNANCE/Lessons-SSoT.md 和 docs/10-WALKTHROUGH/Closeout-SSoT.md
44
+
45
+ - 开发执行 / 回写流程:
46
+ 先读 docs/11-REFERENCE/execution-workflow-standard.md
47
+
48
+ - Repo governance / PR / branch protection:
49
+ 先读 docs/11-REFERENCE/repo-governance-standard.md
50
+
51
+ - CI/CD / required checks:
52
+ 先读 docs/11-REFERENCE/ci-cd-standard.md
53
+
54
+ - 长程任务 / 连续执行 / 子代理审查:
55
+ 先读 docs/11-REFERENCE/long-running-task-standard.md
56
+
57
+ - 对抗性 review / reviewer 报告:
58
+ 先读 docs/11-REFERENCE/adversarial-review-standard.md
59
+
60
+ - Reviewer / subagent / 外部审查路由:
61
+ 先读 docs/11-REFERENCE/review-routing-standard.md
62
+
63
+ - 前端 / UI 任务:
64
+ 先读 docs/11-REFERENCE/frontend-standard.md
65
+ ```
66
+
67
+ ### 推荐结构
68
+
69
+ ```
70
+ 项目根目录/
71
+ ├── AGENTS.md ← 231 行,canonical 宪章 + 索引
72
+ ├── CLAUDE.md ← 轻量 shim,指向 AGENTS.md
73
+ └── docs/
74
+ ├── Harness-Ledger.md
75
+ └── 11-REFERENCE/
76
+ ├── testing-standard.md
77
+ ├── execution-workflow-standard.md
78
+ ├── repo-governance-standard.md
79
+ ├── ci-cd-standard.md
80
+ ├── long-running-task-standard.md
81
+ ├── adversarial-review-standard.md
82
+ ├── review-routing-standard.md
83
+ ├── engineering-standard.md
84
+ ├── frontend-standard.md
85
+ ├── docs-library-standard.md
86
+ ├── harness-ledger-standard.md
87
+ ├── regression-ssot-governance.md
88
+ ├── walkthrough-standard.md
89
+ └── ...(按需扩展)
90
+ ```
91
+
92
+ ### 行数控制
93
+
94
+ AGENTS.md 控制在 **100-300 行**。超过 300 行说明有内容应该下沉到 reference 文件。
95
+
96
+ CLAUDE.md 控制在 **10-50 行**。它只做 Claude Code 兼容入口,不应复制 AGENTS.md 的完整规则,避免两份入口文件漂移。
97
+
98
+ ### 关键设计决策
99
+
100
+ - agent 做后端重构时,不会被前端规范干扰
101
+ - agent 做测试时,不会被文档治理规则分心
102
+ - 每种任务类型只加载它需要的上下文
103
+ - agent 写 walkthrough 时会被入口显式路由回 Lessons SSoT,但 Lessons 全文不会塞进 AGENTS.md
104
+
105
+ 这跟 OpenAI 在 Harness Engineering 实践中得出的结论一致:给 agent 一张地图,不给一本千页手册。
106
+
107
+ ## 生成 AGENTS.md + CLAUDE.md 的步骤
108
+
109
+ 1. 确认项目的技术栈和主要模块
110
+ 2. 确认 `docs/11-REFERENCE/` 下有哪些标准文件
111
+ 3. 用 `templates/AGENTS.md.template` 作为 AGENTS.md 起点
112
+ 4. 填写项目信息区(项目名、技术栈、仓库结构)
113
+ 5. 根据项目模块编写 Task-Type Reading Matrix
114
+ 6. 写入硬规则(核心架构约束、绝对不能违反的原则)
115
+ 7. 控制 AGENTS.md 总行数在 100-300 行
116
+ 8. 用 `templates/CLAUDE.md.template` 生成 CLAUDE.md shim,指向 AGENTS.md
117
+ 9. 不要在 CLAUDE.md 中复制完整规范
118
+
119
+ ## 不同项目类型的调整
120
+
121
+ ### 单仓小项目
122
+ - Reading Matrix 可以简化为 3-5 条
123
+ - 硬规则可以更精简
124
+ - 不需要多 agent 协作规则
125
+
126
+ ### Monorepo
127
+ - Reading Matrix 按包/模块分组
128
+ - 每个包可以有自己的 reference 文件
129
+ - 需要跨包依赖规则
130
+
131
+ ### 前后端分离
132
+ - 前端和后端各有独立的 reference 文件
133
+ - Reading Matrix 按前端/后端/共享分组
134
+ - 需要 API 契约规则
135
+
136
+ ### 多人 + 多 Agent
137
+ - 需要协作纪律规则
138
+ - 需要 worktree 命名规范
139
+ - 需要明确 subagent reviewer 与 worker 的区别:worker 必须使用独立 worktree / branch,提交自己的 commit,再由 coordinator 集成
140
+ - 需要 merge 审批流程