@dommaker/harness 1.3.0 → 1.5.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 (532) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +0 -2
  3. package/bin/harness.js +86 -32
  4. package/dist/cli/command-contract.d.ts +83 -0
  5. package/dist/cli/command-contract.d.ts.map +1 -0
  6. package/dist/cli/command-contract.js +66 -0
  7. package/dist/cli/command-contract.js.map +1 -0
  8. package/dist/cli/commands/acceptance.d.ts +3 -2
  9. package/dist/cli/commands/acceptance.d.ts.map +1 -1
  10. package/dist/cli/commands/acceptance.js +28 -24
  11. package/dist/cli/commands/acceptance.js.map +1 -1
  12. package/dist/cli/commands/analyze-sessions.d.ts +2 -1
  13. package/dist/cli/commands/analyze-sessions.d.ts.map +1 -1
  14. package/dist/cli/commands/analyze-sessions.js +25 -24
  15. package/dist/cli/commands/analyze-sessions.js.map +1 -1
  16. package/dist/cli/commands/check.d.ts +14 -2
  17. package/dist/cli/commands/check.d.ts.map +1 -1
  18. package/dist/cli/commands/check.js +104 -61
  19. package/dist/cli/commands/check.js.map +1 -1
  20. package/dist/cli/commands/command.d.ts +5 -1
  21. package/dist/cli/commands/command.d.ts.map +1 -1
  22. package/dist/cli/commands/command.js +26 -17
  23. package/dist/cli/commands/command.js.map +1 -1
  24. package/dist/cli/commands/constraints-report.d.ts +2 -1
  25. package/dist/cli/commands/constraints-report.d.ts.map +1 -1
  26. package/dist/cli/commands/constraints-report.js +37 -33
  27. package/dist/cli/commands/constraints-report.js.map +1 -1
  28. package/dist/cli/commands/constraints-retire.d.ts +6 -5
  29. package/dist/cli/commands/constraints-retire.d.ts.map +1 -1
  30. package/dist/cli/commands/constraints-retire.js +50 -52
  31. package/dist/cli/commands/constraints-retire.js.map +1 -1
  32. package/dist/cli/commands/constraints.d.ts +2 -1
  33. package/dist/cli/commands/constraints.d.ts.map +1 -1
  34. package/dist/cli/commands/constraints.js +10 -27
  35. package/dist/cli/commands/constraints.js.map +1 -1
  36. package/dist/cli/commands/contract.d.ts +3 -2
  37. package/dist/cli/commands/contract.d.ts.map +1 -1
  38. package/dist/cli/commands/contract.js +45 -42
  39. package/dist/cli/commands/contract.js.map +1 -1
  40. package/dist/cli/commands/definitions.d.ts +11 -11
  41. package/dist/cli/commands/definitions.d.ts.map +1 -1
  42. package/dist/cli/commands/definitions.js +27 -219
  43. package/dist/cli/commands/definitions.js.map +1 -1
  44. package/dist/cli/commands/failure.d.ts +5 -4
  45. package/dist/cli/commands/failure.d.ts.map +1 -1
  46. package/dist/cli/commands/failure.js +31 -25
  47. package/dist/cli/commands/failure.js.map +1 -1
  48. package/dist/cli/commands/init.d.ts +7 -5
  49. package/dist/cli/commands/init.d.ts.map +1 -1
  50. package/dist/cli/commands/init.js +147 -211
  51. package/dist/cli/commands/init.js.map +1 -1
  52. package/dist/cli/commands/knowledge.d.ts +17 -30
  53. package/dist/cli/commands/knowledge.d.ts.map +1 -1
  54. package/dist/cli/commands/knowledge.js +183 -273
  55. package/dist/cli/commands/knowledge.js.map +1 -1
  56. package/dist/cli/commands/passes-gate.d.ts +8 -2
  57. package/dist/cli/commands/passes-gate.d.ts.map +1 -1
  58. package/dist/cli/commands/passes-gate.js +44 -66
  59. package/dist/cli/commands/passes-gate.js.map +1 -1
  60. package/dist/cli/commands/performance.d.ts +2 -1
  61. package/dist/cli/commands/performance.d.ts.map +1 -1
  62. package/dist/cli/commands/performance.js +20 -18
  63. package/dist/cli/commands/performance.js.map +1 -1
  64. package/dist/cli/commands/posteval-plan.d.ts +5 -1
  65. package/dist/cli/commands/posteval-plan.d.ts.map +1 -1
  66. package/dist/cli/commands/posteval-plan.js +26 -15
  67. package/dist/cli/commands/posteval-plan.js.map +1 -1
  68. package/dist/cli/commands/release.d.ts +6 -1
  69. package/dist/cli/commands/release.d.ts.map +1 -1
  70. package/dist/cli/commands/release.js +69 -59
  71. package/dist/cli/commands/release.js.map +1 -1
  72. package/dist/cli/commands/report.d.ts +2 -1
  73. package/dist/cli/commands/report.d.ts.map +1 -1
  74. package/dist/cli/commands/report.js +9 -5
  75. package/dist/cli/commands/report.js.map +1 -1
  76. package/dist/cli/commands/review.d.ts +3 -2
  77. package/dist/cli/commands/review.d.ts.map +1 -1
  78. package/dist/cli/commands/review.js +33 -29
  79. package/dist/cli/commands/review.js.map +1 -1
  80. package/dist/cli/commands/sdd.d.ts +2 -1
  81. package/dist/cli/commands/sdd.d.ts.map +1 -1
  82. package/dist/cli/commands/sdd.js +7 -5
  83. package/dist/cli/commands/sdd.js.map +1 -1
  84. package/dist/cli/commands/security.d.ts +3 -2
  85. package/dist/cli/commands/security.d.ts.map +1 -1
  86. package/dist/cli/commands/security.js +29 -26
  87. package/dist/cli/commands/security.js.map +1 -1
  88. package/dist/cli/commands/spec-baseline-check.d.ts +2 -1
  89. package/dist/cli/commands/spec-baseline-check.d.ts.map +1 -1
  90. package/dist/cli/commands/spec-baseline-check.js +15 -11
  91. package/dist/cli/commands/spec-baseline-check.js.map +1 -1
  92. package/dist/cli/commands/spec.d.ts +7 -2
  93. package/dist/cli/commands/spec.d.ts.map +1 -1
  94. package/dist/cli/commands/spec.js +61 -51
  95. package/dist/cli/commands/spec.js.map +1 -1
  96. package/dist/cli/commands/status.d.ts +2 -1
  97. package/dist/cli/commands/status.d.ts.map +1 -1
  98. package/dist/cli/commands/status.js +57 -53
  99. package/dist/cli/commands/status.js.map +1 -1
  100. package/dist/cli/commands/sync-docs/agents-syncer.d.ts.map +1 -1
  101. package/dist/cli/commands/sync-docs/agents-syncer.js +5 -2
  102. package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
  103. package/dist/cli/commands/sync-docs/context-syncer.d.ts.map +1 -1
  104. package/dist/cli/commands/sync-docs/context-syncer.js +3 -2
  105. package/dist/cli/commands/sync-docs/context-syncer.js.map +1 -1
  106. package/dist/cli/commands/sync-docs/index.d.ts +2 -1
  107. package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
  108. package/dist/cli/commands/sync-docs/index.js +68 -88
  109. package/dist/cli/commands/sync-docs/index.js.map +1 -1
  110. package/dist/cli/commands/sync-docs/project-reader.d.ts +6 -1
  111. package/dist/cli/commands/sync-docs/project-reader.d.ts.map +1 -1
  112. package/dist/cli/commands/sync-docs/project-reader.js +14 -16
  113. package/dist/cli/commands/sync-docs/project-reader.js.map +1 -1
  114. package/dist/cli/commands/update-user-model.d.ts +9 -3
  115. package/dist/cli/commands/update-user-model.d.ts.map +1 -1
  116. package/dist/cli/commands/update-user-model.js +56 -61
  117. package/dist/cli/commands/update-user-model.js.map +1 -1
  118. package/dist/cli/commands/validate.d.ts +4 -3
  119. package/dist/cli/commands/validate.d.ts.map +1 -1
  120. package/dist/cli/commands/validate.js +28 -26
  121. package/dist/cli/commands/validate.js.map +1 -1
  122. package/dist/cli/session-mining/transcript.d.ts +7 -1
  123. package/dist/cli/session-mining/transcript.d.ts.map +1 -1
  124. package/dist/cli/session-mining/transcript.js +21 -14
  125. package/dist/cli/session-mining/transcript.js.map +1 -1
  126. package/dist/context/session-manager.d.ts.map +1 -1
  127. package/dist/context/session-manager.js +19 -32
  128. package/dist/context/session-manager.js.map +1 -1
  129. package/dist/core/constraints/agent-prompt-renderer.d.ts.map +1 -1
  130. package/dist/core/constraints/agent-prompt-renderer.js +1 -4
  131. package/dist/core/constraints/agent-prompt-renderer.js.map +1 -1
  132. package/dist/core/constraints/capabilities-parser.d.ts +24 -7
  133. package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
  134. package/dist/core/constraints/capabilities-parser.js +32 -28
  135. package/dist/core/constraints/capabilities-parser.js.map +1 -1
  136. package/dist/core/constraints/capabilities-reconcile.d.ts +67 -0
  137. package/dist/core/constraints/capabilities-reconcile.d.ts.map +1 -0
  138. package/dist/core/constraints/capabilities-reconcile.js +105 -0
  139. package/dist/core/constraints/capabilities-reconcile.js.map +1 -0
  140. package/dist/core/constraints/checker.d.ts +21 -43
  141. package/dist/core/constraints/checker.d.ts.map +1 -1
  142. package/dist/core/constraints/checker.js +68 -117
  143. package/dist/core/constraints/checker.js.map +1 -1
  144. package/dist/core/constraints/checkers/capability-sync.d.ts +20 -8
  145. package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
  146. package/dist/core/constraints/checkers/capability-sync.js +66 -77
  147. package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
  148. package/dist/core/constraints/checkers/context-doc-sync.d.ts +4 -2
  149. package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -1
  150. package/dist/core/constraints/checkers/context-doc-sync.js +13 -22
  151. package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
  152. package/dist/core/constraints/checkers/docs-freshness.d.ts.map +1 -1
  153. package/dist/core/constraints/checkers/docs-freshness.js +49 -66
  154. package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
  155. package/dist/core/constraints/checkers/governance-presence.d.ts +2 -2
  156. package/dist/core/constraints/checkers/governance-presence.d.ts.map +1 -1
  157. package/dist/core/constraints/checkers/governance-presence.js +7 -28
  158. package/dist/core/constraints/checkers/governance-presence.js.map +1 -1
  159. package/dist/core/constraints/checkers/index.d.ts +2 -2
  160. package/dist/core/constraints/checkers/index.d.ts.map +1 -1
  161. package/dist/core/constraints/checkers/index.js +2 -1
  162. package/dist/core/constraints/checkers/index.js.map +1 -1
  163. package/dist/core/constraints/checkers/no-test-simplification.d.ts.map +1 -1
  164. package/dist/core/constraints/checkers/no-test-simplification.js +4 -3
  165. package/dist/core/constraints/checkers/no-test-simplification.js.map +1 -1
  166. package/dist/core/constraints/checkers/types.d.ts +43 -4
  167. package/dist/core/constraints/checkers/types.d.ts.map +1 -1
  168. package/dist/core/constraints/checkers/types.js +33 -0
  169. package/dist/core/constraints/checkers/types.js.map +1 -1
  170. package/dist/core/constraints/context-builder.d.ts +15 -14
  171. package/dist/core/constraints/context-builder.d.ts.map +1 -1
  172. package/dist/core/constraints/context-builder.js +32 -96
  173. package/dist/core/constraints/context-builder.js.map +1 -1
  174. package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
  175. package/dist/core/constraints/doc-freshness/runner.js +2 -1
  176. package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
  177. package/dist/core/constraints/git-evidence.d.ts +60 -0
  178. package/dist/core/constraints/git-evidence.d.ts.map +1 -0
  179. package/dist/core/constraints/git-evidence.js +88 -0
  180. package/dist/core/constraints/git-evidence.js.map +1 -0
  181. package/dist/core/constraints/injection-drift.d.ts +3 -20
  182. package/dist/core/constraints/injection-drift.d.ts.map +1 -1
  183. package/dist/core/constraints/injection-drift.js +10 -57
  184. package/dist/core/constraints/injection-drift.js.map +1 -1
  185. package/dist/core/constraints/injection-writer.d.ts +113 -0
  186. package/dist/core/constraints/injection-writer.d.ts.map +1 -0
  187. package/dist/core/constraints/injection-writer.js +228 -0
  188. package/dist/core/constraints/injection-writer.js.map +1 -0
  189. package/dist/core/constraints/usage-report.d.ts +22 -1
  190. package/dist/core/constraints/usage-report.d.ts.map +1 -1
  191. package/dist/core/constraints/usage-report.js +27 -20
  192. package/dist/core/constraints/usage-report.js.map +1 -1
  193. package/dist/core/index.d.ts +2 -2
  194. package/dist/core/index.d.ts.map +1 -1
  195. package/dist/core/index.js +4 -2
  196. package/dist/core/index.js.map +1 -1
  197. package/dist/core/project-config-loader.d.ts +32 -1
  198. package/dist/core/project-config-loader.d.ts.map +1 -1
  199. package/dist/core/project-config-loader.js +39 -9
  200. package/dist/core/project-config-loader.js.map +1 -1
  201. package/dist/core/validators/passes-gate.d.ts +15 -64
  202. package/dist/core/validators/passes-gate.d.ts.map +1 -1
  203. package/dist/core/validators/passes-gate.js +84 -222
  204. package/dist/core/validators/passes-gate.js.map +1 -1
  205. package/dist/core/validators/test-output.d.ts +58 -0
  206. package/dist/core/validators/test-output.d.ts.map +1 -0
  207. package/dist/core/validators/test-output.js +109 -0
  208. package/dist/core/validators/test-output.js.map +1 -0
  209. package/dist/failure/recorder.d.ts +6 -0
  210. package/dist/failure/recorder.d.ts.map +1 -1
  211. package/dist/failure/recorder.js +12 -8
  212. package/dist/failure/recorder.js.map +1 -1
  213. package/dist/gates/acceptance.d.ts +1 -48
  214. package/dist/gates/acceptance.d.ts.map +1 -1
  215. package/dist/gates/acceptance.js +6 -38
  216. package/dist/gates/acceptance.js.map +1 -1
  217. package/dist/gates/checker-gate.d.ts +2 -1
  218. package/dist/gates/checker-gate.d.ts.map +1 -1
  219. package/dist/gates/checker-gate.js +11 -13
  220. package/dist/gates/checker-gate.js.map +1 -1
  221. package/dist/gates/command.d.ts.map +1 -1
  222. package/dist/gates/command.js +10 -22
  223. package/dist/gates/command.js.map +1 -1
  224. package/dist/gates/contract.d.ts.map +1 -1
  225. package/dist/gates/contract.js +22 -61
  226. package/dist/gates/contract.js.map +1 -1
  227. package/dist/gates/performance.d.ts.map +1 -1
  228. package/dist/gates/performance.js +13 -31
  229. package/dist/gates/performance.js.map +1 -1
  230. package/dist/gates/review.d.ts.map +1 -1
  231. package/dist/gates/review.js +21 -53
  232. package/dist/gates/review.js.map +1 -1
  233. package/dist/gates/security.d.ts.map +1 -1
  234. package/dist/gates/security.js +14 -32
  235. package/dist/gates/security.js.map +1 -1
  236. package/dist/gates/types.d.ts +28 -5
  237. package/dist/gates/types.d.ts.map +1 -1
  238. package/dist/gates/types.js +38 -1
  239. package/dist/gates/types.js.map +1 -1
  240. package/dist/hooks/bootstrap.d.ts +2 -0
  241. package/dist/hooks/bootstrap.d.ts.map +1 -1
  242. package/dist/hooks/bootstrap.js +5 -2
  243. package/dist/hooks/bootstrap.js.map +1 -1
  244. package/dist/index.d.ts +1 -2
  245. package/dist/index.d.ts.map +1 -1
  246. package/dist/index.js.map +1 -1
  247. package/dist/knowledge/audit.d.ts +7 -2
  248. package/dist/knowledge/audit.d.ts.map +1 -1
  249. package/dist/knowledge/audit.js +59 -79
  250. package/dist/knowledge/audit.js.map +1 -1
  251. package/dist/knowledge/flywheel-metrics.d.ts +39 -0
  252. package/dist/knowledge/flywheel-metrics.d.ts.map +1 -0
  253. package/dist/knowledge/flywheel-metrics.js +47 -0
  254. package/dist/knowledge/flywheel-metrics.js.map +1 -0
  255. package/dist/knowledge/import.d.ts.map +1 -1
  256. package/dist/knowledge/import.js +4 -14
  257. package/dist/knowledge/import.js.map +1 -1
  258. package/dist/knowledge/index-generator.d.ts.map +1 -1
  259. package/dist/knowledge/index-generator.js +17 -14
  260. package/dist/knowledge/index-generator.js.map +1 -1
  261. package/dist/knowledge/ingest.d.ts.map +1 -1
  262. package/dist/knowledge/ingest.js +9 -4
  263. package/dist/knowledge/ingest.js.map +1 -1
  264. package/dist/knowledge/migration.d.ts.map +1 -1
  265. package/dist/knowledge/migration.js +11 -8
  266. package/dist/knowledge/migration.js.map +1 -1
  267. package/dist/knowledge/reference-tracker.d.ts.map +1 -1
  268. package/dist/knowledge/reference-tracker.js +12 -9
  269. package/dist/knowledge/reference-tracker.js.map +1 -1
  270. package/dist/knowledge/store.d.ts +15 -0
  271. package/dist/knowledge/store.d.ts.map +1 -1
  272. package/dist/knowledge/store.js +59 -10
  273. package/dist/knowledge/store.js.map +1 -1
  274. package/dist/monitoring/context-tracker.d.ts.map +1 -1
  275. package/dist/monitoring/context-tracker.js +11 -20
  276. package/dist/monitoring/context-tracker.js.map +1 -1
  277. package/dist/monitoring/index.d.ts +1 -1
  278. package/dist/monitoring/index.d.ts.map +1 -1
  279. package/dist/monitoring/index.js +1 -2
  280. package/dist/monitoring/index.js.map +1 -1
  281. package/dist/monitoring/trace-analyzer.d.ts +15 -0
  282. package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
  283. package/dist/monitoring/trace-analyzer.js +19 -2
  284. package/dist/monitoring/trace-analyzer.js.map +1 -1
  285. package/dist/monitoring/traces.d.ts +21 -2
  286. package/dist/monitoring/traces.d.ts.map +1 -1
  287. package/dist/monitoring/traces.js +38 -29
  288. package/dist/monitoring/traces.js.map +1 -1
  289. package/dist/release/index.d.ts +2 -2
  290. package/dist/release/index.d.ts.map +1 -1
  291. package/dist/release/index.js +1 -5
  292. package/dist/release/index.js.map +1 -1
  293. package/dist/sdd/index-generator.js +10 -11
  294. package/dist/sdd/index-generator.js.map +1 -1
  295. package/dist/test-setup/project-fixture.d.ts +48 -0
  296. package/dist/test-setup/project-fixture.d.ts.map +1 -0
  297. package/dist/test-setup/project-fixture.js +106 -0
  298. package/dist/test-setup/project-fixture.js.map +1 -0
  299. package/dist/types/constraint.d.ts +8 -18
  300. package/dist/types/constraint.d.ts.map +1 -1
  301. package/dist/types/constraint.js +6 -1
  302. package/dist/types/constraint.js.map +1 -1
  303. package/dist/types/passes-gate.d.ts +10 -25
  304. package/dist/types/passes-gate.d.ts.map +1 -1
  305. package/dist/types/project-config.d.ts +1 -1
  306. package/dist/types/session.d.ts +6 -5
  307. package/dist/types/session.d.ts.map +1 -1
  308. package/dist/types/trace.d.ts +9 -0
  309. package/dist/types/trace.d.ts.map +1 -1
  310. package/dist/utils/exec.d.ts +10 -0
  311. package/dist/utils/exec.d.ts.map +1 -1
  312. package/dist/utils/exec.js +12 -0
  313. package/dist/utils/exec.js.map +1 -1
  314. package/dist/utils/file-walk.d.ts +9 -1
  315. package/dist/utils/file-walk.d.ts.map +1 -1
  316. package/dist/utils/file-walk.js +10 -1
  317. package/dist/utils/file-walk.js.map +1 -1
  318. package/dist/utils/frontmatter.d.ts +73 -0
  319. package/dist/utils/frontmatter.d.ts.map +1 -0
  320. package/dist/utils/frontmatter.js +141 -0
  321. package/dist/utils/frontmatter.js.map +1 -0
  322. package/dist/utils/jsonl.d.ts +92 -0
  323. package/dist/utils/jsonl.d.ts.map +1 -0
  324. package/dist/utils/jsonl.js +166 -0
  325. package/dist/utils/jsonl.js.map +1 -0
  326. package/dist/utils/package-version.d.ts +16 -0
  327. package/dist/utils/package-version.d.ts.map +1 -0
  328. package/dist/utils/package-version.js +63 -0
  329. package/dist/utils/package-version.js.map +1 -0
  330. package/package.json +1 -1
  331. package/src/CONTEXT.md +8 -2
  332. package/src/__tests__/acceptance-gate.test.ts +3 -1
  333. package/src/__tests__/checker-extra.test.ts +7 -1218
  334. package/src/__tests__/context-files-resolution.test.ts +116 -0
  335. package/src/__tests__/effective-constraints.test.ts +10 -13
  336. package/src/__tests__/exec.test.ts +35 -1
  337. package/src/__tests__/layering.test.ts +152 -0
  338. package/src/__tests__/passes-gate-extra.test.ts +0 -145
  339. package/src/__tests__/passes-gate.test.ts +130 -101
  340. package/src/__tests__/skip-semantics.test.ts +5 -9
  341. package/src/cli/__tests__/command-contract.test.ts +170 -0
  342. package/src/cli/command-contract.ts +108 -0
  343. package/src/cli/commands/CONTEXT.md +23 -8
  344. package/src/cli/commands/__tests__/acceptance.test.ts +40 -33
  345. package/src/cli/commands/__tests__/analyze-sessions.test.ts +35 -29
  346. package/src/cli/commands/__tests__/bin-exit-mapping.test.ts +107 -0
  347. package/src/cli/commands/__tests__/check-drift.test.ts +27 -34
  348. package/src/cli/commands/__tests__/check-skip-output.test.ts +21 -24
  349. package/src/cli/commands/__tests__/check.test.ts +448 -378
  350. package/src/cli/commands/__tests__/command.test.ts +85 -70
  351. package/src/cli/commands/__tests__/constraints-report.test.ts +100 -71
  352. package/src/cli/commands/__tests__/constraints-retire.test.ts +152 -95
  353. package/src/cli/commands/__tests__/contract.test.ts +27 -34
  354. package/src/cli/commands/__tests__/failure.test.ts +31 -34
  355. package/src/cli/commands/__tests__/init-injection.test.ts +58 -28
  356. package/src/cli/commands/__tests__/init.test.ts +77 -48
  357. package/src/cli/commands/__tests__/knowledge-flywheel-consistency.test.ts +108 -0
  358. package/src/cli/commands/__tests__/knowledge.test.ts +69 -43
  359. package/src/cli/commands/__tests__/passes-gate.test.ts +43 -45
  360. package/src/cli/commands/__tests__/performance.test.ts +22 -23
  361. package/src/cli/commands/__tests__/posteval-plan.test.ts +39 -38
  362. package/src/cli/commands/__tests__/project-path-anchoring.test.ts +157 -0
  363. package/src/cli/commands/__tests__/project-path-convention.test.ts +231 -0
  364. package/src/cli/commands/__tests__/registry.test.ts +75 -35
  365. package/src/cli/commands/__tests__/release.test.ts +209 -80
  366. package/src/cli/commands/__tests__/report-extra.test.ts +16 -16
  367. package/src/cli/commands/__tests__/report.test.ts +25 -25
  368. package/src/cli/commands/__tests__/review.test.ts +33 -31
  369. package/src/cli/commands/__tests__/security.test.ts +23 -27
  370. package/src/cli/commands/__tests__/spec-baseline-check.test.ts +20 -20
  371. package/src/cli/commands/__tests__/spec.test.ts +41 -29
  372. package/src/cli/commands/__tests__/status-extra.test.ts +18 -18
  373. package/src/cli/commands/__tests__/status-skipped-lines.test.ts +72 -0
  374. package/src/cli/commands/__tests__/status.test.ts +34 -34
  375. package/src/cli/commands/__tests__/sync-docs-agents.test.ts +77 -78
  376. package/src/cli/commands/__tests__/sync-docs.test.ts +72 -74
  377. package/src/cli/commands/__tests__/update-user-model.test.ts +97 -34
  378. package/src/cli/commands/__tests__/validate.test.ts +27 -29
  379. package/src/cli/commands/acceptance.ts +35 -24
  380. package/src/cli/commands/analyze-sessions.ts +25 -24
  381. package/src/cli/commands/check.ts +127 -66
  382. package/src/cli/commands/command.ts +30 -17
  383. package/src/cli/commands/constraints-report.ts +37 -34
  384. package/src/cli/commands/constraints-retire.ts +58 -55
  385. package/src/cli/commands/constraints.ts +10 -27
  386. package/src/cli/commands/contract.ts +51 -42
  387. package/src/cli/commands/definitions.ts +34 -227
  388. package/src/cli/commands/failure.ts +33 -26
  389. package/src/cli/commands/init.ts +166 -220
  390. package/src/cli/commands/knowledge.ts +192 -289
  391. package/src/cli/commands/passes-gate.ts +58 -68
  392. package/src/cli/commands/performance.ts +23 -18
  393. package/src/cli/commands/posteval-plan.ts +29 -15
  394. package/src/cli/commands/release.ts +70 -59
  395. package/src/cli/commands/report.ts +9 -5
  396. package/src/cli/commands/review.ts +39 -29
  397. package/src/cli/commands/sdd.ts +7 -5
  398. package/src/cli/commands/security.ts +35 -26
  399. package/src/cli/commands/spec-baseline-check.ts +16 -11
  400. package/src/cli/commands/spec.ts +66 -53
  401. package/src/cli/commands/status.ts +59 -53
  402. package/src/cli/commands/sync-docs/agents-syncer.ts +5 -2
  403. package/src/cli/commands/sync-docs/context-syncer.ts +3 -2
  404. package/src/cli/commands/sync-docs/index.ts +73 -100
  405. package/src/cli/commands/sync-docs/project-reader.ts +17 -18
  406. package/src/cli/commands/update-user-model.ts +64 -61
  407. package/src/cli/commands/validate.ts +31 -25
  408. package/src/cli/session-mining/__tests__/transcript.test.ts +118 -0
  409. package/src/cli/session-mining/transcript.ts +26 -8
  410. package/src/context/session-manager.ts +19 -33
  411. package/src/core/CONTEXT.md +10 -6
  412. package/src/core/constraints/__tests__/capabilities-reconcile.test.ts +200 -0
  413. package/src/core/constraints/__tests__/capability-counts.test.ts +94 -0
  414. package/src/core/constraints/__tests__/git-evidence.test.ts +208 -0
  415. package/src/core/constraints/__tests__/injection-drift.test.ts +3 -10
  416. package/src/core/constraints/__tests__/injection-writer.test.ts +231 -0
  417. package/src/core/constraints/__tests__/trace-injection.test.ts +71 -0
  418. package/src/core/constraints/__tests__/usage-report.test.ts +112 -0
  419. package/src/core/constraints/agent-prompt-renderer.ts +2 -6
  420. package/src/core/constraints/capabilities-parser.ts +53 -35
  421. package/src/core/constraints/capabilities-reconcile.ts +166 -0
  422. package/src/core/constraints/checker.ts +82 -133
  423. package/src/core/constraints/checkers/__tests__/capability-sync.test.ts +273 -0
  424. package/src/core/constraints/checkers/__tests__/check-outcome.test.ts +176 -0
  425. package/src/core/constraints/checkers/__tests__/context-doc-sync.test.ts +77 -0
  426. package/src/core/constraints/checkers/__tests__/docs-freshness.test.ts +126 -0
  427. package/src/{__tests__ → core/constraints/checkers/__tests__}/governance-presence.test.ts +83 -9
  428. package/src/core/constraints/checkers/__tests__/iron-flags.test.ts +50 -0
  429. package/src/core/constraints/checkers/__tests__/no-bypass-checkpoint.test.ts +76 -0
  430. package/src/{__tests__ → core/constraints/checkers/__tests__}/no-hardcoded-credentials.test.ts +4 -3
  431. package/src/core/constraints/checkers/__tests__/no-test-simplification.test.ts +58 -0
  432. package/src/core/constraints/checkers/__tests__/three-state-consistency.test.ts +153 -0
  433. package/src/core/constraints/checkers/capability-sync.ts +75 -96
  434. package/src/core/constraints/checkers/context-doc-sync.ts +15 -25
  435. package/src/core/constraints/checkers/docs-freshness.ts +54 -70
  436. package/src/core/constraints/checkers/governance-presence.ts +7 -25
  437. package/src/core/constraints/checkers/index.ts +9 -2
  438. package/src/core/constraints/checkers/no-test-simplification.ts +4 -3
  439. package/src/core/constraints/checkers/types.ts +60 -4
  440. package/src/core/constraints/context-builder.ts +39 -91
  441. package/src/core/constraints/doc-freshness/runner.ts +2 -1
  442. package/src/core/constraints/git-evidence.ts +120 -0
  443. package/src/core/constraints/injection-drift.ts +13 -60
  444. package/src/core/constraints/injection-writer.ts +212 -0
  445. package/src/core/constraints/usage-report.ts +36 -17
  446. package/src/core/index.ts +4 -2
  447. package/src/core/project-config-loader.ts +49 -9
  448. package/src/core/validators/__tests__/passes-gate.test.ts +2 -56
  449. package/src/core/validators/__tests__/test-output.test.ts +372 -0
  450. package/src/core/validators/passes-gate.ts +86 -248
  451. package/src/core/validators/test-output.ts +128 -0
  452. package/src/failure/__tests__/recorder.test.ts +168 -0
  453. package/src/failure/recorder.ts +12 -10
  454. package/src/gates/CONTEXT.md +7 -4
  455. package/src/gates/__tests__/acceptance-types-single-source.test.ts +68 -0
  456. package/src/gates/__tests__/acceptance.test.ts +4 -86
  457. package/src/gates/__tests__/checker-gate.test.ts +24 -0
  458. package/src/gates/__tests__/effective-gates.test.ts +3 -8
  459. package/src/gates/__tests__/test-verdict-consistency.test.ts +140 -0
  460. package/src/gates/acceptance.ts +19 -84
  461. package/src/gates/checker-gate.ts +12 -15
  462. package/src/gates/command.ts +10 -16
  463. package/src/gates/contract.ts +22 -61
  464. package/src/gates/performance.ts +10 -22
  465. package/src/gates/review.ts +21 -41
  466. package/src/gates/security.ts +10 -22
  467. package/src/gates/types.ts +70 -5
  468. package/src/hooks/CONTEXT.md +1 -1
  469. package/src/hooks/bootstrap.ts +5 -2
  470. package/src/index.ts +0 -4
  471. package/src/knowledge/CONTEXT.md +8 -3
  472. package/src/knowledge/__tests__/audit-labels.test.ts +44 -0
  473. package/src/knowledge/__tests__/flywheel-metrics.test.ts +135 -0
  474. package/src/knowledge/__tests__/import.test.ts +44 -0
  475. package/src/knowledge/__tests__/index-generator.test.ts +53 -0
  476. package/src/knowledge/__tests__/ingest.test.ts +85 -0
  477. package/src/knowledge/__tests__/migration.test.ts +47 -0
  478. package/src/knowledge/__tests__/reference-tracker.test.ts +16 -0
  479. package/src/knowledge/__tests__/store.test.ts +194 -0
  480. package/src/knowledge/audit.ts +67 -71
  481. package/src/knowledge/flywheel-metrics.ts +71 -0
  482. package/src/knowledge/import.ts +4 -18
  483. package/src/knowledge/index-generator.ts +19 -14
  484. package/src/knowledge/ingest.ts +9 -4
  485. package/src/knowledge/migration.ts +11 -8
  486. package/src/knowledge/reference-tracker.ts +12 -8
  487. package/src/knowledge/store.ts +64 -11
  488. package/src/monitoring/CONTEXT.md +8 -3
  489. package/src/monitoring/__tests__/skipped-lines-report.test.ts +178 -0
  490. package/src/monitoring/__tests__/traces.test.ts +57 -0
  491. package/src/monitoring/context-tracker.ts +11 -23
  492. package/src/monitoring/index.ts +1 -1
  493. package/src/monitoring/trace-analyzer.ts +21 -2
  494. package/src/monitoring/traces.ts +39 -36
  495. package/src/release/CONTEXT.md +1 -0
  496. package/src/release/__tests__/barrel.test.ts +60 -0
  497. package/src/release/index.ts +2 -13
  498. package/src/sdd/__tests__/index-generator.test.ts +71 -0
  499. package/src/sdd/index-generator.ts +9 -9
  500. package/src/test-setup/__tests__/project-fixture.test.ts +178 -0
  501. package/src/test-setup/project-fixture.ts +87 -0
  502. package/src/tools/CONTEXT.md +6 -0
  503. package/src/tools/__tests__/registry.test.ts +221 -0
  504. package/src/types/__tests__/types.test.ts +4 -5
  505. package/src/types/constraint.ts +16 -27
  506. package/src/types/passes-gate.ts +10 -30
  507. package/src/types/project-config.ts +1 -1
  508. package/src/types/session.ts +5 -5
  509. package/src/types/trace.ts +10 -0
  510. package/src/utils/__tests__/frontmatter.test.ts +206 -0
  511. package/src/utils/__tests__/jsonl-skip-disposition.test.ts +175 -0
  512. package/src/utils/__tests__/jsonl.test.ts +187 -0
  513. package/src/utils/__tests__/package-version.test.ts +97 -0
  514. package/src/utils/exec.ts +15 -0
  515. package/src/utils/file-walk.ts +11 -2
  516. package/src/utils/frontmatter.ts +121 -0
  517. package/src/utils/jsonl.ts +167 -0
  518. package/src/utils/package-version.ts +27 -0
  519. package/dist/cli/commands/doc-freshness-check.d.ts +0 -53
  520. package/dist/cli/commands/doc-freshness-check.d.ts.map +0 -1
  521. package/dist/cli/commands/doc-freshness-check.js +0 -352
  522. package/dist/cli/commands/doc-freshness-check.js.map +0 -1
  523. package/dist/types/index.d.ts +0 -14
  524. package/dist/types/index.d.ts.map +0 -1
  525. package/dist/types/index.js +0 -39
  526. package/dist/types/index.js.map +0 -1
  527. package/src/__tests__/long-running.test.ts +0 -17
  528. package/src/__tests__/passes-gate-extension.test.ts +0 -151
  529. package/src/cli/commands/__tests__/doc-freshness-check.test.ts +0 -168
  530. package/src/cli/commands/doc-freshness-check.ts +0 -386
  531. package/src/spec/CONTEXT.md +0 -11
  532. package/src/types/index.ts +0 -47
