@aibyzero/cm-workflow 0.17.1 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/AGENTS.md +23 -0
  3. package/CHANGELOG.md +224 -0
  4. package/README.md +14 -3
  5. package/THIRD_PARTY_NOTICES.md +13 -0
  6. package/VERSION +1 -1
  7. package/compat/claude-commands/cm-challenge.md +3 -0
  8. package/docs/architecture.md +11 -0
  9. package/docs/cm-control-policy-v2.md +127 -9
  10. package/docs/installation.md +310 -4
  11. package/docs/js-workflow-control.md +150 -15
  12. package/docs/live-evidence-drivers.md +28 -4
  13. package/docs/out-of-scope/README.md +25 -0
  14. package/docs/out-of-scope/background-supervisor.md +32 -0
  15. package/docs/reviewed-integration.md +48 -0
  16. package/docs/user-guide.md +50 -21
  17. package/install-codex.sh +331 -18
  18. package/install.ps1 +28 -2
  19. package/install.sh +321 -17
  20. package/package.json +2 -1
  21. package/runtime/js/cm-ai/batch-location.mjs +55 -0
  22. package/runtime/js/cm-ai/batch-plan.mjs +242 -0
  23. package/runtime/js/cm-ai/checkpoint-package-material.mjs +162 -0
  24. package/runtime/js/cm-ai/claude-developer-proposal.schema.json +55 -1
  25. package/runtime/js/cm-ai/claude-review-stream.mjs +83 -14
  26. package/runtime/js/cm-ai/claude-tool-preview.mjs +11 -9
  27. package/runtime/js/cm-ai/cm-ai-admission.mjs +18 -12
  28. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +91 -6
  29. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +5 -1
  30. package/runtime/js/cm-ai/codex-config.mjs +6 -2
  31. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +3 -2
  32. package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
  33. package/runtime/js/cm-ai/codex-reconnect-notice.mjs +6 -0
  34. package/runtime/js/cm-ai/codex-review-adapter.mjs +27 -7
  35. package/runtime/js/cm-ai/control-policy.mjs +21 -4
  36. package/runtime/js/cm-ai/developer-adapter.mjs +19 -5
  37. package/runtime/js/cm-ai/drive-core.mjs +114 -11
  38. package/runtime/js/cm-ai/drive-rate-limit.mjs +105 -0
  39. package/runtime/js/cm-ai/durable-runner-state.mjs +234 -33
  40. package/runtime/js/cm-ai/effect-contract.mjs +11 -2
  41. package/runtime/js/cm-ai/execution-policy.mjs +3 -1
  42. package/runtime/js/cm-ai/execution-snapshot.mjs +4 -2
  43. package/runtime/js/cm-ai/execution-store-limits.mjs +14 -7
  44. package/runtime/js/cm-ai/execution-store.mjs +60 -17
  45. package/runtime/js/cm-ai/fix-code-association.mjs +73 -2
  46. package/runtime/js/cm-ai/host-check.mjs +11 -5
  47. package/runtime/js/cm-ai/host-conversation-execution.mjs +70 -28
  48. package/runtime/js/cm-ai/host-qa-executor.mjs +38 -5
  49. package/runtime/js/cm-ai/host-qa-fix-owner.mjs +2 -2
  50. package/runtime/js/cm-ai/host-qa-policy.mjs +19 -2
  51. package/runtime/js/cm-ai/host-replay.mjs +148 -0
  52. package/runtime/js/cm-ai/host-session.mjs +1 -1
  53. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +19 -2
  54. package/runtime/js/cm-ai/host.mjs +1 -1
  55. package/runtime/js/cm-ai/implicit-qa-decision.mjs +5 -0
  56. package/runtime/js/cm-ai/integration-snapshots.mjs +50 -0
  57. package/runtime/js/cm-ai/live-evidence.mjs +28 -6
  58. package/runtime/js/cm-ai/operator-guidance.mjs +9 -2
  59. package/runtime/js/cm-ai/owned-process-cleanup.mjs +27 -9
  60. package/runtime/js/cm-ai/process-group-exit.mjs +46 -0
  61. package/runtime/js/cm-ai/provider-review-observation.mjs +3 -2
  62. package/runtime/js/cm-ai/qa-attachment.mjs +22 -0
  63. package/runtime/js/cm-ai/qa-config-revision.mjs +7 -2
  64. package/runtime/js/cm-ai/requirement-evidence.mjs +102 -0
  65. package/runtime/js/cm-ai/review-package.mjs +79 -7
  66. package/runtime/js/cm-ai/review-presentation-delta.mjs +166 -0
  67. package/runtime/js/cm-ai/review-presentation.mjs +177 -8
  68. package/runtime/js/cm-ai/reviewed-evidence-supersede.mjs +70 -2
  69. package/runtime/js/cm-ai/reviewed-integration.mjs +260 -0
  70. package/runtime/js/cm-ai/scope-revision.mjs +38 -0
  71. package/runtime/js/cm-ai/specification-material.mjs +2 -2
  72. package/runtime/js/cm-ai/task-runner.mjs +242 -39
  73. package/runtime/js/cm-ai/verification-auto.mjs +38 -0
  74. package/runtime/js/cm-ai/worker-claude-developer.mjs +39 -15
  75. package/runtime/js/cm-ai/worker-claude.mjs +35 -13
  76. package/runtime/js/cm-ai/worker-codex-developer.mjs +43 -17
  77. package/runtime/js/cm-ai/worker-codex.mjs +41 -7
  78. package/runtime/js/cm-fix/cause-invocation.mjs +16 -2
  79. package/runtime/js/cm-fix/cause-package.mjs +46 -1
  80. package/runtime/js/cm-fix/command-correction.mjs +37 -0
  81. package/runtime/js/cm-fix/cooperative.mjs +12 -0
  82. package/runtime/js/cm-fix/dossier.mjs +8 -2
  83. package/runtime/js/cm-fix/execution.mjs +578 -100
  84. package/runtime/js/cm-fix/final-review.mjs +39 -8
  85. package/runtime/js/cm-fix/finish.mjs +15 -11
  86. package/runtime/js/cm-fix/host-review.mjs +65 -10
  87. package/runtime/js/cm-fix/host.mjs +35 -12
  88. package/runtime/js/cm-fix/jest-command-correction.mjs +69 -0
  89. package/runtime/js/cm-fix/metrics.mjs +18 -5
  90. package/runtime/js/cm-fix/regression-evidence.mjs +3 -2
  91. package/runtime/js/cm-fix/regression.mjs +16 -7
  92. package/runtime/js/cm-fix/repair.mjs +29 -8
  93. package/runtime/js/cm-fix/review-verification-command.mjs +135 -0
  94. package/runtime/js/cm-fix/review-verification-contract.mjs +54 -0
  95. package/runtime/js/cm-fix/review-verification-diagnostic.mjs +75 -0
  96. package/runtime/js/cm-fix/review-verification-recovery.mjs +44 -0
  97. package/runtime/js/cm-fix/review-verification-server.mjs +38 -0
  98. package/runtime/js/cm-fix/review-verification.mjs +214 -0
  99. package/runtime/js/cm-fix/source-correction-recovery.mjs +65 -0
  100. package/runtime/js/cm-fix/start.mjs +6 -3
  101. package/runtime/js/cm-fix/test-type-correction.mjs +86 -0
  102. package/runtime/js/cm-fix/test-type-recovery.mjs +51 -0
  103. package/runtime/js/cm-fix/type-import-correction.mjs +89 -0
  104. package/runtime/js/cm-prd/accepted-design.mjs +8 -0
  105. package/runtime/js/cm-prd/analysis.mjs +13 -9
  106. package/runtime/js/cm-prd/change.mjs +37 -16
  107. package/runtime/js/cm-prd/draft-save.mjs +13 -6
  108. package/runtime/js/cm-prd/draft.mjs +31 -3
  109. package/runtime/js/cm-prd/failed-correction.mjs +19 -3
  110. package/runtime/js/cm-prd/inputs-replaced.mjs +3 -0
  111. package/runtime/js/cm-prd/review-correction.mjs +6 -4
  112. package/runtime/js/cm-prd/review-disposition.mjs +7 -1
  113. package/runtime/js/cm-prd/self-check-revision.mjs +2 -2
  114. package/runtime/js/cm-prd/self-check.mjs +125 -6
  115. package/runtime/js/cm-prd/session.mjs +30 -1
  116. package/runtime/js/cm-prd/summary.mjs +11 -5
  117. package/runtime/js/cm-prd/task-scope-record.mjs +97 -0
  118. package/runtime/js/cm-prd/tree-digest.mjs +34 -0
  119. package/runtime/js/cm-prd/validation-reason.mjs +8 -4
  120. package/runtime/js/cm-security/scan.mjs +1 -1
  121. package/runtime/js/commander/decision.mjs +44 -0
  122. package/runtime/js/commander/dispatch-registry.mjs +110 -0
  123. package/runtime/js/commander/ledger.mjs +265 -0
  124. package/runtime/js/commander/preflight.mjs +107 -0
  125. package/runtime/js/notify-later.mjs +13 -0
  126. package/runtime/js/notify-send.mjs +6 -2
  127. package/runtime/js/notify.mjs +570 -63
  128. package/runtime/js/review-findings.mjs +38 -0
  129. package/runtime/js/session-boundary.mjs +56 -0
  130. package/runtime/js/session-handoff.mjs +68 -0
  131. package/runtime/js/spec-task-line.mjs +27 -13
  132. package/runtime/js/specs-status.mjs +1 -1
  133. package/runtime/js/task-scope.mjs +197 -0
  134. package/runtime/logging.md +6 -1
  135. package/runtime/model-efficiency.md +69 -10
  136. package/runtime/orchestration.md +3 -1
  137. package/runtime/project-learning.md +2 -0
  138. package/runtime/review.md +3 -2
  139. package/runtime/test-contract.md +1 -0
  140. package/scripts/ci-test-weights.json +3 -0
  141. package/scripts/cm-ai-admission.mjs +11 -5
  142. package/scripts/cm-ai-admission.test.mjs +23 -2
  143. package/scripts/cm-ai-batch-drive.mjs +79 -18
  144. package/scripts/cm-ai-batch-drive.test.mjs +169 -3
  145. package/scripts/cm-ai-batch-host.mjs +38 -9
  146. package/scripts/cm-ai-batch-host.test.mjs +6 -5
  147. package/scripts/cm-ai-batch-learning-merge.test.mjs +36 -0
  148. package/scripts/cm-ai-batch-location.test.mjs +57 -0
  149. package/scripts/cm-ai-batch-plan.mjs +52 -0
  150. package/scripts/cm-ai-batch-plan.test.mjs +397 -0
  151. package/scripts/cm-ai-batch-run-fixture.mjs +446 -35
  152. package/scripts/cm-ai-batch-run-member-stops.test.mjs +16 -0
  153. package/scripts/cm-ai-batch-run-parallel.test.mjs +28 -1
  154. package/scripts/cm-ai-batch-run.mjs +471 -57
  155. package/scripts/cm-ai-batch-run.test.mjs +23 -4
  156. package/scripts/cm-ai-batch-session-e2e.test.mjs +235 -0
  157. package/scripts/cm-ai-batch-session-member.test.mjs +293 -0
  158. package/scripts/cm-ai-batch-session-recovery.test.mjs +423 -0
  159. package/scripts/cm-ai-check-recheck-cancellation.test.mjs +247 -0
  160. package/scripts/cm-ai-checklist-coverage.test.mjs +4 -2
  161. package/scripts/cm-ai-checkpoint-package-material.test.mjs +221 -0
  162. package/scripts/cm-ai-checkpoint-package-owner.test.mjs +193 -0
  163. package/scripts/cm-ai-control-launch.test.mjs +21 -0
  164. package/scripts/cm-ai-control-policy.test.mjs +14 -0
  165. package/scripts/cm-ai-control-v2-drive.test.mjs +398 -3
  166. package/scripts/cm-ai-control-v2-supersede-race.mjs +25 -0
  167. package/scripts/cm-ai-control-v2-supersede.test.mjs +318 -0
  168. package/scripts/cm-ai-develop-driver-gaps.test.mjs +163 -0
  169. package/scripts/cm-ai-development-rework.test.mjs +423 -0
  170. package/scripts/cm-ai-drive.mjs +73 -17
  171. package/scripts/cm-ai-drive.test.mjs +34 -2
  172. package/scripts/cm-ai-execution-store-legacy-probe.test.mjs +84 -0
  173. package/scripts/cm-ai-host.mjs +60 -19
  174. package/scripts/cm-ai-integration-adoption.test.mjs +223 -0
  175. package/scripts/cm-ai-integration-independence.test.mjs +23 -0
  176. package/scripts/cm-ai-integration-launch.test.mjs +240 -0
  177. package/scripts/cm-ai-integration-preview.mjs +41 -0
  178. package/scripts/cm-ai-integration-snapshots.test.mjs +197 -0
  179. package/scripts/cm-ai-nested-execution.test.mjs +29 -1
  180. package/scripts/cm-ai-operator-guidance.test.mjs +16 -1
  181. package/scripts/cm-ai-prefinal-delivery.test.mjs +278 -0
  182. package/scripts/cm-ai-project-qa-gate.test.mjs +56 -0
  183. package/scripts/cm-ai-qa-fingerprint-config.test.mjs +28 -0
  184. package/scripts/cm-ai-qa-rerun-timeouts.test.mjs +36 -2
  185. package/scripts/cm-ai-requirement-evidence.test.mjs +65 -0
  186. package/scripts/cm-ai-review-failure.test.mjs +150 -5
  187. package/scripts/cm-ai-run.mjs +88 -21
  188. package/scripts/cm-ai-scope-revision.test.mjs +341 -0
  189. package/scripts/cm-ai-spec-rebind.test.mjs +13 -0
  190. package/scripts/cm-ai-supersede.test.mjs +28 -0
  191. package/scripts/cm-ai-verification-auto.test.mjs +99 -0
  192. package/scripts/cm-announce-hook.mjs +35 -8
  193. package/scripts/cm-announce-hook.test.mjs +25 -0
  194. package/scripts/cm-challenge.test.mjs +61 -0
  195. package/scripts/cm-check-drive-files.mjs +1 -1
  196. package/scripts/cm-check-runtime.sh +58 -1
  197. package/scripts/cm-claude-developer-worker.test.mjs +56 -7
  198. package/scripts/cm-claude-install-layout.test.mjs +1 -1
  199. package/scripts/cm-claude-review-diagnostics.test.mjs +235 -0
  200. package/scripts/cm-claude-review-stream.test.mjs +13 -0
  201. package/scripts/cm-codex-developer-reconnect-notice.test.mjs +98 -0
  202. package/scripts/cm-codex-developer-worker.test.mjs +120 -0
  203. package/scripts/cm-codex-install-local-edit-guard.test.mjs +436 -0
  204. package/scripts/cm-codex-prompt-input.test.mjs +153 -0
  205. package/scripts/cm-codex-reconnect-notice.test.mjs +167 -0
  206. package/scripts/cm-commander-ledger.test.mjs +260 -0
  207. package/scripts/cm-commander-p2.test.mjs +295 -0
  208. package/scripts/cm-commander-preflight.mjs +84 -0
  209. package/scripts/cm-commander.mjs +116 -0
  210. package/scripts/cm-config-lock.mjs +35 -0
  211. package/scripts/cm-controlled-correction.test.mjs +10 -1
  212. package/scripts/cm-developer-failure-code.test.mjs +62 -0
  213. package/scripts/cm-display-task-id.test.mjs +41 -0
  214. package/scripts/cm-efficiency-presentation-delta.test.mjs +218 -0
  215. package/scripts/cm-execution-snapshot-reuse.test.mjs +115 -0
  216. package/scripts/cm-external-batch-host.test.mjs +4 -3
  217. package/scripts/cm-external-process-cleanup.test.mjs +128 -0
  218. package/scripts/cm-external-qa-fix.test.mjs +89 -7
  219. package/scripts/cm-external-review-reconciliation.test.mjs +11 -0
  220. package/scripts/cm-failover.mjs +48 -10
  221. package/scripts/cm-failover.test.mjs +46 -0
  222. package/scripts/cm-fix-cause-invocation.test.mjs +19 -4
  223. package/scripts/cm-fix-command-correction.mjs +17 -0
  224. package/scripts/cm-fix-command-correction.test.mjs +211 -0
  225. package/scripts/cm-fix-cooperative-closeout.test.mjs +87 -0
  226. package/scripts/cm-fix-diagnosis-module-correction.test.mjs +217 -0
  227. package/scripts/cm-fix-drive.mjs +33 -5
  228. package/scripts/cm-fix-drive.test.mjs +49 -0
  229. package/scripts/cm-fix-host-review-assembly.test.mjs +197 -1
  230. package/scripts/cm-fix-host-review.test.mjs +21 -9
  231. package/scripts/cm-fix-host.mjs +26 -8
  232. package/scripts/cm-fix-monorepo-map.test.mjs +92 -0
  233. package/scripts/cm-fix-observation-task-id.test.mjs +122 -0
  234. package/scripts/cm-fix-regression-input-budget.test.mjs +111 -0
  235. package/scripts/cm-fix-repair-input-budget.test.mjs +119 -0
  236. package/scripts/cm-fix-review-file-paging.test.mjs +91 -0
  237. package/scripts/cm-fix-review-preflight.mjs +24 -0
  238. package/scripts/cm-fix-review-storage.test.mjs +233 -0
  239. package/scripts/cm-fix-review-verification-command.test.mjs +242 -0
  240. package/scripts/cm-fix-review-verification-evidence.test.mjs +218 -0
  241. package/scripts/cm-fix-review-verification-integration.test.mjs +81 -0
  242. package/scripts/cm-fix-review-verification-recovery.test.mjs +198 -0
  243. package/scripts/cm-fix-review-verification.test.mjs +146 -0
  244. package/scripts/cm-fix-revision-transport.test.mjs +81 -0
  245. package/scripts/cm-fix-source-correction.test.mjs +296 -0
  246. package/scripts/cm-fix-test-type-correction.mjs +18 -0
  247. package/scripts/cm-fix-test-type-correction.test.mjs +123 -0
  248. package/scripts/cm-fix-test-type-owner.test.mjs +208 -0
  249. package/scripts/cm-fix-test-type-verification-cost.test.mjs +66 -0
  250. package/scripts/cm-fix-type-import-correction.test.mjs +95 -0
  251. package/scripts/cm-fix-verification-diagnostic.test.mjs +200 -0
  252. package/scripts/cm-fix-verification-recovery.mjs +33 -0
  253. package/scripts/cm-host-qa-executor.test.mjs +77 -0
  254. package/scripts/cm-host-replay.test.mjs +176 -0
  255. package/scripts/cm-install-local-edit-guard.test.mjs +621 -0
  256. package/scripts/cm-install-manifest.sh +351 -0
  257. package/scripts/cm-live-evidence.test.mjs +59 -1
  258. package/scripts/cm-log-event.mjs +61 -10
  259. package/scripts/cm-log-event.test.mjs +121 -1
  260. package/scripts/cm-matt-skills.mjs +576 -0
  261. package/scripts/cm-matt-skills.test.mjs +550 -0
  262. package/scripts/cm-notify-command.test.mjs +42 -10
  263. package/scripts/cm-notify.mjs +14 -10
  264. package/scripts/cm-notify.test.mjs +575 -59
  265. package/scripts/cm-patrol.mjs +4 -1
  266. package/scripts/cm-patrol.test.mjs +23 -5
  267. package/scripts/cm-prd-answer-gaps.test.mjs +2 -2
  268. package/scripts/cm-prd-completion.test.mjs +56 -13
  269. package/scripts/cm-prd-design-phase.test.mjs +78 -8
  270. package/scripts/cm-prd-draft-save.test.mjs +12 -0
  271. package/scripts/cm-prd-draft.test.mjs +1 -1
  272. package/scripts/cm-prd-drive.mjs +13 -6
  273. package/scripts/cm-prd-drive.test.mjs +45 -1
  274. package/scripts/cm-prd-gate-diagnostic.test.mjs +2 -2
  275. package/scripts/cm-prd-host.mjs +10 -5
  276. package/scripts/cm-prd-host.test.mjs +4 -2
  277. package/scripts/cm-prd-inputs-replaced.test.mjs +1 -1
  278. package/scripts/cm-prd-review-disposition.test.mjs +124 -8
  279. package/scripts/cm-prd-revision.test.mjs +1 -1
  280. package/scripts/cm-prd-self-check-revision.test.mjs +1 -1
  281. package/scripts/cm-prd-self-check-rules.test.mjs +239 -0
  282. package/scripts/cm-prd-self-check.test.mjs +105 -5
  283. package/scripts/cm-prd-summary.test.mjs +24 -3
  284. package/scripts/cm-prd-task-grouping.test.mjs +6 -6
  285. package/scripts/cm-prd-tree-digest.test.mjs +74 -0
  286. package/scripts/cm-refactor-drive.mjs +2 -1
  287. package/scripts/cm-refactor-drive.test.mjs +9 -0
  288. package/scripts/cm-release-smoke.sh +1 -1
  289. package/scripts/cm-skill-hints-autowire.test.mjs +394 -0
  290. package/scripts/cm-skill-hints-exam.mjs +149 -0
  291. package/scripts/cm-skill-hints-install.test.mjs +168 -0
  292. package/scripts/cm-skill-hints.exam.json +706 -0
  293. package/scripts/cm-skill-hints.json +119 -0
  294. package/scripts/cm-skill-hints.mjs +669 -0
  295. package/scripts/cm-skill-hints.test.mjs +831 -0
  296. package/scripts/cm-skill-judge.mjs +181 -0
  297. package/scripts/cm-skill-judge.test.mjs +255 -0
  298. package/scripts/cm-specs-status.test.mjs +4 -2
  299. package/scripts/cm-start-check.mjs +208 -0
  300. package/scripts/cm-start-check.test.mjs +321 -0
  301. package/scripts/cm-task-gate.mjs +150 -29
  302. package/scripts/cm-task-gate.test.mjs +73 -1
  303. package/scripts/cm-task-id-grammar.test.mjs +66 -0
  304. package/scripts/cm-task-scope.test.mjs +308 -0
  305. package/scripts/cm-upgrade-compat-batch.test.mjs +172 -0
  306. package/scripts/cm-upgrade-compat.test.mjs +239 -0
  307. package/scripts/cm-workflow-config.mjs +12 -2
  308. package/scripts/fixtures/fix-verification-claude.mjs +44 -0
  309. package/scripts/fixtures/reviewed-integration.mjs +202 -0
  310. package/scripts/scan-public-safety.py +1 -0
  311. package/scripts/session-boundary.test.mjs +170 -0
  312. package/scripts/test-npm-install.py +14 -3
  313. package/scripts/test-shell-compat.sh +2 -0
  314. package/scripts/validate-public-repo.py +1 -0
  315. package/scripts/validate-test-cases.mjs +3 -2
  316. package/skills/cm-ai/SKILL.md +5 -2
  317. package/skills/cm-ai/references/N4-review.md +2 -1
  318. package/skills/cm-ai/references/N6-qa-eval.md +3 -1
  319. package/skills/cm-ai/references/N8-finish.md +22 -0
  320. package/skills/cm-ai/references/js-host-qa-recovery.md +1 -1
  321. package/skills/cm-ai/references/js-host-recovery.md +79 -3
  322. package/skills/cm-ai/references/js-host.md +56 -16
  323. package/skills/cm-challenge/SKILL.md +65 -0
  324. package/skills/cm-challenge/evals/README.md +18 -0
  325. package/skills/cm-challenge/evals/trigger-cases.json +20 -0
  326. package/skills/cm-challenge/evals/trigger-config.json +28 -0
  327. package/skills/cm-challenge/references/examples.md +15 -0
  328. package/skills/cm-check/SKILL.md +5 -0
  329. package/skills/cm-check/references/js-host.md +2 -0
  330. package/skills/cm-fix/SKILL.md +12 -3
  331. package/skills/cm-fix/references/command-correction.md +67 -0
  332. package/skills/cm-fix/references/isolated-review.md +54 -0
  333. package/skills/cm-fix/references/js-host.md +62 -2
  334. package/skills/cm-fix/references/test-type-correction.md +72 -0
  335. package/skills/cm-fix/references/verification-recovery.md +114 -0
  336. package/skills/cm-idea/SKILL.md +2 -0
  337. package/skills/cm-idea/references/js-host.md +2 -0
  338. package/skills/cm-notify/SKILL.md +2 -0
  339. package/skills/cm-prd/SKILL.md +12 -8
  340. package/skills/cm-prd/references/brownfield.md +8 -1
  341. package/skills/cm-prd/references/change-mode.md +6 -0
  342. package/skills/cm-prd/references/greenfield.md +4 -0
  343. package/skills/cm-prd/references/js-host.md +4 -2
  344. package/skills/cm-prd/references/spec-self-check.md +5 -1
  345. package/skills/cm-refactor/SKILL.md +8 -0
  346. package/skills/cm-refactor/references/js-host.md +2 -0
  347. package/skills/cm-test/SKILL.md +4 -0
  348. package/templates/dashboard/dashboard.html +2 -2
  349. package/templates/pixel/cm-pixel.html +1 -1
  350. package/templates/pixel/cm-pixel.sh +1 -1
  351. package/templates/pixel/dev/template.html +1 -1
  352. package/templates/statusline/cm-statusline.sh +1 -1
