@aibyzero/cm-workflow 0.16.3 → 0.16.4

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 (40) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +44 -3
  4. package/VERSION +1 -1
  5. package/docs/installation.md +1 -1
  6. package/docs/next-steps.md +14 -24
  7. package/package.json +1 -1
  8. package/runtime/js/cm-ai/claude-review-stream.mjs +18 -0
  9. package/runtime/js/cm-ai/cm-ai-admission.mjs +2 -1
  10. package/runtime/js/cm-ai/host-session.mjs +8 -1
  11. package/runtime/js/cm-ai/worker-claude-developer.mjs +16 -7
  12. package/runtime/js/cm-prd/summary.mjs +4 -2
  13. package/runtime/js/specs-status.mjs +6 -2
  14. package/scripts/cm-ai-admission.mjs +2 -0
  15. package/scripts/cm-ai-batch-drive.mjs +1 -1
  16. package/scripts/cm-ai-batch-drive.test.mjs +7 -0
  17. package/scripts/cm-ai-batch-host.mjs +13 -5
  18. package/scripts/cm-ai-batch-host.test.mjs +25 -0
  19. package/scripts/cm-ai-drive.mjs +2 -1
  20. package/scripts/cm-ai-drive.test.mjs +7 -0
  21. package/scripts/cm-ai-host.mjs +10 -5
  22. package/scripts/cm-ai-host.test.mjs +42 -0
  23. package/scripts/cm-check-drive.mjs +4 -3
  24. package/scripts/cm-check-drive.test.mjs +16 -0
  25. package/scripts/cm-check-entry.mjs +13 -2
  26. package/scripts/cm-check-host.mjs +2 -2
  27. package/scripts/cm-check-host.test.mjs +56 -0
  28. package/scripts/cm-check-runtime.sh +15 -6
  29. package/scripts/cm-claude-developer-worker.test.mjs +40 -1
  30. package/scripts/cm-claude-review-stream.test.mjs +43 -0
  31. package/scripts/cm-prd-completion.test.mjs +30 -2
  32. package/scripts/cm-prd-drive.mjs +13 -7
  33. package/scripts/cm-prd-drive.test.mjs +10 -0
  34. package/scripts/cm-prd-summary.test.mjs +31 -0
  35. package/scripts/cm-specs-status.test.mjs +19 -0
  36. package/scripts/test-shell-compat.sh +67 -0
  37. package/skills/cm-ai/references/js-host.md +5 -0
  38. package/skills/cm-check/SKILL.md +6 -1
  39. package/skills/cm-check/references/js-host.md +3 -3
  40. package/skills/cm-prd/references/js-change-recovery.md +30 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-workflow",
3
- "version": "0.16.3",
3
+ "version": "0.16.4",
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,15 @@
7
7
 
8
8
  (暂无)
9
9
 
10
+ ## 0.16.4 — 2026-09-27
11
+
12
+ - Claude review 与 developer 的 CLI 流解析器接受 init 前后的 `dev_intent` 通知,校验会话并计入 32 条通知上限。
13
+ - 修复 cm-prd 自检命令产生输出时误报 `output_capture_failed`;cm-ai 单任务和批次宿主可用 `--input-limit BYTES` 将输入上限从默认 64 KiB 提高到最多 4 MiB,恢复时可调整。
14
+ - 修复 `cm-prd --change` 的 `revisionDigest` 在汇总发布或规格审批后丢失,导致后续变更误判旧审查记录;补充旧状态恢复说明与明确的“开始”审批提示。
15
+ - 修复 `cm-check` 机械检查把当前运行时硬当成 Codex 的问题:从 Claude Code 跑自检时,`reviewer` 会被误标成 `declared-adapter`(已声明未派发),看起来像独立审查通道没派出去。
16
+ - `cm-check-runtime.sh` 新增 `--runtime codex|claude`,取值优先级为 `--runtime` > `CM_RUNTIME` > 未判定;两者都没有时打印「未判定」并说明如何指定,不再对是否派发下结论。
17
+ - 该参数经 `cm-check-host.mjs`、`cm-check-entry.mjs`、`cm-check-drive.mjs` 一路透传到检查脚本,并同步更新 `cm-check` 的 SKILL 与接线文档。
18
+
10
19
  ## 0.16.3 — 2026-09-26
11
20
 
12
21
  - `cm-ai` 单步驾驶员按任务适用 case 与 `[需确认]` 标记预检 runner;已映射 logic 仍按当前 executor 的真实请求拒绝。
package/README.md CHANGED
@@ -17,8 +17,36 @@
17
17
 
18
18
  ## 最近更新
19
19
 
20
+ **0.16.4**
21
+
22
+ - **项目类型通知不再导致审查失败**:Claude Code CLI 2.1.x 在 Xcode 等项目目录里会多发一条「项目类型」通知,而且可能排在初始化消息前面,CM 的审查解析器不认它,真实审查就以 `transport_incomplete` 收场。现在审查方和开发方的解析器都能接受这条通知,其余消息仍按原规则严格校验。
23
+ - **规格批准后还能继续改**:批准规格时,`.cm-specs-status` 里「上一次变更记录」的编号被丢掉,此后任何 `cm-prd --change` 都报审查记录被改动,规格批准后就改不了。现在批准和摘要发布都会保留它;已经丢了的规格,按 `skills/cm-prd/references/js-change-recovery.md` 核对:能证明是哪一份变更归档对应这次批准时才人工补回,证据有歧义就停下交人重审。
24
+ - **大任务不用再手改安装文件**:一个开发答案超过 64 KiB(一次写好几个源文件)时宿主会拒收。现在单任务和批次宿主都支持 `--input-limit BYTES`(最多 4 MiB),只影响传输,恢复时也能换。
25
+ - **cm-prd 自检命令有输出不再误判失败**:驾驭员跑自检命令时,只要命令打印了东西就被当成失败,现已修正。
26
+ - **`/cm-check` 按实际运行时打标签**:从 Claude Code 跑自检时,独立审查通道不再被误标成「已声明未派发」。新增 `--runtime codex|claude`,优先级为 `--runtime` > 环境变量 `CM_RUNTIME`;两者都没有时标「未判定」,不再乱下结论。
27
+
20
28
  **0.16.3**
21
29
 
