@aibyzero/cm-workflow 0.25.0 → 0.25.1

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 (46) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +6 -1
  4. package/VERSION +1 -1
  5. package/docs/installation.md +28 -10
  6. package/docs/js-workflow-control.md +2 -1
  7. package/package.json +1 -1
  8. package/runtime/js/cm-ai/claude-probe-diagnosis.mjs +21 -0
  9. package/runtime/js/cm-ai/claude-review-stream.mjs +20 -7
  10. package/runtime/js/cm-ai/claude-tool-preview.mjs +4 -2
  11. package/runtime/js/cm-ai/host-conversation-execution.mjs +7 -1
  12. package/runtime/js/cm-ai/worker-claude-developer.mjs +3 -1
  13. package/runtime/js/cm-ai/worker-claude.mjs +5 -1
  14. package/runtime/js/cm-check/host.mjs +13 -3
  15. package/runtime/js/cm-prd/review-channels.mjs +5 -0
  16. package/runtime/js/cm-prd/review-publication.mjs +2 -1
  17. package/scripts/cm-ai-batch-host.mjs +10 -3
  18. package/scripts/cm-ai-batch-host.test.mjs +1 -0
  19. package/scripts/cm-ai-batch-run.mjs +2 -1
  20. package/scripts/cm-ai-host.mjs +4 -1
  21. package/scripts/cm-check-host.test.mjs +54 -0
  22. package/scripts/cm-check-runtime.sh +18 -15
  23. package/scripts/cm-check-update.mjs +83 -8
  24. package/scripts/cm-check-update.test.mjs +114 -1
  25. package/scripts/cm-claude-developer-worker.test.mjs +29 -1
  26. package/scripts/cm-claude-managed-preflight.test.mjs +126 -0
  27. package/scripts/cm-claude-probe.test.mjs +5 -0
  28. package/scripts/cm-claude-review-stream.test.mjs +4 -1
  29. package/scripts/cm-claude-worker.test.mjs +29 -0
  30. package/scripts/cm-fix-review-preflight.mjs +2 -0
  31. package/scripts/cm-fix-review-verification-integration.test.mjs +19 -0
  32. package/scripts/cm-prd-drive.mjs +2 -1
  33. package/scripts/cm-prd-drive.test.mjs +17 -0
  34. package/scripts/cm-prd-review-gate.mjs +2 -1
  35. package/scripts/cm-prd-review-publication.test.mjs +34 -0
  36. package/scripts/cm-release-smoke.sh +3 -2
  37. package/scripts/cm-workflow-config.test.mjs +8 -3
  38. package/scripts/fixtures/prd-review-gate-python-oracle.py +1 -1
  39. package/scripts/scan-public-safety.py +1 -0
  40. package/scripts/shell-pipe-early-exit.test.mjs +96 -0
  41. package/scripts/test-cm-prd-review-gate.py +30 -0
  42. package/scripts/test-shell-compat.sh +7 -5
  43. package/skills/cm-ai/references/js-host-recovery.md +1 -0
  44. package/skills/cm-check/SKILL.md +3 -0
  45. package/skills/cm-fix/references/isolated-review.md +1 -1
  46. package/templates/auto-update/cm-update.sh +2 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-workflow",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "Spec-driven product development workflow for Codex: external research, PRD, implementation, read-only feature testing, review, QA, fixes, refactors, and documentation.",
