coding-agent-harness 1.0.1 → 1.0.2

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 (159) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.en-US.md +14 -0
  3. package/README.md +111 -86
  4. package/README.zh-CN.md +270 -0
  5. package/SKILL.md +116 -189
  6. package/docs-release/README.md +72 -5
  7. package/docs-release/architecture/overview.md +286 -28
  8. package/docs-release/architecture/overview.zh-CN.md +288 -0
  9. package/docs-release/assets/dashboard-overview-en.png +0 -0
  10. package/docs-release/assets/harness-architecture.svg +163 -0
  11. package/docs-release/assets/harness-workflow.svg +64 -0
  12. package/docs-release/guides/agent-installation.en-US.md +214 -0
  13. package/docs-release/guides/agent-installation.md +123 -26
  14. package/docs-release/guides/document-audience-and-surfaces.en-US.md +112 -0
  15. package/docs-release/guides/document-audience-and-surfaces.md +112 -0
  16. package/docs-release/guides/full-legacy-migration-subagent-strategy.md +334 -0
  17. package/docs-release/guides/full-legacy-migration-subagent-strategy.zh-CN.md +334 -0
  18. package/docs-release/guides/legacy-migration-agent-prompt.md +384 -0
  19. package/docs-release/guides/legacy-migration-agent-prompt.zh-CN.md +361 -0
  20. package/docs-release/guides/migration-playbook.en-US.md +325 -0
  21. package/docs-release/guides/migration-playbook.md +329 -0
  22. package/docs-release/guides/parent-control-repository-pattern.en-US.md +252 -0
  23. package/docs-release/guides/parent-control-repository-pattern.md +252 -0
  24. package/docs-release/guides/repository-operating-models.en-US.md +196 -0
  25. package/docs-release/guides/repository-operating-models.md +196 -0
  26. package/docs-release/intl/README.md +15 -0
  27. package/docs-release/intl/de-DE.md +18 -0
  28. package/docs-release/intl/en-US.md +18 -0
  29. package/docs-release/intl/es-ES.md +18 -0
  30. package/docs-release/intl/fr-FR.md +18 -0
  31. package/docs-release/intl/ja-JP.md +18 -0
  32. package/docs-release/intl/ko-KR.md +18 -0
  33. package/docs-release/intl/zh-CN.md +18 -0
  34. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/brief.md +13 -0
  35. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/lesson_candidates.md +24 -0
  36. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/progress.md +1 -1
  37. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/task_plan.md +4 -2
  38. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/{visual_roadmap.md → visual_map.md} +9 -1
  39. package/package.json +3 -1
  40. package/references/agents-md-pattern.md +3 -3
  41. package/references/docs-directory-standard.md +47 -3
  42. package/references/external-source-intake-standard.md +75 -0
  43. package/references/harness-ledger.md +5 -3
  44. package/references/legacy-12-phase-bootstrap.md +41 -0
  45. package/references/lessons-governance.md +23 -6
  46. package/references/planning-loop.md +41 -3
  47. package/references/project-onboarding-audit.md +10 -0
  48. package/references/repo-governance-standard.md +2 -0
  49. package/references/testing-standard.md +50 -0
  50. package/references/walkthrough-closeout.md +6 -5
  51. package/scripts/check-harness.mjs +76 -35
  52. package/scripts/harness.mjs +303 -12
  53. package/scripts/lib/capability-registry.mjs +533 -0
  54. package/scripts/lib/check-profiles.mjs +510 -0
  55. package/scripts/lib/core-shared.mjs +186 -0
  56. package/scripts/lib/dashboard-data.mjs +389 -0
  57. package/scripts/lib/dashboard-workbench.mjs +217 -0
  58. package/scripts/lib/dashboard-writer.mjs +93 -2
  59. package/scripts/lib/harness-core.mjs +10 -1318
  60. package/scripts/lib/lesson-maintenance.mjs +145 -0
  61. package/scripts/lib/markdown-utils.mjs +158 -0
  62. package/scripts/lib/migration-planner.mjs +478 -0
  63. package/scripts/lib/migration-support.mjs +312 -0
  64. package/scripts/lib/task-lifecycle.mjs +755 -0
  65. package/scripts/lib/task-scanner.mjs +682 -0
  66. package/scripts/smoke-dashboard.mjs +22 -0
  67. package/scripts/test-harness.mjs +926 -14
  68. package/templates/AGENTS.md.template +41 -30
  69. package/templates/architecture/Architecture-SSoT.md +21 -0
  70. package/templates/architecture/README.md +49 -0
  71. package/templates/architecture/critical-flows.md +22 -0
  72. package/templates/architecture/local-repo-context.md +20 -0
  73. package/templates/architecture/service-catalog.md +17 -0
  74. package/templates/architecture/services/service-template.md +31 -0
  75. package/templates/architecture/system-map.md +22 -0
  76. package/templates/dashboard/assets/app-src/00-state.js +41 -0
  77. package/templates/dashboard/assets/app-src/10-router.js +76 -0
  78. package/templates/dashboard/assets/app-src/20-overview.js +235 -0
  79. package/templates/dashboard/assets/app-src/30-tasks.js +563 -0
  80. package/templates/dashboard/assets/app-src/40-modules.js +58 -0
  81. package/templates/dashboard/assets/app-src/45-review.js +128 -0
  82. package/templates/dashboard/assets/app-src/50-migration.js +169 -0
  83. package/templates/dashboard/assets/app-src/60-shared.js +61 -0
  84. package/templates/dashboard/assets/app-src/90-bindings.js +382 -0
  85. package/templates/dashboard/assets/app.css +2575 -310
  86. package/templates/dashboard/assets/app.js +1498 -307
  87. package/templates/dashboard/assets/app.manifest.json +11 -0
  88. package/templates/dashboard/assets/i18n.js +429 -44
  89. package/templates/dashboard/assets/mermaid-renderer.js +58 -8
  90. package/templates/development/README.md +52 -0
  91. package/templates/development/codebase-map.md +11 -0
  92. package/templates/development/cross-repo-debugging.md +18 -0
  93. package/templates/development/external-context/service-template.md +33 -0
  94. package/templates/development/external-source-packs/README.md +24 -0
  95. package/templates/development/external-source-packs/digest-template.md +28 -0
  96. package/templates/development/local-setup.md +16 -0
  97. package/templates/development/stubs-and-mocks.md +11 -0
  98. package/templates/integrations/README.md +40 -0
  99. package/templates/integrations/api-contract.md +42 -0
  100. package/templates/integrations/event-contract.md +46 -0
  101. package/templates/integrations/third-party/vendor-template.md +42 -0
  102. package/templates/integrations/webhook-contract.md +41 -0
  103. package/templates/planning/brief.md +32 -0
  104. package/templates/planning/lesson_candidates.md +58 -0
  105. package/templates/planning/long-running-task-contract.md +7 -0
  106. package/templates/planning/module_brief.md +25 -0
  107. package/templates/planning/module_session_prompt.md +6 -0
  108. package/templates/planning/task_plan.md +7 -5
  109. package/templates/planning/{visual_roadmap.md → visual_map.md} +24 -2
  110. package/templates/reference/docs-library-standard.md +31 -0
  111. package/templates/reference/execution-workflow-standard.md +4 -2
  112. package/templates/reference/external-source-intake-standard.md +82 -0
  113. package/templates/reference/harness-ledger-standard.md +1 -0
  114. package/templates/reference/repo-governance-standard.md +6 -4
  115. package/templates/reference/walkthrough-standard.md +2 -1
  116. package/templates/walkthrough/walkthrough-template.md +2 -2
  117. package/templates-zh-CN/AGENTS.md.template +69 -70
  118. package/templates-zh-CN/architecture/Architecture-SSoT.md +21 -0
  119. package/templates-zh-CN/architecture/README.md +51 -0
  120. package/templates-zh-CN/architecture/critical-flows.md +24 -0
  121. package/templates-zh-CN/architecture/local-repo-context.md +20 -0
  122. package/templates-zh-CN/architecture/service-catalog.md +17 -0
  123. package/templates-zh-CN/architecture/services/service-template.md +31 -0
  124. package/templates-zh-CN/architecture/system-map.md +22 -0
  125. package/templates-zh-CN/development/README.md +54 -0
  126. package/templates-zh-CN/development/codebase-map.md +11 -0
  127. package/templates-zh-CN/development/cross-repo-debugging.md +18 -0
  128. package/templates-zh-CN/development/external-context/service-template.md +33 -0
  129. package/templates-zh-CN/development/external-source-packs/README.md +24 -0
  130. package/templates-zh-CN/development/external-source-packs/digest-template.md +28 -0
  131. package/templates-zh-CN/development/local-setup.md +16 -0
  132. package/templates-zh-CN/development/stubs-and-mocks.md +11 -0
  133. package/templates-zh-CN/integrations/README.md +42 -0
  134. package/templates-zh-CN/integrations/api-contract.md +42 -0
  135. package/templates-zh-CN/integrations/event-contract.md +46 -0
  136. package/templates-zh-CN/integrations/third-party/vendor-template.md +42 -0
  137. package/templates-zh-CN/integrations/webhook-contract.md +41 -0
  138. package/templates-zh-CN/planning/brief.md +32 -0
  139. package/templates-zh-CN/planning/lesson_candidates.md +58 -0
  140. package/templates-zh-CN/planning/long-running-task-contract.md +1 -1
  141. package/templates-zh-CN/planning/module_brief.md +25 -0
  142. package/templates-zh-CN/planning/module_plan.md +2 -2
  143. package/templates-zh-CN/planning/module_session_prompt.md +4 -3
  144. package/templates-zh-CN/planning/task_plan.md +10 -4
  145. package/templates-zh-CN/planning/{visual_roadmap.md → visual_map.md} +21 -2
  146. package/templates-zh-CN/reference/docs-library-standard.md +35 -0
  147. package/templates-zh-CN/reference/execution-workflow-standard.md +9 -2
  148. package/templates-zh-CN/reference/external-source-intake-standard.md +82 -0
  149. package/templates-zh-CN/reference/harness-ledger-standard.md +5 -2
  150. package/templates-zh-CN/reference/repo-governance-standard.md +2 -0
  151. package/templates-zh-CN/reference/walkthrough-standard.md +4 -4
  152. package/templates-zh-CN/walkthrough/Closeout-SSoT.md +2 -2
  153. package/templates-zh-CN/walkthrough/walkthrough-template.md +2 -2
  154. package/templates-zh-CN/dashboard/assets/app.css +0 -399
  155. package/templates-zh-CN/dashboard/assets/app.js +0 -435
  156. package/templates-zh-CN/dashboard/assets/i18n.js +0 -47
  157. package/templates-zh-CN/dashboard/assets/markdown-reader.js +0 -116
  158. package/templates-zh-CN/dashboard/assets/mermaid-renderer.js +0 -59
  159. package/templates-zh-CN/dashboard/index.html +0 -18
