@aibyzero/cm-workflow 0.17.0 → 0.18.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 (372) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/AGENTS.md +27 -0
  3. package/CHANGELOG.md +230 -1
  4. package/CONTRIBUTING.md +47 -0
  5. package/README.md +21 -3
  6. package/THIRD_PARTY_NOTICES.md +13 -0
  7. package/VERSION +1 -1
  8. package/compat/claude-commands/cm-challenge.md +3 -0
  9. package/docs/architecture.md +40 -13
  10. package/docs/cm-control-policy-v2.md +127 -9
  11. package/docs/fixes/20261013-claude-preinit-ui-invalidate.md +48 -0
  12. package/docs/installation.md +310 -4
  13. package/docs/js-workflow-control.md +153 -16
  14. package/docs/live-evidence-drivers.md +28 -4
  15. package/docs/out-of-scope/README.md +25 -0
  16. package/docs/out-of-scope/background-supervisor.md +32 -0
  17. package/docs/reviewed-integration.md +48 -0
  18. package/docs/user-guide.md +50 -21
  19. package/install-codex.sh +331 -18
  20. package/install.ps1 +28 -2
  21. package/install.sh +321 -17
  22. package/package.json +2 -1
  23. package/runtime/js/cm-ai/batch-location.mjs +55 -0
  24. package/runtime/js/cm-ai/batch-plan.mjs +242 -0
  25. package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
  26. package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
  27. package/runtime/js/cm-ai/claude-review-stream.mjs +94 -21
  28. package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
  29. package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
  30. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
  31. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
  32. package/runtime/js/cm-ai/codex-config.mjs +6 -2
  33. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
  34. package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
  35. package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
  36. package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
  37. package/runtime/js/cm-ai/control-policy.mjs +24 -6
  38. package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
  39. package/runtime/js/cm-ai/drive-core.mjs +236 -34
  40. package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
  41. package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
  42. package/runtime/js/cm-ai/effect-contract.mjs +11 -2
  43. package/runtime/js/cm-ai/execution-policy.mjs +3 -1
  44. package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
  45. package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
  46. package/runtime/js/cm-ai/execution-store.mjs +60 -17
  47. package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
  48. package/runtime/js/cm-ai/host-check.mjs +14 -6
  49. package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
  50. package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
  51. package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
  52. package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
  53. package/runtime/js/cm-ai/host-replay.mjs +148 -0
  54. package/runtime/js/cm-ai/host-session.mjs +42 -9
  55. package/runtime/js/cm-ai/host-stage-observer.mjs +26 -0
  56. package/runtime/js/cm-ai/host-tool-bridge.mjs +22 -9
  57. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
  58. package/runtime/js/cm-ai/host.mjs +1 -1
  59. package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
  60. package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
  61. package/runtime/js/cm-ai/live-evidence.mjs +28 -6
  62. package/runtime/js/cm-ai/operator-guidance.mjs +63 -30
  63. package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
  64. package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
  65. package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
  66. package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
  67. package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
  68. package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
  69. package/runtime/js/cm-ai/review-package.mjs +79 -7
  70. package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
  71. package/runtime/js/cm-ai/review-presentation.mjs +177 -8
  72. package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
  73. package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
  74. package/runtime/js/cm-ai/scope-revision.mjs +38 -0
  75. package/runtime/js/cm-ai/specification-material.mjs +2 -2
  76. package/runtime/js/cm-ai/task-runner.mjs +247 -41
  77. package/runtime/js/cm-ai/verification-auto.mjs +38 -0
  78. package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
  79. package/runtime/js/cm-ai/worker-claude.mjs +35 -13
  80. package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
  81. package/runtime/js/cm-ai/worker-codex.mjs +41 -7
  82. package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
  83. package/runtime/js/cm-fix/cause-package.mjs +46 -1
  84. package/runtime/js/cm-fix/command-correction.mjs +37 -0
  85. package/runtime/js/cm-fix/cooperative.mjs +12 -0
  86. package/runtime/js/cm-fix/dossier.mjs +8 -2
  87. package/runtime/js/cm-fix/execution.mjs +578 -100
  88. package/runtime/js/cm-fix/final-review.mjs +39 -8
  89. package/runtime/js/cm-fix/finish.mjs +15 -11
  90. package/runtime/js/cm-fix/host-review.mjs +65 -10
  91. package/runtime/js/cm-fix/host.mjs +35 -12
  92. package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
  93. package/runtime/js/cm-fix/metrics.mjs +18 -5
  94. package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
  95. package/runtime/js/cm-fix/regression.mjs +16 -7
  96. package/runtime/js/cm-fix/repair.mjs +29 -8
  97. package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
  98. package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
  99. package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
  100. package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
  101. package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
  102. package/runtime/js/cm-fix/review-verification.mjs +214 -0
  103. package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
  104. package/runtime/js/cm-fix/start.mjs +6 -3
  105. package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
  106. package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
  107. package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
  108. package/runtime/js/cm-prd/accepted-design.mjs +8 -0
  109. package/runtime/js/cm-prd/analysis.mjs +13 -9
  110. package/runtime/js/cm-prd/change.mjs +37 -16
  111. package/runtime/js/cm-prd/draft-save.mjs +13 -6
  112. package/runtime/js/cm-prd/draft.mjs +31 -3
  113. package/runtime/js/cm-prd/failed-correction.mjs +19 -3
  114. package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
  115. package/runtime/js/cm-prd/review-correction.mjs +6 -4
  116. package/runtime/js/cm-prd/review-disposition.mjs +7 -1
  117. package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
  118. package/runtime/js/cm-prd/self-check.mjs +125 -6
  119. package/runtime/js/cm-prd/session.mjs +30 -1
  120. package/runtime/js/cm-prd/summary.mjs +38 -17
  121. package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
  122. package/runtime/js/cm-prd/tree-digest.mjs +34 -0
  123. package/runtime/js/cm-prd/validation-reason.mjs +8 -4
  124. package/runtime/js/cm-security/scan.mjs +1 -1
  125. package/runtime/js/commander/decision.mjs +44 -0
  126. package/runtime/js/commander/dispatch-registry.mjs +110 -0
  127. package/runtime/js/commander/ledger.mjs +265 -0
  128. package/runtime/js/commander/preflight.mjs +107 -0
  129. package/runtime/js/notify-later.mjs +13 -0
  130. package/runtime/js/notify-send.mjs +6 -2
  131. package/runtime/js/notify.mjs +570 -63
  132. package/runtime/js/review-findings.mjs +38 -0
  133. package/runtime/js/session-boundary.mjs +56 -0
  134. package/runtime/js/session-handoff.mjs +68 -0
  135. package/runtime/js/spec-task-line.mjs +27 -13
  136. package/runtime/js/specs-status.mjs +1 -1
  137. package/runtime/js/task-scope.mjs +197 -0
  138. package/runtime/logging.md +6 -1
  139. package/runtime/model-efficiency.md +69 -10
  140. package/runtime/orchestration.md +3 -1
  141. package/runtime/project-learning.md +2 -0
  142. package/runtime/review.md +12 -2
  143. package/runtime/test-contract.md +1 -0
  144. package/scripts/ci-test-weights.json +3 -0
  145. package/scripts/cm-ai-admission.mjs +11 -5
  146. package/scripts/cm-ai-admission.test.mjs +23 -2
  147. package/scripts/cm-ai-batch-drive.mjs +79 -18
  148. package/scripts/cm-ai-batch-drive.test.mjs +169 -3
  149. package/scripts/cm-ai-batch-host.mjs +38 -9
  150. package/scripts/cm-ai-batch-host.test.mjs +27 -14
  151. package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
  152. package/scripts/cm-ai-batch-location.test.mjs +57 -0
  153. package/scripts/cm-ai-batch-plan.mjs +52 -0
  154. package/scripts/cm-ai-batch-plan.test.mjs +397 -0
  155. package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
  156. package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
  157. package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
  158. package/scripts/cm-ai-batch-run.mjs +483 -63
  159. package/scripts/cm-ai-batch-run.test.mjs +23 -4
  160. package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
  161. package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
  162. package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
  163. package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
  164. package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
  165. package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
  166. package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
  167. package/scripts/cm-ai-control-launch.test.mjs +21 -0
  168. package/scripts/cm-ai-control-policy.test.mjs +82 -0
  169. package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
  170. package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
  171. package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
  172. package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
  173. package/scripts/cm-ai-development-rework.test.mjs +423 -0
  174. package/scripts/cm-ai-drive-bootstrap-rules.test.mjs +3 -2
  175. package/scripts/cm-ai-drive.mjs +73 -17
  176. package/scripts/cm-ai-drive.test.mjs +37 -5
  177. package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
  178. package/scripts/cm-ai-host-fixture.mjs +9 -6
  179. package/scripts/cm-ai-host-protected.test.mjs +1 -1
  180. package/scripts/cm-ai-host.mjs +60 -19
  181. package/scripts/cm-ai-host.test.mjs +15 -0
  182. package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
  183. package/scripts/cm-ai-integration-independence.test.mjs +23 -0
  184. package/scripts/cm-ai-integration-launch.test.mjs +240 -0
  185. package/scripts/cm-ai-integration-preview.mjs +41 -0
  186. package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
  187. package/scripts/cm-ai-nested-execution.test.mjs +29 -1
  188. package/scripts/cm-ai-operator-guidance.test.mjs +71 -0
  189. package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
  190. package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
  191. package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
  192. package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
  193. package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
  194. package/scripts/cm-ai-review-failure.test.mjs +150 -5
  195. package/scripts/cm-ai-review-timeout.test.mjs +20 -0
  196. package/scripts/cm-ai-run.mjs +88 -21
  197. package/scripts/cm-ai-scope-revision.test.mjs +341 -0
  198. package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
  199. package/scripts/cm-ai-supersede.test.mjs +28 -0
  200. package/scripts/cm-ai-verification-auto.test.mjs +99 -0
  201. package/scripts/cm-announce-hook.mjs +35 -8
  202. package/scripts/cm-announce-hook.test.mjs +25 -0
  203. package/scripts/cm-challenge.test.mjs +61 -0
  204. package/scripts/cm-check-drive-files.mjs +2 -2
  205. package/scripts/cm-check-host.test.mjs +1 -1
  206. package/scripts/cm-check-runtime.sh +58 -1
  207. package/scripts/cm-claude-developer-worker.test.mjs +56 -7
  208. package/scripts/cm-claude-install-layout.test.mjs +1 -1
  209. package/scripts/cm-claude-probe.test.mjs +26 -0
  210. package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
  211. package/scripts/cm-claude-review-stream.test.mjs +49 -0
  212. package/scripts/cm-claude-worker.test.mjs +16 -0
  213. package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
  214. package/scripts/cm-codex-developer-worker.test.mjs +120 -0
  215. package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
  216. package/scripts/cm-codex-prompt-input.test.mjs +153 -0
  217. package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
  218. package/scripts/cm-commander-ledger.test.mjs +260 -0
  219. package/scripts/cm-commander-p2.test.mjs +295 -0
  220. package/scripts/cm-commander-preflight.mjs +84 -0
  221. package/scripts/cm-commander.mjs +116 -0
  222. package/scripts/cm-config-lock.mjs +35 -0
  223. package/scripts/cm-controlled-correction.test.mjs +10 -1
  224. package/scripts/cm-developer-failure-code.test.mjs +62 -0
  225. package/scripts/cm-display-task-id.test.mjs +41 -0
  226. package/scripts/cm-drive-liveness.test.mjs +83 -0
  227. package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
  228. package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
  229. package/scripts/cm-external-batch-host.test.mjs +12 -9
  230. package/scripts/cm-external-process-cleanup.test.mjs +128 -0
  231. package/scripts/cm-external-qa-fix.test.mjs +89 -7
  232. package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
  233. package/scripts/cm-failover.mjs +48 -10
  234. package/scripts/cm-failover.test.mjs +46 -0
  235. package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
  236. package/scripts/cm-fix-command-correction.mjs +17 -0
  237. package/scripts/cm-fix-command-correction.test.mjs +211 -0
  238. package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
  239. package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
  240. package/scripts/cm-fix-drive.mjs +33 -5
  241. package/scripts/cm-fix-drive.test.mjs +49 -0
  242. package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
  243. package/scripts/cm-fix-host-review.test.mjs +21 -9
  244. package/scripts/cm-fix-host.mjs +26 -8
  245. package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
  246. package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
  247. package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
  248. package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
  249. package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
  250. package/scripts/cm-fix-review-preflight.mjs +24 -0
  251. package/scripts/cm-fix-review-storage.test.mjs +233 -0
  252. package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
  253. package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
  254. package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
  255. package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
  256. package/scripts/cm-fix-review-verification.test.mjs +146 -0
  257. package/scripts/cm-fix-revision-transport.test.mjs +81 -0
  258. package/scripts/cm-fix-source-correction.test.mjs +296 -0
  259. package/scripts/cm-fix-test-type-correction.mjs +18 -0
  260. package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
  261. package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
  262. package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
  263. package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
  264. package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
  265. package/scripts/cm-fix-verification-recovery.mjs +33 -0
  266. package/scripts/cm-host-diagnostic.test.mjs +33 -0
  267. package/scripts/cm-host-liveness.test.mjs +150 -0
  268. package/scripts/cm-host-qa-executor.test.mjs +77 -0
  269. package/scripts/cm-host-replay.test.mjs +176 -0
  270. package/scripts/cm-host-stage-observer.test.mjs +41 -0
  271. package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
  272. package/scripts/cm-install-manifest.sh +351 -0
  273. package/scripts/cm-live-evidence.test.mjs +59 -1
  274. package/scripts/cm-log-event.mjs +61 -10
  275. package/scripts/cm-log-event.test.mjs +121 -1
  276. package/scripts/cm-matt-skills.mjs +576 -0
  277. package/scripts/cm-matt-skills.test.mjs +550 -0
  278. package/scripts/cm-notify-command.test.mjs +42 -10
  279. package/scripts/cm-notify.mjs +14 -10
  280. package/scripts/cm-notify.test.mjs +625 -75
  281. package/scripts/cm-patrol.mjs +4 -1
  282. package/scripts/cm-patrol.test.mjs +23 -5
  283. package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
  284. package/scripts/cm-prd-completion.test.mjs +56 -13
  285. package/scripts/cm-prd-design-phase.test.mjs +78 -8
  286. package/scripts/cm-prd-draft-save.test.mjs +12 -0
  287. package/scripts/cm-prd-draft.test.mjs +1 -1
  288. package/scripts/cm-prd-drive.mjs +13 -6
  289. package/scripts/cm-prd-drive.test.mjs +46 -2
  290. package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
  291. package/scripts/cm-prd-host.mjs +10 -5
  292. package/scripts/cm-prd-host.test.mjs +4 -2
  293. package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
  294. package/scripts/cm-prd-review-disposition.test.mjs +124 -8
  295. package/scripts/cm-prd-revision.test.mjs +1 -1
  296. package/scripts/cm-prd-self-check-revision.test.mjs +16 -1
  297. package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
  298. package/scripts/cm-prd-self-check.test.mjs +105 -5
  299. package/scripts/cm-prd-session-recovery.test.mjs +5 -3
  300. package/scripts/cm-prd-summary.test.mjs +55 -3
  301. package/scripts/cm-prd-task-grouping.test.mjs +6 -6
  302. package/scripts/cm-prd-tree-digest.test.mjs +74 -0
  303. package/scripts/cm-refactor-drive.mjs +2 -1
  304. package/scripts/cm-refactor-drive.test.mjs +9 -0
  305. package/scripts/cm-release-smoke.sh +3 -15
  306. package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
  307. package/scripts/cm-skill-hints-exam.mjs +149 -0
  308. package/scripts/cm-skill-hints-install.test.mjs +168 -0
  309. package/scripts/cm-skill-hints.exam.json +706 -0
  310. package/scripts/cm-skill-hints.json +119 -0
  311. package/scripts/cm-skill-hints.mjs +669 -0
  312. package/scripts/cm-skill-hints.test.mjs +831 -0
  313. package/scripts/cm-skill-judge.mjs +181 -0
  314. package/scripts/cm-skill-judge.test.mjs +255 -0
  315. package/scripts/cm-specs-status.test.mjs +4 -2
  316. package/scripts/cm-start-check.mjs +208 -0
  317. package/scripts/cm-start-check.test.mjs +321 -0
  318. package/scripts/cm-task-gate.mjs +150 -29
  319. package/scripts/cm-task-gate.test.mjs +73 -1
  320. package/scripts/cm-task-id-grammar.test.mjs +66 -0
  321. package/scripts/cm-task-scope.test.mjs +308 -0
  322. package/scripts/cm-test-suite.mjs +109 -0
  323. package/scripts/cm-test-suite.test.mjs +162 -0
  324. package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
  325. package/scripts/cm-upgrade-compat.test.mjs +239 -0
  326. package/scripts/cm-workflow-config.mjs +12 -2
  327. package/scripts/fixtures/fix-verification-claude.mjs +44 -0
  328. package/scripts/fixtures/host-diagnostic.mjs +33 -0
  329. package/scripts/fixtures/reviewed-integration.mjs +202 -0
  330. package/scripts/scan-public-safety.py +1 -0
  331. package/scripts/session-boundary.test.mjs +170 -0
  332. package/scripts/test-npm-install.py +14 -3
  333. package/scripts/test-shell-compat.sh +2 -0
  334. package/scripts/validate-public-repo.py +1 -0
  335. package/scripts/validate-test-cases.mjs +3 -2
  336. package/skills/cm-ai/SKILL.md +5 -2
  337. package/skills/cm-ai/references/N4-review.md +2 -1
  338. package/skills/cm-ai/references/N6-qa-eval.md +3 -1
  339. package/skills/cm-ai/references/N8-finish.md +22 -0
  340. package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
  341. package/skills/cm-ai/references/js-host-recovery.md +79 -3
  342. package/skills/cm-ai/references/js-host.md +89 -17
  343. package/skills/cm-challenge/SKILL.md +65 -0
  344. package/skills/cm-challenge/evals/README.md +18 -0
  345. package/skills/cm-challenge/evals/trigger-cases.json +20 -0
  346. package/skills/cm-challenge/evals/trigger-config.json +28 -0
  347. package/skills/cm-challenge/references/examples.md +15 -0
  348. package/skills/cm-check/SKILL.md +5 -0
  349. package/skills/cm-check/references/js-host.md +2 -0
  350. package/skills/cm-fix/SKILL.md +12 -3
  351. package/skills/cm-fix/references/command-correction.md +67 -0
  352. package/skills/cm-fix/references/isolated-review.md +54 -0
  353. package/skills/cm-fix/references/js-host.md +62 -2
  354. package/skills/cm-fix/references/test-type-correction.md +72 -0
  355. package/skills/cm-fix/references/verification-recovery.md +114 -0
  356. package/skills/cm-idea/SKILL.md +2 -0
  357. package/skills/cm-idea/references/js-host.md +2 -0
  358. package/skills/cm-notify/SKILL.md +2 -0
  359. package/skills/cm-prd/SKILL.md +12 -8
  360. package/skills/cm-prd/references/brownfield.md +8 -1
  361. package/skills/cm-prd/references/change-mode.md +6 -0
  362. package/skills/cm-prd/references/greenfield.md +4 -0
  363. package/skills/cm-prd/references/js-host.md +4 -2
  364. package/skills/cm-prd/references/spec-self-check.md +5 -1
  365. package/skills/cm-refactor/SKILL.md +8 -0
  366. package/skills/cm-refactor/references/js-host.md +2 -0
  367. package/skills/cm-test/SKILL.md +4 -0
  368. package/templates/dashboard/dashboard.html +2 -2
  369. package/templates/pixel/cm-pixel.html +1 -1
  370. package/templates/pixel/cm-pixel.sh +1 -1
  371. package/templates/pixel/dev/template.html +1 -1
  372. package/templates/statusline/cm-statusline.sh +1 -1