@@ -53,6 +53,7 @@ JS 缺少运行条件时会报告缺口,不会静默切回旧流程。默认
53
53
 
54
54
  | 你现在的情况 | 使用入口 | 会改业务源码吗? | 完成后的下一步 |
55
55
  | --- | --- | --- | --- |
56
+ | 推敲已有方案 | `$cm-challenge`,可说“三轮对抗分析”或“先 grill me” | 否,只在对话中给建议 | 需要实施时另走既有规格/变更流程 |
56
57
  | 只有一个模糊点子 | `$cm-idea` | 否,只产出 PRD | 把 PRD 放入 specs 的 `docs/`,运行 `$cm-prd` |
57
58
  | 第一次接管已有项目 | `$cm-init` | 否,但会生成项目规则和上下文 | 准备需求文档或直接测试已有功能 |
58
59
  | 已有需求文档 | `$cm-prd {specs路径}` | 否,只整理规格 | 人工审查摘要、方案和任务 |
@@ -74,6 +75,7 @@ Codex 与 Claude Code 会先根据 Skill 的 `description` 判断入口。自然
74
75
 
75
76
  | 入口 | 明确点名 | 自然表达 | 模糊或越界时 |
76
77
  | --- | --- | --- | --- |
78
+ | `cm-challenge` | `$cm-challenge 对这个方案做三轮对抗分析` | “挑战这个方案的假设,给最终建议” | 点子转 PRD、正式审查与直接实现仍走原流程 |
77
79
  | `cm-idea` | `$cm-idea 帮我梳理这个点子` | “我有个产品想法,先帮我聊清楚” | 已有完整需求文档 → `cm-prd` |