@@ -7,9 +7,10 @@
7
7
  * - 每个实现引用(CommandImplRef)标注实现文件与导出名;bin 按需
8
8
  * per-command 懒加载(O2):只在 action 执行时 require 对应命令模块,
9
9
  * 不再经单一 barrel 加载全部命令实现。
10
- * - 本模块是纯数据模块:禁止 import 任何命令实现(含运行时依赖),
11
- * 保证 --help/--version 懒加载不被破坏;注册表完整性断言(引用实现
12
- * 可解析)在 __tests__/registry.test.ts 构建/测试期校验。
10
+ * - 本模块是纯数据模块(候选7 后零闭包):禁止 import 任何命令实现,
11
+ * 子命令别名是数据(aliases),实参编组归各命令模块的具名导出
12
+ * (那才是它的 interface/测试面);保证 --help/--version 懒加载不被破坏;
13
+ * 注册表完整性断言(引用实现可解析)在 __tests__/registry.test.ts 构建/测试期校验。
13
14
  */
14
15
 
15
16
  /**
@@ -35,18 +36,21 @@ export interface CommandImplRef {
35
36
  }
36
37
 
37
38
  /**
38
- * 子命令条目:别名实现 + 实参构造
39
+ * 子命令条目:主名实现(别名经 aliases 一名多注册,架构评审候选7)
39
40
  */
