@aibyzero/cm-workflow 0.13.3 → 0.15.2

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 (99) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +41 -0
  3. package/README.md +34 -1
  4. package/VERSION +1 -1
  5. package/docs/installation.md +1 -1
  6. package/docs/js-workflow-control.md +55 -0
  7. package/docs/user-guide.md +3 -0
  8. package/package.json +1 -1
  9. package/runtime/js/cm-ai/claude-developer-proposal.schema.json +1 -0
  10. package/runtime/js/cm-ai/cm-ai-admission.mjs +53 -22
  11. package/runtime/js/cm-ai/cm-ai-context-refresh.mjs +4 -5
  12. package/runtime/js/cm-ai/cm-ai-conversation-entry.mjs +40 -17
  13. package/runtime/js/cm-ai/cm-ai-qa-log.mjs +103 -23
  14. package/runtime/js/cm-ai/cm-ai-run-finalizer.mjs +8 -4
  15. package/runtime/js/cm-ai/codex-developer-basic-output.schema.json +5 -2
  16. package/runtime/js/cm-ai/codex-developer-output.schema.json +2 -1
  17. package/runtime/js/cm-ai/developer-adapter.mjs +17 -5
  18. package/runtime/js/cm-ai/durable-runner-state.mjs +7 -2
  19. package/runtime/js/cm-ai/effect-contract.mjs +8 -1
  20. package/runtime/js/cm-ai/execution-store.mjs +25 -5
  21. package/runtime/js/cm-ai/host-check.mjs +20 -1
  22. package/runtime/js/cm-ai/host-conversation-execution.mjs +5 -4
  23. package/runtime/js/cm-ai/host-documentation.mjs +2 -2
  24. package/runtime/js/cm-ai/host-qa-executor.mjs +46 -24
  25. package/runtime/js/cm-ai/host-qa-policy.mjs +3 -1
  26. package/runtime/js/cm-ai/host-workflow-capabilities.mjs +41 -3
  27. package/runtime/js/cm-ai/qa-environment.mjs +22 -0
  28. package/runtime/js/cm-ai/task-runner.mjs +1 -0
  29. package/runtime/js/cm-ai/worker-claude-developer.mjs +2 -1
  30. package/runtime/js/cm-fix/cause-package.mjs +3 -1
  31. package/runtime/js/cm-fix/dossier.mjs +7 -2
  32. package/runtime/js/cm-fix/reproduce.mjs +26 -5
  33. package/runtime/js/cm-fix/visual.mjs +3 -2
  34. package/runtime/js/cm-fix/walkthrough.mjs +2 -1
  35. package/runtime/js/cm-init/draft-generation.mjs +3 -2
  36. package/runtime/js/cm-init/draft-inspection.mjs +17 -3
  37. package/runtime/js/cm-init/review-evidence.mjs +1 -1
  38. package/runtime/js/cm-prd/summary.mjs +6 -8
  39. package/runtime/js/cm-security/finalize.mjs +164 -0
  40. package/runtime/js/cm-test/host.mjs +2 -2
  41. package/runtime/js/specs-status.mjs +66 -0
  42. package/runtime/project-context.md +4 -1
  43. package/scripts/cm-ai-admission.mjs +46 -7
  44. package/scripts/cm-ai-admission.test.mjs +50 -0
  45. package/scripts/cm-ai-batch-host.mjs +72 -10
  46. package/scripts/cm-ai-batch-host.test.mjs +128 -4
  47. package/scripts/cm-ai-batch-run.mjs +366 -17
  48. package/scripts/cm-ai-batch-run.test.mjs +222 -13
  49. package/scripts/cm-ai-bootstrap.test.mjs +3 -2
  50. package/scripts/cm-ai-host.mjs +38 -21
  51. package/scripts/cm-ai-host.test.mjs +68 -4
  52. package/scripts/cm-ai-nested-execution.test.mjs +1 -1
  53. package/scripts/cm-ai-run.mjs +25 -15
  54. package/scripts/cm-ai-run.test.mjs +48 -0
  55. package/scripts/cm-blocked-reason.test.mjs +104 -0
  56. package/scripts/cm-capability-gate.test.mjs +179 -0
  57. package/scripts/cm-check-update.mjs +5 -2
  58. package/scripts/cm-check-update.test.mjs +21 -0
  59. package/scripts/cm-codex-developer-adapter.test.mjs +70 -0
  60. package/scripts/cm-fix-cause-package.test.mjs +18 -1
  61. package/scripts/cm-fix-execution.test.mjs +31 -0
  62. package/scripts/cm-fix-host-review.test.mjs +2 -1
  63. package/scripts/cm-fix-host.test.mjs +2 -1
  64. package/scripts/cm-fix-observation-dossier.test.mjs +2 -0
  65. package/scripts/cm-fix-qa-source.test.mjs +1 -3
  66. package/scripts/cm-fix-reproduce.test.mjs +53 -2
  67. package/scripts/cm-fix-review-recovery.test.mjs +4 -3
  68. package/scripts/cm-host-check.test.mjs +22 -0
  69. package/scripts/cm-host-qa-executor.test.mjs +302 -3
  70. package/scripts/cm-host-qa-policy.test.mjs +34 -0
  71. package/scripts/cm-init-draft-generation.test.mjs +24 -3
  72. package/scripts/cm-init-draft-inspection.test.mjs +80 -0
  73. package/scripts/cm-init-host.mjs +2 -2
  74. package/scripts/cm-init-host.test.mjs +3 -1
  75. package/scripts/cm-init-session.test.mjs +37 -0
  76. package/scripts/cm-log-event.mjs +28 -7
  77. package/scripts/cm-prd-design-phase.test.mjs +2 -1
  78. package/scripts/cm-prd-host.test.mjs +3 -2
  79. package/scripts/cm-prd-session-recovery.test.mjs +5 -4
  80. package/scripts/cm-qa-environment.test.mjs +30 -0
  81. package/scripts/cm-security.mjs +12 -4
  82. package/scripts/cm-security.test.mjs +109 -0
  83. package/scripts/cm-specs-status.test.mjs +130 -0
  84. package/scripts/cm-workflow-config.mjs +4 -0
  85. package/scripts/test-shell-compat.sh +0 -0
  86. package/skills/cm-ai/references/N1-init.md +22 -15
  87. package/skills/cm-ai/references/N5-mark-done.md +5 -2
  88. package/skills/cm-ai/references/N6-qa-eval.md +9 -4
  89. package/skills/cm-ai/references/js-host.md +25 -0
  90. package/skills/cm-fix/SKILL.md +5 -4
  91. package/skills/cm-fix/references/js-host.md +13 -0
  92. package/skills/cm-idea/SKILL.md +2 -0
  93. package/skills/cm-init/references/runtime-declaration.md +2 -0
  94. package/skills/cm-prd/SKILL.md +9 -8
  95. package/skills/cm-prd/references/spec-self-check.md +1 -0
  96. package/skills/cm-security/SKILL.md +14 -7
  97. package/skills/cm-security/references/scan-contract.md +45 -1
  98. package/skills/cm-test/references/js-host.md +4 -3
  99. package/templates/dashboard/dashboard.html +2 -2