30
+ - **审查过的任务可以显式重做了**:独立审查用过的交接文件不能覆盖。QA 因宿主或环境证据不足而 BLOCKED、且满足重跑条件时,原本就能在原运行上用 `--rerun-blocked-qa` 重跑 QA;但确需重新开发、新建运行时,会一直报 `handoff_exists`,任务就跑不起来。现在报错会直接给出三条出路:原运行修订填错的 QA 配置、原运行重跑被环境卡住的 QA,或把任务改回 `- [ ]` 后用新运行带 `--supersede-reviewed-evidence --supersede-reason` 重做。旧交接和审查回执按内容摘要归档到 `.reviews/.superseded/`,不会删除。
31
+ - **换一个聊天会话也能接着跑**:cm-ai 的单任务运行(及其 QA 修复子运行)和 cm-fix 都能由新会话接手原运行;批次运行和旧受保护兼容入口不在此列。新会话第一次签审查授权前会记进存档,并被排除在审查员之外,只读打开不写记录。0.16.1~0.16.2 期间已换会话签过授权的旧 cm-fix 运行,仍只能由当时签授权的会话继续。
32
+ - **流程不再把自己锁死**:cm-prd 的拆分审查可以修正需求与设计,自检失败可以交人裁决,原材料中途变了可以正式结束旧批次再开新批次;cm-fix 的本地步骤结果丢失时可以显式放弃重做,诊断为 `design_change` 的运行能走到升级收尾,最终审查要求补测试时第二轮也能继续;cm-refactor 审查要求补判官测试时,第二轮可以受控修订。
33
+ - **九个工作流宿主都有单步驾驭员**:`scripts/cm-*-drive.mjs` 一次推进一步,先按「这一步会问什么」查齐答案文件再发指令,缺什么在启动前就说清楚,已知的缺口不会再半路把运行留在 `unknown`;宿主若问到预检没覆盖的问题,驾驭员会明说这一步将停在 `unknown`。人工文件只提供判断和内容,执行证据只来自真实运行的命令。
34
+ - **审查预检能认出错误的模型名**:本机 Claude CLI 不认识的审查模型 id(例如 CLI 2.1.x 上的 `claude-opus-5-5`,应写 `claude-opus-5`)现在在预检时就判失败,不会拖到真实审查才以 `transport_incomplete` 收场。
35
+
36
+ **0.16.2**
37
+
38
+ - **重名当场拦下、出错能定位**:任务编号重名在建运行时就报错,不再等到红灯测试把一轮做废;失败诊断带上是哪一行代码拦的。CI 改为自动收集全部检查,只固定排除 7 份需要 Codex 沙箱的测试,这 7 份在发版冒烟时补跑;改名前的 METRICS 旧表头也能继续识别。
39
+
40
+ **0.16.1**
41
+
42
+ - **cm-fix 能走到收尾**:收尾不再只认 `delivery: diff`;换会话能打开原运行;做过 `pod install` 的 iOS 项目也能拍基线快照。
43
+
44
+ **0.16.0**
45
+
46
+ - **cm-ai 从「跑不完」到「跑得完」**:交接文件撞名不再卡死任务;独立审查与 QA 用例的等待时间可以单独调大;新增可选的交付前验证闸门 `--verification-precheck`,只拦不放。
47
+
48
+ **0.15.5**
49
+
22
50
  - **安装时会问你要不要开启新版提示**。此前安装完只有一句含糊的「自动更新器未自动启用」,已经开启的人也会看到这句(是错的),没开启的人又不会当回事,结果几乎没人用上这个功能。现在安装器会先看你实际配没配,再决定说什么;没配且是手动安装时,问一句、你答 y 才写入。用 `--yes` 静默安装的不会被改动任何配置,只会打印该加什么。
23
51
  - 它**只加一条「有新版就告诉你」的提示**,不会顺手打开后台自动升级——那是另一回事,仍需你自己决定。你的 `settings.json` 里原有的内容(比如自定义状态栏)不会被动。
24
52
 
@@ -148,7 +176,7 @@ $cm-check
148
176
 
149
177
  仓库直接分发 Skills 和脚本,无需在仓库根目录运行 `npm install` 或构建。完整安装行为、覆盖范围和卸载说明见[安装指南](docs/installation.md)。
150
178
 
