reasonweave 1.4.4 → 1.4.6

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.
package/AGENTS.md CHANGED
@@ -67,7 +67,7 @@ docs/ 辅助文档与待办 (docs/backlogs/)
67
67
 
68
68
  <!-- handoff-stub:v2.1 begin -->
69
69
  <!-- generated — do not edit -->
70
- <!-- stub:sha256:9a6076fc -->
70
+ <!-- stub:sha256:5090fcd4 -->
71
71
  ### Agent Baton (Handoff) 接入桩(轻量韧性版 · 细则以 $(lab path handoffs)/README.md 契约 v2.41.2 为准)
72
72
 
73
73
  **核心守卫与身份(强制)**
@@ -83,7 +83,7 @@ docs/ 辅助文档与待办 (docs/backlogs/)
83
83
  2. **读工单**:运行 `baton show <id>`,根据验收判据改动本 lane 范围代码并实测。
84
84
  3. **交付或退回(实测为唯一准绳)**:
85
85
  - **实测通过**:照抄 `$(lab path handoffs)/RESPONSE-TEMPLATE.md` 骨架 → 运行 `baton receipt <id> -n "<正文>" --deliver --as <本方 lane> --evidence-paths "<路径>"`(审计工单附 `--audit-nonce "<nonce>"` 或同工作区授权下使用 `--auto-nonce` 自动绑定最新令牌;红队用例严格遵循 NO_DISPATCH / NO_COMPLETE / COMPLETE 三态标准)。
86
- - **实测未过(NO-GO/受阻)**:享有安全下车通道,直接运行 `baton reject <id> -n "<理由/缺失条件>" --as <本方 lane>` 退回整改。
86
+ - **实测未过(NO-GO/受阻)**:审计方享有安全下车通道,运行 `baton reject <id> -n "<理由/差异在哪>" --as audit` 退回整改;普通执行方若受阻/缺失条件,登记受阻回执 `baton receipt <id> -n "<缺失条件/受阻理由>" --evidence-note "<说明>" --as <本方 lane>` 由发起方核实并处理。
87
87
  4. **收尾自检**:运行 `baton check [id]`(若有数据漂移可加 `--fix` 自动修复)。
88
88
  5. **入站回复收尾(简洁单行裁决 · 严禁角色漂移)**:接收方必须严格保持本方执行/审计角色,严禁切换为发起方角色;**严禁反向输出 `## 交接提示词` 卡片或调用 `baton close` 越权闭环**;最终回复人类的最末尾仅输出单行纯文本(无需标题,无需代码块,严禁多行出站卡片):
89
89
  - 审计驳回:`审计完成,裁决 NO-GO(工单已退回<发起方角色>进入 Round <N>)`
package/INSTALL.md CHANGED
@@ -14,8 +14,8 @@
14
14
  | **spec-guard / drift-gate** | **v2.2.1** | 架构规约与物理接线守卫(ADR-064 机器信任根验签、三维热力表、约定阈值解耦、增量感知门禁、支持 `--version` / `-v` 动态对齐) |
15
15
  | **preflight** | **v1.1.0** | 仓库不变量探针(A1~A5 配置化对账防漂移、工程落地指引) |
16
16
  | **orphan** | **v1.4.2** | 全局死代码与孤儿资产清道夫(ADR-0009 / ADR-0011 / ADR-0013):S1–S3 求解器、L1/L2/L3 正交解耦、新增 `check-deps [--strict]` 孤儿依赖求解器与 `scan-secrets [--strict]` 零调用假凭证探针、支持 `--version` / `-v` 动态对齐 |
17
- | **worktree** | v0.1.0 | 多 Agent 物理工作树隔离调度(动态对齐 `VERSION.md`,支持 `--version`) |
18
- | **review-gate** | **v1.2.2** | SAST + 双盲审计独立重跑器(ADR-0011 / ADR-0012 / ADR-0013):`scan.sh --no-suppress` 穿透扫描、OpenGrep 原生模式对称注入 `engine: "opengrep"` 结构化元数据、Ruff Bandit 诚实降级、macOS bash 3.2 兼容自愈 |
17
+ | **worktree** | v0.1.1 | 多 Agent 物理工作树隔离调度(动态对齐 `VERSION.md`,支持 `--version`) |
18
+ | **review-gate** | **v1.2.3** | SAST + 双盲审计独立重跑器(ADR-0011 / ADR-0012 / ADR-0013):`scan.sh --no-suppress` 穿透扫描、OpenGrep 原生模式对称注入 `engine: "opengrep"` 结构化元数据、Ruff Bandit 诚实降级、macOS bash 3.2 兼容自愈 |
19
19
  | **specs / playbook** | — | Spec Kit 活文档模板全集 (`specs/templates/` 01-research 到 05-evidence) 与 RePPIT 五步工程闭环手册 |
20
20
  | **adr / backlog** | v1.0.1 / v1.2.0 | 架构决策记录 (ADR-0011 ~ ADR-0014 🔒Frozen)、待办捕获跟踪 (Backlog 12 ~ 15) |
21
21
 
@@ -69,10 +69,10 @@ npm link
69
69
 
70
70
  | CLI | 作用 |
71
71
  |---|---|