@@ -1,52 +1,310 @@
1
1
  # Architecture Overview
2
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.
3
+ English | [简体中文](overview.zh-CN.md)
6
4
 
7
- ## Public Architecture
5
+ Coding Agent Harness is a repository-native operating layer for long-running
6
+ coding agent work. It gives agents a stable project memory, a task lifecycle,
7
+ review gates, migration rails, and a dashboard that humans can inspect.
8
+
9
+ The core idea is simple: keep the important state in files the agent can read,
10
+ then use the CLI to derive status, checks, migration plans, and dashboard views
11
+ from those files.
12
+
13
+ ## Mental Model
14
+
15
+ ```mermaid
16
+ flowchart LR
17
+ Prompt["Prompt engineering<br/>better instruction"]
18
+ Context["Context engineering<br/>better evidence loaded"]
19
+ Harness["Harness engineering<br/>better operating system"]
20
+
21
+ Prompt --> Context
22
+ Context --> Harness
23
+
24
+ Prompt --> P1["role, task, constraints"]
25
+ Context --> C1["docs, files, prior outputs"]
26
+ Harness --> H1["state, gates, dashboard, review"]
27
+ ```
28
+
29
+ Prompt engineering improves a single model call. Context engineering improves
30
+ what the model sees across a task. Harness engineering improves how the whole
31
+ agent workflow runs over days, handoffs, reviews, and releases.
32
+
33
+ ## Product Architecture
8
34
 
