@aibyzero/cm-workflow 0.10.5

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 (448) hide show
  1. package/.codex-plugin/plugin.json +30 -0
  2. package/AGENTS.md +74 -0
  3. package/CONTRIBUTING.md +62 -0
  4. package/LICENSE +21 -0
  5. package/README.md +263 -0
  6. package/SECURITY.md +49 -0
  7. package/THIRD_PARTY_NOTICES.md +29 -0
  8. package/VERSION +1 -0
  9. package/agents/cm-backend-agent.md +34 -0
  10. package/agents/cm-contract-agent.md +34 -0
  11. package/agents/cm-database-agent.md +34 -0
  12. package/agents/cm-frontend-agent.md +33 -0
  13. package/agents/cm-miniprogram-agent.md +33 -0
  14. package/agents/cm-ui-agent.md +34 -0
  15. package/assets/docs/command-picker-mobile.svg +56 -0
  16. package/assets/docs/command-picker.svg +56 -0
  17. package/assets/docs/user-guide-hero-mobile.svg +35 -0
  18. package/assets/docs/user-guide-hero.svg +36 -0
  19. package/assets/readme/delivery-flow.svg +86 -0
  20. package/assets/readme/hero.svg +77 -0
  21. package/assets/readme/recovery-record.svg +73 -0
  22. package/assets/readme/test-evidence.svg +64 -0
  23. package/compat/claude-commands/cm-ai.md +3 -0
  24. package/compat/claude-commands/cm-check.md +3 -0
  25. package/compat/claude-commands/cm-fix.md +3 -0
  26. package/compat/claude-commands/cm-idea.md +3 -0
  27. package/compat/claude-commands/cm-init.md +3 -0
  28. package/compat/claude-commands/cm-prd.md +3 -0
  29. package/compat/claude-commands/cm-refactor.md +3 -0
  30. package/compat/claude-commands/cm-test.md +3 -0
  31. package/docs/architecture.md +155 -0
  32. package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-a1-handoff.json +57 -0
  33. package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-a2-handoff.json +58 -0
  34. package/docs/fixes/.reviews/fix-cancel-throw-T-FIX-cancel-throw-r1.md +121 -0
  35. package/docs/fixes/.reviews/fix-cancel-throw-v2-T-FIX-cancel-throw-v2-a1-handoff.json +56 -0
  36. package/docs/fixes/.reviews/fix-cancel-throw-v2-T-FIX-cancel-throw-v2-r1.md +100 -0
  37. package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-a1-handoff.json +61 -0
  38. package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-a2-handoff.json +63 -0
  39. package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-r1.md +58 -0
  40. package/docs/fixes/.reviews/fix-cm-js-n1n2-admission-successor-T-FIX-cm-js-n1n2-admission-successor-r2.md +55 -0
  41. package/docs/fixes/.reviews/fix-f01-dual-failure-terminal-T-FIX-f01-dual-failure-terminal-a1-handoff.json +65 -0
  42. package/docs/fixes/.reviews/fix-f01-dual-failure-terminal-T-FIX-f01-dual-failure-terminal-r1.md +88 -0
  43. package/docs/fixes/.reviews/fix-manifest-runtime-checkbox-drift-r1.md +33 -0
  44. package/docs/fixes/.reviews/fix-manifest-runtime-checkbox-drift-r2.md +31 -0
  45. package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-a1-handoff.json +56 -0
  46. package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-a2-handoff.json +85 -0
  47. package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-r1.md +53 -0
  48. package/docs/fixes/.reviews/fix-model-call-boundary-identity-T-FIX-model-call-boundary-identity-r2.md +80 -0
  49. package/docs/fixes/.reviews/fix-review-evidence-scope-honesty-T-FIX-review-evidence-scope-honesty-a1-handoff.json +35 -0
  50. package/docs/fixes/.reviews/fix-review-evidence-scope-honesty-T-FIX-review-evidence-scope-honesty-r1.md +33 -0
  51. package/docs/fixes/.reviews/fix-windows-cp1252-log-output-r1.md +30 -0
  52. package/docs/fixes/.reviews/fix-windows-cp1252-log-output-r2.md +16 -0
  53. package/docs/fixes/.reviews/openai-compatible-depth-fixture-T-FIX-openai-compatible-depth-fixture-a1-handoff.json +40 -0
  54. package/docs/fixes/.reviews/openai-compatible-depth-fixture-T-FIX-openai-compatible-depth-fixture-r1.md +30 -0
  55. package/docs/fixes/20260729-windows-cp1252-log-output.md +65 -0
  56. package/docs/fixes/20260804-manifest-runtime-checkbox-drift.md +67 -0
  57. package/docs/fixes/20260806-model-call-boundary-identity.md +80 -0
  58. package/docs/fixes/20260807-prelanding-integrity.md +58 -0
  59. package/docs/fixes/20260826-openai-compatible-depth-fixture.md +39 -0
  60. package/docs/fixes/20260903-cm-js-n1n2-admission-r1.md +64 -0
  61. package/docs/fixes/20260903-cm-js-n1n2-admission-successor.md +83 -0
  62. package/docs/fixes/20260903-s4c1b-v3-cancel-throw.md +89 -0
  63. package/docs/fixes/20260904-f01-codex-dual-failure-terminal.md +89 -0
  64. package/docs/fixes/20260907-wip-triage-log.md +44 -0
  65. package/docs/installation.md +202 -0
  66. package/docs/js-workflow-control.md +1010 -0
  67. package/docs/sample-prd/prd-funding-rate-alert.md +42 -0
  68. package/docs/sample-specs/docs//351/234/200/346/261/202/347/244/272/344/276/213.md +24 -0
  69. package/docs/user-guide.md +526 -0
  70. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/README.md +19 -0
  71. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.excalidraw +3650 -0
  72. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.mp4 +0 -0
  73. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.png +0 -0
  74. package/docs//351/207/215/346/236/204/346/265/201/347/250/213/350/256/276/350/256/241/refactor-flow.spec.json +223 -0
  75. package/install-codex.sh +184 -0
  76. package/install.ps1 +206 -0
  77. package/install.sh +244 -0
  78. package/package.json +58 -0
  79. package/runtime/external-expert.md +302 -0
  80. package/runtime/js/cm-ai/accepted-fix.mjs +28 -0
  81. package/runtime/js/cm-ai/claude-developer-adapter.mjs +6 -0
  82. package/runtime/js/cm-ai/claude-review-adapter.mjs +16 -0
  83. package/runtime/js/cm-ai/claude-review-stream.mjs +53 -0
  84. package/runtime/js/cm-ai/claude-tool-preview.mjs +107 -0
  85. package/runtime/js/cm-ai/cm-ai-admission.mjs +353 -0
  86. package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +217 -0
  87. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +538 -0
  88. package/runtime/js/cm-ai/cm-ai-learning-handoff-writer.mjs +119 -0
  89. package/runtime/js/cm-ai/cm-ai-learning-writer.mjs +172 -0
  90. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +320 -0
  91. package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +107 -0
  92. package/runtime/js/cm-ai/code-projects.mjs +85 -0
  93. package/runtime/js/cm-ai/codex-config.mjs +48 -0
  94. package/runtime/js/cm-ai/codex-developer-adapter.mjs +5 -0
  95. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +6 -0
  96. package/runtime/js/cm-ai/codex-developer-output.schema.json +37 -0
  97. package/runtime/js/cm-ai/codex-review-adapter.mjs +73 -0
  98. package/runtime/js/cm-ai/contracts.mjs +156 -0
  99. package/runtime/js/cm-ai/developer-adapter.mjs +93 -0
  100. package/runtime/js/cm-ai/durable-runner-state.mjs +504 -0
  101. package/runtime/js/cm-ai/effect-contract.mjs +102 -0
  102. package/runtime/js/cm-ai/execution-platform.mjs +7 -0
  103. package/runtime/js/cm-ai/execution-store.mjs +211 -0
  104. package/runtime/js/cm-ai/fix-code-association.mjs +40 -0
  105. package/runtime/js/cm-ai/gate-bridge.mjs +25 -0
  106. package/runtime/js/cm-ai/host-bootstrap.mjs +170 -0
  107. package/runtime/js/cm-ai/host-check.mjs +89 -0
  108. package/runtime/js/cm-ai/host-conversation-execution.mjs +125 -0
  109. package/runtime/js/cm-ai/host-documentation.mjs +40 -0
  110. package/runtime/js/cm-ai/host-handoff.mjs +71 -0
  111. package/runtime/js/cm-ai/host-project-execution.mjs +58 -0
  112. package/runtime/js/cm-ai/host-qa-executor.mjs +238 -0
  113. package/runtime/js/cm-ai/host-qa-fix-owner.mjs +131 -0
  114. package/runtime/js/cm-ai/host-qa-fix.mjs +30 -0
  115. package/runtime/js/cm-ai/host-qa-policy.mjs +70 -0
  116. package/runtime/js/cm-ai/host-review-authority.mjs +36 -0
  117. package/runtime/js/cm-ai/host-review-file.mjs +56 -0
  118. package/runtime/js/cm-ai/host-role-routing.mjs +41 -0
  119. package/runtime/js/cm-ai/host-session.mjs +96 -0
  120. package/runtime/js/cm-ai/host-tool-bridge.mjs +53 -0
  121. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +45 -0
  122. package/runtime/js/cm-ai/host.mjs +20 -0
  123. package/runtime/js/cm-ai/index.mjs +7 -0
  124. package/runtime/js/cm-ai/provider-review-observation.mjs +86 -0
  125. package/runtime/js/cm-ai/qa-fix-definition.mjs +21 -0
  126. package/runtime/js/cm-ai/review-evidence-file.mjs +38 -0
  127. package/runtime/js/cm-ai/review-package.mjs +426 -0
  128. package/runtime/js/cm-ai/review-result.schema.json +40 -0
  129. package/runtime/js/cm-ai/review-runner.mjs +35 -0
  130. package/runtime/js/cm-ai/task-commit-codec.mjs +54 -0
  131. package/runtime/js/cm-ai/task-commit.mjs +201 -0
  132. package/runtime/js/cm-ai/task-owner.mjs +97 -0
  133. package/runtime/js/cm-ai/task-runner.mjs +766 -0
  134. package/runtime/js/cm-ai/tool-preview.mjs +205 -0
  135. package/runtime/js/cm-ai/worker-claude.mjs +104 -0
  136. package/runtime/js/cm-ai/worker-codex-developer.mjs +124 -0
  137. package/runtime/js/cm-ai/worker-codex.mjs +143 -0
  138. package/runtime/js/cm-check/host.mjs +101 -0
  139. package/runtime/js/cm-fix/baseline.mjs +70 -0
  140. package/runtime/js/cm-fix/cause-evidence.mjs +24 -0
  141. package/runtime/js/cm-fix/cause-invocation.mjs +40 -0
  142. package/runtime/js/cm-fix/cause-package.mjs +68 -0
  143. package/runtime/js/cm-fix/dossier.mjs +140 -0
  144. package/runtime/js/cm-fix/execution.mjs +1549 -0
  145. package/runtime/js/cm-fix/final-review-evidence.mjs +20 -0
  146. package/runtime/js/cm-fix/final-review.mjs +156 -0
  147. package/runtime/js/cm-fix/finish.mjs +124 -0
  148. package/runtime/js/cm-fix/handoff.mjs +64 -0
  149. package/runtime/js/cm-fix/host-review.mjs +38 -0
  150. package/runtime/js/cm-fix/host.mjs +96 -0
  151. package/runtime/js/cm-fix/investigation.mjs +25 -0
  152. package/runtime/js/cm-fix/layout.mjs +17 -0
  153. package/runtime/js/cm-fix/learning-writeback.mjs +86 -0
  154. package/runtime/js/cm-fix/learning.mjs +31 -0
  155. package/runtime/js/cm-fix/metrics.mjs +75 -0
  156. package/runtime/js/cm-fix/progress.mjs +64 -0
  157. package/runtime/js/cm-fix/protected-edits.mjs +95 -0
  158. package/runtime/js/cm-fix/qa-source.mjs +58 -0
  159. package/runtime/js/cm-fix/red-test.mjs +92 -0
  160. package/runtime/js/cm-fix/regression-evidence.mjs +64 -0
  161. package/runtime/js/cm-fix/regression.mjs +41 -0
  162. package/runtime/js/cm-fix/repair.mjs +95 -0
  163. package/runtime/js/cm-fix/reproduce.mjs +54 -0
  164. package/runtime/js/cm-fix/retrospective.mjs +41 -0
  165. package/runtime/js/cm-fix/review-baseline.mjs +47 -0
  166. package/runtime/js/cm-fix/start.mjs +49 -0
  167. package/runtime/js/cm-fix/test-author.mjs +63 -0
  168. package/runtime/js/cm-fix/visual.mjs +72 -0
  169. package/runtime/js/cm-fix/walkthrough.mjs +126 -0
  170. package/runtime/js/cm-idea/session.mjs +79 -0
  171. package/runtime/js/cm-init/draft-generation.mjs +66 -0
  172. package/runtime/js/cm-init/draft-inspection.mjs +70 -0
  173. package/runtime/js/cm-init/project-analysis.mjs +60 -0
  174. package/runtime/js/cm-init/project-scan.mjs +55 -0
  175. package/runtime/js/cm-init/review-evidence.mjs +80 -0
  176. package/runtime/js/cm-prd/accepted-design.mjs +46 -0
  177. package/runtime/js/cm-prd/analysis.mjs +260 -0
  178. package/runtime/js/cm-prd/change.mjs +268 -0
  179. package/runtime/js/cm-prd/correction-check.mjs +49 -0
  180. package/runtime/js/cm-prd/design-risk.mjs +30 -0
  181. package/runtime/js/cm-prd/disposition-plan.mjs +33 -0
  182. package/runtime/js/cm-prd/draft-save.mjs +122 -0
  183. package/runtime/js/cm-prd/draft.mjs +70 -0
  184. package/runtime/js/cm-prd/materials.mjs +48 -0
  185. package/runtime/js/cm-prd/review-correction.mjs +158 -0
  186. package/runtime/js/cm-prd/review-disposition.mjs +96 -0
  187. package/runtime/js/cm-prd/review-findings.mjs +36 -0
  188. package/runtime/js/cm-prd/review-host.mjs +48 -0
  189. package/runtime/js/cm-prd/review-preparation.mjs +49 -0
  190. package/runtime/js/cm-prd/review-publication.mjs +56 -0
  191. package/runtime/js/cm-prd/self-check.mjs +75 -0
  192. package/runtime/js/cm-prd/session.mjs +74 -0
  193. package/runtime/js/cm-prd/summary.mjs +133 -0
  194. package/runtime/js/cm-refactor/host.mjs +2 -0
  195. package/runtime/js/cm-refactor/records.mjs +86 -0
  196. package/runtime/js/cm-refactor/workflow.mjs +478 -0
  197. package/runtime/js/cm-test/declared-command.mjs +32 -0
  198. package/runtime/js/cm-test/host.mjs +319 -0
  199. package/runtime/js/cm-test/logic-results.mjs +39 -0
  200. package/runtime/js/cm-test/recovery.mjs +58 -0
  201. package/runtime/js/cm-test/session.mjs +56 -0
  202. package/runtime/js/cm-test/source-snapshot.mjs +136 -0
  203. package/runtime/logging.md +207 -0
  204. package/runtime/model-efficiency.md +201 -0
  205. package/runtime/orchestration.md +113 -0
  206. package/runtime/project-context.md +43 -0
  207. package/runtime/project-learning.md +49 -0
  208. package/runtime/review.md +140 -0
  209. package/runtime/steelman-review.md +111 -0
  210. package/runtime/task-gates.md +283 -0
  211. package/runtime/task-handoff.schema.json +103 -0
  212. package/runtime/test-contract.md +212 -0
  213. package/runtime/workflow-config.md +118 -0
  214. package/runtime/workflow-routing.md +82 -0
  215. package/scripts/cm-ai-admission.mjs +50 -0
  216. package/scripts/cm-ai-admission.test.mjs +38 -0
  217. package/scripts/cm-ai-batch-host.mjs +77 -0
  218. package/scripts/cm-ai-batch-host.test.mjs +155 -0
  219. package/scripts/cm-ai-batch-run.mjs +136 -0
  220. package/scripts/cm-ai-batch-run.test.mjs +128 -0
  221. package/scripts/cm-ai-bootstrap.test.mjs +228 -0
  222. package/scripts/cm-ai-fix-integration.test.mjs +233 -0
  223. package/scripts/cm-ai-host.mjs +175 -0
  224. package/scripts/cm-ai-host.test.mjs +368 -0
  225. package/scripts/cm-ai-multi-root.test.mjs +289 -0
  226. package/scripts/cm-ai-nested-execution.test.mjs +313 -0
  227. package/scripts/cm-ai-run.mjs +293 -0
  228. package/scripts/cm-ai-run.test.mjs +336 -0
  229. package/scripts/cm-check-entry.mjs +120 -0
  230. package/scripts/cm-check-host.mjs +29 -0
  231. package/scripts/cm-check-host.test.mjs +71 -0
  232. package/scripts/cm-check-runtime.ps1 +69 -0
  233. package/scripts/cm-check-runtime.sh +910 -0
  234. package/scripts/cm-claude-probe.test.mjs +54 -0
  235. package/scripts/cm-claude-review-stream.test.mjs +45 -0
  236. package/scripts/cm-claude-worker.test.mjs +92 -0
  237. package/scripts/cm-codex-developer-adapter.test.mjs +85 -0
  238. package/scripts/cm-codex-developer-worker.test.mjs +128 -0
  239. package/scripts/cm-codex-review-progress.test.mjs +96 -0
  240. package/scripts/cm-execution-platform.test.mjs +47 -0
  241. package/scripts/cm-fix-cause-invocation.test.mjs +72 -0
  242. package/scripts/cm-fix-cause-package.test.mjs +68 -0
  243. package/scripts/cm-fix-code-association.test.mjs +55 -0
  244. package/scripts/cm-fix-entry.mjs +132 -0
  245. package/scripts/cm-fix-execution.test.mjs +63 -0
  246. package/scripts/cm-fix-final-review.test.mjs +124 -0
  247. package/scripts/cm-fix-host-review-assembly.test.mjs +34 -0
  248. package/scripts/cm-fix-host-review.test.mjs +261 -0
  249. package/scripts/cm-fix-host-sequence.test.mjs +26 -0
  250. package/scripts/cm-fix-host.mjs +89 -0
  251. package/scripts/cm-fix-host.test.mjs +105 -0
  252. package/scripts/cm-fix-learning-writeback.test.mjs +73 -0
  253. package/scripts/cm-fix-learning.test.mjs +66 -0
  254. package/scripts/cm-fix-metrics.test.mjs +58 -0
  255. package/scripts/cm-fix-no-existing-tests.test.mjs +92 -0
  256. package/scripts/cm-fix-observation-dossier.test.mjs +452 -0
  257. package/scripts/cm-fix-progress.test.mjs +45 -0
  258. package/scripts/cm-fix-protected-edits.test.mjs +54 -0
  259. package/scripts/cm-fix-qa-source.test.mjs +206 -0
  260. package/scripts/cm-fix-red-owner.test.mjs +143 -0
  261. package/scripts/cm-fix-red-test.test.mjs +38 -0
  262. package/scripts/cm-fix-regression.test.mjs +57 -0
  263. package/scripts/cm-fix-repair-owner.test.mjs +370 -0
  264. package/scripts/cm-fix-repair.test.mjs +68 -0
  265. package/scripts/cm-fix-reproduce.test.mjs +31 -0
  266. package/scripts/cm-fix-retrospective.test.mjs +46 -0
  267. package/scripts/cm-fix-review-baseline.test.mjs +54 -0
  268. package/scripts/cm-fix-review-recovery.test.mjs +197 -0
  269. package/scripts/cm-fix-test-author.test.mjs +105 -0
  270. package/scripts/cm-fix-visual-bare.test.mjs +171 -0
  271. package/scripts/cm-fix-walkthrough.test.mjs +45 -0
  272. package/scripts/cm-host-check.test.mjs +113 -0
  273. package/scripts/cm-host-documentation.test.mjs +45 -0
  274. package/scripts/cm-host-handoff.test.mjs +58 -0
  275. package/scripts/cm-host-qa-executor.test.mjs +156 -0
  276. package/scripts/cm-host-qa-policy.test.mjs +59 -0
  277. package/scripts/cm-host-review-authority.test.mjs +60 -0
  278. package/scripts/cm-host-role-routing.test.mjs +33 -0
  279. package/scripts/cm-idea-entry.mjs +104 -0
  280. package/scripts/cm-idea-host.mjs +144 -0
  281. package/scripts/cm-idea-host.test.mjs +75 -0
  282. package/scripts/cm-idea-recovery.test.mjs +90 -0
  283. package/scripts/cm-init-analysis-host.test.mjs +50 -0
  284. package/scripts/cm-init-draft-generation.test.mjs +52 -0
  285. package/scripts/cm-init-draft-inspection.test.mjs +41 -0
  286. package/scripts/cm-init-entry.mjs +170 -0
  287. package/scripts/cm-init-host.mjs +284 -0
  288. package/scripts/cm-init-host.test.mjs +231 -0
  289. package/scripts/cm-init-project-analysis.test.mjs +47 -0
  290. package/scripts/cm-init-project-scan.test.mjs +41 -0
  291. package/scripts/cm-init-revision-host.test.mjs +61 -0
  292. package/scripts/cm-init-session.test.mjs +122 -0
  293. package/scripts/cm-log-event.mjs +538 -0
  294. package/scripts/cm-log-event.py +133 -0
  295. package/scripts/cm-log-event.test.mjs +70 -0
  296. package/scripts/cm-openai-compatible-call.py +661 -0
  297. package/scripts/cm-prd-analysis.test.mjs +67 -0
  298. package/scripts/cm-prd-completion.test.mjs +190 -0
  299. package/scripts/cm-prd-design-phase.test.mjs +296 -0
  300. package/scripts/cm-prd-draft-save.test.mjs +63 -0
  301. package/scripts/cm-prd-draft.test.mjs +39 -0
  302. package/scripts/cm-prd-entry.mjs +245 -0
  303. package/scripts/cm-prd-host.mjs +273 -0
  304. package/scripts/cm-prd-host.test.mjs +169 -0
  305. package/scripts/cm-prd-materials.test.mjs +41 -0
  306. package/scripts/cm-prd-review-claim.test.mjs +42 -0
  307. package/scripts/cm-prd-review-disposition.test.mjs +196 -0
  308. package/scripts/cm-prd-review-gate.mjs +194 -0
  309. package/scripts/cm-prd-review-gate.py +26 -0
  310. package/scripts/cm-prd-review-host.test.mjs +30 -0
  311. package/scripts/cm-prd-review-preparation.test.mjs +69 -0
  312. package/scripts/cm-prd-review-publication.test.mjs +95 -0
  313. package/scripts/cm-prd-revision.test.mjs +32 -0
  314. package/scripts/cm-prd-self-check.test.mjs +23 -0
  315. package/scripts/cm-prd-sources.test.mjs +76 -0
  316. package/scripts/cm-prd-timing.py +272 -0
  317. package/scripts/cm-refactor-entry.mjs +145 -0
  318. package/scripts/cm-refactor-host.mjs +26 -0
  319. package/scripts/cm-refactor-host.test.mjs +201 -0
  320. package/scripts/cm-review-dependency-snapshot.test.mjs +67 -0
  321. package/scripts/cm-review-inventory.test.mjs +109 -0
  322. package/scripts/cm-spec-manifest.mjs +104 -0
  323. package/scripts/cm-spec-manifest.py +26 -0
  324. package/scripts/cm-task-gate.mjs +879 -0
  325. package/scripts/cm-task-gate.py +312 -0
  326. package/scripts/cm-task-gate.test.mjs +202 -0
  327. package/scripts/cm-test-declared-command.test.mjs +18 -0
  328. package/scripts/cm-test-entry.mjs +231 -0
  329. package/scripts/cm-test-host.mjs +40 -0
  330. package/scripts/cm-test-host.test.mjs +169 -0
  331. package/scripts/cm-test-logic-results.test.mjs +26 -0
  332. package/scripts/cm-test-session.test.mjs +138 -0
  333. package/scripts/cm-usage-report.py +516 -0
  334. package/scripts/cm-workflow-config.mjs +463 -0
  335. package/scripts/cm-workflow-config.test.mjs +181 -0
  336. package/scripts/cm-workflow.mjs +36 -0
  337. package/scripts/cm-workflow.test.mjs +51 -0
  338. package/scripts/cm_workflow_config.py +52 -0
  339. package/scripts/fixtures/claude-review-process.mjs +35 -0
  340. package/scripts/fixtures/codex-review-process.mjs +22 -0
  341. package/scripts/fixtures/prd-review-gate-python-oracle.py +320 -0
  342. package/scripts/fixtures/spec-manifest-python-oracle.py +172 -0
  343. package/scripts/scan-public-safety.py +117 -0
  344. package/scripts/test-cm-log-event.py +1213 -0
  345. package/scripts/test-cm-openai-compatible-call.py +1185 -0
  346. package/scripts/test-cm-prd-review-gate.py +272 -0
  347. package/scripts/test-cm-prd-timing.py +168 -0
  348. package/scripts/test-cm-usage-report.py +584 -0
  349. package/scripts/test-npm-install.py +171 -0
  350. package/scripts/test-scan-public-safety.py +76 -0
  351. package/scripts/test-shell-compat.sh +365 -0
  352. package/scripts/test-spec-manifest.py +263 -0
  353. package/scripts/test-task-gate.py +46 -0
  354. package/scripts/test-workflow-config.py +30 -0
  355. package/scripts/validate-public-repo.py +245 -0
  356. package/scripts/validate-test-cases.mjs +71 -0
  357. package/scripts/validate-test-cases.py +27 -0
  358. package/scripts/validate-test-cases.test.mjs +36 -0
  359. package/skills/cm-ai/SKILL.md +137 -0
  360. package/skills/cm-ai/references/N1-init.md +108 -0
  361. package/skills/cm-ai/references/N2-enter-feature.md +38 -0
  362. package/skills/cm-ai/references/N3-execute-task.md +123 -0
  363. package/skills/cm-ai/references/N4-review.md +103 -0
  364. package/skills/cm-ai/references/N5-mark-done.md +117 -0
  365. package/skills/cm-ai/references/N6-qa-eval.md +102 -0
  366. package/skills/cm-ai/references/N7-context.md +23 -0
  367. package/skills/cm-ai/references/N8-finish.md +103 -0
  368. package/skills/cm-ai/references/js-host.md +126 -0
  369. package/skills/cm-backend-engineer/SKILL.md +100 -0
  370. package/skills/cm-check/SKILL.md +52 -0
  371. package/skills/cm-check/references/js-host.md +44 -0
  372. package/skills/cm-contract-engineer/SKILL.md +136 -0
  373. package/skills/cm-database-engineer/SKILL.md +89 -0
  374. package/skills/cm-devops-engineer/SKILL.md +137 -0
  375. package/skills/cm-doc-syncer/SKILL.md +150 -0
  376. package/skills/cm-finance-expert/SKILL.md +85 -0
  377. package/skills/cm-fix/SKILL.md +199 -0
  378. package/skills/cm-fix/references/cross-boundary-debugging.md +44 -0
  379. package/skills/cm-fix/references/js-host.md +135 -0
  380. package/skills/cm-frontend-engineer/SKILL.md +127 -0
  381. package/skills/cm-idea/SKILL.md +55 -0
  382. package/skills/cm-idea/references/domains/trading.md +97 -0
  383. package/skills/cm-idea/references/example-prd.md +92 -0
  384. package/skills/cm-idea/references/idea-to-prd.md +282 -0
  385. package/skills/cm-idea/references/js-host.md +63 -0
  386. package/skills/cm-init/SKILL.md +191 -0
  387. package/skills/cm-init/references/js-host.md +123 -0
  388. package/skills/cm-miniprogram-engineer/SKILL.md +141 -0
  389. package/skills/cm-miniprogram-engineer/references/platform-readiness.md +58 -0
  390. package/skills/cm-miniprogram-engineer/references/release-checklist.md +59 -0
  391. package/skills/cm-prd/SKILL.md +548 -0
  392. package/skills/cm-prd/references/brownfield.md +13 -0
  393. package/skills/cm-prd/references/change-mode.md +145 -0
  394. package/skills/cm-prd/references/context-scope.md +62 -0
  395. package/skills/cm-prd/references/greenfield.md +80 -0
  396. package/skills/cm-prd/references/js-change-recovery.md +57 -0
  397. package/skills/cm-prd/references/js-host.md +98 -0
  398. package/skills/cm-prd/references/phase-timing.md +68 -0
  399. package/skills/cm-prd/references/spec-self-check.md +22 -0
  400. package/skills/cm-product-manager/SKILL.md +83 -0
  401. package/skills/cm-qa-engineer/SKILL.md +142 -0
  402. package/skills/cm-refactor/SKILL.md +236 -0
  403. package/skills/cm-refactor/references/js-batch.md +75 -0
  404. package/skills/cm-refactor/references/js-host.md +78 -0
  405. package/skills/cm-test/SKILL.md +288 -0
  406. package/skills/cm-test/references/js-host.md +118 -0
  407. package/skills/cm-ui-engineer/SKILL.md +105 -0
  408. package/skills/codebase-context/SKILL.md +489 -0
  409. package/skills/darwin-skill/NOTICE.md +26 -0
  410. package/skills/darwin-skill/README.md +272 -0
  411. package/skills/darwin-skill/SKILL.md +492 -0
  412. package/skills/darwin-skill/references/runtime-neutrality.md +68 -0
  413. package/skills/darwin-skill/references/skilllens-evidence.md +142 -0
  414. package/skills/darwin-skill/scripts/screenshot.mjs +71 -0
  415. package/skills/darwin-skill/templates/result-card-dark.html +698 -0
  416. package/skills/darwin-skill/templates/result-card-white.html +444 -0
  417. package/skills/darwin-skill/templates/result-card.html +616 -0
  418. package/skills/external-expert/SKILL.md +250 -0
  419. package/templates/arch-reference.md +68 -0
  420. package/templates/auto-update/cm-announce.sh +19 -0
  421. package/templates/auto-update/cm-update.sh +274 -0
  422. package/templates/cm-workflow.yml +52 -0
  423. package/templates/dashboard/dashboard.html +153 -0
  424. package/templates/dashboard/serve.sh +10 -0
  425. package/templates/hooks/pre-commit-cm-task-check +67 -0
  426. package/templates/pixel/cm-pixel.html +388 -0
  427. package/templates/pixel/cm-pixel.sh +212 -0
  428. package/templates/pixel/dev/README.md +20 -0
  429. package/templates/pixel/dev/atlas-preview.png +0 -0
  430. package/templates/pixel/dev/build.py +55 -0
  431. package/templates/pixel/dev/sheets/roguelikeChar_transparent.png +0 -0
  432. package/templates/pixel/dev/sheets/roguelikeCity_tilemap.png +0 -0
  433. package/templates/pixel/dev/sheets/roguelikeIndoor_transparent.png +0 -0
  434. package/templates/pixel/dev/template.html +388 -0
  435. package/templates/pixel/serve.sh +12 -0
  436. package/templates/refactor/cm-refactor-denies.json +14 -0
  437. package/templates/rules/backend-api.md +36 -0
  438. package/templates/rules/coding-style.md +44 -0
  439. package/templates/rules/database.md +27 -0
  440. package/templates/rules/finance.md +32 -0
  441. package/templates/rules/frontend.md +32 -0
  442. package/templates/rules/git-workflow.md +25 -0
  443. package/templates/rules/miniprogram.md +31 -0
  444. package/templates/rules/security.md +31 -0
  445. package/templates/rules/smart-contract.md +28 -0
  446. package/templates/rules/testing.md +36 -0
  447. package/templates/statusline/cm-statusline.sh +73 -0
  448. package/templates/ui-lens/cm-ui-lens-extract.mjs +55 -0
