openfeel 1.6.0 → 1.6.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.
- package/README.en.md +7 -0
- package/README.zh-CN.md +7 -0
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +10 -1
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/flow.d.ts.map +1 -1
- package/dist/commands/flow.js +19 -12
- package/dist/commands/flow.js.map +1 -1
- package/dist/commands/lint.d.ts +3 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +279 -2
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/req.d.ts.map +1 -1
- package/dist/commands/req.js +470 -95
- package/dist/commands/req.js.map +1 -1
- package/dist/core/adherence.d.ts +135 -0
- package/dist/core/adherence.d.ts.map +1 -0
- package/dist/core/adherence.js +221 -0
- package/dist/core/adherence.js.map +1 -0
- package/dist/core/dashboard/aggregate.d.ts +39 -0
- package/dist/core/dashboard/aggregate.d.ts.map +1 -1
- package/dist/core/dashboard/aggregate.js +64 -5
- package/dist/core/dashboard/aggregate.js.map +1 -1
- package/dist/core/dashboard/render.d.ts.map +1 -1
- package/dist/core/dashboard/render.js +88 -1
- package/dist/core/dashboard/render.js.map +1 -1
- package/dist/core/errors.d.ts +27 -2
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +15 -2
- package/dist/core/errors.js.map +1 -1
- package/dist/core/flow/gate-override.d.ts +72 -0
- package/dist/core/flow/gate-override.d.ts.map +1 -0
- package/dist/core/flow/gate-override.js +71 -0
- package/dist/core/flow/gate-override.js.map +1 -0
- package/dist/core/flow-manager.d.ts +13 -4
- package/dist/core/flow-manager.d.ts.map +1 -1
- package/dist/core/flow-manager.js +47 -16
- package/dist/core/flow-manager.js.map +1 -1
- package/dist/core/i18n-data/en.d.ts.map +1 -1
- package/dist/core/i18n-data/en.js +45 -6
- package/dist/core/i18n-data/en.js.map +1 -1
- package/dist/core/i18n-data/zh-CN.d.ts.map +1 -1
- package/dist/core/i18n-data/zh-CN.js +45 -6
- package/dist/core/i18n-data/zh-CN.js.map +1 -1
- package/dist/core/req/body-file.d.ts +37 -0
- package/dist/core/req/body-file.d.ts.map +1 -1
- package/dist/core/req/body-file.js +39 -2
- package/dist/core/req/body-file.js.map +1 -1
- package/dist/core/req/plan-file.d.ts +83 -0
- package/dist/core/req/plan-file.d.ts.map +1 -0
- package/dist/core/req/plan-file.js +205 -0
- package/dist/core/req/plan-file.js.map +1 -0
- package/dist/core/req/requirement-ops.d.ts +25 -3
- package/dist/core/req/requirement-ops.d.ts.map +1 -1
- package/dist/core/req/requirement-ops.js +66 -11
- package/dist/core/req/requirement-ops.js.map +1 -1
- package/dist/core/req/types.d.ts +8 -2
- package/dist/core/req/types.d.ts.map +1 -1
- package/dist/core/req/types.js +10 -2
- package/dist/core/req/types.js.map +1 -1
- package/dist/core/template-loader.d.ts.map +1 -1
- package/dist/core/template-loader.js +12 -0
- package/dist/core/template-loader.js.map +1 -1
- package/dist/core/templates.d.ts +1 -1
- package/dist/core/templates.d.ts.map +1 -1
- package/dist/core/templates.js +18 -0
- package/dist/core/templates.js.map +1 -1
- package/dsh/ACTION-GUIDE.md +15 -6
- package/dsh/ADAPTER.md +62 -1
- package/dsh/README.md +13 -11
- package/dsh/docs/compat/persistence.md +13 -0
- package/dsh/docs/compat/pipeline.md +12 -0
- package/dsh/docs/compat/req.md +15 -0
- package/dsh/docs/compat/stage.md +12 -0
- package/dsh/lib/adapters/dispatch-ledger.js +149 -10
- package/dsh/lib/guard.js +685 -22
- package/dsh/lib/surface/prompt.js +4 -0
- package/dsh/lib/tools/index.js +113 -22
- package/dsh/package.json +2 -2
- package/package.json +2 -1
package/dsh/ACTION-GUIDE.md
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
> **日期**:2026-10-17 | **基线**:OpenFeel `1.2.3` / DSH `0.2.0-rc.2`
|
|
6
6
|
> **权威契约**:[`../docs/json-contract.md`](../docs/json-contract.md)
|
|
7
7
|
>
|
|
8
|
-
> **一句话**(v1.6.
|
|
8
|
+
> **一句话**(v1.6.1 更新):A1~A5 已全部交付;适配器工具面 **15 个**(v1.6.0 新增 `feel_dispatch` / `feel_dev`,v1.6.1 只加 action:`feel_dispatch finish` / `feel_verify adherence`),并新增「主会话只调度」硬规则。§3~§7 是历史需求单存档(交付记录),**现行契约以 §0 与 `docs/json-contract.md` 为准**。
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
## 0. v1.6.
|
|
12
|
+
## 0. v1.6.1 硬规则(现行,优先于下文存档)
|
|
13
13
|
|
|
14
14
|
### 0.1 主会话只调度 —— 必须派发子 Agent
|
|
15
15
|
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
- 每次派发先调 `feel_dispatch` 记账(写 `.openfeel/dev/dispatch.jsonl`,受 guard 保护):
|
|
19
19
|
|
|
20
20
|
```text
|
|
21
|
-
feel_dispatch stage=v1.
|
|
21
|
+
feel_dispatch stage=v1.7.0-stage-133 phase=exec_running
|
|
22
22
|
targetAgent=openfeel-executor role=executor
|
|
23
|
-
goal="
|
|
23
|
+
goal="E13 文档对账:docs/json-contract.md 计数改 51/52,并通过 npm run build"
|
|
24
24
|
files=["docs/json-contract.md","CHANGELOG.md"]
|
|
25
25
|
returnFormat="≤10 行:结论/改动文件/验证/阻塞"
|
|
26
26
|
```
|
|
@@ -41,6 +41,15 @@
|
|
|
41
41
|
- `general` 的**阶段级**转移表仍为空(阶段级 general 在写入面即被拒);强制链落在**需求生命周期**——三种模式都要求「计划 → 执行 → 审查」,区别只在阶段级是否裁剪 scheme/test。
|
|
42
42
|
- `--force` 只做**留痕放行**(`gate_overrides` / waiver + 审计),**不能**绕过 done 门(review + verify)、blocking REV 门与版本归档判据。
|
|
43
43
|
|
|
44
|
+
### 0.4 v1.6.1 增量(REQ-061~067)
|
|
45
|
+
|
|
46
|
+
- **工具面仍 15 个**(计 `tools.length === 15` 不变;新增的是 action):`feel_dispatch action=finish`(按 `dispatchId` 原地补写 `closing{status,artifacts,durationMs,summary}` + 顶层 `closedAt`,幂等);`feel_verify action=adherence`(调 `lint adherence --json`,四指标 `{value,definition}`);`feel_req action=body`(`text` 走 `os.tmpdir()` 临时文件 + `--file`,多行 / CRLF 字节保真)。**适配器暂无 `action=plan` / `body --from`**:需求级计划用 CLI `openfeel req plan <id> [--force]`(出口 #50,已存在默认拒绝、`--force` 返回 `replaced:true`),多节导入用 `openfeel req body <id> --from <md>`。
|
|
47
|
+
- **派发台账 schema v2**:v1.6.0 十三键零改动;闭环追加可选 `closing`(恰 4 键)与行顶层 `closedAt`。`feel_status.dispatch` = `{required,total,sincePhase,open[],closedRatio,missingRoles,records[]}`——`open[]` = 当前 stage 未闭环派发;`closedRatio` = `closing.status==='done'` 数 / `total`(空台账 → `null`);`missingRoles` **改按 `closing.status==='done'`** 判定(旧「有 record 即算」作废)。
|
|
48
|
+
- **遵守率四指标**(`feel_verify action=adherence`,只读、恒 exit 0):`main_write_ratio` = `origin=root` 写调用 /(root + `subagent|delegated` + **`origin` 缺失计 unknown 且进分母**);`subagent_per_req` = `role=executor` 且 `closing.status='done'` 的派发数 / `in_progress` 需求数;`sync_gap` = 现在 − `.sync.json.last_sync`(分钟,缺失 → null);`violation_rate` = `deny` / 全部 guard 决策。每键带 `definition`(分子/分母 + 样本窗口),样本不足 `value:null`、绝不 NaN。
|
|
49
|
+
- **guard wrapper 静态分类(REQ-067)**:`pwsh -File` / `cmd /c` / `bash <脚本>` 读脚本内容(≤64KB)按同一套 `classifyShellCommand` 递归判定;UTF-16LE+BOM 解码后命中 deny;**GBK 等编码不解码 → `undecidable`**(默认 warn + 审计含 `wrapper` / `scriptPath` / `reason`,`strict` 仍拒);`node` 脚本不读内容 → `undecidable`;`readonly.ps1` / `build.ps1` 等普通脚本不误杀。
|
|
50
|
+
- **审后文档 / 夹具白名单(REQ-062)**:`review_passed` / `test_passed` 相位允许改 `docs/**`、根级 `*.md`、`test/fixtures/**`、`dsh/test/fixtures/**`(`reason:'doc-asset-phase'`);`src/**` 与 `test/core/**` 仍拒;豁免只在相位层、不扩散到源码树。
|
|
51
|
+
- **JSON 契约**:51 成功出口 / 52 注册选项(#47~#51);`release` 脚本的 `--json` 不进 CLI 出口表;错误码表 20 行。
|
|
52
|
+
|
|
44
53
|
---
|
|
45
54
|
|
|
46
55
|
## 目录
|
|
@@ -63,8 +72,8 @@
|
|
|
63
72
|
|
|
64
73
|
| 项 | 值 |
|
|
65
74
|
|---|---|
|
|
66
|
-
| OpenFeel 版本 | `1.2.3`(存档基线;现行 1.6.
|
|
67
|
-
| 成功 `--json` 出口 | **33**(存档;现行 **
|
|
75
|
+
| OpenFeel 版本 | `1.2.3`(存档基线;现行 1.6.1) |
|
|
76
|
+
| 成功 `--json` 出口 | **33**(存档;现行 **51**,注册选项 **52**) |
|
|
68
77
|
| 适配器已消费 | **25** 个出口(存档;现行按工具实现,不按出口总数折算) |
|
|
69
78
|
| 适配器文本回显 | **8** 处(存档;现行仅 `dev status` 与 `instructions` XML 默认形态) |
|
|
70
79
|
| 适配器验证 | 存档 110 断言;现行 contract 53 / verify 129 / guard 180 / integration 10 |
|
package/dsh/ADAPTER.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
- **落点**:`ctx.tools`(15 个 `feel_*` 工具)、`ctx.commands`(`/feel`)、
|
|
14
14
|
`ctx.systemPrompt`(`<feel_mode>` 纪律段 + 每轮提醒段)。不写任何领域状态。
|
|
15
15
|
- **契约**:CLI 的 `--json` 出口以 [`docs/json-contract.md`](https://github.com/Liuary/OpenFeel/blob/master/docs/json-contract.md) 为**单一权威**
|
|
16
|
-
(v1.6.
|
|
16
|
+
(v1.6.1 起 51 个成功出口 / 52 个注册 `--json` 选项);本适配器只消费、不重实现。
|
|
17
17
|
- **升级**:`npm i -g openfeel@latest` → 重启 DSH。适配器版本要求见 `package.json`
|
|
18
18
|
的 `openfeel.requiresCli`(≥1.6.0;`req body` / `feel_req body` / 五个新门禁码是硬依赖)。
|
|
19
19
|
|
|
@@ -200,6 +200,67 @@ spike 原始证据(含 upgrade 条件)见 `.openfeel/tmp/stage-132/spike.md`
|
|
|
200
200
|
- **`origin` / `dispatchDepth`**:按 schema 保留缺省 `root` / `1`;**从宿主会话头读取的路径未在真实宿主验证**(spike T9 遗留),因此不构成实测证据,也不据此改审计 schema 版本。
|
|
201
201
|
- **`feel_status.dispatch`** = `{required, records, missingRoles}`:`required` 恒 `true`(**提示级,不做硬拦**,用户裁定②);`records` = 24h 内行数;`missingRoles` = 本快照应有但台账缺的 agent 角色。`feel_status` / `feel_next` 另给动作型 `nextAction`(`{kind:'dispatch'|'command'|'idle', tool, goal, prompt, reason}`),`next` 字符串键保留以不破坏既有断言。
|
|
202
202
|
|
|
203
|
+
## v1.6.1:派发闭环、遵守率、guard wrapper 与文档白名单
|
|
204
|
+
|
|
205
|
+
> 基线:CLI `1.6.1`(`openfeel.requiresCli >=1.6.1`);工具面**仍 15 个**(新增的是 action,不是工具)。
|
|
206
|
+
|
|
207
|
+
### 工具面增量(15 个,计数不变)
|
|
208
|
+
|
|
209
|
+
| 工具 | v1.6.1 增量 |
|
|
210
|
+
|---|---|
|
|
211
|
+
| `feel_dispatch` | **`action=finish`**:按 `dispatchId` **原地补写** `closing{status:'done'\|'failed', artifacts[], durationMs, summary}` + 行顶层 `closedAt`;行数 / 行序 / 其余行字节不变;重复 finish 内容相同 → `ok:true, changed:false`(`ts` / `closing` / `closedAt` 不二次改写);未知 id → 报错。`durationMs` 缺省 = `now - Date.parse(ts)`(非负整数,解析失败 → 0)。 |
|
|
212
|
+
| `feel_status` | `dispatch` 汇总升到 **7 键**:`{required, total, sincePhase, open[], closedRatio, missingRoles, records[]}`(旧四键保留)。`open[]` = 当前 `stage` 范围内无 `closing` 或 `closing.status!=='done'` 的派发;`closedRatio` = `closing.status==='done'` 条数 / `total`(`total===0` → `null`,不出现 NaN);`missingRoles` **改按 `closing.status==='done'`** 判定(旧「有 record 即算」作废);`records[]` 透出 `closing` / `closedAt`。 |
|
|
213
|
+
| `feel_verify` | **`action=adherence`**:调 `openfeel lint adherence --json`(CLI 出口 #51),返回四指标 `{main_write_ratio, subagent_per_req, sync_gap, violation_rate}`,每键 `{value, definition}`;样本不足 → `value:null` 且不抛错。**不新增工具、不新增 `openfeel verify` 顶层命令**。 |
|
|
214
|
+
| `feel_req` | `action=body`(v1.6.0 起;v1.6.1 起 `text` **走 `os.tmpdir()` 临时文件 + `--file`**,argv 零 `--text`,`finally` 清理);`action=add` 可带 `plan` 参数写正文 `## 初步规划` 小节。**已知缺口**:适配器当前没有 `action=plan`,也没有 `body --from` 透传——需求级计划请用 `openfeel req plan <id> [--force]`(CLI 出口 #50),多节导入请用 `openfeel req body <id> --from <md>`。 |
|
|
215
|
+
|
|
216
|
+
### 派发台账 schema v2(`.openfeel/dev/dispatch.jsonl`)
|
|
217
|
+
|
|
218
|
+
v1.6.0 的 13 键(`dispatchId,ts,leadSessionId,origin,stage,phase,targetAgent,role,taskId,goal,files,returnFormat,dispatchDepth`)**零改动**;v1.6.1 只在闭环后追加两个**可选**字段(旧行缺省即未闭环):
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{"dispatchId":"d-0001","ts":"…","leadSessionId":"<session.id>","origin":"root","stage":"v1.7.0-stage-133","phase":"exec_running","targetAgent":"executor-a","role":"executor","taskId":"E13","goal":"…","files":["docs/commands.md"],"returnFormat":"≤10 行","dispatchDepth":1,"closing":{"status":"done","artifacts":["docs/commands.md"],"durationMs":123456,"summary":"文档对账完成"},"closedAt":"2026-11-25T02:00:00.000Z"}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
- `closing` **恰 4 键固定序**:`status` / `artifacts` / `durationMs` / `summary`;`closedAt` 是**行顶层**字段(不塞进 `closing`)。
|
|
225
|
+
- 兼容:读侧跳过畸形行,缺 `closing` 视为未闭环;`summarizeDispatch` 输出 `closing:null` / `closedAt:null`。
|
|
226
|
+
- 写入者唯一(适配器进程直接 fs,temp+rename);文件在 `PROTECTED_OPENFEEL_PATHS` 内,工具直写 → `deny`。
|
|
227
|
+
|
|
228
|
+
### 遵守率四指标(`feel_verify action=adherence`)
|
|
229
|
+
|
|
230
|
+
| 指标 | 分子 / 分母 | 样本窗口 |
|
|
231
|
+
|---|---|---|
|
|
232
|
+
| `main_write_ratio` | `origin=root` 的写调用 /(root + 子 Agent 派生 `subagent\|delegated` + `origin` 缺失计 unknown) | `.openfeel/log/guard-audit.jsonl` 全量 |
|
|
233
|
+
| `subagent_per_req` | `role=executor` 且 `closing.status='done'` 的派发数 / `status='in_progress'` 的需求数 | 台账 24h / 200 行 + 当前 `flow.json` |
|
|
234
|
+
| `sync_gap` | 现在 − `.openfeel/dev/.sync.json` 的 `last_sync`(毫秒 ÷ 60000,取整分钟;缺失/不可解析 → null) | 最近一次同步时刻(单点,无平均) |
|
|
235
|
+
| `violation_rate` | `decision='deny'` 条数 / 全部 guard 决策(`allow\|deny\|warn`) | `guard-audit.jsonl` 全量 |
|
|
236
|
+
|
|
237
|
+
> 口径单点在 `src/core/adherence.ts`;`value` 为 number 或 `null`,**绝不 NaN / Infinity**;**只读观测、恒 exit 0**(低遵守率不是门禁、不产生 deny)。
|
|
238
|
+
|
|
239
|
+
### guard wrapper 静态分类(REQ-067)
|
|
240
|
+
|
|
241
|
+
`bash` / `pwsh` 命令文本里的 wrapper 会**读脚本内容**(`MAX_SCRIPT_BYTES = 64KB`,超限不做部分读取)后按**同一套** `classifyShellCommand` 递归分类(`WRAPPER_MAX_DEPTH = 4`,触顶即不可判定):
|
|
242
|
+
|
|
243
|
+
- **解析面**(v1.6.1 实测,四种 + 内联):`pwsh|powershell -File|-f <脚本>` 与同 token 的 `-File:<脚本>`;`pwsh|powershell <脚本>`(**位置参数**,中间开关值如 `-ExecutionPolicy Bypass` 不丢载体);`cmd [/d|/q|/e:on 等前置开关] [/c|/k] <脚本>`(前置开关不吃掉载体,`/c:x.cmd` 同 token 也认);`bash|sh|zsh|dash|fish|ksh <脚本>`(第一个非旗标参数;`-c` 走内联递归);`source <脚本>` / `. <脚本>`(**只在命令位**识别,避免 `rg source x.sh` 误判;只认已知脚本扩展名);`node <脚本>` 见下条。
|
|
244
|
+
- 命中 openfeel 写动词 → class 1 `deny`;可解析出受保护 / 源码目标 → class 2 `deny`;内容确认只读(`readonly.ps1` / `build.ps1` / 只读 `node -e`)→ `allow`,**不写 deny 审计**(不误杀)。
|
|
245
|
+
- **`.cmd` / `.bat` 用 cmd 语义**(不拿 PowerShell 表硬套):`copy` / `move` **只算目标**(源只读,否则误杀 `copy src\a.ts dist\`)、`xcopy` / `robocopy` 第二个位置参数是目标、`del` / `erase` / `ren` / `rename` / `rd` / `rmdir` / `rm` **全部位置参数都算写**;`>` / `>>` 重定向统一按写处理。
|
|
246
|
+
- **`node` 默认不读内容** → `undecidable`(`node test/guard.js` 正文里本来就有 openfeel 字面量,读内容会误杀);只有脚本路径落在 `scripts/**`、或文件名含 `release` / `publish` / `commit` 时才读内容分类,且这类高风险脚本**内容不可判定时按 class 1 拒绝**(发布/提交类脚本要求人类在外部终端执行);内联 `node -e` / `bash -c` 仍走原递归。
|
|
247
|
+
- 编码:只接受 **UTF-8(含 BOM,严格校验)** 与 **UTF-16(BOM 或 NUL 启发式)**;**GBK 等双字节编码刻意不解码**(解错会给出假安全)→ 一律 `undecidable`。
|
|
248
|
+
- 不可判定(不存在 / 非文件 / 超限 / 编码不明 / `node` 默认不读)→ 第 4 类 `SHELL_GATE_UNDECIDABLE = warn`,**必须写审计**:`event:'guard_deny'` 之外的不可判定行带 `kind:'undecidable'` + `detail:{wrapper, scriptPath, class:'undecidable', reason}`;命中 1/2 类时 `detail.class` 为 `class1`/`class2`、`reason:'wrapper-write'`。`strict` 档下不可判定改为 `deny`。
|
|
249
|
+
- **仍存绕过面(如实记录,未封)**:
|
|
250
|
+
- `python <脚本>` / `deno run` / `bun <脚本>` 等解释器**不读脚本内容**,只落 `undecidable`(默认 `warn` 放行;只有 `strict` 才拒)——经它们真写文件时默认只留告警;
|
|
251
|
+
- `bash < x.sh`(stdin 重定向)没有位置参数载体,内容不被读取(实测落 `undecidable`,`scriptPath` 记为 `<`);
|
|
252
|
+
- PowerShell 调用符 `& ./x.ps1` 与 `if` / `foreach` / `{}` 等**控制流块**不在解析面内(落 `undecidable`,块内写命令不被分类);
|
|
253
|
+
- GBK 等双字节编码的 `.cmd` / `.ps1` 按设计不解码(`undecidable`,`strict` 拒);
|
|
254
|
+
- 变量拼接 / 运行时生成的动态命令同样只能到 `undecidable`。
|
|
255
|
+
|
|
256
|
+
### 文档 / 夹具写白名单相位(REQ-062)
|
|
257
|
+
|
|
258
|
+
`DOC_WRITE_PHASES = ['review_passed', 'test_passed']`(`exec_running` 本就放行,不在名单内):
|
|
259
|
+
|
|
260
|
+
- **放行**:`docs/**`、工作区根级 `*.md`(`README.md` / `CHANGELOG.md` 等)、`test/fixtures/**`、`dsh/test/fixtures/**`;审计 `reason:'doc-asset-phase'`。
|
|
261
|
+
- **仍拒**:`src/**`(含 `src/*.md` / `*.svg`)、`test/core/**` / `test/commands/**`(夹具 ≠ 测试代码)、以及所有受保护路径。
|
|
262
|
+
- 判定发生在**相位层**(`dsh/lib/guard.js` 的命令分类 / 相位判定区);`CODE_DIRECTORIES` / `isCodeDirectoryPath` / `isExemptPath` **未改**,豁免不扩散到源码树。
|
|
263
|
+
|
|
203
264
|
## 目录
|
|
204
265
|
|
|
205
266
|
| 路径 | 内容 |
|
package/dsh/README.md
CHANGED
|
@@ -35,8 +35,8 @@ OpenFeel 是一个给 AI 助手用的记录本和工作流程,主要解决两
|
|
|
35
35
|
- **每次派发都记账**:`feel_dispatch` 追加一行到 `.openfeel/dev/dispatch.jsonl`(`feel_status.dispatch.records` 可查;该文件受 guard 保护,手写会被拒)。示例:
|
|
36
36
|
|
|
37
37
|
```text
|
|
38
|
-
feel_dispatch stage=v1.
|
|
39
|
-
goal="
|
|
38
|
+
feel_dispatch stage=v1.7.0-stage-133 phase=exec_running targetAgent=openfeel-executor role=executor
|
|
39
|
+
goal="E13 文档对账:把 docs/json-contract.md 计数改为 51/52 并通过 npm run build"
|
|
40
40
|
files=["docs/json-contract.md","CHANGELOG.md"]
|
|
41
41
|
returnFormat="≤10 行:结论/改动文件/验证/阻塞"
|
|
42
42
|
```
|
|
@@ -157,18 +157,18 @@ Windows 上的 `openfeel.cmd` 垫片。
|
|
|
157
157
|
|
|
158
158
|
| 工具 | 覆盖的 CLI | 能力域 |
|
|
159
159
|
|---|---|---|
|
|
160
|
-
| `feel_status` | `flow next --json`(权威)→ 失败回退 `flow status --json` + `flow mode --json`(+`req list --json`) | **状态快照**:宏观相位、每阶段相位、模式与来源、合法下一相位、负责 Agent、审查档位、守卫、阻塞审查、`dispatch{required,
|
|
160
|
+
| `feel_status` | `flow next --json`(权威)→ 失败回退 `flow status --json` + `flow mode --json`(+`req list --json`) | **状态快照**:宏观相位、每阶段相位、模式与来源、合法下一相位、负责 Agent、审查档位、守卫、阻塞审查、`dispatch{required,total,sincePhase,open,closedRatio,missingRoles,records}`、动作型 `nextAction`。默认 **compact**(去 `mode.transitionsByMode` / `recovery.handoff` / `observability`,按需用 `feel_flow action=phases|mode` 现取);`detail: "full"` 返回完整快照(v1.5.7);`dispatch` 的 `open[]` / `closedRatio` 与 `missingRoles` 口径见 v1.6.1(`dsh/ADAPTER.md`) |
|
|
161
161
|
| `feel_next` | 同上快照的派生决策(`flow next --json` 字段直出) | **该谁做**:负责 Agent、合法下一相位、建议命令、守卫、阻塞审查、工具化 `dispatch`(goal/context/boundaries/returnFormat)、`nextAction`、`[HANDOFF: agent]` 标记 |
|
|
162
162
|
| `feel_flow` | `flow advance/current/overview/phases/mode/log/metrics/retry/repair/migrate/review_*` | 流水线推进与审查条目(`review_add` 的 `op` / `stage` 二选一,v1.3.4) |
|
|
163
163
|
| `feel_stage` | `plan stage add/list`、`stage status/set/task`、`flow stage set/reset/remove` | 阶段与 `status.md` |
|
|
164
164
|
| `feel_op` | `flow ops list`、`plan scheme create/publish/rename/remove/register`、`flow attempt/retry` | 操作方案与执行结果 |
|
|
165
|
-
| `feel_req` | `req add/list/show/board/next/claim/release/set/link/advance/split/review/verify/release-check/rollover` + **`body`(v1.6.0)** | 需求分发(
|
|
166
|
-
| `feel_dispatch` | 无 CLI(适配器直写 `.openfeel/dev/dispatch.jsonl`) | **派发台账(v1.6.0
|
|
165
|
+
| `feel_req` | `req add/list/show/board/next/claim/release/set/link/advance/split/review/verify/complete/waive/trivial/release-check/rollover` + **`body`(v1.6.0)** | 需求分发(8 状态,v1.6.1 新增 `review_pending`);`action=body` 是**正文唯一写入口**(`section/text/file/append/replace`;`text` 走临时文件,多行保真),元信息小节受保护。**适配器暂无 `action=plan` / `body --from`**:需求级计划用 CLI `openfeel req plan`,多节导入用 `openfeel req body --from`(见 `dsh/ADAPTER.md` 已知缺口) |
|
|
166
|
+
| `feel_dispatch` | 无 CLI(适配器直写 `.openfeel/dev/dispatch.jsonl`) | **派发台账(v1.6.0 / v1.6.1 闭环)**:`action=record` 写 `stage/phase/targetAgent/role/goal/files/returnFormat` → 一行 JSONL + `dispatchId`(5 分钟去重、24h / 200 行清理);**`action=finish`** 按 `dispatchId` 原地补写 `closing{status,artifacts,durationMs,summary}` + 顶层 `closedAt`(幂等);`action=list` 读最近 20 条;文件受 guard 保护 |
|
|
167
167
|
| `feel_dev` | `dev sync` / `dev status` | **开发账本(v1.6.0)**:`action=sync\|status`;写命令成功出口已自动同步,通常只需 `status` 核对 `due` |
|
|
168
168
|
| `feel_checkpoint` | `flow checkpoint list/restore` | 检查点快照与选择性回退 |
|
|
169
169
|
| `feel_archive` | `flow archive <version>/list/show`、`archive <stage>` | 版本分片归档(`allow_unfinished` 显式放行发布软门)+ 阶段摘要归档 |
|
|
170
170
|
| `feel_kb` | `knowledge list/add/search/index/dedup` | 知识库(4 个固定分类) |
|
|
171
|
-
| `feel_verify` | `flow health`、`lint i18n/kb`、`flow recover`、`project overview`、`config get/set/effective` |
|
|
171
|
+
| `feel_verify` | `flow health`、`lint i18n/kb/adherence`、`flow recover`、`project overview`、`config get/set/effective` | 健康检查与配置;**`action=adherence`(v1.6.1)** 输出遵守率四指标 `{value,definition}`(数据源 `lint adherence --json`,只读、样本不足 `null`) |
|
|
172
172
|
| `feel_review` | `view list/accept` | REV 条目视图 |
|
|
173
173
|
| `feel_plan` | `plan stage list`、`plan scheme list`、`roadmap create/show`、`instructions` | 计划与路线图 |
|
|
174
174
|
| `feel_model` | `model list/get/set` | Agent 模型意识配置 |
|
|
@@ -289,6 +289,8 @@ provider 桥接层会把「只有 description、没有 type」的节点转成 `t
|
|
|
289
289
|
3. **构建产物豁免**:`dist/**`、`build/**`、`out/**`、`target/**`、`.next/**`、`*.tsbuildinfo`;`npx vitest` / `npm run build` / `cargo build` / `tsc -b` / `git status` 等只读或产物命令不误杀。
|
|
290
290
|
4. **不可判定 → 默认告警放行 + 审计留痕**(`kind=undecidable`);要更严设 `OPENFEEL_SHELL_GATE=strict`。
|
|
291
291
|
相对路径按 `workdir ?? guard cwd` 解析;档位见下方「shell 判定档位」。
|
|
292
|
+
- **wrapper 静态分类(v1.6.1 / REQ-067)**:`pwsh|powershell -File|-f <脚本>`、`cmd /c|/k <脚本>`、`bash|sh <脚本>` 会**读脚本内容**(≤64KB,超限不做部分读取)并按同一套 `classifyShellCommand` 递归分类(深度上限 4)。编码只接受 UTF-8(含 BOM)与 UTF-16(BOM / NUL 启发式);**GBK 等双字节编码不解码**(解错会给出假安全)→ 一律 `undecidable`,默认 `warn` 并写审计(含 `wrapper` / `scriptPath`),`strict` 下拒绝;`node` 脚本不读内容 → `undecidable`。普通脚本(`readonly.ps1` / `build.ps1` / 只读 `node -e`)仍放行,不写 deny 审计。
|
|
293
|
+
- **审后文档 / 夹具白名单(v1.6.1 / REQ-062)**:`review_passed` / `test_passed` 相位放行 `docs/**`、根级 `*.md`、`test/fixtures/**`、`dsh/test/fixtures/**`(审计 `reason:'doc-asset-phase'`);`src/**`(含其中 `*.md`/`*.svg`)与 `test/core/**` / `test/commands/**` **仍拒**——夹具 ≠ 测试代码,豁免只在相位层、不扩散到源码树。
|
|
292
294
|
- **chore 写窗口(v1.5.11 收窄)**:`openfeel chore "<说明>"` **只允许人类在外部终端**开启(agent 经 shell 跑 `openfeel chore` 属写子命令 → 硬拒;`.openfeel/chore.json` 也是受保护路径)。窗口上限 **30 分钟**(`--ttl-min 1..30` 只能改短,越界 / 非整数 exit 1 且零写盘);**源码写入必须显式 `--source`**——缺省窗口只放行 doc / 静态资源,旧 `chore.json` 无 `source_allowed: true` 一律视为未授权。`openfeel chore --end` 收口;不写 `flow.json.stages`,只留 `chore_start` / `chore_end` 日志。存在活跃阶段时 chore 不生效(不绕过相位门)。
|
|
293
295
|
- **bootstrap 例外(v1.3.3)**:无 `.openfeel/` 时,全部目标为**新增文件**(`apply_patch` 须全部 `*** Add File:`)→ 放行并提示补账本;已存在文件、`.openfeel/**`、Update/Delete/Move 仍拒绝(`enforce=always` 下)。`project`/`off` 放行。
|
|
294
296
|
- `apply_patch` 解析所有 patch 头(`*** Update/Add/Delete File:`、`*** Move to:`、`---/+++`);全部目标在 `.openfeel/**` 才内部放行,混合/无头保守拒绝。
|
|
@@ -305,16 +307,16 @@ provider 桥接层会把「只有 description、没有 type」的节点转成 `t
|
|
|
305
307
|
|
|
306
308
|
```powershell
|
|
307
309
|
cd plugin
|
|
308
|
-
node test/contract.js # DSH 契约:schema 子集、无 type:null、参数契约(
|
|
309
|
-
node test/verify.js # 行为:真实 CLI + 真实 .openfeel 副本(
|
|
310
|
-
node test/guard.js # 写入门禁:fake ToolExecution + 临时工作区(
|
|
310
|
+
node test/contract.js # DSH 契约:schema 子集、无 type:null、参数契约(54 项)
|
|
311
|
+
node test/verify.js # 行为:真实 CLI + 真实 .openfeel 副本(136 项)
|
|
312
|
+
node test/guard.js # 写入门禁:fake ToolExecution + 临时工作区(191 项)
|
|
311
313
|
node test/integration.js # 真实注册表:真 cordis + 真 ToolRuntime 挂载(10 项)
|
|
312
314
|
```
|
|
313
315
|
|
|
314
316
|
- `contract.js` 用宿主 asar 提取出的**真实** `assertSupportedJsonSchema`。
|
|
315
317
|
- `verify.js` 对真实 OpenFeel 项目做只读校验,**所有写操作只打在 `os.tmpdir()` 副本上**,并断言原项目 `revision` 未被改动。
|
|
316
318
|
**前置条件**:当前项目必须至少有 1 个已注册阶段(`flow.json` 的 `stages` 非空)。版本归档(`flow archive <version>`)会把阶段从 `flow.json` 移出,归档后 `stages = 0` 时脚本会在 `[2] 只读工具 — 真实项目快照` 报「需要至少一个阶段用于适配器验证」并退出 1——这是**前置条件不满足**,不是适配器缺陷。此时先 `openfeel plan stage add <临时阶段>`(或切到有活跃阶段的工作区)再跑;CI 不执行本脚本(CI 只跑 `node --check dsh/lib/**` 与 `npm test`),不影响发布门禁。
|
|
317
|
-
- `guard.js` 覆盖 `off/project/always`、`.openfeel/**` 产物、`exec_running`、general 需求、apply_patch 混合/无头/Move 同块、受保护路径、bootstrap 文案、shell 四类判定与 `OPENFEEL_SHELL_GATE`
|
|
319
|
+
- `guard.js` 覆盖 `off/project/always`、`.openfeel/**` 产物、`exec_running`、general 需求、apply_patch 混合/无头/Move 同块、受保护路径、bootstrap 文案、shell 四类判定与 `OPENFEEL_SHELL_GATE` 三档、v1.6.1 wrapper 静态分类(`-File` / `cmd /c` / 编码混淆)与审后文档白名单等(当前 **191** 条)。
|
|
318
320
|
- `integration.js` 构造真实 Cordis 上下文 + 真实 `ToolRuntime`,调用适配器 `apply()`,断言 **15** 个工具真的完成注册与投影。
|
|
319
321
|
|
|
320
322
|
依赖提取:`contract.js` / `integration.js` 默认读 `%TEMP%\dsh-asar\dsh\node_modules\@deepseek-ai`(从宿主
|
|
@@ -369,7 +371,7 @@ dsh/ # OpenFeel 仓库内的一等适配器目录
|
|
|
369
371
|
3. **CLI 契约(v1.3.0)**:`flow next --json` 提供调度决策;`flow status --json` 的
|
|
370
372
|
`stages[]` 已含 `workflowMode` / `requirementId` / `reviewTier` / `effectiveReviewTier` /
|
|
371
373
|
`opsSummary`;`--json` 失败输出 envelope(`error.code` / `kind` / `detail`)为分类权威;
|
|
372
|
-
`flow advance --json` 仅用于失败 envelope。v1.6.
|
|
374
|
+
`flow advance --json` 仅用于失败 envelope。v1.6.1 起共 **51 个成功 `--json` 出口 / 52 个注册选项**;
|
|
373
375
|
适配器按需消费其中一部分(具体调用点见各工具实现,不再按出口总数折算)。详见 [操作指南](https://github.com/Liuary/OpenFeel/blob/master/dsh/ACTION-GUIDE.md) 与
|
|
374
376
|
[更新说明](https://github.com/Liuary/OpenFeel/blob/master/docs/dsh-cli-requirements-supplement-1.2.3.md)。
|
|
375
377
|
4. **读命令已全面结构化**:v1.2.4 补齐了 `plan stage list` / `model list|get` / `flow retry` /
|
|
@@ -1024,3 +1024,16 @@ Top-level keys in order: `meta, pipeline, stages, reviews, log` (no `requirement
|
|
|
1024
1024
|
4. **新增持久面:需求级计划** `.openfeel/plan/reqs/REQ-NNN.plan.md`(全局固定,不随阶段/版本漂移;`mkdir` 幂等);`requirements[*].plan = {path, sha256(前 12 位), recorded_at, deviations?}` 在阶段计划门通过时盖章。
|
|
1025
1025
|
5. **新增可选需求字段**:`body_waiver` / `plan_waiver`(`{at, by, reason, gate}`)与 `plan`;旧数据缺省即未 waiver / 未盖章(读侧宽容)。
|
|
1026
1026
|
6. **既有持久面零改动**:`flow.json` 的 revision / `.bak` / 锁顺序、`sessions.json` / `.preflight.json` / `guard-state.json` / `.sync.json` 的格式与写入时机均不变(`dispatch.jsonl` 是新文件,不参与 `flow.json` 事务)。
|
|
1027
|
+
|
|
1028
|
+
---
|
|
1029
|
+
|
|
1030
|
+
## v1.6.1 增量(现行契约;以上 v1.6.0 段保持冻结)
|
|
1031
|
+
|
|
1032
|
+
> 实现锚点:`dsh/lib/adapters/dispatch-ledger.js`、`dsh/lib/guard.js`、`dsh/lib/adapters/adherence.js`、`src/core/adherence.ts`、`src/core/req/plan-file.ts`。
|
|
1033
|
+
|
|
1034
|
+
1. **派发台账 schema v2(REQ-066)**:v1.6.0 十三键零改动;闭环追加**可选** `closing{status:'done'|'failed', artifacts[], durationMs, summary}`(恰 4 键固定序)与**行顶层** `closedAt`。按 `dispatchId` 原地补写(行数 / 行序 / 其余行字节不变),重复 finish 内容相同 → `changed:false`(`ts`/`closing`/`closedAt` 不二次改写);未知 id 零写盘。旧行缺 `closing` 视为未闭环。`feel_status.dispatch` = `{required,total,sincePhase,open[],closedRatio,missingRoles,records[]}`;`closedRatio` = `done` 条数 / `total`(空台账 `null`);`missingRoles` 只按 `closing.status==='done'` 判定。
|
|
1035
|
+
2. **guard 审计字段扩展(REQ-066 / REQ-067)**:写类决策可携带 `origin`(`root|subagent|delegated`,缺失 = `unknown`,参与 `main_write_ratio` 分母并标注);wrapper 不可判定行写 `kind:'undecidable'` + `detail:{wrapper, scriptPath, reason}`;wrapper 命中写 `detail.{wrapper,scriptPath,class,reason:'wrapper-write'}`。审计文件仍 `.openfeel/log/guard-audit.jsonl`(best-effort、500 字符截断口径不变)。
|
|
1036
|
+
3. **文档 / 夹具白名单相位(REQ-062)**:`DOC_WRITE_PHASES = ['review_passed','test_passed']`;放行 `docs/**`、根级 `*.md`、`test/fixtures/**`、`dsh/test/fixtures/**`(`reason:'doc-asset-phase'`),`src/**` / `test/core/**` 仍拒。判定在相位层,不改 `CODE_DIRECTORIES` / `isCodeDirectoryPath` / `isExemptPath`,受保护路径集合**零新增**。
|
|
1037
|
+
4. **需求级计划文件(REQ-064)**:`req plan` 生成 `.openfeel/plan/reqs/REQ-NNN.plan.md`(四节 + 变更记录,固定路径不随版本漂移);`lint fill --fix-plan` 只为缺失计划生成骨架(不覆盖、不编内容,仍 advisory exit 0)。`requirements[*].plan` 的 `{path,sha256,recorded_at,deviations?}` 盖章语义不变。
|
|
1038
|
+
5. **遵守率只读观测(REQ-066 A66.3)**:数据源为 `.openfeel/log/guard-audit.jsonl`(全量)、`.openfeel/dev/dispatch.jsonl`(24h / 200 行)、`.openfeel/dev/.sync.json` 与当前 `flow.json`;`lint adherence --json` / `feel_verify action=adherence` **只读、恒 exit 0**,样本不足 `value:null`(0/0 不是 0),**不写任何文件**。
|
|
1039
|
+
6. **既有持久面零改动**:`flow.json` 事务 / `.bak` / 锁顺序、`sessions.json` / `.preflight.json` / `guard-state.json` / `.sync.json` 格式与写入时机均不变;`release` 脚本是外部执行通道,不在 agent 写入门禁内。
|
|
@@ -1583,3 +1583,15 @@ Errors surface as `错误:{msg}` (`common.errorTmpl`) → exit 1; `isFlowConcu
|
|
|
1583
1583
|
3. **为何不给阶段表加 `general_transitions`**:阶段级 `general` 在写入面即被拒(`src/commands/stage.ts` / `src/commands/plan.ts` 的 `general_mode_conflict`),表没有消费者——加了是死代码。`flow advance --force` 对阶段级 general 的既有行为不变(仍可强制移动,属既有边界,非本版新增)。
|
|
1584
1584
|
4. **门不进 done / 归档判据**:`describeStageDoneGate`、`requirementDoneBlocker`(review + verify)、`flow archive` 判据**一字不改**;正文门与计划门是不参与这三处的独立前置检查(存量债因此可经 `--force` 留痕到达归档)。
|
|
1585
1585
|
5. **`PipelineConfigSchema.parse` 失败仍是硬错**(`flow-manager.ts:5087-5113` 现状)。
|
|
1586
|
+
|
|
1587
|
+
---
|
|
1588
|
+
|
|
1589
|
+
## v1.6.1 增量(现行契约;以上 v1.6.0 段保持冻结)
|
|
1590
|
+
|
|
1591
|
+
> 实现锚点:`src/core/req/types.ts`、`src/commands/flow.ts`、`src/commands/lint.ts`、`src/core/errors.ts`、`docs/json-contract.md`。
|
|
1592
|
+
|
|
1593
|
+
1. **阶段级转移表继续一字不改**:v1.6.1 的 `review_pending` 是**需求状态**(`REQ_STATUSES`),不是阶段相位;阶段相位表(full / fast)与 `general → {}` 均不变,`flow phases --mode general` 仍为空表。
|
|
1594
|
+
2. **统一 GateOverride 落日志**:`flow advance --force` / `flow stage reset --force` 的 `detail` 上**平铺** `{gate_overrides,gate_missing?,by,reason,from,to,at}`(含 `from`/`to`),是 `--force` 唯一留痕 schema;需求侧(`requirement_status`)装在 `detail.gate_override` 下,同一键集。不新增转移表分支、不新增隐式放行路径。
|
|
1595
|
+
3. **错误码通道扩到 20 行**:新增 `REQ_BODY_GATE` / `REQ_PLAN_GATE` / `REQ_PLAN_DEVIATION` / `REQ_REVIEW_REQUIRED` / `REQ_VERIFY_REQUIRED`(**无 `REQ_REVIEW_GATE`**);`req claim/advance/complete --json` 失败输出 envelope(`error.code` 为稳定码),与 `flow` 侧 envelope 同一套 `code → kind → exitCode`。
|
|
1596
|
+
4. **JSON 契约计数 51 / 52**:新增出口 #47 `req claim` / #48 `req advance` / #49 `req complete` / #50 `req plan` / #51 `lint adherence`;`npm run release` 的 `--json` 是独立脚本输出(`scripts/release.mjs`),**不登记、不计数**。`lint fill` / `lint adherence` **恒 exit 0**(advisory / 只读),不参与门禁退出码。
|
|
1597
|
+
5. **既有门语义零改动**:done 门、blocking REV 门、阶段验证门、归档判据与 `--force` 不绕过的边界均不变;新增的 `--force` 只多做**审计**(不是放行面扩大)。
|
package/dsh/docs/compat/req.md
CHANGED
|
@@ -1255,3 +1255,18 @@ split(data, parentId, children):
|
|
|
1255
1255
|
5. **偏差门(REQ-056)**:`→done` 前比对 `requirements[*].plan.sha256`(执行前盖章的前 12 位)与当前计划文件;不一致且 `## 偏差与回写` 未写实 ⇒ `plan_deviation`(`REQ_PLAN_DEVIATION`);`plan.recorded_at` 缺失的历史需求放行 + `console.warn` + 独立审计 `requirement_plan_unstamped`(不阻塞)。顺序:正文门 → 计划门 → done 门(review + verify)→ 偏差门;缺 review/verify 仍先得 `invalid_status`。
|
|
1256
1256
|
6. **错误码通道**:`RequirementErrorCode` 由 7 值扩到 10 值(+`body_empty` / `plan_missing` / `plan_deviation`)。`req claim/advance/complete` **均无 `--json`**;三码只由 `advance` / `complete` 触发,目前以 i18n 文案 + exit 1 呈现(`REQ_*` envelope 码尚未进入 `src/core/errors.ts`)。
|
|
1257
1257
|
7. **既有行为零改动**:`requirementDoneBlocker`(done 门的 review + verify 两条判据)、`req claim --json` 的 unknown-option 行为、7 状态值域与 `general` 阶段级拒绝均不变。
|
|
1258
|
+
|
|
1259
|
+
---
|
|
1260
|
+
|
|
1261
|
+
## v1.6.1 增量(现行契约;以上 v1.6.0 段保持冻结)
|
|
1262
|
+
|
|
1263
|
+
> 实现锚点:`src/core/req/types.ts`、`src/core/req/requirement-ops.ts`、`src/core/req/plan-file.ts`、`src/commands/req.ts`、`src/core/errors.ts`。
|
|
1264
|
+
|
|
1265
|
+
1. **`review_pending` 状态(REQ-063 A63.1)**:`REQ_STATUSES` 在 `in_progress` 与 `done` 之间插入 `review_pending`(现 8 值);`ALLOWED_TRANSITIONS`:`in_progress: ['review_pending','blocked','cancelled','rejected']`,`review_pending: ['done','in_progress','blocked','cancelled','rejected']`。**旧 `in_progress → done` 直连移除**(exit 1,文案含 `review_pending`);`--force` 跳链留痕 `detail.gate_override.gate_overrides=['req_review']`(复用统一 `buildGateOverrideAudit`,含 `from`/`to`/`by`/`reason`/`at`)。`req board` / `dashboard` 的 `groups` 键序随值域只增一档(旧 7 键一个不删)。
|
|
1266
|
+
2. **done 门码化(REQ-063 A63.2/A63.3)**:`requirementDoneBlocker` 三值语义与判定顺序**不变**;命令层把 `review` / `verification` 分别映射为稳定码 `REQ_REVIEW_REQUIRED` / `REQ_VERIFY_REQUIRED`(`stage_phase` 仍 `invalid_status`),并进入 `src/core/errors.ts` 与 error-envelope 契约表。**无 `REQ_REVIEW_GATE`**。`REQ_BODY_GATE` / `REQ_PLAN_GATE` / `REQ_PLAN_DEVIATION` 同批进表(错误码表共 20 行)。
|
|
1267
|
+
3. **`--json` 出口(REQ-063 A63.3)**:`req claim`(#47)/ `req advance`(#48)/ `req complete`(#49)成功 5 键固定序 `schemaVersion,id,from,to,status`,`gates` 为末位条件键(仅 `--force` 实际放行过门时出现,取值闭集 `req_review|req_body|req_plan`);失败走 envelope(稳定码)。stdout 恰一个 JSON 文档、stderr 零输出。
|
|
1268
|
+
4. **`req plan`(REQ-064 A64.1,出口 #50)**:`req plan <id> [--force] [--json]` 写固定路径 `.openfeel/plan/reqs/REQ-NNN.plan.md`;四节 `## 目标` / `## 任务拆解` / `## 验收判据` / `## 偏差与回写` + `## 变更记录`;写实判据复用 `isRequirementPlanFilled`(禁第二份规则)。已存在默认拒绝且**字节不变**(legacy `plan_exists`),`--force` 覆盖并在 `--json` 末位追加 `replaced:true`(新建 6 键 / 覆盖 7 键)。
|
|
1269
|
+
5. **`req body --from`(REQ-064 A64.2)**:按 `##` 一次导入多节,一次调用写多小节(`sections[{name,created,lines}]`);元信息小节(`状态` / `预估版本` / `父需求` / `关联阶段` / `变更记录`)与空正文小节**跳过并在 stderr 报告**;`--from` 恒整节替换、与 `--section/--text/--file/--append/--replace` 互斥;每个实际写入小节各追加 1 条 `## 变更记录`。
|
|
1270
|
+
6. **`--text` 多行保真(REQ-064 A64.4)**:只拒绝全空白、**不做首尾裁剪**;空行、`###` 子标题、列表行、`---` 与 CRLF 原样落盘;`lines` 与 `body.split(/\r?\n/).length` 同源。适配器 `feel_req action=body text=` 改走 `os.tmpdir()` 临时文件 + `--file`(argv 零 `--text`,`finally` 清理)。
|
|
1271
|
+
7. **`lint fill --fix-plan`(REQ-064 A64.3)**:只为 `missingPlan`(计划文件不存在)生成骨架,已有计划(含空壳)进 `skipped[{id,reason:'exists'}]` 且字节不变;`--json` 末位追加 `created[]` / `skipped[]`;**仍恒 exit 0**(advisory 不变)。
|
|
1272
|
+
8. **既有行为零改动**:`req claim` 仍只写身份字段、不校验正文;7 状态既有键序与 `general` 阶段级拒绝不变;`req add` / `body` / `lint` 既有用例零失败。
|
package/dsh/docs/compat/stage.md
CHANGED
|
@@ -1448,3 +1448,15 @@ const SchemaSchema = z.object({
|
|
|
1448
1448
|
4. **账本陈旧门(REQ-059)**:`advanceStagePhase` 入口**先**跑 `maybeSyncDevStatus()`,再在 done 门之前判 `targetPhase === 'done' && fromPhase !== 'done'` 且 `getDevStatus().due === true` ⇒ `DEV_SYNC_STALE` / refusal / exit 1,零写盘;同一 `allowGateOverride` 放行并在 `gate_overrides` 追加 `'dev_sync'`。正常路径同步成功即 `due=false`,不会触发(构造法单测见 `test/core/dev-status.test.ts`)。
|
|
1449
1449
|
5. **盖章(REQ-056)**:计划门**通过时**对每个在办需求写 `requirements[*].plan = {path, sha256(前 12 位), recorded_at}`(已有 `deviations` 保留);拒绝路径零写盘。
|
|
1450
1450
|
6. **既有行为零改动**:`describeStageDoneGate`(`archiving → done` 的 verification + 关联需求全 done)、`status.md` 投影、`reset_stage_phase` / `advance_stage_phase` 既有字段、`--force` 跳过非法 phase 的既有语义均不变。
|
|
1451
|
+
|
|
1452
|
+
---
|
|
1453
|
+
|
|
1454
|
+
## v1.6.1 增量(现行契约;以上 v1.6.0 段保持冻结)
|
|
1455
|
+
|
|
1456
|
+
> 实现锚点:`src/core/flow/gate-override.ts`、`src/core/flow-manager.ts`(`advanceStagePhase` / `resetStagePhase`)、`src/commands/flow.ts`。
|
|
1457
|
+
|
|
1458
|
+
1. **统一 `GateOverride` 审计(REQ-062 A62.2)**:`flow advance --force`、`flow stage reset --force` 与各门 `allowGateOverride` 收敛为**同一份** helper `buildGateOverrideAudit({gates,missing,by,reason,from,to})` → `{gate_overrides, gate_missing?, by, reason, from, to, at}`,并**平铺写入 `appendLog.detail`**(flow 侧不嵌套;需求侧 `requirement_status` 条目才装在 `detail.gate_override` 下)。`from`/`to` **必填**;`gate_overrides` 取值闭集 `plan|dev_sync|req_review|req_body|req_plan`。
|
|
1459
|
+
2. **`reset --force` 也有审计(REQ-062 A62.3)**:`flow stage reset --to <后置相> --force` 的 `flow.json.log` 末条必含 `gate_override`(非空 `gate_overrides` + `from`/`to` + `by`/`reason`/`at`);无 `--force` 时同命令被拒且**零伪造审计**。单点 `grep -rn "gate_missing" src/` 只命中 helper 与写入口。
|
|
1460
|
+
3. **`--reason` 成为留痕原因**:`flow advance` / `flow stage reset` 的 `--reason <text>` 在 `--force` 放行时写入 `detail.reason`(缺省 `manual`);`advance` 的 `review_passed → exec_running` 仍写既有 `rework_reason`,两者互不覆盖。
|
|
1461
|
+
4. **`--force` 语义边界不变(REQ-062 A62.4)**:仍只跳过非法 phase / 阶段跳跃检查;blocking open REV 门、done 门(阶段 verify + 关联需求全 done)、版本归档判据**不可 force 绕过**;`GateOverride` 类型与 `buildGateOverrideAudit()` 由 `src/core/flow/gate-override.ts` 导出,既有 done 门三态用例零改动。
|
|
1462
|
+
5. **既有行为零改动**:阶段转移表(full / fast / general)、`describeStagePlanGate` / `describeStageDoneGate`、`status.md` 投影与 checkpoint 写点均不变;进入 `exec_running` 的计划门(v1.6.0)同口径。
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 派发台账(v1.6.0 / REQ-057)— DSH 适配器侧
|
|
2
|
+
* 派发台账(v1.6.0 / REQ-057;v1.6.1 / REQ-066 增闭环 closing)— DSH 适配器侧
|
|
3
3
|
*
|
|
4
4
|
* 文件:`<project>/.openfeel/dev/dispatch.jsonl`(UTF-8 / LF,一行一条 JSON)。
|
|
5
5
|
* 行 schema(plan §5.4):
|
|
6
6
|
* { dispatchId, ts, leadSessionId, origin, stage, phase,
|
|
7
7
|
* targetAgent, role, taskId, goal, files[], returnFormat, dispatchDepth }
|
|
8
|
+
* 可选闭环字段(v1.6.1 / REQ-066 A66.1,由 `closeDispatch` 原地补写):
|
|
9
|
+
* closing: { status: 'done'|'failed', artifacts: string[], durationMs: number, summary: string }
|
|
10
|
+
* closedAt: ISO 时间(**行的顶层字段**——A66.1 要求 closing 恰 4 键,时间戳不进 closing)
|
|
8
11
|
*
|
|
9
|
-
*
|
|
10
|
-
* `feel_status.dispatch` 汇总(提示级,不做硬拦——用户裁定 ②)。
|
|
12
|
+
* 职责:把「派给谁、派什么、允许写哪些文件」变成可审计的记录,并在完成后补上
|
|
13
|
+
* 产物/耗时/失败原因,供 `feel_status.dispatch` 汇总(提示级,不做硬拦——用户裁定 ②)。
|
|
11
14
|
*
|
|
12
15
|
* 纪律:
|
|
13
16
|
* - 只有适配器进程直接 fs 写;该文件在 `PROTECTED_OPENFEEL_PATHS` 里,
|
|
@@ -72,6 +75,31 @@ function asStringArray(value) {
|
|
|
72
75
|
.filter((entry) => entry !== '');
|
|
73
76
|
}
|
|
74
77
|
|
|
78
|
+
/**
|
|
79
|
+
* 归一化闭环段(v1.6.1 / REQ-066 A66.1)。
|
|
80
|
+
*
|
|
81
|
+
* 输出**恰 4 键**且键序固定:`status` / `artifacts` / `durationMs` / `summary`
|
|
82
|
+
* (`closedAt` 落行的顶层,见文件头注释——A66.1 不允许第 5 键混进 closing)。
|
|
83
|
+
* 非法输入(非对象 / status 不在闭集)→ `undefined`(读侧丢弃;写侧由调用方报错)。
|
|
84
|
+
*
|
|
85
|
+
* @param {unknown} raw
|
|
86
|
+
* @returns {{ status: 'done'|'failed', artifacts: string[], durationMs: number, summary: string } | undefined}
|
|
87
|
+
*/
|
|
88
|
+
function normalizeClosing(raw) {
|
|
89
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return undefined;
|
|
90
|
+
const status = raw.status === 'done' ? 'done' : raw.status === 'failed' ? 'failed' : '';
|
|
91
|
+
if (status === '') return undefined;
|
|
92
|
+
const durationMs = typeof raw.durationMs === 'number' && Number.isFinite(raw.durationMs) && raw.durationMs >= 0
|
|
93
|
+
? Math.round(raw.durationMs)
|
|
94
|
+
: 0;
|
|
95
|
+
return {
|
|
96
|
+
status,
|
|
97
|
+
artifacts: asStringArray(raw.artifacts),
|
|
98
|
+
durationMs,
|
|
99
|
+
summary: asString(raw.summary),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
75
103
|
/**
|
|
76
104
|
* 归一化一条台账记录(字段齐全、类型稳定)。
|
|
77
105
|
* @param {Record<string, unknown>} raw
|
|
@@ -79,6 +107,8 @@ function asStringArray(value) {
|
|
|
79
107
|
*/
|
|
80
108
|
function normalizeRecord(raw) {
|
|
81
109
|
const depth = Number.isInteger(raw?.dispatchDepth) && raw.dispatchDepth >= 0 ? raw.dispatchDepth : 1;
|
|
110
|
+
const closing = normalizeClosing(raw?.closing);
|
|
111
|
+
const closedAt = asString(raw?.closedAt);
|
|
82
112
|
return {
|
|
83
113
|
dispatchId: asString(raw?.dispatchId),
|
|
84
114
|
ts: asString(raw?.ts),
|
|
@@ -93,6 +123,9 @@ function normalizeRecord(raw) {
|
|
|
93
123
|
files: asStringArray(raw?.files),
|
|
94
124
|
returnFormat: asString(raw?.returnFormat) || DEFAULT_RETURN_FORMAT,
|
|
95
125
|
dispatchDepth: depth,
|
|
126
|
+
// 可选闭环字段只增不改:未闭环的行不写这两个键(存量行字节不变)
|
|
127
|
+
...(closing !== undefined ? { closing } : {}),
|
|
128
|
+
...(closedAt !== '' ? { closedAt } : {}),
|
|
96
129
|
};
|
|
97
130
|
}
|
|
98
131
|
|
|
@@ -220,6 +253,99 @@ export function appendDispatch(projectPath, record = {}, options = {}) {
|
|
|
220
253
|
return { dispatchId: incoming.dispatchId, path, duplicate: false };
|
|
221
254
|
}
|
|
222
255
|
|
|
256
|
+
/**
|
|
257
|
+
* 读台账的**原始行**(不归一化;用于 `closeDispatch` 的原地补写,保证未命中行字节不变)。
|
|
258
|
+
* @param {string} projectPath
|
|
259
|
+
* @returns {string[]}
|
|
260
|
+
*/
|
|
261
|
+
function readRawLedgerLines(projectPath) {
|
|
262
|
+
let text;
|
|
263
|
+
try {
|
|
264
|
+
text = readFileSync(dispatchLedgerPath(projectPath), 'utf-8');
|
|
265
|
+
} catch {
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
return text.split(/\r?\n/).filter((line) => line.trim() !== '');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* 关闭一条派发(v1.6.1 / REQ-066 A66.1):按 `dispatchId` **原地补写** `closing` + 顶层 `closedAt`。
|
|
273
|
+
*
|
|
274
|
+
* 契约:
|
|
275
|
+
* - **行数 / 行序不变**,未命中的行字节不变(只对目标行 JSON.parse → 补键 → stringify);
|
|
276
|
+
* - **幂等**:同 id 重复 finish 且 `status` / `artifacts` / `summary` 相同 → `changed:false`,
|
|
277
|
+
* `ts` / `closing` / `closedAt` 都不二次改写(`durationMs` 未显式给出时沿用既有值,
|
|
278
|
+
* 避免「重复调用 = 耗时变大」);
|
|
279
|
+
* - `durationMs` 缺省 = `now - Date.parse(ts)`(非负整数;ts 不可解析 → 0);
|
|
280
|
+
* - 未知 id → `{ ok:false, code:'not_found' }` 且**零写盘**;status 非法 → `invalid_closing`。
|
|
281
|
+
*
|
|
282
|
+
* @param {string} projectPath
|
|
283
|
+
* @param {string} dispatchId
|
|
284
|
+
* @param {{ status?: 'done'|'failed', artifacts?: string[], durationMs?: number, summary?: string }} closing
|
|
285
|
+
* @param {{ now?: number }} [options] `now` 注入便于单测(缺省 `Date.now()`)
|
|
286
|
+
* @returns {{ ok: true, dispatchId: string, closedAt: string, changed: boolean, path: string }
|
|
287
|
+
* | { ok: false, code: 'not_found'|'invalid_closing', path: string }}
|
|
288
|
+
*/
|
|
289
|
+
export function closeDispatch(projectPath, dispatchId, closing = {}, options = {}) {
|
|
290
|
+
const file = dispatchLedgerPath(projectPath);
|
|
291
|
+
const id = asString(dispatchId).trim();
|
|
292
|
+
if (id === '') return { ok: false, code: 'not_found', path: file };
|
|
293
|
+
|
|
294
|
+
const now = Number.isFinite(options.now) ? /** @type {number} */ (options.now) : Date.now();
|
|
295
|
+
const lines = readRawLedgerLines(projectPath);
|
|
296
|
+
/** @type {Array<Record<string, any> | null>} */
|
|
297
|
+
const parsed = [];
|
|
298
|
+
let targetIndex = -1;
|
|
299
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
300
|
+
let value = null;
|
|
301
|
+
try {
|
|
302
|
+
const candidate = JSON.parse(lines[index]);
|
|
303
|
+
if (candidate !== null && typeof candidate === 'object' && !Array.isArray(candidate)) value = candidate;
|
|
304
|
+
} catch {
|
|
305
|
+
// 损坏行保持原样:不因一行坏掉改写整份台账
|
|
306
|
+
}
|
|
307
|
+
parsed.push(value);
|
|
308
|
+
if (targetIndex === -1 && value !== null && value.dispatchId === id) targetIndex = index;
|
|
309
|
+
}
|
|
310
|
+
if (targetIndex === -1) return { ok: false, code: 'not_found', path: file };
|
|
311
|
+
|
|
312
|
+
const target = /** @type {Record<string, any>} */ (parsed[targetIndex]);
|
|
313
|
+
const existing = normalizeClosing(target.closing);
|
|
314
|
+
const existingClosedAt = asString(target.closedAt);
|
|
315
|
+
const explicitDuration = typeof closing.durationMs === 'number'
|
|
316
|
+
&& Number.isFinite(closing.durationMs)
|
|
317
|
+
&& closing.durationMs >= 0;
|
|
318
|
+
const tsMs = Date.parse(asString(target.ts));
|
|
319
|
+
// 幂等关键:未显式给 durationMs 时优先沿用既有值(否则重复调用会因 now 变化而「改写」)。
|
|
320
|
+
const durationMs = explicitDuration
|
|
321
|
+
? Math.round(/** @type {number} */ (closing.durationMs))
|
|
322
|
+
: existing !== undefined
|
|
323
|
+
? existing.durationMs
|
|
324
|
+
: Number.isFinite(tsMs)
|
|
325
|
+
? Math.max(0, Math.round(now - tsMs))
|
|
326
|
+
: 0;
|
|
327
|
+
const next = normalizeClosing({ ...closing, durationMs });
|
|
328
|
+
if (next === undefined) return { ok: false, code: 'invalid_closing', path: file };
|
|
329
|
+
|
|
330
|
+
const sameClosing = existing !== undefined && JSON.stringify(existing) === JSON.stringify(next);
|
|
331
|
+
if (sameClosing && existingClosedAt !== '') {
|
|
332
|
+
return { ok: true, dispatchId: id, closedAt: existingClosedAt, changed: false, path: file };
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const closedAt = sameClosing && existingClosedAt !== '' ? existingClosedAt : new Date(now).toISOString();
|
|
336
|
+
target.closing = next;
|
|
337
|
+
target.closedAt = closedAt;
|
|
338
|
+
|
|
339
|
+
const body = parsed
|
|
340
|
+
.map((value, index) => (value === null ? lines[index] : JSON.stringify(value)))
|
|
341
|
+
.join('\n');
|
|
342
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
343
|
+
const tmp = `${file}.${process.pid}.${randomBytes(6).toString('hex')}.tmp`;
|
|
344
|
+
writeFileSync(tmp, body === '' ? '' : `${body}\n`, 'utf-8');
|
|
345
|
+
renameSync(tmp, file);
|
|
346
|
+
return { ok: true, dispatchId: id, closedAt, changed: true, path: file };
|
|
347
|
+
}
|
|
348
|
+
|
|
223
349
|
/**
|
|
224
350
|
* 清理超龄 / 超上限记录(无变化时不重写文件)。
|
|
225
351
|
* @param {string} projectPath
|
|
@@ -244,6 +370,10 @@ export const DISPATCH_STATUS_RECENT = 5;
|
|
|
244
370
|
|
|
245
371
|
/**
|
|
246
372
|
* 台账里一条记录的摘要(`feel_status.dispatch.records` 的元素)。
|
|
373
|
+
*
|
|
374
|
+
* v1.6.1 / REQ-066 A66.2:透出 `closing`(无闭环 → null)与顶层 `closedAt`,
|
|
375
|
+
* 让「这条派发到底完成没有」在状态快照里可直接读。
|
|
376
|
+
*
|
|
247
377
|
* @param {Record<string, any>} record 已归一化的台账行
|
|
248
378
|
* @returns {Record<string, any>}
|
|
249
379
|
*/
|
|
@@ -257,22 +387,27 @@ function summarizeDispatch(record) {
|
|
|
257
387
|
role: record.role,
|
|
258
388
|
taskId: record.taskId,
|
|
259
389
|
goal: record.goal,
|
|
390
|
+
closing: record.closing ?? null,
|
|
391
|
+
closedAt: record.closedAt ?? null,
|
|
260
392
|
};
|
|
261
393
|
}
|
|
262
394
|
|
|
263
395
|
/**
|
|
264
|
-
* 派发汇总(`feel_status.dispatch`
|
|
396
|
+
* 派发汇总(`feel_status.dispatch` 的数据源;v1.6.1 / REQ-066 A66.2 增 `open[]` / `closedRatio`)。
|
|
265
397
|
*
|
|
266
398
|
* - `required`:恒 `true`——**提示级**(用户裁定 ②:只做台账 + 强提示,不做硬拦);
|
|
267
399
|
* - `total`:台账总行数;
|
|
268
400
|
* - `sincePhase`:当前 `stage` + `phase` 范围内的派发条数;
|
|
269
|
-
* - `
|
|
270
|
-
*
|
|
271
|
-
* - `
|
|
401
|
+
* - `open[]`:当前 `stage` 范围内**未闭环**的派发(无 `closing` 或 `closing.status!=='done'`;
|
|
402
|
+
* 跨相位保留——早期相位没做完的派发不该因相位推进而「消失」);
|
|
403
|
+
* - `closedRatio`:全台账 `closing.status==='done'` 条数 / `total`(`total===0` → `null`,不出现 NaN);
|
|
404
|
+
* - `missingRoles`:当前 `stage` + `phase` 范围内**没有 `closing.status==='done'` 记录**的角色
|
|
405
|
+
* (五个闭集角色,固定顺序;v1.6.0 的「有 record 即算」口径已作废——A66.2);
|
|
406
|
+
* - `records`:最近 `DISPATCH_STATUS_RECENT` 条派发摘要(含 `closing` / `closedAt`)。
|
|
272
407
|
*
|
|
273
408
|
* @param {string} projectPath
|
|
274
409
|
* @param {{ stage?: string, phase?: string }} [options]
|
|
275
|
-
* @returns {{ required: true, total: number, sincePhase: number, missingRoles: string[], records: Array<Record<string, any>> }}
|
|
410
|
+
* @returns {{ required: true, total: number, sincePhase: number, open: Array<Record<string, any>>, closedRatio: number | null, missingRoles: string[], records: Array<Record<string, any>> }}
|
|
276
411
|
*/
|
|
277
412
|
export function dispatchSummary(projectPath, options = {}) {
|
|
278
413
|
const records = readAllDispatches(projectPath);
|
|
@@ -281,13 +416,17 @@ export function dispatchSummary(projectPath, options = {}) {
|
|
|
281
416
|
|
|
282
417
|
const stageScoped = stage === '' ? records : records.filter((record) => record.stage === stage);
|
|
283
418
|
const phaseScoped = phase === '' ? stageScoped : stageScoped.filter((record) => record.phase === phase);
|
|
284
|
-
const
|
|
419
|
+
const isClosedDone = (record) => record.closing !== undefined && record.closing !== null && record.closing.status === 'done';
|
|
420
|
+
const doneRoles = new Set(phaseScoped.filter(isClosedDone).map((record) => record.role));
|
|
421
|
+
const doneCount = records.filter(isClosedDone).length;
|
|
285
422
|
|
|
286
423
|
return {
|
|
287
424
|
required: true,
|
|
288
425
|
total: records.length,
|
|
289
426
|
sincePhase: phaseScoped.length,
|
|
290
|
-
|
|
427
|
+
open: stageScoped.filter((record) => !isClosedDone(record)).map(summarizeDispatch),
|
|
428
|
+
closedRatio: records.length === 0 ? null : doneCount / records.length,
|
|
429
|
+
missingRoles: DISPATCH_ROLES.filter((role) => !doneRoles.has(role)),
|
|
291
430
|
records: records.slice(-DISPATCH_STATUS_RECENT).map(summarizeDispatch),
|
|
292
431
|
};
|
|
293
432
|
}
|