78
80
  | `cm-init` | `$cm-init` | “第一次接管这个仓库,先生成项目规则” | 空项目或普通改代码 → 不触发 |
79
81
  | `cm-prd` | `$cm-prd {specs路径}` | “把这份需求拆成方案、任务和验收标准” | 要求直接编码 → 先确认 specs 是否已审批 |
@@ -182,8 +184,20 @@ $cm-prd ~/projects/my-app-specs
182
184
  `approved / changes_requested / blocked`。只有当前轮为 `approved` 时,N5 才能标记
183
185
  完成;第 1 轮要求修改会回到实现,第 2 轮仍阻塞则停止等待人工处理。
184
186
 
185
- 默认仍是串行。只读探索可以并行;两个任务要同时修改代码时,必须位于同一仓库的
186
- 不同 Git Worktree 和不同分支,否则工作流自动降级串行。
187
+ 单代码根的项目,`$cm-ai` 默认让每个任务都在自己的 Git Worktree 和分支里开发,做完按任务顺序合回主目录
188
+ (被阻断改为串行重做的除外,它在主目录重做再合)。写了 `- 范围:`、文件不重叠、互不依赖的任务还会同时开发。
189
+ 例外的任务直接在主目录串行:功能的最后一个任务、批次里最后执行的任务、标了 `- 设备: 需要` 的任务。
190
+ 有任务没写范围或是脚手架功能时,整个功能都在主目录串行。
191
+ 功能有浏览器等交互式验收用例时,凑不成组的任务也留在主目录串行,避免验收连到主目录的服务、测到没合并的代码。
192
+ 批次里没有 QA 修复出口,所以可能在中途触发 QA 的任务(改到登记的关键路径,或可能是连续第 5 个没跑 QA 的任务)也留在主目录;
193
+ 主目录的项目配置文件和当前提交里的不一致时(没提交,或用 skip-worktree 之类藏了本地改动)同样不单独开 worktree。
194
+ 最终以 worktree 建好后两边实际读到的配置为准:开发前发现不一样就不开发,批次停下并提示怎么改;批次不会自动删除这个 worktree,提示里给出路径和手动清理命令,确认里面没有要保留的内容后再自己删。生成批次时用 `--workflow-config` 把工作流配置传给 `cm-ai-batch-plan.mjs`。
195
+ 单独在 worktree 里开发的任务,QA 仍按固定检查点判断;万一需要跑却没通过,批次停下,不合并,
196
+ 提示你合并它的分支、用 `/cm-fix` 修复、再用新批次继续剩余任务。
197
+ 同组一起开发的多个任务不逐个跑 QA,统一到功能最后一个任务跑一次。
198
+ 项目配置里写 `parallel: {worktree_all: false}` 只让能同时开发的任务进 worktree,其余回到主目录串行;
199
+ 写 `parallel: {enabled: false}` 完全不建 worktree;`max` 调每组人数(默认 2,最多 4)。
200
+ 只读探索可以并行;不满足上述条件时工作流自动串行。
187
201
 