@@ -0,0 +1,207 @@
1
+ # CM run logging contract
2
+
3
+ CM records workflow events at two levels:
4
+
5
+ ```text
6
+ {SPECS_DIR}/运行日志.jsonl
7
+ ${CM_WORKFLOW_LOG_HOME:-~/.cm-workflow/logs}/
8
+ ├── index.jsonl
9
+ └── runs/YYYY-MM/{run_id}.jsonl
10
+ ```
11
+
12
+ The specs log is the portable recovery and audit source of truth. The user-global
13
+ tree is a private analysis mirror across projects, sessions, Codex, and Claude
14
+ Code. It is not telemetry and nothing is transmitted off the machine.
15
+
16
+ ## Writer
17
+
18
+ Resolve `scripts/cm-log-event.py` from the active CM Workflow root. It is the
19
+ cross-platform lock adapter and forwards the held-lock write to the authoritative
20
+ `scripts/cm-log-event.mjs` implementation; both use only bundled runtimes:
21
+
22
+ ```bash
23
+ python3 "{CM_WORKFLOW_ROOT}/scripts/cm-log-event.py" \
24
+ --workflow cm-ai \
25
+ --event task_start \
26
+ --runtime codex \
27
+ --project-root "{CODE_PROJECT}" \
28
+ --specs-dir "{SPECS_DIR}" \
29
+ --detail "正在开发登录接口" \
30
+ --data-json '{"node":"N3","feature":"1.login","task":"T-003","role":"coder"}'
31
+ ```
32
+
33
+ Use `runtime: codex`, `claude`, or `unknown` according to the runtime actually
34
+ observed. Optional `role` and model values describe visible configuration only;
35
+ never infer an exact backend model. When a requested model is routed to a
36
+ different effective model, record `requested_model`, `effective_model`,
37
+ `provider`, `purpose`, and `model_equivalent`; never report an alias as the
38
+ effective model.
39
+
40
+ The JavaScript writer prints one compact JSON result containing `event_id`, `run_id`,
41
+ project/global log paths, `global_written`, `pointer_written`, `deduplicated`,
42
+ and `degraded`.
43
+ Preserve the returned `run_id` for a standalone flow. With a specs directory,
44
+ `.cm-run.json` stores the active run id so a resumed session automatically
45
+ continues the same run. If that pointer is unavailable, the writer reconstructs
46
+ the active/terminal state from the authoritative project log. After `run_done`,
47
+ the next `run_start` creates a new run.
48
+
49
+ ## Event envelope
50
+
51
+ Each output line contains:
52
+
53
+ ```json
54
+ {
55
+ "schema_version": 1,
56
+ "event_id": "<uuid>",
57
+ "run_id": "<stable run id>",
58
+ "at": "<ISO-8601 with timezone>",
59
+ "workflow": "cm-ai",
60
+ "event": "task_start",
61
+ "phase": "start",
62
+ "runtime": "codex",
63
+ "project": "my-app",
64
+ "project_path": "<canonical path when known>",
65
+ "specs_path": "<canonical path when known>",
66
+ "detail": "<one plain-language line>"
67
+ }
68
+ ```
69
+
70
+ Existing project logs without these fields remain valid historical input. New
71
+ events use this envelope. Event-specific fields are supplied by `--data-json`
72
+ and may not replace envelope fields.
73
+
74
+ ## Required lifecycle events
75
+
76
+ | Workflow/action | Event | Phases or required data |
77
+ | --- | --- | --- |
78
+ | each workflow run | `run_start` / `run_done` | start once; terminal result in detail/data |
79
+ | PRD and approval | `spec_lifecycle` | `generated`, `awaiting_review`, `approved`, `changed` |
80
+ | PRD phase timing | `progress` | paired `start`/`complete`; operation_id, phase_name, segment |
81
+ | N1–N8 | existing node/task/review/degrade/pause/resume/decision/error/qa/done events | preserve existing semantics |
82
+ | long external, desktop, or browser step | `progress` | `start`, `checkpoint`, `complete`; operation id and observable milestone |
83
+ | any QA invocation | `test_run` | `start`, `case_start`, `case_complete`, `case_blocked`, `complete`; case counts, result, report |
84
+ | temporary resource | `resource` | `acquired`, `released`, `cleanup_failed`; unique non-secret `resource_id` per acquisition and stable `resource_kind` |
85
+ | External Expert | `external_expert` | `route`, `dispatch`, `complete`; route/mode/state/evidence metadata |
86
+ | role routing | `decision` | `phase: route`; role, adapter, requested_model, source, purpose, route_state |
87
+ | managed model-call claim | `model_call` | `claimed`; unique call_id and complete safe route identity, atomically written before HTTP |
88
+ | observed model call | `model_usage` | `complete`; the same route identity, usage_state, outcome, and verified counts when available |
89
+ | Git delivery | `delivery` | `commit`, `push`, `pull_request`; identifiers only after success |
90
+
91
+ Do not invent `push` or `pull_request` events before the remote side effect
92
+ succeeds. External Expert `dispatch` records the observed dispatch state, not
93
+ mere intent. `LOCAL` selected without AUTO or an explicit External Expert
94
+ invocation does not need an event.
95
+
96
+ Model-call usage follows `runtime/model-efficiency.md`. `model_call/claimed` is
97
+ an idempotency claim, not proof of provider completion; the matching
98
+ `model_usage/complete` records the observed outcome. The writer allows token
99
+ *counts* only on the strict `model_usage` field allowlist; credential-like token
100
+ fields remain forbidden. When a claim exists, completion must match its
101
+ `workflow`, `runtime`, `stage`, `role`, `adapter`, `requested_model`, `source`,
102
+ and `purpose`; a completed call id cannot later be claimed. A route decision is
103
+ not a model call, and a requested model alias is not an observed effective model.
104
+ The bundled `openai-compatible` completion is rejected unless its matching claim
105
+ already exists; standalone usage events remain available only to other
106
+ call-owning adapters.
107
+
108
+ ## Progress, recovery, and cleanup
109
+
110
+ Keep progress event-based. Do not add a background heartbeat, timer, or polling
111
+ service merely to make the log look active.
112
+
113
+ `cm-prd` phase timing follows `skills/cm-prd/references/phase-timing.md`. Duration comes from
114
+ paired envelope timestamps; callers do not write guessed `duration_ms`. A hard pause closes the
115
+ active segment with `outcome: awaiting_input`, and resume uses a higher segment so human wait is
116
+ not counted as active workflow time. Stages that did not run emit no timing pair.
117
+
118
+ Use the dependency-free read-only report for recent `cm-prd` runs:
119
+
120
+ ```bash
121
+ python3 "{CM_WORKFLOW_ROOT}/scripts/cm-prd-timing.py" --last 5
122
+ ```
123
+
124
+ It reads only the local global mirror, reports paired active segments, and labels incomplete pairs
125
+ instead of guessing their duration. It does not write logs or workflow state.
126
+
127
+ Use the dependency-free usage report for recent runs when call-owning adapters
128
+ have emitted verified usage events:
129
+
130
+ ```bash
131
+ python3 "{CM_WORKFLOW_ROOT}/scripts/cm-usage-report.py" --last 10
132
+ ```
133
+
134
+ It keeps unavailable calls explicit and does not estimate missing tokens or cost.
135
+ Claims without a matching valid usage completion are listed separately as
136
+ unresolved and are not counted as calls, outcomes, or Token usage.
137
+
138
+ 1. Before a potentially long external command, desktop launch, browser case, or
139
+ model turn, write `progress/start`; write `progress/checkpoint` only at an
140
+ actually observed milestone, and `progress/complete` when it ends.
141
+ 2. Every blocking browser case writes `test_run/case_start` followed by exactly
142
+ one `case_complete` or `case_blocked`. When a specs directory exists, update
143
+ `.cm-status.json` at the same checkpoints so live status and the audit log do
144
+ not disagree; standalone `$cm-test` runs do not create that file. A phased
145
+ `test_run/start` must end in `test_run/complete`; `task_done`/`run_done` are
146
+ mechanically rejected while the invocation or any case remains open.
147
+ 3. A temporary profile, process, model alias, worktree, or fixture writes
148
+ `resource/acquired` before use with `cleanup_required: true`. Its cleanup
149
+ writes `resource/released`; cleanup failure writes `resource/cleanup_failed`
150
+ and keeps the task blocked. Terminal phases require the same `resource_id`
151
+ and `resource_kind`, but do not repeat `cleanup_required`.
152
+ 4. `resource_id` identifies one acquisition lifetime, not a path, credential,
153
+ token, or secret. While the acquisition remains active, only an exact retry
154
+ reuses that ID; any distinct acquisition uses a new ID. After `released`, the
155
+ ID cannot be acquired again. A delayed exact retry remains deduplicated and
156
+ does not reopen the resource. The writer never guesses which acquisition a
157
+ delayed cleanup belongs to.
158
+ 5. The writer checks resource events in the current run before `task_done`,
159
+ legacy `done`, or `run_done`. Any latest `acquired` or `cleanup_failed`
160
+ without a later `released` blocks completion. Malformed resource events or
161
+ an unreadable authoritative log also block completion. Historical runs
162
+ without resource events remain compatible.
163
+
164
+ For recoverable operational mistakes, prefer a `warning` event. New warning and
165
+ error events include `severity`, `impact`, `recovered`, `attempt`, and `outcome`.
166
+ Use `severity: error` only when the current task cannot continue; a successful
167
+ retry is `warning` with `recovered: true`. The writer's sensitive-field rejection
168
+ remains authoritative—choose safe metadata names instead of weakening it.
169
+
170
+ ## Write and degradation rules
171
+
172
+ 1. When `{SPECS_DIR}` exists, write the project event first, then mirror the
173
+ identical event id into the global run file.
174
+ 2. A global-mirror failure appends a project-side `degrade` event with
175
+ `phase: global_log`, warns once, and returns success. The project log remains
176
+ authoritative.
177
+ 3. A project-log failure returns non-zero; do not claim the event was recorded.
178
+ 4. A standalone flow without specs has only the global destination. Global
179
+ failure returns non-zero and must be reported.
180
+ 5. `index.jsonl` contains lightweight `running` and `done` run records. Full
181
+ events stay in per-run files, avoiding one contended global stream.
182
+ 6. Global directories/files are user-private (`0700`/`0600` where supported).
183
+ The location can be changed only through the explicit
184
+ `CM_WORKFLOW_LOG_HOME` environment variable.
185
+ 7. A run keeps the global file selected at its start even when it crosses a
186
+ month boundary. Pointer failure degrades to project-log recovery and does not
187
+ invalidate events that were already durably appended.
188
+ 8. `.cm-run.lock` and the private global `.cm-write.lock` serialize concurrent
189
+ writers. Completely identical retries in one run reuse a deterministic
190
+ `event_id`; callers must include an attempt/task identifier in `data` when
191
+ two otherwise identical events are intentionally distinct.
192
+
193
+ ## Privacy and size boundary
194
+
195
+ Logs contain metadata, counts, identifiers, relative evidence references, and
196
+ short decisions. Never log:
197
+
198
+ - complete prompts or model responses;
199
+ - source, diff, document, or local-file contents;
200
+ - API keys, tokens, passwords, cookies, authorization headers, private keys, or
201
+ recovery codes;
202
+ - customer data, browser state, databases, or internal endpoints.
203
+
204
+ Keep `detail` to one line and at most 500 characters. Put test/review detail in
205
+ `.reviews/`, External Expert detail in `.external/`, and code truth in Git. The
206
+ writer rejects sensitive field names, but callers still own content
207
+ minimization and redaction.
@@ -0,0 +1,201 @@
1
+ # CM model-call efficiency contract
2
+
3
+ This contract reduces repeated API context and verbose model output without
4
+ reducing requirements, tests, independent review, approval, or evidence. It is
5
+ an execution contract for model-call owners; it is not a model gateway and does
6
+ not claim visibility into calls made by Codex, Claude, or a declared adapter.
7
+
8
+ ## Minimal role packet
9
+
10
+ Build one packet for the current role and current task. Reference durable files
11
+ by path and include only the slices needed for the decision; do not paste the
12
+ same project overview, full specs, full source files, or prior conversation into
13
+ every role call.
14
+
15
+ | Role | Required dynamic packet |
16
+ | --- | --- |
17
+ | `analyst` | current requirement, relevant business-map slice, known constraints, unresolved questions |
18
+ | `planner` | analyst result, affected modules/interfaces, approved constraints, acceptance-criteria candidates |
19
+ | `coder` | one task, mapped ACs, relevant design contracts, allowed files, verification commands, current attempt |
20
+ | `tester` | test contract/cases in scope, declared commands, environment facts, concise failure evidence when retrying |
21
+ | `reviewer` | current task handoff, task-only diff/new files, mapped ACs and rules, verification summary, pre-task dirty exclusions |
22
+ | `browser_qa` | selected browser cases, target environment/route, setup and cleanup facts, expected observable results |
23
+
24
+ Every packet states `workflow`, `stage`, `role`, objective, stable artifact
25
+ references, current identifiers, constraints, and expected output shape. A
26
+ missing required item is reported as missing; it is not replaced with guessed
27
+ context. The reviewer package in `runtime/review.md` and test evidence in
28
+ `runtime/test-contract.md` remain minimum quality requirements, not optional
29
+ content to trim.
30
+
31
+ Start targeted. Escalate only when a concrete dependency, ambiguity, changed
32
+ shared contract, or review finding shows that the packet is insufficient.
33
+ Record the reason and newly added scope; do not reread or resend unchanged full
34
+ context. `cm-prd` additionally follows its progressive context-scope contract.
35
+
36
+ ## Stable prefix
37
+
38
+ When an integration owns the prompt assembly, keep reusable instructions in
39
+ this order:
40
+
41
+ 1. safety and authorization boundary;
42
+ 2. CM workflow/stage boundary;
43
+ 3. applicable project rules;
44
+ 4. role contract;
45
+ 5. output schema.
46
+
47
+ Append the dynamic role packet after that prefix. Keep stable sections byte-for-
48
+ byte unchanged during one run when their source has not changed. Put timestamps,
49
+ attempt ids, diffs, task text, test output, and conversation history only in the
50
+ dynamic packet.
51
+
52
+ Prompt caching is optional. Enable it only through an adapter/runtime capability
53
+ that is actually available, and only report cache reads/writes returned by that
54
+ adapter. A stable prefix improves reuse even when no cache API exists, but CM
55
+ must never claim a cache hit from prefix stability alone.
56
+
57
+ ## Compact output
58
+
59
+ Ask each role for its decision artifact, not a narration of its reasoning:
60
+
61
+ - analyst/planner: deltas, decisions, open questions, AC/task mappings;
62
+ - coder: changed paths, verification, blockers, scope deviation;
63
+ - tester/browser QA: case verdicts, counts, failing identifiers, evidence paths;
64
+ - reviewer: findings first, verdict, blocking count, reviewed scope.
65
+
66
+ Do not repeat the prompt, full specs, source, diff, or successful command output.
67
+ For failures retain the exit code, failing case/command, first actionable error
68
+ and evidence path; avoid arbitrary truncation that hides the root error. Durable
69
+ detail stays in the existing specs/review/test artifacts. Main logs keep only
70
+ safe identifiers, counts, outcomes, and short summaries.
71
+
72
+ ## Verified usage event
73
+
74
+ ### Bundled OpenAI-compatible boundary
75
+
76
+ `roles.*.adapter: openai-compatible` resolves to `managed-adapter`. The role
77
+ owner invokes the bundled standard-library boundary instead of treating it as
78
+ unavailable:
79
+
80
+ ```bash
81
+ export CM_OPENAI_COMPATIBLE_ENABLED=true
82
+ export CM_OPENAI_COMPATIBLE_BASE_URL="https://models.example.invalid/v1"
83
+ export CM_OPENAI_COMPATIBLE_API_KEY="<set outside project config>"
84
+
85
+ python3 "{CM_WORKFLOW_ROOT}/scripts/cm-openai-compatible-call.py" \
86
+ --workflow cm-prd --stage design_generation --role planner --runtime codex \
87
+ --requested-model planner-default --call-id "{unique_call_id}" \
88
+ --project-root "{CODE_PROJECT}" --specs-dir "{SPECS_DIR}" \
89
+ --run-id "{run_id}" < "{ROLE_PACKET_JSON}"
90
+ ```
91
+
92
+ The stdin JSON has exactly two fields. The adapter canonicalizes the stable
93
+ prefix in the declared order, so callers do not depend on JSON key order.
94
+ `dynamic_packet` requires the seven fields shown below and permits only one
95
+ optional `context` object for role-specific material. Its workflow, stage, and
96
+ role must match the CLI identity; rejected packets create neither a claim nor an
97
+ HTTP request:
98
+
99
+ ```json
100
+ {
101
+ "stable_prefix": {
102
+ "safety": "applicable safety and authorization boundary",
103
+ "workflow": "current CM workflow and stage boundary",
104
+ "project_rules": "only the applicable stable project rules",
105
+ "role": "current role contract",
106
+ "output_schema": "compact role output schema"
107
+ },
108
+ "dynamic_packet": {
109
+ "workflow": "cm-prd",
110
+ "stage": "design_generation",
111
+ "role": "planner",
112
+ "objective": "current objective",
113
+ "identifiers": {},
114
+ "constraints": [],
115
+ "context": {"requirement": "only the task-relevant material"},
116
+ "expected_output": "compact plan"
117
+ }
118
+ }
119
+ ```
120
+
121
+ The three environment variables are invocation authority, endpoint, and secret;
122
+ none belong in `.cm-workflow.yml`, command arguments, evidence, or logs. HTTP is
123
+ accepted only for loopback fixtures; remote endpoints require HTTPS. The adapter
124
+ connects directly to the configured endpoint and does not inherit environment
125
+ proxy settings or follow redirects. It
126
+ first records an atomic `model_call/claimed` event, then sends the packet, prints
127
+ only the model's text result to stdout, and writes one verified `model_usage`
128
+ event at the same response boundary. A repeated or concurrent invocation with
129
+ the same run and `call_id` is rejected before HTTP, including a call id that
130
+ already has a completion, so retries that represent a new provider call must use
131
+ a new `call_id`. `--run-id` is required when no
132
+ `--specs-dir` is provided, keeping the claim and completion in one global-only
133
+ run. Exit states are:
134
+
135
+ - `0`: model result returned and usage event recorded;
136
+ - `1`: call/response failed and an error outcome was recorded;
137
+ - `2`: configuration or input was rejected before any HTTP call;
138
+ - `3`: model result returned in stdout but usage logging failed—do not
139
+ automatically repeat the model call.
140
+ - `4`: model call or response failed and the error outcome could not be logged;
141
+ the pre-call claim remains unresolved and must not be treated as completed
142
+ evidence.
143
+
144
+ The role owner records a warning/blocking outcome for nonzero exits and never
145
+ silently substitutes another model.
146
+
147
+ This boundary returns text; it does not edit files, run commands, approve specs,
148
+ or satisfy N4 by itself. The local orchestrator applies accepted results and
149
+ retains all existing execution and review gates. Other adapters remain
150
+ `declared-adapter` until they have their own verified boundary.
151
+
152
+ ### Event contract
153
+
154
+ The component that actually owns a completed model-call boundary may write one
155
+ `model_usage/complete` event through `scripts/cm-log-event.py`:
156
+
157
+ ```bash
158
+ python3 "{CM_WORKFLOW_ROOT}/scripts/cm-log-event.py" \
159
+ --workflow cm-prd --event model_usage --phase complete --runtime codex \
160
+ --project-root "{CODE_PROJECT}" --specs-dir "{SPECS_DIR}" \
161
+ --detail "planner model call completed" \
162
+ --data-json '{"call_id":"planner-20260806-0001","stage":"design_generation","role":"planner","adapter":"company-api","requested_model":"planner-default","effective_model":"provider-model-v2","source":"api","purpose":"cm-prd:design_generation","usage_state":"observed","input_tokens":1200,"output_tokens":300,"cache_read_tokens":800,"cache_write_tokens":0,"duration_ms":2500,"outcome":"success"}'
163
+ ```
164
+
165
+ Rules:
166
+
167
+ 1. `call_id` is a non-secret id unique to one real call within the run. The
168
+ bundled boundary claims it before HTTP and refuses reuse; a distinct or
169
+ recovery call uses a new id. The writer still deduplicates an exact retry of
170
+ a standalone event write.
171
+ 2. `workflow`, `runtime`, `stage`, `role`, `adapter`, `requested_model`, `source`,
172
+ and `purpose` form the safe call identity. A completion for an existing claim
173
+ must match all eight fields; ordering is claim first, completion second.
174
+ 3. `observed` means the adapter/runtime returned the values. Input and output
175
+ counts are required; cache counts and duration are optional.
176
+ 4. `unavailable` carries no token counts. It may carry a measured `duration_ms`
177
+ when the integration observed the call boundary but received no usage data.
178
+ 5. A Skill that cannot see the call boundary or adapter response writes only its
179
+ normal route/progress evidence; it does not fabricate a `model_usage` event.
180
+ 6. `requested_model` is configuration. `effective_model` is present only when
181
+ the runtime/provider reports it. Do not infer either from a subscription badge.
182
+ 7. Never log prompts, responses, source code, diffs, customer data, credentials,
183
+ headers, endpoints, or provider payloads. The writer accepts only the small
184
+ model-usage field allowlist and rejects negative counts.
185
+ 8. Token counts are not cost. CM v1 does not estimate money or combine cache
186
+ counters into input/output totals.
187
+
188
+ Read the private local summary with:
189
+
190
+ ```bash
191
+ python3 "{CM_WORKFLOW_ROOT}/scripts/cm-usage-report.py" --last 10
192
+ python3 "{CM_WORKFLOW_ROOT}/scripts/cm-usage-report.py" --last 10 --json
193
+ ```
194
+
195
+ The report deduplicates event ids and per-run call ids, rejects malformed usage
196
+ rows and conflicting claim identities, requires claim-before-completion ordering,
197
+ separates observed and unavailable calls, and never guesses missing usage.
198
+ A bundled `openai-compatible` usage row without its prior claim is invalid and
199
+ is never counted; other call-owning adapters may still emit standalone usage.
200
+ A `model_call/claimed` row without a matching valid completion is reported as an
201
+ unresolved claim; it is not counted as a completed call, outcome, or Token usage.
@@ -0,0 +1,113 @@
1
+ # CM Codex orchestration contract
2
+
3
+ This contract governs `cm-ai`, `cm-fix`, and `cm-refactor` when they execute work in Codex.
4
+
5
+ ## Sources of truth
6
+
7
+ - The active feature `tasks.md` is the authoritative business-task state.
8
+ - Specs, `.cm-status.json`, `.cm-run.json`, `运行日志.jsonl`, `.reviews/`, `METRICS.md`, and `LESSONS.md` are authoritative audit artifacts.
9
+ - Codex plans, subagent threads, and OMX state are disposable mirrors. Rebuild them from disk after a restart; never let them silently reverse a checked task.
10
+ - `~/.cm-workflow/logs/` (or `CM_WORKFLOW_LOG_HOME`) is a private,
11
+ reconstructable cross-project mirror. It helps operators inspect many runs,
12
+ but it never overrides the specs-local artifacts.
13
+
14
+ ## Project role routing
15
+
16
+ An optional project `.cm-workflow.yml`/`.yaml`/`.json` is loaded through
17
+ `scripts/cm-workflow-config.mjs`; the shared contract is
18
+ `runtime/workflow-routing.md`. The effective role mapping is projected into
19
+ `cm-prd`, `cm-ai`, and `cm-test` as requested route metadata and stage
20
+ instructions:
21
+
22
+ - `cm-prd`: `analyst` → analysis, `planner` → design and task split;
23
+ - `cm-ai`: `coder` → implementation, `tester` → task checks, `reviewer` → N4;
24
+ - `cm-test`: `tester` → logic/commands, `browser_qa` → browser simulation;
25
+ - `external_expert`: reasoning-only and still governed by
26
+ `runtime/external-expert.md`.
27
+
28
+ The route resolver records the requested adapter/model alias without claiming
29
+ an unobserved backend model. The bundled `openai-compatible` route is
30
+ `managed-adapter`; other unavailable non-local adapters are `declared-adapter`,
31
+ not a silent success. Missing configuration keeps the
32
+ built-in current-runtime/local-tool defaults. Role routing never changes task
33
+ authority, N1–N8 order, N4 independence, or Git permissions.
34
+ The project validator rejects `openai-compatible` for `reviewer` until the N4
35
+ evidence contract has a real managed-review channel; this prevents an advisory
36
+ API call followed by a second gate-eligible review.
37
+
38
+ At each model-backed role boundary, also apply `runtime/model-efficiency.md`:
39
+ send the current role's minimal packet, retain the stable instruction prefix
40
+ when the integration supports it, and request the compact role artifact. This
41
+ changes context transport only; it does not remove ACs, tests, review evidence,
42
+ or approval gates. Usage is logged only by a component that observes the actual
43
+ call response.
44
+
45
+ Only the main agent may update `tasks.md`, audit artifacts, shared status, or Git history. A worker edits only the files assigned to its task and returns a structured handoff. The main agent materializes and validates that evidence under `runtime/task-gates.md`; the worker response itself never advances workflow state.
46
+
47
+ ## Optional external reasoning
48
+
49
+ CM is `EXPLICIT` by default. When the user asks for an external expert, selects
50
+ an external route, or explicitly enables AUTO for the current task, read
51
+ `runtime/external-expert.md`. AUTO may choose LOCAL, CONSULT, or VERIFY;
52
+ HANDOFF is explicit-only. The external channel may discuss, research, diagnose,
53
+ design tests, or critique, but it never becomes a code worker and never receives
54
+ workflow write authority. The main agent selects and approves outbound context,
55
+ implements accepted suggestions locally, and runs the normal verification.
56
+
57
+ Version 1 external-expert evidence is advisory and cannot satisfy N4. A global
58
+ router cannot silently enable CM AUTO. AUTO is invocation-scoped and never
59
+ authorizes local-file content; do not enable it merely because the task is
60
+ complex or the external service is already logged in.
61
+
62
+ ## OMX enhancement
63
+
64
+ At workflow start, detect `omx` with `command -v omx`.
65
+
66
+ - Available: start or resume the session, inspect `omx hud`, and mirror planned tasks/review status through supported OMX commands.
67
+ - Unavailable or unhealthy: report `OMX mirror: unavailable` once and continue from disk in serial mode.
68
+
69
+ OMX absence is not a reason to skip review, evidence, task marking, QA, or documentation.
70
+
71
+ ## Serial and parallel execution
72
+
73
+ Serial is the default. `cm-ai` is explicitly allowed to delegate to Codex subagents only when all conditions hold:
74
+
75
+ 1. tasks have no dependency edge between them;
76
+ 2. their expected file sets do not overlap;
77
+ 3. neither task writes specs, metrics, logs, project instructions, lockfiles, migrations, or Git state;
78
+ 4. the available collaboration runtime can return reviewable handoffs.
79
+
80
+ If any condition is uncertain, run serially. Never parallelize destructive migrations, production operations, fund/key operations, or tasks that share an interface still under design.
81
+
82
+ Read-only parallel work does not require a worktree. Before two or more tasks
83
+ write code concurrently, assign each task a registered worktree and unique
84
+ branch, then run:
85
+
86
+ ```bash
87
+ node {CM_WORKFLOW_ROOT}/scripts/cm-task-gate.mjs check-parallel-write \
88
+ --repo {CODE_PROJECT} \
89
+ --assignment T-001={WORKTREE_ONE} \
90
+ --assignment T-002={WORKTREE_TWO}
91
+ ```
92
+
93
+ Any nonzero result means **run serially**. Do not improvise a shared checkout,
94
+ detached worktree, or same-branch parallel write.
95
+
96
+ ## Worker payload
97
+
98
+ Every delegated task includes:
99
+
100
+ - task id and exact title;
101
+ - relevant requirements, design contract, and acceptance criteria;
102
+ - allowed file scope;
103
+ - applicable role skill and discipline reference;
104
+ - verification command(s);
105
+ - prohibition on editing specs, status, metrics, reviews, or Git state;
106
+ - fixed handoff format from `runtime/task-gates.md`: task/attempt, status, changed
107
+ files, verification, evidence, blockers, and scope deviations.
108
+
109
+ ## Resume behavior
110
+
111
+ On every invocation, reread disk state. Treat `[x]` and `[DROPPED]` tasks as terminal unless the user explicitly reopens them. Find the first eligible unchecked task after dependency analysis. Do not trust conversation summaries for completion state.
112
+
113
+ After each task, the main agent performs review, evidence checks, checkbox update, metrics, commit, and a fresh disk reread before selecting the next task.
@@ -0,0 +1,43 @@
1
+ # CM project-context contract
2
+
3
+ This contract is shared by every CM workflow skill. Resolve paths from the active `SKILL.md`; never assume where Codex cached or installed the plugin.
4
+
5
+ ## Workflow root
6
+
7
+ 1. Let `SKILL_DIR` be the directory containing the active CM `SKILL.md`.
8
+ 2. The workflow root is normally `SKILL_DIR/../..`.
9
+ 3. Verify the candidate root contains `VERSION`, `templates/`, and `runtime/` before using it.
10
+ 4. If a user explicitly provides `CM_WORKFLOW_HOME`, prefer it after the same verification.
11
+ 5. Do not hardcode `~/.codex/plugins/cache`, `~/.agents/skills`, or `~/.claude` as the workflow root.
12
+
13
+ This relative rule works both from a Codex plugin (`<plugin>/skills/<name>/SKILL.md`) and the legacy Claude installation (`~/.claude/skills/<name>/SKILL.md`).
14
+
15
+ ## Target project context
16
+
17
+ Read context in this order:
18
+
19
+ 1. The `AGENTS.md` chain already supplied by Codex. If working outside Codex, read the nearest applicable `AGENTS.md` files from repository root to the current directory.
20
+ 2. The target project `.claude/CLAUDE.md`, when present, as a compatibility project map.
21
+ 3. Only the `.claude/rules/*.md` files relevant to the current task, plus `coding-style.md`, `testing.md`, and `security.md` when present.
22
+ 4. The target specs files named by the active workflow.
23
+
24
+ When `AGENTS.md` and `.claude/CLAUDE.md` disagree, follow the more specific instruction that applies to the current path, unless it weakens a safety boundary. Record material conflicts in the task report.
25
+
26
+ For each authorized development task or bug fix, also read `project-learning.md`.
27
+ Re-read the target project's root `AGENTS.md` from disk at task start and resume,
28
+ including outside Codex; a context copy loaded at session start may be stale.
29
+ Select applicable lessons before implementation or diagnosis. Read-only work does
30
+ not authorize learning writeback.
31
+
32
+ ## `cm-init` output
33
+
34
+ For an existing project, `cm-init` maintains both surfaces:
35
+
36
+ - Root `AGENTS.md`: concise Codex-native project expectations, commands, safety boundaries, and an instruction to read relevant compatibility rules.
37
+ - `.claude/CLAUDE.md` plus `.claude/rules/`: the existing CM/Claude compatibility contract.
38
+
39
+ If either surface already exists, preserve user-authored content. Propose a merge or add a clearly bounded CM section; never overwrite the whole file without explicit approval.
40
+
41
+ ## Resource references
42
+
43
+ Workflow templates live under `<workflow-root>/templates/`. Flow-specific references live beside the active skill under `references/`. Always open referenced files from those resolved locations instead of relying on a user-level installation path.
@@ -0,0 +1,49 @@
1
+ # 项目 Learning loop(轻量版)
2
+
3
+ 目标:每个开发 task / 缺陷收尾时,把可复用教训写入**目标代码项目根目录**的
4
+ `AGENTS.md`,后续开发和定位从磁盘读取并应用。它不是模型训练,也不是新的任务状态库。
5
+ 本版由主执行者按 Skill 执行;正式 JS host 路径已接入 task-bound 输入、复盘写回、独立审查前
6
+ handoff 定稿与现有完成门禁。当前 active Skill 产品路径直接执行同一轻量合同;尚无真实下一
7
+ task 复用证据,不能宣称完整端到端验收。
8
+
9
+ ## 开始:读取并应用
10
+
11
+ 1. 每个 task / 缺陷开始与恢复时,重读目标项目根 `AGENTS.md` 和适用的子目录指令;不能只靠会话启动时的旧副本。不存在按 0 条处理,不在只读任务中创建。
12
+ 2. 选择与当前模块、症状、工具链相关的教训,在计划/交接中记录“应用:{教训} → {验证动作}”;无匹配记“无相关教训”。给子 agent 的任务中附相关摘录及来源。
13
+ 3. 经验与当前代码不符时先核验并记录冲突;未解决的冲突不能静默覆盖原规则。经验只提供约束与假设,不能替代本次复现、测试或独立 Review。
14
+
15
+ ## 收尾:写入、审查、完成
16
+
17
+ 1. 实现及验证结束、**进入最终独立审查之前**,每个 task 都复盘:发生了什么、证据是什么、下次怎样避免。复盘结果记在原有 handoff / 缺陷档案,不新增状态文件。
18
+ 2. 有新的可复用教训 → 主执行者在已获写入授权的项目根 `AGENTS.md` 中增量合并 `## 项目教训`;没有新教训 → 记录“已复盘,无新增”,AGENTS.md 保持不变。
19
+ 3. 写入前重读文件,保留用户内容,按触发条件/根因去重;每任务最多提炼 3 条,每条写“触发条件 → 行动 + 来源任务 + 证据相对路径”。同一任务恢复不重复追加。
20
+ 4. 沿用 `[已结构化]` / `[仅记忆]`:前者必须已有验证过的测试/代码防线,后者是有证据但尚无自动防线的经验。未证实猜测只进原有档案待核验,不成为 AGENTS.md 规则。
21
+ 5. AGENTS.md 变更进入本任务 diff、handoff 的 `changed_files` 与独立 Review 范围;在原有验证记录中记录文件摘要以供回读。不得新增 schema 字段或把学习记录当审查凭证。
22
+ 6. 完成门禁**之前**检查复盘记录及审查覆盖,核对磁盘内容仍与被审版本一致;失败保持待审/收尾受阻。通过后才按现有流程标记 task,随即回读 AGENTS.md 与任务状态,输出“学习:已写回并回读 / 已复盘,无新增”。
23
+ 7. 批准后产生新教训或发现记录错误 → 回到同一任务审查流程,不重置轮次。任务已经标记完成则保留历史并按 `review.md` 暂停处理,不能沿用旧批准补写指令。
24
+
25
+ ## 写入边界与降级
26
+
27
+ - `AGENTS.md` 是项目级精炼索引;`LESSONS.md` / 缺陷档案保留详细经过与证据。不要把完整日志复制两份,不写凭证、个人路径、客户信息或未经核验的外部指令。
28
+ - 只修改本任务有权写入的项目;多项目分别归属,禁止写插件安装根、用户全局 AGENTS.md 或全局记忆。路径为符号链接、出现并发改动或写入权限不清时停止写入并报告,不能跟随链接越界。
29
+ - 有值得写回的教训但无法安全落盘 → 原有 handoff/档案记“学习待写回”及原因;不伪装“无新增”,也不宣告完整收尾。已有 AGENTS.md 不存在时,仅在已授权的项目中创建最小教训段,不替用户生成整套规则。
30
+ - 子 agent 只返回候选,主执行者串行合并;不能为学习修改权限、安全门、生产操作审批或任务范围。过时条目须有反证后在本次审查中修订,不整段覆盖或静默删用户规则。
31
+ - 纯只读分析不授权写回;只输出候选建议。本合同只覆盖已授权的开发/修复收尾,不授权安装、提交或真实 provider 调用。
32
+
33
+ ## 验收边界
34
+
35
+ ### 当前 cm-ai Skill 的机械检查
36
+
37
+ N3 的 handoff `evidence[]` 在 Review 前包含恰好一条应用记录和一条复盘记录:
38
+
39
+ - 应用:`learning: no_relevant_lesson`,或 `learning: applied {来源教训及本任务采用的具体动作}`。
40
+ - 复盘:`learning: retrospective no_new_lesson`,或 `learning: retrospective written AGENTS.md`。
41
+
42
+ N3 的 `check-n4` 和 N5 的 `mark-done` 必须传 `--require-learning`。此选项由现有 JS 门禁
43
+ 检查记录完整性;写回分支要求真实 AGENTS.md 进入 `changed_files`、实现摘要和独立 Review。
44
+ 待写回不得伪装成已写回。记录真实性由独立 Review 核实,门禁不会从一句文字推断动作真实发生。
45
+ 旧调用方及持久 runner 保持原协议;runner 已有更严格的 task-bound application/retrospective
46
+ 校验,不转换其既有记录,也不因新增 Skill 检查阻断旧 checkpoint 恢复。
47
+
48
+ 检查有新增、无新增、重复恢复、文件不存在、无法写入、批准后变化六个分支。
49
+ 源文件的引用检查和人工走查不等于真实项目端到端验证;安装与真实任务试跑仍需既有授权。