9
35
  ```mermaid
10
36
  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"]
37
+ Skill["Agent skill<br/>SKILL.md"]
38
+ CLI["Harness CLI<br/>scripts/harness.mjs"]
39
+ Standards["Standards<br/>references/"]
40
+ Templates["Scaffolds<br/>templates/ + templates-zh-CN/"]
41
+ Target["Target repository<br/>AGENTS.md + docs/"]
42
+ Scanner["Scanner and validators<br/>status/check"]
43
+ Dashboard["Dashboard / Workbench<br/>HTML + JSON"]
44
+ Human["Human reviewer<br/>approval and inspection"]
45
+ Agent["Coding agent<br/>Codex / Claude / Gemini"]
16
46
 
17
- Skill --> Docs
18
- Skill --> Templates
47
+ Agent --> Skill
48
+ Skill --> Standards
49
+ Skill --> CLI
50
+ CLI --> Templates
19
51
  Templates --> Target
20
- Docs --> Target
21
- Check --> Target
52
+ Standards --> Target
53
+ Target --> Scanner
54
+ Scanner --> Dashboard
55
+ Dashboard --> Human
56
+ Scanner --> Agent
57
+ Human --> Agent
58
+ ```
59
+
60
+ The package ships the repeatable pieces: standards, templates, CLI logic,
61
+ dashboard assets, examples, and public docs. Target projects hold the live
62
+ project facts.
63
+
64
+ ## Target Repository Model
65
+
66
+ ```mermaid
67
+ flowchart TB
68
+ Entry["AGENTS.md<br/>agent entry and routing"]
69
+ Registry[".harness-capabilities.json<br/>enabled capabilities"]
70
+ Docs["docs/"]
71
+ Architecture["03-ARCHITECTURE<br/>system facts"]
72
+ Development["04-DEVELOPMENT<br/>local setup and code map"]
73
+ QA["05-TEST-QA<br/>regression and cadence"]
74
+ Integrations["06-INTEGRATIONS<br/>external contracts"]
75
+ Planning["09-PLANNING<br/>tasks and modules"]
76
+ Walkthrough["10-WALKTHROUGH<br/>closeout evidence"]
77
+ Reference["11-REFERENCE<br/>local operating standards"]
78
+ Ledger["Harness Ledger / SSoTs / Lessons<br/>long-lived memory"]
79
+
80
+ Entry --> Docs
81
+ Registry --> Docs
82
+ Docs --> Architecture
83
+ Docs --> Development
84
+ Docs --> QA
85
+ Docs --> Integrations
86
+ Docs --> Planning
87
+ Docs --> Walkthrough
88
+ Docs --> Reference
89
+ Docs --> Ledger
22
90
  ```