72
- | `reasonweave`(别名 `lab`, `rw`) | 能力库总管、`lab init` 全套一键初始化、路径动态解析、环境体检 (`lab doctor`)、ZSpec 脚手架、下游一键批量同步分发 (`sync-consumers`)、全量转发核心工具 (v1.4.4,支持 `--version`) |
72
+ | `reasonweave`(别名 `lab`, `rw`) | 能力库总管、`lab init` 全套一键初始化、路径动态解析、环境体检 (`lab doctor`)、ZSpec 脚手架、下游一键批量同步分发 (`sync-consumers`)、全量转发核心工具 (v1.4.6,支持 `--version`) |
73
73
  | `baton`(别名 `agent-baton` / `handoff`) | 跨仓 / 仓内任务交割中枢、统一会话ID、防跨会话硬门禁、会话锁、密码学防伪回执、事件驱动唤醒(v2.41.2) |
74
- | `baton-worktree` | 为工单分配 / 回收独立物理工作树(v0.1.0,支持 `--version`) |
75
- | `baton-audit-runner` | 无上下文独立进程重跑验收测试,真实 Exit 0 方可签发回执(v1.2.2,支持 `--version`) |
74
+ | `baton-worktree` | 为工单分配 / 回收独立物理工作树(v0.1.1,支持 `--version`) |
75
+ | `baton-audit-runner` | 无上下文独立进程重跑验收测试,真实 Exit 0 方可签发回执(v1.2.3,支持 `--version`) |
76
76
  | `lab-orphan` | 死代码与孤儿资产清道夫(v1.4.2,支持 `--version`,也可 `lab orphan <cmd>`) |
77
77
  | `spec-guard`(别名 `drift-gate`) | 架构规约与物理接线守卫、ADR 机器信任根验签、三维热力表(v2.2.1,支持 `--version`) |
78
78
  | `lab-skills`(别名 `skills`) | 微观工程原子技能库与上下文零污染切片引擎(v0.1.0,支持 `--version`,也可 `lab skills <cmd>`) |
package/README.md CHANGED
@@ -160,7 +160,7 @@ adr-init <目标目录> <档位: light|standard|frozen> "<项目名>"
160
160
  | **orphan** | [`units/orphan/`](units/orphan/) | 死代码与孤儿资产清道夫、反假接线三层正交治理(v1.4.2,ADR-0009 / ADR-0011),只读 Git HEAD + S1–S3 求解器 + L1/L2/L3 规范、`check-deps [--strict]` 孤儿依赖分析、`scan-secrets [--strict]` 假凭证探针 |
161
161
  | **backlog** | [`units/backlog/`](units/backlog/) | 待办捕获:越界 / 待拍板 / 未来功能,一任务一文件,不打断当前工作流 |
162
162
  | **preflight** | [`units/preflight/`](units/preflight/) | 仓库不变量探针 + Git 提交门禁(v1.1.0),A1~A5 探针(含配置化单一事实源与派生状态防漂移对账),防止“做完才发现还有一件事” |
163
- | **review-gate** | [`units/review-gate/`](units/review-gate/) | 本地 SAST 扫描 (OpenGrep) + review 门禁 + 双盲审计自动化重跑器 (`baton-audit-runner`),v1.2.2 新增 `--no-suppress` 穿透扫描、Ruff Bandit 诚实降级结构化 JSON 标记与 macOS bash 3.2 兼容自愈、顶层同构 engine 元数据 |
163
+ | **review-gate** | [`units/review-gate/`](units/review-gate/) | 本地 SAST 扫描 (OpenGrep) + review 门禁 + 双盲审计自动化重跑器 (`baton-audit-runner`),v1.2.3 新增 `--no-suppress` 穿透扫描、Ruff Bandit 诚实降级结构化 JSON 标记与 macOS bash 3.2 兼容自愈、顶层同构 engine 元数据 |
164
164
  | **handoffs** | [`units/handoffs/`](units/handoffs/) | 跨仓 / 同仓任务交割中枢(Agent Baton v2.41.2),统一会话ID、防跨会话硬门禁、会话身份锁、跨客户端角色锚定与状态机归属确定性、自主双盲审计分诊协议、避免角色漂移、纯化入站单行裁决提示词、Rule 8 分级 SDD 验收与负向测试先行证明、`--profile readonly` 生产源码写保护物理硬门禁、密码学审计凭据签章、出站防注入提示词、无条件下车、五态状态机与事件唤醒 |
165
165
  | **worktree** | [`units/worktree/`](units/worktree/) | 基于 Git Worktree 的物理目录隔离调度引擎,为多 Agent 并发分配独立沙盒并智能共享依赖缓存 |
166
166
  | **skills** | [`units/skills/`](units/skills/) | 微观工程原子技能库与分发引擎(v0.1.0,ADR-0015),官方沉淀 TDD、系统化调试、先验后报、需求澄清 4 大原子技能,带 Iron Law 与借口阻断表,提供 `task-brief` 与 `review-package` 零污染切片流水线 |
@@ -246,7 +246,7 @@ ln -sf ~/dev-templates/hooks/pre-commit-miniprogram .git/hooks/pre-commit
246
246
 
247
247
  <!-- handoff-stub:v2.1 begin -->
248
248
  <!-- generated — do not edit -->
249
- <!-- stub:sha256:9a6076fc -->
249
+ <!-- stub:sha256:5090fcd4 -->
250
250
  ### Agent Baton (Handoff) 接入桩(轻量韧性版 · 细则以 $(lab path handoffs)/README.md 契约 v2.41.2 为准)
251
251
 
252
252
  **核心守卫与身份(强制)**
@@ -262,7 +262,7 @@ ln -sf ~/dev-templates/hooks/pre-commit-miniprogram .git/hooks/pre-commit
262
262
  2. **读工单**:运行 `baton show <id>`,根据验收判据改动本 lane 范围代码并实测。