@@ -23,7 +23,7 @@
23
23
  快照与原始临时结果在 finally 清理,报告需由宿主单独保存在项目外本次目录。
24
24
 
25
25
  工具退出 0 不代表完整:解析 JSON、检查错误与已扫描文件,保留所有未覆盖项。
26
- CLI 退出码:0=帮助/无改动;1=存在候选发现(仍可能部分覆盖);2=阻断;3=没有候选但 AI/工具覆盖仍待核验。
26
+ CLI 退出码:0=帮助/无改动;1=存在候选发现(仍可能部分覆盖);2=阻断;3=没有候选但检查仍待复核,或最终 REVIEWED_PARTIAL(包括 FULL 覆盖)。
27
27
  不把错误退出、超时、缺工具、空/畸形输出、过期数据库当作无漏洞。
28
28
 
29
29
  ## AI 复核与边界
@@ -34,6 +34,50 @@ CLI 退出码:0=帮助/无改动;1=存在候选发现(仍可能部分覆
34
34
  每项发现记录:来源、revision、位置、攻击者能力、路径、现有防护、业务后果、置信度与建议;未经执行的场景标记静态推断。
35
35
  真正的动态利用、部署环境测试、自动修复另需明确授权和隔离环境。
36
36
 
37
+ ## finalize 报告门禁
38
+
39
+ 扫描与复核结果必须是项目外普通 JSON 文件(拒绝最终路径符号链接、目录、项目内路径或指向项目内的路径),各至多 32 MiB。`--finalize --scan {外部扫描报告.json} --review {外部复核结果.json}` 与 `--all`、`--inventory`、扫描器配置参数互斥;范围仅从扫描报告重绑。扫描报告须为完整 scan 输出,不能用 inventory-only 输出代替。
40
+
41
+ 复核输入只接受以下键集;多余键、重复路径、范围外路径或 digest 不匹配均拒绝:
42
+
43
+ ```json
44
+ {
45
+ "version": 1,
46
+ "scanDigest": "扫描报告的 64 位十六进制 digest",
47
+ "paths": [
48
+ {"path": "src/a.js", "status": "reviewed", "findings": [
49
+ {"severity": "high", "location": "src/a.js:42", "attacker": "攻击者能力",
50
+ "vector": "攻击路径", "existingControls": "现有防护", "impact": "业务后果",
51
+ "confidence": "static-inference", "recommendation": "建议"}
52
+ ]},
53
+ {"path": "src/b.js", "status": "not_reviewed", "reason": "未复核原因"}
54
+ ]
55
+ }
56
+ ```
57
+
58
+ `reviewed` 必须带 findings 且不得带 reason;`not_reviewed` 必须带 reason 且不得带 findings。
59
+ 字符串 trim 后非空、至多 1000 UTF-8 字节,禁止 NUL 及除换行/制表符外的 C0;paths 至多 2000,每路径 findings 至多 200,总 findings 至多 2000。
60
+ severity 只取 high/medium/low,confidence 只取 static-inference/observed,location 必须绑定本路径及正整数行号。
61
+ 漏报路径补为 not_reviewed / not_reported;范围外路径报 review_path_unknown。
62
+
63
+ 宿主复用 inventory 重新解析原范围;comparison 身份参与 digest,源码、暂存或基准变化均不能沿用旧结论。
64
+ 此为第二个窗口:`sourceWindows.scan.sourceUnchanged` 保留扫描时结果,`sourceWindows.review` 记录复核后 digest 及一致性;顶层 sourceUnchanged 为两段均一致。
65
+ 复核期间漂移追加 source_changed_during_review,扫描时 source_changed 缺口保留。
66
+ 只有全部路径 reviewed、无 gaps、全部工具为 FINDINGS/NO_FINDINGS 且无 reason 时 coverage 才为 FULL。
67
+
68
+ | 优先级 / 输入 | result | 退出码 |
69
+ | --- | --- | --- |
70
+ | 原扫描 BLOCKED 或复核窗口漂移 | BLOCKED | 2 |
71
+ | 任一扫描或复核 finding | FINDINGS | 1 |
72
+ | selected 为空且无漂移 | NO_CHANGES | 0 |
73
+ | 其余,包括无发现且 FULL | REVIEWED_PARTIAL | 3 |
74
+
75
+ aiReview 由宿主固定为 completed,表示复核输入已经处理,未复核项仍在 gaps 中;不证明模型真的读过源码。
76
+ stdout 仅返回 result、coverage、reportPath、gaps、findingsCount、sourceUnchanged,不含自由描述(gaps 中用户提供的 reason 仅在 stdout 遮蔽);输入拒绝返回脱敏 BLOCKED 错误码。
77
+ 最终 JSON 保留扫描元数据、规范化 review 及机械判定;校验通过的 attacker、vector、existingControls、impact、recommendation 与未复核 reason 原样保留,宿主生成的 not_reported 保留。脱敏针对扫描器原始 stdout/stderr、密钥原文与源码片段;模型不得把这些内容粘进分析字段,JS 无法验证这项语义义务。扫描报告未知字段拒绝,不透传源文件 bytes 或工具原始消息。
78
+ 报告使用项目外 mkdtemp 私有目录与 0600 文件。输入文件不会被删除或复制;调用者负责在输入阶段也遵守脱敏纪律。
79
+ 本门禁验证覆盖声明与本地证据的一致性,不为输入扫描报告提供签名认证,也不能证明漏洞不存在。
80
+
37
81
  ## 复用来源
38
82
 
39
83
  - [Gitleaks](https://github.com/gitleaks/gitleaks):外部 CLI,MIT。
@@ -44,9 +44,10 @@
44
44
  不改 argv、不用底层二进制回退;workspace/prefix/if-present 等变体不静默放行。
45
45
  禁止安装/升级、自动改快照或代码,以及生产操作;执行前由宿主核对命令行为。
46
46
  4. commands/browser 需要明确的 `environment`:
47
- `{scope:"local"|"test",kind:"web"|"app"|"miniprogram",carrier,target}`;
48
- carrier 使用 browser、ios-simulator、android-emulator、wechat-devtools 或 device,
49
- 与形态匹配。目标必须真实是本地/测试环境,不能只把生产 URL 标成 test。
47
+ `{scope:"local"|"test",kind,carrier,target}`;kind 与 carrier 的合法组合以
48
+ `runtime/js/cm-ai/qa-environment.mjs` 的 `QA_ENVIRONMENT_CARRIERS` 为准:
49
+ web→browser,app→ios-simulator/android-emulator/device,miniprogram→wechat-devtools/device,
50
+ desktop→app-window,service→cli/http-api,library→none。按真实交付形态填写,不得借用不符的形态。目标必须真实是本地/测试环境,不能只把生产 URL 标成 test。
50
51
  浏览器有副作用时确认可执行 cleanup;权限不足、工具缺失或无法清理时阻断。
51
52
  5. 启动 `node "{CM_WORKFLOW_ROOT}/scripts/cm-test-host.mjs" serve --config "{配置路径}"`,
52
53
  保持 stdin/stdout 双向连接。收到 host_ready 后发送
@@ -128,10 +128,10 @@ async function load(){
128
128
  const met=await txt('./METRICS.md');
129
129
  let rows=[],human=0,firstPass=0;
130
130
  if(met){
131
- rows=[...met.matchAll(/^\|\s*(T-\d+)\s*\|(.+)$/gm)].map(m=>[m[1],...m[2].split('|').map(s=>s.trim()).slice(0,7)]);
131
+ rows=[...met.matchAll(/^\|\s*(T-\d+)\s*\|(.+)$/gm)].map(m=>[m[1],...m[2].split('|').map(s=>s.trim()).slice(0,8)]);
132
132
  for(const r of rows){human+=parseInt(r[7])||0;if((r[4]||'')==='1')firstPass++}
133
133
  if(rows.length){
134
- $('metrics').innerHTML='<table><tr><th>任务</th><th>Feature</th><th>开始</th><th>结束</th><th>审查轮</th><th>独立审查拦截</th><th>QA</th><th>人工介入</th></tr>'+
134
+ $('metrics').innerHTML='<table><tr><th>任务</th><th>Feature</th><th>开始</th><th>结束</th><th>审查轮</th><th>独立审查拦截</th><th>QA</th><th>人工介入</th><th>执行方式</th></tr>'+
135
135
  rows.map(r=>'<tr>'+r.map(c=>`<td>${c}</td>`).join('')+'</tr>').join('')+'</table>';
136
136
  }
137
137
  }