23
91
 
24
- ## Operating Principle
92
+ The target repository is the source of truth. The agent should be able to resume
93
+ from these files without relying on previous chat memory.
94
+
95
+ ## Repository Operating Models
96
+
97
+ The target repository can be organized in three ways:
98
+
99
+ | Model | Control surface | Execution surface |
100
+ | --- | --- | --- |
101
+ | Single repo | The same repository owns `AGENTS.md`, `docs/`, code, tests, and closeout. | The same repository. |
102
+ | Independent multi-repo | Each repository owns its own local `AGENTS.md` and `docs/`. | Each repository runs independently. |
103
+ | Parent-control repository | A parent repository owns the global Harness control plane. | Child repositories own implementation code and local checks. |
104
+
105
+ For products split across frontend, backend, SDKs, services, and upstream references,
106
+ the parent-control model keeps the agent startup point, Feature SSoT, regression
107
+ state, and closeout evidence in one place. See
108
+ `docs-release/guides/repository-operating-models.en-US.md` and
109
+ `docs-release/guides/parent-control-repository-pattern.en-US.md`.
110
+
111
+ ## CLI Command Surface
112
+
113
+ ```mermaid
114
+ flowchart LR
115
+ CLI["harness CLI"]
116
+
117
+ CLI --> Init["init / add-capability<br/>create or extend harness files"]
118
+ CLI --> Status["status / check<br/>derive health and failures"]
119
+ CLI --> Dashboard["dashboard / dev<br/>render human-readable state"]
120
+ CLI --> Migration["migrate-plan / migrate-run / migrate-verify<br/>legacy project adoption"]
121
+ CLI --> Task["new-task / task-* / review-confirm<br/>task lifecycle operations"]
122
+ CLI --> UserSkill["install-user / doctor-user<br/>local skill setup"]
123
+
124
+ Status --> Scanner["task scanner + check profiles"]
125
+ Dashboard --> Bundle["status, tables, docs, graph, adoption warnings"]
126
+ Task --> Lifecycle["task lifecycle writer"]
127
+ Migration --> Planner["migration planner and verifier"]
128
+ ```
129
+
130
+ All command families read the same repository facts. That keeps CLI output,
131
+ checks, migration reports, and dashboard views aligned.
132
+
133
+ ## Dashboard Data Flow
134
+
135
+ ```mermaid
136
+ sequenceDiagram
137
+ autonumber
138
+ participant CLI as harness dashboard/dev
139
+ participant Scanner as scanner + validators
140
+ participant Bundle as dashboard bundle
141
+ participant Output as HTML output
142
+ participant Browser as browser
143
+ participant Target as target docs
144
+
145
+ CLI->>Scanner: read AGENTS.md, docs, tasks, SSoTs
146
+ Scanner->>Bundle: build status, tables, documents, graph, warnings
147
+ Bundle->>Output: write index.html, assets, data/*.json
148
+ Browser->>Output: open static dashboard snapshot
149
+ alt local workbench mode
150
+ Browser->>CLI: submit approved action
151
+ CLI->>Target: update scoped markdown files
152
+ CLI->>Output: regenerate snapshot
153
+ end
154
+ ```
25
155
 
26
- The harness separates three concerns:
156
+ The static dashboard is a portable evidence snapshot. The local workbench adds a
157
+ small writable surface for human-confirmed actions such as review completion.
27
158
 