40
41
  export interface CommandSubcommand {
41
42
  /** 实现引用 */
42
43
  impl: CommandImplRef;
43
- /** 实参构造:positionals = 子命令名之后的位置参数(无则 []) */
44
- args?: (positionals: (string | undefined)[], options: Record<string, unknown>) => unknown[];
44
+ /** 别名:与主名解析到同一实现(不再整块复印 args 闭包) */
45
+ aliases?: string[];
46
+ /** true = 实现签名 (positionals, options)(需要位置参数的命令,如 knowledge search);缺省 (options) */
47
+ withPositionals?: boolean;
45
48
  }
46
49
 
47
50
  /**
48
51
  * 选项条件路由(如 check --list):选项值匹配时以路由替代默认 action;
49
- * 同一选项可挂多条路由(按声明顺序执行,如 passes-gate --coverage
52
+ * 同一选项可挂多条路由(按序执行,如 passes-gate --coverage)。
53
+ * 实现一律以 (options) 调用;需编组/取值的指向命令模块内的具名包装导出。
50
54
  */
51
55
  export interface CommandOptionRoute {
52
56
  /** 触发选项键(commander options 对象键名,如 'list') */
@@ -55,8 +59,6 @@ export interface CommandOptionRoute {
55
59
  when: unknown;
56
60
  /** 实现引用 */
57
61
  impl: CommandImplRef;
58
- /** 实参构造(缺省为 [options]) */
59
- args?: (positionals: (string | undefined)[], options: Record<string, unknown>) => unknown[];
60
62
  }
61
63
 
62
64
  /**
@@ -87,8 +89,6 @@ export interface CommandDefinition {
87
89
  optionRoutes?: CommandOptionRoute[];
88
90
  /** 默认 action 实参构造(缺省为 [options]) */
89
91
  mapActionArgs?: (positionals: (string | undefined)[], options: Record<string, unknown>) => unknown[];
90
- /** action 完成后处理(接收返回值,如 sync-docs --check 失败 exit(1)) */
91
- afterRun?: (result: unknown, options: Record<string, unknown>) => void;
92
92
  }
