openfeel 1.5.9 → 1.5.12
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.md +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/chore.d.ts +7 -0
- package/dist/commands/chore.d.ts.map +1 -1
- package/dist/commands/chore.js +43 -3
- package/dist/commands/chore.js.map +1 -1
- package/dist/commands/dashboard.d.ts +42 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +170 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/flow.d.ts +8 -0
- package/dist/commands/flow.d.ts.map +1 -1
- package/dist/commands/flow.js +2 -1
- package/dist/commands/flow.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +10 -0
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/shared/json-output.d.ts.map +1 -1
- package/dist/commands/shared/json-output.js +1 -0
- package/dist/commands/shared/json-output.js.map +1 -1
- package/dist/core/dashboard/aggregate.d.ts +146 -0
- package/dist/core/dashboard/aggregate.d.ts.map +1 -0
- package/dist/core/dashboard/aggregate.js +231 -0
- package/dist/core/dashboard/aggregate.js.map +1 -0
- package/dist/core/dashboard/render.d.ts +12 -0
- package/dist/core/dashboard/render.d.ts.map +1 -0
- package/dist/core/dashboard/render.js +506 -0
- package/dist/core/dashboard/render.js.map +1 -0
- package/dist/core/dsh-profile.d.ts +5 -0
- package/dist/core/dsh-profile.d.ts.map +1 -1
- package/dist/core/dsh-profile.js +5 -2
- package/dist/core/dsh-profile.js.map +1 -1
- package/dist/core/i18n-data/en.d.ts +6 -0
- package/dist/core/i18n-data/en.d.ts.map +1 -1
- package/dist/core/i18n-data/en.js +64 -1
- package/dist/core/i18n-data/en.js.map +1 -1
- package/dist/core/i18n-data/zh-CN.d.ts +6 -0
- package/dist/core/i18n-data/zh-CN.d.ts.map +1 -1
- package/dist/core/i18n-data/zh-CN.js +64 -1
- package/dist/core/i18n-data/zh-CN.js.map +1 -1
- package/dist/core/i18n.js +4 -4
- package/dist/core/i18n.js.map +1 -1
- package/dist/core/setup.d.ts +10 -0
- package/dist/core/setup.d.ts.map +1 -1
- package/dist/core/setup.js +11 -1
- package/dist/core/setup.js.map +1 -1
- package/dist/core/template-loader.d.ts.map +1 -1
- package/dist/core/template-loader.js +29 -7
- package/dist/core/template-loader.js.map +1 -1
- package/dist/core/update.d.ts.map +1 -1
- package/dist/core/update.js +29 -7
- package/dist/core/update.js.map +1 -1
- package/dsh/ADAPTER.md +106 -13
- package/dsh/README.md +20 -11
- package/dsh/cordis.patch.yml +23 -3
- package/dsh/lib/adapters/guard-state.js +722 -0
- package/dsh/lib/adapters/session-cwd-registry.js +82 -0
- package/dsh/lib/adapters/workflow-gate.js +101 -2
- package/dsh/lib/adapters/workspace.js +4 -2
- package/dsh/lib/guard.js +3147 -206
- package/dsh/lib/index.js +56 -4
- package/dsh/lib/tools/index.js +126 -9
- package/dsh/package.json +2 -2
- package/package.json +1 -1
package/dsh/ADAPTER.md
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
- **落点**:`ctx.tools`(13 个 `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.5.
|
|
16
|
+
(v1.5.10 起 43 个成功出口 / 44 个注册 `--json` 选项);本适配器只消费、不重实现。
|
|
17
17
|
- **升级**:`npm i -g openfeel@latest` → 重启 DSH。适配器版本要求见 `package.json`
|
|
18
|
-
的 `openfeel.requiresCli`(≥1.
|
|
18
|
+
的 `openfeel.requiresCli`(≥1.5.12)。
|
|
19
19
|
|
|
20
20
|
## 设计边界
|
|
21
21
|
|
|
@@ -28,16 +28,66 @@ OpenFeel 采用「核心层 + 适配器层」架构(`claude/`、`kilo/`、`.op
|
|
|
28
28
|
- **不解析**中文文本:优先消费 `--json`;失败读 `error.kind` / `error.code` / `error.detail`。
|
|
29
29
|
- **不 shadow** 既有能力:DSH 已有的 `subagent` / `workflow` / `todo_write` 照常使用;
|
|
30
30
|
`feel_next` 只给「该谁做」,实际派发交给 DSH。
|
|
31
|
-
- **写入门禁**(v1.3.3
|
|
32
|
-
`
|
|
33
|
-
|
|
31
|
+
- **写入门禁**(v1.3.3;v1.5.11 收窄为**三层**):用 DSH `ctx.tools.guard()` 同步拒绝。
|
|
32
|
+
- **第 1 层 · 文件工具**:`edit` / `write` / `apply_patch` / `str_replace_editor`。
|
|
33
|
+
- **第 2 层 · shell**:`bash` / `pwsh`(默认受守,四类判定见下)。
|
|
34
|
+
- **第 3 层 · 受保护路径**:`.openfeel/flow.json`(含 `.bak`)、`**/status.md`、`.openfeel/chore.json`、
|
|
35
|
+
`dev/.preflight.json` / `dev/sessions.json` / `dev/guard-state.json`、`flow-archive/**`、
|
|
36
|
+
`checkpoints/**`、`requirements/*.md`、`log/guard-audit.jsonl` —— **任意相位硬拒**
|
|
37
|
+
(D-126-05:防 agent 手写状态/写窗口自提权),拒绝文案指向对应的人类 CLI 路径。
|
|
38
|
+
其余分层:
|
|
34
39
|
- **bootstrap 例外**:工作区无 `.openfeel/` 时,全部目标为「新增文件」(`apply_patch` 还要求全部为
|
|
35
40
|
`*** Add File:`)→ 放行并提示补账本;已存在文件、`.openfeel/**`、Update/Delete/Move 仍拒绝;
|
|
36
41
|
- **doc/note 不绑相位**:`docs/**` 与 `.md/.mdx/.txt/.rst/.adoc` 在无活跃阶段或非 `exec_running`
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
|
|
42
|
+
相位也可写;**代码目录(`src` / `test` / `scripts` / `dsh` / `bin`)内任何扩展名都不豁免**
|
|
43
|
+
(`src/x.md` / `src/assets/logo.svg` 一样按源码判,D-126-06);**混合目标从严**(任一源码 → 按源码规则);
|
|
44
|
+
- 源码(`src/**` 等)要求 `exec_running`;`dist|build|out|target|.next|node_modules|coverage|*.tsbuildinfo`
|
|
45
|
+
等构建/测试产物不触发判定(保证 `npm run build` / `cargo build` / `tsc -b` 不被误杀,仍需全部目标命中);
|
|
46
|
+
- **v1.4.0 静态展示资源**:`.css/.scss/.html/.svg/.png/.jpg/.jpeg/.webp` 与 `assets/**`、`public/**` 与 doc
|
|
47
|
+
同层放行(根级 `README*` / `CHANGELOG*` / `LICENSE*` 亦豁免);豁免放行写 `.openfeel/log/guard-audit.jsonl`;
|
|
48
|
+
- **v1.5.11 chore 写窗口(纯人类通道)**:窗口**上限 30 分钟**(`--ttl-min 1..30`,只能改短;越界/非整数
|
|
49
|
+
直接 exit 1 且零写盘),默认只放行 doc/静态资源,**只有 `--source` 才允许源码**
|
|
50
|
+
(`chore.json.source_allowed: true`;旧记录缺该字段视为未授权)。shell 门禁拒 agent 开启 chore、
|
|
51
|
+
`chore.json` 又在受保护名单 ⇒ 窗口只能由人类在外部终端 `openfeel chore [--source] "<说明>"` 开启;
|
|
52
|
+
- **shell 四类判定**(`bash` / `pwsh`;相对路径按 `workdir ?? guard cwd` 解析):
|
|
53
|
+
① **硬拒**:受保护路径、`openfeel flow|stage|req|chore` 的**写**子命令(`--status` / `--end` 放行;
|
|
54
|
+
引号程序名 / `node <cli 路径>` / `Start-Process openfeel` / 任何 `chore` + `--source` 同样命中)、
|
|
55
|
+
以及编码/嵌套执行形态(`-EncodedCommand`、`iex`/`Invoke-Expression`、`bash -c`、`eval`、`node -e` 等)
|
|
56
|
+
与 `.NET` 静态写方法(**正面判定**:`IO.File|Directory|StreamWriter|Compression.*` 等可写类型上
|
|
57
|
+
方法不在只读白名单即拒 —— `WriteAllTextAsync` / `[IO.File]::Open('x','Create')` 一并命中)、
|
|
58
|
+
`New-Object` 写对象、`Add-Type` 动态编译;
|
|
59
|
+
② **按目标路径判**(与文件工具共用同一 `decideForTargets`):重定向 / `tee` / `Set-Content` / `New-Item` /
|
|
60
|
+
`Copy-Item` / `Remove-Item` / `sed -i` / `rm` / `mkdir` / `robocopy` / `xcopy` /
|
|
61
|
+
下载器输出(`curl -o` / `iwr -OutFile` / `wget -O`)/ `certutil -urlcache|decode` /
|
|
62
|
+
格式化改写(`prettier --write`、`eslint --fix`、`gofmt -w`;**无写标志的 `prettier --check` /
|
|
63
|
+
`eslint src` 判确认只读**),以及**全部 git 工作区写**
|
|
64
|
+
(`checkout --`、`restore`、`reset --hard`、`stash`(含 `push`)、`clean`、`apply`、
|
|
65
|
+
无 `exec_running` 时的 `commit`;整树写还要求 `.openfeel/**` 无未提交差异,
|
|
66
|
+
`git clean` / `stash -u` 额外要求**无未跟踪文件**(`checkpoints/`、新 plan 目录),
|
|
67
|
+
带 `-x` 的 `clean` 还要求**审计 `log/guard-audit.jsonl` 与 `chore.json` 不存在**
|
|
68
|
+
—— 这两类文件被 .gitignore 忽略,`ls-files` 看不见,但 `clean -fdx` 会删掉;
|
|
69
|
+
`git commit` 不覆盖工作区,不受这条限制);
|
|
70
|
+
③ **产物豁免**(同上面的构建/测试产物表);④ **无法判定** → 默认告警放行(审计 + stderr)。
|
|
71
|
+
**例外(v1.5.12 / op-002 纯书账)**:无 `exec_running` / `archiving` 阶段时,`git commit` 仅在
|
|
72
|
+
**单条、直接、无重定向/`$()`/反引号**,且 `git status --porcelain -z` 的待提交路径**全部**落在
|
|
73
|
+
`.openfeel/**` 下才放行(允许原因 `git-commit-bookkeeping`,审计可查);出现外部路径则拒并点名前
|
|
74
|
+
5 条。带 `-C` / `--git-dir` / `--work-tree` 的 commit 一律拒(仓库归属无法校验);
|
|
75
|
+
- **默认 fail-closed(op-005)**:**无法确认「这条命令不写」就落第 4 类**,不再把未识别命令
|
|
76
|
+
当作 `no-write` 静默放行。审计的 `kind` 因此能区分 `none`(确认只读)与 `undecidable`。
|
|
77
|
+
「确认只读」需要正面证据:命中只读白名单、已知构建/测试工具(`npx vitest` / `npm run build` /
|
|
78
|
+
`cargo build` / `tsc -b` 仍放行),否则一律第 4 类 —— 包括 `npx <任意>`、`node <脚本>`、
|
|
79
|
+
`python <脚本>`、不可解析的 `& $var`、`$()`/反引号命令替换;
|
|
80
|
+
- **第 4 类的书面口径**:默认 `warn`(审计 + stderr),要更严就设 `OPENFEEL_SHELL_GATE=strict`。
|
|
81
|
+
**已知敞口**:第 4 类默认放行意味着「蓄意用未识别写法」仍能写盘(只是留痕)——
|
|
82
|
+
典型是 `node <脚本>`、`npx <任意>`、`$()`/反引号里再嵌一层不透明执行;
|
|
83
|
+
门禁的目标是让**默认路径**不静默 —— 需要硬保证时把宿主设成 `strict`(第 4 类也拒);
|
|
84
|
+
- **`OPENFEEL_SHELL_GATE` 三档**(缺省 = 「1/2 类拒 + 4 类告警」组合,不是单一开关):`strict` 第 4 类也拒;
|
|
85
|
+
`warn` 第 1/2/4 类全部降级为告警放行;`off` shell 完全不解析。**只影响 shell 分支**,文件工具不受影响;
|
|
86
|
+
`warn`/`off` 的降级事实写进 `guard-state.json.shellGate` 与审计,可反查;
|
|
87
|
+
- **cwd 解析六环**(fail-closed):① `OPENFEEL_GUARD_CWD`(env,**最高优先逃生阀**,非空即生效)→
|
|
88
|
+
② `agent.session.header.cwd` → ③ `config.cwd`(`cordis.patch.yml` 的 `cwd:`)→ ④ 会话登记表 `[sessionId]` →
|
|
89
|
+
⑤ `process.cwd()`(**仅当该目录本身含 `.openfeel/`**)→ ⑥ 全部失败 → 拒绝。已删除 `registry-last`
|
|
90
|
+
(进程级单标量,多项目会「按别的项目放行」);非 `agent-session` 来源 stderr 告警 + `feel_status.guard.degraded=true`;
|
|
41
91
|
- `enforce=always`(默认)对非 OpenFeel 工作区也拦截,可用 `project` / `off` opt-out。
|
|
42
92
|
- **审查归属**(v1.3.3 / v1.3.4):REV 可挂 op(`stageId.op-xxx`)或挂 stage(`op = stageId`,无 op 的 fast 场景);
|
|
43
93
|
`feel_flow action=review_add` 的 `op` / `stage` 二选一透传(v1.3.4,两者皆无 → `FEEL_BAD_USAGE`);
|
|
@@ -45,6 +95,47 @@ OpenFeel 采用「核心层 + 适配器层」架构(`claude/`、`kilo/`、`.op
|
|
|
45
95
|
- **宿主加载指纹**(v1.3.4):`apply()` 启动时把适配器 `lib/` 指纹写入
|
|
46
96
|
`~/.openfeel/adapter-host-dsh.json`(`OPENFEEL_ADAPTER_HOST_PATH` 可覆盖,测试用);
|
|
47
97
|
CLI `setup --check` 据此区分「文件旧」与「文件已新但宿主未重启」。
|
|
98
|
+
- **门禁可见性**(v1.5.11 / D-126-04;v1.5.12 / stage-127 身份自证):注册 guard 时写
|
|
99
|
+
`.openfeel/dev/guard-state.json`(`registered` / `enforce` / `shellGate` / `cwd` / `cwdSource` /
|
|
100
|
+
`degraded` / `resolvedAt` / `hostStartedAt` / `loaded_hash` / `pid`),每次放行/拒绝更新 `lastDecision`;
|
|
101
|
+
`feel_status` / `feel_next` 返回 `guard` 段(compact 档也带)。
|
|
102
|
+
**身份三键只来自当前进程**(`setGuardRuntimeIdentity` 在 `apply()` 写完 marker 后登记)或显式 patch,
|
|
103
|
+
**旧工作区文件里的身份一律剥离、绝不继承**(重启后不再因旧 `hostStartedAt` 恒 `stale`)。
|
|
104
|
+
**stale 只认 `pid` + `loaded_hash`**:`pid` 缺失/不符、`loaded_hash` 缺失(`loaded-hash-missing`)、
|
|
105
|
+
或双方非空的 `loaded_hash` 不符 → `guard.stale=true`
|
|
106
|
+
并让 summary 明说「门禁来自旧进程/旧适配器」,同时 `workflowGate.required=true`(**不拒写**,见 §F.0 决策)。
|
|
107
|
+
`guard.hostStartedAt` 是**诊断字段**:`stale:false` 时它仍可能是 state 里的旧值(不改 `guard` 段键形状,
|
|
108
|
+
避免动 `deepEqual` 契约);时间比较在多 profile/多宿主下必然误报,故不参与判定。
|
|
109
|
+
**HMAC**(进程内密钥,不落盘)跨进程必然失配,因此只降级为可见信号:`guard.signature='valid'|'mismatch'`;
|
|
110
|
+
`pid`/`loaded_hash` 都通过而验签失败时加 `guard.hmacWarn=true`(不置 stale、不进 `workflowGate`、不进 summary 门禁)。
|
|
111
|
+
残留敞口:伪造只影响显示;跨进程识别由 `pid` 覆盖,代码版本由 `loaded_hash` 覆盖。
|
|
112
|
+
cwd 解析失败时不静默丢弃:状态与审计固定落 `os.tmpdir()/openfeel-guard/`(`cwd:null`、`cwdSource:'unresolved'`;
|
|
113
|
+
`OPENFEEL_GUARD_DIR` 可覆盖,测试隔离用),`feel_status` 在工作区文件缺失时也读该全局文件并标 `degraded=true`。
|
|
114
|
+
- **门禁自愈**(v1.5.12 / stage-127;op-005 加固):官方修复路径**不需要删除** `.openfeel/dev/guard-state.json`。
|
|
115
|
+
- **自动**:重启后**首次任意 `feel_*`** 即尝试修复(`target()` 公共入口,best-effort,异常绝不阻断)。
|
|
116
|
+
**只对「`pid` 缺失 / `pid` 已死(`ESRCH`)」自动修**:活着的异 pid(含 `EPERM`)跳过(两个活宿主共享
|
|
117
|
+
同一工程会互相覆盖);**同 pid 的 `loaded_hash` 失配绝不自动修**——那是「适配器已更新但宿主没重启」的
|
|
118
|
+
信号,必须在展示前保留(`stale` 保持),交由完全重启或显式入口。marker 不完整(缺 `started_at` /
|
|
119
|
+
空 `loaded_hash`)时自动修也会以 `marker-incomplete` 拒绝且零写盘。
|
|
120
|
+
同一 root 60s 节流(**检查成功后才记时间**,异常不占窗口;节流表上限 64,LRU);
|
|
121
|
+
marker 按 `{path, mtimeMs, size}` 缓存;单次自动检查 3~4 次同步小 JSON 读
|
|
122
|
+
(state 1 + marker 0~1 + 修复写盘内部 `writeGuardState` 的 global/workspace 2);自动 `guard_repair`
|
|
123
|
+
审计每宿主启动至多 1 条(**取舍**:多 root 时只第一条自动修复进审计,其余只写 state;要逐 root 追溯用显式入口)。
|
|
124
|
+
- **显式**:`feel_verify action=health fix=true`(`dry_run` 不写盘)→ 结果在 `data.health.guardRepair`,
|
|
125
|
+
summary 明示成功/失败;marker 缺失报 `marker-missing`、marker 不完整报 `marker-incomplete`,均**零写盘**。
|
|
126
|
+
身份**只来自 marker + 当前宿主 `process.pid`**,不接受任何工具参数(agent 无法注入 pid/loaded_hash)。
|
|
127
|
+
- **逃生阀**:`OPENFEEL_GUARD_SELF_HEAL=off` 关闭自动自愈(显式入口仍可用)。
|
|
128
|
+
- **审计**:修复追加 `.openfeel/log/guard-audit.jsonl`(`event:'guard_repair'`,含 old/new;幂等时不写)。
|
|
129
|
+
该文件本身是受保护路径(工具写被 guard 拒),而 repair 走适配器进程内 `fs` 直写、不经 guard,故无自锁。
|
|
130
|
+
- **多宿主同工程时不要用显式修复**(会把 state 归到当前宿主);自动自愈在活 pid 场景已自动跳过。
|
|
131
|
+
- **测试隔离 env(非安全边界)**:`OPENFEEL_GUARD_DIR`(覆盖全局 guard 目录,状态+审计一起隔离)与
|
|
132
|
+
`OPENFEEL_ADAPTER_HOST_PATH`(沿用,覆盖宿主 marker 路径)应在宿主启动前设置;
|
|
133
|
+
`dsh/test/{guard,verify,contract,integration}.js` 各自指向 `mkdtempSync` 临时目录,并断言真实状态未被改写。
|
|
134
|
+
该断言按**逐文件内容**比对(name + size + mtime + sha256):内容变 → FAIL;仅新增/删除文件或
|
|
135
|
+
`started_at` 变 → `skip: host-active`;全不变 → PASS。`dsh/test/guard-isolation.js` 自带这三条自测。
|
|
136
|
+
- **生效条件(重要)**:门禁在 `apply()` 时注册,**部署/更新后必须完全重启 DSH 宿主**才生效
|
|
137
|
+
(重启会话不够,Loader 按 URL 缓存 ESM 模块);重启后首条判定即写 `guard-state.json`,
|
|
138
|
+
可用 `feel_status.guard` 核对 `registered` / `cwdSource` / `stale`(`stale` 由 pid/loaded_hash 判定,可自愈)。
|
|
48
139
|
- **命令执行推荐**(v1.3.5):系统提示段新增「Windows:优先 `bash`(Git Bash),其次 `pwsh`(PowerShell 7);macOS/Linux 用 `bash`;默认不用 `cmd.exe`」;同一任务保持同一 shell。
|
|
49
140
|
- **状态与记录**(v1.5.0):只有 Feel 写状态;子 agent 不读不写 `dev_last*` / `current.md` / `status.md` / `flow.json`;日志不强制;`feel_next` / `feel_status` 暴露 `statusSync.due`(30 分钟),到期只提示更新交接摘要 + `openfeel dev sync`。
|
|
50
141
|
- **流程入口闸**(v1.5.2):`feel_status` / `feel_next` 在无活跃阶段时返回 `workflowGate`;无阶段写 `docs/research/**` 被拒(chore 不能绕过;拒绝写 `guard-audit.jsonl`,`event=guard_deny`)。
|
|
@@ -62,7 +153,9 @@ OpenFeel 采用「核心层 + 适配器层」架构(`claude/`、`kilo/`、`.op
|
|
|
62
153
|
|
|
63
154
|
| 路径 | 内容 |
|
|
64
155
|
|---|---|
|
|
65
|
-
| `lib/guard.js` |
|
|
156
|
+
| `lib/guard.js` | 写入门禁:三层(文件工具 / shell 四类 / 受保护路径)、`enforce`、bootstrap 新增放行、doc/asset 分层、apply_patch 目标解析、cwd 六环 fail-closed |
|
|
157
|
+
| `lib/adapters/guard-state.js` | 门禁自证:`.openfeel/dev/guard-state.json`(注册态 + `lastDecision`)与 cwd 失败时的全局落点 |
|
|
158
|
+
| `lib/adapters/session-cwd-registry.js` | 会话 cwd 登记表(只按 `sessionId`,**无 `lastCwd`** 进程级兜底) |
|
|
66
159
|
| [`ACTION-GUIDE.md`](ACTION-GUIDE.md) | **给 OpenFeel 本体的操作指南**:剩余 5 项待办、验收标准、边界约定 |
|
|
67
160
|
| `lib/index.js` | 插件入口(`name` / `inject` / `apply` / `normalizeConfig`) |
|
|
68
161
|
| `lib/adapters/cli.js` | CLI 执行器:可执行文件解析、UTF-8/无色/无日志、退出码与 envelope 语义 |
|
|
@@ -73,7 +166,7 @@ OpenFeel 采用「核心层 + 适配器层」架构(`claude/`、`kilo/`、`.op
|
|
|
73
166
|
| `lib/tools/shared.js` | 输出封装、参数编译、渲染 |
|
|
74
167
|
| `lib/surface/command.js` | `/feel` 人类命令 |
|
|
75
168
|
| `lib/surface/prompt.js` | `<feel_mode>` 系统提示段 |
|
|
76
|
-
| `test/` | 契约 / 行为 / 门禁 / 真实注册表 四套验证(46 +
|
|
169
|
+
| `test/` | 契约 / 行为 / 门禁 / 真实注册表 四套验证(46 + 112 + 138 + 10 断言,v1.5.11 / stage-126 后实测) |
|
|
77
170
|
| `docs/compat/` | OpenFeel v1.2.1 逆向兼容性契约(6 份;仅供回归参照,权威以 [docs/json-contract.md](https://github.com/Liuary/OpenFeel/blob/master/docs/json-contract.md) 为准) |
|
|
78
171
|
|
|
79
172
|
## 验证
|
|
@@ -81,8 +174,8 @@ OpenFeel 采用「核心层 + 适配器层」架构(`claude/`、`kilo/`、`.op
|
|
|
81
174
|
```bash
|
|
82
175
|
cd dsh
|
|
83
176
|
node test/contract.js # 46 — DSH schema 契约(真实 assertSupportedJsonSchema)
|
|
84
|
-
node test/verify.js #
|
|
85
|
-
node test/guard.js #
|
|
177
|
+
node test/verify.js # 112 — 行为(真实 CLI + 真实 .openfeel 副本)
|
|
178
|
+
node test/guard.js # 138 — 写入门禁(fake ToolExecution + 临时工作区)
|
|
86
179
|
node test/integration.js # 10 — 真实 cordis + 真实 ToolRuntime 挂载
|
|
87
180
|
```
|
|
88
181
|
|
package/dsh/README.md
CHANGED
|
@@ -103,7 +103,10 @@ Windows 上的 `openfeel.cmd` 垫片。
|
|
|
103
103
|
activation: auto # auto=项目→完整纪律/非项目→bootstrap;always=完整纪律;off=不注入
|
|
104
104
|
enforce: always # always=所有工作区守门禁;project=仅项目;off=完全不注册 guard
|
|
105
105
|
allowGeneral: true # general 需求 in_progress 且无阶段时放行源码写入
|
|
106
|
-
# mutatingTools 默认 [edit, write, apply_patch, str_replace_editor
|
|
106
|
+
# mutatingTools 默认 [edit, write, apply_patch, str_replace_editor, bash, pwsh, shell, execute_command, exec]
|
|
107
|
+
# (bash / pwsh 默认受守;shell / execute_command / exec 本宿主不存在,仅作跨宿主防御)
|
|
108
|
+
# shellGate 可选(只影响 shell 分支;env OPENFEEL_SHELL_GATE 优先):strict | warn | off
|
|
109
|
+
# shellGate: strict
|
|
107
110
|
```
|
|
108
111
|
|
|
109
112
|
`normalizeConfig` 对非法值做安全回落(如 `timeoutMs: -5` → `120000`)。
|
|
@@ -232,19 +235,25 @@ provider 桥接层会把「只有 description、没有 type」的节点转成 `t
|
|
|
232
235
|
|
|
233
236
|
适配器在 `apply()` 中用 DSH 的 `ctx.tools.guard()` 注册同步守卫(`dsh/lib/guard.js`):
|
|
234
237
|
|
|
235
|
-
-
|
|
238
|
+
- **文件工具与 shell 都受守(v1.5.11)**:文件工具 `edit` / `write` / `apply_patch` / `str_replace_editor`;shell `bash` / `pwsh`(`shell` / `execute_command` / `exec` 在本宿主不存在,仅预置为跨宿主防御条目)。`feel_*`、`read`、`todo_write` 等不受影响。
|
|
236
239
|
- `.openfeel/**` 是**流程产物区**:plan / scheme / review 产物在任意阶段可写;但 `.openfeel/flow.json` 与 `.openfeel/**/status.md` **始终拒绝**(用 `feel_*`)。受保护路径按**会话工作区 `<cwd>`** 判定;执行阶段仍可编辑其他项目的 `.openfeel/`(不做跨项目全局保护)。
|
|
237
240
|
- **风险分层(v1.3.3 / v1.4.0)**——源码(`src/**` 等)仍要求存在 `exec_running` 阶段;以下两类在无活跃阶段或非 `exec_running` 相位也放行,**混合目标从严**(任一源码 → 按源码规则):
|
|
238
241
|
- **doc/note**:`docs/**` 与 `.md/.mdx/.txt/.rst/.adoc`;
|
|
239
242
|
- **静态展示资源(v1.4.0)**:`.css/.scss/.html/.svg/.png/.jpg/.jpeg/.webp`,以及路径含 `assets/` 或 `public/`(支持 `crates/cli/assets/index.html` 这类嵌套资产目录;**源码扩展名不因目录豁免**,如 `assets/gen.ts` 仍按源码门禁)。
|
|
240
243
|
- **审计(v1.4.0)**:doc/静态资源豁免放行与 chore 放行时,追加 JSONL 到 `.openfeel/log/guard-audit.jsonl`(`time/tool/reason/phase/paths`),best-effort 不影响放行。
|
|
241
|
-
- **
|
|
244
|
+
- **shell 四类判定(v1.5.11 / D-126-02)**:`bash` / `pwsh` 默认受守,按命令文本分四类——
|
|
245
|
+
1. **硬拒**:受保护路径(`flow.json` / `status.md` / `chore.json` / `config.yaml` / `.preflight.json` / `guard-state.json` / `pipeline.yaml` / `flow-archive/**` 等)、用 shell 跑 `openfeel` 写子命令(`flow` / `stage` / `req` / `chore` 等,应改用 `feel_*`),以及编码与间接执行形态(`-EncodedCommand` / `iex` / `bash -c` / `node -e` / `python -c`)。
|
|
246
|
+
2. **按目标判定**:能静态解析出目标路径的源码写与 git 工作区写(`checkout` / `restore` / `reset --hard|--merge` / `stash pop|apply` / `clean` / `apply` / `commit`)→ 按相位拒(源码要求 `exec_running`;整树 git 写在无 `exec_running` 或 `.openfeel/**` 有未提交改动时拒)。
|
|
247
|
+
3. **构建产物豁免**:`dist/**`、`build/**`、`out/**`、`target/**`、`.next/**`、`*.tsbuildinfo`;`npx vitest` / `npm run build` / `cargo build` / `tsc -b` / `git status` 等只读或产物命令不误杀。
|
|
248
|
+
4. **不可判定 → 默认告警放行 + 审计留痕**(`kind=undecidable`);要更严设 `OPENFEEL_SHELL_GATE=strict`。
|
|
249
|
+
相对路径按 `workdir ?? guard cwd` 解析;档位见下方「shell 判定档位」。
|
|
250
|
+
- **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 不生效(不绕过相位门)。
|
|
242
251
|
- **bootstrap 例外(v1.3.3)**:无 `.openfeel/` 时,全部目标为**新增文件**(`apply_patch` 须全部 `*** Add File:`)→ 放行并提示补账本;已存在文件、`.openfeel/**`、Update/Delete/Move 仍拒绝(`enforce=always` 下)。`project`/`off` 放行。
|
|
243
252
|
- `apply_patch` 解析所有 patch 头(`*** Update/Add/Delete File:`、`*** Move to:`、`---/+++`);全部目标在 `.openfeel/**` 才内部放行,混合/无头保守拒绝。
|
|
244
253
|
- `enforce=off` **完全不注册 guard**(连 flow.json/status.md 也不拦)。
|
|
245
254
|
- `ctx.tools.guard` 缺失时记警告并降级;`ctx.effect` 负责 disposer,避免 HMR 累积。
|
|
246
255
|
|
|
247
|
-
|
|
256
|
+
**shell 判定档位(`OPENFEEL_SHELL_GATE`;只影响 shell 分支,文件工具不受影响)**:缺省 = 「第 1/2 类拒 + 第 4 类告警」;`strict` = 第 4 类也拒;`warn` = 第 1/2/4 类全部降级为告警放行(仍写审计);`off` = shell 完全不解析(`edit` / `write` 等仍受守)。profile 的 `shellGate:` 同值,环境变量优先(排障逃生阀)。`enforce=always` 对非 OpenFeel 工作区较激进,可用 `project` / `off` opt-out。
|
|
248
257
|
|
|
249
258
|
---
|
|
250
259
|
|
|
@@ -254,16 +263,16 @@ provider 桥接层会把「只有 description、没有 type」的节点转成 `t
|
|
|
254
263
|
|
|
255
264
|
```powershell
|
|
256
265
|
cd plugin
|
|
257
|
-
node test/contract.js # DSH 契约:schema 子集、无 type:null、参数契约(
|
|
258
|
-
node test/verify.js # 行为:真实 CLI + 真实 .openfeel 副本(
|
|
259
|
-
node test/guard.js # 写入门禁:fake ToolExecution + 临时工作区(
|
|
266
|
+
node test/contract.js # DSH 契约:schema 子集、无 type:null、参数契约(46 项)
|
|
267
|
+
node test/verify.js # 行为:真实 CLI + 真实 .openfeel 副本(112 项)
|
|
268
|
+
node test/guard.js # 写入门禁:fake ToolExecution + 临时工作区(138 项)
|
|
260
269
|
node test/integration.js # 真实注册表:真 cordis + 真 ToolRuntime 挂载(10 项)
|
|
261
270
|
```
|
|
262
271
|
|
|
263
272
|
- `contract.js` 用宿主 asar 提取出的**真实** `assertSupportedJsonSchema`。
|
|
264
273
|
- `verify.js` 对真实 OpenFeel 项目做只读校验,**所有写操作只打在 `os.tmpdir()` 副本上**,并断言原项目 `revision` 未被改动。
|
|
265
274
|
**前置条件**:当前项目必须至少有 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`),不影响发布门禁。
|
|
266
|
-
- `guard.js` 覆盖 `off/project/always`、`.openfeel/**` 产物、`exec_running`、general 需求、apply_patch 混合/无头/Move 同块、受保护路径、bootstrap
|
|
275
|
+
- `guard.js` 覆盖 `off/project/always`、`.openfeel/**` 产物、`exec_running`、general 需求、apply_patch 混合/无头/Move 同块、受保护路径、bootstrap 文案、shell 四类判定与 `OPENFEEL_SHELL_GATE` 三档等 138 条。
|
|
267
276
|
- `integration.js` 构造真实 Cordis 上下文 + 真实 `ToolRuntime`,调用适配器 `apply()`,断言 13 个工具真的完成注册与投影。
|
|
268
277
|
|
|
269
278
|
依赖提取:`contract.js` / `integration.js` 默认读 `%TEMP%\dsh-asar\dsh\node_modules\@deepseek-ai`(从宿主
|
|
@@ -329,9 +338,9 @@ dsh/ # OpenFeel 仓库内的一等适配器目录
|
|
|
329
338
|
6. **超时**:默认单次 120s。超大 `flow.json`(数百 KB)的 `flow status` 可能接近上限。
|
|
330
339
|
7. **不替代 agent 委派**:`feel_next` 给出负责 Agent 与 `[HANDOFF: agent]` 标记,实际派发
|
|
331
340
|
由 DSH 的 `subagent` / `workflow` 完成——DSH 没有 OpenFeel 的 `Task` 语义。
|
|
332
|
-
8.
|
|
333
|
-
`
|
|
334
|
-
`
|
|
341
|
+
8. **写入门禁覆盖文件工具 + shell(v1.5.11)**:`edit` / `write` / `apply_patch` / `str_replace_editor`
|
|
342
|
+
与 `bash` / `pwsh` 都受守;shell 按四类判定(见 §6.5)——第 1/2 类拒、第 3 类构建产物豁免、
|
|
343
|
+
第 4 类默认告警,可用 `OPENFEEL_SHELL_GATE=strict` 收紧、`=warn|off` 放宽(只影响 shell 分支)。
|
|
335
344
|
9. **默认 `enforce=always` 较激进**:所有工作区(含非 OpenFeel)都会拦截文件写入,直到
|
|
336
345
|
`openfeel init` 或用户把 profile 的 `enforce` 改为 `project` / `off`。适合“OpenFeel 必须启用”
|
|
337
346
|
的机器;普通试用建议 `project`。
|
package/dsh/cordis.patch.yml
CHANGED
|
@@ -29,12 +29,32 @@
|
|
|
29
29
|
# always = 所有工作区都注入完整 Feel 纪律
|
|
30
30
|
# off = 不注入任何提示
|
|
31
31
|
activation: auto
|
|
32
|
-
# 写入门禁(ctx.tools.guard
|
|
32
|
+
# 写入门禁(ctx.tools.guard)——三层:文件工具 / shell / 受保护路径。
|
|
33
33
|
# always = 所有工作区都拦截(默认;无 .openfeel 时也会拒绝写文件)
|
|
34
34
|
# project = 仅当会话工作区本身是 OpenFeel 项目时拦截
|
|
35
35
|
# off = 完全不注册 guard(含 flow.json/status.md 也不拦)
|
|
36
36
|
enforce: always
|
|
37
37
|
# general 需求在 in_progress 且无阶段时,允许源码写入(需求级例外)。
|
|
38
38
|
allowGeneral: true
|
|
39
|
-
#
|
|
40
|
-
#
|
|
39
|
+
# 会话工作区(可选,cwd 解析链第 3 环)。
|
|
40
|
+
# 完整链(取第一个可用值):
|
|
41
|
+
# ① OPENFEEL_GUARD_CWD(env,最高优先级逃生阀,非空即生效)
|
|
42
|
+
# ② agent.session.header.cwd(正常链路)
|
|
43
|
+
# ③ config.cwd(本项)
|
|
44
|
+
# ④ 会话登记表 [sessionId]
|
|
45
|
+
# ⑤ process.cwd()(仅当该目录本身含 .openfeel/)
|
|
46
|
+
# ⑥ 全部失败 → fail-closed 拒绝(绝不静默放行)
|
|
47
|
+
# 缺省不配即可;宿主升级拿不到会话 cwd 时,先设 OPENFEEL_GUARD_CWD 救急(无需改 profile),
|
|
48
|
+
# 再把项目绝对路径配在这里。非 ② 来源都会在 stderr 告警并在 feel_status.guard 里标 degraded。
|
|
49
|
+
# cwd: 'C:\path\to\OpenFeel'
|
|
50
|
+
# 默认受守卫的工具:edit / write / apply_patch / str_replace_editor / bash / pwsh
|
|
51
|
+
# (shell/execute_command/exec 本宿主不存在,仅作跨宿主防御)。
|
|
52
|
+
# shell(bash/pwsh)默认受守:可判定即拒(第 1 类受保护 / openfeel 写子命令、
|
|
53
|
+
# 第 2 类可解析的源码/文档写),**无法判定是否写(第 4 类)默认告警放行**
|
|
54
|
+
# —— op-005 起未识别命令不再静默当作「没有写」,审计 kind=undecidable 可查。
|
|
55
|
+
# shellGate 三档(缺省 = 上面这个默认组合;只影响 shell 分支,文件工具不受影响):
|
|
56
|
+
# strict = 第 4 类也拒;warn = 第 1/2/4 类全部告警放行;off = shell 完全不守。
|
|
57
|
+
# 环境变量 OPENFEEL_SHELL_GATE 优先级高于此处(排障逃生阀,取值同为 strict|warn|off)。
|
|
58
|
+
# **注意:本文件的 enforce / shellGate 是门禁自身的开关,已纳入受保护名单
|
|
59
|
+
# (PROTECTED_WORKSPACE_PATHS);agent 改不了,只能由人类在这里调整后重启宿主。**
|
|
60
|
+
# shellGate: strict
|