coding-agent-harness 1.0.5 → 1.0.6

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 (260) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/README.md +63 -3
  3. package/README.zh-CN.md +52 -3
  4. package/SKILL.md +43 -43
  5. package/dist/build-dist.mjs +189 -0
  6. package/dist/check-dist-observation.mjs +428 -0
  7. package/dist/check-harness.mjs +489 -0
  8. package/dist/check-import-graph.mjs +511 -0
  9. package/dist/check-runtime-emit.mjs +304 -0
  10. package/dist/check-type-boundaries.mjs +139 -0
  11. package/dist/commands/dashboard-command.mjs +80 -0
  12. package/dist/commands/migration-command.mjs +152 -0
  13. package/dist/commands/preset-command.mjs +91 -0
  14. package/dist/commands/task-command.mjs +324 -0
  15. package/dist/harness.mjs +304 -0
  16. package/dist/lib/capability-registry.mjs +643 -0
  17. package/dist/lib/check-module-parallel.mjs +227 -0
  18. package/dist/lib/check-profiles.mjs +414 -0
  19. package/dist/lib/check-task-contracts.mjs +54 -0
  20. package/dist/lib/core-shared.mjs +254 -0
  21. package/dist/lib/dashboard-data.mjs +608 -0
  22. package/dist/lib/dashboard-workbench.mjs +334 -0
  23. package/dist/lib/dashboard-writer.mjs +200 -0
  24. package/dist/lib/git-status-summary.mjs +45 -0
  25. package/dist/lib/governance-index-generator.mjs +236 -0
  26. package/dist/lib/governance-sync.mjs +617 -0
  27. package/dist/lib/governance-table-boundary.mjs +161 -0
  28. package/{scripts → dist}/lib/harness-core.mjs +2 -0
  29. package/dist/lib/harness-paths.mjs +338 -0
  30. package/dist/lib/lesson-maintenance.mjs +139 -0
  31. package/dist/lib/markdown-utils.mjs +193 -0
  32. package/dist/lib/migration-planner.mjs +439 -0
  33. package/dist/lib/migration-support.mjs +317 -0
  34. package/dist/lib/phase-kind.mjs +46 -0
  35. package/dist/lib/preset-audit-contracts.mjs +40 -0
  36. package/dist/lib/preset-engine.mjs +516 -0
  37. package/dist/lib/preset-registry.mjs +831 -0
  38. package/dist/lib/preset-resource-contracts.mjs +83 -0
  39. package/dist/lib/review-confirm-git-gate.mjs +244 -0
  40. package/dist/lib/status-builder.mjs +87 -0
  41. package/{scripts → dist}/lib/status-dashboard-renderer.mjs +44 -46
  42. package/dist/lib/structure-migration.mjs +404 -0
  43. package/dist/lib/subagent-authorization-audit.mjs +198 -0
  44. package/dist/lib/task-audit-metadata.mjs +376 -0
  45. package/dist/lib/task-audit-migration.mjs +355 -0
  46. package/dist/lib/task-completion-consistency.mjs +29 -0
  47. package/dist/lib/task-index.mjs +133 -0
  48. package/dist/lib/task-lesson-candidates.mjs +239 -0
  49. package/dist/lib/task-lesson-sedimentation.mjs +300 -0
  50. package/dist/lib/task-lifecycle/create-task-helpers.mjs +84 -0
  51. package/dist/lib/task-lifecycle/phase-sync.mjs +82 -0
  52. package/dist/lib/task-lifecycle/review-confirm.mjs +93 -0
  53. package/dist/lib/task-lifecycle/review-gates.mjs +62 -0
  54. package/dist/lib/task-lifecycle/review-submission.mjs +52 -0
  55. package/dist/lib/task-lifecycle/scaffold-provenance.mjs +54 -0
  56. package/dist/lib/task-lifecycle/template-files.mjs +52 -0
  57. package/dist/lib/task-lifecycle/text-utils.mjs +26 -0
  58. package/dist/lib/task-lifecycle.mjs +611 -0
  59. package/dist/lib/task-metadata.mjs +116 -0
  60. package/dist/lib/task-review-model.mjs +474 -0
  61. package/dist/lib/task-scanner.mjs +439 -0
  62. package/dist/lib/task-tombstone-commands.mjs +125 -0
  63. package/dist/postinstall.mjs +14 -0
  64. package/dist/run-built-tests.mjs +84 -0
  65. package/docs-release/README.md +1 -0
  66. package/docs-release/architecture/overview.md +12 -12
  67. package/docs-release/architecture/overview.zh-CN.md +12 -12
  68. package/docs-release/architecture/system-explainer/01-system-overview.md +15 -14
  69. package/docs-release/architecture/system-explainer/02-module-dependency.md +8 -8
  70. package/docs-release/architecture/system-explainer/03-task-lifecycle.md +3 -3
  71. package/docs-release/architecture/system-explainer/04-check-and-governance.md +9 -7
  72. package/docs-release/architecture/system-explainer/05-data-flow.md +5 -5
  73. package/docs-release/architecture/system-explainer/06-preset-and-migration.md +1 -4
  74. package/docs-release/architecture/system-explainer/en-US/01-system-overview.md +15 -14
  75. package/docs-release/architecture/system-explainer/en-US/02-module-dependency.md +8 -8
  76. package/docs-release/architecture/system-explainer/en-US/03-task-lifecycle.md +3 -3
  77. package/docs-release/architecture/system-explainer/en-US/04-check-and-governance.md +10 -8
  78. package/docs-release/architecture/system-explainer/en-US/05-data-flow.md +5 -5
  79. package/docs-release/architecture/system-explainer/en-US/06-preset-and-migration.md +1 -4
  80. package/docs-release/guides/agent-installation.en-US.md +14 -8
  81. package/docs-release/guides/agent-installation.md +14 -8
  82. package/docs-release/guides/contributing.md +3 -3
  83. package/docs-release/guides/contributing.zh-CN.md +3 -3
  84. package/docs-release/guides/document-audience-and-surfaces.en-US.md +10 -10
  85. package/docs-release/guides/document-audience-and-surfaces.md +10 -10
  86. package/docs-release/guides/legacy-migration-agent-prompt.md +25 -2
  87. package/docs-release/guides/legacy-migration-agent-prompt.zh-CN.md +25 -2
  88. package/docs-release/guides/migration-playbook.en-US.md +63 -1
  89. package/docs-release/guides/migration-playbook.md +59 -1
  90. package/docs-release/guides/parent-control-repository-pattern.en-US.md +25 -25
  91. package/docs-release/guides/parent-control-repository-pattern.md +25 -25
  92. package/docs-release/guides/preset-development.md +2 -2
  93. package/docs-release/guides/repository-operating-models.en-US.md +21 -21
  94. package/docs-release/guides/repository-operating-models.md +21 -21
  95. package/docs-release/guides/task-state-machine.en-US.md +5 -5
  96. package/docs-release/guides/task-state-machine.md +5 -5
  97. package/docs-release/guides/typescript-runtime-migration-closeout.md +96 -0
  98. package/examples/minimal-project/AGENTS.md +2 -2
  99. package/examples/minimal-project/coding-agent-harness/harness.yaml +14 -0
  100. package/examples/minimal-project/coding-agent-harness/planning/tasks/demo-task/progress.md +11 -0
  101. package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/review.md +1 -1
  102. package/package.json +20 -12
  103. package/presets/legacy-migration/preset.yaml +5 -5
  104. package/presets/legacy-migration/templates/execution_strategy.append.md +1 -1
  105. package/presets/lesson-sedimentation/preset.yaml +3 -3
  106. package/presets/module/preset.yaml +2 -2
  107. package/presets/module/templates/execution_strategy.append.md +1 -1
  108. package/presets/module/templates/task_plan.append.md +3 -3
  109. package/presets/standard-task/preset.yaml +2 -2
  110. package/references/adversarial-review-standard.md +2 -2
  111. package/references/agents-md-pattern.md +14 -14
  112. package/references/cadence-ledger.md +1 -1
  113. package/references/ci-cd-standard.md +1 -1
  114. package/references/delivery-operating-model-standard.md +4 -4
  115. package/references/docs-directory-standard.md +65 -159
  116. package/references/external-source-intake-standard.md +10 -10
  117. package/references/harness-ledger.md +5 -5
  118. package/references/legacy-12-phase-bootstrap.md +2 -2
  119. package/references/lessons-governance.md +15 -15
  120. package/references/long-running-task-standard.md +6 -6
  121. package/references/module-parallel-standard.md +34 -34
  122. package/references/planning-loop.md +6 -6
  123. package/references/project-onboarding-audit.md +4 -4
  124. package/references/regression-system.md +2 -2
  125. package/references/repo-governance-standard.md +4 -4
  126. package/references/review-routing-standard.md +1 -1
  127. package/references/ssot-governance.md +19 -19
  128. package/references/taskr-gap-analysis.md +5 -5
  129. package/references/walkthrough-closeout.md +14 -14
  130. package/references/worktree-parallel.md +3 -3
  131. package/skills/preset-creator/references/complex-task-skeleton/task_plan.md +1 -1
  132. package/skills/preset-creator/references/preset-package-skeleton.md +5 -5
  133. package/templates/AGENTS.md.template +26 -26
  134. package/templates/architecture/README.md +4 -4
  135. package/templates/architecture/service-catalog.md +2 -2
  136. package/templates/architecture/services/service-template.md +1 -1
  137. package/templates/dashboard/assets/app-src/20-overview.js +11 -5
  138. package/templates/dashboard/assets/app-src/40-modules.js +1 -1
  139. package/templates/dashboard/assets/app.js +12 -6
  140. package/templates/dashboard/assets/i18n.js +4 -2
  141. package/templates/development/README.md +10 -10
  142. package/templates/development/cross-repo-debugging.md +3 -3
  143. package/templates/development/external-context/service-template.md +2 -2
  144. package/templates/development/external-source-packs/README.md +4 -4
  145. package/templates/integrations/README.md +4 -4
  146. package/templates/integrations/api-contract.md +2 -2
  147. package/templates/integrations/event-contract.md +2 -2
  148. package/templates/integrations/third-party/vendor-template.md +2 -2
  149. package/templates/integrations/webhook-contract.md +2 -2
  150. package/templates/ledger/Harness-Ledger.md +1 -1
  151. package/templates/planning/INDEX.md +1 -0
  152. package/templates/planning/module_session_prompt.md +1 -1
  153. package/templates/planning/task_plan.md +1 -1
  154. package/templates/planning/walkthrough.md +47 -0
  155. package/templates/reference/docs-library-standard.md +8 -8
  156. package/templates/reference/external-source-intake-standard.md +15 -15
  157. package/templates/reference/repo-governance-standard.md +1 -1
  158. package/templates/ssot/Module-Registry.md +1 -1
  159. package/templates/walkthrough/walkthrough-template.md +2 -2
  160. package/templates-zh-CN/AGENTS.md.template +26 -26
  161. package/templates-zh-CN/CLAUDE.md.template +1 -1
  162. package/templates-zh-CN/architecture/README.md +4 -4
  163. package/templates-zh-CN/architecture/service-catalog.md +2 -2
  164. package/templates-zh-CN/architecture/services/service-template.md +1 -1
  165. package/templates-zh-CN/development/README.md +10 -10
  166. package/templates-zh-CN/development/cross-repo-debugging.md +3 -3
  167. package/templates-zh-CN/development/external-context/service-template.md +2 -2
  168. package/templates-zh-CN/development/external-source-packs/README.md +4 -4
  169. package/templates-zh-CN/integrations/README.md +4 -4
  170. package/templates-zh-CN/integrations/api-contract.md +2 -2
  171. package/templates-zh-CN/integrations/event-contract.md +2 -2
  172. package/templates-zh-CN/integrations/third-party/vendor-template.md +2 -2
  173. package/templates-zh-CN/integrations/webhook-contract.md +2 -2
  174. package/templates-zh-CN/ledger/Harness-Ledger.md +1 -1
  175. package/templates-zh-CN/lessons/lesson-arch-process-change.md +1 -1
  176. package/templates-zh-CN/lessons/lesson-new-doc.md +3 -3
  177. package/templates-zh-CN/lessons/lesson-ref-change.md +4 -4
  178. package/templates-zh-CN/planning/module_session_prompt.md +11 -11
  179. package/templates-zh-CN/planning/walkthrough.md +47 -0
  180. package/templates-zh-CN/reference/adversarial-review-standard.md +2 -2
  181. package/templates-zh-CN/reference/delivery-operating-model-standard.md +3 -3
  182. package/templates-zh-CN/reference/docs-library-standard.md +28 -28
  183. package/templates-zh-CN/reference/execution-workflow-standard.md +1 -1
  184. package/templates-zh-CN/reference/external-source-intake-standard.md +16 -16
  185. package/templates-zh-CN/reference/harness-ledger-standard.md +6 -6
  186. package/templates-zh-CN/reference/regression-ssot-governance.md +2 -2
  187. package/templates-zh-CN/reference/repo-governance-standard.md +1 -1
  188. package/templates-zh-CN/reference/review-routing-standard.md +1 -1
  189. package/templates-zh-CN/reference/walkthrough-standard.md +7 -7
  190. package/templates-zh-CN/reference/worktree-standard.md +1 -1
  191. package/templates-zh-CN/regression/Cadence-Ledger.md +2 -2
  192. package/templates-zh-CN/ssot/Delivery-SSoT.md +3 -3
  193. package/templates-zh-CN/ssot/Module-Registry.md +3 -3
  194. package/templates-zh-CN/ssot/Regression-SSoT.md +2 -2
  195. package/templates-zh-CN/walkthrough/walkthrough-template.md +5 -5
  196. package/tsconfig.dist.json +16 -0
  197. package/tsconfig.json +25 -0
  198. package/tsconfig.runtime.json +24 -0
  199. package/examples/minimal-project/.harness-capabilities.json +0 -8
  200. package/examples/minimal-project/docs/09-PLANNING/TASKS/demo-task/progress.md +0 -11
  201. package/scripts/check-harness.mjs +0 -508
  202. package/scripts/commands/dashboard-command.mjs +0 -67
  203. package/scripts/commands/migration-command.mjs +0 -126
  204. package/scripts/commands/preset-command.mjs +0 -73
  205. package/scripts/commands/task-command.mjs +0 -328
  206. package/scripts/harness.mjs +0 -291
  207. package/scripts/lib/capability-registry.mjs +0 -587
  208. package/scripts/lib/check-module-parallel.mjs +0 -230
  209. package/scripts/lib/check-profiles.mjs +0 -372
  210. package/scripts/lib/check-task-contracts.mjs +0 -55
  211. package/scripts/lib/core-shared.mjs +0 -249
  212. package/scripts/lib/dashboard-data.mjs +0 -520
  213. package/scripts/lib/dashboard-workbench.mjs +0 -336
  214. package/scripts/lib/dashboard-writer.mjs +0 -202
  215. package/scripts/lib/git-status-summary.mjs +0 -46
  216. package/scripts/lib/governance-index-generator.mjs +0 -174
  217. package/scripts/lib/governance-sync.mjs +0 -611
  218. package/scripts/lib/governance-table-boundary.mjs +0 -175
  219. package/scripts/lib/lesson-maintenance.mjs +0 -152
  220. package/scripts/lib/markdown-utils.mjs +0 -191
  221. package/scripts/lib/migration-planner.mjs +0 -476
  222. package/scripts/lib/migration-support.mjs +0 -312
  223. package/scripts/lib/phase-kind.mjs +0 -50
  224. package/scripts/lib/preset-audit-contracts.mjs +0 -37
  225. package/scripts/lib/preset-engine.mjs +0 -494
  226. package/scripts/lib/preset-registry.mjs +0 -776
  227. package/scripts/lib/preset-resource-contracts.mjs +0 -83
  228. package/scripts/lib/review-confirm-git-gate.mjs +0 -248
  229. package/scripts/lib/status-builder.mjs +0 -88
  230. package/scripts/lib/subagent-authorization-audit.mjs +0 -196
  231. package/scripts/lib/task-audit-metadata.mjs +0 -385
  232. package/scripts/lib/task-audit-migration.mjs +0 -350
  233. package/scripts/lib/task-completion-consistency.mjs +0 -26
  234. package/scripts/lib/task-index.mjs +0 -93
  235. package/scripts/lib/task-lesson-candidates.mjs +0 -242
  236. package/scripts/lib/task-lesson-sedimentation.mjs +0 -326
  237. package/scripts/lib/task-lifecycle/create-task-helpers.mjs +0 -67
  238. package/scripts/lib/task-lifecycle/phase-sync.mjs +0 -88
  239. package/scripts/lib/task-lifecycle/review-confirm.mjs +0 -112
  240. package/scripts/lib/task-lifecycle/review-gates.mjs +0 -73
  241. package/scripts/lib/task-lifecycle/review-submission.mjs +0 -63
  242. package/scripts/lib/task-lifecycle/scaffold-provenance.mjs +0 -49
  243. package/scripts/lib/task-lifecycle/template-files.mjs +0 -53
  244. package/scripts/lib/task-lifecycle/text-utils.mjs +0 -24
  245. package/scripts/lib/task-lifecycle.mjs +0 -616
  246. package/scripts/lib/task-metadata.mjs +0 -118
  247. package/scripts/lib/task-review-model.mjs +0 -455
  248. package/scripts/lib/task-scanner.mjs +0 -503
  249. package/scripts/lib/task-tombstone-commands.mjs +0 -140
  250. package/scripts/postinstall.mjs +0 -14
  251. package/templates/walkthrough/Closeout-SSoT.md +0 -43
  252. package/templates-zh-CN/walkthrough/Closeout-SSoT.md +0 -42
  253. /package/examples/minimal-project/{docs → coding-agent-harness/governance/generated}/Harness-Ledger.md +0 -0
  254. /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/INDEX.md +0 -0
  255. /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/brief.md +0 -0
  256. /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/execution_strategy.md +0 -0
  257. /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/findings.md +0 -0
  258. /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/lesson_candidates.md +0 -0
  259. /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/task_plan.md +0 -0
  260. /package/examples/minimal-project/{docs/09-PLANNING/TASKS → coding-agent-harness/planning/tasks}/demo-task/visual_map.md +0 -0
