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 +2 -2
- package/INSTALL.md +5 -5
- package/README.md +3 -3
- package/bin/lab.mjs +43 -23
- package/docs/CONSUMER-PROMPTS.md +47 -0
- package/package.json +3 -3
- package/scripts/postinstall.mjs +42 -0
- package/units/handoffs/CHANGELOG.md +5 -2
- package/units/handoffs/handoff-status.mjs +1 -0
- package/units/handoffs/handoff.mjs +5 -3
- package/units/review-gate/CHANGELOG.md +5 -0
- package/units/review-gate/VERSION.md +1 -1
- package/units/review-gate/clean-runner.mjs +24 -20
- package/units/review-gate/templates/pre-commit +84 -34
- package/units/review-gate/templates/scan.sh +16 -2
- package/units/skills/CHANGELOG.md +5 -0
- package/units/skills/bin/review-package.mjs +2 -1
- package/units/skills/bin/task-brief.mjs +2 -1
- package/units/skills/skills.mjs +1 -1
- package/units/spec-guard/CHANGELOG.md +9 -0
- package/units/spec-guard/core/adr-parser.mjs +5 -2
- package/units/spec-guard/core/matrix-checker.mjs +20 -8
- package/units/spec-guard/core/mutation-runner.mjs +54 -26
- package/units/spec-guard/core/telemetry_authenticator.mjs +42 -9
- package/units/spec-guard/tests/spec-guard.test.mjs +63 -0
- package/units/spec-guard/tests/telemetry_authenticator.test.mjs +22 -0
- package/units/worktree/CHANGELOG.md +6 -0
- package/units/worktree/VERSION.md +1 -1
- package/units/worktree/tests/worktree.test.mjs +57 -0
- package/units/worktree/worktree.mjs +20 -4
- package//344/275/277/347/224/250/350/257/264/346/230/216.md +3 -3
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog — units/worktree
|
|
2
2
|
|
|
3
|
+
## [v0.1.1] - 2026-11-27
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **诚实分支回收状态报告**:修复 `prune` 子命令在临时分支包含未合并修改且未加 `--force` 时静默吞掉 `git branch -d` 报错并虚报成功的问题;现在明确输出警告并返回 `worktree_removed_branch_retained` 状态与详细错误。
|
|
7
|
+
- **单元测试补齐**:新增 `units/worktree/tests/worktree.test.mjs`,常驻校验回收状态诚实性。
|
|
8
|
+
|
|
3
9
|
## [v0.1.0] - 2026-11-09
|
|
4
10
|
|
|
5
11
|
### Added
|
|
@@ -1 +1 @@
|
|
|
1
|
-
v0.1.
|
|
1
|
+
v0.1.1 — 2026-11-27
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
7
|
+
|
|
8
|
+
describe('units/worktree: 隔离与回收诚实状态测试', () => {
|
|
9
|
+
const worktreeBin = path.resolve('units/worktree/worktree.mjs');
|
|
10
|
+
|
|
11
|
+
it('prune 在分支无法安全删除时真实反映状态,不瞒报成功', () => {
|
|
12
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'wt-test-'));
|
|
13
|
+
try {
|
|
14
|
+
execSync('git init', { cwd: tmpDir, stdio: 'pipe' });
|
|
15
|
+
execSync('git config user.name "Test"', { cwd: tmpDir, stdio: 'pipe' });
|
|
16
|
+
execSync('git config user.email "test@example.com"', { cwd: tmpDir, stdio: 'pipe' });
|
|
17
|
+
|
|
18
|
+
// 创建初始提交
|
|
19
|
+
fs.writeFileSync(path.join(tmpDir, 'init.txt'), 'base');
|
|
20
|
+
execSync('git add init.txt && git commit -m "init"', { cwd: tmpDir, stdio: 'pipe' });
|
|
21
|
+
|
|
22
|
+
const ticketId = 'TASK-001';
|
|
23
|
+
// 1. 分配 worktree
|
|
24
|
+
execSync(`node "${worktreeBin}" allocate ${ticketId}`, { cwd: tmpDir, stdio: 'pipe' });
|
|
25
|
+
|
|
26
|
+
const wtPath = path.join(tmpDir, '.worktrees', ticketId);
|
|
27
|
+
assert.ok(fs.existsSync(wtPath), 'Worktree directory should be created');
|
|
28
|
+
|
|
29
|
+
// 2. 在 worktree 中产生未合并提交
|
|
30
|
+
fs.writeFileSync(path.join(wtPath, 'feature.txt'), 'feature branch commit');
|
|
31
|
+
execSync('git add feature.txt && git commit -m "work in progress"', { cwd: wtPath, stdio: 'pipe' });
|
|
32
|
+
|
|
33
|
+
// 3. 执行 prune (不带 --force)
|
|
34
|
+
const pruneOut = execSync(`node "${worktreeBin}" prune ${ticketId} --json`, {
|
|
35
|
+
cwd: tmpDir,
|
|
36
|
+
encoding: 'utf8',
|
|
37
|
+
stdio: 'pipe',
|
|
38
|
+
});
|
|
39
|
+
const parsed = JSON.parse(pruneOut);
|
|
40
|
+
assert.equal(parsed.status, 'worktree_removed_branch_retained');
|
|
41
|
+
assert.equal(parsed.branchPruned, false);
|
|
42
|
+
assert.ok(parsed.branchPruneError, 'Should report branch prune error');
|
|
43
|
+
|
|
44
|
+
// 4. 带 --force 执行 prune
|
|
45
|
+
const forceOut = execSync(`node "${worktreeBin}" prune ${ticketId} --force --json`, {
|
|
46
|
+
cwd: tmpDir,
|
|
47
|
+
encoding: 'utf8',
|
|
48
|
+
stdio: 'pipe',
|
|
49
|
+
});
|
|
50
|
+
const forceParsed = JSON.parse(forceOut);
|
|
51
|
+
assert.equal(forceParsed.status, 'pruned');
|
|
52
|
+
assert.equal(forceParsed.branchPruned, true);
|
|
53
|
+
} finally {
|
|
54
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -187,22 +187,38 @@ function prune(ticketId, options = {}) {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
// 2. 清理分支
|
|
190
|
+
let branchPruned = true;
|
|
191
|
+
let branchPruneError = null;
|
|
190
192
|
const branchExists = runCmd(`git rev-parse --verify refs/heads/${branchName}`, { ignoreError: true });
|
|
191
193
|
if (branchExists) {
|
|
192
194
|
const delFlag = options.force ? '-D' : '-d';
|
|
193
195
|
try {
|
|
194
196
|
runCmd(`git branch ${delFlag} "${branchName}"`);
|
|
195
|
-
} catch {
|
|
196
|
-
|
|
197
|
+
} catch (err) {
|
|
198
|
+
branchPruned = false;
|
|
199
|
+
branchPruneError = err.message;
|
|
200
|
+
if (!options.json) {
|
|
201
|
+
console.warn(`⚠️ 临时分支 [${branchName}] 未能自动删除(可能包含未合并改动): ${err.message}`);
|
|
202
|
+
console.warn(` 若确认丢弃该分支,可运行: git branch -D "${branchName}"`);
|
|
203
|
+
}
|
|
197
204
|
}
|
|
198
205
|
}
|
|
199
206
|
|
|
200
207
|
runCmd('git worktree prune', { ignoreError: true });
|
|
201
208
|
|
|
202
209
|
if (options.json) {
|
|
203
|
-
console.log(JSON.stringify({
|
|
210
|
+
console.log(JSON.stringify({
|
|
211
|
+
status: branchPruned ? 'pruned' : 'worktree_removed_branch_retained',
|
|
212
|
+
ticketId: cleanId,
|
|
213
|
+
branchPruned,
|
|
214
|
+
branchPruneError
|
|
215
|
+
}));
|
|
204
216
|
} else {
|
|
205
|
-
|
|
217
|
+
if (branchPruned) {
|
|
218
|
+
console.log(`\n🧹 已成功回收工单 [${cleanId}] 的隔离工作区与临时分支。`);
|
|
219
|
+
} else {
|
|
220
|
+
console.log(`\n🧹 已成功回收工单 [${cleanId}] 的隔离工作区,但临时分支保留。`);
|
|
221
|
+
}
|
|
206
222
|
}
|
|
207
223
|
}
|
|
208
224
|
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
| **codegraph** | `docs/codegraph-readiness-check.md` | 代码语义索引就绪检查(索引工具本身需独立安装,本库只含就绪检查文档) |
|
|
56
56
|
| **code-review-graph** | `docs/code-review-graph-guide.md` | 代码审查与变动爆炸半径(Blast Radius)分析引擎就绪与使用指引 |
|
|
57
57
|
| **handoffs** | `handoffs/` | 跨仓 / 仓内交接枢纽(`handoff.mjs` 引擎 + 中央契约 **v2.41.2**),统一工单与会话ID、防跨会话硬门禁、跨客户端角色锚定与状态机归属确定性 (ADR-0016)、根治建单 from_lane 为空与上游角色倒错、出站提示词双向锚定、自主双盲审计分诊协议、避免角色漂移、纯化入站单行裁决提示词、Rule 8 分级 SDD 验收与负向测试先行证明、`--profile readonly` 生产源码写保护物理硬门禁、HMAC-SHA256 密码学审计凭据 (`audit.token`)、出站提示词防注入三段式、五态状态机、显式身份 `--as`、无条件下车与事件唤醒 |
|
|
58
|
-
| **worktree** | `worktree/` | 基于 Git Worktree 的物理目录隔离调度引擎,为多 Agent 并发分配独立沙盒,智能共享依赖缓存(v0.1.
|
|
58
|
+
| **worktree** | `worktree/` | 基于 Git Worktree 的物理目录隔离调度引擎,为多 Agent 并发分配独立沙盒,智能共享依赖缓存(v0.1.1,支持 `--version` 与契约门禁) |
|
|
59
59
|
| **orphan** | `orphan/` | 全局死代码与孤儿资产清道夫与反假接线三层正交治理(**v1.4.2**,ADR-0009 / ADR-0011 / ADR-0013):只读 Git HEAD、S1–S3 求解器、L1/L2/L3 规范、Tier 1/2 自查、`check-deps [--strict]` 孤儿依赖求解器、`scan-secrets [--strict]` 零调用高熵假凭证探针、动态 SSOT 与 `--version` 支持 |
|
|
60
60
|
| **spec-guard** | `spec-guard/` | 架构规约与物理接线守卫(**v2.2.1**):P3' 三元对账、三维热力表、ADR 机器信任根验签、物理接线探针、约定阈值解耦、零覆盖假绿防卫、暂存区增量快速放行、动态 SSOT 与 `--version` 支持 |
|
|
61
61
|
| **skills** | `skills/` | 微观工程原子技能库与分发引擎(**v0.1.0**,ADR-0015):官方沉淀 TDD 红绿循环、系统化排错四步法、先验后报、需求澄清 4 大原子技能,带 Iron Law 与借口阻断表,提供 `task-brief` 与 `review-package` 零污染切片流水线 |
|
|
62
62
|
| **specs** | `specs/` | Spec Kit 活文档模板全集(`specs/templates/` 01-research 到 05-evidence),赋能 RePPIT 5 步规约驱动开发闭环 |
|
|
63
63
|
| **playbook** | `playbook/` | AEF 全套执行手册(constitution + group + specs + 生命周期门禁 + 第 20/21 章战法手册) |
|
|
64
64
|
| **preflight** | `preflight/` | 仓库不变量探针 + 提交门禁 + 收尾回报三节形状(**v1.1.0**,A1~A5 探针含配置化单一事实源对账防漂移) |
|
|
65
|
-
| **review-gate** | `review-gate/` | SAST (OpenGrep) + 本地 review + 双盲审计自动化运行器 (`baton-audit-runner`),**v1.2.
|
|
65
|
+
| **review-gate** | `review-gate/` | SAST (OpenGrep) + 本地 review + 双盲审计自动化运行器 (`baton-audit-runner`),**v1.2.3** 新增 `--no-suppress` 穿透扫描、OpenGrep 原生模式顶层对称注入 `engine: "opengrep"` 结构化元数据、Ruff Bandit 诚实降级与 macOS bash 3.2 兼容自愈 |
|
|
66
66
|
|
|
67
67
|
每个模块目录里都有 `README.md`(规范的**唯一事实源**);`adr` / `backlog` / `preflight` / `review-gate` 另提供 `docs/new-project-prompt.md`(可直接复制给 AI Agent 会话),其余模块按 README 与 `$(lab path <unit>)` 动态指针接入。全部 10 个单元可用 `lab list` 列出。
|
|
68
68
|
|
|
@@ -143,7 +143,7 @@ baton check # 交接 / 回执合规自检
|
|
|
143
143
|
- 出站转递:单工单 `baton forward <ID> --wait`(挂起监听),多工单并发解耦 `baton forward <ID> --async`,或批量派发与聚合等待 `baton forward <id1> <id2> ... --wait`。
|
|
144
144
|
- 详见 `units/handoffs/AGENT-GUIDE.md` + `units/handoffs/COMMANDS.md`。
|
|
145
145
|
|
|
146
|
-
6. **worktree(多 Agent 物理并发隔离引擎 · v0.1.
|
|
146
|
+
6. **worktree(多 Agent 物理并发隔离引擎 · v0.1.1)**
|
|
147
147
|
解决多 Agent 并发开发时互相踩踏主目录暂存区的顽疾:
|
|
148
148
|
```bash
|
|
149
149
|
baton-worktree allocate <ticket-id> # 为工单创建专属物理目录 (.worktrees/<id>) 并软链共享依赖缓存
|