5
5
  "author": {
6
6
  "name": "cm-workflow maintainers",
package/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@
7
7
 
8
8
  (暂无)
9
9
 
10
+ ## 0.25.1 — 2026-12-03
11
+
12
+ - **cm-check 自动升级遇本机改动时,经你明确同意可直接覆盖**:安装器以 3 停止后,`/cm-check` 用安装器自己的清单核对函数列出被改过的文件(`localEdits`),附上这份清单的摘要(`localEditsDigest`)。你明确同意丢弃这些文件后,它带 `--overwrite-local-edits <摘要>` 重跑同一更新命令。重跑前会重新核对:清单多出或少了文件、安装清单缺失或格式损坏、已没有改动、核对失败,都会停下,不交覆盖参数给安装器。默认仍只传 `--yes`。这份绑定只到安装器启动为止:安装器的覆盖参数对所有改动生效,最后一次核对之后、安装器替换完文件之前新改的文件仍可能被覆盖,同意前先结束其他 CM 会话。
13
+ - **安装自检不再偶发误报**:`cm-check-runtime.sh` 在 `pipefail` 下用 `printf | grep -q` 查文本,`grep` 提前退出时前一个命令会被管道中断,检查偶尔报「cm-prd single-round reviews have no crash-safe disposition recovery gate」等失败,实际文字都在。查文本改用 shell 自带的 `case` 比较,不经管道、不建临时文件;发布冒烟、测试脚本和自动更新脚本里同类写法一并改掉,输出与原来一致。新增 `scripts/shell-pipe-early-exit.test.mjs`:开了 `pipefail` 的脚本里,管道(含跨行)接 `grep -q/-l/-m`、`head`、`awk … exit` 或 `sed … q` 就报错。
14
+ - **托管环境下 Claude 工具预检过不了时,说清可能原因和出路**:预检要把 `ANTHROPIC_BASE_URL` 指向本机探测地址,核对审查时只开放了允许的工具。组织的托管设置固定了接口地址、或不许改这个变量时,Claude 命令行能启动,但用于核对工具的消息请求到不了,预检永远失败,以前只报 `passed:false`。现在命令行已启动、却没收到消息请求时,`cm-ai-host.mjs preflight`、`cm-fix-review-preflight.mjs` 会在 stderr 说明可能原因;单任务的 `tool_preflight_missing` 和批次的 `review_preflight_failed` 也带上同一段原因。出路是在不受托管限制的机器上对同一代码根预检和审查,或新建运行时按角色声明改由 Codex 审查;cm-fix 的隔离审查只支持 Claude,只给第一条出路。命令找不到、模型不认等已有原因的失败不显示这段说明。新预检回执多一个 `cli_started` 字段。CM 没有别的办法确认 Claude 审查时工具已被关掉,所以照旧拦住,不加跳过开关。
15
+ - **只用 Claude 的用户也能完成规格独立审查**:`claude-only` 预设把审查方配成 `claude-cli`,但 `/cm-prd` 的答案检查、审查发布和证据回读只认两个 Codex 通道,规格审查走不下去。现在 `/cm-prd` 的原审查(r1)接受 `claude-cli`,按 Codex 通道同样的规则判定:只核对声明格式和前后一致,不证明审查真是独立做的;独立审查的会话不能是作者会话,原审查遇到未知通道照旧拒绝。`/cm-prd` 的通道清单与任务审查的清单由测试保持一致,以后任一方加减通道,都要先决定 `/cm-prd` 接不接。
16
+ - **`/cm-check` 自动升级被安装器拦下时,说清原因和手动出口**:本机改过 CM 文件、安装清单无效或路径类型变了,安装器会以 3 停止;如已写入文件,会尝试回滚,结果见安装器输出。以前 `/cm-check` 只报「安装器失败」;现在会说明这几种可能,提醒阻断安装的路径异常或未完成的回滚要先按安装器输出处理,并指出怎样在新建的空目录里解包、手动运行安装器加 `--overwrite-local-edits` 丢弃改动。(本版另一条已扩展:经你明确同意后可由 `/cm-check` 代为覆盖。)
17
+ - **Claude 写代码和审查时能走自己的 API 网关**:以前 CM 启动 Claude 子进程时把 `ANTHROPIC_BASE_URL` 去掉了,设了网关地址的用户审查和开发都连不上。现在这一个变量会传下去;代理、Bedrock/Vertex 开关、`NODE_OPTIONS` 等其他路由变量仍不传。工具预检照旧用自己的本机探测地址。
18
+ - **公司统一下发的 SessionStart 钩子不再让 Claude 审查和开发报错**:托管钩子会在 Claude 命令行正式开始前输出 `hook_started` / `hook_response`,以前审查(含工具预检)报 `missing_init`,开发进程在开始前后都会报错。现在把它们当作启动通知:计入通知上限,只上报类型和钩子名这类摘要,钩子输出内容不转发,也不算开始。
19
+ - **Python 3.14 下安装不再因自检失败而回滚**:Python 3.14 在环境里有 `FORCE_COLOR=1`(终端或 Node 测试运行器会设置)时给命令行帮助上色,安装末尾自检里的配置测试按纯文本比对,必定失败并整体回滚,回滚还会删掉刚装的文档范围清单,之后再检查会报「兼容安装缺少范围清单」。现在这条测试调用 Python 时关掉颜色。
20
+ - **`/cm-check` 在 Claude 安装模式下不再被版本文件卡住**:版本号存在没有扩展名的 `templates/cm-VERSION` 里,以前检查工具不收它当证据,语义检查第 7 组一引用就被判「证据无效」。现在 CM 自己 `templates/` 下文件名不带点、不超过 16 MiB 的文字文件(版本文件和钩子模板)能引用,检查期间被改动也会被发现;这类文件若是二进制内容,只查改动、不能引用。
21
+
10
22
  ## 0.25.0 — 2026-12-03
11
23
 
12
24
  - **技能自动调用默认不再用 Jev 判断**:handoff、wayfinder、improve-codebase-architecture 三个技能该不该用,默认只看本机关键词,消息一个字都不外发。以前只要有 TypeSafe 密钥就会把消息前 500 字发给 Jev;现在要在 `~/.cm-workflow/skill-hints.local.json` 写 `"judge": true` 才开。已写 `"judge": false` 的不受影响。`/cm-check` 和安装提示同步改了说法。升级没能换掉的旧钩子仍可能按旧规则外发:运行副本复制失败时,安装和 `/cm-check` 会提醒;要立即停止,在旧钩子运行时读取的 CM 目录(宿主进程的 `CM_WORKFLOW_HOME`,未设置时为 `~/.cm-workflow`)下的 `skill-hints.local.json` 写 `"judge": false`,用过几个目录就每个都写。换过 `CM_WORKFLOW_HOME` 的,旧目录挂在 `~/.claude/settings.json`、`~/.codex/hooks.json` 里的钩子,`/cm-check` 和安装时会逐条列出,不需要就删掉。凡是提到这个脚本、又不是规规矩矩跑本目录副本的钩子命令都会列出,可能有误报。已知缺口:把脚本名拆开拼接的命令、命令写的是本目录副本、但名叫 `node` 的程序实为转发旧副本的包装程序,以及 CM 不读的配置(如项目自己的 `.claude/settings.json`)里的钩子查不出来,需要自己检查;`node` 所在路径含单引号时认不出 CM 自己挂的钩子,再次开启会多挂一条。开启 Jev 后发出的前 500 字包含代码块,代码块只在关键词判断时跳过。
package/README.md CHANGED
@@ -17,6 +17,11 @@
17
17
 
18
18
  ## 最近更新
19
19
 
20
+ **0.25.1**
21
+
22
+ - **只用 Claude 的用户能完成更多环节**:`claude-only` 预设下,规格独立审查接受 `claude-cli`;Claude 子进程带上 `ANTHROPIC_BASE_URL`,走网关的用户能审查和开发;公司下发的 SessionStart 钩子不再让 Claude 审查和开发报 `missing_init`。托管环境固定了接口地址时,Claude 工具预检照旧拦住,只是会说明可能的原因和出路。
23
+ - **升级与自检更稳**:修复 Python 3.14 在 `FORCE_COLOR` 下安装自检失败回滚;修复 `cm-check-runtime.sh` 在 `pipefail` 下偶发误报;Claude 安装下 `cm-check` 可引用 `templates/cm-VERSION`。`/cm-check` 自动升级遇到本机改过的 CM 文件时会列出这些文件,你明确同意后按这份清单重跑覆盖;清单变了就停下。最后一次核对之后、安装器替换完文件之前新改的文件仍可能被覆盖,同意前先结束其他 CM 会话。详见[更新日志](CHANGELOG.md)。
24
+
20
25
  **0.25.0**
21
26
 
22
27
  - **技能自动调用默认不再外发**:handoff、wayfinder、improve-codebase-architecture 三个技能默认只用本机关键词判断;要用 TypeSafe 的 Jev 判断,在 `~/.cm-workflow/skill-hints.local.json` 写 `"judge": true`。升级没换掉的旧钩子仍可能外发,`cm-check` 会提示;要立即停止,在旧钩子读取的 CM 目录(`CM_WORKFLOW_HOME`,默认 `~/.cm-workflow`)下的 `skill-hints.local.json` 写 `"judge": false`;换过 `CM_WORKFLOW_HOME` 的,旧目录挂在用户级配置里的钩子 `cm-check` 会逐条列出,项目自己配置里的需要自己检查。详见[更新日志](CHANGELOG.md)。
@@ -313,7 +318,7 @@ $cm-check
313
318
 
314
319
  仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
315
320
 
316
- 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.25.0 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
321
+ 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.25.1 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
317
322
 
318
323
  ## 升级旧版本
319
324
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.25.0
1
+ 0.25.1
@@ -76,7 +76,7 @@ Install or upgrade with the same command:
76
76
  npx @aibyzero/cm-workflow@latest install
77
77
  ```
78
78
 
79
- To pin a version, use `npx @aibyzero/cm-workflow@0.25.0 install` from outside
79
+ To pin a version, use `npx @aibyzero/cm-workflow@0.25.1 install` from outside
80
80
  the CM Workflow source checkout (for example, your home directory). Inside a
81
81
  checkout with the same package name and version, npm can select the local
82
82
  uninstalled package and report `cm-workflow: command not found`.
@@ -209,13 +209,31 @@ and again in the middle of the transaction:
209
209
 
210
210
  | Installer | When the late check finds a change | What is left |
211
211
  | ---- | ---- | ---- |
212
- | `install.sh` | Right before each file is copied (content, file type and parent path) | Exit 3 after files were already written: the files written so far are rolled back; the changed file is untouched |
213
- | `install-codex.sh` | After the old plugin directory is renamed aside | Exit 3: the old directory is moved back and the marketplace restored |
214
-
215
- The npm entry and `$cm-check` automatic upgrades only pass `--yes`. When the
216
- installer stops for local edits, `$cm-check` reports the upgrade as `blocked`
217
- (its CLI exits 1, not 3). Save your edits, then run the Bash installer yourself
218
- with `--overwrite-local-edits` if you want to discard them.
212
+ | `install.sh` | Right before each file is copied (content, file type and parent path) | Exit 3 after files were already written: the installer tries to roll back the files written so far and reports whether that completed; the changed file is untouched |
213
+ | `install-codex.sh` | After the old plugin directory is renamed aside | Exit 3: the installer tries to move the old directory back and restore the marketplace, and reports whether that completed |
214
+
215
+ The npm entry and `$cm-check` automatic upgrades pass only `--yes` by default.
216
+ When the installer stops with status 3 (local edits, an invalid manifest, or a
217
+ path that changed type), `$cm-check` reports the upgrade as `blocked` with
218
+ `installerStatus: 3` (its CLI exits 1, not 3) and names the way out. If files
219
+ were already written, the installer tried to roll them back; its output says
220
+ whether that completed. First follow the installer output for any path problem
221
+ that blocks the install or any unfinished rollback. When the cause is local
222
+ edits, the report lists them in `localEdits` (read with the installer's own
223
+ manifest helper) with a `localEditsDigest`. Save your edits; if you then
224
+ explicitly agree to discard exactly those files, `$cm-check` reruns the same
225
+ update command once with `--overwrite-local-edits <localEditsDigest>`. Before
226
+ passing the option to the installer it lists the edits again and stops, without
227
+ installing, if the list changed, the manifest is missing or malformed, no
228
+ edit is left, or the check fails. This binding ends when the installer starts:
229
+ the installer's option is global, so an edit made, or a manifest damaged, after
230
+ that last check and before the installer replaces the file can still be
231
+ overwritten. Finish other CM sessions before agreeing. It never adds the option on its own. You can also run the Bash installer yourself with
232
+ `--yes --overwrite-local-edits`, from a CM Workflow checkout or from the npm
233
+ package unpacked in a new empty directory (`mkdir` a fresh directory and `cd` into it, run
234
+ `npm pack @aibyzero/cm-workflow@latest`, `tar -xzf` the printed file, then run
235
+ `package/install.sh` or `package/install-codex.sh`). Unpacking over an earlier
236
+ `package/` directory would silently replace any edits made there.
219
237
 
220
238
  **Install lock.** One install per real target at a time. The lock is a
221
239
  directory next to the target named `.<target name>.cm-install.lock`:
@@ -242,7 +260,7 @@ before a rollback writes it back; if a rollback finds the wrong type there, it
242
260
  writes nothing, reports the rollback as incomplete and keeps the marketplace
243
261
  backup.
244
262
 
245
- **Rollback.** A failed install restores what it wrote. It trusts only complete
263
+ **Rollback.** A failed install tries to restore what it wrote and reports whether that completed. It trusts only complete
246
264
  records of its own list of written files that name a file this install manages;
247
265
  a record cut short (for example by a full disk) or an unknown one is not used and
248
266
  makes the rollback incomplete. If a restore step itself
@@ -275,7 +293,7 @@ Known limitations:
275
293
  | SIGKILL, power loss, kernel or storage failure | The exit trap cannot run and there is no persistent recovery journal. The lock and the backup directory may remain; recover by hand using them. |
276
294
  | No manifest yet; deleted and unrecorded files | Without a manifest nothing can be judged. A deleted recorded file is not an edit. Codex replaces the whole directory, so unrecorded files you added there are removed; Claude leaves files it does not install in place. |
277
295
  | Windows and the optional updater | `install.ps1` has none of this protection. `~/.cm-workflow/cm-update.sh` and `cm-announce.sh` are not in the manifest. |
278
- | No forced overwrite from npm or `$cm-check` | Intentional: they stop on local edits; run the Bash installer yourself to discard edits. |
296
+ | No forced overwrite by default from npm or `$cm-check` | Intentional: they stop on local edits. `$cm-check` discards them only after you explicitly agree; otherwise run the Bash installer yourself. |
279
297
  | `~/.cm-workflow/cm-update.sh` deletes first | The optional auto-updater uses its own lock and older path list and deletes files removed upstream before it runs `install.sh`, outside this lock and check. It can delete a file and then stop on a local edit. |
280
298
  | Other marketplace writers and Codex internal state | The lock only coordinates CM installers. Do not manage other Codex plugins while CM installs: a rollback restores the whole previous `marketplace.json`. Cleanup does not undo Codex cache or registration side effects of `codex plugin add`. |
281
299
  | Directories replaced while an install runs | Out of scope (see the boundary above). Partial checks remain: the marketplace structure is re-checked before its directory is first created, before it is written and before a rollback writes it; the Codex local-edit checks stop with status 2 when `~/plugins` is no longer the physical directory resolved at start, and then the lock is not deleted through the replaced path (remove it by hand). Other write points are not re-checked. |
@@ -769,6 +769,7 @@ feature。恢复对应运行让 QA 通过后,再次 `advance` 本运行即可
769
769
  # 探测按字面比对,别名会以 request_checks 里的 model_matches:false 判失败,
770
770
  # 而回执只给布尔值、不给期望值,仅看输出无法推断该填什么。
771
771
  # Claude CLI 报 unrecognized_model 时 preflight 也会失败;stderr 指明被拒 id 和家族别名示例(如 CLI 2.1.x 的 claude-opus-5),可快速读取时还会显示 CLI 版本。示例不是完整模型清单。
772
+ # Claude 命令行已启动、但预检没收到用于核对工具的消息请求时(例如组织托管设置固定了接口地址、不许改 ANTHROPIC_BASE_URL),stderr、tool_preflight_missing 和批次 review_preflight_failed 的 reason 都会说明可能原因与出路;预检照旧拦住,没有跳过开关。
772
773
  node scripts/cm-ai-host.mjs preflight --config /absolute/run.json --review-model model-name
773
774
  # create 必须带 --review-config,开发和检查完成后直接派发 fresh 审查:
774
775
  # 审查配置写进运行指纹,resume 时无法补加;不带时宿主以 review_configuration_required 拒绝并说明。
@@ -1806,7 +1807,7 @@ evidenceDigest绑定完整feature清单、原状态文件和精确规格/审查
1806
1807
  `review-host.mjs`串联重新准备/核对原包→原claim→`prd_review`宿主请求→再核对→原r1发布。请求给出精确packageDigest/examinedPaths、真实作者ID、代码项目及steelman-review参考;宿主核实真实独立上下文并原样转交结果,不得自行伪造来源。取消/status沿同一JSONL控制通道,reviewState单独展示审查进度。
1807
1808
  登记后的断连/无效响应/中止保留review_unknown或review_cancelled和原占用,不自动重发。成功为review_recorded,该操作本身不写处置/规格/审批、不完成任务;日志关闭仍incomplete。当前仅临时目录真实CLI配合合成review响应通过,未实际运行独立产品reviewer。保存、修订和处置走上方独立启用的入口;跨进程真实调用句柄追踪与未知结果恢复仍待接线。
1808
1809
 
1809
- `review-publication.mjs`提供主宿主专用`publishPrdReview({specs,reviewPackage,packageDigest,authorContextId,response})`:只有已有dispatch且原包hash匹配才能发布固定r1。response沿原result验证器(verdict/packageDigest/examinedPaths/findings/summary),外层reviewer/contextId/independent/at;独立渠道仅原PRD支持的codex-subagent/codex-cli,contextId不得等于作者。self-degraded要求同作者context、independent:false及单行degradedReason。主执行者须使用 fresh 上下文并原样转交结果,reviewer/contextId/independent 仅是来源声明,字段用于机械一致性检查;不要从任意用户JSON直接写独立审查证据。
1810
+ `review-publication.mjs`提供主宿主专用`publishPrdReview({specs,reviewPackage,packageDigest,authorContextId,response})`:只有已有dispatch且原包hash匹配才能发布固定r1。response沿原result验证器(verdict/packageDigest/examinedPaths/findings/summary),外层reviewer/contextId/independent/at;独立渠道为codex-subagent/codex-cli/claude-cli(claude-only预设的审查方是claude-cli),contextId不得等于作者。self-degraded要求同作者context、independent:false及单行degradedReason。主执行者须使用 fresh 上下文并原样转交结果,reviewer/contextId/independent 仅是来源声明,字段用于机械一致性检查;不要从任意用户JSON直接写独立审查证据。
1810
1811
  设计审查scope为requirements/design,拆分审查为requirements/design/tasks;未投喂的测试合同不冒充已审查。复用原不可覆盖writer,以0600发布并精确回读;原样重复发布可验证,不同结果冲突停止。r1内保留原包和完整宿主响应,含私有材料不得自动提交或外发;它不是V3 receipt、处置回执或规格批准。发布后原gate进入resume_disposition,不创建disposition或修改任务。
1811
1812
  发布模块已通过上方显式启用的宿主流程接线;证据仍限临时目录实写及合成review响应,不能当成独立产品审查已运行。
1812
1813
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibyzero/cm-workflow",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "Spec-driven business development workflow for Pi, Codex, and Claude Code",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -0,0 +1,21 @@
1
+ // External report 2026-12 item 6: in a managed environment the organisation can pin the API endpoint
2
+ // or forbid ANTHROPIC_BASE_URL, so the CLI starts but no message request reaches the loopback probe and
3
+ // the preflight can never pass. The probe is the only evidence that review runs with tools disabled, so
4
+ // it stays a block; this only explains that observed signature and the exits. No dependencies: hosts
5
+ // import it without loading the probe module. Facts come only from the receipt; anything it cannot
6
+ // judge (old receipts, odd shapes, other known failures) gets no explanation rather than a wrong one.
7
+ const CODES_WITH_OWN_CAUSE=new Set(['spawn_failed','reviewer_model_not_found']);
8
+ export function claudeProbeDiagnosis(config,{flow='review'}={}){
9
+ const preflight=config?.preflight;
10
+ if(preflight===null||typeof preflight!=='object'||!Array.isArray(preflight.request_checks))return null;
11
+ if(preflight.provider!=='claude'||preflight.passed!==false||preflight.cli_started!==true||preflight.message_requests!==0)return null;
12
+ if(CODES_WITH_OWN_CAUSE.has(preflight.process_code)||preflight.request_checks.some(check=>check?.model_recognized===false))return null;
13
+ const exit=Number.isInteger(preflight.exit_code)?`,本次退出码 ${preflight.exit_code}`:'';
14
+ const exits=flow==='fix'
15
+ ?'出路:cm-fix 的隔离审查只支持 Claude,不能改由 Codex;在不受托管设置限制的机器上,对同一代码根和同一份运行配置做预检和审查(预检回执绑定代码根、模型和审查配置)。'
16
+ :'出路:在不受托管设置限制的机器上,对同一代码根做预检和审查(预检回执绑定代码根、模型和审查选项);或新建运行时按项目的角色声明改由 Codex 审查(用 cm-runtime 查看或切换谁写谁审)。';
17
+ return 'Claude 命令行已启动,但工具预检没有收到用于核对工具的消息请求。预检要把 ANTHROPIC_BASE_URL 指向本机探测地址,才能核对审查时只开放了允许的工具;'
18
+ +'如果组织的托管设置固定了接口地址或不许改这个变量,消息请求就到不了这里,预检会一直失败。'
19
+ +'CM 没有别的办法确认 Claude 审查时工具已被关掉,所以照旧拦住,也不提供跳过开关。'
20
+ +exits+`其他原因(例如命令行在发出请求前出错${exit})也会出现同样的结果。`;
21
+ }
@@ -89,6 +89,15 @@ export function createClaudeReviewStream(onEvent, onNotice = null, allowedTools
89
89
  if (subtype === 'dev_intent') reportClaudeDevIntentNotice(onNotice);
90
90
  else try { if (typeof onNotice === 'function') onNotice({kind:'claude_system_notice', subtype:'ui_invalidate'}); } catch {}
91
91
  };
92
+ // CLI notifications carry no verdict; never forward hook output or command bodies.
93
+ const systemNotice = message => {
94
+ const notice = {kind:'claude_system_notice', subtype:message.subtype};
95
+ for (const key of ['attempt','max_retries','error_status']) {
96
+ if (typeof message[key] === 'number' && Number.isFinite(message[key])) notice[key] = message[key];
97
+ }
98
+ if (typeof message.hook_name === 'string') notice.hook_name = message.hook_name;
99
+ try { if (typeof onNotice === 'function') onNotice(notice); } catch {}
100
+ };
92
101
  return Object.freeze({
93
102
  accept(message) {
94
103
  current=message;
@@ -105,6 +114,16 @@ export function createClaudeReviewStream(onEvent, onNotice = null, allowedTools
105
114
  startupNotice(message.subtype);
106
115
  return;
107
116
  }
117
+ // Managed SessionStart hooks report before init (2026-12 user report: company-wide
118
+ // hooks made every review fail with missing_init). Same counted, allowlisted summary
119
+ // as after init; hook output is never forwarded and never initializes the turn.
120
+ if (message.type === 'system' && ['hook_started','hook_response'].includes(message.subtype)) {
121
+ if (noticeCount >= 32) reject('unexpected_event',null,'notice_limit');
122
+ noticeCount++;
123
+ session = message.session_id;
124
+ systemNotice(message);
125
+ return;
126
+ }
108
127
  if (message.type !== 'system' || message.subtype !== 'init') reject('missing_init');
109
128
  session = message.session_id;
110
129
  stage = 'assistant';
@@ -133,13 +152,7 @@ export function createClaudeReviewStream(onEvent, onNotice = null, allowedTools
133
152
  reject('unexpected_event',null,'unknown_system_subtype');
134
153
  if (noticeCount >= 32) reject('unexpected_event',null,'notice_limit');
135
154
  noticeCount++;
136
- // CLI notifications carry no verdict; never forward hook output or command bodies.
137
- const notice = {kind:'claude_system_notice', subtype:message.subtype};
138
- for (const key of ['attempt','max_retries','error_status']) {
139
- if (typeof message[key] === 'number' && Number.isFinite(message[key])) notice[key] = message[key];
140
- }
141
- if (typeof message.hook_name === 'string') notice.hook_name = message.hook_name;
142
- try { if (typeof onNotice === 'function') onNotice(notice); } catch {}
155
+ systemNotice(message);
143
156
  return;
144
157
  }
145
158
  if (message.type === 'tool_progress') {
@@ -56,7 +56,7 @@ export async function previewClaudeTools({cwd,model,effort,cli='claude',spawnPro
56
56
  const fingerprint=claudeReviewFingerprint({cwd,model,effort,cli,verification});
57
57
  const temp=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-claude-probe-')));
58
58
  const observations=[];
59
- const controller=new AbortController();let stoppedByProbe=false,modelMarker=null;
59
+ const controller=new AbortController();let stoppedByProbe=false,modelMarker=null,cliStarted=false;
60
60
  const server=http.createServer((request,response)=>{
61
61
  const index=observations.length;
62
62
  if(index<8)observations.push({valid:false});else observations[0]={valid:false};
@@ -132,6 +132,8 @@ export async function previewClaudeTools({cwd,model,effort,cli='claude',spawnPro
132
132
  result=await worker({prompt:'Return JSON for synthetic diagnostic task CM-PROBE-001.'},
133
133
  {signal:controller.signal,onEvent:event=>{
134
134
  if(event.event==='process_closed')closeEvidence=event;
135
+ // The CLI's init event: it started, so a missing message request is not a launch failure.
136
+ if(event.event==='thread.started')cliStarted=true;
135
137
  }});
136
138
  } finally {
137
139
  server.closeAllConnections();
@@ -143,7 +145,7 @@ export async function previewClaudeTools({cwd,model,effort,cli='claude',spawnPro
143
145
  config_fingerprint:fingerprint,passed:modelMarker===null&&messages.length>=1&&messages.length<=2&&messages.every(message=>message.valid)
144
146
  &&stoppedByProbe&&result?.status==='cancelled'&&closeEvidence!==null&&!closeEvidence.timed_out,
145
147
  local_requests:observations.length,message_requests:messages.length,message_requests_expected:'1-2',
146
- listener_closed:closed,isolation:'macos-loopback-sandbox',
148
+ listener_closed:closed,isolation:'macos-loopback-sandbox',cli_started:cliStarted,
147
149
  process_code:result?.code??'unknown',stopped_by_probe:stoppedByProbe,exit_code:closeEvidence?.exit_code??null,
148
150
  request_checks:[...observations.map(item=>item.startup?{startup:true}:item.checks??{complete:false}),
149
151
  ...(modelMarker?[{model_recognized:false,...modelMarker}]:[])]}};
@@ -18,6 +18,7 @@ import {createDeveloperRun,validateDeveloperValue} from './developer-adapter.mjs
18
18
  import {createCodexReviewRun} from './codex-review-adapter.mjs';
19
19
  import {createClaudeReviewRun} from './claude-review-adapter.mjs';
20
20
  import {claudeWorker,claudePreflightMatches} from './worker-claude.mjs';
21
+ import {claudeProbeDiagnosis} from './claude-probe-diagnosis.mjs';
21
22
  import {codexWorker,preflightMatches} from './worker-codex.mjs';
22
23
  import {createHostWorkflowCapabilities,createImplicitQaDecision} from './host-workflow-capabilities.mjs';
23
24
  import {resolveHostRole} from './host-role-routing.mjs';
@@ -441,7 +442,12 @@ export function preflightMissingReason(reviewerRuntime,{preflight,model,effort})
441
442
  ?`--external-provider ${reviewerRuntime} --external-models-config {写着这组值的配置文件}(预检读的是这份文件里 ${reviewerRuntime} 的模型与强度,必须等于本运行冻结的模型 ${model}、强度 ${effort};`
442
443
  +'创建时用的那份文件没改过就直接用它,用户默认配置后来改过就另写一份,否则恢复时以 external_model_configuration_conflict 拒绝)'
443
444
  :`--review-model ${model==='unconfigured'?'{审查模型}':model} --runtime ${reviewerRuntime}`;
444
- return `审查端是 ${reviewerRuntime},${why}。用同一代码根的单任务运行定义重新预检:`
445
+ const base=`审查端是 ${reviewerRuntime},${why}。用同一代码根的单任务运行定义重新预检:`
445
446
  +`cm-ai-host.mjs preflight --config {单任务运行定义.json} ${command},`
446
447
  +'把输出原样存为 review-config 后重新启动;另一端的预检不能复用,也不要手改 passed 或指纹';
448
+ // Only append when the whole stays well inside the 8192-byte reason bound (a batch adds its own note),
449
+ // so an unusually long model name never makes the original reason disappear.
450
+ const diagnosis=reviewerRuntime==='claude'?claudeProbeDiagnosis({preflight}):null;
451
+ const combined=diagnosis?`${base}。${diagnosis}`:base;
452
+ return Buffer.byteLength(combined,'utf8')<=7000?combined:base;
447
453
  }
@@ -75,7 +75,9 @@ export function validateClaudeProposal(raw,{allowSymlinks=false}={}){
75
75
  const DEVELOPER_API_ERROR_CLASSES=Object.freeze({authentication_failed:'developer_auth_failed',
76
76
  billing_error:'developer_billing_error',rate_limit:'developer_rate_limited',
77
77
  server_error:'developer_server_error',model_not_found:'developer_model_not_found'});
78
- const STARTUP_NOTICES=new Set(['dev_intent','ui_invalidate']);
78
+ // hook_started/hook_response come from managed SessionStart hooks, before or after init
79
+ // (2026-12 user report: missing_init on every run). Counted notices; hook output is dropped.
80
+ const STARTUP_NOTICES=new Set(['dev_intent','ui_invalidate','hook_started','hook_response']);
79
81
  function startupNotice(subtype,onNotice){
80
82
  if(subtype==='dev_intent')return reportClaudeDevIntentNotice(onNotice);
81
83
  if(typeof onNotice!=='function')return;
@@ -38,7 +38,11 @@ export function claudeReviewFingerprint({cwd,model,cli='claude',effort=null,veri
38
38
  }
39
39
  export function claudeEnvironment() {
40
40
  // CM_NOTIFY_OFF kept for the same reason as in cleanEnvironment (codex-config.mjs).
41
- const allowed=['PATH','HOME','USER','LOGNAME','TMPDIR','LANG','LC_ALL','ANTHROPIC_API_KEY','CM_NOTIFY_OFF'];
41
+ // ANTHROPIC_BASE_URL reaches the reviewer and developer so users behind an API gateway are
42
+ // served (2026-12 user report; maintainer approved widening the boundary for this one variable).
43
+ // Other routing variables (proxies, Bedrock/Vertex switches, NODE_OPTIONS) stay out. The tool
44
+ // preflight still overrides it with its local probe address.
45
+ const allowed=['PATH','HOME','USER','LOGNAME','TMPDIR','LANG','LC_ALL','ANTHROPIC_API_KEY','ANTHROPIC_BASE_URL','CM_NOTIFY_OFF'];
42
46
  return {...Object.fromEntries(Object.entries(process.env).filter(([key])=>allowed.includes(key))),
43
47
  CLAUDE_CODE_MAX_RETRIES:'0',CLAUDE_CODE_RETRY_WATCHDOG:'0',
44
48
  // CM's own sessions are not a person typing: the skill-hints hook stays out of them.
@@ -17,6 +17,10 @@ function readOversize(file,size){
17
17
  const bytes=Buffer.alloc(size);need(fs.readSync(fd,bytes,0,size,0)===size,'check_source_changed');return bytes;
18
18
  }finally{fs.closeSync(fd);}
19
19
  }
20
+ function isText(bytes){
21
+ if(bytes.includes(0))return false;
22
+ try{new TextDecoder('utf-8',{fatal:true}).decode(bytes);return true;}catch{return false;}
23
+ }
20
24
  const optionalIds=['statusline','updater','subagents','isolated_review','external_browser'];
21
25
  // Groups 1 and 7 inspect the Codex plugin manifest, the root VERSION and the root README.
22
26
  // A Claude-compatible installation legitimately owns none of them, so only these two may be
@@ -41,18 +45,24 @@ function snapshot(root){
41
45
  // 超过 readCmInitSource 单文件上限(1MB)的文本(如非 CM 技能自带的 babel.min.js,约 3MB)不再走它,
42
46
  // 否则整次检查会以 init_draft_target_invalid 阻断(2026-11 反馈:~/.claude/skills/huashu-design)。
43
47
  // 仍要发现检查期间的改动:16MB 内的按内容算摘要,更大的只记大小与修改时间。
44
- const text=/\.(?:md|mjs|js|json|ya?ml|py|sh|ps1|toml|txt|ts|css|html)$/.test(relative)||relative==='VERSION';
48
+ // CM 自己 templates/ 下无扩展名的标志(claude-compat 的 templates/cm-VERSION、钩子模板)也按内容摘要,
49
+ // 否则第 7 组唯一的版本标志无法作证据(2026-12 实跑 0.25.0:check_evidence_invalid)。
50
+ // 只认 templates/:skills/ 里第三方的无扩展名大文件或不可读文件不能拖垮整次检查;
51
+ // 点开头的文件(Finder 随时改写的 .DS_Store 等)不算,按内容摘要会在检查中途误报漂移。
52
+ const marker=relative.startsWith('templates/')&&!path.basename(relative).includes('.');
53
+ const text=/\.(?:md|mjs|js|json|ya?ml|py|sh|ps1|toml|txt|ts|css|html)$/.test(relative)||relative==='VERSION'||marker;
45
54
  if(text&&stat.size<=READ_LIMIT){
46
55
  bytes+=stat.size;need(bytes<=64*1024*1024,'check_inventory_limit');
47
56
  let data;
48
57
  try{data=readCmInitSource(root,relative);need(data!==null,'check_source_changed');}
49
58
  catch(error){if(error&&typeof error==='object')error.file=relative;throw error;}
50
- files[relative]={digest:digest(data.toString('base64')),lines:data.toString('utf8').split('\n').length};
59
+ // 二进制标志只用来查漂移,不给行数,所以不能被当作文本证据引用。
60
+ files[relative]={digest:digest(data.toString('base64')),...(marker&&!isText(data)?{}:{lines:data.toString('utf8').split('\n').length})};
51
61
  }else if(text&&stat.size<=OVERSIZE_HASH_LIMIT){
52
62
  bytes+=stat.size;need(bytes<=64*1024*1024,'check_inventory_limit');
53
63
  let data;
54
64
  try{data=readOversize(target,stat.size);}catch(error){if(error&&typeof error==='object')error.file=relative;throw error;}
55
- files[relative]={size:stat.size,mode:stat.mode&0o777,oversized:true,digest:digest(data.toString('base64')),lines:data.toString('utf8').split('\n').length};
65
+ files[relative]={size:stat.size,mode:stat.mode&0o777,oversized:true,digest:digest(data.toString('base64')),...(marker&&!isText(data)?{}:{lines:data.toString('utf8').split('\n').length})};
56
66
  }else files[relative]={size:stat.size,mode:stat.mode&0o777,...(text?{oversized:true,mtimeMs:stat.mtimeMs,ctimeMs:stat.ctimeMs}:{})};
57
67
  }
58
68
  }
@@ -0,0 +1,5 @@
1
+ // cm-prd 规格审查接受的审查来源声明。只核对声明格式与前后一致,不证明审查真是独立执行的。
2
+ // 守卫测试(scripts/cm-prd-review-publication.test.mjs)要求它与任务审查的 REVIEWER_SOURCES
3
+ // 逐项一致,并与 Python 对照夹具一致:任一方增减通道都会报错,由维护者明确决定 cm-prd 是否接纳。
4
+ export const PRD_REVIEWER_SOURCES=Object.freeze(['codex-subagent','codex-cli','claude-cli','self-degraded']);
5
+ export const PRD_INDEPENDENT_REVIEWERS=Object.freeze(PRD_REVIEWER_SOURCES.filter(source=>source!=='self-degraded'));
@@ -7,6 +7,7 @@ import {writeReviewEvidence} from '../cm-ai/review-evidence-file.mjs';
7
7
  import {reviewResultForPaths} from '../cm-ai/review-runner.mjs';
8
8
  import {need,shape,json,digest,id} from '../cm-ai/effect-contract.mjs';
9
9
  import {needPrd} from './validation-reason.mjs';
10
+ import {PRD_INDEPENDENT_REVIEWERS} from './review-channels.mjs';
10
11
 
11
12
  export function inspectPrdReviewResponse({reviewPackage,packageDigest,authorContextId,response}){
12
13
  reviewPackage=json(reviewPackage,256*1024);response=json(response,64*1024);id(authorContextId);
@@ -25,7 +26,7 @@ export function inspectPrdReviewResponse({reviewPackage,packageDigest,authorCont
25
26
  need(degraded?response.independent===false&&response.contextId===authorContextId
26
27
  &&typeof response.degradedReason==='string'&&response.degradedReason.trim().length>0
27
28
  &&!/[\r\n\v\f\x1c-\x1e\x85\u2028\u2029\0]/.test(response.degradedReason):
28
- ['codex-subagent','codex-cli'].includes(response.reviewer)&&response.independent===true&&response.contextId!==authorContextId,
29
+ PRD_INDEPENDENT_REVIEWERS.includes(response.reviewer)&&response.independent===true&&response.contextId!==authorContextId,
29
30
  'prd_review_independence_invalid');
30
31
  needPrd(typeof response.at==='string'&&Number.isFinite(Date.parse(response.at))
31
32
  &&new Date(response.at).toISOString()===response.at,'prd_review_timestamp_invalid',
@@ -12,6 +12,7 @@ import {assertCreatableScope} from './cm-ai-run.mjs';
12
12
  import {createConversationExecution,readConversationReviewConfiguration,readConversationReviewConfigurationValue,readConversationProtection,runReviewPreflight} from './cm-ai-host.mjs';
13
13
  import {loadConfig,resolveProtectedRuntimes} from './cm-workflow-config.mjs';
14
14
  import {preflightMatches} from '../runtime/js/cm-ai/worker-codex.mjs';
15
+ import {claudeProbeDiagnosis} from '../runtime/js/cm-ai/claude-probe-diagnosis.mjs';
15
16
  import {claudePreflightMatches} from '../runtime/js/cm-ai/worker-claude.mjs';
16
17
  import {createHostToolBridge,HOST_ANSWER_BACKSTOP_MS} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
17
18
  import {serveCmAiHost,parseHostInputLimit,inputLimitReason} from '../runtime/js/cm-ai/host-session.mjs';
@@ -24,7 +25,7 @@ import {EXECUTOR_REASON_CODES} from '../runtime/js/executor-version.mjs';
24
25
  const usage='cm-ai-batch-host.mjs serve --config PATH --host-context ID --allow-development --review-config PATH (required for a new batch; later launches pass the same file) [--execution-optimizations] [--external-models [--external-models-config PATH]] [--runtime codex|claude] [--review-runtime codex|claude] [--input-limit BYTES] [--allow-qa] [--rerun-unknown-qa | --rerun-blocked-qa [--qa-environment-failure REASON]] [--allow-develop-redo FEATURE/TASK]... [--allow-abandon-effect FEATURE/TASK]... [--allow-abandon-review FEATURE/TASK]... [--allow-bootstrap-review-recovery FEATURE/TASK]... [--verification-precheck] [--browser-qa available|unavailable] [--protected-conversation-config PATH | --protected-config PATH] [--allow-provider-development FEATURE/TASK:1|2]... [--hold-revision FEATURE/TASK]...';
25
26
  const safeCode=error=>typeof error?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(error.code)?error.code:'batch_host_failed';
26
27
  // Operator-facing reasons the batch owner writes itself (R4); others stay redacted.
27
- const REASONED=new Set(['batch_resources_open','tool_preflight_missing','legacy_preflight_cache_invalid','batch_qa_cadence_changed','batch_member_store_unreadable',...EXECUTOR_REASON_CODES]);
28
+ const REASONED=new Set(['batch_resources_open','tool_preflight_missing','review_preflight_failed','legacy_preflight_cache_invalid','batch_qa_cadence_changed','batch_member_store_unreadable',...EXECUTOR_REASON_CODES]);
28
29
  const boundedReason=error=>REASONED.has(error?.code)&&typeof error.reason==='string'&&Buffer.byteLength(error.reason,'utf8')<=8192&&!/[\r\n\0]/.test(error.reason)?error.reason:null;
29
30
  const actionFlags=new Map(Object.entries(BATCH_MEMBER_ACTIONS).map(([name,{flag}])=>[flag,name]));
30
31
  // Single-task recovery inputs a batch cannot take: each member's fingerprint binds
@@ -163,12 +164,18 @@ async function memberReviewConfiguration(batch,definition,review,runtime,pair=nu
163
164
  }
164
165
  need(allowPreflight,'review_preflight_missing');
165
166
  const config=await runReviewPreflight(definition,{model:review.model,...(pair?{effort:pair.effort}:{}),runtime,disabledSkills:review.disabledSkills});
166
- need(matches(config),'review_preflight_failed');
167
+ if(!matches(config)){
168
+ const reason=runtime==='claude'?claudeProbeDiagnosis(config):null;
169
+ throw Object.assign(new Error('review_preflight_failed'),{code:'review_preflight_failed',...(reason?{reason}:{})});
170
+ }
167
171
  const temporary=`${file}.${process.pid}.tmp`;
168
172
  fs.writeFileSync(temporary,JSON.stringify(config)+'\n',{flag:'wx',mode:0o600});
169
173
  try{fs.renameSync(temporary,file);}finally{if(fs.existsSync(temporary))fs.unlinkSync(temporary);}
170
174
  return withTimeout(config);
171
- }catch{need(false,'review_preflight_failed');}
175
+ }catch(error){
176
+ if(error?.code==='review_preflight_failed'&&typeof error.reason==='string')throw error;
177
+ need(false,'review_preflight_failed');
178
+ }
172
179
  }
173
180
 
174
181
  export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr}={}){
@@ -268,6 +268,7 @@ let input='';process.stdin.on('data',part=>input+=part);process.stdin.on('end',(
268
268
  const failed=await execute(f);
269
269
  assert.equal(failed.result.code,'review_preflight_failed',JSON.stringify(failed));
270
270
  assert.equal(failed.result.currentTask,'1.work/T-002');assert.deepEqual(failed.calls,[]);
271
+ assert.equal(failed.result.reason,undefined,'a Codex preflight failure carries no Claude managed-endpoint reason');
271
272
  assert.equal(probes().length,2);
272
273
  fs.unlinkSync(fail);
273
274
  const held=requestFirstRevision(f,['T-001','T-002'],processFixture);
@@ -882,8 +882,9 @@ export function createCmAiBatch({configuration,executionFor,logHome,runtime='cod
882
882
  for(const key of group.filter(key=>membership.has(key)&&!initial.done.has(key))){
883
883
  try{await executionForKey(key);}catch(cause){
884
884
  if(cause.code!=='review_preflight_failed')throw cause;
885
+ // The batch host only attaches a one-line reason it wrote itself (managed-endpoint diagnosis).
885
886
  return {outcome:'blocked',state:'blocked',code:'review_preflight_failed',batchId:config.batchId,
886
- currentTask:key,identity:plans.get(key).identity};
887
+ currentTask:key,identity:plans.get(key).identity,...(typeof cause.reason==='string'?{reason:cause.reason}:{})};
887
888
  }
888
889
  }
889
890
  need(!cancelled,'cancelled');
@@ -26,6 +26,7 @@ import {readControlPolicyFile,withControlPolicyHost,readControlTarget} from '../
26
26
  import {readExecutionSnapshot} from '../runtime/js/cm-ai/execution-snapshot.mjs';
27
27
  import {parseModelJson} from '../runtime/js/cm-ai/model-configuration-file.mjs';
28
28
  import {EXECUTOR_REASON_CODES} from '../runtime/js/executor-version.mjs';
29
+ import {claudeProbeDiagnosis} from '../runtime/js/cm-ai/claude-probe-diagnosis.mjs';
29
30
  export {executionFor as createConversationExecution,reviewConfiguration as readConversationReviewConfiguration,reviewConfigurationValue as readConversationReviewConfigurationValue};
30
31
  export function readScopeRevisionFile(file){
31
32
  const before=fs.lstatSync(file);
@@ -208,7 +209,8 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
208
209
  if([5,7].includes(argv.length)&&argv[1]==='--config'&&argv[3]==='--external-provider'){
209
210
  need(argv.length===5||argv[5]==='--external-models-config','invalid_arguments');
210
211
  const runtime=argv[4],pair=loadExternalModels(argv[6]).providers[runtime];need(pair,'external_model_setup_required');
211
- const config=await runReviewPreflight(readRunDefinition(argv[2]),{...pair,runtime});output.write(JSON.stringify({...config,timeoutMs:900000})+'\n');return config.preflight.passed?0:1;
212
+ const config=await runReviewPreflight(readRunDefinition(argv[2]),{...pair,runtime});output.write(JSON.stringify({...config,timeoutMs:900000})+'\n');
213
+ const diagnosis=claudeProbeDiagnosis(config);if(diagnosis)error.write(diagnosis+'\n');return config.preflight.passed?0:1;
212
214
  }
213
215
  need((argv.length===5||argv.length===7)&&argv[1]==='--config'&&argv[3]==='--review-model','invalid_arguments');
214
216
  const runtime=argv.length===5?'codex':argv[6];
@@ -219,6 +221,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
219
221
  output.write(JSON.stringify({...config,timeoutMs:900000})+'\n');
220
222
  if(runtime==='claude'){
221
223
  const hint=formatClaudeModelHint(config,claudeCliVersion());if(hint)error.write(hint+'\n');
224
+ const diagnosis=claudeProbeDiagnosis(config);if(diagnosis)error.write(diagnosis+'\n');
222
225
  }
223
226
  return config.preflight.passed?0:1;
224
227
  }
@@ -195,6 +195,60 @@ test('a Claude-compatible installation waives only the Codex-owned halves and st
195
195
  assert.deepEqual(report.result.checks.filter(row=>row.status==='not_applicable').map(row=>row.id),[1,7]);
196
196
  });
197
197
 
198
+ // 回归点:扩展名外的文本文件(claude-compat 的 templates/cm-VERSION、钩子模板)曾不进摘要,
199
+ // 第 7 组唯一的版本标志引用必被判 check_evidence_invalid(2026-12 实跑 0.25.0 被卡住)。
200
+ test('extensionless markers such as templates/cm-VERSION and hook templates are citable and drift-checked',{timeout:8000},async t=>{
201
+ const prepare=()=>{
202
+ const f=fixture(t);
203
+ fs.mkdirSync(path.join(f.dir,'templates/hooks'),{recursive:true});
204
+ fs.writeFileSync(path.join(f.dir,'templates/cm-VERSION'),'9.9.9\n');
205
+ fs.writeFileSync(path.join(f.dir,'templates/hooks/pre-commit-cm-task-check'),'#!/bin/sh\nexit 0\n');
206
+ return f;
207
+ };
208
+ const cite=value=>{
209
+ value.checks.find(check=>check.id===7).evidence=[{path:'templates/cm-VERSION',line:1}];
210
+ value.checks.find(check=>check.id===6).evidence=[{path:'templates/hooks/pre-commit-cm-task-check',line:2}];
211
+ return value;
212
+ };
213
+ let f=prepare();
214
+ let report=await createCmCheckHost(f.input,{call:async(kind,payload)=>kind==='check_runtime'?mechanical(payload):cite(assessment(payload))})
215
+ .handle({requestId:'ext-1',operation:'start'});
216
+ assert.equal(report.result.overall,'PASSED',JSON.stringify(report.result));
217
+ f=prepare();
218
+ report=await createCmCheckHost(f.input,{call:async(kind,payload)=>{
219
+ if(kind==='check_runtime')return mechanical(payload);
220
+ fs.writeFileSync(path.join(f.dir,'templates/cm-VERSION'),'9.9.8\n');
221
+ return cite(assessment(payload));
222
+ }}).handle({requestId:'ext-2',operation:'start'});
223
+ assert.equal(report.result.overall,'BLOCKED',JSON.stringify(report.result));
224
+ assert.equal(report.result.reason,'check_source_changed','a same-length edit to the version marker must count as drift');
225
+ f=prepare();
226
+ report=await createCmCheckHost(f.input,{call:async(kind,payload)=>{
227
+ if(kind==='check_runtime')return mechanical(payload);
228
+ const value=cite(assessment(payload));value.checks.find(check=>check.id===7).evidence=[{path:'templates/cm-VERSION',line:9}];return value;
229
+ }}).handle({requestId:'ext-3',operation:'start'});
230
+ assert.equal(report.result.reason,'check_evidence_invalid','a line past the end of the marker is still refused');
231
+ f=prepare();fs.writeFileSync(path.join(f.dir,'templates/.DS_Store'),'aaaa');
232
+ report=await createCmCheckHost(f.input,{call:async(kind,payload)=>{
233
+ if(kind==='check_runtime')return mechanical(payload);
234
+ fs.writeFileSync(path.join(f.dir,'templates/.DS_Store'),'bbbb');
235
+ return cite(assessment(payload));
236
+ }}).handle({requestId:'ext-4',operation:'start'});
237
+ assert.equal(report.result.overall,'PASSED','Finder rewriting a same-size dotfile mid-check is not drift: '+JSON.stringify(report.result));
238
+ // 第三方技能里无扩展名、不可读的文件仍只记元数据,不能拖垮整次检查。
239
+ f=prepare();fs.mkdirSync(path.join(f.dir,'skills/third-party'),{recursive:true});
240
+ const locked=path.join(f.dir,'skills/third-party/blob');fs.writeFileSync(locked,'secret');fs.chmodSync(locked,0o000);
241
+ t.after(()=>fs.existsSync(locked)&&fs.chmodSync(locked,0o600));
242
+ report=await createCmCheckHost(f.input,{call:async(kind,payload)=>kind==='check_runtime'?mechanical(payload):cite(assessment(payload))})
243
+ .handle({requestId:'ext-5',operation:'start'});
244
+ assert.equal(report.result.overall,'PASSED','an unreadable third-party extensionless file must not block: '+JSON.stringify(report.result));
245
+ // 二进制的 templates 标志只查漂移,不能冒充文本证据。
246
+ f=prepare();fs.writeFileSync(path.join(f.dir,'templates/cm-VERSION'),Buffer.from([0x39,0x0a,0x00,0xff,0x0a]));
247
+ report=await createCmCheckHost(f.input,{call:async(kind,payload)=>kind==='check_runtime'?mechanical(payload):cite(assessment(payload))})
248
+ .handle({requestId:'ext-6',operation:'start'});
249
+ assert.equal(report.result.reason,'check_evidence_invalid','a binary marker cannot be cited as text');
250
+ });
251
+
198
252
  test('not_applicable is refused outside the mode-scoped groups and when findings are missing',{timeout:5000},async t=>{
199
253
  for(const mutate of [
200
254
  value=>{const row=value.checks.find(check=>check.id===3);row.status='not_applicable';row.evidence=[];row.findings=['not a mode-scoped group'];},