@@ -1,520 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { spawnSync } from "node:child_process";
4
- import {
5
- legacyChecker,
6
- repoRoot,
7
- builtinPresetRoot,
8
- normalizeTarget,
9
- projectPresetRoot,
10
- readFileSafe,
11
- sanitizeText,
12
- sanitizeDeep,
13
- slug,
14
- titleFromMarkdown,
15
- prefixedPath,
16
- toPosix,
17
- walkFiles,
18
- visualMapFile,
19
- legacyVisualRoadmapFile,
20
- lessonCandidatesFile,
21
- longRunningTaskContractFile,
22
- userPresetRoot,
23
- } from "./core-shared.mjs";
24
- import {
25
- parseAllMarkdownTables,
26
- getCell,
27
- splitDependencies,
28
- } from "./markdown-utils.mjs";
29
- import { readCapabilityRegistry, validateCapabilities } from "./capability-registry.mjs";
30
- import { buildStatusData } from "./status-builder.mjs";
31
- import {
32
- listTaskPlanPaths,
33
- parseTaskState,
34
- isActiveTaskState,
35
- } from "./task-scanner.mjs";
36
- import { writeDashboardDirectory, writeDashboardFile } from "./dashboard-writer.mjs";
37
- import { listPresetPackageLayers } from "./preset-registry.mjs";
38
- import { validateGovernanceTableBoundaries } from "./governance-table-boundary.mjs";
39
- import { summarizeGitState } from "./git-status-summary.mjs";
40
-
41
- export function collectMarkdownDocuments(target, options = {}) {
42
- const docs = collectDashboardDocumentPaths(target, options);
43
- return docs.map((entry, index) => {
44
- const file = typeof entry === "string" ? entry : entry.file;
45
- const content = sanitizeText(readFileSafe(file));
46
- const source = prefixedPath(target, file);
47
- return {
48
- id: `doc-${String(index + 1).padStart(4, "0")}-${slug(path.basename(file, ".md"))}`,
49
- path: source,
50
- title: titleFromMarkdown(content, path.basename(file)),
51
- type: documentKind(source),
52
- content,
53
- ...(entry.partial ? { partial: true, partialReason: entry.partialReason || "partial", taskId: entry.taskId || "" } : {}),
54
- };
55
- });
56
- }
57
-
58
- function collectDashboardDocumentPaths(target, options = {}) {
59
- const selected = new Set();
60
- const partial = new Map();
61
- const addDocsPath = (relativePath) => {
62
- const file = path.join(target.docsRoot, relativePath);
63
- if (fs.existsSync(file)) selected.add(file);
64
- };
65
- for (const relativePath of [
66
- "Harness-Ledger.md",
67
- "09-PLANNING/Module-Registry.md",
68
- "05-TEST-QA/Regression-SSoT.md",
69
- "05-TEST-QA/Cadence-Ledger.md",
70
- "10-WALKTHROUGH/Closeout-SSoT.md",
71
- ]) {
72
- addDocsPath(relativePath);
73
- }
74
- for (const file of walkFiles(path.join(target.docsRoot, "10-WALKTHROUGH"))) {
75
- if (!file.endsWith(".md")) continue;
76
- if (file.includes(`${path.sep}_archive${path.sep}`)) continue;
77
- if (path.basename(file).startsWith("_")) continue;
78
- selected.add(file);
79
- }
80
- const tasksByPlanPath = new Map((options.tasks || []).map((task) => [
81
- path.join(target.projectRoot, String(task.taskPlanPath || "").replace(/^TARGET:/, "")),
82
- task,
83
- ]));
84
- for (const taskPlanPath of options.taskPlanPaths || listTaskPlanPaths(target)) {
85
- const taskDir = path.dirname(taskPlanPath);
86
- const progress = readFileSafe(path.join(taskDir, "progress.md"));
87
- const state = parseTaskState(progress);
88
- const active = isActiveTaskState(state);
89
- const task = tasksByPlanPath.get(taskPlanPath);
90
- const historicalClosed = !active && task?.closeoutStatus === "closed";
91
- const documentNames = historicalClosed
92
- ? ["brief.md"]
93
- : ["brief.md", "task_plan.md", "execution_strategy.md", visualMapFile, legacyVisualRoadmapFile, lessonCandidatesFile, longRunningTaskContractFile, "progress.md", "review.md", "findings.md"];
94
- for (const fileName of documentNames) {
95
- const file = path.join(taskDir, fileName);
96
- if (fs.existsSync(file)) {
97
- selected.add(file);
98
- if (historicalClosed) {
99
- partial.set(file, {
100
- partial: true,
101
- partialReason: "historical-closed",
102
- taskId: task?.id || path.basename(taskDir),
103
- });
104
- }
105
- }
106
- }
107
- if (!historicalClosed) {
108
- for (const indexFile of ["references/INDEX.md", "artifacts/INDEX.md"]) {
109
- const file = path.join(taskDir, indexFile);
110
- if (fs.existsSync(file)) selected.add(file);
111
- }
112
- }
113
- }
114
- for (const file of walkFiles(path.join(target.docsRoot, "09-PLANNING/MODULES"))) {
115
- if (file.endsWith("module_plan.md")) selected.add(file);
116
- if (/09-PLANNING[\\/]+MODULES[\\/]+[^\\/]+[\\/]brief\.md$/.test(file)) selected.add(file);
117
- }
118
- for (const file of walkFiles(path.join(target.docsRoot, "01-GOVERNANCE/lessons"))) {
119
- if (file.endsWith(".md")) selected.add(file);
120
- }
121
- return [...selected]
122
- .filter((file) => !file.includes(`${path.sep}_archive${path.sep}`))
123
- .filter((file) => !file.includes(`${path.sep}_task-template${path.sep}`))
124
- .filter((file) => !file.includes(`${path.sep}_optional-structures${path.sep}`))
125
- .sort()
126
- .map((file) => ({ file, ...(partial.get(file) || {}) }));
127
- }
128
-
129
- function documentKind(source) {
130
- const lower = source.toLowerCase();
131
- if (lower.includes("harness-ledger.md")) return "harness-ledger";
132
- if (lower.includes("module-registry.md")) return "module-registry";
133
- if (lower.includes("regression-ssot.md")) return "regression-ssot";
134
- if (lower.includes("cadence-ledger.md")) return "cadence-ledger";
135
- if (/\/01-governance\/lessons\/[^/]+\.md$/i.test(lower)) return "lesson-detail";
136
- if (lower.endsWith("/progress.md")) return "task-progress";
137
- if (lower.endsWith("/brief.md")) return "task-brief";
138
- if (lower.endsWith("/review.md")) return "task-review";
139
- if (lower.endsWith("/lesson_candidates.md")) return "lesson-candidates";
140
- if (lower.endsWith("/long-running-task-contract.md")) return "long-running-contract";
141
- if (lower.endsWith("/references/index.md")) return "task-references";
142
- if (lower.endsWith("/artifacts/index.md")) return "task-artifacts";
143
- if (lower.endsWith("/execution_strategy.md")) return "execution-strategy";
144
- if (lower.endsWith("/visual_map.md")) return "visual-map";
145
- if (lower.endsWith("/visual_roadmap.md")) return "legacy-visual-roadmap";
146
- if (lower.endsWith("/module_plan.md")) return "module-plan";
147
- return "markdown-table";
148
- }
149
-
150
- export function collectTables(documents) {
151
- return {
152
- tables: documents.flatMap((document) => parseAllMarkdownTables(document.content, document.path, documentKind(document.path))),
153
- };
154
- }
155
-
156
- export function collectGraph(status, tables = { tables: [] }) {
157
- const nodes = [];
158
- const edges = [];
159
- const seenNodes = new Map();
160
- const addNode = (node) => {
161
- const existing = seenNodes.get(node.id);
162
- if (existing) {
163
- Object.assign(existing, node);
164
- return;
165
- }
166
- seenNodes.set(node.id, node);
167
- nodes.push(node);
168
- };
169
- const addEdge = (edge) => {
170
- if (!edge.from || !edge.to || edge.from === edge.to) return;
171
- edges.push(edge);
172
- };
173
- for (const task of status.tasks) {
174
- addNode({ id: `task:${task.id}`, type: "task", label: task.title, state: task.state, completion: task.completion });
175
- for (const phase of task.phases || []) {
176
- const phaseId = `phase:${task.id}:${phase.id}`;
177
- addNode({
178
- id: phaseId,
179
- type: "phase",
180
- label: phase.id,
181
- state: phase.state,
182
- completion: phase.completion,
183
- kind: phase.kind,
184
- actor: phase.actor,
185
- exitCommand: phase.exitCommand,
186
- taskId: task.id,
187
- });
188
- addEdge({ from: `task:${task.id}`, to: phaseId, type: "contains" });
189
- for (const dependency of phase.dependsOn || []) {
190
- addEdge({ from: `phase:${task.id}:${dependency}`, to: phaseId, type: "depends_on" });
191
- }
192
- }
193
- for (const handoff of task.handoffs || []) {
194
- const handoffId = `handoff:${handoff.id}`;
195
- addNode({ id: handoffId, type: "handoff", label: handoff.summary, state: handoff.state });
196
- addEdge({ from: `task:${task.id}`, to: handoffId, type: "handoff" });
197
- }
198
- }
199
- for (const table of tables.tables || []) {
200
- if (table.kind === "module-registry") {
201
- for (const row of table.rows) {
202
- const key = getCell(row.cells, ["Key", "Module", "模块 Key", "模块"]) || "";
203
- if (!key) continue;
204
- const moduleId = `module:${key}`;
205
- const status = getCell(row.cells, ["Status", "状态"], "unknown");
206
- const currentStep = getCell(row.cells, ["Current Step", "当前步骤"], "");
207
- addNode({ id: moduleId, type: "module", label: getCell(row.cells, ["Name", "Module", "模块名称", "模块"], key), state: status, currentStep });
208
- if (currentStep) {
209
- const stepId = `step:${currentStep}`;
210
- if (!seenNodes.has(stepId)) addNode({ id: stepId, type: "step", label: currentStep, state: status, module: key });
211
- addEdge({ from: moduleId, to: stepId, type: "current_step" });
212
- }
213
- }
214
- }
215
- if (table.kind === "module-plan") {
216
- const moduleMatch = table.source.match(/MODULES\/([^/]+)\/module_plan\.md$/);
217
- const moduleKey = moduleMatch ? moduleMatch[1] : slug(table.source);
218
- const moduleId = `module:${moduleKey}`;
219
- addNode({ id: moduleId, type: "module", label: moduleKey, state: "planned" });
220
- for (const row of table.rows) {
221
- const step = getCell(row.cells, ["Step ID", "步骤 ID"]);
222
- if (!step) continue;
223
- const stepId = `step:${step}`;
224
- addNode({ id: stepId, type: "step", label: `${step} ${getCell(row.cells, ["Name", "名称"]) || ""}`.trim(), state: getCell(row.cells, ["Status", "状态"], "unknown"), module: moduleKey });
225
- addEdge({ from: moduleId, to: stepId, type: "contains" });
226
- for (const dependency of splitDependencies(getCell(row.cells, ["Depends On", "依赖"]) || "")) {
227
- addEdge({ from: `step:${dependency}`, to: stepId, type: "depends_on" });
228
- }
229
- }
230
- }
231
- }
232
- for (const edge of edges) {
233
- if (edge.type === "depends_on" && !seenNodes.has(edge.from)) {
234
- addNode({ id: edge.from, type: "external-dependency", label: edge.from.replace(/^(phase:[^:]+:|step:)/, ""), state: "external" });
235
- }
236
- }
237
- return { nodes, edges: edges.filter((edge) => seenNodes.has(edge.from) && seenNodes.has(edge.to)) };
238
- }
239
-
240
- export function categorizeWarning(message) {
241
- if (/governance-table-entropy/i.test(message)) return "Governance Table Boundary";
242
- if (/missing execution_strategy\.md|missing visual_(?:map|roadmap)\.md|Visual (?:Map|Roadmap)/i.test(message)) return "Plan Contract Missing";
243
- if (/legacy-compat|adoption-needed|legacy check/i.test(message)) return "Adoption Advice";
244
- if (/Evidence|evidence/i.test(message)) return "Missing Evidence";
245
- if (/schema|missing .*columns|invalid/i.test(message)) return "Schema Drift";
246
- return "Review Finding";
247
- }
248
-
249
- function warningType(message) {
250
- if (/missing brief\.md|briefSource|brief/i.test(message) && /missing|缺少/i.test(message)) return "missing-brief";
251
- if (/missing execution_strategy\.md/i.test(message)) return "missing-execution-strategy";
252
- if (/missing visual_map\.md|Visual Map/i.test(message)) return "missing-visual-map";
253
- if (/missing visual_roadmap\.md|Visual Roadmap/i.test(message)) return "missing-visual-roadmap";
254
- if (/Reviewer Identity|Confidence Challenge|Final Confidence Basis|Evidence Checked/i.test(message)) return "review-schema-gap";
255
- if (/governance-table-entropy/i.test(message)) return "governance-table-entropy";
256
- if (/Evidence|evidence/i.test(message)) return "missing-evidence";
257
- if (/missing required file/i.test(message)) return "legacy-reference-gap";
258
- if (/legacy-compat|legacy check|adoption-needed/i.test(message)) return "capability-adoption";
259
- if (/schema|missing .*columns|invalid/i.test(message)) return "schema-drift";
260
- return "review-finding";
261
- }
262
-
263
- function warningScope(message) {
264
- if (/docs\/09-PLANNING\/TASKS\//i.test(message)) return "task";
265
- if (/docs\/09-PLANNING\/MODULES\//i.test(message)) return "module";
266
- if (/review\.md|findings table/i.test(message)) return "review";
267
- if (/docs\/11-REFERENCE\//i.test(message)) return "reference";
268
- if (/\.harness-capabilities\.json|capability|legacy-compat/i.test(message)) return "capability";
269
- return "project";
270
- }
271
-
272
- function warningPhase(type, scope) {
273
- if (type === "capability-adoption") return "baseline";
274
- if (type === "governance-table-entropy") return "global-table-boundary";
275
- if (type === "missing-brief" || type === "missing-execution-strategy" || type === "missing-visual-map" || type === "missing-visual-roadmap") return "active-task-contracts";
276
- if (scope === "module") return "module-classification";
277
- if (type === "review-schema-gap" || type === "missing-evidence") return "review-evidence";
278
- if (type === "legacy-reference-gap" || type === "schema-drift") return "strict-cutover";
279
- return "triage";
280
- }
281
-
282
- function warningFixability(type, scope) {
283
- if (["missing-brief", "missing-execution-strategy", "missing-visual-map", "missing-visual-roadmap"].includes(type)) return "guided";
284
- if (type === "governance-table-entropy") return "manual";
285
- if (type === "legacy-reference-gap" || scope === "reference") return "template";
286
- if (type === "capability-adoption") return "decision";
287
- if (type === "review-schema-gap" || type === "missing-evidence") return "human-evidence";
288
- return "manual";
289
- }
290
-
291
- function warningPriority(type, scope, message) {
292
- if (/fail|invalid|blocked/i.test(message) || type === "schema-drift") return "P1";
293
- if (type === "governance-table-entropy") return /legacy-report-only/i.test(message) ? "P3" : "P2";
294
- if (["missing-brief", "missing-execution-strategy", "missing-visual-map", "missing-visual-roadmap"].includes(type) && scope === "task") return "P2";
295
- if (type === "review-schema-gap" || type === "missing-evidence") return "P2";
296
- if (type === "capability-adoption") return "P3";
297
- return "P3";
298
- }
299
-
300
- function warningConfidence(message) {
301
- if (/legacy|unknown|fallback/i.test(message)) return "medium";
302
- return "high";
303
- }
304
-
305
- function warningAffectedPaths(message) {
306
- const matches = String(message).match(/(?:docs|\.harness-private)\/[^\s:]+|\.harness-capabilities\.json|AGENTS\.md|CLAUDE\.md/g) || [];
307
- return [...new Set(matches.map((item) => item.replace(/[),.;]+$/, "")))];
308
- }
309
-
310
- function summarizeWarnings(warnings) {
311
- const countBy = (field) =>
312
- warnings.reduce((acc, warning) => {
313
- const key = warning[field] || "unknown";
314
- acc[key] = (acc[key] || 0) + 1;
315
- return acc;
316
- }, {});
317
- return {
318
- total: warnings.length,
319
- byCategory: countBy("category"),
320
- byType: countBy("type"),
321
- byPriority: countBy("priority"),
322
- byPhase: countBy("phase"),
323
- byFixability: countBy("fixability"),
324
- activeTaskWarnings: warnings.filter((warning) => warning.scope === "task" && warning.phase === "active-task-contracts").length,
325
- strictCutoverWarnings: warnings.filter((warning) => warning.phase === "strict-cutover").length,
326
- };
327
- }
328
-
329
- export function collectAdoption(status) {
330
- const dashboardMessages = [
331
- ...(status.checkState.details.warnings || []),
332
- ...(status.checkState.details.failures || []).filter((message) => /governance-table-entropy/i.test(message)),
333
- ];
334
- const warnings = dashboardMessages.flatMap((message) => splitWarningMessage(message)).map((message, index) => {
335
- const type = warningType(message);
336
- const scope = warningScope(message);
337
- const affectedPaths = warningAffectedPaths(message);
338
- const stableSuffix = type === "governance-table-entropy" ? `-${stableWarningIdPart(governanceWarningRowKey(message))}` : "";
339
- return {
340
- id: `AD-${String(index + 1).padStart(3, "0")}${stableSuffix}`,
341
- category: categorizeWarning(message),
342
- type,
343
- scope,
344
- priority: warningPriority(type, scope, message),
345
- phase: warningPhase(type, scope),
346
- fixability: warningFixability(type, scope),
347
- status: /legacy-report-only/i.test(message) ? "legacy-report-only" : "open",
348
- confidence: warningConfidence(message),
349
- severity: status.mode === "legacy-compat" ? "advice" : "warning",
350
- title: warningTitle(message),
351
- affected: affectedPaths[0] || warningAffected(message),
352
- affectedPaths,
353
- requiredAction: warningAction(message),
354
- detail: sanitizeText(message),
355
- };
356
- });
357
- return {
358
- mode: status.mode,
359
- project: status.project,
360
- summary: {
361
- blockers: status.checkState.failures,
362
- advice: warnings.length,
363
- ...summarizeWarnings(warnings),
364
- },
365
- warnings,
366
- manualSteps: {
367
- zh: [
368
- "先查看升级建议,决定当前项目要采用哪些 v1.0 能力合同。",
369
- "为仍在活跃的任务手工补齐 execution_strategy.md 和 visual_map.md。",
370
- "只有在项目明确声明 v1.0 capability 后,再把 strict check 当成阻塞门禁。",
371
- ],
372
- en: [
373
- "Review adoption advice and decide which v1.0 capability contracts should be adopted.",
374
- "Manually add execution_strategy.md and visual_map.md for active tasks.",
375
- "Treat strict check as blocking only after the project intentionally declares v1.0 capabilities.",
376
- ],
377
- },
378
- };
379
- }
380
-
381
- function governanceWarningRowKey(message) {
382
- const match = String(message || "").match(/\brow\s+([^:]+)/i);
383
- return match ? match[1].trim() : "global-table";
384
- }
385
-
386
- function stableWarningIdPart(value) {
387
- return String(value || "global-table")
388
- .replace(/[^A-Za-z0-9_-]+/g, "-")
389
- .replace(/^-+|-+$/g, "")
390
- .slice(0, 80) || "global-table";
391
- }
392
-
393
- export function splitWarningMessage(message) {
394
- return String(message || "")
395
- .split(/\n-\s+/)
396
- .map((item, index) => (index === 0 ? item : `- ${item}`))
397
- .filter(Boolean);
398
- }
399
-
400
- function warningTitle(message) {
401
- if (/governance-table-entropy/i.test(message)) return "Global table boundary";
402
- if (/missing execution_strategy\.md/i.test(message)) return "Missing execution strategy";
403
- if (/missing visual_map\.md|Visual Map/i.test(message)) return "Missing visual map";
404
- if (/missing visual_roadmap\.md|Visual Roadmap/i.test(message)) return "Missing legacy visual roadmap";
405
- if (/legacy-compat/i.test(message)) return "Legacy compatibility mode";
406
- if (/legacy check failed/i.test(message)) return "Legacy checker finding";
407
- if (/review\.md missing/i.test(message)) return "Review schema gap";
408
- if (/findings table missing/i.test(message)) return "Review findings schema gap";
409
- return String(message).split(":")[0].slice(0, 96);
410
- }
411
-
412
- function warningAffected(message) {
413
- const target = String(message).match(/(?:docs|\.harness-private)\/[^\s:]+/);
414
- return target ? target[0] : "project";
415
- }
416
-
417
- function warningAction(message) {
418
- if (/governance-table-entropy/i.test(message)) return "Move local detail to module/task docs; keep the global row to summary, state, route, and audit result.";
419
- if (/execution_strategy\.md/i.test(message)) return "Add standalone execution strategy file.";
420
- if (/visual_map\.md|Visual Map/i.test(message)) return "Add standalone visual map file.";
421
- if (/visual_roadmap\.md|Visual Roadmap/i.test(message)) return "Rewrite legacy visual_roadmap.md into canonical visual_map.md.";
422
- if (/review\.md missing/i.test(message)) return "Update review.md to v1 review schema.";
423
- if (/legacy/i.test(message)) return "Review manually; do not auto-migrate.";
424
- return "Inspect source document and decide whether to adopt v1 contract.";
425
- }
426
-
427
- export function buildDashboardBundle(targetInput, options = {}) {
428
- const target = normalizeTarget(targetInput);
429
- const taskPlanPaths = listTaskPlanPaths(target);
430
- const capabilityState = validateCapabilities(target);
431
- const gitState = summarizeGitState(target);
432
- const declaredCapabilities = new Set(capabilityState.registry.capabilities.map((capability) => capability.name));
433
- const shouldRunLegacy = !options.skipLegacyCheck && (capabilityState.registry.mode === "legacy-compat" || declaredCapabilities.has("safe-adoption"));
434
- const legacy = shouldRunLegacy ? runDashboardLegacyCheck(target) : { status: "skipped", code: 0, stdout: "", stderr: "" };
435
- const legacyWarnings = legacy.status === "fail" ? [`adoption-needed: legacy check failed: ${(legacy.stderr || legacy.stdout).trim()}`] : [];
436
- const governanceBoundaries = validateGovernanceTableBoundaries(target);
437
- const status = buildStatusData(target, {
438
- ...options,
439
- capabilityState,
440
- gitState,
441
- taskPlanPaths,
442
- legacy,
443
- failures: [...capabilityState.failures, ...governanceBoundaries.failures],
444
- warnings: [...capabilityState.warnings, ...legacyWarnings, ...governanceBoundaries.warnings, ...gitState.warnings],
445
- });
446
- const documents = { documents: collectMarkdownDocuments(target, { taskPlanPaths, tasks: status.tasks }) };
447
- const tables = collectTables(documents.documents);
448
- const graph = collectGraph(status, tables);
449
- const adoption = collectAdoption(status);
450
- const presetCatalog = collectPresetCatalog(targetInput, target, options);
451
- return sanitizeDeep({ status, tables, documents, graph, adoption, presetCatalog });
452
- }
453
-
454
- function runDashboardLegacyCheck(target) {
455
- const checkTarget = target.docsOnly ? target.projectRoot : target.input;
456
- const result = spawnSync(process.execPath, [legacyChecker, checkTarget], {
457
- cwd: repoRoot,
458
- encoding: "utf8",
459
- });
460
- return {
461
- status: result.status === 0 ? "pass" : "fail",
462
- code: result.status ?? 1,
463
- stdout: result.stdout || "",
464
- stderr: result.stderr || "",
465
- };
466
- }
467
-
468
- export function collectPresetCatalog(targetInput, target = normalizeTarget(targetInput), options = {}) {
469
- const home = options.home || "";
470
- const presets = listPresetPackageLayers({ targetInput: target.projectRoot, home }).map((preset) => ({
471
- key: `${preset.source}:${preset.id}`,
472
- id: preset.id,
473
- version: preset.version,
474
- source: preset.source,
475
- effective: preset.effective === true,
476
- purpose: preset.purpose,
477
- compatibleBudgets: preset.compatibleBudgets,
478
- manifestPath: preset.manifestRelativePath,
479
- manifestSha256: preset.manifestSha256,
480
- taskKind: preset.task?.kind || "",
481
- inputCount: Object.keys(preset.inputs || {}).length,
482
- referenceCount: Object.keys(preset.resources?.references || {}).length,
483
- artifactCount: Object.keys(preset.resources?.artifacts || {}).length,
484
- writeScopeCount: Object.keys(preset.writeScopes || {}).length,
485
- evidenceFileCount: Object.keys(preset.evidence?.files || {}).length,
486
- requiredReadCount: Array.isArray(preset.context?.requiredReads) ? preset.context.requiredReads.length : 0,
487
- checkStatus: "unknown",
488
- }));
489
- const countSource = (source) => presets.filter((preset) => preset.source === source).length;
490
- return {
491
- summary: {
492
- total: presets.length,
493
- project: countSource("project"),
494
- user: countSource("user"),
495
- builtin: countSource("builtin"),
496
- },
497
- roots: [
498
- { source: "project", path: projectPresetRoot(target.projectRoot) },
499
- { source: "user", path: home ? path.join(path.resolve(home), ".coding-agent-harness/presets") : userPresetRoot },
500
- { source: "builtin", path: builtinPresetRoot },
501
- ],
502
- presets,
503
- };
504
- }
505
-
506
- export function writeDashboardFolder(outDir, targetInput, options = {}) {
507
- const target = normalizeTarget(targetInput);
508
- const registry = readCapabilityRegistry(target);
509
- const locale = options.localeOverride || registry.locale;
510
- const bundle = buildDashboardBundle(targetInput, options);
511
- return writeDashboardDirectory(outDir, bundle, { repoRoot, projectRoot: target.projectRoot, docsRoot: target.docsRoot, locale, workbenchRuntime: options.workbenchRuntime === true, recoverGeneratedDashboard: options.recoverGeneratedDashboard === true });
512
- }
513
-
514
- export function writeDashboardSingleFile(outFile, targetInput, options = {}) {
515
- const target = normalizeTarget(targetInput);
516
- const registry = readCapabilityRegistry(target);
517
- const locale = options.localeOverride || registry.locale;
518
- const bundle = buildDashboardBundle(targetInput, options);
519
- return writeDashboardFile(outFile, bundle, { repoRoot, projectRoot: target.projectRoot, docsRoot: target.docsRoot, locale });
520
- }