93
93
 
94
94
  /**
@@ -107,7 +107,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
107
107
  ],
108
108
  action: { module: 'check', export: 'check' },
109
109
  optionRoutes: [
110
- { flag: 'list', when: true, impl: { module: 'check', export: 'listLaws' }, args: () => [] },
110
+ { flag: 'list', when: true, impl: { module: 'check', export: 'listLaws' } },
111
111
  ],
112
112
  },
113
113
  {
@@ -135,15 +135,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
135
135
  action: { module: 'passes-gate', export: 'runPassesGate' },
136
136
  optionRoutes: [
137
137
  { flag: 'coverage', when: true, impl: { module: 'passes-gate', export: 'runPassesGate' } },
138
- {
139
- flag: 'coverage',
140
- when: true,
141
- impl: { module: 'passes-gate', export: 'checkCoverage' },
142
- args: (_pos, options) => [
143
- options.projectPath || process.cwd(),
144
- parseInt(String(options.coverageThreshold), 10),
145
- ],
146
- },
138
+ { flag: 'coverage', when: true, impl: { module: 'passes-gate', export: 'coverageCheck' } },
147
139
  ],
148
140
  },
149
141
  {
@@ -202,7 +194,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
202
194
  ],
203
195
  action: { module: 'spec', export: 'specValidate' },
204
196
  subcommands: {
205
- list: { impl: { module: 'spec', export: 'listSpecTypes' }, args: () => [] },
197
+ list: { impl: { module: 'spec', export: 'listSpecTypes' } },
206
198
  },
207
199
  // 未知位置参数按文件路径落回默认 action(spec foo.yaml 合法用法)
208
200
  subcommandStrict: false,
@@ -227,12 +219,8 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
227
219
  { flags: '--agents', description: '同步 AGENTS.md(agent 导读;PRESERVE 标记段重新生成时保留)', defaultValue: false },
228
220
  { flags: '--compact', description: '一次性迁移:将 CAPABILITIES.md 文件表格折叠为目录条目', defaultValue: false },
229
221
  ],
222
+ // --check 下的漂移由实现返回 fail(候选7:退出码映射只在 bin 一处),故无需 afterRun
230
223
  action: { module: 'sync-docs', export: 'syncDocs' },
231
- afterRun: (ok, options) => {
232
- if (!ok && options.check) {
233
- process.exit(1);
234
- }
235
- },
236
224
  },
237
225
  {
238
226
  command: 'knowledge',
@@ -247,11 +235,6 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
247
235
  { flags: '--sources <sources>', description: '导入源(逗号分隔: code,git,docs)' },
248
236
  { flags: '--limit <n>', description: '结果数量限制', defaultValue: '20' },
249
237
  { flags: '--reset', description: '重置导入状态', defaultValue: false },
250
- { flags: '--scope <scope>', description: '知识范围(用于 upsert 去重)' },
251
- { flags: '--title <title>', description: '知识标题(用于 upsert)' },
252
- { flags: '--content <content>', description: '知识内容 Markdown(用于 upsert)' },
253
- { flags: '--file <path>', description: '从文件读取内容(用于 upsert)' },
254
- { flags: '--source <source>', description: '知识来源 (cli/design)', defaultValue: 'cli' },
255
238
  { flags: '--fix', description: '自动修复(用于 audit)', defaultValue: false },
256
239
  { flags: '--dry-run', description: '只输出报告不修改(用于 audit)', defaultValue: false },
257
240
  { flags: '--threshold <n>', description: '短内容阈值(字符数,用于 audit)', defaultValue: '50' },
@@ -259,150 +242,22 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
259
242
  { flags: '--json', description: 'JSON 格式输出', defaultValue: false },
260
243
  ],
261
244
  subcommands: {
262
- list: {
263
- impl: { module: 'knowledge', export: 'knowledgeList' },
264
- args: (_pos, options) => [{
265
- projectPath: options.projectPath, json: options.json,
266
- type: options.type, maturity: options.maturity, tag: options.tag,
267
- }],
268
- },
269
- ls: {
270
- impl: { module: 'knowledge', export: 'knowledgeList' },
271
- args: (_pos, options) => [{
272
- projectPath: options.projectPath, json: options.json,
273
- type: options.type, maturity: options.maturity, tag: options.tag,
274
- }],
275
- },
245
+ // 纯投影条目:commander options 与处理器参数同名,原样传入(编组归命令模块)
246
+ list: { impl: { module: 'knowledge', export: 'knowledgeList' }, aliases: ['ls'] },
276
247
  search: {
277
- impl: { module: 'knowledge', export: 'knowledgeSearch' },
278
- args: (positionals, options) => {
279
- if (!positionals[0]) {
280
- console.error('请提供搜索关键词');
281
- process.exit(1);
282
- }
283
- return [positionals[0], {
284
- projectPath: options.projectPath, json: options.json,
285
- limit: parseInt(String(options.limit), 10),
286
- }];
287
- },
288
- },
289
- s: {
290
- impl: { module: 'knowledge', export: 'knowledgeSearch' },
291
- args: (positionals, options) => {
292
- if (!positionals[0]) {
293
- console.error('请提供搜索关键词');
294
- process.exit(1);
295
- }
296
- return [positionals[0], {
297
- projectPath: options.projectPath, json: options.json,
298
- limit: parseInt(String(options.limit), 10),
299
- }];
300
- },
301
- },
302
- import: {
303
- impl: { module: 'knowledge', export: 'knowledgeImport' },
304
- args: (_pos, options) => [{
305
- projectPath: options.projectPath, json: options.json,
306
- sources: options.sources, reset: options.reset,
307
- }],
308
- },
309
- i: {
310
- impl: { module: 'knowledge', export: 'knowledgeImport' },
311
- args: (_pos, options) => [{
312
- projectPath: options.projectPath, json: options.json,
313
- sources: options.sources, reset: options.reset,
314
- }],
315
- },
316
- decay: {
317
- impl: { module: 'knowledge', export: 'knowledgeDecay' },
318
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
319
- },
320
- d: {
321
- impl: { module: 'knowledge', export: 'knowledgeDecay' },
322
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
323
- },
324
- stats: {
325
- impl: { module: 'knowledge', export: 'knowledgeStats' },
326
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
327
- },
328
- st: {
329
- impl: { module: 'knowledge', export: 'knowledgeStats' },
330
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
331
- },
332
- 'sync-rag': {
333
- impl: { module: 'knowledge', export: 'knowledgeSyncRag' },
334
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
335
- },
336
- 'sync-status': {
337
- impl: { module: 'knowledge', export: 'knowledgeSyncStatus' },
338
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
339
- },
340
- sync: {
341
- impl: { module: 'knowledge', export: 'knowledgeSyncStatus' },
342
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
343
- },
344
- upsert: {
345
- impl: { module: 'knowledge', export: 'knowledgeUpsert' },
346
- args: (_pos, options) => [{
347
- scope: options.scope || '',
348
- title: options.title || '',
349
- content: options.content || '',
350
- file: options.file || '',
351
- type: options.type || 'architecture',
352
- source: options.source || 'cli',
353
- }],
354
- },
355
- up: {
356
- impl: { module: 'knowledge', export: 'knowledgeUpsert' },
357
- args: (_pos, options) => [{
358
- scope: options.scope || '',
359
- title: options.title || '',
360
- content: options.content || '',
361
- file: options.file || '',
362
- type: options.type || 'architecture',
363
- source: options.source || 'cli',
364
- }],
365
- },
366
- audit: {
367
- impl: { module: 'knowledge', export: 'knowledgeAudit' },
368
- args: (_pos, options) => [{
369
- projectPath: options.projectPath, json: options.json,
370
- fix: options.fix, dryRun: options.dryRun,
371
- threshold: options.threshold, dir: options.dir,
372
- }],
373
- },
374
- a: {
375
- impl: { module: 'knowledge', export: 'knowledgeAudit' },
376
- args: (_pos, options) => [{
377
- projectPath: options.projectPath, json: options.json,
378
- fix: options.fix, dryRun: options.dryRun,
379
- threshold: options.threshold, dir: options.dir,
380
- }],
381
- },
382
- snapshot: {
383
- impl: { module: 'knowledge', export: 'knowledgeSnapshot' },
384
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
385
- },
386
- migrate: {
387
- impl: { module: 'knowledge', export: 'knowledgeMigrate' },
388
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
389
- },
390
- index: {
391
- impl: { module: 'knowledge', export: 'knowledgeIndex' },
392
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
393
- },
394
- idx: {
395
- impl: { module: 'knowledge', export: 'knowledgeIndex' },
396
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
397
- },
398
- health: {
399
- impl: { module: 'knowledge', export: 'knowledgeHealth' },
400
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
401
- },
402
- h: {
403
- impl: { module: 'knowledge', export: 'knowledgeHealth' },
404
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
405
- },
248
+ impl: { module: 'knowledge', export: 'knowledgeSearchCommand' },
249
+ aliases: ['s'],
250
+ withPositionals: true,
251
+ },
252
+ import: { impl: { module: 'knowledge', export: 'knowledgeImport' }, aliases: ['i'] },
253
+ decay: { impl: { module: 'knowledge', export: 'knowledgeDecay' }, aliases: ['d'] },
254
+ stats: { impl: { module: 'knowledge', export: 'knowledgeStats' }, aliases: ['st'] },
255
+ 'sync-rag': { impl: { module: 'knowledge', export: 'knowledgeSyncRag' } },
256
+ audit: { impl: { module: 'knowledge', export: 'knowledgeAudit' }, aliases: ['a'] },
257
+ snapshot: { impl: { module: 'knowledge', export: 'knowledgeSnapshot' } },
258
+ migrate: { impl: { module: 'knowledge', export: 'knowledgeMigrate' } },
259
+ index: { impl: { module: 'knowledge', export: 'knowledgeIndex' }, aliases: ['idx'] },
260
+ health: { impl: { module: 'knowledge', export: 'knowledgeHealth' }, aliases: ['h'] },
406
261
  },
407
262
  },
408
263
  {
@@ -415,14 +270,7 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
415
270
  { flags: '--json', description: 'JSON 输出' },
416
271
  ],
417
272
  subcommands: {
418
- index: {
419
- impl: { module: 'sdd', export: 'sddIndex' },
420
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
421
- },
422
- idx: {
423
- impl: { module: 'sdd', export: 'sddIndex' },
424
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json, dir: options.dir }],
425
- },
273
+ index: { impl: { module: 'sdd', export: 'sddIndex' }, aliases: ['idx'] },
426
274
  },
427
275
  },
428
276
  {
@@ -437,34 +285,9 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
437
285
  { flags: '--json', description: 'JSON 格式输出', defaultValue: false },
438
286
  ],
439
287
  subcommands: {
440
- list: {
441
- impl: { module: 'failure', export: 'failureList' },
442
- args: (_pos, options) => [{
443
- projectPath: options.projectPath, json: options.json,
444
- limit: parseInt(String(options.limit), 10),
445
- type: options.type, level: options.level,
446
- }],
447
- },
448
- ls: {
449
- impl: { module: 'failure', export: 'failureList' },
450
- args: (_pos, options) => [{
451
- projectPath: options.projectPath, json: options.json,
452
- limit: parseInt(String(options.limit), 10),
453
- type: options.type, level: options.level,
454
- }],
455
- },
456
- stats: {
457
- impl: { module: 'failure', export: 'failureStats' },
458
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
459
- },
460
- st: {
461
- impl: { module: 'failure', export: 'failureStats' },
462
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
463
- },
464
- clear: {
465
- impl: { module: 'failure', export: 'failureClear' },
466
- args: (_pos, options) => [{ projectPath: options.projectPath, json: options.json }],
467
- },
288
+ list: { impl: { module: 'failure', export: 'failureList' }, aliases: ['ls'] },
289
+ stats: { impl: { module: 'failure', export: 'failureStats' }, aliases: ['st'] },
290
+ clear: { impl: { module: 'failure', export: 'failureClear' } },
468
291
  },
469
292
  },
470
293
  {
@@ -562,22 +385,6 @@ export const COMMAND_DEFINITIONS: CommandDefinition[] = [
562
385
  },
563
386
  ],
564
387
  },
565
- {
566
- command: 'doc-freshness-check',
567
- argument: '<docPath>',
568
- description: '检查文档声明的新鲜度:提取可验证声明,与代码对照',
569
- options: [
570
- { flags: '--changed-files <list>', description: '变更文件列表(逗号分隔)' },
571
- { flags: '--format <format>', description: '输出格式 (table/json)', defaultValue: 'table' },
572
- { flags: '-p, --project-path <path>', description: '项目路径' },
573
- ],
574
- action: { module: 'doc-freshness-check', export: 'docFreshnessCheck' },
575
- mapActionArgs: (positionals, options) => [positionals[0], {
576
- changedFiles: options.changedFiles,
577
- format: options.format,
578
- projectPath: options.projectPath,
579
- }],
580
- },
581
388
  {
582
389
  command: 'spec-baseline-check',
583
390
  argument: '<specPath>',
@@ -8,6 +8,7 @@ import chalk from 'chalk';
8
8
  import * as path from 'path';
9
9
  import { FailureRecorder } from '../../failure/recorder';
10
10
  import { DEFAULT_FAILURE_LOG_FILE } from '../../types/failure';
11
+ import { log, processIO, type CommandIO, type CommandResult } from '../command-contract';
11
12
 
12
13
  export interface FailureOptions {
13
14
  /** 项目路径 */
