openfeel 1.5.25 → 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 +14 -0
- package/README.zh-CN.md +14 -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 +126 -25
- package/dist/commands/flow.js.map +1 -1
- package/dist/commands/lint.d.ts +5 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +373 -0
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/req.d.ts.map +1 -1
- package/dist/commands/req.js +814 -88
- package/dist/commands/req.js.map +1 -1
- package/dist/commands/stage.d.ts.map +1 -1
- package/dist/commands/stage.js +19 -0
- package/dist/commands/stage.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/dev-status.d.ts +25 -0
- package/dist/core/dev-status.d.ts.map +1 -1
- package/dist/core/dev-status.js +35 -0
- package/dist/core/dev-status.js.map +1 -1
- package/dist/core/errors.d.ts +38 -3
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +22 -3
- 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 +118 -3
- package/dist/core/flow-manager.d.ts.map +1 -1
- package/dist/core/flow-manager.js +357 -14
- 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 +96 -5
- 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 +96 -5
- package/dist/core/i18n-data/zh-CN.js.map +1 -1
- package/dist/core/lint-req.d.ts +17 -1
- package/dist/core/lint-req.d.ts.map +1 -1
- package/dist/core/lint-req.js +14 -2
- package/dist/core/lint-req.js.map +1 -1
- package/dist/core/plan/body-lint.d.ts +58 -0
- package/dist/core/plan/body-lint.d.ts.map +1 -0
- package/dist/core/plan/body-lint.js +197 -0
- package/dist/core/plan/body-lint.js.map +1 -0
- package/dist/core/plan/filled.d.ts +143 -0
- package/dist/core/plan/filled.d.ts.map +1 -0
- package/dist/core/plan/filled.js +244 -0
- package/dist/core/plan/filled.js.map +1 -0
- package/dist/core/plan/path.d.ts +24 -0
- package/dist/core/plan/path.d.ts.map +1 -1
- package/dist/core/plan/path.js +56 -0
- package/dist/core/plan/path.js.map +1 -1
- package/dist/core/req/aggregate.d.ts.map +1 -1
- package/dist/core/req/aggregate.js +5 -0
- package/dist/core/req/aggregate.js.map +1 -1
- package/dist/core/req/body-file.d.ts +103 -0
- package/dist/core/req/body-file.d.ts.map +1 -1
- package/dist/core/req/body-file.js +221 -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 +151 -15
- package/dist/core/req/requirement-ops.d.ts.map +1 -1
- package/dist/core/req/requirement-ops.js +402 -22
- package/dist/core/req/requirement-ops.js.map +1 -1
- package/dist/core/req/types.d.ts +63 -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 +87 -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 +50 -8
- package/dsh/ADAPTER.md +119 -13
- package/dsh/README.md +49 -26
- package/dsh/docs/compat/persistence.md +26 -0
- package/dsh/docs/compat/pipeline.md +24 -0
- package/dsh/docs/compat/req.md +29 -0
- package/dsh/docs/compat/stage.md +25 -0
- package/dsh/lib/adapters/dispatch-ledger.js +432 -0
- package/dsh/lib/adapters/dispatch.js +54 -6
- package/dsh/lib/adapters/next-action.js +336 -0
- package/dsh/lib/guard.js +694 -24
- package/dsh/lib/index.js +37 -0
- package/dsh/lib/surface/prompt.js +66 -178
- package/dsh/lib/tools/index.js +527 -12
- package/dsh/package.json +2 -2
- package/package.json +2 -1
package/dsh/ACTION-GUIDE.md
CHANGED
|
@@ -5,8 +5,50 @@
|
|
|
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
|
-
>
|
|
9
|
-
|
|
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
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 0. v1.6.1 硬规则(现行,优先于下文存档)
|
|
13
|
+
|
|
14
|
+
### 0.1 主会话只调度 —— 必须派发子 Agent
|
|
15
|
+
|
|
16
|
+
- 写文件 / 改代码 / 跑测试**一律交给子 agent**(DSH 的 `subagent` / `workflow`);主会话只做「判断该谁做 → 派发 → 记账 → 裁决」。
|
|
17
|
+
- **主会话直接改仓库即违规**:派发台账里没有记录,等于没派发。`feel_status.dispatch` 给出 `{required, records, missingRoles}`,`required` 恒 `true`(提示级,不做硬拦)。
|
|
18
|
+
- 每次派发先调 `feel_dispatch` 记账(写 `.openfeel/dev/dispatch.jsonl`,受 guard 保护):
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
feel_dispatch stage=v1.7.0-stage-133 phase=exec_running
|
|
22
|
+
targetAgent=openfeel-executor role=executor
|
|
23
|
+
goal="E13 文档对账:docs/json-contract.md 计数改 51/52,并通过 npm run build"
|
|
24
|
+
files=["docs/json-contract.md","CHANGELOG.md"]
|
|
25
|
+
returnFormat="≤10 行:结论/改动文件/验证/阻塞"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- 子 agent 只读派发 prompt 与其中指定的文件;**禁读** `flow.json` / `status.md` / `dev_last*` / `dev/current.md`;返回 ≤10 行。
|
|
29
|
+
- **适用模式**:以上是 **Feel Mode(流程模式)** 的硬规则;**Free Mode**(`feel_mode=disabled`)下流程与检查点可选(写入门禁仍生效),派发台账 / 正文写入口 / 需求级计划仍可用,只是不强制。
|
|
30
|
+
|
|
31
|
+
### 0.2 需求正文必须写实(`req body` / `feel_req action=body`)
|
|
32
|
+
|
|
33
|
+
- 正文**唯一写入口**是 `openfeel req body <id> --section <摘要|目标与验收> (--text <md> | --file <path>) [--json]`;适配器通道为 `feel_req action=body`。
|
|
34
|
+
- 空壳(两节不足 40 字 / 只有占位行)在状态流转 `→scheduled|in_progress|done` 时被 `REQ_BODY_GATE` 拦住(exit 1,零写盘);`--force`(`advance` / `complete`)写 `body_waiver` + 审计后放行。**认领(`claim`)不校验正文**,`add --claim` 可一次原子成功。
|
|
35
|
+
- 元信息(状态 / 负责人 / 版本)**不走** `body`,用 `req add|set|claim`。
|
|
36
|
+
|
|
37
|
+
### 0.3 执行前必须有需求级计划,全模式强制 plan → exec → review
|
|
38
|
+
|
|
39
|
+
- 进入 `exec_running` 前:阶段 `plan.md` 与每个在办需求的 `.openfeel/plan/reqs/REQ-NNN.plan.md` 必须**存在且写实**(`STAGE_PLAN_GATE`)。
|
|
40
|
+
- `general` 需求 / 零关联阶段的 `fast`·`full` 需求:`→in_progress` 前必须有写实计划(`REQ_PLAN_GATE`);`→done` 前计划被改动须写实 `## 偏差与回写`(`REQ_PLAN_DEVIATION`)。
|
|
41
|
+
- `general` 的**阶段级**转移表仍为空(阶段级 general 在写入面即被拒);强制链落在**需求生命周期**——三种模式都要求「计划 → 执行 → 审查」,区别只在阶段级是否裁剪 scheme/test。
|
|
42
|
+
- `--force` 只做**留痕放行**(`gate_overrides` / waiver + 审计),**不能**绕过 done 门(review + verify)、blocking REV 门与版本归档判据。
|
|
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 行。
|
|
10
52
|
|
|
11
53
|
---
|
|
12
54
|
|
|
@@ -26,15 +68,15 @@
|
|
|
26
68
|
|
|
27
69
|
---
|
|
28
70
|
|
|
29
|
-
## 1.
|
|
71
|
+
## 1. 现状基线(v1.2.3 存档;现行数字见 §0 与 `docs/json-contract.md`)
|
|
30
72
|
|
|
31
73
|
| 项 | 值 |
|
|
32
74
|
|---|---|
|
|
33
|
-
| OpenFeel 版本 | `1.2.3
|
|
34
|
-
| 成功 `--json` 出口 | **33
|
|
35
|
-
| 适配器已消费 | **25**
|
|
36
|
-
| 适配器文本回显 | **8**
|
|
37
|
-
| 适配器验证 | contract
|
|
75
|
+
| OpenFeel 版本 | `1.2.3`(存档基线;现行 1.6.1) |
|
|
76
|
+
| 成功 `--json` 出口 | **33**(存档;现行 **51**,注册选项 **52**) |
|
|
77
|
+
| 适配器已消费 | **25** 个出口(存档;现行按工具实现,不按出口总数折算) |
|
|
78
|
+
| 适配器文本回显 | **8** 处(存档;现行仅 `dev status` 与 `instructions` XML 默认形态) |
|
|
79
|
+
| 适配器验证 | 存档 110 断言;现行 contract 53 / verify 129 / guard 180 / integration 10 |
|
|
38
80
|
| 适配器位置 | `OpenFeel/dsh/`(与 `claude/`、`kilo/` 同级的一等适配器) |
|
|
39
81
|
|
|
40
82
|
**为什么要关心文本回显那 7 处**:适配器要把结构化结果交给模型。落地为人类中文文本后,
|
package/dsh/ADAPTER.md
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
`pnpm install`。**改代码后需重启 DSH 宿主**(Loader 按 URL 缓存 ESM 模块)。
|
|
11
11
|
- **安装(另一种)**:经 DSH 插件管理器 `install_bundle` 装 `link:<repo>/dsh`;`file:` 会拷贝,
|
|
12
12
|
改代码后须重装。
|
|
13
|
-
- **落点**:`ctx.tools`(
|
|
14
|
-
`ctx.systemPrompt`(`<feel_mode>`
|
|
13
|
+
- **落点**:`ctx.tools`(15 个 `feel_*` 工具)、`ctx.commands`(`/feel`)、
|
|
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.
|
|
16
|
+
(v1.6.1 起 51 个成功出口 / 52 个注册 `--json` 选项);本适配器只消费、不重实现。
|
|
17
17
|
- **升级**:`npm i -g openfeel@latest` → 重启 DSH。适配器版本要求见 `package.json`
|
|
18
|
-
的 `openfeel.requiresCli`(≥1.
|
|
18
|
+
的 `openfeel.requiresCli`(≥1.6.0;`req body` / `feel_req body` / 五个新门禁码是硬依赖)。
|
|
19
19
|
|
|
20
20
|
## 设计边界
|
|
21
21
|
|
|
@@ -32,9 +32,10 @@ OpenFeel 采用「核心层 + 适配器层」架构(`claude/`、`kilo/`、`.op
|
|
|
32
32
|
- **第 1 层 · 文件工具**:`edit` / `write` / `apply_patch` / `str_replace_editor`。
|
|
33
33
|
- **第 2 层 · shell**:`bash` / `pwsh`(默认受守,四类判定见下)。
|
|
34
34
|
- **第 3 层 · 受保护路径**:`.openfeel/flow.json`(含 `.bak`)、`**/status.md`、`.openfeel/chore.json`、
|
|
35
|
-
`dev/.preflight.json` / `dev/sessions.json` / `dev/guard-state.json
|
|
35
|
+
`dev/.preflight.json` / `dev/sessions.json` / `dev/guard-state.json` / **`dev/dispatch.jsonl`(v1.6.0 派发台账)**、`flow-archive/**`、
|
|
36
36
|
`checkpoints/**`、`requirements/*.md`、`log/guard-audit.jsonl` —— **任意相位硬拒**
|
|
37
37
|
(D-126-05:防 agent 手写状态/写窗口自提权),拒绝文案指向对应的人类 CLI 路径。
|
|
38
|
+
`dev/dispatch.jsonl` 只能由 `feel_dispatch`(适配器进程内 fs 直写)维护;`requirements/*.md` 的提示文案指向 `feel_req action=body`。
|
|
38
39
|
其余分层:
|
|
39
40
|
- **bootstrap 例外**:工作区无 `.openfeel/` 时,全部目标为「新增文件」(`apply_patch` 还要求全部为
|
|
40
41
|
`*** Add File:`)→ 放行并提示补账本;已存在文件、`.openfeel/**`、Update/Delete/Move 仍拒绝;
|
|
@@ -145,7 +146,7 @@ OpenFeel 采用「核心层 + 适配器层」架构(`claude/`、`kilo/`、`.op
|
|
|
145
146
|
(重启会话不够,Loader 按 URL 缓存 ESM 模块);重启后首条判定即写 `guard-state.json`,
|
|
146
147
|
可用 `feel_status.guard` 核对 `registered` / `cwdSource` / `stale`(`stale` 由 pid/loaded_hash 判定,可自愈)。
|
|
147
148
|
- **命令执行推荐**(v1.3.5):系统提示段新增「Windows:优先 `bash`(Git Bash),其次 `pwsh`(PowerShell 7);macOS/Linux 用 `bash`;默认不用 `cmd.exe`」;同一任务保持同一 shell。
|
|
148
|
-
- **状态与记录**(v1.5.0
|
|
149
|
+
- **状态与记录**(v1.5.0;v1.6.0 收口):只有 Feel 写状态;子 agent 不读不写 `dev_last*` / `current.md` / `status.md` / `flow.json`;日志不强制;`feel_next` / `feel_status` 暴露 `statusSync.due`(30 分钟)。**同步入口是 `feel_dev action=sync`(工具),不是 shell**——`/feel` 与提示段都不再让 agent 跑 `openfeel dev sync`(写命令经 shell 会被门禁拒);`stage set` / `req advance|complete|review|verify|body` / `flow advance` 成功出口已自动同步(v1.6.0 / REQ-059),`due` 通常已为 `false`。
|
|
149
150
|
- **流程入口闸**(v1.5.2):`feel_status` / `feel_next` 在无活跃阶段时返回 `workflowGate`;无阶段写 `docs/research/**` 被拒(chore 不能绕过;拒绝写 `guard-audit.jsonl`,`event=guard_deny`)。
|
|
150
151
|
- **派发/恢复**(v1.5.3):`feel_next.dispatch`(goal/context/boundaries/returnFormat;子 agent 禁读状态文件、返回 ≤10 行);`feel_status.recovery`(lastTransition / handoff / nextAction)。
|
|
151
152
|
- **快照/空转**(v1.5.4):`feel_status` / `feel_next` 返回 `revision` / `snapshotAt` / `stale`;`plan_pending` 停留 >10 分钟提示空转。
|
|
@@ -157,6 +158,109 @@ OpenFeel 采用「核心层 + 适配器层」架构(`claude/`、`kilo/`、`.op
|
|
|
157
158
|
- **完成必审验**(v1.5.8 / REQ-027):`feel_req` 新增 `action=review`(`result`/`by`/`note`/`independent`)与 `action=verify`(`result`/`kind`/`by`/`note`/`evidence`),`feel_stage` 新增 `action=verify`(仅 archiving 相位);需求 `done` 门要求 review + verification 均 `pass`,阶段 `archiving → done` 要求阶段验证 `pass` 且关联需求全部 `done`(`--force` 不绕过)。review 缺省按**自我审查**处理并显式传 `--self`(归档摘要标注 `self-review`)。
|
|
158
159
|
- **需求随版本归档 + 发布门**(v1.5.8 / REQ-030):归档前先 `feel_req action=release-check`(只读,恒 exit 0);该版本仍有未完成需求时缺省拒绝归档,先 `feel_req action=rollover`(`from`/`to`/`id`|`all`)顺延,或 `feel_archive action=create` 显式 `allow_unfinished=true`。归档会把该版本**终态**需求移入归档文件;`feel_req action=list` 传 `include_archived=true` 合并查看,`action=show` 对已归档需求回退读归档文件(`archived: true`)。需求 ID 由 `flow.json.meta.last_req_seq` 单调分配,归档后不复用。
|
|
159
160
|
|
|
161
|
+
## v1.6.0:派发台账、提示词预算与每轮提醒
|
|
162
|
+
|
|
163
|
+
### 工具面(15 个,v1.6.0 新增 2 个)
|
|
164
|
+
|
|
165
|
+
| 工具 | 覆盖的 CLI | 能力域 |
|
|
166
|
+
|---|---|---|
|
|
167
|
+
| `feel_dispatch` | 无 CLI(适配器进程内直写 `.openfeel/dev/dispatch.jsonl`) | **派发台账**:`{stage, phase, targetAgent, role, goal, files, returnFormat, taskId?}` → 追加一行 JSONL 并返回 `dispatchId`;同 `leadSessionId + taskId + goal` 在 5 分钟内去重;24h / 上限 200 行清理 |
|
|
168
|
+
| `feel_dev` | `dev sync`(`cli.write`)/ `dev status`(文本 + 读 `.sync.json`) | **开发账本**:`action=sync|status`;返回 `{ok, lastSync, due, changed, wrote}` |
|
|
169
|
+
|
|
170
|
+
其余 13 个见 [`README.md`](README.md) 的工具表;`feel_req` 另新增 `action=body`(`cli.write(['req','body',...])`,走 T2 的正文写入口)。
|
|
171
|
+
|
|
172
|
+
### 提示词预算(`lib/surface/prompt.js`,v1.6.0 / T10)
|
|
173
|
+
|
|
174
|
+
| 语言 | enabled | disabled(含 Free Mode 附录) | 判据 |
|
|
175
|
+
|---|---|---|---|
|
|
176
|
+
| `zh-CN` | **720 字符 / 14 行** | **837 字符 / 17 行** | ≤1200 字符 且 ≤25 行 |
|
|
177
|
+
| `en` | **1027 字符 / 13 行** | **1143 字符 / 16 行** | 同上 |
|
|
178
|
+
|
|
179
|
+
正文常量 `FEEL_BODY_ZH` / `FEEL_BODY_EN` 是单一源:`src/core/template-loader.ts` 与 claude/opencode 四份 `feel.md` 用 `<!-- feel-prompt-parity:begin/end -->` 包住同一段文本,`test/cli/feel-prompt-parity.test.ts` 断言 5 处 sha256 一致(防副本分叉)。
|
|
180
|
+
|
|
181
|
+
### 每轮提醒:首选档不可用 → 降级 1(已落地)
|
|
182
|
+
|
|
183
|
+
| 档位 | 机制 | 结论 |
|
|
184
|
+
|---|---|---|
|
|
185
|
+
| 首选 | `ctx.tools.post-execute` → `additionalContexts` | **不可用**:`additionalContexts` 需 `UserMessage`(`createUserMessage` 来自 `@deepseek-ai/dsh-llm`),适配器零运行时依赖、profile 是 `link:`,`realpath` 上溯解析不到该包(`MODULE_NOT_FOUND`)。`post-execute` 仍注册为**只观察**(记步数 / 判断写类工具),不改结果 |
|
|
186
|
+
| **降级 1(采用)** | `ctx.systemPrompt.context({name:'openfeel-feel-next', order: FEEL_PROMPT_ORDER+5, text})` | 每次装配求值的函数;**写类工具之后**或**每 5 步**注入一行 `阶段 <stage> / <phase>|下一步:subagent(goal=…)`,其余请求返回空串(零 token 开销) |
|
|
187
|
+
| 降级 2 | 只在 `feel_*` 返回体加 `nextLine` | 未采用(覆盖率低) |
|
|
188
|
+
|
|
189
|
+
spike 原始证据(含 upgrade 条件)见 `.openfeel/tmp/stage-132/spike.md`;两处注册都以 `typeof … === 'function'` 守卫,宿主不支持时静默降级为无提醒。
|
|
190
|
+
|
|
191
|
+
### 派发台账 schema(`.openfeel/dev/dispatch.jsonl`)
|
|
192
|
+
|
|
193
|
+
每行一条 UTF-8 / LF JSON(读侧跳过畸形行;文件不存在视同空):
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{"dispatchId":"d-0001","ts":"2026-11-24T04:31:52.000Z","leadSessionId":"<session.id>","origin":"root","stage":"v1.6.0-stage-132","phase":"exec_running","targetAgent":"executor-a-cli","role":"executor","taskId":"T5","goal":"<一句话任务,含验收命令>","files":["src/core/plan/path.ts"],"returnFormat":"≤10 行:结论/改动文件/验证/阻塞","dispatchDepth":1}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
- **写入者唯一**:适配器 `lib/adapters/dispatch-ledger.js`(原子 temp + rename,仿 `sessions.js`);该文件在 `PROTECTED_OPENFEEL_PATHS` 内,agent 工具直写 → `deny`。
|
|
200
|
+
- **`origin` / `dispatchDepth`**:按 schema 保留缺省 `root` / `1`;**从宿主会话头读取的路径未在真实宿主验证**(spike T9 遗留),因此不构成实测证据,也不据此改审计 schema 版本。
|
|
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
|
+
|
|
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
|
+
|
|
160
264
|
## 目录
|
|
161
265
|
|
|
162
266
|
| 路径 | 内容 |
|
|
@@ -169,22 +273,24 @@ OpenFeel 采用「核心层 + 适配器层」架构(`claude/`、`kilo/`、`.op
|
|
|
169
273
|
| `lib/adapters/cli.js` | CLI 执行器:可执行文件解析、UTF-8/无色/无日志、退出码与 envelope 语义 |
|
|
170
274
|
| `lib/adapters/workspace.js` | 会话工作区 → OpenFeel 项目根 |
|
|
171
275
|
| `lib/adapters/dashboard.js` | 状态快照(消费 `flow next --json`)+ 「下一步」决策 |
|
|
276
|
+
| `lib/adapters/dispatch-ledger.js` | 派发台账(`.openfeel/dev/dispatch.jsonl` 读写 / 去重 / prune,v1.6.0) |
|
|
277
|
+
| `lib/adapters/next-action.js` | 动作型 `nextAction` 纯函数 + 每轮提醒状态(v1.6.0 / REQ-060) |
|
|
172
278
|
| `lib/adapters/host-state.js` | 宿主启动标记:适配器 `lib/` 指纹写入 `~/.openfeel/adapter-host-dsh.json`(v1.3.4) |
|
|
173
|
-
| `lib/tools/index.js` |
|
|
279
|
+
| `lib/tools/index.js` | **15** 个工具与 CLI argv 翻译 |
|
|
174
280
|
| `lib/tools/shared.js` | 输出封装、参数编译、渲染 |
|
|
175
281
|
| `lib/surface/command.js` | `/feel` 人类命令 |
|
|
176
|
-
| `lib/surface/prompt.js` | `<feel_mode>`
|
|
177
|
-
| `test/` | 契约 / 行为 / 门禁 / 真实注册表
|
|
282
|
+
| `lib/surface/prompt.js` | `<feel_mode>` 系统提示段(v1.6.0 压到 ≤1200 字符 / ≤25 行) |
|
|
283
|
+
| `test/` | 契约 / 行为 / 门禁 / 真实注册表 四套验证(断言数随版本增长,以 `dsh/test/*` 实测输出为准) |
|
|
178
284
|
| `docs/compat/` | OpenFeel v1.2.1 逆向兼容性契约(6 份;仅供回归参照,权威以 [docs/json-contract.md](https://github.com/Liuary/OpenFeel/blob/master/docs/json-contract.md) 为准) |
|
|
179
285
|
|
|
180
286
|
## 验证
|
|
181
287
|
|
|
182
288
|
```bash
|
|
183
289
|
cd dsh
|
|
184
|
-
node test/contract.js #
|
|
185
|
-
node test/verify.js #
|
|
186
|
-
node test/guard.js #
|
|
187
|
-
node test/integration.js # 10 — 真实 cordis + 真实 ToolRuntime
|
|
290
|
+
node test/contract.js # 53 — DSH schema 契约(真实 assertSupportedJsonSchema;v1.6.0 实测)
|
|
291
|
+
node test/verify.js # 129 — 行为(真实 CLI + 真实 .openfeel 副本;v1.6.0 实测)
|
|
292
|
+
node test/guard.js # 180 — 写入门禁(fake ToolExecution + 临时工作区;v1.6.0 实测)
|
|
293
|
+
node test/integration.js # 10 — 真实 cordis + 真实 ToolRuntime 挂载(取不到 tools 服务时跳过,exit 0)
|
|
188
294
|
```
|
|
189
295
|
|
|
190
296
|
## 发布说明
|
package/dsh/README.md
CHANGED
|
@@ -29,6 +29,23 @@ OpenFeel 是一个给 AI 助手用的记录本和工作流程,主要解决两
|
|
|
29
29
|
|
|
30
30
|
模式可以按项目切换,也可以改全局默认;直接让 AI 帮忙改就行。两种模式共用同一套记录和检查条件,区别只是要不要强制执行。
|
|
31
31
|
|
|
32
|
+
### 硬规则:主会话只调度(v1.6.0 起)
|
|
33
|
+
|
|
34
|
+
- **必须派发子 Agent**:写文件 / 改代码 / 跑测试一律交给子 agent;主会话只做「判断该谁做 + 派发 + 记账 + 裁决」。**主会话直接改仓库即违规**(台账无记录 = 未派发)。
|
|
35
|
+
- **每次派发都记账**:`feel_dispatch` 追加一行到 `.openfeel/dev/dispatch.jsonl`(`feel_status.dispatch.records` 可查;该文件受 guard 保护,手写会被拒)。示例:
|
|
36
|
+
|
|
37
|
+
```text
|
|
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
|
+
files=["docs/json-contract.md","CHANGELOG.md"]
|
|
41
|
+
returnFormat="≤10 行:结论/改动文件/验证/阻塞"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- **需求正文必须写实**:正文只经 `feel_req action=body` 写(`section=摘要|目标与验收`,`text` 或 `file`);空壳需求在**状态流转**(`→scheduled` / `→in_progress` / `→done`)时被 `REQ_BODY_GATE` 拦住(认领不校验正文;放行用 `advance` / `complete` 的 `--force` 留痕)。
|
|
45
|
+
- **执行前必须有需求级计划**:`.openfeel/plan/reqs/REQ-NNN.plan.md` 写实后才可 `→in_progress`;有关联阶段的需求同时受阶段 exec 门(`STAGE_PLAN_GATE`)约束。
|
|
46
|
+
- **全模式强制 plan → exec → review**:`general` / `fast` / `full` 都要求「需求级计划 → 执行 → 审查」,区别只在阶段级是否裁剪 scheme/test 相位;`--force` 只留痕放行,**不放宽** done 门(review + verify)/ blocking REV / 归档判据。
|
|
47
|
+
- **适用模式**:以上是 **Feel Mode(流程模式)** 的硬规则;**Free Mode**(`feel_mode=disabled`)下流程与检查点可选(写入门禁仍生效),但派发台账、正文写入口与需求级计划仍可用——记录照常,只是不强制。
|
|
48
|
+
|
|
32
49
|
## 记录存在哪
|
|
33
50
|
|
|
34
51
|
记录都在项目根目录的 `.openfeel/` 文件夹里,不在对话中,换会话或关软件都不会丢。内容包括当前进度、待办清单、检查记录、历史版本和项目设置,由 OpenFeel 自己维护,不需要手改。
|
|
@@ -134,22 +151,24 @@ Windows 上的 `openfeel.cmd` 垫片。
|
|
|
134
151
|
|
|
135
152
|
---
|
|
136
153
|
|
|
137
|
-
### 工具面(
|
|
154
|
+
### 工具面(15 个)
|
|
138
155
|
|
|
139
|
-
适配器在 DSH 工具注册表上注册
|
|
156
|
+
适配器在 DSH 工具注册表上注册 15 个工具,全部经 `openfeel` CLI 执行(`feel_dispatch` 例外:它直接维护派发台账)。
|
|
140
157
|
|
|
141
158
|
| 工具 | 覆盖的 CLI | 能力域 |
|
|
142
159
|
|---|---|---|
|
|
143
|
-
| `feel_status` | `flow next --json`(权威)→ 失败回退 `flow status --json` + `flow mode --json`(+`req list --json`) | **状态快照**:宏观相位、每阶段相位、模式与来源、合法下一相位、负责 Agent
|
|
144
|
-
| `feel_next` | 同上快照的派生决策(`flow next --json` 字段直出) | **该谁做**:负责 Agent
|
|
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
|
+
| `feel_next` | 同上快照的派生决策(`flow next --json` 字段直出) | **该谁做**:负责 Agent、合法下一相位、建议命令、守卫、阻塞审查、工具化 `dispatch`(goal/context/boundaries/returnFormat)、`nextAction`、`[HANDOFF: agent]` 标记 |
|
|
145
162
|
| `feel_flow` | `flow advance/current/overview/phases/mode/log/metrics/retry/repair/migrate/review_*` | 流水线推进与审查条目(`review_add` 的 `op` / `stage` 二选一,v1.3.4) |
|
|
146
163
|
| `feel_stage` | `plan stage add/list`、`stage status/set/task`、`flow stage set/reset/remove` | 阶段与 `status.md` |
|
|
147
164
|
| `feel_op` | `flow ops list`、`plan scheme create/publish/rename/remove/register`、`flow attempt/retry` | 操作方案与执行结果 |
|
|
148
|
-
| `feel_req` | `req add/list/show/board/next/claim/release/set/link/advance/split/review/verify/release-check/rollover` | 需求分发(
|
|
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
|
+
| `feel_dev` | `dev sync` / `dev status` | **开发账本(v1.6.0)**:`action=sync\|status`;写命令成功出口已自动同步,通常只需 `status` 核对 `due` |
|
|
149
168
|
| `feel_checkpoint` | `flow checkpoint list/restore` | 检查点快照与选择性回退 |
|
|
150
169
|
| `feel_archive` | `flow archive <version>/list/show`、`archive <stage>` | 版本分片归档(`allow_unfinished` 显式放行发布软门)+ 阶段摘要归档 |
|
|
151
170
|
| `feel_kb` | `knowledge list/add/search/index/dedup` | 知识库(4 个固定分类) |
|
|
152
|
-
| `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`) |
|
|
153
172
|
| `feel_review` | `view list/accept` | REV 条目视图 |
|
|
154
173
|
| `feel_plan` | `plan stage list`、`plan scheme list`、`roadmap create/show`、`instructions` | 计划与路线图 |
|
|
155
174
|
| `feel_model` | `model list/get/set` | Agent 模型意识配置 |
|
|
@@ -224,17 +243,18 @@ provider 桥接层会把「只有 description、没有 type」的节点转成 `t
|
|
|
224
243
|
|
|
225
244
|
### 系统提示面
|
|
226
245
|
|
|
227
|
-
启用 `autoPrompt` 时注入 `<feel_mode>` 段落,教会 agent **OpenFeel
|
|
246
|
+
启用 `autoPrompt` 时注入 `<feel_mode>` 段落,教会 agent **OpenFeel 的纪律**而非重复工具说明。v1.6.0 起提示**只有三节**(角色 / 三个可判定检查点 / 兜底),预算 **≤1200 字符、≤25 行**(实测 zh 700/817、en 1038/1154,含 Free Mode 附录):
|
|
228
247
|
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
- `
|
|
235
|
-
-
|
|
248
|
+
- **角色**:调度者不是执行者——写文件 / 改代码 / 跑测试由子 agent 完成。
|
|
249
|
+
- **检查点一(入口)**:无开启阶段或没有需求 → 先 `feel_stage action=add` + `feel_req action=add`,并用 `feel_req action=body` 写实正文;否则写入被拒 / 流转被拒(`REQ_BODY_GATE`)。
|
|
250
|
+
- **检查点二(计划)**:需求没有 `.openfeel/plan/reqs/REQ-NNN.plan.md` 或仍是占位空壳 → 停止执行,先补正文与计划;否则 `REQ_PLAN_GATE` / `STAGE_PLAN_GATE`。
|
|
251
|
+
- **检查点三(派发)**:要执行任何一步 → 必须派发子 agent 并用 `feel_dispatch` 记账;主会话只收 ≤10 行回报,直接改仓库即违规。
|
|
252
|
+
- **兜底**:不确定时调 `feel_status` / `feel_next`,不凭记忆;禁止手改 `flow.json` / `status.md`。
|
|
253
|
+
- **每轮提醒(v1.6.0)**:经 `ctx.systemPrompt.context` 注入,写类工具之后或每 5 步一次(首选档 `post-execute.additionalContexts` 不可用,降级原因见 [ADAPTER.md](ADAPTER.md));行文形如 `阶段 X / 相位 Y|下一步:subagent(goal=…)`。
|
|
254
|
+
- **状态与记录(v1.5.0;v1.6.0 收口)**:只有 Feel 写状态;子 agent 不读不写 `dev_last*` / `current.md` / `status.md` / `flow.json`;`feel_next` / `feel_status` 返回 `statusSync`(`due` / `lastSync` / `intervalMinutes`=30)。**同步用 `feel_dev action=sync`,不再用 shell 跑 `openfeel dev sync`**(写命令经 shell 会被门禁拒;且写成功出口已自动同步)。
|
|
236
255
|
- **命令执行工具(v1.3.5)**:Windows 优先 `bash`(Git Bash),其次 `pwsh`(PowerShell 7);macOS / Linux 用 `bash`;默认不用 `cmd.exe`;同一任务保持同一 shell。
|
|
237
|
-
-
|
|
256
|
+
- 门禁拒绝是预期结果,`--force` 只留痕放行(**不能**绕过 done 门 / blocking REV / 归档判据);退出码 `2` = 并发冲突可重试、`3` = 内部故障。
|
|
257
|
+
- **调度目标是活跃阶段**:`pipeline.phase` 只是宏观态,取 `phase != done` 的阶段;`auto_advance=disabled` 时推进前必须询问用户。
|
|
238
258
|
- **流程入口闸(v1.5.2)**:`feel_status` / `feel_next` 在无活跃阶段时返回 `workflowGate`;无阶段写 `docs/research/**` 被拒(chore 不能绕过,拒绝写 `guard-audit.jsonl`);提示段要求先 `feel_status`、不得以「调研/只读」为由跳过阶段。
|
|
239
259
|
- **派发/恢复(v1.5.3)**:`feel_next.dispatch`(goal/context/boundaries/returnFormat;子 agent 禁读状态文件、返回 ≤10 行);`feel_status.recovery`(lastTransition / handoff / nextAction);提示段新增派发契约节。
|
|
240
260
|
- **快照与空转(v1.5.4)**:`feel_status`/`feel_next` 返回 `revision` / `snapshotAt` / `stale`;`plan_pending` 停留 >10 分钟时提示空转。
|
|
@@ -258,7 +278,7 @@ provider 桥接层会把「只有 description、没有 type」的节点转成 `t
|
|
|
258
278
|
适配器在 `apply()` 中用 DSH 的 `ctx.tools.guard()` 注册同步守卫(`dsh/lib/guard.js`):
|
|
259
279
|
|
|
260
280
|
- **文件工具与 shell 都受守(v1.5.11)**:文件工具 `edit` / `write` / `apply_patch` / `str_replace_editor`;shell `bash` / `pwsh`(`shell` / `execute_command` / `exec` 在本宿主不存在,仅预置为跨宿主防御条目)。`feel_*`、`read`、`todo_write` 等不受影响。
|
|
261
|
-
- `.openfeel/**` 是**流程产物区**:plan / scheme / review 产物在任意阶段可写;但 `.openfeel/flow.json` 与 `.openfeel/**/status.md` **始终拒绝**(用 `feel_
|
|
281
|
+
- `.openfeel/**` 是**流程产物区**:plan / scheme / review 产物在任意阶段可写;但 `.openfeel/flow.json` 与 `.openfeel/**/status.md` **始终拒绝**(用 `feel_*`),`dev/dispatch.jsonl` 由 `feel_dispatch` 独占(手写 → deny)。受保护路径按**会话工作区 `<cwd>`** 判定;执行阶段仍可编辑其他项目的 `.openfeel/`(不做跨项目全局保护)。
|
|
262
282
|
- **风险分层(v1.3.3 / v1.4.0)**——源码(`src/**` 等)仍要求存在 `exec_running` 阶段;以下两类在无活跃阶段或非 `exec_running` 相位也放行,**混合目标从严**(任一源码 → 按源码规则):
|
|
263
283
|
- **doc/note**:`docs/**` 与 `.md/.mdx/.txt/.rst/.adoc`;
|
|
264
284
|
- **静态展示资源(v1.4.0)**:`.css/.scss/.html/.svg/.png/.jpg/.jpeg/.webp`,以及路径含 `assets/` 或 `public/`(支持 `crates/cli/assets/index.html` 这类嵌套资产目录;**源码扩展名不因目录豁免**,如 `assets/gen.ts` 仍按源码门禁)。
|
|
@@ -269,6 +289,8 @@ provider 桥接层会把「只有 description、没有 type」的节点转成 `t
|
|
|
269
289
|
3. **构建产物豁免**:`dist/**`、`build/**`、`out/**`、`target/**`、`.next/**`、`*.tsbuildinfo`;`npx vitest` / `npm run build` / `cargo build` / `tsc -b` / `git status` 等只读或产物命令不误杀。
|
|
270
290
|
4. **不可判定 → 默认告警放行 + 审计留痕**(`kind=undecidable`);要更严设 `OPENFEEL_SHELL_GATE=strict`。
|
|
271
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/**` **仍拒**——夹具 ≠ 测试代码,豁免只在相位层、不扩散到源码树。
|
|
272
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 不生效(不绕过相位门)。
|
|
273
295
|
- **bootstrap 例外(v1.3.3)**:无 `.openfeel/` 时,全部目标为**新增文件**(`apply_patch` 须全部 `*** Add File:`)→ 放行并提示补账本;已存在文件、`.openfeel/**`、Update/Delete/Move 仍拒绝(`enforce=always` 下)。`project`/`off` 放行。
|
|
274
296
|
- `apply_patch` 解析所有 patch 头(`*** Update/Add/Delete File:`、`*** Move to:`、`---/+++`);全部目标在 `.openfeel/**` 才内部放行,混合/无头保守拒绝。
|
|
@@ -285,17 +307,17 @@ provider 桥接层会把「只有 description、没有 type」的节点转成 `t
|
|
|
285
307
|
|
|
286
308
|
```powershell
|
|
287
309
|
cd plugin
|
|
288
|
-
node test/contract.js # DSH 契约:schema 子集、无 type:null、参数契约(
|
|
289
|
-
node test/verify.js # 行为:真实 CLI + 真实 .openfeel 副本(
|
|
290
|
-
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 项)
|
|
291
313
|
node test/integration.js # 真实注册表:真 cordis + 真 ToolRuntime 挂载(10 项)
|
|
292
314
|
```
|
|
293
315
|
|
|
294
316
|
- `contract.js` 用宿主 asar 提取出的**真实** `assertSupportedJsonSchema`。
|
|
295
317
|
- `verify.js` 对真实 OpenFeel 项目做只读校验,**所有写操作只打在 `os.tmpdir()` 副本上**,并断言原项目 `revision` 未被改动。
|
|
296
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`),不影响发布门禁。
|
|
297
|
-
- `guard.js` 覆盖 `off/project/always`、`.openfeel/**` 产物、`exec_running`、general 需求、apply_patch 混合/无头/Move 同块、受保护路径、bootstrap 文案、shell 四类判定与 `OPENFEEL_SHELL_GATE`
|
|
298
|
-
- `integration.js` 构造真实 Cordis 上下文 + 真实 `ToolRuntime`,调用适配器 `apply()`,断言
|
|
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** 条)。
|
|
320
|
+
- `integration.js` 构造真实 Cordis 上下文 + 真实 `ToolRuntime`,调用适配器 `apply()`,断言 **15** 个工具真的完成注册与投影。
|
|
299
321
|
|
|
300
322
|
依赖提取:`contract.js` / `integration.js` 默认读 `%TEMP%\dsh-asar\dsh\node_modules\@deepseek-ai`(从宿主
|
|
301
323
|
`app.asar` 解出的包)。缺失时 `contract.js` / `integration.js` 会跳过并说明。
|
|
@@ -317,7 +339,7 @@ dsh/ # OpenFeel 仓库内的一等适配器目录
|
|
|
317
339
|
│ │ ├── workspace.js # 会话工作区 = 项目根(与 CLI 一致,**不回溯**)
|
|
318
340
|
│ │ └── dashboard.js # 状态快照 + 「下一步」决策(消费 flow next/status,无相位→Agent 本地镜像)
|
|
319
341
|
│ ├── tools/
|
|
320
|
-
│ │ ├── index.js #
|
|
342
|
+
│ │ ├── index.js # 15 个工具定义与 CLI argv 翻译
|
|
321
343
|
│ │ └── shared.js # 输出封装、参数编译、渲染
|
|
322
344
|
│ └── surface/
|
|
323
345
|
│ ├── command.js # /feel 命令
|
|
@@ -349,12 +371,13 @@ dsh/ # OpenFeel 仓库内的一等适配器目录
|
|
|
349
371
|
3. **CLI 契约(v1.3.0)**:`flow next --json` 提供调度决策;`flow status --json` 的
|
|
350
372
|
`stages[]` 已含 `workflowMode` / `requirementId` / `reviewTier` / `effectiveReviewTier` /
|
|
351
373
|
`opsSummary`;`--json` 失败输出 envelope(`error.code` / `kind` / `detail`)为分类权威;
|
|
352
|
-
`flow advance --json` 仅用于失败 envelope。v1.
|
|
353
|
-
|
|
374
|
+
`flow advance --json` 仅用于失败 envelope。v1.6.1 起共 **51 个成功 `--json` 出口 / 52 个注册选项**;
|
|
375
|
+
适配器按需消费其中一部分(具体调用点见各工具实现,不再按出口总数折算)。详见 [操作指南](https://github.com/Liuary/OpenFeel/blob/master/dsh/ACTION-GUIDE.md) 与
|
|
354
376
|
[更新说明](https://github.com/Liuary/OpenFeel/blob/master/docs/dsh-cli-requirements-supplement-1.2.3.md)。
|
|
355
377
|
4. **读命令已全面结构化**:v1.2.4 补齐了 `plan stage list` / `model list|get` / `flow retry` /
|
|
356
|
-
`lint` / `roadmap show` / `config get --all
|
|
357
|
-
|
|
378
|
+
`lint` / `roadmap show` / `config get --all`;v1.6.0 补 `req body`(`feel_req action=body`)与
|
|
379
|
+
`lint fill`。适配器仅剩 `dev status` 的**文本回显**(该子命令无 `--json`;`feel_dev` 另读
|
|
380
|
+
`.sync.json` 补结构化字段)与 `instructions` 的 XML 默认形态(合理)。
|
|
358
381
|
5. **`stage_summary` 默认拒绝覆盖**:v1.2.4 起 `archive <stage>` 对已存在的归档文件返回
|
|
359
382
|
`ARCHIVE_EXISTS`(refusal)且零写盘;确需覆盖须传 `force=true`,会冲掉人工整理的摘要。
|
|
360
383
|
6. **超时**:默认单次 120s。超大 `flow.json`(数百 KB)的 `flow status` 可能接近上限。
|
|
@@ -1011,3 +1011,29 @@ Top-level keys in order: `meta, pipeline, stages, reviews, log` (no `requirement
|
|
|
1011
1011
|
20. CLI runtime log line `[ISO][LEVEL][pid] message`, `cli start:` / `cli done exit=… [duration_ms=…] [project=…] [session=…]`, `~/.openfeel/cli/logs/openfeel-YYYY-MM-DD.log`, best-effort, no rotation.
|
|
1012
1012
|
21. `.info.json` = `{user, lang}`; `user` is never overwritten; `lang` defaults to `zh-CN`.
|
|
1013
1013
|
22. `openfeel archive <stage>` writes `.openfeel/log/archive-{stage}.md`, appends one `archive_stage` log entry, saves `flow.json`, optionally seeds `kb/patterns.md` — and removes nothing.
|
|
1014
|
+
|
|
1015
|
+
---
|
|
1016
|
+
|
|
1017
|
+
## v1.6.0 增量(现行契约;以上 v1.2.1 正文保持冻结)
|
|
1018
|
+
|
|
1019
|
+
> 实现锚点:`src/core/dev-status.ts`(`maybeSyncDevStatus` / `getDevStatus`)、`src/core/flow-manager.ts`、`dsh/lib/adapters/dispatch-ledger.js`、`dsh/lib/guard.js`。
|
|
1020
|
+
|
|
1021
|
+
1. **`dev/` 自动同步(REQ-059)**:`maybeSyncDevStatus(projectPath)` 在 `due === true` 或节点相位(start / turning point / end)时调 `syncDevStatus`,**异常不再吞**(返回 `error`,调用方输出一行 stderr)。挂在**写成功出口**:`flow advance`、`stage set` / `stage task` / `stage verify`、`req advance` / `complete` / `review` / `verify` / `body`;读命令不调。`blockChanged()` 保证状态未变不重写。
|
|
1022
|
+
2. **`DEV_SYNC_STALE` 门**:`archiving → done` 前仍 `due === true` ⇒ refusal / exit 1、零写盘;门之前必先跑一次 `maybeSyncDevStatus`,正常路径不会触发(只有同步本身失败 / `.openfeel/dev/` 不可写才拦),`--force` 留痕放行(`gate_overrides` 追加 `'dev_sync'`)。**正常 CLI 序列不可复现**,取证只认构造法单测(注入 `syncDevStatus` 抛错 / 目录只读)。
|
|
1023
|
+
3. **`.openfeel/dev/dispatch.jsonl`(REQ-057,派发台账)**:每行一条 UTF-8 / LF JSON,键序 `dispatchId, ts, leadSessionId, origin, stage, phase, targetAgent, role, taskId, goal, files, returnFormat, dispatchDepth`。同 `leadSessionId + taskId + goal` 5 分钟内去重(返回既有 `dispatchId`);保留 24h / 上限 200 行(读侧跳过畸形行;文件不存在视同空)。由适配器 `feel_dispatch` 原子写(temp + rename),**在 `PROTECTED_OPENFEEL_PATHS` 内**(agent 工具直写 → deny)。`origin` / `dispatchDepth` 按 schema 缺省 `root` / `1`,会话头读取路径**未在真实宿主验证**。
|
|
1024
|
+
4. **新增持久面:需求级计划** `.openfeel/plan/reqs/REQ-NNN.plan.md`(全局固定,不随阶段/版本漂移;`mkdir` 幂等);`requirements[*].plan = {path, sha256(前 12 位), recorded_at, deviations?}` 在阶段计划门通过时盖章。
|
|
1025
|
+
5. **新增可选需求字段**:`body_waiver` / `plan_waiver`(`{at, by, reason, gate}`)与 `plan`;旧数据缺省即未 waiver / 未盖章(读侧宽容)。
|
|
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 写入门禁内。
|
|
@@ -1571,3 +1571,27 @@ Errors surface as `错误:{msg}` (`common.errorTmpl`) → exit 1; `isFlowConcu
|
|
|
1571
1571
|
15. **The `done` git commit must happen after `save()`**, driven by the `true` return of
|
|
1572
1572
|
`advanceStagePhase`.
|
|
1573
1573
|
16. **`flow phases` shows the unpruned table even when it reports `reviewTier: "lean"`.**
|
|
1574
|
+
|
|
1575
|
+
---
|
|
1576
|
+
|
|
1577
|
+
## v1.6.0 增量(现行契约;以上 v1.2.1 正文保持冻结)
|
|
1578
|
+
|
|
1579
|
+
> 实现锚点:`src/core/flow-manager.ts:resolveTransitionsForMode`、`src/core/req/requirement-ops.ts`、`src/core/pipeline-schema.ts`(本版**零改动**)。
|
|
1580
|
+
|
|
1581
|
+
1. **阶段级转移表一字不改**:`resolveTransitionsForMode` 的 `general → {}` **保留**;`flow phases --mode general` 仍为空表(`no-path` + 专用 `generalNoPipeline` 文案);`pipeline.yaml` 的 `transitions`(full)与 `fast_transitions` 均不变,**不新增 `general_transitions`**。`fast` 表本就含 `plan_review` + `review`,本版只补「进入 exec_running 前必须有写实计划」的门,表不变。
|
|
1582
|
+
2. **`general` 的强制链落在需求生命周期(REQ-058)**:`general` 需求(有/无阶段)与零关联阶段的 `fast`/`full` 需求,`→in_progress` 前必须有写实的 `.openfeel/plan/reqs/REQ-NNN.plan.md`(内部码 `plan_missing`,CLI 文案 + exit 1);`→done` 前计划被改动须写实 `## 偏差与回写`(`plan_deviation`)。有阶段的 `fast`/`full` 需求由阶段 exec 门(`STAGE_PLAN_GATE`)覆盖,本门不重复判。
|
|
1583
|
+
3. **为何不给阶段表加 `general_transitions`**:阶段级 `general` 在写入面即被拒(`src/commands/stage.ts` / `src/commands/plan.ts` 的 `general_mode_conflict`),表没有消费者——加了是死代码。`flow advance --force` 对阶段级 general 的既有行为不变(仍可强制移动,属既有边界,非本版新增)。
|
|
1584
|
+
4. **门不进 done / 归档判据**:`describeStageDoneGate`、`requirementDoneBlocker`(review + verify)、`flow archive` 判据**一字不改**;正文门与计划门是不参与这三处的独立前置检查(存量债因此可经 `--force` 留痕到达归档)。
|
|
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
|
@@ -1241,3 +1241,32 @@ split(data, parentId, children):
|
|
|
1241
1241
|
| `req next --limit 2` with 0 candidates | `(无可接取需求)`; `--json` → `requirement: null, candidates: []` |
|
|
1242
1242
|
| `req next --limit 0` | exit 1, `非法 --limit 值(应为 ≥1 的整数)` |
|
|
1243
1243
|
| `req claim REQ-001 --json` | commander unknown-option error (write commands have no `--json`) |
|
|
1244
|
+
|
|
1245
|
+
---
|
|
1246
|
+
|
|
1247
|
+
## v1.6.0 增量(现行契约;以上 v1.2.1 正文保持冻结)
|
|
1248
|
+
|
|
1249
|
+
> 本节只登记 v1.2.1 之后**新增或改变**的语义;与上文冲突时以本节为准。实现锚点:`src/core/req/requirement-ops.ts`、`src/core/plan/filled.ts`、`src/commands/req.ts`。
|
|
1250
|
+
|
|
1251
|
+
1. **`req body <id>` —— 正文唯一业务小节写入口(REQ-055)**。`--section <name>` 必填;`--text` / `--file` 恰一;`--append` / `--replace` 互斥(缺省替换整节)。只改目标小节,元信息小节(`状态` / `变更记录` 等)返回 legacy `protected_section`;每次成功写入追加一条 `## 变更记录`。`--json` 出口 #45:`{schemaVersion,id,section,path,lines,created}`;失败 legacy `{schemaVersion,error,errorKind}`,`error ∈ {not_found,protected_section,empty_text,invalid_field}`,exit 1、零写盘。
|
|
1252
|
+
2. **写实判据单点**:`src/core/plan/filled.ts` 的 `isRequirementBodyFilled`。`## 摘要` / `## 目标与验收` 各需 ≥40 个非空白字符(`MIN_FILLED_CHARS`),`## 目标与验收` 至少一行判据(`-` / `*` / `A1` / `验收` 开头);占位行(`- [ ] 待补充` / `(待补充)` / `TODO` 等)整行剔除。禁止子串判定(`includes('待补充')` 会误伤正文引用)。
|
|
1253
|
+
3. **正文门(REQ-055 / REV-013)**:`applyStatusChange` 在 `targetStatus ∈ {scheduled,in_progress,done}` 且无 `body_waiver` 时判(判据 `requirementBodyBlocker`)。**`claimRequirement` 不校验正文**——认领 ≠ 开工,`req add --claim` 必须原子成功;`req claim --force` 仅为旧脚本兼容保留,**当前无实际作用**。空壳 ⇒ exit 1 专用文案(提示 `req body` 补写),零写盘;`req advance|complete --force` 写 `body_waiver={at,by,reason}` + 审计 `requirement_body_forced`(`gate: advance|complete`),再次流转放行。`draft` / `blocked` / `cancelled` / `rejected` 不受此门;`general` 与零关联阶段需求**同样生效**;**不进入** done 门(归档判据不受影响)。
|
|
1254
|
+
4. **需求级计划门(REQ-056 / REQ-058)**:计划文件全局固定 `.openfeel/plan/reqs/REQ-NNN.plan.md`(不随版本漂移,`rollover` 后仍在)。适用面三种组合:① `workflow_mode === 'general'`(有/无阶段);② `fast` / `full` 且关联阶段数 **0**;③ 有阶段的 `fast`/`full` **不走本门**(由阶段 exec 门覆盖)。`→in_progress` 前计划缺失或未写实 ⇒ `plan_missing`(`REQ_PLAN_GATE`);`req claim` **不**挂计划门(claim ≠ 开工)。
|
|
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
|
+
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
|
+
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
|
@@ -1435,3 +1435,28 @@ const SchemaSchema = z.object({
|
|
|
1435
1435
|
`~/.openfeel/schemas/{name}/schema.yaml` → `node_modules/openfeel/schemas/{name}/schema.yaml`;
|
|
1436
1436
|
otherwise throws `找不到 Schema "{name}": 已搜索路径 {paths}`
|
|
1437
1437
|
- No CLI command in this repository consumes `ArtifactGraph`; the stage/op layer never reads `schemas/`.
|
|
1438
|
+
|
|
1439
|
+
---
|
|
1440
|
+
|
|
1441
|
+
## v1.6.0 增量(现行契约;以上 v1.2.1 正文保持冻结)
|
|
1442
|
+
|
|
1443
|
+
> 实现锚点:`src/core/flow-manager.ts`(`describeStagePlanGate` / `advanceStagePhase` / `resetStagePhase`)、`src/commands/flow.ts`、`src/core/plan/filled.ts`。
|
|
1444
|
+
|
|
1445
|
+
1. **执行前计划门(REQ-056 / REV-014)**:`advanceStagePhase` 在 done 门之后、写盘之前插入;条件是本次相位路径**跨越** `exec_running`(`crossesExecRunning`:`fromPhase` 严格早于 `exec_running` 且 `targetPhase` 等于或晚于 `exec_running`;`--force` 单跳如 `plan_passed → review_pending` 同样触发,已在 `exec_running` 及之后的阶段不重复触发),而非 `targetPhase === 'exec_running'`。要求阶段 `plan.md`(`findStagePlanPath` 三级回退)与每个在办需求(`scheduled`/`in_progress`,**全局扫描**,含零关联阶段与 `general`)的 `.openfeel/plan/reqs/REQ-NNN.plan.md` 存在**且写实**(`isStagePlanFilled` / `isRequirementPlanFilled`)。拒绝 ⇒ `STAGE_PLAN_GATE` / refusal / exit 1,`detail = {stagePlanMissing, stagePlanUnfilled, requirementsMissingPlan[], requirementsUnfilledPlan[]}`,**零写盘**(revision 不变)。
|
|
1446
|
+
2. **`--force` 语义**:`flow advance` / `flow stage reset` 把 `allowGateOverride: true` 传给核心层;放行时 `appendLog` 的条目 detail 追加 `gate_overrides:['plan']` 与 `gate_missing` 快照。**不是静默放行**,也不改变 done 门 / blocking REV 门 / 归档判据。`--dry-run` 只预览相位,不预演证据门。
|
|
1447
|
+
3. **复位同口径(REV-005 / 裁定①)**:`flow stage reset <stage> --to exec_running` 复检同一谓词;**不加 `--force` 拒绝**(零写盘,提示「补计划 / 加 `--force`」两条出路);加 `--force` 时审计条目不叫 `advance_stage_phase` 而是 `reset_stage_phase`,detail 同样是 `gate_overrides` + `gate_missing`。
|
|
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
|
+
5. **盖章(REQ-056)**:计划门**通过时**对每个在办需求写 `requirements[*].plan = {path, sha256(前 12 位), recorded_at}`(已有 `deviations` 保留);拒绝路径零写盘。
|
|
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)同口径。
|