151
- 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.16.3 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
179
+ 需要固定版本时可使用 `npx @aibyzero/cm-workflow@0.16.4 install`,请在 CM Workflow 源码仓库以外的目录执行,例如用户主目录。npm 安装入口复用原安装器,要求与覆盖范围见[安装指南](docs/installation.md#npm-installation-macos-codex)。
152
180
 
153
181
  ## 升级旧版本
154
182
 
@@ -276,6 +304,17 @@ CM 从磁盘记录恢复上下文,而不是只依赖聊天历史。
276
304
 
277
305
  再次调用 `cm-ai` 时,先核对已有运行的归属和恢复条件。恢复受原配置、内容和会话身份约束;不满足时明确阻断。已登记但结果未知的审查不会自动重发,必须先核对并按规定处理。
278
306
 
307
+ 换了聊天会话时,当前会话模式的单任务运行用 `--mode resume` 并声明创建运行的原会话即可接手,不需要新建运行(批次运行和旧受保护兼容入口不支持换会话)。卡住时按报错给的出路走,都需要显式授权并留下记录:
308
+
309
+ | 卡在哪 | 怎么继续 |
310
+ | --- | --- |
311
+ | QA 配置填错(如漏了测试命令) | 保留上一版 workflow 文件,原运行用新的 `--workflow-config` 加 `--allow-qa`,再带 `--revise-qa-config 旧文件 --qa-config-revision-reason "原因"` 续验 |
312
+ | QA 因宿主或环境证据不足而 BLOCKED(最新一轮已完成、无失败、轮次未满) | 原运行 `--rerun-blocked-qa` 重跑一轮 |
313
+ | 审查已用过交接、确需重做开发 | 把任务改回 `- [ ]`,新运行带 `--supersede-reviewed-evidence --supersede-reason "原因"` |
314
+ | cm-fix 某个本地步骤卡在 `unknown` | 先确认旧进程已停,以 `--allow-abandon` 启动后发 `abandon_step` 并写明原因;只适用于复现、诊断、测试、修复、回归、复盘、走查等本地步骤,根因审查、最终审查、Learning 写回和交接不适用 |
315
+
316
+ 具体参数见 [cm-ai 宿主接入](skills/cm-ai/references/js-host.md) 与 [cm-fix 宿主接入](skills/cm-fix/references/js-host.md)。
317
+
279
318
  跨项目日志位于本机 `~/.cm-workflow/logs/`,是可重建的私有镜像,不是遥测。它只保存规范化运行元数据,不收集源码、Prompt、模型回答或凭证。详见[日志合同](runtime/logging.md)。
280
319
 
281
320
  ## 支持范围
@@ -285,7 +324,7 @@ CM 从磁盘记录恢复上下文,而不是只依赖聊天历史。
285
324
  | 环境 | 安装 / 入口 | JS 开发流程的当前边界 |
286
325
  | --- | --- | --- |
287
326
  | Codex · macOS | `npx @aibyzero/cm-workflow@latest install` 或 `./install-codex.sh`;`$cm-*` | 默认 JS 入口已接入,有本地安装与工具执行证据;不等于所有业务场景、真实模型审查都已验收 |
288
- | Claude Code · macOS | `./install.sh`;`/cm-*` | 使用同一 JS 核心,当前会话入口已接入;2026-09-17 真实模型双向单文件小任务验收各一次,均停在 N6 QA 待决;QA/N8 不在验收范围、仍未验收 |
327
+ | Claude Code · macOS | `./install.sh`;`/cm-*` | 使用同一 JS 核心,当前会话入口已接入;2026-09-17 真实模型双向单文件小任务验收各一次;2026-09-25 在临时项目上用当前会话开发、Claude CLI 独立审查跑到 N6 QA,并实测 QA 卡住后的作废重跑。浏览器 QA 与 N8 收尾仍未做真实验收 |
289
328
  | Linux / WSL2 | 对应 Bash 安装器 | runner 已有平台准入;尚缺目标环境端到端实测,Claude 隔离配置诊断目前限 macOS |
290
329
  | Claude Code · 原生 Windows | `install.ps1`;`/cm-*` | PowerShell 安装和共享工具有 CI 覆盖;原生 Windows JS runner 尚不支持 |
291
330
  | Pi / BYZ | Pi package | 分发同一组 Skills 与 Prompts;包加载不代表已具备 Codex/Claude 的 JS 工具宿主 |
@@ -323,6 +362,8 @@ Pi 资源加载器直接发现 Skills 与 Prompts,不运行上述安装器,
323
362
 
324
363
  交互安装会询问单/双 AI 与谁写代码,保存到 `~/.cm-workflow/runtimes.yml`;`--yes` / `-Yes` 或非 TTY 跳过且不写。运行时声明按 **项目 > 用户级默认 > 未声明** 解析。`$cm-runtime` 可查看/切换,已创建 run 保留原配置。
325
364
 
365
+ 配置独立审查时,`--review-model` 要写本机 CLI 实际接受的完整模型 id,预检会替你核对;真实审查一次常超过一分钟,建议在审查配置里把 `timeoutMs` 调大(上限一小时)。没等到结果就超时时记为可续跑的审查超时,同一轮最多重派一次;已经收到部分结果的超时要先核对,不会自动重派。
366
+
326
367
  项目配置放在代码根目录的 `.cm-workflow.yml`,可从[配置模板](templates/cm-workflow.yml)开始。角色路由和执行策略必须落在实际宿主已支持的能力内;声明模型或适配器不等于已实际调用。
327
368
 
328
369
  | 文档 | 内容 |
@@ -336,7 +377,7 @@ Pi 资源加载器直接发现 Skills 与 Prompts,不运行上述安装器,
336
377
 
337
378
  ## 维护与贡献
338
379
 
339
- `skills/` 保存工作流与角色规则,`runtime/js/cm-ai/` 保存共享 JS 实现,`scripts/` 提供入口与验证工具。`compat/claude-commands/` 只做历史命令转发;根 `package.json` 保存 Pi/BYZ 包元数据和 npm 安装命令入口,无 npm 依赖或构建脚本。
380
+ `skills/` 保存工作流与角色规则,`runtime/js/cm-ai/` 保存共享 JS 实现,`scripts/` 提供入口、单步驾驭员(`cm-*-drive.mjs`)与验证工具。`experiments/js-orchestration/` 是历史兼容夹具,CI 单独跑它但不阻断合并。`compat/claude-commands/` 只做历史命令转发;根 `package.json` 保存 Pi/BYZ 包元数据和 npm 安装命令入口,无 npm 依赖或构建脚本。
340
381
 
341
382
  入口目录与计数:10 个核心入口(包括独立工具 `cm-runtime`),11 个工种 Skill 与 6 个兼容 agent;独立工具不参与工种配对。
342
383
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.16.3
1
+ 0.16.4
@@ -73,7 +73,7 @@ Install or upgrade with the same command:
73
73
  npx @aibyzero/cm-workflow@latest install
74
74
  ```
75
75
 
76
- To pin a version, use `npx @aibyzero/cm-workflow@0.16.3 install` from outside
76
+ To pin a version, use `npx @aibyzero/cm-workflow@0.16.4 install` from outside
77
77
  the CM Workflow source checkout (for example, your home directory). Inside a
78
78
  checkout with the same package name and version, npm can select the local
79
79
  uninstalled package and report `cm-workflow: command not found`.
@@ -1,22 +1,14 @@
1
1
  # 接下来要做的事
2
2
 
3
- 写于 2026-09-22,0.16.2 发布之后。按优先级排,每条写清:为什么要做、做完是什么样、动手前要先弄清什么。
3
+ 写于 2026-09-22,2026-09-26 在 0.16.3 发布后更新。按优先级排,每条写清:为什么要做、做完是什么样、动手前要先弄清什么。
4
4
 
5
5
  ## 现状
6
6
 
7
- - npm 上是 **0.16.2**。
8
- - 主干已有这些改动,**还没发布**:
9
- - #114 半路死掉的运行让出任务编号(审查过的仍占住)
10
- - #115 cm-fix 驾驶员 `scripts/cm-fix-drive.mjs`
11
- - #116 补上 `auto_fix: never` 和视觉证据 `video` 两条测试
12
- - #117 整理后续工作文档
13
- - #118 + #120 cm-fix 在签授权前记下每个接手会话,并修好交叉审查发现的两处缺陷
14
- - #119 cm-ai 父运行可以换会话接着跑
15
- - #121 QA 修复子运行也能换会话接着跑
16
- - 已补齐 cm-check 可选能力三态、cm-test 中断步骤恢复;本次补齐 cm-refactor 规则三态和四个停机码,A 类清单已完成
17
- - 自动检查:每个 PR 跑 119 份,发版时跑满 126 份。
18
- - 盘点脚本 `scripts/audit-untested-enums.mjs` 报告:**38 个取值缺覆盖,分布在 40 处**(本次由 45 个、42 处降下)。
19
- - 已完成两份「归档让路」实现的收拢:单一实现位于 `runtime/js/cm-ai/review-evidence-file.mjs`,`host-handoff.mjs` 与 cm-fix 共用;交接文件归档行为逐字节保持不变。
7
+ - npm 上是 **0.16.3**(2026-09-26 发布,标记 `v0.16.3`)。下载回来拆包核对过,本次改动都在包里。
8
+ - 主干在发版之后只有文档更新(#150 README、#151 本文件及其审查修正),没有未发布的功能改动。
9
+ - 自动检查:每个 PR 跑 `scripts/` 下 138 份,另有不阻断合并的历史兼容夹具任务跑 `experiments/` 下 24 份;发版时由 `cm-release-smoke.sh` 补跑 CI 跑不了的 7 份。
10
+ - 盘点脚本 `scripts/audit-untested-enums.mjs` 报告:**24 个取值缺覆盖,分布在 22 处**(上次记录为 38 个、40 处)。
11
+ - 已在真实环境验证:「已审交接后 QA 卡住的任务作废重跑」在 e2e 存量项目和全真模型临时项目上各跑通一次(2026-09-25);公司项目上的原始事故尚待维护者本人跑一次确认。
20
12
 
21
13
  ---
22
14
 
@@ -43,7 +35,7 @@
43
35
 
44
36
  ## 第二档:已拍板的设计问题
45
37
 
46
- ### 1. cm-fix 本地 unknown 步骤的显式放弃与重做(已决定,未发布)
38
+ ### 1. cm-fix 本地 unknown 步骤的显式放弃与重做(已发布于 0.16.3)
47
39
 
48
40
  **决定**:保留所有 `unknown` 的默认不重派。仅对复现、诊断、测试编写与运行、修复、回归、复盘、走查及对应第二轮本地步骤,
49
41
  在原运行中增加带原因和独立启动旗标的 `abandon_step`;每次保留旧 intent,追加绑定摘要的记录和日志,再用新的 retry ID 重做。
@@ -56,7 +48,7 @@
56
48
 
57
49
  ## 第三档:已知缺口,值得做但不急
58
50
 
59
- ### 2. QA 修复子运行换会话恢复(已补齐,未发布)
51
+ ### 2. QA 修复子运行换会话恢复(已发布于 0.16.3)
60
52
 
61
53
  cm-ai 的 V3 会话父运行用 `--original-host-context` 恢复后,QA 修复子运行也使用当前真实会话打开和签审查授权;已有子配置保持不变。新建子运行只接受当前会话或父运行的持久创建会话,runtime 仍须匹配。父子运行继续串行交接同一把锁,原逐项授权不变。
62
54
 
@@ -78,7 +70,7 @@ cm-ai 的 V3 会话父运行用 `--original-host-context` 恢复后,QA 修复
78
70
 
79
71
  - **受保护模式跑不了 `tsx` / `vitest` 这类命令**。它们要开本地 socket,而沙箱把这个和「联网」放在同一个开关下。放开就等于给测试命令开整个外网,不划算。替代写法见 `skills/cm-fix/references/js-host.md`。驾驶员在建运行前会预警。
80
72
  - **有 7 份测试只在发版时跑**。它们要启动 Codex 沙箱,GitHub 的机器不给这个权限。已接进 `cm-release-smoke.sh`,发版必过;CI 里有一句断言钉死这 7 份的名单,不会悄悄变多。
81
- - **盘点脚本只认一种写法**(`['a','b'].includes(x)`),`switch`、对象查表、`Set.has` 都漏掉了。所以「38」是下限。
73
+ - **盘点脚本只认一种写法**(`['a','b'].includes(x)`),`switch`、对象查表、`Set.has` 都漏掉了。所以「24」是下限。
82
74
  - **读代码找不到所有问题**。0.16.1 修的四个缺陷全是跑真实项目跑出来的。拿工作流去跑真实项目,仍然是发现问题最有效的办法。
83
75
 
84
76
  ---
@@ -97,14 +89,12 @@ cm-ai 的 V3 会话父运行用 `--original-host-context` 恢复后,QA 修复
97
89
 
98
90
  ---
99
91
 
100
- ## 发版(等决定时再做)
92
+ ## 发版
101
93
 
102
- 是否发布 0.16.3、什么时候发,由维护者决定;决定之前先做前面的事。
94
+ 0.16.3 已于 2026-09-26 发布。下一版是否发、什么时候发,由维护者决定。
103
95
 
104
- **为什么**:上面这些改动还没进 npm 包。其中驾驶员是实打实省事的东西,#114 修的是上一版自己造出来的摩擦。
96
+ **流程**(0.16.1~0.16.3 都这样走):改六处版本号(`package.json`、`VERSION`、`.codex-plugin/plugin.json`、README 两处、`docs/installation.md`)→ 把 CHANGELOG「未发布」切成新版本 → 跑全套检查和 `cm-release-smoke.sh` → 开 PR 合并 → 在 `cm-workflow-dev` 目录的终端 `npm publish` 并过两步验证(这一步必须本人做)→ 下载包核对 → 在发版提交上打标记 → 两端重新安装。
105
97
 
106
- **做完是什么样**:npm 上是 0.16.3;把包从 npm 下载回来拆开,确认本次纳入发布的改动都在;打上 `v0.16.3` 标记。
98
+ **README 的「最近更新」要重写正文,不能只换版本号**。0.16.0~0.16.2 发版时只替换了版本号,结果那段一直挂着 0.15.5 的内容,直到 #150 才改回来。
107
99
 
108
- **流程**(和前两次一样):改六处版本号 → 跑全套检查和 `cm-release-smoke.sh` → 开 PR 合并 → 在终端 `npm publish` 并过两步验证(这一步必须本人做)→ 补标记 → 两端重新安装。
109
-
110
- **注意**:npm 登录会过期。`npm whoami` 报 401 时,先 `npm login`,确认打印出 `aibyzero` 再发。过期时 npm 报的是 404「找不到包」,很容易误判成包出了问题。
100
+ **注意**:npm 登录会过期。`npm whoami` 报 401 时,先 `npm login`,确认打印出 `aibyzero` 再发。过期时 npm 报的是 404「找不到包」,很容易误判成包出了问题。浏览器登录那一步超时时,可以改用 `npm login --auth-type=legacy`,在终端里依次输入用户名、密码和两步验证码。`npm publish` 过程中还会再弹一次网页确认,链接出来就尽快打开,别让它过期。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibyzero/cm-workflow",
3
- "version": "0.16.3",
3
+ "version": "0.16.4",
4
4
  "description": "Spec-driven business development workflow for Pi, Codex, and Claude Code",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -10,6 +10,11 @@ export function reportClaudeRateLimitNotice(raw, onNotice) {
10
10
  try { onNotice({kind:'rate_limit', info}); } catch {}
11
11
  }
12
12
 
13
+ export function reportClaudeDevIntentNotice(onNotice) {
14
+ if (typeof onNotice !== 'function') return;
15
+ try { onNotice({kind:'claude_system_notice', subtype:'dev_intent'}); } catch {}
16
+ }
17
+
13
18
  export function createClaudeReviewStream(onEvent, onNotice = null) {
14
19
  let session = null, stage = 'init', value, noticeCount = 0, thinkingCount = 0, rejectedAttempts = 0;
15
20
  const pendingTools = new Map(), toolIds = new Set();
@@ -22,6 +27,13 @@ export function createClaudeReviewStream(onEvent, onNotice = null) {
22
27
  || message.session_id.length > 256) reject('invalid_session');
23
28
  if (session !== null && session !== message.session_id) reject('session_mismatch');
24
29
  if (stage === 'init') {
30
+ if (message.type === 'system' && message.subtype === 'dev_intent') {
31
+ if (noticeCount >= 32) reject('unexpected_event');
32
+ noticeCount++;
33
+ session = message.session_id;
34
+ reportClaudeDevIntentNotice(onNotice);
35
+ return;
36
+ }
25
37
  if (message.type !== 'system' || message.subtype !== 'init') reject('missing_init');
26
38
  session = message.session_id;
27
39
  stage = 'assistant';
@@ -36,6 +48,12 @@ export function createClaudeReviewStream(onEvent, onNotice = null) {
36
48
  return;
37
49
  }
38
50
  if (message.type === 'system') {
51
+ if (message.subtype === 'dev_intent') {
52
+ if (noticeCount >= 32) reject('unexpected_event');
53
+ noticeCount++;
54
+ reportClaudeDevIntentNotice(onNotice);
55
+ return;
56
+ }
39
57
  if (message.subtype === 'thinking_tokens') {
40
58
  // Long reviews emit usage heartbeats; worker-claude also caps total output at 1 MB.
41
59
  if (thinkingCount >= 4096) reject('unexpected_event');
@@ -359,7 +359,8 @@ export function approveCmAiSpecs(options){
359
359
  const specFiles=buildManifest(specsDir),at=new Date().toISOString();
360
360
  writeSpecsStatus(specsDir,{status:'approved',summaryDigest:status.value?.summaryDigest??null,at,
361
361
  features:discovered.names,specFiles,testCases:specFiles.filter(item=>item.path.endsWith('/test-cases.json')),
362
- approval:{response:options.approvalResponse,at}});
362
+ approval:{response:options.approvalResponse,at},
363
+ ...(status.value&&Object.hasOwn(status.value,'revisionDigest')?{revisionDigest:status.value.revisionDigest}:{})});
363
364
  }catch(error){return refuse(error.code??error.message);}
364
365
  return {projectResults:inspect()};
365
366
  }
@@ -1,7 +1,14 @@
1
1
  // JSONL transport only. The existing host/runner owns decisions and durable state.
2
- import {executionDiagnostic} from './effect-contract.mjs';
2
+ import {executionDiagnostic,need} from './effect-contract.mjs';
3
3
 
4
4
  const LIMIT=64*1024;
5
+ export function parseHostInputLimit(raw){
6
+ if(raw===undefined)return LIMIT;
7
+ const value=Number(raw);
8
+ need(typeof raw==='string'&&/^[1-9][0-9]*$/.test(raw)&&Number.isSafeInteger(value)
9
+ &&value>=LIMIT&&value<=4*1024*1024,'invalid_arguments');
10
+ return value;
11
+ }
5
12
  const operationNames=new Set(['replace_inputs','read_batch','recover_final_review','abandon_step','advance','start','plan_design','promote_design','select_design_reviews','status','fix_status','fix_advance','fix_action','fix_run','decision','complete','qa','qa_result','prepare_revision','prepare_save',
6
13
  'context_refresh','finish','completion_evidence','run_finalize','review_findings','review_disposition','save_draft','save_design','correct_findings','prepare_summary','publish_summary','inspect_correction','resume_correction','cancel','resume','prepare_judge_revision','cause_review_package','cause_review','red_test','baseline','author_tests','repair','regression','retrospective','learning_writeback','handoff','final_review_package','final_review','publish_review','check_n5','post_review_regression','publish_dossier','walkthrough']);
7
14
 
@@ -2,7 +2,7 @@
2
2
  import {spawn} from 'node:child_process';
3
3
  import {readFileSync} from 'node:fs';
4
4
  import {claudeBaseArgs,claudeEnvironment} from './worker-claude.mjs';
5
- import {reportClaudeRateLimitNotice} from './claude-review-stream.mjs';
5
+ import {reportClaudeDevIntentNotice,reportClaudeRateLimitNotice} from './claude-review-stream.mjs';
6
6
  import {need,text,validCallTimeout,json,shape} from './effect-contract.mjs';
7
7
 
8
8
  export function claudeDeveloperArgs(model){
@@ -54,21 +54,30 @@ export function validateClaudeProposal(raw){
54
54
  }
55
55
 
56
56
  function createClaudeDeveloperStream(onNotice=null){
57
- let session=null,done=false,value,assistant=false,noticeCount=0,thinkingCount=0;
57
+ let session=null,initialized=false,done=false,value,assistant=false,noticeCount=0,thinkingCount=0;
58
58
  const tools=new Set();
59
59
  return {
60
60
  accept(event){
61
61
  need(event&&typeof event==='object'&&!Array.isArray(event)&&!done,'invalid_event');
62
- need(typeof event.session_id==='string'&&event.session_id.length>0&&event.session_id.length<=128,'invalid_session');
63
- if(session===null){
64
- need(event.type==='system'&&event.subtype==='init','missing_init');session=event.session_id;return;
62
+ need(typeof event.session_id==='string'&&event.session_id.trim()&&event.session_id.length<=128,'invalid_session');
63
+ if(session!==null)need(event.session_id===session,'session_mismatch');
64
+ if(!initialized){
65
+ if(event.type==='system'&&event.subtype==='dev_intent'){
66
+ need(noticeCount<32,'unexpected_event');noticeCount++;
67
+ session=event.session_id;reportClaudeDevIntentNotice(onNotice);return;
68
+ }
69
+ need(event.type==='system'&&event.subtype==='init','missing_init');
70
+ session=event.session_id;initialized=true;return;
65
71
  }
66
- need(event.session_id===session,'session_mismatch');
67
72
  if(event.type==='rate_limit_event'){
68
- need(noticeCount<8,'unexpected_event');noticeCount++;
73
+ need(noticeCount<32,'unexpected_event');noticeCount++;
69
74
  reportClaudeRateLimitNotice(event.rate_limit_info,onNotice);return;
70
75
  }
71
76
  if(event.type==='system'){
77
+ if(event.subtype==='dev_intent'){
78
+ need(noticeCount<32,'unexpected_event');noticeCount++;
79
+ reportClaudeDevIntentNotice(onNotice);return;
80
+ }
72
81
  need(event.subtype==='thinking_tokens'&&thinkingCount<64,'unexpected_event');thinkingCount++;return;
73
82
  }
74
83
  if(event.type==='assistant'){
@@ -6,7 +6,7 @@ import {inspectPrdSplitDesign} from './split-design.mjs';
6
6
  import path from 'node:path';
7
7
  import {createHash} from 'node:crypto';
8
8
  import {TextDecoder} from 'node:util';
9
- import {writeSpecsStatus} from '../specs-status.mjs';
9
+ import {readSpecsStatus,writeSpecsStatus} from '../specs-status.mjs';
10
10
  import {buildManifest} from '../../../scripts/cm-spec-manifest.mjs';
11
11
  import {inspectPrdReview} from '../../../scripts/cm-prd-review-gate.mjs';
12
12
  import {readCmInitSource} from '../cm-init/draft-inspection.mjs';
@@ -125,8 +125,10 @@ export function publishPrdAwaitingReview({specs,summary,writeEnabled,recover=fal
125
125
  }
126
126
  }
127
127
  need(digest(before)===summary.evidenceDigest,'prd_summary_inputs_changed');
128
+ const prior=readSpecsStatus(specs);
128
129
  const status={status:'awaiting_review',summaryDigest:summary.summaryDigest,at:new Date().toISOString(),features:before.features.map(item=>item.directory),
129
- specFiles:before.specFiles,testCases:before.specFiles.filter(item=>item.path.endsWith('/test-cases.json')),approval:null};
130
+ specFiles:before.specFiles,testCases:before.specFiles.filter(item=>item.path.endsWith('/test-cases.json')),approval:null,
131
+ ...(prior.kind==='valid'&&Object.hasOwn(prior.value,'revisionDigest')?{revisionDigest:prior.value.revisionDigest}:{})};
130
132
  const bytes=Buffer.from(JSON.stringify(status)+'\n'),target=path.join(specs,'.cm-specs-status');
131
133
  try{
132
134
  writeSpecsStatus(specs,status,{beforeRename:()=>{
@@ -3,9 +3,10 @@ import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import {randomUUID} from 'node:crypto';
5
5
 
6
- const fields=['status','summaryDigest','at','features','specFiles','testCases','approval'];
6
+ const fields=['status','summaryDigest','at','features','specFiles','testCases','approval','revisionDigest'];
7
7
  const record=value=>value!==null&&typeof value==='object'&&!Array.isArray(value);
8
8
  const hex=value=>typeof value==='string'&&/^[a-fA-F0-9]{64}$/.test(value);
9
+ const revisionHex=value=>typeof value==='string'&&/^[a-f0-9]{64}$/.test(value);
9
10
  const iso=value=>typeof value==='string'&&/^\d{4}-\d\d-\d\dT/.test(value)&&Number.isFinite(Date.parse(value));
10
11
  const need=condition=>{if(!condition)throw new Error('spec_status_invalid');};
11
12
 
@@ -20,6 +21,7 @@ export function readSpecsStatus(specsDir){
20
21
  need(relative!==''&&relative!=='..'&&!relative.startsWith(`..${path.sep}`)&&!path.isAbsolute(relative));
21
22
  const source=JSON.parse(fs.readFileSync(real,'utf8'));
22
23
  need(record(source)&&['approved','awaiting_review'].includes(source.status));
24
+ if(Object.hasOwn(source,'revisionDigest'))need(revisionHex(source.revisionDigest));
23
25
  // Keep optional fields absent: admission distinguishes legacy omissions.
24
26
  const value=Object.fromEntries(fields.filter(key=>Object.hasOwn(source,key)).map(key=>[key,source[key]]));
25
27
  if(record(value.approval))value.approval=Object.fromEntries(['response','at']
@@ -32,6 +34,7 @@ export function writeSpecsStatus(specsDir,value,{beforeRename=()=>{}}={}){
32
34
  need(record(value)&&['approved','awaiting_review'].includes(value.status));
33
35
  const summaryDigest=value.summaryDigest===undefined?null:value.summaryDigest;
34
36
  need(summaryDigest===null||hex(summaryDigest));
37
+ if(Object.hasOwn(value,'revisionDigest'))need(revisionHex(value.revisionDigest));
35
38
  need(iso(value.at)&&Array.isArray(value.features)&&value.features.length>0
36
39
  &&value.features.every(name=>typeof name==='string'&&/^\d+\.[^/\\]+$/.test(name))
37
40
  &&new Set(value.features).size===value.features.length);
@@ -49,7 +52,8 @@ export function writeSpecsStatus(specsDir,value,{beforeRename=()=>{}}={}){
49
52
  &&typeof approval.response==='string'&&approval.response.trim()!==''&&iso(approval.at)));
50
53
  const canonical={status:value.status,summaryDigest,at:value.at,features:[...value.features],
51
54
  specFiles:manifest(value.specFiles),testCases:manifest(value.testCases),
52
- approval:approval===null?null:{response:approval.response,at:approval.at}};
55
+ approval:approval===null?null:{response:approval.response,at:approval.at},
56
+ ...(Object.hasOwn(value,'revisionDigest')?{revisionDigest:value.revisionDigest}:{})};
53
57
  const bytes=Buffer.from(JSON.stringify(canonical)+'\n'),target=path.join(specsDir,'.cm-specs-status');
54
58
  const temporary=path.join(specsDir,`.cm-specs-status-${randomUUID()}`);let fd;
55
59
  try{
@@ -74,6 +74,8 @@ export function main(argv=process.argv.slice(2)){
74
74
  const result={...selected,...(approval?.approveRefused?{approveRefused:approval.approveRefused}:{}),codeProject:input.codeProjects.length===1?selected.codeProject:null,
75
75
  codeProjects:projectResults.map(item=>item.codeProject),
76
76
  projectAdmissions:projectResults.map(item=>({codeProject:item.codeProject,state:item.state,reason:item.reason}))};
77
+ if(result.state==='awaiting_spec_approval'&&(result.approvalIntent!=='explicit'||input.assumeYes))
78
+ result.message='确认规格摘要后,请在 --approval-response 后准确输入“开始”。';
77
79
  if(input.printRunDefinition&&!result.approveRefused&&result.state==='ready'){
78
80
  try{process.stdout.write(`${JSON.stringify(buildRunDefinition(result,input))}\n`);return 0;}
79
81
  catch(error){process.stderr.write(`${JSON.stringify({error:{code:error.code??error.message}})}\n`);return 1;}
@@ -30,7 +30,7 @@ const HOST=fileURLToPath(new URL('./cm-ai-batch-host.mjs',import.meta.url));
30
30
  const KINDS={develop:'develop.json',qa_assess:'qa-assess.json',
31
31
  documentation_sync:'documentation-sync.json',documentation_inspect:'documentation-inspect.json'};
32
32
  const PAIRS=new Set(['--runtime','--review-config','--browser-qa','--protected-conversation-config',
33
- '--protected-config','--allow-provider-development','--allow-review']);
33
+ '--protected-config','--allow-provider-development','--allow-review','--input-limit']);
34
34
  const FLAGS=new Set(['--allow-qa','--rerun-unknown-qa','--rerun-blocked-qa','--verification-precheck',
35
35
  '--allow-bootstrap-write']);
36
36
  const isObject=x=>x!==null&&typeof x==='object'&&!Array.isArray(x);
@@ -67,6 +67,13 @@ test('help names plan invocation',()=>{
67
67
  const run=spawnSync(process.execPath,[DRIVER,'--help'],{encoding:'utf8'});
68
68
  assert.equal(run.status,0);assert.match(run.stdout,/--plan PLAN\.json <operation>/);
69
69
  });
70
+ test('batch driver accepts input limit as a value before host launch',t=>{
71
+ const f=fixture(t);
72
+ const run=f.drive(f.plan({permissions:['--allow-qa','--input-limit','1048576']}),'advance');
73
+ assert.equal(run.status,2);assert.match(run.stderr,/develop\.json/);
74
+ assert.doesNotMatch(run.stderr,/permissions 无效|--input-limit 文件不存在/);
75
+ noStore(f);
76
+ });
70
77
  test('real batch host advances with authored edit and actual check, then resumes and reports status',t=>{
71
78
  const f=fixture(t);prepared(f);
72
79
  const first=f.drive(f.plan(),'advance');assert.equal(first.status,0,first.stderr);
@@ -9,13 +9,17 @@ import {loadConfig,resolveProtectedRuntimes} from './cm-workflow-config.mjs';
9
9
  import {preflightMatches} from '../runtime/js/cm-ai/worker-codex.mjs';
10
10
  import {claudePreflightMatches} from '../runtime/js/cm-ai/worker-claude.mjs';
11
11
  import {createHostToolBridge} from '../runtime/js/cm-ai/host-tool-bridge.mjs';
12
- import {serveCmAiHost} from '../runtime/js/cm-ai/host-session.mjs';
12
+ import {serveCmAiHost,parseHostInputLimit} from '../runtime/js/cm-ai/host-session.mjs';
13
13
  import {validateHostWorkflowConfiguration,featureHasBrowserCases,readBrowserCapability} from '../runtime/js/cm-ai/host-workflow-capabilities.mjs';
14
14
  import {digest,json,need,shape} from '../runtime/js/cm-ai/effect-contract.mjs';
15
15
 
16
- const usage='cm-ai-batch-host.mjs serve --config PATH --host-context ID --allow-development [--runtime codex|claude] [--review-config PATH] [--allow-review FEATURE/TASK:1|2]... [--allow-qa] [--rerun-unknown-qa | --rerun-blocked-qa] [--verification-precheck] [--browser-qa available|unavailable] [--protected-conversation-config PATH | --protected-config PATH] [--allow-provider-development FEATURE/TASK:1|2]...';
16
+ const usage='cm-ai-batch-host.mjs serve --config PATH --host-context ID --allow-development [--runtime codex|claude] [--input-limit BYTES] [--review-config PATH] [--allow-review FEATURE/TASK:1|2]... [--allow-qa] [--rerun-unknown-qa | --rerun-blocked-qa] [--verification-precheck] [--browser-qa available|unavailable] [--protected-conversation-config PATH | --protected-config PATH] [--allow-provider-development FEATURE/TASK:1|2]...';
17
17
  const safeCode=error=>typeof error?.code==='string'&&/^[a-z][a-z0-9_]{0,63}$/.test(error.code)?error.code:'batch_host_failed';
18
18
 
19
+ export async function serveHostTransport(options,rawInputLimit,serve=serveCmAiHost){
20
+ return serve({...options,inputLimit:parseHostInputLimit(rawInputLimit)});
21
+ }
22
+
19
23
  async function memberReviewConfiguration(batch,definition,review,runtime){
20
24
  try{
21
25
  need(review!==null,'review_configuration_required');
@@ -44,7 +48,7 @@ async function memberReviewConfiguration(batch,definition,review,runtime){
44
48
  }
45
49
 
46
50
  export async function main(argv=process.argv.slice(2),{input=process.stdin,output=process.stdout,error=process.stderr}={}){
47
- if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nOptional --protected-conversation-config PATH uses the shared current-host scoped text proposals and native sandbox checks; {checkCommands,timeoutMs}. No extra model call, same Codex/Claude runtime and per-task Review permissions. Optional --protected-config PATH {model,checkCommands,timeoutMs} enables CLI development only for per-task --allow-provider-development FEATURE/TASK:1|2 grants; mutually exclusive with --protected-conversation-config. Optional bundle.bootstraps maps approved bootstrap task keys to {selection}; --allow-bootstrap-write grants only those fixed instruction/scaffold steps. Optional batch.codeProjects uses prefixed paths and checks with codeProject per command; one task remains one completion gate.\nOptional --review-config PATH is {model,preflight[,disabledSkills][,timeoutMs]}; timeoutMs is the reviewer transport budget in milliseconds (integer 1-3600000, default 60000). It is independent of --protected-conversation-config/--protected-config and wins over their timeoutMs for the reviewer, so a review that exceeds the default can be raised without switching development mode. It is not part of the authorized configuration digest, so a resumed run may raise it after review_transport_timeout.\nOptional --rerun-unknown-qa / --rerun-blocked-qa carry the same single-task QA recovery into a batch and require --allow-qa; they are mutually exclusive. A batch has no --mode, so each task applies the flag only when it resumes an existing run and has a QA executor; a created run or a task without QA ignores it rather than failing the whole batch. Semantics, limits and the qaRound cap are the single-task ones, unchanged.\nOptional --verification-precheck sends the written verification of the task and the collected checks back as a verification_precheck request before any handoff or review package is built. It may only block: a requirement reported unsatisfied stops the task at blocked / verification_precheck_failed with pendingAction resume and spends no review round. Passing it is not an approval, writes no receipt and does not replace the independent review. A task with no written verification is unaffected.\nBatch entry requires a clean Git main checkout (including untracked files); batch_main_dirty lists dirty files before any task or worktree starts. Serial tasks are committed automatically before batch_handoff, with task_commit recording the SHA (null if unchanged). Terminal parallel members preserve WIP on their retained branches and fall back once to serial generation 2 after ready members merge.\n');return 0;}
51
+ if(argv.length===1&&['--help','-h'].includes(argv[0])){output.write(usage+'\nOptional --input-limit BYTES sets the host input transport limit to an integer from 65536 to 4194304 (default 65536); it may change on resume.\nOptional --protected-conversation-config PATH uses the shared current-host scoped text proposals and native sandbox checks; {checkCommands,timeoutMs}. No extra model call, same Codex/Claude runtime and per-task Review permissions. Optional --protected-config PATH {model,checkCommands,timeoutMs} enables CLI development only for per-task --allow-provider-development FEATURE/TASK:1|2 grants; mutually exclusive with --protected-conversation-config. Optional bundle.bootstraps maps approved bootstrap task keys to {selection}; --allow-bootstrap-write grants only those fixed instruction/scaffold steps. Optional batch.codeProjects uses prefixed paths and checks with codeProject per command; one task remains one completion gate.\nOptional --review-config PATH is {model,preflight[,disabledSkills][,timeoutMs]}; timeoutMs is the reviewer transport budget in milliseconds (integer 1-3600000, default 60000). It is independent of --protected-conversation-config/--protected-config and wins over their timeoutMs for the reviewer, so a review that exceeds the default can be raised without switching development mode. It is not part of the authorized configuration digest, so a resumed run may raise it after review_transport_timeout.\nOptional --rerun-unknown-qa / --rerun-blocked-qa carry the same single-task QA recovery into a batch and require --allow-qa; they are mutually exclusive. A batch has no --mode, so each task applies the flag only when it resumes an existing run and has a QA executor; a created run or a task without QA ignores it rather than failing the whole batch. Semantics, limits and the qaRound cap are the single-task ones, unchanged.\nOptional --verification-precheck sends the written verification of the task and the collected checks back as a verification_precheck request before any handoff or review package is built. It may only block: a requirement reported unsatisfied stops the task at blocked / verification_precheck_failed with pendingAction resume and spends no review round. Passing it is not an approval, writes no receipt and does not replace the independent review. A task with no written verification is unaffected.\nBatch entry requires a clean Git main checkout (including untracked files); batch_main_dirty lists dirty files before any task or worktree starts. Serial tasks are committed automatically before batch_handoff, with task_commit recording the SHA (null if unchanged). Terminal parallel members preserve WIP on their retained branches and fall back once to serial generation 2 after ready members merge.\n');return 0;}
48
52
  let bridge;
49
53
  try{
50
54
  need(argv.length>=6&&argv[0]==='serve'&&argv[1]==='--config'&&argv[3]==='--host-context'
@@ -62,7 +66,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
62
66
  }
63
67
  need(keys.length===Object.keys(workflows).length&&keys.every(key=>Object.hasOwn(workflows,key)),'workflow_task_mismatch');
64
68
  for(const key of keys)if(workflows[key]!==null)validateHostWorkflowConfiguration(workflows[key]);
65
- let review=null,allowQa=false,allowBootstrap=false,runtime=null,protection=null,providerConfig=null,browserQaFlag;
69
+ let review=null,allowQa=false,allowBootstrap=false,runtime=null,protection=null,providerConfig=null,browserQaFlag,inputLimitRaw;
66
70
  let rerunUnknownQa=false,rerunBlockedQa=false,verificationPrecheck=false;const approvals=new Set(),developments=new Map();
67
71
  for(let index=6;index<argv.length;index++){
68
72
  const name=argv[index];
@@ -92,6 +96,10 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
92
96
  else if(name==='--runtime'){
93
97
  need(runtime===null&&['codex','claude'].includes(argv[index+1]),'invalid_runtime');runtime=argv[++index];
94
98
  }
99
+ else if(name==='--input-limit'){
100
+ need(inputLimitRaw===undefined&&typeof argv[index+1]==='string','invalid_arguments');
101
+ inputLimitRaw=argv[++index];parseHostInputLimit(inputLimitRaw);
102
+ }
95
103
  else if(name==='--review-config'){need(review===null&&typeof argv[index+1]==='string','invalid_arguments');review=readConversationReviewConfiguration(argv[++index]);}
96
104
  else if(name==='--allow-review'){
97
105
  const approval=argv[++index];need(typeof approval==='string'&&!approvals.has(approval),'invalid_arguments');
@@ -142,7 +150,7 @@ export async function main(argv=process.argv.slice(2),{input=process.stdin,outpu
142
150
  try{return await driver.handle(request);}catch(cause){return {outcome:'blocked',code:safeCode(cause)};}
143
151
  }};
144
152
  const rawMode=input.isTTY&&typeof input.setRawMode==='function';if(rawMode)input.setRawMode(true);
145
- try{await serveCmAiHost({host,input,output,toolBridge:bridge});}
153
+ try{await serveHostTransport({host,input,output,toolBridge:bridge},inputLimitRaw);}
146
154
  finally{if(rawMode)input.setRawMode(false);}
147
155
  return 0;
148
156
  }catch(cause){error.write(JSON.stringify({error:{code:safeCode(cause)}})+'\n');return 1;}
@@ -11,6 +11,29 @@ import {claudeReviewFingerprint} from '../runtime/js/cm-ai/worker-claude.mjs';
11
11
  import {buildManifest} from './cm-spec-manifest.mjs';
12
12
 
13
13
  const cli=fileURLToPath(new URL('./cm-ai-batch-host.mjs',import.meta.url));
14
+ test('batch host input limit reaches transport without opening a host',async()=>{
15
+ const {serveHostTransport}=await import('./cm-ai-batch-host.mjs');
16
+ assert.equal(typeof serveHostTransport,'function');
17
+ let seen;
18
+ await serveHostTransport({host:{}},'1048576',async options=>{seen=options.inputLimit;});
19
+ assert.equal(seen,1048576);
20
+ for(const raw of ['65535','4194305','1.5'])
21
+ await assert.rejects(serveHostTransport({host:{}},raw,async()=>{}),/invalid_arguments/);
22
+ });
23
+ test('batch host help documents input limit',()=>{
24
+ const help=spawnSync(process.execPath,[cli,'--help'],{encoding:'utf8'});
25
+ assert.equal(help.status,0);assert.match(help.stdout,/--input-limit BYTES/);
26
+ });
27
+ test('batch host CLI rejects out-of-range and non-integer input limits before opening a run',()=>{
28
+ const f=fixture();
29
+ try{
30
+ for(const raw of ['65535','4194305','1.5']){
31
+ const run=spawnSync(process.execPath,[cli,...f.args,'--input-limit',raw],{encoding:'utf8'});
32
+ assert.equal(run.status,1);assert.match(run.stderr,/invalid_arguments/);
33
+ assert.equal(fs.existsSync(path.join(f.specsDir,'.reviews')),false);
34
+ }
35
+ }finally{fs.rmSync(f.root,{recursive:true,force:true});}
36
+ });
14
37
  function fixture(runtime='codex'){
15
38
  const root=fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(),'cm-batch-host-')));
16
39
  const specsDir=path.join(root,'specs'),codeProject=path.join(root,'code'),feature='1.work',bin=path.join(root,'bin');
@@ -233,10 +256,12 @@ test('provider development grants select worktree runtimes and keep the serial t
233
256
  const protectedFile=path.join(f.root,'protected.json');fs.writeFileSync(protectedFile,JSON.stringify(protection));
234
257
  const stub=path.join(f.root,'stub.mjs'),host=path.join(f.root,'batch-host.mjs');
235
258
  const hostModule=new URL('./cm-ai-host.mjs',import.meta.url).href;
259
+ const sessionModule=new URL('../runtime/js/cm-ai/host-session.mjs',import.meta.url).href;
236
260
  const workerModule=new URL('../runtime/js/cm-ai/codex-config.mjs',import.meta.url).href;
237
261
  fs.writeFileSync(stub,`
238
262
  import {configFingerprint} from ${JSON.stringify(workerModule)};
239
263
  export {readConversationReviewConfiguration,readConversationProtection} from ${JSON.stringify(hostModule)};
264
+ export {parseHostInputLimit} from ${JSON.stringify(sessionModule)};
240
265
  export const calls=[];export let scheduler;
241
266
  export function createConversationExecution(...args){calls.push(args);return {};}
242
267
  export async function runReviewPreflight(definition,{model}){return {model,disabledSkills:[],preflight:{passed:true,
@@ -59,6 +59,7 @@ const FILES={develop:'develop.json',qa_assess:'qa-assess.json',documentation_ins
59
59
  documentation_sync:'documentation-sync.json',fix_learning:'learning.json',fix_diagnose:'diagnosis.json',
60
60
  fix_test_author:'test-edits.json',fix_repair:'repair-edits.json',fix_retrospective:'retrospective.json'};
61
61
  const PAIR_FLAGS=new Set(['--allow-review-attempt','--review-config','--workflow-config',
62
+ '--input-limit',
62
63
  '--protected-conversation-config','--protected-config','--revise-qa-config','--qa-config-revision-reason',
63
64
  '--qa-fix-owner-config','--qa-fix-template-config','--qa-fix-review-config','--browser-qa',
64
65
  '--bootstrap-config','--allow-provider-development-attempt','--supersede-reason']);
@@ -200,7 +201,7 @@ function load(){
200
201
  for(let i=0;i<permissions.length;i++)if(PAIR_FLAGS.has(permissions[i])
201
202
  &&permissions[i]!=='--allow-review-attempt'&&permissions[i]!=='--browser-qa'
202
203
  &&permissions[i]!=='--qa-config-revision-reason'&&permissions[i]!=='--allow-provider-development-attempt'
203
- &&permissions[i]!=='--supersede-reason'){
204
+ &&permissions[i]!=='--supersede-reason'&&permissions[i]!=='--input-limit'){
204
205
  const file=path.resolve(base,permissions[i+1]);if(!fs.existsSync(file))stop(2,`${permissions[i]} 文件不存在: ${file}`);
205
206
  permissions[i+1]=file;i++;
206
207
  }
@@ -77,6 +77,13 @@ test('missing develop answer is refused before store creation',t=>{
77
77
  const f=fixture(t);const run=f.drive(f.plan(),'advance');
78
78
  assert.equal(run.status,2);assert.match(run.stderr,/develop\.json/);assert.equal(fs.existsSync(f.store),false);
79
79
  });
80
+ test('single driver accepts input limit as a value before host launch',t=>{
81
+ const f=fixture(t);
82
+ const run=f.drive(f.plan({permissions:['--input-limit','1048576']}),'advance');
83
+ assert.equal(run.status,2);assert.match(run.stderr,/develop\.json/);
84
+ assert.doesNotMatch(run.stderr,/permissions 无效|--input-limit 文件不存在/);
85
+ assert.equal(fs.existsSync(f.store),false);
86
+ });
80
87
  test('out-of-scope develop edit is refused before host launch',t=>{
81
88
  const f=fixture(t);prepared(f);
82
89
  f.write('develop.json',{...develop,edits:{'outside.mjs':'target-content.mjs'}});