@@ -30,8 +31,9 @@ function getRecorder(projectPath?: string): FailureRecorder {
30
31
  * 失败记录列表
31
32
  */
32
33
  export async function failureList(
33
- options: FailureOptions & { limit?: number; type?: string; level?: string },
34
- ): Promise<void> {
34
+ options: FailureOptions & { limit?: number | string; type?: string; level?: string },
35
+ io: CommandIO = processIO,
36
+ ): Promise<CommandResult> {
35
37
  const recorder = getRecorder(options.projectPath);
36
38
 
37
39
  let records = await recorder.getHistory();
@@ -42,77 +44,82 @@ export async function failureList(
42
44
  if (options.level) {
43
45
  records = records.filter(r => r.level === options.level);
44
46
  }
45
- if (options.limit && options.limit > 0) {
46
- records = records.slice(-options.limit);
47
+ // CLI 直传时 limit commander 字符串值;程序内调用传 number(候选7:编组在命令函数)
48
+ const limit = typeof options.limit === 'string' ? parseInt(options.limit, 10) : options.limit;
49
+ if (limit && limit > 0) {
50
+ records = records.slice(-limit);
47
51
  }
48
52
 
49
53
  if (options.json) {
50
- console.log(JSON.stringify({ total: records.length, records }, null, 2));
51
- return;
54
+ log(io, JSON.stringify({ total: records.length, records }, null, 2));
55
+ return { kind: 'ok' };
52
56
  }
53
57
 
54
58
  if (records.length === 0) {
55
- console.log(chalk.yellow('没有失败记录'));
56
- return;
59
+ log(io, chalk.yellow('没有失败记录'));
60
+ return { kind: 'ok' };
57
61
  }
58
62
 
59
- console.log(chalk.red(`📋 失败记录 (${records.length} 条)\n`));
63
+ log(io, chalk.red(`📋 失败记录 (${records.length} 条)\n`));
60
64
  for (const record of records) {
61
65
  const levelColor = record.level === 'L4' ? chalk.red
62
66
  : record.level === 'L3' ? chalk.yellow
63
67
  : record.level === 'L2' ? chalk.cyan
64
68
  : chalk.gray;
65
69
  const time = new Date(record.timestamp).toLocaleString();
66
- console.log(` ${levelColor(`[${record.level}]`)} ${chalk.bold(record.type)} ${chalk.gray(time)}`);
67
- console.log(` ${record.message}`);
70
+ log(io, ` ${levelColor(`[${record.level}]`)} ${chalk.bold(record.type)} ${chalk.gray(time)}`);
71
+ log(io, ` ${record.message}`);
68
72
  }
73
+ return { kind: 'ok' };
69
74
  }
70
75
 
71
76
  /**
72
77
  * 失败记录统计
73
78
  */
74
- export async function failureStats(options: FailureOptions): Promise<void> {
79
+ export async function failureStats(options: FailureOptions, io: CommandIO = processIO): Promise<CommandResult> {
75
80
  const recorder = getRecorder(options.projectPath);
76
81
  const stats = await recorder.getStats();
77
82
 
78
83
  if (options.json) {
79
- console.log(JSON.stringify(stats, null, 2));
80
- return;
84
+ log(io, JSON.stringify(stats, null, 2));
85
+ return { kind: 'ok' };
81
86
  }
82
87
 
83
88
  if (stats.total === 0) {
84
- console.log(chalk.green('✅ 没有失败记录'));
85
- return;
89
+ log(io, chalk.green('✅ 没有失败记录'));
90
+ return { kind: 'ok' };
86
91
  }
87
92
 
88
- console.log(chalk.red(`📊 失败统计\n`));
89
- console.log(chalk.bold(` 总计: ${stats.total} 条\n`));
93
+ log(io, chalk.red(`📊 失败统计\n`));
94
+ log(io, chalk.bold(` 总计: ${stats.total} 条\n`));
90
95
 
91
- console.log(chalk.bold(' 按类型:'));
96
+ log(io, chalk.bold(' 按类型:'));
92
97
  for (const [type, count] of Object.entries(stats.byType)) {
93
- console.log(` ${type}: ${count}`);
98
+ log(io, ` ${type}: ${count}`);
94
99
  }
95
100
 
96
- console.log(chalk.bold('\n 按等级:'));
101
+ log(io, chalk.bold('\n 按等级:'));
97
102
  for (const [level, count] of Object.entries(stats.byLevel)) {
98
103
  const color = level === 'L4' ? chalk.red : level === 'L3' ? chalk.yellow : chalk.gray;
99
- console.log(` ${color(level)}: ${count}`);
104
+ log(io, ` ${color(level)}: ${count}`);
100
105
  }
106
+ return { kind: 'ok' };
101
107
  }
102
108
 
103
109
  /**
104
110
  * 清空失败记录
105
111
  */
106
- export async function failureClear(options: FailureOptions): Promise<void> {
112
+ export async function failureClear(options: FailureOptions, io: CommandIO = processIO): Promise<CommandResult> {
107
113
  const recorder = getRecorder(options.projectPath);
108
114
  const stats = await recorder.getStats();
109
115
 
110
116
  await recorder.clear();
111
117
 
112
118
  if (options.json) {
113
- console.log(JSON.stringify({ cleared: stats.total }));
114
- return;
119
+ log(io, JSON.stringify({ cleared: stats.total }));
120
+ return { kind: 'ok' };
115
121
  }
116
122
 
117
- console.log(chalk.green(`✅ 已清空 ${stats.total} 条失败记录`));
123
+ log(io, chalk.green(`✅ 已清空 ${stats.total} 条失败记录`));
124
+ return { kind: 'ok' };
118
125
  }