28
- | Layer | Responsibility |
159
+ ## Task Lifecycle State Machine
160
+
161
+ ```mermaid
162
+ stateDiagram-v2
163
+ [*] --> ready: new-task or planned docs
164
+ ready --> active: task-start
165
+ active --> active: task-log / task-phase
166
+ active --> blocked: task-block
167
+ blocked --> active: task-start
168
+ active --> in_review: task-review
169
+ in_review --> review_blocked: open P0-P2 finding
170
+ review_blocked --> in_review: finding closed or routed
171
+ in_review --> closing: review-confirm + task-complete
172
+ closing --> closed: closeout evidence linked
173
+ closed --> [*]
174
+ ```
175
+
176
+ The scanner keeps raw task state and derived lifecycle state separate:
177
+
178
+ | Raw task state | Derived lifecycle meaning |
29
179
  | --- | --- |
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. |
180
+ | `not_started` / `planned` | `ready` |
181
+ | `in_progress` | `active` |
182
+ | `blocked` | `blocked` |
183
+ | `review` with open blocking findings | `review-blocked` |
184
+ | `review` without blocking findings | `in_review` |
185
+ | `done` without closeout | `closing` |
186
+ | any state with closed closeout evidence | `closed` |
187
+
188
+ This prevents a task from looking finished just because one file says `done`.
189
+
190
+ ## Review And Closeout Gate
191
+
192
+ ```mermaid
193
+ flowchart TB
194
+ Review["task-review"]
195
+ Simple{"simple budget?"}
196
+ Phase["Visual Map progress<br/>or phase evidence"]
197
+ Lessons["lesson candidates<br/>review decision complete"]
198
+ Findings{"open P0-P2 findings?"}
199
+ Walkthrough["walkthrough / closeout evidence"]
200
+ Confirm["human review confirmation"]
201
+ Complete["task-complete"]
202
+ Closed["closed lifecycle"]
203
+
204
+ Review --> Simple
205
+ Simple -- yes --> Findings
206
+ Simple -- no --> Phase
207
+ Phase --> Lessons
208
+ Lessons --> Findings
209
+ Findings -- yes --> Review
210
+ Findings -- no --> Walkthrough
211
+ Walkthrough --> Confirm
212
+ Confirm --> Complete
213
+ Complete --> Closed
214
+ ```
215
+
216
+ Standard and complex tasks must show progress, evidence, lesson resolution,
217
+ review confirmation, and closeout linkage before they are treated as closed.
218
+
219
+ ## Migration Rails
220
+
221
+ ```mermaid
222
+ flowchart LR
223
+ Legacy["existing project"]
224
+ Scan["migrate-plan<br/>scan facts"]
225
+ Mode{"recommended mode"}
226
+ Baseline["baseline-preserve<br/>safe adoption"]
227
+ StatusAware["status-aware-rewrite<br/>current task repair"]
228
+ Full["full-semantic-rewrite<br/>full readable cutover"]
229
+ Run["migrate-run<br/>session + dashboard"]
230
+ Verify["migrate-verify<br/>normal or full-cutover"]
231
+ Evidence["final evidence<br/>dashboard + checks"]
232
+
233
+ Legacy --> Scan
234
+ Scan --> Mode
235
+ Mode --> Baseline
236
+ Mode --> StatusAware
237
+ Mode --> Full
238
+ Baseline --> Run
239
+ StatusAware --> Run
240
+ Full --> Run
241
+ Run --> Verify
242
+ Verify --> Evidence
243
+ ```
244
+
245
+ Migration is plan-first. The agent scans the project, recommends a mode, and
246
+ waits for confirmation before changing old task history.
247
+
248
+ ## Documentation Surface
249
+
250
+ ```mermaid
251
+ flowchart TB
252
+ Readme["README<br/>first impression and quick start"]
253
+ DocsRelease["docs-release<br/>public architecture and guides"]
254
+ References["references<br/>reusable standards"]
255
+ Templates["templates<br/>files generated into target repos"]
256
+ Skill["SKILL.md<br/>agent operating entry"]
257
+ CLI["harness CLI<br/>enforces and renders"]
258
+
259
+ Readme --> DocsRelease
260
+ DocsRelease --> References
261
+ Skill --> References
262
+ Skill --> Templates
263
+ CLI --> Templates
264
+ CLI --> References
265
+ ```
266
+
267
+ `README` introduces the product. `docs-release` explains architecture and user
268
+ workflows. `references` defines reusable standards. `templates` are the concrete
269
+ files installed into a target project.
270
+
271
+ ## Release Package Surface
272
+
273
+ ```mermaid
274
+ flowchart LR
275
+ Source["source checkout"]
276
+ Check["source-package check"]
277
+ Test["npm test<br/>dashboard smoke"]
278
+ Pack["npm pack --dry-run"]
279
+ Tarball["npm tarball<br/>CLI + docs + templates + examples"]
280
+ Publish["npm publish"]
281
+
282
+ Source --> Check
283
+ Check --> Test
284
+ Test --> Pack
285
+ Pack --> Tarball
286
+ Tarball --> Publish
287
+ ```
33
288
 
34
- The public package should describe the system. It should not publish private
35
- operating ledgers from this repository or from any target project.
289
+ The public release artifact is the npm package. `npm pack --dry-run` is the
290
+ final shape check before publish because it shows exactly which docs, scripts,
291
+ templates, examples, and assets will be shipped.
36
292
 
37
293
  ## Worker / Coordinator Boundary
38
294
 
