@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,171 @@
1
+ #!/usr/bin/env python3
2
+ """Isolated package/installer fixture; final Codex registration is simulated.
3
+
4
+ Never changes HOME/CODEX_HOME or the live installation. Only the three installer
5
+ path assignments are relocated in a fixture copy; transaction code is unchanged.
6
+ Requires macOS, Node 24.14+, npm, Git, Python and local Codex plugin helpers.
7
+ """
8
+ import hashlib
9
+ import json
10
+ import os
11
+ from pathlib import Path
12
+ import shlex
13
+ import shutil
14
+ import subprocess
15
+ import sys
16
+ import tempfile
17
+
18
+ ROOT = Path(__file__).resolve().parent.parent
19
+
20
+
21
+ def run(args, *, cwd=ROOT, env=None, expected=0, input=None):
22
+ result = subprocess.run(args, cwd=cwd, env=env, input=input, text=True,
23
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
24
+ if result.returncode != expected:
25
+ raise AssertionError(f"{args[0]} exited {result.returncode}, expected {expected}\n{result.stdout}")
26
+ return result.stdout
27
+
28
+
29
+ def tree(root):
30
+ return {str(p.relative_to(root)): hashlib.sha256(p.read_bytes()).hexdigest()
31
+ for p in root.rglob('*') if p.is_file()}
32
+
33
+
34
+ def relocated(source, home, helpers):
35
+ text = (source / 'install-codex.sh').read_text()
36
+ replacements = {
37
+ 'MARKETPLACE_ROOT="$HOME/.agents/plugins"':
38
+ 'MARKETPLACE_ROOT=' + shlex.quote(str(home / '.agents/plugins')),
39
+ 'PLUGIN_PARENT="$HOME/plugins"':
40
+ 'PLUGIN_PARENT=' + shlex.quote(str(home / 'plugins')),
41
+ 'CREATOR_ROOT="$CODEX_HOME/skills/.system/plugin-creator"':
42
+ 'CREATOR_ROOT=' + shlex.quote(str(helpers)),
43
+ }
44
+ for old, new in replacements.items():
45
+ assert text.count(old) == 1, f'Installer preamble changed: {old}'
46
+ text = text.replace(old, new, 1)
47
+ target = source / '.npm-installer-fixture.sh'
48
+ target.write_text(text)
49
+ return target
50
+
51
+
52
+ def main():
53
+ assert sys.platform == 'darwin', 'This integration fixture requires macOS'
54
+ helpers = Path(os.environ.get('CODEX_HOME', str(Path.home() / '.codex'))) / 'skills/.system/plugin-creator'
55
+ assert (helpers / 'scripts/create_basic_plugin.py').is_file(), 'Codex bundled helpers required'
56
+ with tempfile.TemporaryDirectory(prefix='cm-npm-fixture-') as folder:
57
+ temp = Path(folder).resolve()
58
+ # Include spaces to catch unsafe shell/path forwarding.
59
+ unpack = temp / 'npm package'
60
+ unpack.mkdir()
61
+ info = json.loads(run(['npm', 'pack', '--ignore-scripts', '--json', '--pack-destination', str(temp)]))[0]
62
+ archive = temp / info['filename']
63
+ packed_paths = {f['path'] for f in info['files']}
64
+ assert {'.codex-plugin/plugin.json', 'install-codex.sh', 'install.sh', 'install.ps1',
65
+ 'scripts/cm-workflow.mjs', 'AGENTS.md', 'SECURITY.md', 'CONTRIBUTING.md'} <= packed_paths
66
+ assert not any(p.startswith(('.omx/', '.git/', '.env')) for p in packed_paths)
67
+ run(['tar', '-xzf', str(archive), '-C', str(unpack)])
68
+ package = unpack / 'package'
69
+ metadata = json.loads((package / 'package.json').read_text())
70
+ assert not metadata.get('scripts') and not metadata.get('dependencies')
71
+ assert metadata['version'] == (package / 'VERSION').read_text().strip()
72
+ assert metadata['version'] == json.loads((package / '.codex-plugin/plugin.json').read_text())['version']
73
+ outside = temp / 'unrelated project'
74
+ outside.mkdir()
75
+ help_text = run(['npm', 'exec', '--offline', '--yes', '--cache', str(temp / 'npm-cache'),
76
+ '--package', str(archive), '--', 'cm-workflow', '--help'], cwd=outside)
77
+ assert 'Usage: cm-workflow install' in help_text, help_text
78
+ (outside / 'tasks.md').write_text('T-001 remains pending\n')
79
+ project_before = tree(outside)
80
+ source = temp / 'old source checkout'
81
+ source.mkdir()
82
+ old_archive = temp / 'source.tar'
83
+ run(['git', 'archive', '--format=tar', '-o', str(old_archive), 'HEAD'])
84
+ run(['tar', '-xf', str(old_archive), '-C', str(source)])
85
+ source_before = tree(source)
86
+ bin_dir = temp / 'bin'
87
+ bin_dir.mkdir()
88
+ fake = bin_dir / 'codex'
89
+ fake.write_text('#!' + sys.executable + '\n' + '''import json, os, pathlib, sys
90
+ args = sys.argv[1:]
91
+ assert len(args) == 3 and args[:2] == ['plugin', 'add'], args
92
+ assert args[2].startswith('cm-workflow@'), args
93
+ with pathlib.Path(os.environ['CM_NPM_FIXTURE_CALLS']).open('a') as out:
94
+ out.write(json.dumps(args) + '\\n')
95
+ sys.exit(17 if os.environ.get('CM_NPM_FIXTURE_FAIL') == '1' else 0)
96
+ ''')
97
+ fake.chmod(0o755)
98
+ env = {**os.environ, 'PATH': str(bin_dir) + os.pathsep + os.environ['PATH'],
99
+ 'CM_NPM_FIXTURE_CALLS': str(temp / 'calls.jsonl')}
100
+ # The shipped Node entry still chooses the original script and arguments.
101
+ # Its injected subprocess executes only our relocated fixture copy.
102
+ bridge = temp / 'entry-fixture.mjs'
103
+ bridge.write_text('''import {spawnSync} from 'node:child_process';
104
+ import {pathToFileURL} from 'node:url';
105
+ import assert from 'node:assert/strict';
106
+ const [pkg,fixture,...args]=process.argv.slice(2);
107
+ const {main}=await import(pathToFileURL(pkg+'/scripts/cm-workflow.mjs'));
108
+ process.exitCode=main(args,{run:(command,argv,options)=>{
109
+ assert.equal(command,'/bin/bash');
110
+ assert.equal(argv[0],pkg+'/install-codex.sh');
111
+ return spawnSync(command,[fixture,...argv.slice(1)],options);
112
+ }});
113
+ ''')
114
+
115
+ def install(pkg, home, *, npm=True, yes=True, fail=False, input=None):
116
+ fixture = relocated(pkg, home, helpers)
117
+ args = ['install'] + (['--yes'] if yes else [])
118
+ command = (['node', str(bridge), str(pkg), str(fixture), *args] if npm else
119
+ ['/bin/bash', str(fixture), *args[1:]])
120
+ try:
121
+ return run(command, cwd=outside, env={**env, 'CM_NPM_FIXTURE_FAIL': '1' if fail else '0'},
122
+ expected=17 if fail else 0, input=input)
123
+ finally:
124
+ fixture.unlink()
125
+
126
+ fresh = temp / 'fresh user'
127
+ install(package, fresh)
128
+ assert (fresh / 'plugins/cm-workflow/skills/cm-ai/SKILL.md').is_file()
129
+ print('PASS: tarball contents, offline npm CLI and fresh file installation', flush=True)
130
+
131
+ upgrade = temp / 'existing user'
132
+ install(source, upgrade, npm=False)
133
+ dest = upgrade / 'plugins/cm-workflow'
134
+ marketplace = upgrade / '.agents/plugins/marketplace.json'
135
+ payload = json.loads(marketplace.read_text())
136
+ sibling = {**payload['plugins'][0], 'name': 'unrelated-plugin'}
137
+ payload['plugins'].append(sibling)
138
+ marketplace.write_text(json.dumps(payload))
139
+ (dest / 'old-local-edit.txt').write_text('fixture old plugin marker\n')
140
+ before = tree(upgrade)
141
+ calls = (temp / 'calls.jsonl').read_bytes()
142
+ assert 'cancelled' in install(package, upgrade, yes=False, input='n\n').lower()
143
+ assert tree(upgrade) == before
144
+ assert (temp / 'calls.jsonl').read_bytes() == calls
145
+ print('PASS: declined upgrade preserves plugin and marketplace', flush=True)
146
+
147
+ install(package, upgrade, fail=True)
148
+ assert tree(upgrade) == before
149
+ print('PASS: failed source-to-npm upgrade restores exact previous files', flush=True)
150
+
151
+ install(package, upgrade)
152
+ assert not (dest / 'old-local-edit.txt').exists()
153
+ installed_entries = json.loads(marketplace.read_text())['plugins']
154
+ assert sum(p['name'] == 'cm-workflow' for p in installed_entries) == 1
155
+ assert sibling in installed_entries
156
+ for folder in ['skills', 'runtime', 'templates', 'scripts', 'agents', 'compat', 'docs', 'assets']:
157
+ assert tree(package / folder) == tree(dest / folder), folder
158
+ assert tree(source) == source_before
159
+ assert tree(outside) == project_before
160
+ print('PASS: source-to-npm upgrade replaces same plugin; project/source and other entry preserved', flush=True)
161
+
162
+ failed_fresh = temp / 'failed fresh user'
163
+ install(package, failed_fresh, fail=True)
164
+ assert not (failed_fresh / 'plugins/cm-workflow').exists()
165
+ assert not (failed_fresh / '.agents/plugins/marketplace.json').exists()
166
+ print('PASS: failed fresh registration leaves no plugin or marketplace file', flush=True)
167
+ print('LIMIT: Codex registration simulated; registry publication and live cache ingestion not tested.')
168
+
169
+
170
+ if __name__ == '__main__':
171
+ main()
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env python3
2
+ """Run the actual safety CLI against isolated public-tree fixtures."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ import tempfile
10
+ import unittest
11
+ from pathlib import Path
12
+
13
+
14
+ SCANNER = Path(__file__).with_name("scan-public-safety.py")
15
+ LOOPBACK = "http://" + "127.0.0.1"
16
+ PRIVATE = "http://" + "192.168.40.2"
17
+ APPROVED = "scripts/cm-test-host.test.mjs"
18
+ LEGACY = "scripts/test-cm-openai-compatible-call.py"
19
+
20
+
21
+ class PublicSafetyTests(unittest.TestCase):
22
+ def scan(self, files):
23
+ with tempfile.TemporaryDirectory(prefix="cm-safety-") as raw:
24
+ root = Path(raw)
25
+ script = root / "scripts" / SCANNER.name
26
+ script.parent.mkdir()
27
+ shutil.copyfile(SCANNER, script)
28
+ for name, text in files.items():
29
+ target = root / name
30
+ target.parent.mkdir(parents=True, exist_ok=True)
31
+ target.write_text(text, encoding="utf-8")
32
+ return subprocess.run(
33
+ [sys.executable, str(script)], cwd=root,
34
+ capture_output=True, text=True, check=False,
35
+ )
36
+
37
+ def test_reviewed_loopback_literals_and_local_port_templates(self):
38
+ for authority in ["127.0.0.1", "localhost:3000", "localhost:$PORT",
39
+ "127.0.0.1:${port}", "127.0.0.1:{server.server_port}"]:
40
+ with self.subTest(authority=authority):
41
+ result = self.scan({APPROVED: '"http://' + authority + '/capture"'})
42
+ self.assertEqual(result.returncode, 0, result.stderr)
43
+
44
+ def test_loopback_in_unreviewed_path_is_still_reported(self):
45
+ result = self.scan({"docs/unreviewed.md": LOOPBACK + "/capture"})
46
+ self.assertEqual(result.returncode, 1)
47
+ self.assertIn("docs/unreviewed.md:1: private endpoint", result.stderr)
48
+
49
+ def test_rfc1918_is_not_exempt_in_any_reviewed_file(self):
50
+ for name in [APPROVED, LEGACY, "templates/dashboard/serve.sh"]:
51
+ for host in ["10.4.5.6", "192.168.40.2", "172.16.4.5", "172.31.4.5"]:
52
+ with self.subTest(name=name, host=host):
53
+ result = self.scan({name: '"http://' + host + ':3000/"'})
54
+ self.assertEqual(result.returncode, 1, result.stdout)
55
+ self.assertIn("private endpoint", result.stderr)
56
+
57
+ def test_lookalike_and_credential_authorities_are_not_loopback_exceptions(self):
58
+ for suffix in [".example.invalid", "@example.invalid", ":80@example.invalid",
59
+ ":3000.evil", "0", ":${untrusted.host}"]:
60
+ with self.subTest(suffix=suffix):
61
+ result = self.scan({APPROVED: '"' + LOOPBACK + suffix + '/"'})
62
+ self.assertEqual(result.returncode, 1, result.stdout)
63
+
64
+ def test_other_findings_and_line_numbers_survive_loopback_exception(self):
65
+ # Deliberately constructed fake markers; never use a real credential.
66
+ fake_key = "sk-" + "x" * 24
67
+ personal = "/Users/" + "fixture-owner/project"
68
+ result = self.scan({APPROVED: f'"{LOOPBACK}/"\n{PRIVATE}\n{fake_key}\n{personal}\n'})
69
+ self.assertEqual(result.returncode, 1)
70
+ for expected in [":2: private endpoint", ":3: OpenAI-style key", ":4: personal macOS path"]:
71
+ self.assertIn(APPROVED + expected, result.stderr)
72
+ self.assertNotIn(APPROVED + ":1:", result.stderr)
73
+
74
+
75
+ if __name__ == "__main__":
76
+ unittest.main()
@@ -0,0 +1,365 @@
1
+ #!/usr/bin/env bash
2
+ # Dependency-free regression fixtures for shell/runtime portability.
3
+ set -euo pipefail
4
+
5
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6
+ TMP_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/cm-shell-compat.XXXXXX")"
7
+ trap 'rm -rf "$TMP_ROOT"' EXIT HUP INT TERM
8
+ FAILURES=0
9
+
10
+ fail() {
11
+ echo "FAIL: $*" >&2
12
+ FAILURES=$((FAILURES + 1))
13
+ }
14
+
15
+ REAL_PYTHON=""
16
+ for candidate in python3 python; do
17
+ if command -v "$candidate" >/dev/null 2>&1 &&
18
+ "$candidate" -c 'import sys; raise SystemExit(sys.version_info < (3, 9))' >/dev/null 2>&1; then
19
+ REAL_PYTHON="$(command -v "$candidate")"
20
+ break
21
+ fi
22
+ done
23
+
24
+ if [ -z "$REAL_PYTHON" ]; then
25
+ echo "shell compatibility fixtures: BLOCKED (Python 3.9+ not found)" >&2
26
+ exit 2
27
+ fi
28
+
29
+ if [ ! -x "$ROOT/install.sh" ]; then
30
+ fail "Claude Bash installer must remain directly executable"
31
+ fi
32
+
33
+ REAL_NODE=""
34
+ if command -v node >/dev/null 2>&1 &&
35
+ node -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 18 ? 0 : 1)' >/dev/null 2>&1; then
36
+ REAL_NODE="$(command -v node)"
37
+ fi
38
+ if [ -z "$REAL_NODE" ]; then
39
+ echo "shell compatibility fixtures: BLOCKED (Node.js 18+ not found)" >&2
40
+ exit 2
41
+ fi
42
+
43
+ # The runtime checker must continue to work when a platform exposes only
44
+ # `python`, even though `python3` is unavailable on PATH. Node.js remains a
45
+ # declared runtime requirement for the JavaScript config authority.
46
+ FAKE_BIN="$TMP_ROOT/compat-bin"
47
+ mkdir -p "$FAKE_BIN"
48
+ printf '%s\n' '#!/usr/bin/env bash' "exec \"$REAL_PYTHON\" \"\$@\"" > "$FAKE_BIN/python"
49
+ printf '%s\n' '#!/usr/bin/env bash' 'exit 127' > "$FAKE_BIN/python3"
50
+ printf '%s\n' '#!/usr/bin/env bash' "exec \"$REAL_NODE\" \"\$@\"" > "$FAKE_BIN/node"
51
+ chmod +x "$FAKE_BIN/python" "$FAKE_BIN/python3" "$FAKE_BIN/node"
52
+
53
+ if PATH="$FAKE_BIN:/usr/bin:/bin" "$ROOT/scripts/cm-check-runtime.sh" \
54
+ >"$TMP_ROOT/python-fallback.out" 2>&1; then
55
+ :
56
+ else
57
+ cat "$TMP_ROOT/python-fallback.out" >&2
58
+ fail "runtime checker must support the python fallback with Node.js present"
59
+ fi
60
+
61
+ # The Codex installer performs the same fallback before it validates its
62
+ # arguments. An invalid option gives us a side-effect-free smoke check.
63
+ if PATH="$FAKE_BIN:/usr/bin:/bin" "$ROOT/install-codex.sh" --invalid \
64
+ >"$TMP_ROOT/installer-python-fallback.out" 2>&1; then
65
+ fail "Codex installer must reject an invalid option"
66
+ elif grep -q 'Usage:' "$TMP_ROOT/installer-python-fallback.out" &&
67
+ ! grep -q 'Python 3.9+ not found' "$TMP_ROOT/installer-python-fallback.out"; then
68
+ :
69
+ else
70
+ cat "$TMP_ROOT/installer-python-fallback.out" >&2
71
+ fail "Codex installer must support the python fallback with Node.js present"
72
+ fi
73
+
74
+ # Missing Node.js must fail before an installer can mutate user directories.
75
+ NO_NODE_BIN="$TMP_ROOT/no-node-bin"
76
+ mkdir -p "$NO_NODE_BIN"
77
+ cp "$FAKE_BIN/python" "$NO_NODE_BIN/python"
78
+ cp "$FAKE_BIN/python3" "$NO_NODE_BIN/python3"
79
+ if PATH="$NO_NODE_BIN:/usr/bin:/bin" "$ROOT/install-codex.sh" --yes \
80
+ >"$TMP_ROOT/installer-no-node.out" 2>&1; then
81
+ fail "Codex installer must reject a PATH without Node.js"
82
+ elif grep -q 'Node.js 18+ not found' "$TMP_ROOT/installer-no-node.out"; then
83
+ :
84
+ else
85
+ cat "$TMP_ROOT/installer-no-node.out" >&2
86
+ fail "Codex installer must explain the Node.js requirement"
87
+ fi
88
+
89
+ make_git_fixture() {
90
+ repo="$1"
91
+ specs="$2"
92
+ task_mtime_delta="$3"
93
+ mkdir -p "$repo" "$specs/1-demo"
94
+ git -C "$repo" init -q
95
+ git -C "$repo" config user.email "cm-workflow@example.invalid"
96
+ git -C "$repo" config user.name "cm-workflow fixture"
97
+ printf '%s\n' 'base' > "$repo/src.js"
98
+ git -C "$repo" add src.js
99
+ git -C "$repo" commit -qm "fixture: baseline"
100
+ printf '%s\n' '- [ ] T-001: fixture task' > "$specs/1-demo/tasks.md"
101
+ last_commit_ts="$(git -C "$repo" log -1 --format=%ct)"
102
+ "$REAL_PYTHON" - "$specs/1-demo/tasks.md" "$last_commit_ts" "$task_mtime_delta" <<'PY'
103
+ import os
104
+ import sys
105
+
106
+ path, commit_ts, delta = sys.argv[1], float(sys.argv[2]), float(sys.argv[3])
107
+ timestamp = commit_ts + delta
108
+ os.utime(path, (timestamp, timestamp))
109
+ PY
110
+ printf '%s\n' 'changed' >> "$repo/src.js"
111
+ git -C "$repo" add src.js
112
+ }
113
+
114
+ # A fresh tasks file must allow a strict commit check. The old implementation
115
+ # used macOS-incompatible `find -newermt` and rejected this valid case.
116
+ fresh_repo="$TMP_ROOT/fresh-repo"
117
+ fresh_specs="$TMP_ROOT/fresh-specs"
118
+ make_git_fixture "$fresh_repo" "$fresh_specs" 10
119
+ if (
120
+ cd "$fresh_repo"
121
+ PATH="$FAKE_BIN:/usr/bin:/bin" CM_SPECS_DIR="$fresh_specs" CM_TASK_CHECK_STRICT=1 \
122
+ /bin/bash "$ROOT/templates/hooks/pre-commit-cm-task-check"
123
+ ); then
124
+ :
125
+ else
126
+ fail "strict hook must allow a source commit when tasks.md is newer"
127
+ fi
128
+
129
+ # An unchanged/stale tasks file must still block strict source commits.
130
+ stale_repo="$TMP_ROOT/stale-repo"
131
+ stale_specs="$TMP_ROOT/stale-specs"
132
+ make_git_fixture "$stale_repo" "$stale_specs" -10
133
+ if (
134
+ cd "$stale_repo"
135
+ PATH="$FAKE_BIN:/usr/bin:/bin" CM_SPECS_DIR="$stale_specs" CM_TASK_CHECK_STRICT=1 \
136
+ /bin/bash "$ROOT/templates/hooks/pre-commit-cm-task-check"
137
+ ); then
138
+ fail "strict hook must block a source commit when tasks.md is stale"
139
+ fi
140
+
141
+ # Rejecting any conflict in the Claude compatibility installer must be an
142
+ # all-or-nothing cancellation. A stale Skill mixed with a new runtime is not a
143
+ # usable degraded install.
144
+ claude_fixture="$TMP_ROOT/claude-atomic"
145
+ claude_home="$claude_fixture/home"
146
+ claude_dest="$claude_fixture/.claude"
147
+ mkdir -p "$claude_home" "$claude_dest/skills/cm-ai"
148
+ printf '%s\n' 'stale cm-ai skill' > "$claude_dest/skills/cm-ai/SKILL.md"
149
+ (
150
+ cd "$claude_fixture"
151
+ find . -type f -exec shasum -a 256 {} \; | sort
152
+ ) > "$TMP_ROOT/claude-before.sha"
153
+ printf 'n\n' | HOME="$claude_home" CLAUDE_HOME="$claude_dest" \
154
+ /bin/bash "$ROOT/install.sh" > "$TMP_ROOT/claude-install.out" 2>&1 || true
155
+ (
156
+ cd "$claude_fixture"
157
+ find . -type f -exec shasum -a 256 {} \; | sort
158
+ ) > "$TMP_ROOT/claude-after.sha"
159
+ if cmp -s "$TMP_ROOT/claude-before.sha" "$TMP_ROOT/claude-after.sha"; then
160
+ :
161
+ else
162
+ cat "$TMP_ROOT/claude-install.out" >&2
163
+ fail "Claude installer cancellation must not leave a partial upgrade"
164
+ fi
165
+
166
+ claude_success="$TMP_ROOT/claude-success"
167
+ mkdir -p "$claude_success/home"
168
+ if HOME="$claude_success/home" CLAUDE_HOME="$claude_success/.claude" \
169
+ /bin/bash "$ROOT/install.sh" --yes > "$TMP_ROOT/claude-success.out" 2>&1 &&
170
+ [ -f "$claude_success/.claude/skills/cm-ai/SKILL.md" ] &&
171
+ [ "$(cat "$claude_success/.claude/templates/cm-VERSION")" = "$(cat "$ROOT/VERSION")" ]; then
172
+ :
173
+ else
174
+ cat "$TMP_ROOT/claude-success.out" >&2
175
+ fail "Claude Bash installer must complete an isolated atomic install"
176
+ fi
177
+
178
+ claude_optional_blocked="$TMP_ROOT/claude-optional-blocked"
179
+ mkdir -p "$claude_optional_blocked/home"
180
+ printf '%s\n' 'occupied' > "$claude_optional_blocked/home/.cm-workflow"
181
+ if HOME="$claude_optional_blocked/home" \
182
+ CLAUDE_HOME="$claude_optional_blocked/.claude" \
183
+ /bin/bash "$ROOT/install.sh" --yes > "$TMP_ROOT/claude-optional-blocked.out" 2>&1 &&
184
+ [ -f "$claude_optional_blocked/.claude/skills/cm-ai/SKILL.md" ] &&
185
+ grep -q '可选更新器安装跳过' "$TMP_ROOT/claude-optional-blocked.out"; then
186
+ :
187
+ else
188
+ cat "$TMP_ROOT/claude-optional-blocked.out" >&2
189
+ fail "optional updater failure must not invalidate the verified core install"
190
+ fi
191
+
192
+ installer_fail_bin="$TMP_ROOT/installer-fail-bin"
193
+ mkdir -p "$installer_fail_bin"
194
+ printf '%s\n' '#!/usr/bin/env sh' 'exit 127' > "$installer_fail_bin/python3"
195
+ printf '%s\n' '#!/usr/bin/env sh' 'exit 127' > "$installer_fail_bin/python"
196
+ chmod +x "$installer_fail_bin/python3" "$installer_fail_bin/python"
197
+
198
+ claude_rollback="$TMP_ROOT/claude-rollback"
199
+ mkdir -p "$claude_rollback/home" "$claude_rollback/.claude/skills/cm-ai"
200
+ printf '%s\n' 'stale cm-ai skill' > "$claude_rollback/.claude/skills/cm-ai/SKILL.md"
201
+ (
202
+ cd "$claude_rollback"
203
+ find . -type f -exec shasum -a 256 {} \; | sort
204
+ ) > "$TMP_ROOT/claude-rollback-before.sha"
205
+ if HOME="$claude_rollback/home" CLAUDE_HOME="$claude_rollback/.claude" \
206
+ PATH="$installer_fail_bin:/usr/bin:/bin" \
207
+ /bin/bash "$ROOT/install.sh" --yes > "$TMP_ROOT/claude-rollback.out" 2>&1; then
208
+ fail "Claude Bash installer must fail when the installed self-check fails"
209
+ fi
210
+ (
211
+ cd "$claude_rollback"
212
+ find . -type f -exec shasum -a 256 {} \; | sort
213
+ ) > "$TMP_ROOT/claude-rollback-after.sha"
214
+ if cmp -s "$TMP_ROOT/claude-rollback-before.sha" "$TMP_ROOT/claude-rollback-after.sha"; then
215
+ :
216
+ else
217
+ cat "$TMP_ROOT/claude-rollback.out" >&2
218
+ fail "Claude Bash installer must restore all managed files after self-check failure"
219
+ fi
220
+
221
+ claude_directory_collision="$TMP_ROOT/claude-directory-collision"
222
+ mkdir -p "$claude_directory_collision/home" \
223
+ "$claude_directory_collision/.claude/skills/cm-ai/SKILL.md"
224
+ printf '%s\n' 'keep directory collision' \
225
+ > "$claude_directory_collision/.claude/skills/cm-ai/SKILL.md/marker.txt"
226
+ (
227
+ cd "$claude_directory_collision"
228
+ find . -type f -exec shasum -a 256 {} \; | sort
229
+ ) > "$TMP_ROOT/claude-directory-before.sha"
230
+ if HOME="$claude_directory_collision/home" \
231
+ CLAUDE_HOME="$claude_directory_collision/.claude" \
232
+ /bin/bash "$ROOT/install.sh" --yes > "$TMP_ROOT/claude-directory.out" 2>&1; then
233
+ fail "Claude Bash installer must reject a directory at a managed file path"
234
+ fi
235
+ (
236
+ cd "$claude_directory_collision"
237
+ find . -type f -exec shasum -a 256 {} \; | sort
238
+ ) > "$TMP_ROOT/claude-directory-after.sha"
239
+ if cmp -s "$TMP_ROOT/claude-directory-before.sha" "$TMP_ROOT/claude-directory-after.sha"; then
240
+ :
241
+ else
242
+ cat "$TMP_ROOT/claude-directory.out" >&2
243
+ fail "Claude Bash installer must not partially write after a directory collision"
244
+ fi
245
+
246
+ claude_symlink="$TMP_ROOT/claude-symlink"
247
+ claude_external="$TMP_ROOT/claude-symlink-external"
248
+ mkdir -p "$claude_symlink/home" "$claude_symlink/.claude" "$claude_external"
249
+ ln -s "$claude_external" "$claude_symlink/.claude/skills"
250
+ if HOME="$claude_symlink/home" CLAUDE_HOME="$claude_symlink/.claude" \
251
+ /bin/bash "$ROOT/install.sh" --yes > "$TMP_ROOT/claude-symlink.out" 2>&1; then
252
+ fail "Claude Bash installer must reject a symlinked managed ancestor"
253
+ fi
254
+ if [ -n "$(find "$claude_external" -type f -print -quit)" ]; then
255
+ cat "$TMP_ROOT/claude-symlink.out" >&2
256
+ fail "Claude Bash installer must not write through a managed ancestor symlink"
257
+ fi
258
+
259
+ if command -v pwsh >/dev/null 2>&1; then
260
+ powershell_cancel="$TMP_ROOT/powershell-cancel"
261
+ mkdir -p "$powershell_cancel/home" "$powershell_cancel/.claude/skills/cm-ai"
262
+ printf '%s\n' 'stale cm-ai skill' > "$powershell_cancel/.claude/skills/cm-ai/SKILL.md"
263
+ (
264
+ cd "$powershell_cancel"
265
+ find . -type f -exec shasum -a 256 {} \; | sort
266
+ ) > "$TMP_ROOT/powershell-before.sha"
267
+ printf 'n\n' | USERPROFILE="$powershell_cancel/home" \
268
+ CLAUDE_HOME="$powershell_cancel/.claude" \
269
+ pwsh -NoProfile -File "$ROOT/install.ps1" \
270
+ > "$TMP_ROOT/powershell-cancel.out" 2>&1 || true
271
+ (
272
+ cd "$powershell_cancel"
273
+ find . -type f -exec shasum -a 256 {} \; | sort
274
+ ) > "$TMP_ROOT/powershell-after.sha"
275
+ if cmp -s "$TMP_ROOT/powershell-before.sha" "$TMP_ROOT/powershell-after.sha"; then
276
+ :
277
+ else
278
+ cat "$TMP_ROOT/powershell-cancel.out" >&2
279
+ fail "Claude PowerShell installer cancellation must not leave a partial upgrade"
280
+ fi
281
+
282
+ powershell_success="$TMP_ROOT/powershell-success"
283
+ mkdir -p "$powershell_success/home"
284
+ if USERPROFILE="$powershell_success/home" CLAUDE_HOME="$powershell_success/.claude" \
285
+ pwsh -NoProfile -File "$ROOT/install.ps1" -Force \
286
+ > "$TMP_ROOT/powershell-success.out" 2>&1 &&
287
+ [ -f "$powershell_success/.claude/skills/cm-ai/SKILL.md" ] &&
288
+ [ "$(tr -d '\r\n' < "$powershell_success/.claude/templates/cm-VERSION")" = "$(cat "$ROOT/VERSION")" ]; then
289
+ :
290
+ else
291
+ cat "$TMP_ROOT/powershell-success.out" >&2
292
+ fail "Claude PowerShell installer must complete an isolated atomic install"
293
+ fi
294
+
295
+ powershell_rollback="$TMP_ROOT/powershell-rollback"
296
+ mkdir -p "$powershell_rollback/home" "$powershell_rollback/.claude/skills/cm-ai"
297
+ printf '%s\n' 'stale cm-ai skill' > "$powershell_rollback/.claude/skills/cm-ai/SKILL.md"
298
+ (
299
+ cd "$powershell_rollback"
300
+ find . -type f -exec shasum -a 256 {} \; | sort
301
+ ) > "$TMP_ROOT/powershell-rollback-before.sha"
302
+ if USERPROFILE="$powershell_rollback/home" CLAUDE_HOME="$powershell_rollback/.claude" \
303
+ PATH="$installer_fail_bin:/usr/bin:/bin" \
304
+ pwsh -NoProfile -File "$ROOT/install.ps1" -Force \
305
+ > "$TMP_ROOT/powershell-rollback.out" 2>&1; then
306
+ fail "Claude PowerShell installer must fail when the installed self-check fails"
307
+ fi
308
+ (
309
+ cd "$powershell_rollback"
310
+ find . -type f -exec shasum -a 256 {} \; | sort
311
+ ) > "$TMP_ROOT/powershell-rollback-after.sha"
312
+ if cmp -s "$TMP_ROOT/powershell-rollback-before.sha" "$TMP_ROOT/powershell-rollback-after.sha"; then
313
+ :
314
+ else
315
+ cat "$TMP_ROOT/powershell-rollback.out" >&2
316
+ fail "Claude PowerShell installer must restore all managed files after self-check failure"
317
+ fi
318
+
319
+ powershell_directory_collision="$TMP_ROOT/powershell-directory-collision"
320
+ mkdir -p "$powershell_directory_collision/home" \
321
+ "$powershell_directory_collision/.claude/skills/cm-ai/SKILL.md"
322
+ printf '%s\n' 'keep directory collision' \
323
+ > "$powershell_directory_collision/.claude/skills/cm-ai/SKILL.md/marker.txt"
324
+ (
325
+ cd "$powershell_directory_collision"
326
+ find . -type f -exec shasum -a 256 {} \; | sort
327
+ ) > "$TMP_ROOT/powershell-directory-before.sha"
328
+ if USERPROFILE="$powershell_directory_collision/home" \
329
+ CLAUDE_HOME="$powershell_directory_collision/.claude" \
330
+ pwsh -NoProfile -File "$ROOT/install.ps1" -Force \
331
+ > "$TMP_ROOT/powershell-directory.out" 2>&1; then
332
+ fail "Claude PowerShell installer must reject a directory at a managed file path"
333
+ fi
334
+ (
335
+ cd "$powershell_directory_collision"
336
+ find . -type f -exec shasum -a 256 {} \; | sort
337
+ ) > "$TMP_ROOT/powershell-directory-after.sha"
338
+ if cmp -s "$TMP_ROOT/powershell-directory-before.sha" "$TMP_ROOT/powershell-directory-after.sha"; then
339
+ :
340
+ else
341
+ cat "$TMP_ROOT/powershell-directory.out" >&2
342
+ fail "Claude PowerShell installer must not partially write after a directory collision"
343
+ fi
344
+
345
+ powershell_symlink="$TMP_ROOT/powershell-symlink"
346
+ powershell_external="$TMP_ROOT/powershell-symlink-external"
347
+ mkdir -p "$powershell_symlink/home" "$powershell_symlink/.claude" "$powershell_external"
348
+ ln -s "$powershell_external" "$powershell_symlink/.claude/skills"
349
+ if USERPROFILE="$powershell_symlink/home" CLAUDE_HOME="$powershell_symlink/.claude" \
350
+ pwsh -NoProfile -File "$ROOT/install.ps1" -Force \
351
+ > "$TMP_ROOT/powershell-symlink.out" 2>&1; then
352
+ fail "Claude PowerShell installer must reject a symlinked managed ancestor"
353
+ fi
354
+ if [ -n "$(find "$powershell_external" -type f -print -quit)" ]; then
355
+ cat "$TMP_ROOT/powershell-symlink.out" >&2
356
+ fail "Claude PowerShell installer must not write through a managed ancestor symlink"
357
+ fi
358
+ fi
359
+
360
+ if [ "$FAILURES" -ne 0 ]; then
361
+ echo "shell compatibility fixtures: FAILED ($FAILURES)" >&2
362
+ exit 1
363
+ fi
364
+
365
+ echo "shell compatibility fixtures: PASSED"