263
263
  3. **交付或退回(实测为唯一准绳)**:
264
264
  - **实测通过**:照抄 `$(lab path handoffs)/RESPONSE-TEMPLATE.md` 骨架 → 运行 `baton receipt <id> -n "<正文>" --deliver --as <本方 lane> --evidence-paths "<路径>"`(审计工单附 `--audit-nonce "<nonce>"` 或同工作区授权下使用 `--auto-nonce` 自动绑定最新令牌;红队用例严格遵循 NO_DISPATCH / NO_COMPLETE / COMPLETE 三态标准)。
265
- - **实测未过(NO-GO/受阻)**:享有安全下车通道,直接运行 `baton reject <id> -n "<理由/缺失条件>" --as <本方 lane>` 退回整改。
265
+ - **实测未过(NO-GO/受阻)**:审计方享有安全下车通道,运行 `baton reject <id> -n "<理由/差异在哪>" --as audit` 退回整改;普通执行方若受阻/缺失条件,登记受阻回执 `baton receipt <id> -n "<缺失条件/受阻理由>" --evidence-note "<说明>" --as <本方 lane>` 由发起方核实并处理。
266
266
  4. **收尾自检**:运行 `baton check [id]`(若有数据漂移可加 `--fix` 自动修复)。
267
267
  5. **入站回复收尾(简洁单行裁决 · 严禁角色漂移)**:接收方必须严格保持本方执行/审计角色,严禁切换为发起方角色;**严禁反向输出 `## 交接提示词` 卡片或调用 `baton close` 越权闭环**;最终回复人类的最末尾仅输出单行纯文本(无需标题,无需代码块,严禁多行出站卡片):
268
268
  - 审计驳回:`审计完成,裁决 NO-GO(工单已退回<发起方角色>进入 Round <N>)`
package/bin/lab.mjs CHANGED
@@ -107,20 +107,22 @@ function doctor() {
107
107
  console.log(`\n🔍 正在检查环境依赖 (ReasonWeave v${LAB_VERSION}):\n`);
108
108
 
109
109
  const userHome = os.homedir();
110
+ const isWin = process.platform === 'win32';
111
+ const pathSep = path.delimiter;
112
+
110
113
  const extraPaths = [
111
114
  path.dirname(process.execPath),
112
115
  path.join(userHome, '.local', 'bin'),
113
- '/opt/homebrew/bin',
114
- '/usr/local/bin',
116
+ ...(!isWin ? ['/opt/homebrew/bin', '/usr/local/bin'] : []),
115
117
  ].filter(p => fs.existsSync(p));
116
118
 
117
119
  const envPath = process.env.PATH || '';
118
120
  const augmentedPath = [
119
121
  ...new Set([
120
- ...envPath.split(':').filter(Boolean),
122
+ ...envPath.split(pathSep).filter(Boolean),
121
123
  ...extraPaths,
122
124
  ])
123
- ].join(':');
125
+ ].join(pathSep);
124
126
 