39
295
  ```mermaid
40
296
  flowchart LR
41
- Worker["Worker<br/>local module files"]
42
- Handoff["Coordinator Handoff"]
43
- Coordinator["Coordinator<br/>global facts"]
44
- Check["Strict Check"]
297
+ Worker["Worker agent<br/>local module or task files"]
298
+ Handoff["handoff marker<br/>progress.md"]
299
+ Coordinator["Coordinator agent<br/>global projection"]
300
+ Registry["registries / ledgers / SSoTs"]
301
+ Check["strict check"]
45
302
 
46
303
  Worker --> Handoff
47
304
  Handoff --> Coordinator
48
- Coordinator --> Check
305
+ Coordinator --> Registry
306
+ Registry --> Check
49
307
  ```
50
308
 
51
- Workers own local task and module facts. Coordinators own global projections such
52
- as registries, ledgers, closeout indexes, and regression state.
309
+ Workers own local task and module facts. Coordinators own global projections:
310
+ registries, ledgers, closeout indexes, and regression state.
@@ -0,0 +1,288 @@
1
+ # 架构总览
2
+
3
+ [English](overview.md) | 简体中文
4
+
5
+ Coding Agent Harness 是一套面向长程 Coding Agent 工作的、仓库原生的运行层。它给 Agent 提供稳定的项目记忆、任务生命周期、审查门禁、迁移轨道,以及人可以检查的 Dashboard。
6
+
7
+ 核心思路很简单:把重要状态放进 Agent 能读取的文件里,再用 CLI 从这些文件推导 status、check、migration plan 和 dashboard view。
8
+
9
+ ## 心智模型
10
+
11
+ ```mermaid
12
+ flowchart LR
13
+ Prompt["Prompt engineering<br/>优化单次指令"]
14
+ Context["Context engineering<br/>优化可见证据"]
15
+ Harness["Harness engineering<br/>优化运行系统"]
16
+
17
+ Prompt --> Context
18
+ Context --> Harness
19
+
20
+ Prompt --> P1["角色、任务、约束"]
21
+ Context --> C1["文档、文件、历史输出"]
22
+ Harness --> H1["状态、门禁、Dashboard、审查"]
23
+ ```
24
+
25
+ Prompt engineering 改善一次模型调用。Context engineering 改善模型在任务中能看到什么。Harness engineering 改善 Agent 在多天执行、多人交接、审查和发布中的整体运行方式。
26
+
27
+ ## 产品架构
28
+
29
+ ```mermaid
30
+ flowchart TB
31
+ Skill["Agent Skill<br/>SKILL.md"]
32
+ CLI["Harness CLI<br/>scripts/harness.mjs"]
33
+ Standards["标准<br/>references/"]
34
+ Templates["脚手架<br/>templates/ + templates-zh-CN/"]
35
+ Target["目标仓库<br/>AGENTS.md + docs/"]
36
+ Scanner["扫描器与校验器<br/>status/check"]
37
+ Dashboard["Dashboard / Workbench<br/>HTML + JSON"]
38
+ Human["人工审查者<br/>批准与检查"]
39
+ Agent["Coding Agent<br/>Codex / Claude / Gemini"]
40
+
41
+ Agent --> Skill
42
+ Skill --> Standards
43
+ Skill --> CLI
44
+ CLI --> Templates
45
+ Templates --> Target
46
+ Standards --> Target
47
+ Target --> Scanner
48
+ Scanner --> Dashboard
49
+ Dashboard --> Human
50
+ Scanner --> Agent
51
+ Human --> Agent
52
+ ```
53
+
54
+ 这个包交付的是可复用部件:标准、模板、CLI 逻辑、Dashboard 资产、示例和公开文档。目标项目保存真实运行中的项目事实。
55
+
56
+ ## 目标仓库模型
57
+
58
+ ```mermaid
59
+ flowchart TB
60
+ Entry["AGENTS.md<br/>Agent 入口与路由"]
61
+ Registry[".harness-capabilities.json<br/>已启用能力"]
62
+ Docs["docs/"]
63
+ Architecture["03-ARCHITECTURE<br/>系统事实"]
64
+ Development["04-DEVELOPMENT<br/>本地设置与代码地图"]
65
+ QA["05-TEST-QA<br/>回归与节奏"]
66
+ Integrations["06-INTEGRATIONS<br/>外部契约"]
67
+ Planning["09-PLANNING<br/>任务与模块"]
68
+ Walkthrough["10-WALKTHROUGH<br/>收口证据"]
69
+ Reference["11-REFERENCE<br/>本地运行标准"]
70
+ Ledger["Harness Ledger / SSoT / Lessons<br/>长期记忆"]
71
+
72
+ Entry --> Docs
73
+ Registry --> Docs
74
+ Docs --> Architecture
75
+ Docs --> Development
76
+ Docs --> QA
77
+ Docs --> Integrations
78
+ Docs --> Planning
79
+ Docs --> Walkthrough
80
+ Docs --> Reference
81
+ Docs --> Ledger
82
+ ```
83
+
84
+ 目标仓库是事实源。Agent 应该能从这些文件恢复上下文,而不是依赖上一轮聊天记忆。
85
+
86
+ ## 仓库运行模式
87
+
88
+ 目标项目可以采用三种仓库组织方式:
89
+
90
+ | 模式 | 控制面 | 执行面 |
91
+ | --- | --- | --- |
92
+ | 单仓模式 | 同一个仓库管理 `AGENTS.md`、`docs/`、代码、测试和收口。 | 同一个仓库。 |
93
+ | 多仓独立模式 | 每个仓库都有自己的局部 `AGENTS.md` 和 `docs/`。 | 每个仓库独立执行。 |
94
+ | 主控仓库模式 | 父仓库管理全局 Harness 控制面。 | 子仓库管理实现代码和局部检查。 |
95
+
96
+ 如果一个产品拆成前端、后端、SDK、微服务和上游参考仓库,主控仓库模式可以把 Agent 启动入口、Feature SSoT、回归状态和收口证据固定在一个地方。详见 `docs-release/guides/repository-operating-models.md` 和 `docs-release/guides/parent-control-repository-pattern.md`。
97
+
98
+ ## CLI 命令面
99
+
100
+ ```mermaid
101
+ flowchart LR
102
+ CLI["harness CLI"]
103
+
104
+ CLI --> Init["init / add-capability<br/>创建或扩展 Harness 文件"]
105
+ CLI --> Status["status / check<br/>推导健康状态与失败项"]
106
+ CLI --> Dashboard["dashboard / dev<br/>渲染可读状态"]
107
+ CLI --> Migration["migrate-plan / migrate-run / migrate-verify<br/>旧项目迁移"]
108
+ CLI --> Task["new-task / task-* / review-confirm<br/>任务生命周期操作"]
109
+ CLI --> UserSkill["install-user / doctor-user<br/>本机 Skill 设置"]
110
+
111
+ Status --> Scanner["任务扫描器 + check profiles"]
112
+ Dashboard --> Bundle["status、tables、docs、graph、adoption warnings"]
113
+ Task --> Lifecycle["任务生命周期写入器"]
114
+ Migration --> Planner["迁移规划器与验证器"]
115
+ ```
116
+
117
+ 所有命令族都读取同一份仓库事实,因此 CLI 输出、检查结果、迁移报告和 Dashboard 视图会保持一致。
118
+
119
+ ## Dashboard 数据流
120
+
121
+ ```mermaid
122
+ sequenceDiagram
123
+ autonumber
124
+ participant CLI as harness dashboard/dev
125
+ participant Scanner as 扫描器 + 校验器
126
+ participant Bundle as dashboard bundle
127
+ participant Output as HTML 输出
128
+ participant Browser as 浏览器
129
+ participant Target as 目标 docs
130
+
131
+ CLI->>Scanner: 读取 AGENTS.md、docs、tasks、SSoT
132
+ Scanner->>Bundle: 构建 status、tables、documents、graph、warnings
133
+ Bundle->>Output: 写入 index.html、assets、data/*.json
134
+ Browser->>Output: 打开静态 Dashboard 快照
135
+ alt 本地 Workbench 模式
136
+ Browser->>CLI: 提交已批准动作
137
+ CLI->>Target: 更新受限 Markdown 文件
138
+ CLI->>Output: 重新生成快照
139
+ end
140
+ ```
141
+
142
+ 静态 Dashboard 是可携带的证据快照。本地 Workbench 增加一个很小的可写操作面,用于人工确认过的动作,例如 review completion。
143
+
144
+ ## 任务生命周期状态机
145
+
146
+ ```mermaid
147
+ stateDiagram-v2
148
+ [*] --> ready: new-task 或 planned docs
149
+ ready --> active: task-start
150
+ active --> active: task-log / task-phase
151
+ active --> blocked: task-block
152
+ blocked --> active: task-start
153
+ active --> in_review: task-review
154
+ in_review --> review_blocked: 存在 P0-P2 finding
155
+ review_blocked --> in_review: finding 关闭或路由
156
+ in_review --> closing: review-confirm + task-complete
157
+ closing --> closed: 收口证据已链接
158
+ closed --> [*]
159
+ ```
160
+
161
+ 扫描器会区分原始任务状态和派生生命周期状态:
162
+
163
+ | 原始任务状态 | 派生生命周期含义 |
164
+ | --- | --- |
165
+ | `not_started` / `planned` | `ready` |
166
+ | `in_progress` | `active` |
167
+ | `blocked` | `blocked` |
168
+ | `review` 且存在阻塞 finding | `review-blocked` |
169
+ | `review` 且无阻塞 finding | `in_review` |
170
+ | `done` 但缺少 closeout | `closing` |
171
+ | 任意状态且已有 closed closeout 证据 | `closed` |
172
+
173
+ 这样可以避免一个文件里写了 `done`,任务就被误认为真正完成。
174
+
175
+ ## Review 与 Closeout 门禁
176
+
177
+ ```mermaid
178
+ flowchart TB
179
+ Review["task-review"]
180
+ Simple{"simple budget?"}
181
+ Phase["Visual Map 进度<br/>或 phase evidence"]
182
+ Lessons["lesson candidates<br/>review decision complete"]
183
+ Findings{"存在 P0-P2 findings?"}
184
+ Walkthrough["walkthrough / closeout evidence"]
185
+ Confirm["human review confirmation"]
186
+ Complete["task-complete"]
187
+ Closed["closed lifecycle"]
188
+
189
+ Review --> Simple
190
+ Simple -- yes --> Findings
191
+ Simple -- no --> Phase
192
+ Phase --> Lessons
193
+ Lessons --> Findings
194
+ Findings -- yes --> Review
195
+ Findings -- no --> Walkthrough
196
+ Walkthrough --> Confirm
197
+ Confirm --> Complete
198
+ Complete --> Closed
199
+ ```
200
+
201
+ standard 和 complex 任务必须具备进度、证据、lesson 决议、人工确认和收口链接,才会被视为真正关闭。
202
+
203
+ ## 迁移轨道
204
+
205
+ ```mermaid
206
+ flowchart LR
207
+ Legacy["已有项目"]
208
+ Scan["migrate-plan<br/>扫描事实"]
209
+ Mode{"推荐模式"}
210
+ Baseline["baseline-preserve<br/>安全接入"]
211
+ StatusAware["status-aware-rewrite<br/>修复当前任务"]
212
+ Full["full-semantic-rewrite<br/>完整可读迁移"]
213
+ Run["migrate-run<br/>session + dashboard"]
214
+ Verify["migrate-verify<br/>normal 或 full-cutover"]
215
+ Evidence["最终证据<br/>dashboard + checks"]
216
+
217
+ Legacy --> Scan
218
+ Scan --> Mode
219
+ Mode --> Baseline
220
+ Mode --> StatusAware
221
+ Mode --> Full
222
+ Baseline --> Run
223
+ StatusAware --> Run
224
+ Full --> Run
225
+ Run --> Verify
226
+ Verify --> Evidence
227
+ ```
228
+
229
+ 迁移是 plan-first 的。Agent 先扫描项目、推荐模式,并在修改旧任务历史前等待确认。
230
+
231
+ ## 文档表面
232
+
233
+ ```mermaid
234
+ flowchart TB
235
+ Readme["README<br/>第一印象与快速开始"]
236
+ DocsRelease["docs-release<br/>公开架构与指南"]
237
+ References["references<br/>可复用标准"]
238
+ Templates["templates<br/>生成到目标仓库的文件"]
239
+ Skill["SKILL.md<br/>Agent 运行入口"]
240
+ CLI["harness CLI<br/>执行校验与渲染"]
241
+
242
+ Readme --> DocsRelease
243
+ DocsRelease --> References
244
+ Skill --> References
245
+ Skill --> Templates
246
+ CLI --> Templates
247
+ CLI --> References
248
+ ```
249
+
250
+ `README` 介绍产品。`docs-release` 解释架构和用户工作流。`references` 定义可复用标准。`templates` 是安装到目标项目里的具体文件。
251
+
252
+ ## 发布包表面
253
+
254
+ ```mermaid
255
+ flowchart LR
256
+ Source["source checkout"]
257
+ Check["source-package check"]
258
+ Test["npm test<br/>dashboard smoke"]
259
+ Pack["npm pack --dry-run"]
260
+ Tarball["npm tarball<br/>CLI + docs + templates + examples"]
261
+ Publish["npm publish"]
262
+
263
+ Source --> Check
264
+ Check --> Test
265
+ Test --> Pack
266
+ Pack --> Tarball
267
+ Tarball --> Publish
268
+ ```
269
+
270
+ 公开发布物是 npm package。`npm pack --dry-run` 是 publish 前的最终形态检查,因为它展示了会被发布出去的 docs、scripts、templates、examples 和 assets。
271
+
272
+ ## Worker / Coordinator 边界
273
+
274
+ ```mermaid
275
+ flowchart LR
276
+ Worker["Worker agent<br/>局部模块或任务文件"]
277
+ Handoff["handoff marker<br/>progress.md"]
278
+ Coordinator["Coordinator agent<br/>全局投影"]
279
+ Registry["registries / ledgers / SSoT"]
280
+ Check["strict check"]
281
+
282
+ Worker --> Handoff
283
+ Handoff --> Coordinator
284
+ Coordinator --> Registry
285
+ Registry --> Check
286
+ ```
287
+
288
+ Worker 负责局部任务与模块事实。Coordinator 负责全局投影:registries、ledgers、closeout indexes 和 regression state。