@@ -0,0 +1,176 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
7
+ import {captureBeforeSnapshot,replayDelivery,encodeHostReplayEvidence,notReplayed,HOST_REPLAY_EVIDENCE_PREFIX} from '../runtime/js/cm-ai/host-replay.mjs';
8
+ import {autoVerificationVerdict} from '../runtime/js/cm-ai/verification-auto.mjs';
9
+ import {splitRequirementReport} from '../runtime/js/cm-ai/requirement-evidence.mjs';
10
+
11
+ const identity={repositoryId:'replay',runId:'replay-run',taskId:'T-001',attempt:1};
12
+ // Unit tests run the check directly; production passes the same specs sandbox as the task's own checks.
13
+ const directCheck=({specsRoot,...rest})=>createHostCheck(rest);
14
+ const passed=[{id:'unit',command:['node','--test'],outcome:'passed',exitCode:0,evidence:'host check exited 0 (pass 2)'}];
15
+
16
+ function project(t){
17
+ const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-replay-test-')));
18
+ t.after(()=>fs.rmSync(root,{recursive:true,force:true}));
19
+ const code=path.join(root,'code'),specs=path.join(root,'specs');
20
+ fs.mkdirSync(path.join(code,'src'),{recursive:true});fs.mkdirSync(path.join(code,'test'));fs.mkdirSync(specs);
21
+ fs.writeFileSync(path.join(code,'package.json'),'{"type":"module"}\n');
22
+ fs.writeFileSync(path.join(code,'src/sum.js'),'export const sum=(a,b)=>0;\n');
23
+ fs.writeFileSync(path.join(code,'test/old.test.js'),"import test from 'node:test';test('old',()=>{});\n");
24
+ return {code,specs};
25
+ }
26
+ const deliver=code=>{
27
+ fs.writeFileSync(path.join(code,'src/sum.js'),'export const sum=(a,b)=>a+b;\n');
28
+ fs.writeFileSync(path.join(code,'test/sum.test.js'),"import test from 'node:test';import assert from 'node:assert';import {sum} from '../src/sum.js';test('sum',()=>assert.equal(sum(1,2),3));\n");
29
+ };
30
+ const commands=[{id:'unit',command:['node','--test']}];
31
+
32
+ test('baseline, test-files-only and full delivery: the test fails first, the real project is never written',async t=>{
33
+ const {code,specs}=project(t),scope=['src/sum.js','test/sum.test.js'];
34
+ const snapshot=captureBeforeSnapshot(code,scope);
35
+ assert.equal(snapshot.files.get('test/sum.test.js'),null);
36
+ deliver(code);
37
+ const before=fs.readFileSync(path.join(code,'src/sum.js'));
38
+ const facts=await replayDelivery({codeProject:code,specsDir:specs,snapshot,scope,tests:['test/sum.test.js'],checkCommands:commands,
39
+ timeoutMs:30000,identity,greenChecks:passed,signal:new AbortController().signal,makeCheck:directCheck});
40
+ assert.equal(facts.status,'replayed');
41
+ assert.equal(facts.baseline.outcome,'passed');
42
+ assert.equal(facts.red.outcome,'failed');assert.match(facts.red.evidence,/^unit: host check exited 1/);
43
+ assert.equal(facts.green.outcome,'passed');
44
+ assert.deepEqual(fs.readFileSync(path.join(code,'src/sum.js')),before);
45
+ assert.equal(fs.readdirSync(os.tmpdir()).some(name=>name.startsWith('cm-host-replay-')&&fs.existsSync(path.join(os.tmpdir(),name,'project','src','sum.js'))
46
+ &&fs.readFileSync(path.join(os.tmpdir(),name,'project','src','sum.js'),'utf8').includes('a+b')),false,'the private copy is removed');
47
+ const entry=encodeHostReplayEvidence({identity,facts});
48
+ assert.ok(entry.startsWith(HOST_REPLAY_EVIDENCE_PREFIX));
49
+ assert.equal(JSON.parse(entry.slice(HOST_REPLAY_EVIDENCE_PREFIX.length)).facts.red.outcome,'failed');
50
+ });
51
+
52
+ test('without declared test files there is no test-files-only run; without a snapshot or checks nothing is replayed',async t=>{
53
+ const {code,specs}=project(t),scope=['src/sum.js'];
54
+ const snapshot=captureBeforeSnapshot(code,scope);deliver(code);
55
+ const base={codeProject:code,specsDir:specs,scope,checkCommands:commands,timeoutMs:30000,identity,greenChecks:passed,
56
+ signal:new AbortController().signal,makeCheck:directCheck};
57
+ const facts=await replayDelivery({...base,snapshot,tests:[]});
58
+ assert.equal(facts.status,'replayed');assert.deepEqual(facts.red,{skipped:'no_test_files'});
59
+
60
+ assert.equal((await replayDelivery({...base,snapshot:null,tests:[]})).reason,'no_before_snapshot');
61
+ assert.equal((await replayDelivery({...base,snapshot,checkCommands:[],tests:[]})).reason,'no_host_checks');
62
+ fs.symlinkSync(path.join(code,'src/sum.js'),path.join(code,'src/link.js'));
63
+ assert.deepEqual(captureBeforeSnapshot(code,['src/link.js']),{unavailable:'snapshot_unsupported_file'});
64
+ assert.equal((await replayDelivery({...base,snapshot:{unavailable:'snapshot_unsupported_file'},tests:[]})).reason,'snapshot_unsupported_file');
65
+ assert.equal(notReplayed('multi_root',passed).green.outcome,'passed');
66
+ // A path added to the scope after the snapshot has no known prior state: not replayed, never assumed absent.
67
+ assert.equal((await replayDelivery({...base,scope:['src/sum.js','src/extra.js'],snapshot,tests:[]})).reason,'snapshot_scope_changed');
68
+ });
69
+
70
+ test('the developer report is split off the value; malformed reports are kept as invalid, not dropped silently',()=>{
71
+ const item={requirement:'RED 先失败',satisfied:true,evidence:'test/sum.test.js 在旧实现下失败'};
72
+ assert.deepEqual(splitRequirementReport({outcome:'implemented',requirements:[item]}),{value:{outcome:'implemented'},items:[item]});
73
+ assert.deepEqual(splitRequirementReport({outcome:'implemented',requirements:null}),{value:{outcome:'implemented'},items:null});
74
+ assert.deepEqual(splitRequirementReport({outcome:'implemented',requirements:[]}),{value:{outcome:'implemented'},items:null});
75
+ assert.deepEqual(splitRequirementReport({outcome:'implemented'}),{value:{outcome:'implemented'},items:null});
76
+ // An invalid report names the first broken rule, never the reported text.
77
+ assert.deepEqual(splitRequirementReport({outcome:'implemented',requirements:[{requirement:'x'}]}),
78
+ {value:{outcome:'implemented'},items:'invalid',problem:'item 1: missing satisfied'});
79
+ });
80
+
81
+ test('the auto gate checks tagged run claims against the host runs, never free text',()=>{
82
+ const replayed=(red,extra={})=>({version:1,status:'replayed',baseline:{outcome:'passed',evidence:'b'},red,green:{outcome:'passed',evidence:'g'},...extra});
83
+ const redItem={requirement:'T-002: RED 必须因占位体抛错失败',satisfied:true,evidence:'test/sum.test.js',run:'red'};
84
+ const plain={requirement:'只改 src/sum.js',satisfied:true,evidence:'diff'};
85
+ assert.deepEqual(autoVerificationVerdict({report:[redItem,plain],facts:replayed({outcome:'failed',evidence:'r'})}),
86
+ {satisfied:true,items:[redItem,plain]});
87
+ for(const [report,facts,match] of [
88
+ [null,replayed({outcome:'failed',evidence:'r'}),/没有逐条要求/],
89
+ ['invalid',replayed({outcome:'failed',evidence:'r'}),/格式不合法/],
90
+ [[{...plain,satisfied:false}],replayed({outcome:'failed',evidence:'r'}),/只改 src\/sum\.js/],
91
+ [[redItem],replayed({outcome:'passed',evidence:'r'}),/只放入测试文件时检查 passed/],
92
+ [[redItem],replayed({outcome:'unavailable',evidence:'r'}),/只放入测试文件时检查 unavailable/],
93
+ [[redItem],replayed({skipped:'no_test_files'}),/未写测试文件/],
94
+ [[redItem],notReplayed('no_before_snapshot',passed),/未实跑(no_before_snapshot)/],
95
+ [[{...plain,run:'baseline'}],notReplayed('replay_failed',passed),/没有实跑基线:replay_failed/],
96
+ [[{...plain,run:'baseline'}],replayed({skipped:'no_test_files'},{baseline:{outcome:'unavailable',evidence:'spawn_failed'}}),/基线没有跑起来:unavailable/],
97
+ [[{...plain,run:'baseline',result:'passed'}],replayed({skipped:'no_test_files'},{baseline:{outcome:'failed',evidence:'b'}}),/标记基线 passed,宿主实跑基线 failed/],
98
+ [[{...plain,run:'baseline',result:'failed'}],replayed({skipped:'no_test_files'}),/标记基线 failed,宿主实跑基线 passed/],
99
+ [[plain],{...replayed({outcome:'failed',evidence:'r'}),green:{outcome:'failed',evidence:'g'}},/全部放入后检查 failed/],
100
+ ]){
101
+ const verdict=autoVerificationVerdict({report,facts});
102
+ assert.equal(verdict.satisfied,false);assert.match(verdict.unsatisfied.join('\n'),match);
103
+ }
104
+ // Untagged text is never parsed: neither a behaviour that mentions failure nor a prose run claim.
105
+ for(const evidence of ['校验失败时显示错误','新增测试先失败后通过','基线:失败 2 项'])
106
+ assert.equal(autoVerificationVerdict({report:[{...plain,evidence}],facts:replayed({outcome:'passed',evidence:'r'})}).satisfied,true);
107
+ // A baseline tag without a result needs only a baseline that ran.
108
+ assert.equal(autoVerificationVerdict({report:[{...plain,run:'baseline'}],facts:replayed({skipped:'no_test_files'},{baseline:{outcome:'failed',evidence:'b'}})}).satisfied,true);
109
+ assert.equal(autoVerificationVerdict({report:[plain],facts:notReplayed('multi_root',passed)}).satisfied,true);
110
+ // Tags are validated (known values only); a result off a baseline item is dropped, never voids the report
111
+ // (the first real run tagged its red item with result "failed"); the handoff text drops tags.
112
+ assert.deepEqual(splitRequirementReport({outcome:'implemented',requirements:[{...plain,run:'red',result:'failed'}]}).items,[{...plain,run:'red'}]);
113
+ assert.deepEqual(splitRequirementReport({outcome:'implemented',requirements:[{...plain,result:'passed'}]}).items,[plain]);
114
+ assert.equal(splitRequirementReport({outcome:'implemented',requirements:[{...plain,run:'baseline',result:'green'}]}).items,'invalid');
115
+ assert.equal(splitRequirementReport({outcome:'implemented',requirements:[{...plain,run:'baseline',result:'green'}]}).problem,
116
+ 'item 1: result is not passed, failed or null');
117
+ assert.equal(splitRequirementReport({outcome:'implemented',requirements:[{...plain,run:'green'}]}).items,'invalid');
118
+ assert.deepEqual(splitRequirementReport({outcome:'implemented',requirements:[{...plain,run:null,result:null}]}).items,[plain]);
119
+ });
120
+
121
+ test('each run uses a fresh copy: a check that plants a link cannot make the host write outside the copy',async t=>{
122
+ const {code,specs}=project(t),scope=['src/sum.js','test/sum.test.js'];
123
+ const victim=path.join(path.dirname(code),'victim.txt');fs.writeFileSync(victim,'untouched\n');
124
+ const snapshot=captureBeforeSnapshot(code,scope);deliver(code);
125
+ // The baseline check replaces the test file in its copy with a link to a file outside it.
126
+ const planting=[{id:'plant',command:['node','-e',`const fs=require('fs');fs.rmSync('test/sum.test.js',{force:true});fs.symlinkSync(${JSON.stringify(victim)},'test/sum.test.js');`]}];
127
+ const facts=await replayDelivery({codeProject:code,specsDir:specs,snapshot,scope,tests:['test/sum.test.js'],checkCommands:planting,
128
+ timeoutMs:30000,identity,greenChecks:passed,signal:new AbortController().signal,makeCheck:directCheck});
129
+ assert.equal(facts.status,'replayed');assert.equal(fs.readFileSync(victim,'utf8'),'untouched\n');
130
+ // A link already on a scope path in the project is never written through.
131
+ const outside=path.join(path.dirname(code),'outside');fs.mkdirSync(outside);fs.writeFileSync(path.join(outside,'sum.js'),'outside\n');
132
+ fs.rmSync(path.join(code,'src'),{recursive:true});fs.symlinkSync(outside,path.join(code,'src'));
133
+ const linked=await replayDelivery({codeProject:code,specsDir:specs,snapshot,scope,tests:[],checkCommands:commands,
134
+ timeoutMs:30000,identity,greenChecks:passed,signal:new AbortController().signal,makeCheck:directCheck});
135
+ assert.equal(linked.reason,'scope_link');assert.equal(fs.readFileSync(path.join(outside,'sum.js'),'utf8'),'outside\n');
136
+ });
137
+
138
+ test('the baseline restores file permissions, and a failed copy leaves no private directory behind',async t=>{
139
+ const {code,specs}=project(t);
140
+ fs.writeFileSync(path.join(code,'run.sh'),'#!/bin/sh\nexit 0\n',{mode:0o644});
141
+ const snapshot=captureBeforeSnapshot(code,['run.sh']);fs.chmodSync(path.join(code,'run.sh'),0o755);
142
+ const executable=[{id:'exec',command:['node','-e',"process.exit(require('fs').statSync('run.sh').mode&0o111?0:1)"]}];
143
+ const facts=await replayDelivery({codeProject:code,specsDir:specs,snapshot,scope:['run.sh'],tests:[],checkCommands:executable,
144
+ timeoutMs:30000,identity,greenChecks:passed,signal:new AbortController().signal,makeCheck:directCheck});
145
+ assert.equal(facts.baseline.outcome,'failed','the copy has the 0644 the file had before development');
146
+ const tmp=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-replay-tmp-')));t.after(()=>fs.rmSync(tmp,{recursive:true,force:true}));
147
+ const unreadable=path.join(code,'secret.bin');fs.writeFileSync(unreadable,'x');fs.chmodSync(unreadable,0o000);
148
+ const previous=process.env.TMPDIR;process.env.TMPDIR=tmp;
149
+ try{
150
+ const failed=await replayDelivery({codeProject:code,specsDir:specs,snapshot,scope:['run.sh'],tests:[],checkCommands:executable,
151
+ timeoutMs:30000,identity,greenChecks:passed,signal:new AbortController().signal,makeCheck:directCheck});
152
+ assert.equal(failed.reason,'replay_failed');assert.deepEqual(fs.readdirSync(tmp),[]);
153
+ }finally{fs.chmodSync(unreadable,0o600);if(previous===undefined)delete process.env.TMPDIR;else process.env.TMPDIR=previous;}
154
+ });
155
+
156
+ test('a check that could read the real project is not replayed; a link that stays inside the copy is',async t=>{
157
+ const {code,specs}=project(t),scope=['src/sum.js','test/sum.test.js'];
158
+ const snapshot=captureBeforeSnapshot(code,scope);deliver(code);
159
+ const base={codeProject:code,specsDir:specs,snapshot,scope,tests:['test/sum.test.js'],timeoutMs:30000,identity,
160
+ greenChecks:passed,signal:new AbortController().signal,makeCheck:directCheck};
161
+ // A command naming the project by absolute path would run the real project.
162
+ assert.equal((await replayDelivery({...base,checkCommands:[{id:'abs',command:['node','--test',path.join(code,'test/sum.test.js')]}]})).reason,
163
+ 'absolute_project_path');
164
+ // A relative link inside the project (node_modules/.bin style) resolves inside the copy: replayed.
165
+ fs.symlinkSync('src',path.join(code,'lib'));
166
+ fs.writeFileSync(path.join(code,'test/sum.test.js'),"import test from 'node:test';import assert from 'node:assert';import {sum} from '../lib/sum.js';test('sum',()=>assert.equal(sum(1,2),3));\n");
167
+ const relative=await replayDelivery({...base,checkCommands:commands});
168
+ assert.equal(relative.status,'replayed');assert.equal(relative.red.outcome,'failed');
169
+ // An absolute link into the project, or a chain that leaves and re-enters it, would read the real project.
170
+ fs.rmSync(path.join(code,'lib'));fs.symlinkSync(path.join(code,'src'),path.join(code,'lib'));
171
+ assert.equal((await replayDelivery({...base,checkCommands:commands})).reason,'internal_link');
172
+ const alias=path.join(path.dirname(code),'alias');fs.symlinkSync(path.join(code,'src'),alias);
173
+ fs.rmSync(path.join(code,'lib'));fs.symlinkSync(path.relative(code,alias),path.join(code,'lib'));
174
+ assert.equal((await replayDelivery({...base,checkCommands:commands})).reason,'internal_link');
175
+ assert.equal(fs.readlinkSync(path.join(code,'lib')),path.relative(code,alias),'the real link is untouched');
176
+ });
@@ -0,0 +1,41 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import {withHostStageObserver,beginHostStage} from '../runtime/js/cm-ai/host-stage-observer.mjs';
7
+ import {createHostCheck} from '../runtime/js/cm-ai/host-check.mjs';
8
+
9
+ test('nested native stage preserves outer deadline and restores its identity',async()=>{
10
+ const rows=[];
11
+ await withHostStageObserver(row=>rows.push(row),async()=>{
12
+ const outer=beginHostStage('develop',1000),parent=rows.at(-1);
13
+ const inner=beginHostStage('check',5000),child=rows.at(-1);
14
+ assert.equal(child.kind,'check');assert.notEqual(child.id,parent.id);assert.equal(child.deadlineMs,parent.deadlineMs);
15
+ inner();assert.deepEqual(rows.at(-1),parent);outer();assert.equal(rows.at(-1),null);
16
+ });
17
+ });
18
+ test('overlapping operations and late stages cannot replace another operation telemetry',async()=>{
19
+ const a=[],b=[];let wake,late;
20
+ const waiting=new Promise(resolve=>{wake=resolve;});
21
+ const first=withHostStageObserver(row=>a.push(row),async()=>{late=beginHostStage('review',1000);await waiting;});
22
+ await withHostStageObserver(row=>b.push(row),async()=>{const end=beginHostStage('check',2000);assert.equal(a.at(-1).kind,'review');end();});
23
+ const before=b.length;wake();await first;late();assert.equal(b.length,before);assert.equal(a.at(-1),null);
24
+ });
25
+ test('observer failures and absent observers never alter original result or error',async()=>{
26
+ beginHostStage('check',1)();
27
+ assert.equal(await withHostStageObserver(()=>{throw Error('observer');},async()=>{beginHostStage('check',1)();return 7;}),7);
28
+ const failure=Error('original');
29
+ await assert.rejects(withHostStageObserver(()=>{throw Error('observer');},async()=>{beginHostStage('review',1);throw failure;}),error=>error===failure);
30
+ });
31
+ test('real native checks publish a distinct configured deadline per command without changing checks',async t=>{
32
+ const cwd=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-native-stage-')));
33
+ t.after(()=>fs.rmSync(cwd,{recursive:true,force:true}));const rows=[];
34
+ const check=createHostCheck({cwd,timeoutMs:2500,commands:['first','second'].map(id=>({id,command:[process.execPath,'-e','0']}))});
35
+ const result=await withHostStageObserver(row=>rows.push(row),()=>check({identity:{repositoryId:'stage-fixture',runId:'stage-fixture-run',taskId:'T-001',attempt:1}},{signal:new AbortController().signal}));
36
+ assert.deepEqual(result.map(row=>row.outcome),['passed','passed']);
37
+ const stages=rows.filter(Boolean);assert.equal(stages.length,2);
38
+ assert.equal(new Set(stages.map(row=>row.id)).size,2);
39
+ for(const row of stages){assert.equal(row.kind,'check');assert.equal(row.deadlineMs-Date.parse(row.startedAt),2500);assert.deepEqual(Object.keys(row).sort(),['deadlineMs','id','kind','startedAt']);}
40
+ assert.equal(rows.at(-1),null);
41
+ });