125
127
  const runCmd = (cmd, env = {}) => {
126
128
  return execSync(cmd, {
@@ -130,6 +132,18 @@ function doctor() {
130
132
  }).toString().trim();
131
133
  };
132
134
 
135
+ const findExecutable = (binName) => {
136
+ try {
137
+ const probeCmd = isWin ? `where ${binName}` : `which ${binName}`;
138
+ const out = runCmd(probeCmd);
139
+ if (out) {
140
+ const firstLine = out.split(/\r?\n/).map(s => s.trim()).filter(Boolean)[0];
141
+ if (firstLine && fs.existsSync(firstLine)) return firstLine;
142
+ }
143
+ } catch {}
144
+ return null;
145
+ };
146
+
133
147
  // 1. Node.js (>=18)
134
148
  try {
135
149
  const nodeVer = process.version;
@@ -155,19 +169,15 @@ function doctor() {
155
169
  try {
156
170
  let ogBin = process.env.OPENGREP_BIN;
157
171
  if (!ogBin || !fs.existsSync(ogBin)) {
158
- try {
159
- const whichOut = runCmd('which opengrep');
160
- if (whichOut && fs.existsSync(whichOut)) ogBin = whichOut;
161
- } catch {}
172
+ ogBin = findExecutable('opengrep');
162
173
  }
163
174
  const searchDirs = [
164
175
  path.join(userHome, '.local', 'bin'),
165
- '/opt/homebrew/bin',
166
- '/usr/local/bin',
176
+ ...(!isWin ? ['/opt/homebrew/bin', '/usr/local/bin'] : []),
167
177
  ];
168
178
  if (!ogBin) {
169
179
  for (const d of searchDirs) {
170
- const cand = path.join(d, 'opengrep');
180
+ const cand = path.join(d, isWin ? 'opengrep.exe' : 'opengrep');
171
181
  if (fs.existsSync(cand)) {
172
182
  ogBin = cand;
173
183
  break;
@@ -177,16 +187,11 @@ function doctor() {
177
187
  // Fallback to semgrep
178
188
  let isSemgrepFallback = false;
179
189
  if (!ogBin) {
180
- try {
181
- const whichSemgrep = runCmd('which semgrep');
182
- if (whichSemgrep && fs.existsSync(whichSemgrep)) {
183
- ogBin = whichSemgrep;
184
- isSemgrepFallback = true;
185
- }
186
- } catch {}
190
+ ogBin = findExecutable('semgrep');
191
+ if (ogBin) isSemgrepFallback = true;
187
192
  if (!ogBin) {
188
193
  for (const d of searchDirs) {
189
- const cand = path.join(d, 'semgrep');
194
+ const cand = path.join(d, isWin ? 'semgrep.exe' : 'semgrep');
190
195
  if (fs.existsSync(cand)) {
191
196
  ogBin = cand;
192
197
  isSemgrepFallback = true;
@@ -207,7 +212,11 @@ function doctor() {
207
212
  } catch {
208
213
  verOut = '已就绪 (探针超时)';
209
214
  }
210
- const inOriginalPath = (process.env.PATH || '').split(':').some(p => ogBin.startsWith(p + '/'));
215
+ const inOriginalPath = (process.env.PATH || '').split(pathSep).some(p => {
216
+ const normP = path.normalize(p).toLowerCase();
217
+ const normBin = path.normalize(ogBin).toLowerCase();
218
+ return normBin.startsWith(normP);
219
+ });
211
220
  const note = inOriginalPath ? '' : ` (位于 ${ogBin},非默认 PATH)`;
212
221
  const label = isSemgrepFallback ? 'Semgrep (review-gate 兼容)' : 'OpenGrep (review-gate L1)';
213
222
  console.log(` ✅ \x1b[32m${label.padEnd(28)}\x1b[0m: ${verOut}${note}`);
@@ -220,10 +229,21 @@ function doctor() {
220
229
 
221
230
  // 4. Python 3 (review-gate L2 fallback & test tooling)
222
231
  try {
223
- const pyOut = runCmd('python3 --version');
224
- console.log(` ✅ \x1b[32m${'Python 3 (L2 fallback)'.padEnd(28)}\x1b[0m: ${pyOut}`);
232
+ let pyOut = '';
233
+ try {
234
+ pyOut = runCmd('python3 --version');
235
+ } catch {
236
+ try {
237
+ pyOut = runCmd('python --version');
238
+ } catch {}
239
+ }
240
+ if (pyOut) {
241
+ console.log(` ✅ \x1b[32m${'Python 3 (L2 fallback)'.padEnd(28)}\x1b[0m: ${pyOut}`);
242
+ } else {
243
+ console.log(` ⚠️ \x1b[33m${'Python 3 (L2 fallback)'.padEnd(28)}\x1b[0m: 未检测到 python3/python (可选)`);
244
+ }
225
245
  } catch {
226
- console.log(` ⚠️ \x1b[33m${'Python 3 (L2 fallback)'.padEnd(28)}\x1b[0m: 未检测到 python3 (可选)`);
246
+ console.log(` ⚠️ \x1b[33m${'Python 3 (L2 fallback)'.padEnd(28)}\x1b[0m: 未检测到 python3/python (可选)`);
227
247
  }
228
248
 
229
249
  // 5. 核心 Unit CLI 完备性检查
@@ -16,6 +16,7 @@
16
16
  8. [场景七:消费方接入或升级 orphan v1.4.2 反假接线三层治理与 AGENTS/GEMINI 极简路由](#场景七消费方接入或升级-orphan-v142-反假接线三层治理与-agentsgemini-极简路由)
17
17
  9. [场景八:消费方基于 ReasonWeave v1.3.2 新架构全面排查、整改与优化(Vibe Security 穿透防线 + 依赖瘦身 + SDD/RePPIT 落地)](#场景八消费方基于-reasonweave-v132-新架构全面排查整改与优化vibe-security-穿透防线--依赖瘦身--sddreppit-落地)
18
18
  10. [场景九:极简触发自主多维双盲审计(Zero-Cognitive Double-Blind Audit · v2.40.0)](#场景九极简触发自主多维双盲审计zero-cognitive-double-blind-audit--v2400)
19
+ 11. [场景十:消费方接入 AEF 2.0 研发纪律、三态裁决与标准作业程序 (SOP)](#场景十消费方接入-aef-20-研发纪律三态裁决与标准作业程序-sop)
19
20
 
20
21
  ---
21
22
 
@@ -498,4 +499,50 @@ baton install && baton link --check && lab doctor && baton check
498
499
  - 默认(95% 场景):开立 **1 份「自适应多维矩阵工单」**,作为后台任务运行 `baton forward <id> --blind --wait`(自动脱敏思考与自辩,挂起秒级监听);
499
500
  - 回复末尾**仅输出唯一一张独立的标准交接提示词卡片**,严禁将多份工单或多个卡片堆叠在同一个代码块内!
500
501
 
502
+ ---
503
+
504
+ ### 场景十:消费方接入 AEF 2.0 研发纪律、三态裁决与标准作业程序 (SOP)
505
+
506
+ > 📋 **适用场景**:消费方项目升级至 ReasonWeave v1.4.4 / AEF 2.0,接入三态裁决体系 (GO / NO-GO / BLOCKED)、免责受阻挂起呈报与工业级 SOP 执行流。彻底终结环境限制(如 socketpair E_ACCESSDENIED)下的越界 reject 拦截与认知死锁。
507
+ > 📋 **使用方式**:复制以下内容发送给消费方项目的 AI Agent 会话:
508
+
509
+ ```markdown
510
+ 请按 ReasonWeave AEF 2.0 工业级标准为本项目对齐研发纪律与标准作业程序 (SOP)。
511
+
512
+ ### 核心升级背景与纪律要点(不可违背):
513
+ 1. **三态裁决体系 (GO / NO-GO / BLOCKED · ADR-0017 / 宪法 T8)**:
514
+ - 严禁二元思维:当遭遇宿主容器沙箱权限硬拦截(如 `socketpair E_ACCESSDENIED`)、外部依赖缺失或基础设施不可用等不可抗力(`E_ENV`)时:
515
+ - **普通实现方(`impl`/`worker`)专享交付权,严禁越界调用 `baton reject`**(会被 CLI 越界拦截);
516
+ - **严禁伪造 PASS 交付,亦严禁静默挂起或失踪**;
517
+ - 必须在 15 分钟内提交客观受阻回执:`baton receipt <ID> -n "## 状态 / 结论\n- **结论**:BLOCKED\n- **阻断类型**:E_ENV\n- **根因分析**:..." --evidence-note "环境阻断日志"`,解除死锁并移交发起方协调。
518
+ 2. **标准作业程序流水线 (docs/sop/)**:
519
+ - 日常作业优先查阅并执行 SOP,严禁凭主观臆想操作:
520
+ - 全仓与业务仓接入:参考 `$(lab path playbook)/docs/sop/01-installation-and-onboarding-sop.md`
521
+ - 日常工程协同与三态流转:参考 `$(lab path playbook)/docs/sop/02-day-to-day-engineering-sop.md`
522
+ - 跨端流转与双盲审计:参考 `$(lab path playbook)/docs/sop/03-handoffs-and-audit-sop.md`
523
+ - 提交前反未接线与孤儿治理:参考 `$(lab path playbook)/docs/sop/04-anti-orphan-governance-sop.md`
524
+ 3. **单行裁决收尾铁律 (宪法 T4 / ADR-0016)**:
525
+ - 接收方/审计方在回复人类时,末尾仅输出单行纯文本(无需标题,无需代码块,严禁反向输出出站交接卡片):
526
+ - 交付通过:`交付完成,回执已就绪`(或 `审计完成,裁决 GO`)
527
+ - 驳回退回:`审计完成,裁决 NO-GO(工单已退回<发起方角色>进入 Round <N>)`
528
+
529
+ ### 本次排查与就绪执行动作:
530
+ 1. **核验接入桩版本**:
531
+ ```bash
532
+ baton doctor
533
+ ```
534
+ 确保输出 `桩版本 == 引擎版本`。
535
+ 2. **合规体检与历史漂移自愈**:
536
+ ```bash
537
+ baton check --fix
538
+ ```
539
+ 对历史工单的 needs_change 漂移与状态流水进行原子对齐。
540
+ 3. **验证提交前增量接线门禁**:
541
+ ```bash
542
+ lab-orphan check-diff --staged
543
+ ```
544
+ 4. **输出确认报告**:汇报接入桩版本、体检自愈结果以及已遵照 AEF 2.0 三态裁决(GO/NO-GO/BLOCKED)就绪。
545
+ ```
546
+
547
+
501
548
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reasonweave",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "Agent Engineering Framework (AEF) & Disciplines Toolkit for multi-agent software engineering",
5
5
  "type": "module",
6
6
  "main": "bin/lab.mjs",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "scripts": {
34
34
  "sync:consumers": "node scripts/sync-all-consumers.mjs",
35
- "test": "node bin/lab.mjs doctor && node units/handoffs/handoff.mjs status && node units/worktree/worktree.mjs --help && node units/review-gate/clean-runner.mjs --help && node units/orphan/bin/lab-orphan.mjs test-solver && node --test units/orphan/tests/*.test.mjs && node --test units/spec-guard/tests/*.test.mjs && node --test units/handoffs/tests/*.test.mjs && node --test units/review-gate/tests/*.test.mjs && node --test units/skills/tests/*.test.mjs && node --test tests/*.test.mjs",
36
- "postinstall": "chmod +x bin/lab.mjs units/handoffs/handoff.mjs units/worktree/worktree.mjs units/review-gate/clean-runner.mjs units/orphan/bin/lab-orphan.mjs units/spec-guard/bin/spec-guard.mjs units/skills/skills.mjs units/skills/bin/*.mjs units/adr/scripts/adr-init.sh units/preflight/templates/preflight.sh units/preflight/templates/check.sh units/review-gate/templates/scan.sh scripts/sync-all-consumers.mjs 2>/dev/null || true"
35
+ "test": "node bin/lab.mjs doctor && node units/handoffs/handoff.mjs status && node units/worktree/worktree.mjs --help && node units/review-gate/clean-runner.mjs --help && node units/orphan/bin/lab-orphan.mjs test-solver && node --test units/orphan/tests/*.test.mjs && node --test units/spec-guard/tests/*.test.mjs && node --test units/handoffs/tests/*.test.mjs && node --test units/review-gate/tests/*.test.mjs && node --test units/worktree/tests/*.test.mjs && node --test units/skills/tests/*.test.mjs && node --test tests/*.test.mjs",
36
+ "postinstall": "node scripts/postinstall.mjs"
37
37
  },
38
38
  "files": [
39
39
  "bin/",
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import process from 'node:process';
5
+ import { fileURLToPath } from 'node:url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+ const repoRoot = path.resolve(__dirname, '..');
10
+
11
+ // 在 POSIX 平台(macOS / Linux)为 CLI 脚本与模板自适应赋予执行权限(chmod +x)
12
+ // Windows 平台跳过(不依赖 POSIX 权限位),彻底根除 Windows cmd.exe 下 chmod 与 true 不可识别导致的安装中断
13
+ if (process.platform !== 'win32') {
14
+ const targets = [
15
+ 'bin/lab.mjs',
16
+ 'units/handoffs/handoff.mjs',
17
+ 'units/worktree/worktree.mjs',
18
+ 'units/review-gate/clean-runner.mjs',
19
+ 'units/orphan/bin/lab-orphan.mjs',
20
+ 'units/spec-guard/bin/spec-guard.mjs',
21
+ 'units/skills/skills.mjs',
22
+ 'units/skills/bin/task-brief.mjs',
23
+ 'units/skills/bin/review-package.mjs',
24
+ 'units/adr/scripts/adr-init.sh',
25
+ 'units/preflight/templates/preflight.sh',
26
+ 'units/preflight/templates/check.sh',
27
+ 'units/review-gate/templates/scan.sh',
28
+ 'scripts/sync-all-consumers.mjs',
29
+ 'scripts/postinstall.mjs',
30
+ ];
31
+
32
+ for (const rel of targets) {
33
+ const fullPath = path.join(repoRoot, rel);
34
+ try {
35
+ if (fs.existsSync(fullPath)) {
36
+ const stat = fs.statSync(fullPath);
37
+ fs.chmodSync(fullPath, stat.mode | 0o111);
38
+ }
39
+ } catch {}
40
+ }
41
+ }
42
+ process.exit(0);
@@ -6,12 +6,15 @@
6
6
 
7
7
  ---
8
8
 
9
- > **v2.41.2 补丁(2026-11-26 · 双盲审计出站卡片独立沙箱角色锚定与防自证拒识死锁加固)**:动因——用户反馈在跨客户端(WorkBuddy → ChatGPT)派发双盲审计工单时,ChatGPT 新窗口因全局安装了以“双盲审计”为触发词的派发技能,误以为人类在要求发起 `/audit`,激活派单逻辑后触发内部“严禁当前窗口自行审计”守卫,将自身锁死在派发官角色并拒接审计。经排查,系提示词缺乏独立沙箱声明与技能触发词语义撞车导致。实施彻底根治:
9
+ > **v2.41.2 补丁(2026-11-26 · 双盲审计出站卡片独立沙箱角色锚定与防自证拒识死锁加固 & 接入桩受阻话术契约对齐)**:动因——用户反馈在跨客户端(WorkBuddy → ChatGPT)派发双盲审计工单时,ChatGPT 新窗口因全局安装了以“双盲审计”为触发词的派发技能,误以为人类在要求发起 `/audit`,激活派单逻辑后触发内部“严禁当前窗口自行审计”守卫,将自身锁死在派发官角色并拒接审计;同时消费方反馈接入桩在执行方受阻时误导普通 `impl` 运行 `baton reject` 导致被系统越界拦截。经排查,实施彻底根治:
10
10
  > 1. **出站提示词双盲审计角色锚定(Audit Role Anchor Invariant)**:
11
11
  > - `cmdPrompt`(仓内及跨仓)在判定 `to_lane=audit` 时,自动在出站交接提示词卡片中注入显式角色锚定行:
12
12
  > `[角色锚定] 本会话即为独立审计沙箱,请直接作为审计执行员进行独立测试与核验(切勿触发派单逻辑)`(英文对应注入 `[Role Anchor]`);
13
13
  > - 接收端 Agent(ChatGPT / Claude / Cursor 等)读取提示词瞬间强行覆写系统上下文,消除角色认知模糊,阻断模型误召回全局派单技能。
14
- > 2. **自主双盲审计分诊协议边界加固(Dispatcher vs Verifier Boundary)**:
14
+ > 2. **接入桩入站退回契约与话术对齐(Inbound Bailout Contract Alignment)**:
15
+ > - 接入桩清晰界定“审计方安全下车驳回”与“普通执行方受阻登记回执”;
16
+ > - 纠正接入桩将普通执行方受阻误写为 `baton reject` 的瑕疵,对齐 `reject` 专属于发起方与审计方的物理门禁约束,普通执行方受阻统一通过登记受阻回执交由发起方协调推进。
17
+ > 3. **自主双盲审计分诊协议边界加固(Dispatcher vs Verifier Boundary)**:
15
18
  > - 在 `AGENT-GUIDE.md` 明确划定 `自主双盲审计分诊协议` 仅限发起方(`from_lane`)交割时触发;
16
19
  > - 明确禁止接收方(`to_lane=audit`)以“当前窗口不能自行审计”为借口推诿拒单(该窗口即为合法独立审计沙箱),强制进入入站实测工作流。
17
20
  > 3. **全套单测与事实源同步对齐**:更新用例 30 断言 `to_lane=audit` 时必须包含角色锚定行;全仓文档与门禁对齐。
@@ -157,6 +157,7 @@ function getSessionId() {
157
157
  process.env.CURSOR_CONVERSATION_ID ||
158
158
  process.env.CLAUDE_CONVERSATION_ID ||
159
159
  process.env.CLAUDE_SESSION_ID ||
160
+ process.env.CODEX_SESSION_ID ||
160
161
  process.env.WORKBUDDY_CONVERSATION_ID ||
161
162
  process.env.WORKBUDDY_SESSION_ID ||
162
163
  process.env.CODEBUDDY_CONVERSATION_ID ||
@@ -301,6 +301,7 @@ function isAgentEnvironment() {
301
301
  process.env.BATON_AGENT_HOST ||
302
302
  process.env.CLAUDE_CODE ||
303
303
  process.env.CLAUDE_SESSION_ID ||
304
+ process.env.CODEX_SESSION_ID ||
304
305
  process.env.CURSOR_AGENT ||
305
306
  process.env.WORKBUDDY_AGENT ||
306
307
  process.env.WORKBUDDY_SESSION_ID ||
@@ -974,6 +975,7 @@ const KNOWN_SESSION_ENV_KEYS = [
974
975
  'CURSOR_CONVERSATION_ID',
975
976
  'CLAUDE_CONVERSATION_ID',
976
977
  'CLAUDE_SESSION_ID',
978
+ 'CODEX_SESSION_ID',
977
979
  'WORKBUDDY_CONVERSATION_ID',
978
980
  'WORKBUDDY_SESSION_ID',
979
981
  'CODEBUDDY_CONVERSATION_ID',
@@ -1893,7 +1895,7 @@ function cmdReject(args) {
1893
1895
  isFromLane = fromLanes.includes(cur);
1894
1896
  isAuditor = (cur === toLaneRaw && toLaneRaw === 'audit');
1895
1897
  if (!isFromLane && !isAuditor) {
1896
- console.error(`❌ 越界驳回:当前执行身份 lane=${cur} 既非发起方 from_lane=${fromLaneRaw},亦非审计方 to_lane=${toLaneRaw}。驳回仅允许由发起方或审计方执行。`);
1898
+ console.error(`❌ 越界驳回:当前执行身份 lane=${cur} 既非发起方 from_lane=${fromLaneRaw},亦非审计方 to_lane=${toLaneRaw}。驳回仅允许由发起方或审计方执行(普通执行方受阻请通过 baton receipt 登记受阻回执交由发起方协调)。`);
1897
1899
  process.exit(1);
1898
1900
  }
1899
1901
  } else {
@@ -3213,7 +3215,7 @@ const STUB_BODY_ZH = `### Agent Baton (Handoff) 接入桩(轻量韧性版 ·
3213
3215
  2. **读工单**:运行 \`baton show <id>\`,根据验收判据改动本 lane 范围代码并实测。
3214
3216
  3. **交付或退回(实测为唯一准绳)**:
3215
3217
  - **实测通过**:照抄 \`$(lab path handoffs)/RESPONSE-TEMPLATE.md\` 骨架 → 运行 \`baton receipt <id> -n "<正文>" --deliver --as <本方 lane> --evidence-paths "<路径>"\`(审计工单附 \`--audit-nonce "<nonce>"\` 或同工作区授权下使用 \`--auto-nonce\` 自动绑定最新令牌;红队用例严格遵循 NO_DISPATCH / NO_COMPLETE / COMPLETE 三态标准)。
3216
- - **实测未过(NO-GO/受阻)**:享有安全下车通道,直接运行 \`baton reject <id> -n "<理由/缺失条件>" --as <本方 lane>\` 退回整改。
3218
+ - **实测未过(NO-GO/受阻)**:审计方享有安全下车通道,运行 \`baton reject <id> -n "<理由/差异在哪>" --as audit\` 退回整改;普通执行方若受阻/缺失条件,登记受阻回执 \`baton receipt <id> -n "<缺失条件/受阻理由>" --evidence-note "<说明>" --as <本方 lane>\` 由发起方核实并处理。
3217
3219
  4. **收尾自检**:运行 \`baton check [id]\`(若有数据漂移可加 \`--fix\` 自动修复)。
3218
3220
  5. **入站回复收尾(简洁单行裁决 · 严禁角色漂移)**:接收方必须严格保持本方执行/审计角色,严禁切换为发起方角色;**严禁反向输出 \`## 交接提示词\` 卡片或调用 \`baton close\` 越权闭环**;最终回复人类的最末尾仅输出单行纯文本(无需标题,无需代码块,严禁多行出站卡片):
3219
3221
  - 审计驳回:\`审计完成,裁决 NO-GO(工单已退回<发起方角色>进入 Round <N>)\`
@@ -5607,7 +5609,7 @@ async function cmdWait(args) {
5607
5609
 
5608
5610
  // 平息完成后:对自愈候选工单安全落盘推进为 delivered
5609
5611
  promoteAutoDeliverCandidates();
5610
- console.log(`🎉 [会话已平息] 执行方会话已彻底结束,正式唤醒发起方!`);
5612
+ console.log(`🎉 [会话已平息] 执行方会话已平息,监听进程结束并以 Exit 0 唤醒宿主发起方!`);
5611
5613
  }
5612
5614
 
5613
5615
  cleanupAll();
@@ -1,5 +1,10 @@
1
1
  # Changelog — review-gate
2
2
 
3
+ ## v1.2.3 (2026-11-27)
4
+ - **Ruff 降级结果解析与门禁拦截漏洞彻底根治**:重构 `pre-commit` 门禁与 `scan.sh`,支持准确解析 Ruff 输出的 JSON 数组结构并归一化转换为基线比对模型,杜绝因 `dict.get` 在列表上抛错被捕获而静默放行 Python 安全漏洞的问题。
5
+ - **真实暂存区(Git Index Blob)快照扫描**:门禁扫描不再直接读取可能已被修改的工作区物理文件,改为通过 `git show :<staged_path>` 将待提交快照还原至独立沙箱目录进行扫描,彻底解决部分暂存误报或工作区未重新暂存导致的漏洞漏检。
6
+ - **双盲审计运行器(Clean Runner)多行判据块保持**:修复验收判据代码块按换行逐行切割导致 `cd` 上下文丢失、多行语句断裂的问题,完整保持脚本块原子执行。
7
+
3
8
  ## v1.2.2 (2026-11-22)
4
9
  - **文档与审查防线增强(Layer-2 code-review-graph 集成指引)**:在 `README.md` §6 Layer-2 本地审查中明确补充与 `code-review-graph` 的协同工作模式,推荐在 Review 前运行 `code-review-graph impact` 提取爆炸半径精准切片。
5
10
  - **OpenGrep 原生扫描产物补齐结构化引擎元数据**:修复 `scan.sh` 在 OpenGrep 原生扫描路径下输出 JSON 缺少顶层 `engine: "opengrep"` 与 `fallback: false` 字段的问题,实现与降级扫描模式对齐的对称契约。
@@ -1,3 +1,3 @@
1
1
  # review-gate 版本
2
2
 
3
- v1.2.2 — 2026-11-22
3
+ v1.2.3 — 2026-11-27
@@ -16,12 +16,12 @@ const REVIEW_GATE_VERSION = (() => {
16
16
  try {
17
17
  const vPath = path.join(SCRIPT_ROOT, 'VERSION.md');
18
18
  if (fs.existsSync(vPath)) {
19
- const line = fs.readFileSync(vPath, 'utf8').trim().split('\n')[0];
20
- const m = line.match(/v?(\d+\.\d+\.\d+)/);
19
+ const content = fs.readFileSync(vPath, 'utf8');
20
+ const m = content.match(/v?(\d+\.\d+\.\d+)/);
21
21
  if (m) return m[1];
22
22
  }
23
23
  } catch {}
24
- return '1.2.2';
24
+ return '1.2.3';
25
25
  })();
26
26
 
27
27
  const args = process.argv.slice(2);
@@ -91,11 +91,11 @@ function extractCommandsFromTicket(content) {
91
91
  const codeBlockRegex = /```(?:bash|sh|zsh)?\n([\s\S]*?)```/g;
92
92
  let match;
93
93
  while ((match = codeBlockRegex.exec(sectionBody)) !== null) {
94
- const lines = match[1]
95
- .split('\n')
96
- .map((l) => l.trim())
97
- .filter((l) => l && !l.startsWith('#'));
98
- commands.push(...lines);
94
+ const block = match[1].trim();
95
+ if (block) {
96
+ // 保持代码块作为一个完整的 Shell 脚本块执行,避免逐行拆分导致 cd、变量与上下文断裂
97
+ commands.push(block);
98
+ }
99
99
  }
100
100
  }
101
101
  return commands;
@@ -199,29 +199,33 @@ function runAudit(ticketId, options = {}) {
199
199
  process.exit(1);
200
200
  }
201
201
 
202
- console.log(`\n🛡️ [Clean Audit Runner] 启动无上下文双盲审计执行:`);
203
- console.log(` • 工单 ID: \x1b[36m${cleanId}\x1b[0m`);
204
- console.log(` • 执行物理目录: \x1b[32m${targetDir}\x1b[0m ${isWorktree ? '(隔离工作树)' : '(主代码库)'}`);
205
- console.log(` • 待执行校验项 (${commands.length} 项):`);
206
- commands.forEach((c, idx) => console.log(` ${idx + 1}. \x1b[33m${c}\x1b[0m`));
207
- console.log('─'.repeat(70));
202
+ if (!options.json) {
203
+ console.log(`\n🛡️ [Clean Audit Runner] 启动无上下文双盲审计执行:`);
204
+ console.log(` • 工单 ID: \x1b[36m${cleanId}\x1b[0m`);
205
+ console.log(` • 执行物理目录: \x1b[32m${targetDir}\x1b[0m ${isWorktree ? '(隔离工作树)' : '(主代码库)'}`);
206
+ console.log(` • 待执行校验项 (${commands.length} 项):`);
207
+ commands.forEach((c, idx) => console.log(` ${idx + 1}. \x1b[33m${c}\x1b[0m`));
208
+ console.log('─'.repeat(70));
209
+ }
208
210
 
209
211
  const results = [];
210
212
  let allPassed = true;
211
213
 
212
214
  for (const cmd of commands) {
213
- process.stdout.write(`⏳ 正在执行: ${cmd} ... `);
215
+ if (!options.json) process.stdout.write(`⏳ 正在执行: ${cmd} ... `);
214
216
  const execRes = executeClean(cmd, targetDir);
215
217
  results.push(execRes);
216
218
 
217
219
  if (execRes.exitCode === 0) {
218
- console.log(`\x1b[32mPASS\x1b[0m (${(execRes.durationMs / 1000).toFixed(2)}s)`);
220
+ if (!options.json) console.log(`\x1b[32mPASS\x1b[0m (${(execRes.durationMs / 1000).toFixed(2)}s)`);
219
221
  } else {
220
- console.log(`\x1b[31mFAIL (Exit ${execRes.exitCode})\x1b[0m (${(execRes.durationMs / 1000).toFixed(2)}s)`);
222
+ if (!options.json) {
223
+ console.log(`\x1b[31mFAIL (Exit ${execRes.exitCode})\x1b[0m (${(execRes.durationMs / 1000).toFixed(2)}s)`);
224
+ console.error('\n' + '─'.repeat(40) + ' [错误输出摘要] ' + '─'.repeat(40));
225
+ console.error(execRes.stderr.trim() || execRes.stdout.trim() || '(无标准输出)');
226
+ console.error('─'.repeat(96) + '\n');
227
+ }
221
228
  allPassed = false;
222
- console.error('\n' + '─'.repeat(40) + ' [错误输出摘要] ' + '─'.repeat(40));
223
- console.error(execRes.stderr.trim() || execRes.stdout.trim() || '(无标准输出)');
224
- console.error('─'.repeat(96) + '\n');
225
229
  break;
226
230
  }
227
231
  }