openfeel 1.5.9 → 1.5.11
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/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/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 +63 -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 +63 -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/template-loader.d.ts.map +1 -1
- package/dist/core/template-loader.js +19 -7
- package/dist/core/template-loader.js.map +1 -1
- package/dist/core/update.d.ts.map +1 -1
- package/dist/core/update.js +19 -7
- package/dist/core/update.js.map +1 -1
- package/dsh/ADAPTER.md +72 -13
- package/dsh/README.md +20 -11
- package/dsh/cordis.patch.yml +23 -3
- package/dsh/lib/adapters/guard-state.js +326 -0
- package/dsh/lib/adapters/session-cwd-registry.js +82 -0
- package/dsh/lib/adapters/workflow-gate.js +52 -2
- package/dsh/lib/adapters/workspace.js +4 -2
- package/dsh/lib/guard.js +2732 -206
- package/dsh/lib/index.js +48 -4
- package/dsh/lib/tools/index.js +54 -1
- package/dsh/package.json +2 -2
- package/package.json +1 -1
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
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 门禁自检状态(v1.5.11 D-126-04 / P0-4)
|
|
3
|
+
*
|
|
4
|
+
* 目的:让「门禁到底有没有生效、用哪个 cwd 判的、是不是旧进程/旧适配器」
|
|
5
|
+
* 成为**可查证据**,而不是靠「工具没报错」猜。两处落点:
|
|
6
|
+
*
|
|
7
|
+
* 1. 工作区:`<project>/.openfeel/dev/guard-state.json`
|
|
8
|
+
* 2. 全局:`os.tmpdir()/openfeel-guard/guard-state.json`
|
|
9
|
+
*
|
|
10
|
+
* **cwd 解析失败时必须落全局路径**(`root = null`):绝不用 `process.cwd()`
|
|
11
|
+
* (那会把宿主启动目录当成会话工作区,正是原 bug 的形态),也绝不静默丢弃——
|
|
12
|
+
* 那恰好是最需要证据的时刻。
|
|
13
|
+
*
|
|
14
|
+
* 失败策略:写盘失败要**出声**(stderr),但不阻塞判定(best-effort)。
|
|
15
|
+
* 读取顺序:工作区 → 全局(全局命中时 `source='global-fallback'`、`degraded=true`)。
|
|
16
|
+
*
|
|
17
|
+
* @module openfeel-dsh/guard-state
|
|
18
|
+
*/
|
|
19
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
20
|
+
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import { tmpdir } from 'node:os';
|
|
22
|
+
import { dirname, join } from 'node:path';
|
|
23
|
+
|
|
24
|
+
/** 文件 schema 版本(后续字段演进用)。 */
|
|
25
|
+
export const GUARD_STATE_SCHEMA_VERSION = 1;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 进程内 HMAC 密钥(op-005 / P1-6):**只在内存里**,绝不落盘、绝不写日志。
|
|
29
|
+
*
|
|
30
|
+
* 为什么需要:`guard-state.json` 是普通 JSON,agent 可以用 P0-1 的写通道整体重写它
|
|
31
|
+
* (伪造 `pid` / `lastDecision` / `stale` 三键),让 `feel_status` 显示「门禁正常」。
|
|
32
|
+
* 加一个只有**当前进程**知道的密钥签名后:
|
|
33
|
+
* - 本进程写的状态 → 校验通过;
|
|
34
|
+
* - 别的进程(含重启前的自己/被伪造的文件)写的状态 → 校验失败 → `stale: true`
|
|
35
|
+
* (文案「门禁状态被篡改或来自旧进程」)。
|
|
36
|
+
*
|
|
37
|
+
* 代价:跨进程共享时必然 stale —— 这恰好是「状态是否由**正在服务的进程**写出」的
|
|
38
|
+
* 正确语义,不是缺陷。
|
|
39
|
+
*/
|
|
40
|
+
const STATE_HMAC_KEY = randomBytes(32);
|
|
41
|
+
|
|
42
|
+
/** 递归稳定序列化(键排序),保证同一对象在写入/校验两侧得到同一字符串。 */
|
|
43
|
+
function stableStringify(value) {
|
|
44
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(',')}]`;
|
|
45
|
+
if (value !== null && typeof value === 'object') {
|
|
46
|
+
const keys = Object.keys(value).filter((key) => value[key] !== undefined).sort();
|
|
47
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(',')}}`;
|
|
48
|
+
}
|
|
49
|
+
return JSON.stringify(value) ?? 'null';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 计算状态签名(排除 `hmac` 与读取时附加的 `source`)。
|
|
54
|
+
* @param {Record<string, any>} state
|
|
55
|
+
* @returns {string}
|
|
56
|
+
*/
|
|
57
|
+
function signState(state) {
|
|
58
|
+
const { hmac: _hmac, source: _source, ...rest } = state;
|
|
59
|
+
return createHmac('sha256', STATE_HMAC_KEY).update(stableStringify(rest)).digest('hex');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 校验状态签名(op-005 / P1-6)。
|
|
64
|
+
* @param {Record<string, any> | null} state
|
|
65
|
+
* @returns {boolean}
|
|
66
|
+
*/
|
|
67
|
+
export function verifyGuardStateSignature(state) {
|
|
68
|
+
if (state === null || typeof state !== 'object') return false;
|
|
69
|
+
const actual = state.hmac;
|
|
70
|
+
if (typeof actual !== 'string' || actual === '') return false;
|
|
71
|
+
const expected = signState(state);
|
|
72
|
+
if (actual.length !== expected.length) return false;
|
|
73
|
+
try {
|
|
74
|
+
return timingSafeEqual(Buffer.from(actual, 'utf8'), Buffer.from(expected, 'utf8'));
|
|
75
|
+
} catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** 注册段字段(从全局文件播种到工作区文件时只带这些,避免把别的项目的 lastDecision 带进来)。 */
|
|
81
|
+
const REGISTRATION_KEYS = [
|
|
82
|
+
'schemaVersion',
|
|
83
|
+
'registered',
|
|
84
|
+
'enforce',
|
|
85
|
+
'shellGate',
|
|
86
|
+
'hostStartedAt',
|
|
87
|
+
'loaded_hash',
|
|
88
|
+
'pid',
|
|
89
|
+
'resolvedAt',
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 工作区 guard-state 路径。
|
|
94
|
+
* @param {string} root 项目根
|
|
95
|
+
* @returns {string}
|
|
96
|
+
*/
|
|
97
|
+
export function guardStatePath(root) {
|
|
98
|
+
return join(root, '.openfeel', 'dev', 'guard-state.json');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** 全局落点目录(cwd 不可解析时用)。 @returns {string} */
|
|
102
|
+
export function globalGuardDir() {
|
|
103
|
+
return join(tmpdir(), 'openfeel-guard');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** 全局 guard-state 路径。 @returns {string} */
|
|
107
|
+
export function globalGuardStatePath() {
|
|
108
|
+
return join(globalGuardDir(), 'guard-state.json');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 全局审计落点(`recordGuardAudit(null)` 用)。
|
|
113
|
+
*
|
|
114
|
+
* 与 guard.js 的 `.openfeel/log/guard-audit.jsonl` 同名同格式:
|
|
115
|
+
* cwd 解析失败时证据不会丢,只是换了目录。
|
|
116
|
+
* @returns {string}
|
|
117
|
+
*/
|
|
118
|
+
export function globalGuardAuditPath() {
|
|
119
|
+
return join(globalGuardDir(), 'guard-audit.jsonl');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 读一个 state 文件(缺失/损坏 → null)。
|
|
124
|
+
* @param {string} file
|
|
125
|
+
* @returns {Record<string, any> | null}
|
|
126
|
+
*/
|
|
127
|
+
function readStateFile(file) {
|
|
128
|
+
try {
|
|
129
|
+
const raw = JSON.parse(readFileSync(file, 'utf-8'));
|
|
130
|
+
return typeof raw === 'object' && raw !== null ? raw : null;
|
|
131
|
+
} catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 读取 guard-state(工作区优先,缺失/root=null 时回退全局)。
|
|
138
|
+
*
|
|
139
|
+
* @param {string | null} root 项目根(null = 只看全局)
|
|
140
|
+
* @returns {(Record<string, any> & { source: 'workspace'|'global-fallback' }) | null}
|
|
141
|
+
*/
|
|
142
|
+
export function readGuardState(root) {
|
|
143
|
+
if (typeof root === 'string' && root !== '') {
|
|
144
|
+
const workspace = readStateFile(guardStatePath(root));
|
|
145
|
+
if (workspace !== null) return { ...workspace, source: 'workspace' };
|
|
146
|
+
}
|
|
147
|
+
const global = readStateFile(globalGuardStatePath());
|
|
148
|
+
if (global !== null) return { ...global, source: 'global-fallback' };
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 写入 guard-state(best-effort;失败出声、不阻塞)。
|
|
154
|
+
*
|
|
155
|
+
* `root = null` → 固定写全局路径(**绝不**用 `process.cwd()`)。
|
|
156
|
+
* 工作区文件不存在时,用全局文件的注册段播种(registered/enforce/…),
|
|
157
|
+
* 这样第一次判定写出的工作区文件同样带自证三键。
|
|
158
|
+
*
|
|
159
|
+
* 失败时:stderr 打文件与原因;给了 `fallback`(at/tool/reason/cwdSource)时
|
|
160
|
+
* 再打两行结构化的判定现场 —— 「最需要证据的时候」绝不静默(D-126-04)。
|
|
161
|
+
*
|
|
162
|
+
* @param {string | null} root
|
|
163
|
+
* @param {Record<string, any>} patch
|
|
164
|
+
* @param {{ at?: string, tool?: string, reason?: string, decision?: string, cwdSource?: string } | null} [fallback]
|
|
165
|
+
* @returns {boolean} 是否写入成功
|
|
166
|
+
*/
|
|
167
|
+
export function writeGuardState(root, patch, fallback = null) {
|
|
168
|
+
const isGlobal = typeof root !== 'string' || root === '';
|
|
169
|
+
const file = isGlobal ? globalGuardStatePath() : guardStatePath(root);
|
|
170
|
+
try {
|
|
171
|
+
const globalRaw = readStateFile(globalGuardStatePath());
|
|
172
|
+
const workspaceRaw = isGlobal ? null : readStateFile(file);
|
|
173
|
+
const seed = globalRaw === null
|
|
174
|
+
? {}
|
|
175
|
+
: Object.fromEntries(REGISTRATION_KEYS.filter((key) => globalRaw[key] !== undefined).map((key) => [key, globalRaw[key]]));
|
|
176
|
+
const next = {
|
|
177
|
+
...seed,
|
|
178
|
+
...(workspaceRaw ?? {}),
|
|
179
|
+
...patch,
|
|
180
|
+
schemaVersion: GUARD_STATE_SCHEMA_VERSION,
|
|
181
|
+
source: undefined,
|
|
182
|
+
updatedAt: new Date().toISOString(),
|
|
183
|
+
};
|
|
184
|
+
delete next.source;
|
|
185
|
+
delete next.hmac;
|
|
186
|
+
next.hmac = signState(next);
|
|
187
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
188
|
+
const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
189
|
+
writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`, 'utf-8');
|
|
190
|
+
renameSync(tmp, file);
|
|
191
|
+
return true;
|
|
192
|
+
} catch (error) {
|
|
193
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
194
|
+
process.stderr.write(`[guard] guard-state-unavailable:${file}(${reason})\n`);
|
|
195
|
+
if (fallback !== null && typeof fallback === 'object') {
|
|
196
|
+
process.stderr.write(
|
|
197
|
+
`[guard] at=${fallback.at ?? ''} tool=${fallback.tool ?? ''} reason=${fallback.reason ?? ''}\n`,
|
|
198
|
+
);
|
|
199
|
+
process.stderr.write(`[guard] cwdSource=${fallback.cwdSource ?? ''} decision=${fallback.decision ?? ''}\n`);
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* 删除 guard-state / 全局审计(测试用)。
|
|
207
|
+
* @param {string | null} root
|
|
208
|
+
*/
|
|
209
|
+
export function clearGuardState(root) {
|
|
210
|
+
try {
|
|
211
|
+
if (typeof root === 'string' && root !== '') rmSync(guardStatePath(root), { force: true });
|
|
212
|
+
} catch {
|
|
213
|
+
/* ignore */
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
rmSync(globalGuardStatePath(), { force: true });
|
|
217
|
+
rmSync(globalGuardAuditPath(), { force: true });
|
|
218
|
+
} catch {
|
|
219
|
+
/* ignore */
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 可信度判定(op-005 / P1-6):返回不可信的原因,可信时返回 null。
|
|
225
|
+
*
|
|
226
|
+
* 顺序很重要 —— **先验签**:签名不过说明文件不是本进程写的(被 agent 重写、
|
|
227
|
+
* 或来自旧进程),后面所有自证字段都不可信,没必要再看。
|
|
228
|
+
*
|
|
229
|
+
* @param {Record<string, any> | null} state
|
|
230
|
+
* @param {Record<string, any> | null} hostMarker
|
|
231
|
+
* @param {number} pid
|
|
232
|
+
* @returns {{ reason: string, message?: string } | null}
|
|
233
|
+
*/
|
|
234
|
+
export function guardStateDistrust(state, hostMarker = null, pid = process.pid) {
|
|
235
|
+
if (state === null || typeof state !== 'object') return null;
|
|
236
|
+
if (!verifyGuardStateSignature(state)) {
|
|
237
|
+
return {
|
|
238
|
+
reason: 'hmac',
|
|
239
|
+
message: '门禁状态被篡改或来自旧进程(guard-state 签名校验失败):请重启宿主后确认 feel_status.guard.stale === false。',
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
if (!Number.isFinite(state.pid)) {
|
|
243
|
+
return {
|
|
244
|
+
reason: 'pid-missing',
|
|
245
|
+
message: '门禁状态缺少 pid(无法证明由当前进程写入):请重启宿主后确认 feel_status.guard.stale === false。',
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
if (state.pid !== pid) return { reason: 'pid' };
|
|
249
|
+
if (hostMarker === null || typeof hostMarker !== 'object') return null;
|
|
250
|
+
if (
|
|
251
|
+
typeof state.loaded_hash === 'string' && state.loaded_hash !== ''
|
|
252
|
+
&& typeof hostMarker.loaded_hash === 'string' && hostMarker.loaded_hash !== ''
|
|
253
|
+
&& state.loaded_hash !== hostMarker.loaded_hash
|
|
254
|
+
) return { reason: 'loaded-hash' };
|
|
255
|
+
const stateAt = Date.parse(state.hostStartedAt);
|
|
256
|
+
const markerAt = Date.parse(hostMarker.started_at);
|
|
257
|
+
if (Number.isFinite(stateAt) && Number.isFinite(markerAt) && stateAt < markerAt) return { reason: 'host-started-at' };
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* stale 判定(P0-4 / op-005 P1-6):状态不可信 → true。
|
|
263
|
+
*
|
|
264
|
+
* - **HMAC 校验失败** → 被篡改或来自旧进程(新增,防伪造);
|
|
265
|
+
* - **缺 `pid`** → 不可信(旧实现「无证据不冤枉」,但状态文件可被整体重写,
|
|
266
|
+
* 所以缺 pid 必须当 stale);
|
|
267
|
+
* - `pid` 与当前进程不符 → 状态来自旧进程;
|
|
268
|
+
* - `loaded_hash` 与标记不符 → 适配器文件已更新但宿主没重启;
|
|
269
|
+
* - `hostStartedAt` 早于标记的 `started_at` → 状态来自更早的宿主启动。
|
|
270
|
+
*
|
|
271
|
+
* @param {Record<string, any> | null} state
|
|
272
|
+
* @param {Record<string, any> | null} hostMarker
|
|
273
|
+
* @param {number} [pid]
|
|
274
|
+
* @returns {boolean}
|
|
275
|
+
*/
|
|
276
|
+
export function computeGuardStale(state, hostMarker, pid = process.pid) {
|
|
277
|
+
return guardStateDistrust(state, hostMarker, pid) !== null;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 组装 `feel_status` / `feel_next` 的 `guard` 段。
|
|
282
|
+
*
|
|
283
|
+
* 两处都缺 → `{ registered:false, cwd:null, cwdSource:null, stale:false }`(计划口径:
|
|
284
|
+
* 不再假装生效)。`live` 是调用方用**同一条 cwd 解析链**现算的结果,仅用于
|
|
285
|
+
* 填补「还没有第一条判定」时的显示空缺(状态里已有 cwd 时以状态为准)。
|
|
286
|
+
*
|
|
287
|
+
* @param {{ root: string | null, hostMarker?: Record<string, any> | null, pid?: number, live?: { cwd: string | null, source: string, degraded: boolean } | null }} input
|
|
288
|
+
* @returns {Record<string, any>}
|
|
289
|
+
*/
|
|
290
|
+
export function buildGuardSection({ root, hostMarker = null, pid = process.pid, live = null }) {
|
|
291
|
+
const state = readGuardState(root);
|
|
292
|
+
if (state === null) {
|
|
293
|
+
return { registered: false, cwd: null, cwdSource: null, stale: false };
|
|
294
|
+
}
|
|
295
|
+
const distrust = guardStateDistrust(state, hostMarker, pid);
|
|
296
|
+
const stale = distrust !== null;
|
|
297
|
+
const section = {
|
|
298
|
+
registered: state.registered === true,
|
|
299
|
+
enforce: typeof state.enforce === 'string' ? state.enforce : undefined,
|
|
300
|
+
shellGate: typeof state.shellGate === 'string' ? state.shellGate : undefined,
|
|
301
|
+
cwd: typeof state.cwd === 'string' && state.cwd !== '' ? state.cwd : null,
|
|
302
|
+
cwdSource: typeof state.cwdSource === 'string' && state.cwdSource !== '' ? state.cwdSource : null,
|
|
303
|
+
degraded: state.degraded === true || state.source === 'global-fallback',
|
|
304
|
+
resolvedAt: state.resolvedAt ?? null,
|
|
305
|
+
hostStartedAt: state.hostStartedAt ?? null,
|
|
306
|
+
loaded_hash: state.loaded_hash ?? null,
|
|
307
|
+
pid: Number.isFinite(state.pid) ? state.pid : null,
|
|
308
|
+
lastDecision: state.lastDecision ?? null,
|
|
309
|
+
stale,
|
|
310
|
+
// op-005 / P1-6:不可信的原因与文案(`hmac` = 被篡改或来自旧进程)。
|
|
311
|
+
...(stale ? { staleReason: distrust.reason, staleMessage: distrust.message ?? null } : {}),
|
|
312
|
+
source: state.source,
|
|
313
|
+
};
|
|
314
|
+
// 只在「还没有任何判定」时用现场解析填补显示。**已有 lastDecision 时以状态为准**:
|
|
315
|
+
// fail-closed 那次判定写的是 `cwd:null / unresolved`,如果这里用同类链再解析一次
|
|
316
|
+
// (比如落到 process/config 环)就会把「已 fail-closed」粉饰成正常 —— 那正是
|
|
317
|
+
// D-126-04 要杜绝的「静默失效」。
|
|
318
|
+
const hasDecision = state.lastDecision !== null && typeof state.lastDecision === 'object';
|
|
319
|
+
if (!hasDecision && section.cwd === null && live !== null && typeof live.cwd === 'string' && live.cwd !== '') {
|
|
320
|
+
section.cwd = live.cwd;
|
|
321
|
+
section.cwdSource = live.source;
|
|
322
|
+
section.degraded = live.degraded === true;
|
|
323
|
+
section.source = 'live-resolution';
|
|
324
|
+
}
|
|
325
|
+
return section;
|
|
326
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会话 → 工作区 cwd 登记表(v1.5.11 D-126-01 / P1-4)
|
|
3
|
+
*
|
|
4
|
+
* 目的:给写入门禁的 cwd 解析链补上第 3 环。**只按 `sessionId` 存**,
|
|
5
|
+
* 不存任何「进程级最近一次 cwd」(`registry-last`):后者在多窗口/多项目时
|
|
6
|
+
* 会跨项目串味——窗口 A 在 P1(`exec_running`)登记过,窗口 B 在 P2
|
|
7
|
+
* (`review_pending`)拿不到 cwd 时就会用 P1 的 cwd 去判 B 的写入,
|
|
8
|
+
* 等于「按别的项目放行」,比静默放行更危险(plan §D-126-01 P1-4)。
|
|
9
|
+
*
|
|
10
|
+
* 纪律:
|
|
11
|
+
* - 纯内存、零依赖、全 try/catch —— 登记失败绝不影响工具/提示主流程;
|
|
12
|
+
* - 上限 64,LRU 淘汰(`get` 也算一次使用);
|
|
13
|
+
* - 只有 `sessionId` 与 `cwd` 都非空才写入(写入点不产生误记)。
|
|
14
|
+
*
|
|
15
|
+
* @module openfeel-dsh/session-cwd-registry
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** 登记上限(LRU)。 */
|
|
19
|
+
export const CWD_REGISTRY_LIMIT = 64;
|
|
20
|
+
|
|
21
|
+
/** @type {Map<string, { cwd: string, at: number }>} */
|
|
22
|
+
const registry = new Map();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 登记 / 刷新某会话的工作区。
|
|
26
|
+
* @param {unknown} sessionId
|
|
27
|
+
* @param {unknown} cwd
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
30
|
+
export function touchSession(sessionId, cwd) {
|
|
31
|
+
try {
|
|
32
|
+
if (typeof sessionId !== 'string' || sessionId.trim() === '') return;
|
|
33
|
+
if (typeof cwd !== 'string' || cwd.trim() === '') return;
|
|
34
|
+
const key = sessionId.trim();
|
|
35
|
+
// 重新插入以刷新 LRU 顺序
|
|
36
|
+
registry.delete(key);
|
|
37
|
+
registry.set(key, { cwd: cwd.trim(), at: Date.now() });
|
|
38
|
+
while (registry.size > CWD_REGISTRY_LIMIT) {
|
|
39
|
+
const oldest = registry.keys().next().value;
|
|
40
|
+
if (oldest === undefined) break;
|
|
41
|
+
registry.delete(oldest);
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
/* 登记是观测手段,失败不影响主流程 */
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 读取某会话登记的工作区(命中即刷新 LRU 顺序)。
|
|
50
|
+
* @param {unknown} sessionId
|
|
51
|
+
* @returns {string | null}
|
|
52
|
+
*/
|
|
53
|
+
export function getSessionCwd(sessionId) {
|
|
54
|
+
try {
|
|
55
|
+
if (typeof sessionId !== 'string' || sessionId.trim() === '') return null;
|
|
56
|
+
const key = sessionId.trim();
|
|
57
|
+
const entry = registry.get(key);
|
|
58
|
+
if (entry === undefined) return null;
|
|
59
|
+
registry.delete(key);
|
|
60
|
+
registry.set(key, entry);
|
|
61
|
+
return entry.cwd;
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 当前登记的会话数(测试/诊断用)。
|
|
69
|
+
* @returns {number}
|
|
70
|
+
*/
|
|
71
|
+
export function cwdRegistrySize() {
|
|
72
|
+
return registry.size;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** 清空登记表(测试用)。 */
|
|
76
|
+
export function resetCwdRegistry() {
|
|
77
|
+
registry.clear();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* 与 plan §3.3 的命名对齐(两种名字同义,避免各调用点各写一套)。 */
|
|
81
|
+
export const recordSessionCwd = touchSession;
|
|
82
|
+
export const lookupSessionCwd = getSessionCwd;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 流程入口闸(v1.5.2;v1.5.7
|
|
2
|
+
* 流程入口闸(v1.5.2;v1.5.7 需求导向;v1.5.11 增加门禁自检)
|
|
3
3
|
*
|
|
4
4
|
* 目的:把「每个需求都要建/推进阶段」纠正为「阶段是版本容器、长期保持开启」。
|
|
5
|
-
* 无开启阶段时提示按当前小版本开一个(保持 exec_running),而不是把它当成一次性任务;
|
|
6
5
|
* 已开启阶段时不做任何催促(需求在阶段内完成,阶段关闭由用户在发布节点决定)。
|
|
7
6
|
*
|
|
7
|
+
* v1.5.11(D-126-04):若 `snapshot.guard` 显示门禁**自身**不可信
|
|
8
|
+
* (未注册 / cwd 解析失败 / 来自旧进程或旧适配器),优先提示它 —— 「门禁看着在跑
|
|
9
|
+
* 其实没生效」比「没开阶段」严重得多。**无 `guard` 字段时行为完全不变**(零回归)。
|
|
10
|
+
*
|
|
8
11
|
* 纯函数、无 IO;由工具层在读取快照后调用。
|
|
9
12
|
*/
|
|
10
13
|
|
|
@@ -13,6 +16,53 @@
|
|
|
13
16
|
* @returns {{ required: boolean, reason: string|null, message: string, actions: string[] }}
|
|
14
17
|
*/
|
|
15
18
|
export function computeWorkflowGate(snapshot) {
|
|
19
|
+
const guard = snapshot?.guard;
|
|
20
|
+
if (guard !== null && guard !== undefined && typeof guard === 'object') {
|
|
21
|
+
if (guard.registered === false) {
|
|
22
|
+
return {
|
|
23
|
+
required: true,
|
|
24
|
+
reason: 'guard-inactive',
|
|
25
|
+
message:
|
|
26
|
+
'写入门禁未生效(guard-state 缺失或 guard 未注册,例如 profile 的 enforce=off 或宿主未加载适配器):'
|
|
27
|
+
+ '当前对源码/文档的写入没有门禁保护。请重启宿主让适配器重新注册,或确认 enforce 不是 off。',
|
|
28
|
+
actions: [
|
|
29
|
+
'确认 profile(cordis.patch.yml)的 openfeel-feel.enforce 为 project 或 always',
|
|
30
|
+
'重启 DSH 宿主(guard 只在宿主启动时注册)',
|
|
31
|
+
'feel_status 的 guard 段应显示 registered:true;否则看 .openfeel/dev/guard-state.json 与 ~/.openfeel/adapter-host-dsh.json',
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (guard.cwd === null || guard.cwdSource === 'unresolved') {
|
|
36
|
+
return {
|
|
37
|
+
required: true,
|
|
38
|
+
reason: 'guard-cwd-unresolved',
|
|
39
|
+
message:
|
|
40
|
+
'写入门禁无法确定会话工作区(cwd 解析失败),已按 fail-closed 拒绝写入。'
|
|
41
|
+
+ '修复(任一):① profile 的 cordis.patch.yml 给 openfeel-feel 配 cwd: "<项目绝对路径>";'
|
|
42
|
+
+ '② 设环境变量 OPENFEEL_GUARD_CWD 后重启;③ 重启会话让提示装配登记 cwd。',
|
|
43
|
+
actions: [
|
|
44
|
+
'cordis.patch.yml 配 cwd: "<项目绝对路径>" 后重启',
|
|
45
|
+
'或设 OPENFEEL_GUARD_CWD=<项目绝对路径> 后重启',
|
|
46
|
+
'重启会话让提示装配写入会话 cwd 登记表',
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (guard.stale === true) {
|
|
51
|
+
return {
|
|
52
|
+
required: true,
|
|
53
|
+
reason: 'guard-stale',
|
|
54
|
+
message:
|
|
55
|
+
'门禁来自旧进程/旧适配器,判定不可信(适配器文件已更新但宿主仍加载旧模块,或状态来自更早的进程)。'
|
|
56
|
+
+ '请完全重启 DSH 宿主后再写入。',
|
|
57
|
+
actions: [
|
|
58
|
+
'完全重启 DSH 宿主(不是重载会话)',
|
|
59
|
+
'重启后确认 feel_status.guard.stale === false',
|
|
60
|
+
'确认 ~/.openfeel/adapter-host-dsh.json 的 loaded_hash 与 .openfeel/dev/guard-state.json 一致',
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
16
66
|
const phase = snapshot?.focus?.phase;
|
|
17
67
|
// v1.5.8:『开启阶段』= phase 非空且非 done。仅剩 done 阶段时同样要求开新阶段
|
|
18
68
|
// (此前 done 被当成活跃阶段,导致需求导向下永远不提示开阶段)。
|
|
@@ -34,10 +34,12 @@ export const OPENFEEL_DIR = '.openfeel';
|
|
|
34
34
|
*
|
|
35
35
|
* - `flow.json`:`openfeel init` 必然创建,是核心数据存储。
|
|
36
36
|
* - `config.yaml`:同为 `init` 产物(`flow.json` 被手工删除时的兜底判据)。
|
|
37
|
+
* - `stages` / `metrics.json`:op-005 / P2 —— `flow.json` 被删/搬走时,
|
|
38
|
+
* 仍有其它 init 产物可自证「这是 OpenFeel 项目」,避免误落 fail-closed 全拒。
|
|
37
39
|
*
|
|
38
|
-
* 全局家目录 `~/.openfeel/`
|
|
40
|
+
* 全局家目录 `~/.openfeel/` 这些都没有,因此不会被误判。
|
|
39
41
|
*/
|
|
40
|
-
export const PROJECT_MARKERS = /** @type {const} */ (['flow.json', 'config.yaml']);
|
|
42
|
+
export const PROJECT_MARKERS = /** @type {const} */ (['flow.json', 'config.yaml', 'stages', 'metrics.json']);
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* 从工具执行上下文解析会话工作区目录。
|