openfeel 1.5.13 → 1.5.15

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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/flow.d.ts.map +1 -1
  3. package/dist/commands/flow.js +138 -31
  4. package/dist/commands/flow.js.map +1 -1
  5. package/dist/core/flow-manager.d.ts +52 -1
  6. package/dist/core/flow-manager.d.ts.map +1 -1
  7. package/dist/core/flow-manager.js +117 -2
  8. package/dist/core/flow-manager.js.map +1 -1
  9. package/dist/core/i18n-data/en.d.ts.map +1 -1
  10. package/dist/core/i18n-data/en.js +8 -0
  11. package/dist/core/i18n-data/en.js.map +1 -1
  12. package/dist/core/i18n-data/zh-CN.d.ts.map +1 -1
  13. package/dist/core/i18n-data/zh-CN.js +9 -0
  14. package/dist/core/i18n-data/zh-CN.js.map +1 -1
  15. package/dist/core/preflight.d.ts +8 -0
  16. package/dist/core/preflight.d.ts.map +1 -1
  17. package/dist/core/preflight.js +25 -2
  18. package/dist/core/preflight.js.map +1 -1
  19. package/dist/core/process-health.d.ts +2 -2
  20. package/dist/core/process-health.d.ts.map +1 -1
  21. package/dist/core/process-health.js +4 -4
  22. package/dist/core/process-health.js.map +1 -1
  23. package/dist/core/template-loader.d.ts.map +1 -1
  24. package/dist/core/template-loader.js +18 -1
  25. package/dist/core/template-loader.js.map +1 -1
  26. package/dist/core/update.d.ts.map +1 -1
  27. package/dist/core/update.js +18 -1
  28. package/dist/core/update.js.map +1 -1
  29. package/dist/core/workspace/identity.d.ts +5 -3
  30. package/dist/core/workspace/identity.d.ts.map +1 -1
  31. package/dist/core/workspace/identity.js +36 -10
  32. package/dist/core/workspace/identity.js.map +1 -1
  33. package/dsh/ADAPTER.md +9 -2
  34. package/dsh/lib/adapters/cli.js +15 -0
  35. package/dsh/lib/adapters/dashboard.js +8 -1
  36. package/dsh/lib/adapters/preflight.js +23 -1
  37. package/dsh/lib/guard.js +75 -4
  38. package/dsh/lib/surface/prompt.js +1 -1
  39. package/dsh/lib/tools/index.js +1 -1
  40. package/dsh/package.json +2 -2
  41. package/package.json +1 -1