188
202
  ```text
189
203
  $cm-ai ~/projects/my-app-specs ~/code/my-app
@@ -528,7 +542,11 @@ CM 不保存、不显示任何 token;密钥只在你自己填写的本机文
528
542
 
529
543
  **什么时候提醒**
530
544
 
531
- - 驾驶员(`scripts/*-drive.mjs`)一步结束后停在需要人的状态:blocked、unknown、次数用完、`requiresUser`,或驾驶员自己拒绝继续。
545
+ - 驾驶员(`scripts/*-drive.mjs`)一步结束后停在需要人的状态:blocked、unknown、次数用完、`requiresUser`,或驾驶员自己拒绝继续。分两种:
546
+ - **立即推送**:只有你本人能拍板或授权的事——规格要批准(`awaiting_spec_approval`)、规格被改过(`spec_drift`)、各种授权(代码以 `_authorization_required`/`_approval_required` 结尾、`permission_denied`)、两轮审查都没过(`review_limit`)、审查判定改不好(`review_blocked`)、审查多次没结论或自动重试次数用完(`review_redispatch_limit`、`*_retry_limit` 等)、要你授权才能走的恢复出口(`pendingAction` 为 `abandon_review`、`abandon_effect`、`develop_redo`、`bootstrap_review_recover`、`spec_rebind`)、驾驶员要你回答的确认,以及流程停下来问你问题或等你确认(cm-prd 的 `awaiting_*_user`、`change_confirmation`、带问题的 `change_requirements/design/tasks/check`,cm-idea 的提问,cm-init 的 `confirmation_required`,cm-refactor 的 `awaiting_finish`,cm-fix 的 `requiresUser`)。判断「要你回答」和判断「要人处理」用的是同一份分类结果。
547
+ - **延后推送**:其余停下(如审查失败要重派、检查没通过、QA 已触发、宿主中途退出)先等 `waitMinutes` 分钟(默认 10)。这期间会话只要接着做了下一步(宿主接下新一步,或这一步有了进展),这条就作废、不发;仍停着才发。同一会话连续停几次只发最后一次。等待由一个脱离驾驶员的小进程计时,电脑关机、睡眠或这个小进程被杀时就不发。待发记录放在 `notify-pending/`:这个目录必须是你自己的、权限 700 的真实目录(不能是符号链接,也不能指向通知目录以外);不满足时不读、不写、不删,延后类提醒一律不发,改为每天最多一条「延后提醒不可用:.cm-workflow 目录下的 notify-pending 权限或类型不安全……修好前普通停顿不会提醒」的配置故障提醒;需要你本人处理的停下照常立即推送。
548
+ - provider 开发进程(Codex 直接写代码、Claude 出修改提案)被限流或碰到 API 错误时,结果会标出类别(如 `developer_rate_limited`),但不会自动重试:重做这一轮开发要你授权(宿主会先核对旧开发进程已退出)。这时立即推送,「你要做」写「开发进程被限流(429):过一刻钟后回到会话「X」,授权它重做这一轮开发」。
549
+ - 审查被限流(Codex/Claude 返回 429)时,`cm-ai` 的单任务和批次驾驶员会自己等一会儿再在原运行重派这一次审查,期间不推送(批次由批次宿主在批次锁里先核对批次和成员都还停在那次限流),见 `skills/cm-ai/references/js-host-recovery.md`「审查被限流时自动等待重试」。重派由宿主在运行的写锁里核对:仍是原来那一轮、那个审查包、那一次失败的审查调用,才只重派这一次审查;状态变了就不派发任何操作。重试后仍被限流才推送,并按真实出口写动作:同一轮第二次限流要你确认旧审查进程已停后授权放弃再重派;只有出口仍是原运行重派时,才写「过半小时后回到会话说继续即可」。
532
550
  - 整个流程结束(如 `run_done`)时提醒一次,告诉你跑完了。
533
551
  - 宿主向会话提问(`host_request`,如 qa_browser、develop、fix_diagnose)后,超过 `waitMinutes` 分钟没有应答,每个提问只提醒一次。
534
552
  - 宿主一步做完后一直开着,手上没有进行中的操作,会话却超过 `idleMinutes` 分钟没发下一步,提醒一次:上一步停在要人处理的状态时标题是「在等你」,否则是「疑似空转」。只读的 `status` 查询不算下一步。驾驶员一步结束就关宿主,不会触发这一条。
@@ -551,6 +569,8 @@ cm-ai、批次和 cm-fix 的提问本来就有自己的计时(最长 60 分钟
551
569
  - 会话自己派出去的子代理、后台命令和等待脚本,宿主看不见;它们卡住或被工具时限停掉,不会直接触发这里的提醒(只有当它们导致宿主的提问没人应答时,才会间接触发「等待会话应答」)。减少这类空转靠派发纪律(见 `skills/cm-ai/references/js-host.md`「启动前」第 7 项)。
552
570
  - 流程结果里的「已发送」只表示提醒命令已经启动,不表示送达。
553
571
 
572
+ **临时关掉某次运行的提醒**:在启动流程的命令前加环境变量 `CM_NOTIFY_OFF=1`。只要有值且不是 `0` 就算关闭(写成 `false` 也是关闭;要打开就不设或设为 `0`)。这个进程和它启动的宿主、审查、开发、检查命令和延后计时等子进程,一律不发流程自动提醒,也不写 `notify.log`、待发记录和宿主登记。你明确要求的 `/cm:notify test` 不受影响,照常发一条测试推送并在 `notify.log` 记一行;直接手动运行发送器本身也不受影响。只影响带了这个变量的环境,不改 `notify.json`,别处正在跑的流程照常提醒。适合在项目副本上做验收实跑、演示,不想手机收到看不懂的推送时用。不要用把 `CM_WORKFLOW_HOME` 指到临时目录的办法代替:那样连用户级的运行时声明(`runtimes.yml`)等其他设置也一起换掉了。`/cm:notify` 查看时如果当前环境带了这个变量,会多写一行说明。
573
+
554
574
  **用 /cm:notify 配置(推荐)**
555
575
 
556
576
  暂不支持 Windows:在 Windows 上切换、`test`(含演练模式)和发送器本身(含 `--check`)都会以退出码 2 拒绝,提示「/cm:notify 暂不支持 Windows:密钥文件权限核对尚未在 Windows 实机验证」;查看只显示渠道和密钥文件是否存在,不读取密钥内容(渠道文件也按同样的安全方式读:不跟随符号链接、限制大小、核对是同一个文件);`off` 和只读的 `preview` 照常可用。两个入口一启动就先做这项拒绝,在这之前不访问文件。需要在 Windows 上推送,可先按下文「手动配置」用自己的命令。
@@ -603,13 +623,15 @@ node 被移动或升级到别的目录后,旧路径会失效(`notify.log`
603
623
  ```
604
624
 
605
625
  - `command`:要运行的程序和参数,第一项必须是绝对路径;不经过 shell。
606
- - `waitMinutes`:等待会话应答多久后提醒,默认 10。
626
+ - `waitMinutes`:等待会话应答多久后提醒,默认 10。驾驶员停下后不需要你本人拍板的提醒,也先等这么久,期间会话有动作就不发(见上文「什么时候提醒」)。
607
627
  - `checkWaitMinutes`:宿主请求「跑检查」(`check`、`verification_precheck`、`init_verify`)时,会话要先跑完项目的检查命令(如 xcodebuild、测试套件),正常就要几十分钟,所以这三类提问只看这个门槛,默认 45;其他提问仍看 `waitMinutes`。
608
628
  - `idleMinutes`:宿主一步做完后等下一步多久算空转,默认 45。真实项目里正常的开发加检查一段常见 45~60 分钟,但那时宿主手上有进行中的操作,不计入。
609
629
  - `text`:可选,自定义提醒文案,见下文「自定义文案」。
630
+ - `frequency`:可选,调提醒频率,见下文「限流与日志」。
631
+ - `layout`:可选,`"full"`(默认)或 `"compact"`。`compact` 只写三样:标题是项目,副标题是「会话:会话标题」(没有标题时用会话短编号,都没有时写流程名),正文是为什么停下,再加一行「你要做:……」(流程结束时没有这一行;行首标签沿用 `text.labels.nextAction`,没改过时写「你要做」;内容见下文「消息长什么样」的动作表)。为什么停下只写中文(没有中文对照的原因代码改写成该事件的标题词,原代码仍在标准输入那行 JSON 的 `code` 里)。写成其他值时整个提醒功能关闭并在 `notify.log` 记一行。`compact` 下 `text` 里只有两样起作用:`headlines`(原因翻不成中文或流程结束时用它)和 `labels.nextAction`(只用作「你要做」那一行的行首标签);`titlePrefix`、`fields` 和其他 `labels` 都不生效。原因代码先查常用对照,没有对照时按代码里的词拼出中文(例如 `review_verification_failed` 写成「审查失败」),仍拼不出来才用标题词。巡检发现宿主已退出时,会话写那个宿主登记时记下的会话标题,不用运行巡检的会话。
610
632
  - 文件格式不对时,功能关闭,只在 `notify.log` 记一行,不往流程输出里打印。只有 `text` 写错时例外:提醒照常发送,改用默认文案。
611
633
 
612
- 命令通过环境变量 `CM_NOTIFY_TITLE`(不超过 60 字)、`CM_NOTIFY_BODY`(不超过 500 字)拿到内容。
634
+ 命令通过环境变量 `CM_NOTIFY_TITLE`(不超过 60 字)、`CM_NOTIFY_SUBTITLE`(副标题,不超过 60 字)、`CM_NOTIFY_BODY`(不超过 500 字)拿到内容;`CM_NOTIFY_GROUP` 是分组名(项目)、`CM_NOTIFY_LEVEL` 是建议的响铃级别(`timeSensitive`、`active` 或 `passive`)。内置的 Bark 发送器会把副标题、分组和级别原样带上,pushplus 把副标题放在正文第一行。
613
635
  标准输入还会收到一行同样内容的 JSON。
614
636
  命令在后台独立运行,流程不等它结束;15 秒内没结束会被终止。
615
637
 
@@ -618,26 +640,27 @@ node 被移动或升级到别的目录后,旧路径会失效(`notify.log`
618
640
  下面是默认文案,可在 `notify.json` 的 `text` 里改(见下文「自定义文案」);空的字段整行省略。要人处理(卡住、等待应答、空转、宿主退出)时:
619
641
 
620
642
  ```text
621
- CM cm-fix 需要人处理 · demo-app
622
- 下一步:核对 reason 后恢复原运行
623
- 项目:demo-app
624
- 流程:cm-fix
625
- 任务:T-001
626
- 阶段:blocked
627
- 原因:checks_not_passed
643
+ CM 需要人处理 · cm-workflow-e2e-real/app
644
+ cm-ai · 12.app-version-footer T-001 · 会话 4f9fa27f
645
+ 下一步:回到会话,回答 QA 判定
646
+ 卡在:在等 QA 判定(qa_decision_required)
628
647
  时间:16:00
629
648
  ```
630
649
 
631
- 流程结束时只写项目、任务和时间:
650
+ 流程结束时:
632
651
 
633
652
  ```text
634
- CM cm-ai 流程已结束 · demo-app
635
- 项目:demo-app
636
- 任务:T-003
653
+ CM 流程已结束 · cm-workflow-e2e-real/app
654
+ cm-ai · T-003 · 会话 4f9fa27f
655
+ 下一步:会话边界:换新会话,下一项在新会话里运行
637
656
  时间:16:00
638
657
  ```
639
658
 
640
- 第一行是标题,其余是正文。时间是本机时区(遵循 `TZ` 环境变量)的 24 小时制「时:分」。运行编号默认不进正文,仍在标准输入那行 JSON 的 `runId` 字段里。
659
+ - 第一行是标题:标题词加项目。项目取代码目录的最后两级,`app` 这类常见目录名也分得清;两级同名时(如 `cm-workflow/cm-workflow`)只显示一级。
660
+ - 第二行是副标题:流程、功能和任务、会话。会话优先写 Claude Code 侧边栏里的会话标题:从环境变量 `CLAUDE_CODE_SESSION_ID` 找到 `~/.claude/projects/*/<会话编号>.jsonl`(设置了 `CLAUDE_CONFIG_DIR` 时在那个目录下),只读文件最后 1 MiB 里最近一条你改过的标题(没有就用自动标题)。不进入是符号链接的项目目录,不读符号链接或非普通文件(如管道),打开后再核对一次目录和文件没被换掉;读取过程中有人反复并发替换项目目录不在防护范围内——能替换这个目录的人本来就能直接改写会话记录里的标题。找不到标题时(例如在 Codex 里运行)写驾驶员启动宿主时 `--host-context` 的值,UUID 只取前 8 位。驾驶员启动时会在本会话输出里打印一行 `[drive] 提醒里的标识:项目 … · 会话 …`。会话标题除了显示在副标题里,也会出现在交给发送命令的标准输入 JSON(`sessionTitle` 字段)和本机宿主登记文件(`~/.cm-workflow/hosts/`)里。
661
+ - 「下一步」写给你看:驾驶员给的下一步是空的、超过 80 字,或带着参数、代码名、文件名(如 `--allow-…`、`reviewer_rate_limited`、`.json`)时,改用按原因代码写好的大白话动作,例如审查失败写「回到会话「X」说「继续」,让它重派审查」,QA 已触发写「回到会话「X」说「继续」,让它执行 QA」,规格要批准写「打开规格确认内容,再回到会话「X」说「批准」」,要授权写「回到会话「X」,看它要你授权什么;同意就说「授权」」;没有对应动作时写「回到会话「X」,让它说明停在哪、需要你做什么」。「X」是会话标题,没有标题时用会话短编号。标准输入那行 JSON 另有 `action` 字段放这句动作。
662
+ - 其余是正文。常见的原因代码会翻成中文,括号里保留原代码方便搜索。时间是本机时区(遵循 `TZ` 环境变量)的 24 小时制「时:分」。运行编号默认不进正文,仍在标准输入那行 JSON 的 `runId` 字段里。
663
+ - Bark 按项目分组,同一项目的提醒在手机上折叠在一起;要人处理的提醒用 `timeSensitive`,「流程已结束」用 `passive`(不响铃)。
641
664
 
642
665
  **自定义文案(可选)**
643
666
 
@@ -653,23 +676,29 @@ CM cm-ai 流程已结束 · demo-app
653
676
  }}
654
677
  ```