@@ -404,6 +404,13 @@ export function planNextStep(snapshot) {
404
404
  ? focus.suggestedCommand
405
405
  : `openfeel flow advance --stage ${stage} --to <${nextPhases[0] ?? 'phase'}>`;
406
406
 
407
+ // v1.5.14 / OF-06.3:toolCall 跟随 CLI 权威 `suggestedCommand` 的 `--to <phase>`;
408
+ // 解析不到或不在合法相位内才回退 `nextPhases[0]`(形状不变)。
409
+ const suggestedMatch = /--to\s+(\S+)/.exec(cliCommand);
410
+ const suggestedTo = suggestedMatch !== null && nextPhases.includes(suggestedMatch[1])
411
+ ? suggestedMatch[1]
412
+ : null;
413
+
407
414
  return {
408
415
  phase,
409
416
  stage,
@@ -421,7 +428,7 @@ export function planNextStep(snapshot) {
421
428
  cli: cliCommand,
422
429
  toolCall: nextPhases.length === 0
423
430
  ? null
424
- : { tool: 'feel_flow', arguments: { action: 'advance', stage, to: nextPhases[0] } },
431
+ : { tool: 'feel_flow', arguments: { action: 'advance', stage, to: suggestedTo ?? nextPhases[0] } },
425
432
  /** OpenFeel 的交接标记;DSH 侧建议配合 `subagent` 工具派发。 */
426
433
  handoff: agent === 'none' || agent === 'unknown' ? null : `[HANDOFF: ${agent}]`,
427
434
  };
@@ -2,12 +2,34 @@
2
2
  * Preflight 状态(v1.5.5,适配器只读)
3
3
  *
4
4
  * 与 CLI `.openfeel/dev/.preflight.json` 同源;供 feel_status/feel_next 暴露是否已读过状态。
5
+ *
6
+ * v1.5.14:账本窗口与 CLI 同语义读 `OPENFEEL_PREFLIGHT_MAX_AGE_MS`
7
+ * (仅正整数生效,缺省 10 分钟),避免长构建后适配器视图与 `flow health` / 写门漂移。
5
8
  */
6
9
  import { existsSync, readFileSync } from 'node:fs';
7
10
  import { join } from 'node:path';
8
11
 
9
12
  export const PREFLIGHT_MAX_AGE_MS = 10 * 60_000;
10
13
 
14
+ /** 解析正整数;非字符串 / 空 / 非数字 / ≤0 / 非整数 → null(回退默认)。 */
15
+ function parsePositiveInteger(raw) {
16
+ if (typeof raw !== 'string') return null;
17
+ const text = raw.trim();
18
+ if (text === '') return null;
19
+ const value = Number(text);
20
+ if (!Number.isFinite(value) || value <= 0 || !Number.isInteger(value)) return null;
21
+ return value;
22
+ }
23
+
24
+ /**
25
+ * 账本有效期(毫秒)——与 `src/core/preflight.ts:getPreflightMaxAgeMs` 同一语义。
26
+ * @param {NodeJS.ProcessEnv} [env]
27
+ * @returns {number}
28
+ */
29
+ export function getPreflightMaxAgeMs(env = process.env) {
30
+ return parsePositiveInteger(env?.OPENFEEL_PREFLIGHT_MAX_AGE_MS) ?? PREFLIGHT_MAX_AGE_MS;
31
+ }
32
+
11
33
  /**
12
34
  * @param {string} projectRoot
13
35
  * @param {number} [now]
@@ -23,7 +45,7 @@ export function readPreflightInfo(projectRoot, now = Date.now()) {
23
45
  const at = Date.parse(raw.at);
24
46
  if (!Number.isFinite(at)) return { ok: false, at: raw.at, ageMs: null, mode };
25
47
  const ageMs = now - at;
26
- return { ok: ageMs <= PREFLIGHT_MAX_AGE_MS, at: raw.at, ageMs, mode };
48
+ return { ok: ageMs <= getPreflightMaxAgeMs(), at: raw.at, ageMs, mode };
27
49
  } catch {
28
50
  return { ok: false, at: null, ageMs: null, mode };
29
51
  }
package/dsh/lib/guard.js CHANGED
@@ -118,6 +118,43 @@ export function resolveShellGate(raw) {
118
118
  };
119
119
  }
120
120
 
121
+ /**
122
+ * `OPENFEEL_SHELL_ALLOW` 白名单解析(v1.5.14 / stage-129 OF-05)。
123
+ *
124
+ * `||` 分隔多条;条目与命令在比较前都折叠空白、去首尾。只用于第 4 类
125
+ * `undecidable` 出口,且必须**整条命令全等**——绝不做子串匹配:否则白名单
126
+ * `npm run build` 会把 `rm -rf x && npm run build` 一起放行。
127
+ *
128
+ * @param {unknown} [raw]
129
+ * @returns {string[]}
130
+ */
131
+ function parseShellAllowlist(raw = process.env.OPENFEEL_SHELL_ALLOW) {
132
+ if (typeof raw !== 'string' || raw.trim() === '') return [];
133
+ return raw
134
+ .split('||')
135
+ .map((entry) => entry.replace(/\s+/g, ' ').trim())
136
+ .filter((entry) => entry !== '');
137
+ }
138
+
139
+ /** 命令与白名单条目共用的归一化:折叠连续空白 + 去首尾。 */
140
+ function collapseShellWhitespace(value) {
141
+ return String(value).replace(/\s+/g, ' ').trim();
142
+ }
143
+
144
+ /**
145
+ * 命令是否命中 `OPENFEEL_SHELL_ALLOW`(整条全等;空命令永不命中)。
146
+ *
147
+ * @param {string} command
148
+ * @param {string[]} entries
149
+ * @returns {boolean}
150
+ */
151
+ function isShellAllowlisted(command, entries) {
152
+ if (entries.length === 0 || typeof command !== 'string') return false;
153
+ const normalized = collapseShellWhitespace(command);
154
+ if (normalized === '') return false;
155
+ return entries.some((entry) => entry === normalized);
156
+ }
157
+
121
158
  /**
122
159
  * 大小写不敏感文件系统:Windows + 默认 macOS(APFS/HFS+)。
123
160
  * 在这两类平台上把路径统一小写,防止 `.OPENFEEL/FLOW.JSON` 绕过。
@@ -412,12 +449,16 @@ export function isExemptPath(absolute, cwd) {
412
449
  }
413
450
 
414
451
  /**
415
- * 审计里的命令片段(v1.5.11 D-126-02):折叠空白并截断到 200 字符。
452
+ * 审计里的命令片段(v1.5.11 D-126-02):折叠空白并截断到 500 字符。
453
+ *
454
+ * v1.5.14 / stage-129 OF-08.1:上限 200 → 500。`lastDecision`
455
+ * (`.openfeel/dev/guard-state.json`)与审计(`guard-audit.jsonl`)**共用**该上限
456
+ * (两处都走本函数,没有第二份截断逻辑);长命令的排查信息不再被腰斩。
416
457
  * @param {unknown} command
417
458
  * @param {number} [limit]
418
459
  * @returns {string | undefined}
419
460
  */
420
- function truncateCommand(command, limit = 200) {
461
+ function truncateCommand(command, limit = 500) {
421
462
  if (typeof command !== 'string') return undefined;
422
463
  const value = command.replace(/\s+/g, ' ').trim();
423
464
  if (value === '') return undefined;
@@ -432,10 +473,10 @@ function truncateCommand(command, limit = 200) {
432
473
  * —— 那恰好是最需要证据的时刻。写失败也出声(stderr)。
433
474
  *
434
475
  * 每行必须带 `cwdSource`(验收 14)与 `decision`(allow|deny|warn);shell 行
435
- * 额外带 `command`(截断 ≤200 字符),否则「门禁是否真的拦过」无法自证。
476
+ * 额外带 `command`(截断 ≤500 字符,v1.5.14 / stage-129 OF-08.1),否则「门禁是否真的拦过」无法自证。
436
477
  *
437
478
  * @param {string | null} cwd 已归一化工作区(null = 不可解析)
438
- * @param {{ event?: 'guard_allow'|'guard_deny'|'guard_shell_unresolved'|'guard_shell_downgraded', decision?: 'allow'|'deny'|'warn', tool: string, reason: string, phase: string, paths: string[], cwdSource?: string, command?: string }} event
479
+ * @param {{ event?: 'guard_allow'|'guard_deny'|'guard_shell_unresolved'|'guard_shell_downgraded'|'guard_shell_allowlisted', decision?: 'allow'|'deny'|'warn', tool: string, reason: string, phase: string, paths: string[], cwdSource?: string, command?: string }} event
439
480
  */
440
481
  function recordGuardAudit(cwd, event) {
441
482
  const entry = {
@@ -3305,6 +3346,15 @@ export function createOpenFeelGuard(options = {}) {
3305
3346
  /** 第 4 类:默认告警放行 + 审计 + stderr 一行;`strict` 下拒绝。 */
3306
3347
  const undecidableShell = (detail, paths) => {
3307
3348
  const reason = 'shell-undecidable';
3349
+ // v1.5.14 / stage-129 OF-05:`OPENFEEL_SHELL_ALLOW` 是**用户显式配置**的整条
3350
+ // 命令白名单,只挂在这一类出口上(第 1/2 类 deny 永不触达)。整条全等才算命中
3351
+ // —— 子串匹配会让 `rm -rf x && npm run build` 被白名单 `npm run build` 顺带放行。
3352
+ // `strict` 下同样放行(这是用户显式声明的例外,不是门禁降级)。
3353
+ if (isShellAllowlisted(command, parseShellAllowlist())) {
3354
+ recordShellAudit({ event: 'guard_shell_allowlisted', decision: 'allow', reason: 'shell-allowlisted', paths });
3355
+ recordDecision('allow', { reason: 'shell-allowlisted', paths });
3356
+ return undefined;
3357
+ }
3308
3358
  if (shellGate.undecidable === 'deny') {
3309
3359
  recordShellAudit({ event: 'guard_deny', decision: 'deny', reason, paths });
3310
3360
  recordDecision('deny', { reason, paths });
@@ -3366,6 +3416,27 @@ export function createOpenFeelGuard(options = {}) {
3366
3416
  && flow.ok === true;
3367
3417
  const scope = canBeBookkeeping ? inspectCommitBookkeeping(resolvedCwd, baseDir) : null;
3368
3418
  if (scope !== null && scope.ok === true) return allowShell('git-commit-bookkeeping', []);
3419
+ // v1.5.14 / stage-129 OF-04:归档收尾提交(idle commit)。
3420
+ //
3421
+ // 版本归档 / 收口后只剩「done 阶段」或「无阶段」,涉 docs/源码的收尾提交
3422
+ // 原本无处可走(书账窄口只认纯 `.openfeel/**`)。这里开一道**窄于四相位门**
3423
+ // 的通道,条件同样缺一不可(见 plan R1):
3424
+ // ① 与书账窄口同源的命令/项目条件(单条直连 commit、无 -C/-c、可判定、
3425
+ // 项目工作区、flow 可读);
3426
+ // ② **无任何活跃阶段**(`activeStages` 空);
3427
+ // ③ `stages` 是空集 **或** `pipeline.phase === 'done'` —— 「done 阶段但
3428
+ // pipeline 仍在跑」不满足(既有 done 负例夹具正是这种形态,仍拒);
3429
+ // ④ 实际生效仓库根 = 项目工作区(`repoMismatch !== true`)。待提交路径里的
3430
+ // offender **不构成拒绝**:这是收尾提交,本来就要提交 src/docs。
3431
+ const idleEligible = canBeBookkeeping
3432
+ && activeStages(flow.value).length === 0
3433
+ && (
3434
+ Object.keys(flow.value?.stages ?? {}).length === 0
3435
+ || flow.value?.pipeline?.phase === 'done'
3436
+ );
3437
+ if (idleEligible && scope !== null && scope.repoMismatch !== true) {
3438
+ return allowShell('git-commit-idle', []);
3439
+ }
3369
3440
  // v1.5.13 / stage-128:文案按子命令分叉,相位串从 `classification.phases`
3370
3441
  // 派生(单一真值,防数组与文案两处漂移)。**必须保留**「git 工作区写」字样
3371
3442
  // (既有断言 `/git 工作区写/`),非 commit 的通用文案逐字保留(stash/clean/
@@ -148,7 +148,7 @@ Feel(你)只做编排、决策与门禁判断。
148
148
 
149
149
  ## 写命令与 preflight(v1.5.5)
150
150
  - **状态写操作只能用 \`feel_*\` 工具**(\`feel_flow\` / \`feel_stage\` / \`feel_req\`);禁止用 shell 跑 \`openfeel flow/stage/req\` 写命令——那会绕过适配器与 preflight。
151
- - **先读后写**:核心写命令(advance / stage add / req add / claim)要求 10 分钟内调用过 \`feel_status\` / \`feel_next\`;遇到 preflight 拒绝先 \`feel_status\` 再重试。
151
+ - **先读后写**:核心写命令(advance / stage add / req add / claim)要求窗口内调用过 \`feel_status\` / \`feel_next\`(缺省 10 分钟;长构建可用 \`OPENFEEL_PREFLIGHT_MAX_AGE_MS\` 显式放宽);遇到 preflight 拒绝先 \`feel_status\` 再重试。适配器会在账本过期时为你真实读一次状态,但**不要**依赖它跳过读状态。
152
152
  - **审查独立**:fast 单轮审查也应由独立 reviewer 完成;Feel 自审必须在 REV 标题标注 \`self-review\`,归档摘要记录原因。
153
153
 
154
154
  ## 需求导向与流程入口(v1.5.7)
@@ -741,7 +741,7 @@ export function createTools(context) {
741
741
  parameters: {
742
742
  action: stringEnum(['list', 'create', 'publish', 'rename', 'remove', 'register', 'attempt', 'retry'], '操作。', { required: true }),
743
743
  stage: string('阶段 ID。除 retry 外必需。'),
744
- op: string('操作 ID(如 op-001,或 attempt/retry 用的完整 ID v1.2.1-stage-93.op-001)。'),
744
+ op: string('操作 ID:完整 ID `<stage>.op-001`,或阶段内短 ID `op-001`(当前阶段优先;歧义/未找到会列候选并报错)。'),
745
745
  title: string('方案标题(create/rename)。'),
746
746
  result: stringEnum(['pass', 'fail'], 'attempt 的执行结果。'),
747
747
  project: string('项目根目录。'),
package/dsh/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfeel-dsh",
3
- "version": "1.5.13",
3
+ "version": "1.5.15",
4
4
  "description": "OpenFeel × DSH — Feel 模式适配器:把 OpenFeel 的流水线、需求分发、版本归档与知识库接入 DeepSeek Harness",
5
5
  "type": "module",
6
6
  "private": true,
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "openfeel": {
35
35
  "adapter": "dsh",
36
- "requiresCli": ">=1.5.13"
36
+ "requiresCli": ">=1.5.15"
37
37
  },
38
38
  "keywords": [
39
39
  "openfeel",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfeel",
3
- "version": "1.5.13",
3
+ "version": "1.5.15",
4
4
  "description": "AI Agent 开发流程治理 CLI 工具",
5
5
  "type": "module",
6
6
  "private": false,