655
678
 
656
- - `titlePrefix`:标题开头,默认 `CM`;写空字符串就不要前缀。标题仍是「前缀 流程 标题词 · 项目」。
679
+ - `titlePrefix`:标题开头,默认 `CM`;写空字符串就不要前缀。标题是「前缀 标题词 · 项目」;流程、功能、任务和会话在副标题里,不受 `text` 影响。
657
680
  - `headlines`:各事件的标题词。键只能是 `done`(流程已结束)、`waiting`(等待会话应答)、`idle`(疑似空转)、`idle_waiting`(在等你)、`dead`(宿主已退出未收尾)、`default`(其他要人处理的情况,默认「需要人处理」)。
658
681
  - `fields`:正文显示哪些字段、按什么顺序。`default` 用于要人处理的提醒,`done` 用于流程结束;每项是不重复、至少一个的字段名列表。
659
682
  - `labels`:字段前的名字。
660
- - 字段名只能是 `project`(项目)、`workflow`(流程)、`runId`(运行)、`task`(任务)、`stage`(阶段)、`code`(原因)、`nextAction`(下一步)、`time`(时间)。不支持模板、占位符或表达式。
683
+ - 字段名只能是 `project`(项目)、`workflow`(流程)、`runId`(运行)、`feature`(功能)、`task`(任务)、`stage`(阶段)、`code`(卡在)、`nextAction`(下一步)、`time`(时间)。默认 `default` 是 `nextAction`、`code`、`time`,`done` 是 `nextAction`、`time`。不支持模板、占位符或表达式。
661
684
  - 自定义的字符串先删掉所有 Unicode 格式字符(文字方向控制符 U+202A–202E、U+2066–2069、U+200E/200F、U+061C,零宽字符 U+200B–200D、U+2060、U+FEFF,软连字符等),防止倒序或隐藏文字;换行等控制字符换成空格;然后从 `/`、`~/`、盘符加 `:\` 或 `:/`、`\\` 开始,到下一个空白、引号或 `,。;;、))` 为止的部分一律换成 `<路径>`,不管前面贴着什么字符(所以 `CI/CD` 会变成 `CI<路径>`,自定义文字里别用斜杠);前缀最多 16 个字、标题词 24 个、标签 12 个,超出截断。整条标题 60 字、正文 500 字的上限不变。
662
685
  - `text` 写错(键名拼错、字段名不认识、类型不对、去掉上述字符后没有可见的文字、数字、标点或符号;前缀只有写成 `""` 才表示不要前缀)时,提醒不会被关掉,整份 `text` 不生效、改用默认文案,`notify.log` 记一行 `default_text text_config <原因>`;`/cm:notify` 查看会写「文案:默认(notify.json 里的 text 无效:<原因>…)」。
663
686
  - 改完先跑 `/cm:notify preview` 看效果,不会发出任何推送。
664
687
 
665
688
  **限流与日志**
666
689
 
667
- - 同一件事 6 小时内只提醒一次;所有提醒合计每分钟最多 4 条、24 小时最多 150 条。
690
+ - 同一个会话(同一项目、同一 `--host-context`;没有会话标识时按项目、流程和运行)要人处理的提醒合成一件事:卡住、等待会话应答、空转只推一条。只有状态升级(例如从空转变成在等应答)或卡住的原因换了才重新推。
691
+ - 宿主还在等(等待会话应答、空转)时,2 小时后仍没处理会再推一条,开头写「第 2 次提醒」,之后不再推,直到状态变化或 24 小时后;会话先应答或宿主结束会取消补发。驾驶员结束时报的卡住没有进程留下来补发,只在同一会话下次再触发提醒且已过 2 小时时,才以「第 2 次提醒」发出。
692
+ - 驾驶员这一步有了进展(结果不再卡住)时清掉这件事,下次再卡住会立刻提醒;只清进展之前记下的,进展之后新记的卡住保留。还在等着发的延后提醒(记在 `notify-pending/` 下,一个会话一个小文件)同样按这条规则清掉;同一会话发出立即提醒时,等着发的那条也作废。状态文件正被占用时会短暂重试,仍失败就在 `notify.log` 记一行 `clear … failed`。
693
+ - 没有会话标识、宿主也没返回运行编号时(例如启动即退出),按启动参数区分不同运行。
694
+ - 「流程已结束」每个运行和任务 6 小时内只提醒一次。
695
+ - 所有提醒合计每 10 分钟最多 3 条、24 小时最多 150 条。超出的不单独推,下一条发出的提醒末尾写「另有 N 条提醒为避免刷屏已合并」。
696
+ - 可在 `notify.json` 里写 `"frequency": {"followUpMinutes": 120, "windowMinutes": 10, "perWindow": 3}` 调整补发间隔、窗口长度和窗口内条数(分钟 1–1440,条数 1–50);写错时整个提醒功能关闭并在 `notify.log` 记一行。
668
697
  - 计数记在 `notify-state.json`;发送失败或被限流只在 `notify.log` 追加一行,不影响流程结果和退出码。
669
698
 
670
699
  **隐私**
671
700
 
672
- 消息只含项目目录名、流程、运行编号、任务、阶段、原因代码和下一步提示。
701
+ 消息只含项目目录的最后两级、流程、运行编号、功能、任务、会话标题或标识、阶段、原因代码和下一步提示。
673
702
  不含文件内容、日志、diff、审查意见、环境变量或项目目录以外的路径(绝对路径会被替换成 `<路径>`;字段值里紧贴在英文字母、数字或 `_ . ~ -` 后面的斜杠不当作路径开头,例如 `a/b`、`v1.2/x` 原样保留)。
674
703
  这些文字会经过你选的推送服务,对方能看到;介意的话不要启用。
675
704
 
package/install-codex.sh CHANGED
@@ -23,8 +23,24 @@ VALIDATE_PLUGIN="$CREATOR_ROOT/scripts/validate_plugin.py"
23
23
  UPDATE_CACHEBUSTER="$CREATOR_ROOT/scripts/update_plugin_cachebuster.py"
24
24
  READ_MARKETPLACE="$CREATOR_ROOT/scripts/read_marketplace_name.py"
25
25
  ASSUME_YES=0
26
+ OVERWRITE_LOCAL_EDITS=0
27
+ # Non-empty when --no-skill-hints is given: this run does not wire the skill-hints hook.
28
+ SKIP_SKILL_HINTS=""
29
+ # Non-empty when --no-matt-skills is given: this run does not install the companion skills.
30
+ SKIP_MATT_SKILLS=""
31
+ # Records what this install wrote so the next install can tell hand edits apart.
32
+ INSTALL_MANIFEST_NAME=".cm-install-manifest.sha256"
33
+ INSTALL_MANIFEST="$PLUGIN_DEST/$INSTALL_MANIFEST_NAME"
34
+ GUARD_TMP=""
35
+ # One install transaction per target; never taken over automatically. The path
36
+ # is set from the canonical target below (shared rule with install.sh).
37
+ LOCK_DIR=""
38
+ LOCK_HELD=0
39
+ ROLLBACK_FAILED=0
26
40
  INSTALL_COMPLETE=0
27
41
  DEST_REPLACED=0
42
+ # Set before the old plugin is moved aside, so cleanup knows a restore may be due.
43
+ PLUGIN_MOVED_ASIDE=0
28
44
  MARKETPLACE_TOUCHED=0
29
45
  MARKETPLACE_EXISTED=0
30
46
  MARKETPLACE_BACKUP="$PLUGIN_PARENT/.cm-workflow.marketplace.backup.$$"
@@ -65,38 +81,161 @@ if ! NODE_BIN="$(find_node)"; then
65
81
  exit 1
66
82
  fi
67
83
 
68
- case "${1:-}" in
69
- "") ;;
70
- --yes) ASSUME_YES=1 ;;
71
- *)
72
- echo "Usage: $0 [--yes]" >&2
84
+ for arg in "$@"; do
85
+ case "$arg" in
86
+ --yes) ASSUME_YES=1 ;;
87
+ --overwrite-local-edits) OVERWRITE_LOCAL_EDITS=1 ;;
88
+ --no-skill-hints) SKIP_SKILL_HINTS=1 ;;
89
+ --no-matt-skills) SKIP_MATT_SKILLS=1 ;;
90
+ *)
91
+ echo "Usage: $0 [--yes] [--overwrite-local-edits] [--no-skill-hints] [--no-matt-skills]" >&2
92
+ exit 2
93
+ ;;
94
+ esac
95
+ done
96
+
97
+ # shellcheck source=scripts/cm-install-manifest.sh
98
+ . "$SRC_DIR/scripts/cm-install-manifest.sh"
99
+
100
+ # Managed roots must be real directories and the marketplace a real file, so no
101
+ # write can be redirected through a symlink, and every spelling of the target
102
+ # resolves to one canonical path (one lock identity).
103
+ # One structure check for the marketplace and its managed parents, used at
104
+ # entry, right before the helper writes it, and right before rollback writes
105
+ # it: ~/.agents and ~/.agents/plugins must be real directories (or missing) and
106
+ # marketplace.json a regular file (or missing). Prints the offending path.
107
+ marketplace_structure_problem() {
108
+ for marketplace_dir in "$(dirname "$MARKETPLACE_ROOT")" "$MARKETPLACE_ROOT"; do
109
+ # A directory that cannot be searched would make the marketplace look
110
+ # missing; treat it as a problem rather than as "no marketplace yet".
111
+ if [ -L "$marketplace_dir" ] || { [ -e "$marketplace_dir" ] && { [ ! -d "$marketplace_dir" ] || [ ! -x "$marketplace_dir" ]; }; }; then
112
+ printf '%s\n' "$marketplace_dir"
113
+ return 0
114
+ fi
115
+ done
116
+ if [ -L "$MARKETPLACE_PATH" ] || { [ -e "$MARKETPLACE_PATH" ] && [ ! -f "$MARKETPLACE_PATH" ]; }; then
117
+ printf '%s\n' "$MARKETPLACE_PATH"
118
+ return 0
119
+ fi
120
+ return 1
121
+ }
122
+
123
+ for managed_path in "$PLUGIN_PARENT" "$PLUGIN_DEST"; do
124
+ if [ -L "$managed_path" ]; then
125
+ echo "Refusing a symlinked install path: $managed_path. Installation stopped; nothing was changed." >&2
73
126
  exit 2
74
- ;;
75
- esac
127
+ fi
128
+ done
129
+ if [ -e "$PLUGIN_PARENT" ] && [ ! -d "$PLUGIN_PARENT" ]; then
130
+ echo "Install path must be a directory: $PLUGIN_PARENT. Installation stopped; nothing was changed." >&2
131
+ exit 2
132
+ fi
133
+ if marketplace_problem=$(marketplace_structure_problem); then
134
+ echo "Refusing a symlinked or wrong-type install path: $marketplace_problem. Installation stopped; nothing was changed." >&2
135
+ exit 2
136
+ fi
137
+ if ! PLUGIN_DEST_CANONICAL=$(cm_install_canonical_target "$PLUGIN_DEST"); then
138
+ echo "Cannot resolve the plugin directory: $PLUGIN_DEST. Installation stopped; nothing was changed." >&2
139
+ exit 2
140
+ fi
141
+ PLUGIN_DEST="$PLUGIN_DEST_CANONICAL"
142
+ PLUGIN_PARENT="$(dirname "$PLUGIN_DEST")"
143
+ STAGE="$PLUGIN_PARENT/.cm-workflow.stage.$$"
144
+ BACKUP="$PLUGIN_PARENT/.cm-workflow.backup.$$"
145
+ SCAFFOLD_PARENT="$PLUGIN_PARENT/.cm-workflow.scaffold.$$"
146
+ MARKETPLACE_BACKUP="$PLUGIN_PARENT/.cm-workflow.marketplace.backup.$$"
147
+ FAILED_DEST="$PLUGIN_PARENT/.cm-workflow.failed.$$"
148
+ FAILED_MARKETPLACE="$PLUGIN_PARENT/.cm-workflow.marketplace.failed.$$"
149
+ INSTALL_MANIFEST="$PLUGIN_DEST/$INSTALL_MANIFEST_NAME"
150
+ LOCK_DIR="$(cm_install_lock_path "$PLUGIN_DEST")"
151
+
152
+ # PLUGIN_PARENT is the physical directory resolved at entry; a later symlink
153
+ # or different physical path there means it was replaced during the install.
154
+ plugin_parent_unchanged() {
155
+ [ ! -L "$PLUGIN_PARENT" ] && [ -d "$PLUGIN_PARENT" ] && [ -x "$PLUGIN_PARENT" ] &&
156
+ [ "$(cd "$PLUGIN_PARENT" 2>/dev/null && pwd -P)" = "$PLUGIN_PARENT" ]
157
+ }
158
+
159
+ # Rollback keeps going after a failed step (no errexit, signals ignored), keeps
160
+ # every recovery copy whenever anything could not be restored, and always
161
+ # unlocks.
162
+ rollback_fail() {
163
+ echo " Restore failed: $1" >&2
164
+ ROLLBACK_FAILED=1
165
+ }
76
166
 
77
167
  cleanup() {
78
168
  status=$?
79
- trap - EXIT HUP INT TERM
80
- if [ "$INSTALL_COMPLETE" -ne 1 ]; then
169
+ set +e
170
+ trap '' HUP INT TERM
171
+ trap - EXIT
172
+ # The plugins directory must be searchable for any existence test below to
173
+ # mean anything; otherwise report the restore as incomplete, never skip it.
174
+ parent_ok=1
175
+ { [ -d "$PLUGIN_PARENT" ] && [ -x "$PLUGIN_PARENT" ]; } || parent_ok=0
176
+ if [ "$INSTALL_COMPLETE" -ne 1 ] && [ "$parent_ok" -eq 0 ]; then
177
+ if [ "$DEST_REPLACED" -eq 1 ] || [ "$PLUGIN_MOVED_ASIDE" -eq 1 ]; then
178
+ rollback_fail "$PLUGIN_DEST (the plugins directory cannot be accessed; the previous plugin is expected at $BACKUP)"
179
+ fi
180
+ if [ "$MARKETPLACE_TOUCHED" -eq 1 ] && [ "$MARKETPLACE_EXISTED" -eq 1 ]; then
181
+ rollback_fail "$MARKETPLACE_PATH (its backup in the plugins directory cannot be accessed: $MARKETPLACE_BACKUP)"
182
+ elif [ "$MARKETPLACE_TOUCHED" -eq 1 ]; then
183
+ rollback_fail "$MARKETPLACE_PATH (left in place: it can only be moved aside into the plugins directory, which cannot be accessed)"
184
+ fi
185
+ fi
186
+ if [ "$INSTALL_COMPLETE" -ne 1 ] && [ "$parent_ok" -eq 1 ]; then
81
187
  if [ "$DEST_REPLACED" -eq 1 ] && [ -e "$PLUGIN_DEST" ]; then
82
- mv "$PLUGIN_DEST" "$FAILED_DEST"
188
+ mv "$PLUGIN_DEST" "$FAILED_DEST" || rollback_fail "$PLUGIN_DEST (new plugin could not be moved aside)"
83
189
  fi
84
- if [ -d "$BACKUP" ] && [ ! -e "$PLUGIN_DEST" ]; then
85
- mv "$BACKUP" "$PLUGIN_DEST"
190
+ if [ -d "$BACKUP" ]; then
191
+ if [ ! -e "$PLUGIN_DEST" ] && [ ! -L "$PLUGIN_DEST" ]; then
192
+ mv "$BACKUP" "$PLUGIN_DEST" || rollback_fail "$PLUGIN_DEST (previous plugin is in $BACKUP)"
193
+ else
194
+ rollback_fail "$PLUGIN_DEST (occupied; previous plugin is in $BACKUP)"
195
+ fi
86
196
  fi
87
197
  if [ "$MARKETPLACE_TOUCHED" -eq 1 ]; then
88
- if [ "$MARKETPLACE_EXISTED" -eq 1 ] && [ -f "$MARKETPLACE_BACKUP" ]; then
89
- cp "$MARKETPLACE_BACKUP" "$MARKETPLACE_PATH"
198
+ if marketplace_problem=$(marketplace_structure_problem); then
199
+ rollback_fail "$MARKETPLACE_PATH (not written: $marketplace_problem is a symlink or the wrong type)"
200
+ elif [ "$MARKETPLACE_EXISTED" -eq 1 ] && [ -f "$MARKETPLACE_BACKUP" ]; then
201
+ cp "$MARKETPLACE_BACKUP" "$MARKETPLACE_PATH" || rollback_fail "$MARKETPLACE_PATH"
90
202
  elif [ -f "$MARKETPLACE_PATH" ]; then
91
- mv "$MARKETPLACE_PATH" "$FAILED_MARKETPLACE"
203
+ mv "$MARKETPLACE_PATH" "$FAILED_MARKETPLACE" || rollback_fail "$MARKETPLACE_PATH"
92
204
  fi
93
205
  fi
94
206
  fi
95
- rm -rf "$STAGE" "$SCAFFOLD_PARENT" "$FAILED_DEST" "$FAILED_MARKETPLACE"
96
- rm -f "$MARKETPLACE_BACKUP"
207
+ if [ "$INSTALL_COMPLETE" -ne 1 ] && [ "$ROLLBACK_FAILED" -eq 1 ]; then
208
+ if [ "$parent_ok" -eq 1 ]; then
209
+ echo "Installation failed and the rollback is incomplete. Recovery copies were kept:" >&2
210
+ for kept in "$BACKUP" "$FAILED_DEST" "$MARKETPLACE_BACKUP" "$FAILED_MARKETPLACE"; do
211
+ [ ! -e "$kept" ] || echo " $kept" >&2
212
+ done
213
+ else
214
+ echo "Installation failed and the rollback is incomplete. The plugins directory cannot be accessed, so recovery copies could not be checked; restore access, then look for:" >&2
215
+ for kept in "$BACKUP" "$FAILED_DEST" "$MARKETPLACE_BACKUP" "$FAILED_MARKETPLACE"; do
216
+ echo " $kept" >&2
217
+ done
218
+ fi
219
+ fi
220
+ rm -rf "$STAGE" "$SCAFFOLD_PARENT"
221
+ if [ "$ROLLBACK_FAILED" -ne 1 ]; then
222
+ rm -rf "$FAILED_DEST" "$FAILED_MARKETPLACE"
223
+ rm -f "$MARKETPLACE_BACKUP"
224
+ fi
225
+ [ -z "$GUARD_TMP" ] || rm -rf "$GUARD_TMP"
97
226
  if [ "$INSTALL_COMPLETE" -eq 1 ]; then
98
227
  rm -rf "$BACKUP"
99
228
  fi
229
+ if [ "$LOCK_HELD" -eq 1 ]; then
230
+ if plugin_parent_unchanged; then
231
+ rm -rf "$LOCK_DIR" || echo "Could not release the install lock: $LOCK_DIR" >&2
232
+ elif [ "$parent_ok" -eq 0 ] && [ ! -L "$PLUGIN_PARENT" ]; then
233
+ echo "The plugins directory cannot be accessed, so the install lock was not released. Restore access, check no install is running, then remove it: $(cm_install_quote "$LOCK_DIR")" >&2
234
+ else
235
+ # Never delete through a replaced parent: the lock may be elsewhere now.
236
+ echo "The plugins directory was replaced during the install, so the lock location cannot be confirmed. Find and remove it by hand after checking no install is running: $(cm_install_quote "$LOCK_DIR")" >&2
237
+ fi
238
+ fi
100
239
  exit "$status"
101
240
  }
102
241
  trap cleanup EXIT
@@ -110,6 +249,69 @@ if [ ! -f "$CREATE_PLUGIN" ]; then
110
249
  exit 1
111
250
  fi
112
251
 
252
+ # Stop before any write when a file recorded by the previous install changed.
253
+ # --yes only accepts replacing the plugin; it never discards hand edits.
254
+ # Runs up front, again after the replace prompt (before the marketplace is
255
+ # touched), and once more right before the plugin directory is swapped, because
256
+ # another session may edit an installed file while this one waits or stages.
257
+ guard_local_edits() {
258
+ guard_mode=${1:-initial}
259
+ if ! cm_manifest_select_hasher; then
260
+ echo "Neither shasum nor sha256sum was found, so local edits to the installed plugin cannot be checked. Installation stopped; nothing was changed." >&2
261
+ return 2
262
+ fi
263
+ if ! plugin_parent_unchanged; then
264
+ echo "The plugins directory is no longer the one checked at start, or cannot be searched: $PLUGIN_PARENT. Installation stopped." >&2
265
+ return 2
266
+ fi
267
+ if [ -L "$PLUGIN_DEST" ]; then
268
+ echo "Refusing to read an install manifest through a symlinked plugin directory: $PLUGIN_DEST" >&2
269
+ return 2
270
+ fi
271
+ # A manifest path that exists as a directory, symlink or other non-file is a
272
+ # corrupt manifest, not a pre-manifest install.
273
+ manifest_access=0
274
+ cm_manifest_parent_is_safe "$PLUGIN_DEST" "$INSTALL_MANIFEST_NAME" || manifest_access=$?
275
+ if [ "$manifest_access" -eq 2 ]; then
276
+ echo "The plugin directory cannot be searched, so whether an install manifest exists cannot be told: $PLUGIN_DEST. Installation stopped; nothing was changed." >&2
277
+ return 2
278
+ fi
279
+ if [ ! -e "$INSTALL_MANIFEST" ] && [ ! -L "$INSTALL_MANIFEST" ]; then
280
+ [ "$guard_mode" = recheck ] ||
281
+ echo "No previous install manifest found (first install or installed by an older version); local edits are not checked this time. A manifest is written after a successful install."
282
+ return 0
283
+ fi
284
+ edits="$GUARD_TMP/local-edits"
285
+ if cm_manifest_find_edits "$PLUGIN_DEST" "$INSTALL_MANIFEST" "$edits" "$GUARD_TMP"; then
286
+ :
287
+ else
288
+ find_status=$?
289
+ if [ "$find_status" -ne 3 ]; then
290
+ echo "Checking installed files failed. Installation stopped; nothing was changed." >&2
291
+ return 2
292
+ fi
293
+ echo "Unrecognized install manifest: $INSTALL_MANIFEST" >&2
294
+ if [ "$OVERWRITE_LOCAL_EDITS" -eq 1 ]; then
295
+ echo "--overwrite-local-edits given; skipping the local-edit check and writing a new manifest."
296
+ return 0
297
+ fi
298
+ echo "Installation stopped; nothing was changed. Rerun with --overwrite-local-edits to replace the installed plugin." >&2
299
+ return 1
300
+ fi
301
+ [ -s "$edits" ] || return 0
302
+ if [ "$OVERWRITE_LOCAL_EDITS" -eq 1 ] && [ "$guard_mode" = recheck ]; then
303
+ return 0
304
+ fi
305
+ echo "These installed CM files changed since the last install (sha256 differs from the install manifest):" >&2
306
+ sed 's/^/ /' "$edits" >&2
307
+ if [ "$OVERWRITE_LOCAL_EDITS" -eq 1 ]; then
308
+ echo "--overwrite-local-edits given; these edits will be replaced."
309
+ return 0
310
+ fi
311
+ echo "Installation stopped; nothing was changed. --yes does not discard local edits. Save or merge them first, then rerun with --overwrite-local-edits to discard them." >&2
312
+ return 1
313
+ }
314
+
113
315
  run_official_validation() {
114
316
  target=$1
115
317
  if [ -f "$VALIDATE_PLUGIN" ] && "$PYTHON_BIN" -c 'import yaml' >/dev/null 2>&1; then
@@ -120,9 +322,58 @@ run_official_validation() {
120
322
  fi
121
323
  }
122
324
 
325
+ mkdir -p "$PLUGIN_PARENT"
326
+ cm_defer_signals
327
+ if cm_install_lock_acquire "$LOCK_DIR"; then
328
+ LOCK_HELD=1
329
+ cm_install_test_hook lock-acquired
330
+ cm_install_lock_write_owner "$LOCK_DIR" "$PLUGIN_DEST"
331
+ fi
332
+ cm_resume_signals
333
+ if [ "$LOCK_HELD" -eq 1 ]; then
334
+ :
335
+ elif [ ! -d "$LOCK_DIR" ] || [ -L "$LOCK_DIR" ]; then
336
+ echo "Cannot create the install lock: $LOCK_DIR. Installation stopped; nothing was changed." >&2
337
+ exit 2
338
+ else
339
+ lock_pid=$(cm_install_lock_field "$LOCK_DIR" pid)
340
+ lock_started=$(cm_install_lock_field "$LOCK_DIR" started)
341
+ lock_state=$(cm_install_lock_pid_state "$lock_pid")
342
+ echo "Another CM install is writing the same target. Installation stopped; nothing was changed." >&2
343
+ echo " Lock: $LOCK_DIR" >&2
344
+ echo " Holder pid: ${lock_pid:-unknown} (started ${lock_started:-unknown})" >&2
345
+ case "$lock_state" in
346
+ alive) echo " That process is still running; retry after it finishes." >&2 ;;
347
+ not-running) echo " That process is no longer running; the lock may be left over from an interrupted install." >&2
348
+ echo " After confirming no install is in progress, remove it manually and retry:" >&2
349
+ echo " rm -rf $(cm_install_quote "$LOCK_DIR")" >&2 ;;
350
+ *) echo " Cannot tell whether that process is still running. After confirming no install is in progress, remove it manually and retry:" >&2
351
+ echo " rm -rf $(cm_install_quote "$LOCK_DIR")" >&2 ;;
352
+ esac
353
+ exit 4
354
+ fi
355
+
356
+ GUARD_TMP="$(mktemp -d "${TMPDIR:-/tmp}/cm-install-guard.XXXXXX")"
357
+ run_local_edit_guard() {
358
+ if guard_local_edits "$1"; then
359
+ :
360
+ else
361
+ guard_status=$?
362
+ [ "$guard_status" -eq 1 ] && exit 3
363
+ exit "$guard_status"
364
+ fi
365
+ }
366
+ run_local_edit_guard initial
367
+
123
368
  "$PYTHON_BIN" "$SRC_DIR/scripts/validate-public-repo.py"
124
369
  "$SRC_DIR/scripts/cm-check-runtime.sh" --project "$SRC_DIR"
125
370
  run_official_validation "$SRC_DIR"
371
+ # Re-check the marketplace structure before the first directory is created.
372
+ cm_install_test_hook before-marketplace-check
373
+ if marketplace_problem=$(marketplace_structure_problem); then
374
+ echo "Refusing a symlinked or wrong-type install path: $marketplace_problem. Installation stopped; nothing was changed." >&2
375
+ exit 2
376
+ fi
126
377
  mkdir -p "$PLUGIN_PARENT" "$MARKETPLACE_ROOT"
127
378
 
128
379
  if [ -d "$PLUGIN_DEST" ] && [ "$(cd "$PLUGIN_DEST" && pwd -P)" = "$SRC_DIR" ]; then
@@ -140,8 +391,14 @@ if [ -e "$PLUGIN_DEST" ] && [ "$ASSUME_YES" -ne 1 ]; then
140
391
  esac
141
392
  fi
142
393
 
394
+ run_local_edit_guard recheck
395
+
143
396
  # Use the first-party helper to own marketplace.json updates, but scaffold in
144
397
  # a disposable directory so an interrupted install cannot damage the plugin.
398
+ if marketplace_problem=$(marketplace_structure_problem); then
399
+ echo "Refusing a symlinked or wrong-type install path: $marketplace_problem. Installation stopped; nothing was changed." >&2
400
+ exit 2
401
+ fi
145
402
  if [ -f "$MARKETPLACE_PATH" ]; then
146
403
  cp "$MARKETPLACE_PATH" "$MARKETPLACE_BACKUP"
147
404
  MARKETPLACE_EXISTED=1
@@ -181,11 +438,57 @@ fi
181
438
  run_official_validation "$STAGE"
182
439
  "$STAGE/scripts/cm-check-runtime.sh" --project "$STAGE"
183
440
 
441
+ # Hash the exact bytes that will be installed (after the cache-version stamp).
442
+ (cd "$STAGE" && find . -type f | sed 's#^\./##' | LC_ALL=C sort) > "$GUARD_TMP/managed-files"
443
+ if ! cm_manifest_write "$STAGE" "$GUARD_TMP/managed-files" "$GUARD_TMP/new-manifest"; then
444
+ echo "Writing the install manifest failed. Installation stopped; the existing plugin was not replaced." >&2
445
+ exit 1
446
+ fi
447
+ cp "$GUARD_TMP/new-manifest" "$STAGE/$INSTALL_MANIFEST_NAME"
448
+
449
+ # Final check right before the installed plugin is swapped out; an exit here
450
+ # restores the marketplace through cleanup.
451
+ run_local_edit_guard recheck
452
+
184
453
  if [ -e "$PLUGIN_DEST" ]; then
454
+ if [ -L "$PLUGIN_DEST" ] || [ ! -d "$PLUGIN_DEST" ]; then
455
+ echo "Plugin directory changed type during the install: $PLUGIN_DEST. Installation stopped." >&2
456
+ exit 3
457
+ fi
458
+ cm_install_test_hook before-plugin-rename
459
+ PLUGIN_MOVED_ASIDE=1
185
460
  mv "$PLUGIN_DEST" "$BACKUP"
461
+ # Edits written by path before the rename landed in the moved directory, so
462
+ # one last check there closes the gap after the recheck above. An exit here
463
+ # moves the old plugin back and restores the marketplace through cleanup.
464
+ backup_access=0
465
+ cm_manifest_parent_is_safe "$BACKUP" "$INSTALL_MANIFEST_NAME" || backup_access=$?
466
+ if [ "$OVERWRITE_LOCAL_EDITS" -ne 1 ] && [ "$backup_access" -ne 0 ]; then
467
+ echo "The previous plugin directory cannot be checked; it was restored and nothing was replaced: $PLUGIN_DEST" >&2
468
+ exit 2
469
+ fi
470
+ if [ "$OVERWRITE_LOCAL_EDITS" -ne 1 ] && [ -f "$BACKUP/$INSTALL_MANIFEST_NAME" ] &&
471
+ [ ! -L "$BACKUP/$INSTALL_MANIFEST_NAME" ]; then
472
+ if cm_manifest_find_edits "$BACKUP" "$BACKUP/$INSTALL_MANIFEST_NAME" "$GUARD_TMP/late-edits" "$GUARD_TMP"; then
473
+ late_status=0
474
+ else
475
+ late_status=$?
476
+ fi
477
+ if [ "$late_status" -ne 0 ] || [ -s "$GUARD_TMP/late-edits" ]; then
478
+ echo "Installed CM files changed during the install; the previous plugin was restored and nothing was replaced:" >&2
479
+ [ ! -s "$GUARD_TMP/late-edits" ] || sed 's/^/ /' "$GUARD_TMP/late-edits" >&2
480
+ [ "$late_status" -eq 0 ] || [ "$late_status" -eq 3 ] || exit 2
481
+ exit 3
482
+ fi
483
+ fi
186
484
  fi
187
- mv "$STAGE" "$PLUGIN_DEST"
485
+ # Register the swap together with the rename: a signal in between is held
486
+ # until DEST_REPLACED is set, so cleanup always knows to put the old plugin back.
487
+ cm_defer_signals
488
+ cm_run_shielded mv "$STAGE" "$PLUGIN_DEST"
188
489
  DEST_REPLACED=1
490
+ cm_install_test_hook after-stage-moved
491
+ cm_resume_signals
189
492
 
190
493
  if [ -f "$READ_MARKETPLACE" ]; then
191
494
  marketplace_name="$("$PYTHON_BIN" "$READ_MARKETPLACE" --marketplace-path "$MARKETPLACE_PATH")"
@@ -204,3 +507,13 @@ echo
204
507
  echo "CM Workflow installed for Codex from: $PLUGIN_DEST"
205
508
  echo "User guide: $PLUGIN_DEST/docs/user-guide.md"
206
509
  echo "Start a new Codex thread, then run \$cm-check, \$cm-prd, or \$cm-test."
510
+ # Skill hints: wire the hook into ~/.codex/hooks.json once by default (not with
511
+ # --no-skill-hints, CM_SKILL_HINTS_INSTALL=off, "enabled": false, or after the user removed
512
+ # it); otherwise only refresh the copy. Codex trust stays the user's. Failure only warns.
513
+ node "$PLUGIN_DEST/scripts/cm-skill-hints.mjs" install --host codex ${SKIP_SKILL_HINTS:+--no-skill-hints} </dev/null ||
514
+ echo "⚠ 技能提醒钩子未处理完(不影响本次安装)" >&2
515
+ # Optional Matt Pocock companion skills: put the pinned set in by default (not with
516
+ # --no-matt-skills, CM_MATT_SKILLS_INSTALL=off, {"install": false} in ~/.cm-workflow/matt-skills.local.json,
517
+ # or a skill the user removed after CM saw it there); a fetch that fails only warns.
518
+ echo
519
+ node "$PLUGIN_DEST/scripts/cm-matt-skills.mjs" auto ${SKIP_MATT_SKILLS:+--no-matt-skills} </dev/null || true
package/install.ps1 CHANGED
@@ -1,10 +1,12 @@
1
1
  param(
2
2
  [switch]$Force,
3
- [switch]$Yes
3
+ [switch]$Yes,
4
+ [switch]$NoSkillHints,
5
+ [switch]$NoMattSkills
4
6
  )
5
7
 
6
8
  # CM Workflow Claude Code compatibility installer for Windows.
7
- # Usage: powershell -ExecutionPolicy Bypass -File install.ps1 [-Force] [-Yes]
9
+ # Usage: powershell -ExecutionPolicy Bypass -File install.ps1 [-Force] [-Yes] [-NoSkillHints] [-NoMattSkills]
8
10
  $ErrorActionPreference = "Stop"
9
11
  if ($Yes) { $Force = $true }
10
12
 
@@ -200,6 +202,30 @@ if ($InstallComplete) {
200
202
  if ($LASTEXITCODE -ne 0) { throw "运行时声明未完成(核心安装已成功)" }
201
203
  }
202
204
 
205
+ # Skill hints: wire the hook into Claude settings once by default (not with -NoSkillHints,
206
+ # CM_SKILL_HINTS_INSTALL=off, "enabled": false, or after the user removed it); otherwise
207
+ # only refresh the copy the hook runs. Any failure only warns.
208
+ try {
209
+ $HintArgs = @("install", "--host", "claude")
210
+ if ($NoSkillHints) { $HintArgs += "--no-skill-hints" }
211
+ & node (Join-Path $Dest "scripts/cm-skill-hints.mjs") @HintArgs
212
+ if ($LASTEXITCODE -ne 0) { Write-Warning "技能提醒钩子未处理完(不影响本次安装)" }
213
+ } catch {
214
+ Write-Warning "技能提醒钩子未处理完(不影响本次安装):$($_.Exception.Message)"
215
+ }
216
+
217
+ # Optional Matt Pocock companion skills: put the pinned set in by default (not with
218
+ # -NoMattSkills, CM_MATT_SKILLS_INSTALL=off, {"install": false} in ~/.cm-workflow/matt-skills.local.json,
219
+ # or a skill the user removed after CM saw it there); a fetch that fails only warns.
220
+ try {
221
+ $MattArgs = @("auto")
222
+ if ($NoMattSkills) { $MattArgs += "--no-matt-skills" }
223
+ & node (Join-Path $Dest "scripts/cm-matt-skills.mjs") @MattArgs
224
+ if ($LASTEXITCODE -ne 0) { Write-Warning "作者技能未处理完(不影响本次安装)" }
225
+ } catch {
226
+ Write-Warning "作者技能未处理完(不影响本次安装):$($_.Exception.Message)"
227
+ }
228
+
203
229
  Write-Host "`n完成(已安装版本: v$Version)。请在 Claude Code 中运行 /cm-check 校验。"
204
230
  Write-Host "使用手册: $(Join-Path $Dest 'cm-workflow\docs\user-guide.md')"
205
231
  Write-Host @"