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.
Files changed (55) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/index.d.ts.map +1 -1
  3. package/dist/cli/index.js +2 -0
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/commands/chore.d.ts +7 -0
  6. package/dist/commands/chore.d.ts.map +1 -1
  7. package/dist/commands/chore.js +43 -3
  8. package/dist/commands/chore.js.map +1 -1
  9. package/dist/commands/dashboard.d.ts +42 -0
  10. package/dist/commands/dashboard.d.ts.map +1 -0
  11. package/dist/commands/dashboard.js +170 -0
  12. package/dist/commands/dashboard.js.map +1 -0
  13. package/dist/commands/flow.d.ts +8 -0
  14. package/dist/commands/flow.d.ts.map +1 -1
  15. package/dist/commands/flow.js +2 -1
  16. package/dist/commands/flow.js.map +1 -1
  17. package/dist/commands/shared/json-output.d.ts.map +1 -1
  18. package/dist/commands/shared/json-output.js +1 -0
  19. package/dist/commands/shared/json-output.js.map +1 -1
  20. package/dist/core/dashboard/aggregate.d.ts +146 -0
  21. package/dist/core/dashboard/aggregate.d.ts.map +1 -0
  22. package/dist/core/dashboard/aggregate.js +231 -0
  23. package/dist/core/dashboard/aggregate.js.map +1 -0
  24. package/dist/core/dashboard/render.d.ts +12 -0
  25. package/dist/core/dashboard/render.d.ts.map +1 -0
  26. package/dist/core/dashboard/render.js +506 -0
  27. package/dist/core/dashboard/render.js.map +1 -0
  28. package/dist/core/i18n-data/en.d.ts +6 -0
  29. package/dist/core/i18n-data/en.d.ts.map +1 -1
  30. package/dist/core/i18n-data/en.js +63 -1
  31. package/dist/core/i18n-data/en.js.map +1 -1
  32. package/dist/core/i18n-data/zh-CN.d.ts +6 -0
  33. package/dist/core/i18n-data/zh-CN.d.ts.map +1 -1
  34. package/dist/core/i18n-data/zh-CN.js +63 -1
  35. package/dist/core/i18n-data/zh-CN.js.map +1 -1
  36. package/dist/core/i18n.js +4 -4
  37. package/dist/core/i18n.js.map +1 -1
  38. package/dist/core/template-loader.d.ts.map +1 -1
  39. package/dist/core/template-loader.js +19 -7
  40. package/dist/core/template-loader.js.map +1 -1
  41. package/dist/core/update.d.ts.map +1 -1
  42. package/dist/core/update.js +19 -7
  43. package/dist/core/update.js.map +1 -1
  44. package/dsh/ADAPTER.md +72 -13
  45. package/dsh/README.md +20 -11
  46. package/dsh/cordis.patch.yml +23 -3
  47. package/dsh/lib/adapters/guard-state.js +326 -0
  48. package/dsh/lib/adapters/session-cwd-registry.js +82 -0
  49. package/dsh/lib/adapters/workflow-gate.js +52 -2
  50. package/dsh/lib/adapters/workspace.js +4 -2
  51. package/dsh/lib/guard.js +2732 -206
  52. package/dsh/lib/index.js +48 -4
  53. package/dsh/lib/tools/index.js +54 -1
  54. package/dsh/package.json +2 -2
  55. package/package.json +1 -1
package/dsh/lib/index.js CHANGED
@@ -29,7 +29,9 @@ import { fileURLToPath } from 'node:url';
29
29
  import { FeelCli } from './adapters/cli.js';
30
30
  import { resolveWorkspace } from './adapters/workspace.js';
31
31
  import { writeHostMarker } from './adapters/host-state.js';
32
- import { createOpenFeelGuard } from './guard.js';
32
+ import { writeGuardState } from './adapters/guard-state.js';
33
+ import { touchSession } from './adapters/session-cwd-registry.js';
34
+ import { createOpenFeelGuard, resolveShellGate } from './guard.js';
33
35
  import { createFeelCommandHandler } from './surface/command.js';
34
36
  import { FEEL_PROMPT_NAME, FEEL_PROMPT_ORDER, renderBootstrapPrompt, renderFeelPrompt } from './surface/prompt.js';
35
37
  import { createTools } from './tools/index.js';
@@ -57,7 +59,7 @@ const COMMAND_ID = '@openfeel/dsh/feel';
57
59
  * - `log: false`(不写 `~/.openfeel/cli/logs/`,避免只读沙箱下失败)。
58
60
  *
59
61
  * @param {Record<string, any> | undefined} raw Loader 传入的配置。
60
- * @returns {{ command: string, commandPrefix: string[], timeoutMs: number, log: boolean, autoPrompt: boolean, activation: 'auto'|'always'|'off', language: string, cwd: string | undefined, enforce: 'off'|'project'|'always', mutatingTools: string[], allowGeneral: boolean }}
62
+ * @returns {{ command: string, commandPrefix: string[], timeoutMs: number, log: boolean, autoPrompt: boolean, activation: 'auto'|'always'|'off', language: string, cwd: string | undefined, enforce: 'off'|'project'|'always', mutatingTools: string[], allowGeneral: boolean, shellGate: 'strict'|'warn'|'off'|undefined }}
61
63
  */
62
64
  export function normalizeConfig(raw) {
63
65
  const source = typeof raw === 'object' && raw !== null ? raw : {};
@@ -69,9 +71,17 @@ export function normalizeConfig(raw) {
69
71
  const enforce = source.enforce === 'off' || source.enforce === 'project' || source.enforce === 'always'
70
72
  ? source.enforce
71
73
  : 'always';
74
+ // v1.5.11 D-126-02:默认列表必须与 `guard.js` 的 `DEFAULT_MUTATING_TOOLS` **逐项同步**,
75
+ // 否则 profile 传空数组会回落到旧列表(pwsh/bash 不受守)。`shell`/`execute_command`/`exec`
76
+ // 本宿主不存在,只是跨宿主防御条目。
72
77
  const mutatingTools = Array.isArray(source.mutatingTools)
73
78
  ? source.mutatingTools.filter((item) => typeof item === 'string' && item !== '')
74
- : ['edit', 'write', 'apply_patch', 'str_replace_editor'];
79
+ : ['edit', 'write', 'apply_patch', 'str_replace_editor', 'bash', 'pwsh', 'shell', 'execute_command', 'exec'];
80
+ // shell 门禁档位(v1.5.11 D-126-02):`strict` / `warn` / `off` 透传;未设 = 默认组合
81
+ // (1/2 类拒、4 类告警)。运行时 `OPENFEEL_SHELL_GATE` 优先(见 guard.js)。
82
+ const shellGate = source.shellGate === 'strict' || source.shellGate === 'warn' || source.shellGate === 'off'
83
+ ? source.shellGate
84
+ : undefined;
75
85
  return {
76
86
  command: typeof source.command === 'string' && source.command !== '' ? source.command : 'openfeel',
77
87
  commandPrefix,
@@ -84,6 +94,7 @@ export function normalizeConfig(raw) {
84
94
  enforce,
85
95
  mutatingTools,
86
96
  allowGeneral: source.allowGeneral !== false,
97
+ shellGate,
87
98
  };
88
99
  }
89
100
 
@@ -116,6 +127,8 @@ function currentAgent(ctx) {
116
127
  export function apply(ctx, rawConfig) {
117
128
  const config = normalizeConfig(rawConfig);
118
129
 
130
+ /** 本宿主加载标记(D-126-04 自证三键的来源之一:started_at / loaded_hash 同源同值)。 */
131
+ let hostMarker = null;
119
132
  // v1.3.4:记录「本宿主实际加载的适配器指纹」,供 `openfeel setup --check` 区分
120
133
  // 「文件旧」与「文件已新但宿主未重启」。best-effort:失败不影响挂载。
121
134
  try {
@@ -127,7 +140,7 @@ export function apply(ctx, rawConfig) {
127
140
  } catch {
128
141
  /* package.json 不可读时保持占位版本 */
129
142
  }
130
- writeHostMarker({ adapterRoot, version: adapterVersion });
143
+ hostMarker = writeHostMarker({ adapterRoot, version: adapterVersion });
131
144
  } catch {
132
145
  /* 标记写入失败 → CLI check 会提示 restart-required,可操作,不阻塞 */
133
146
  }
@@ -167,6 +180,7 @@ export function apply(ctx, rawConfig) {
167
180
  allowGeneral: config.allowGeneral,
168
181
  language: config.language,
169
182
  cwd: config.cwd,
183
+ shellGate: config.shellGate,
170
184
  }));
171
185
  if (typeof ctx.effect === 'function') {
172
186
  ctx.effect(registerGuard);
@@ -177,6 +191,32 @@ export function apply(ctx, rawConfig) {
177
191
  }
178
192
  }
179
193
 
194
+ /* ── 门禁自检状态(v1.5.11 D-126-04) ──────────────────── */
195
+
196
+ // 注册段写一次:registered / enforce / shellGate / cwd / cwdSource / degraded /
197
+ // resolvedAt + 自证三键(hostStartedAt / loaded_hash / pid,与宿主标记同源同值)。
198
+ // 启动期还不知道会话 cwd:profile 未配 cwd 时写 `null` → **固定落
199
+ // `os.tmpdir()/openfeel-guard/guard-state.json`**,绝不用 `process.cwd()`
200
+ // (那会把宿主启动目录误当会话工作区,正是原 bug 的形态)。
201
+ const gate = resolveShellGate(
202
+ typeof process.env.OPENFEEL_SHELL_GATE === 'string' && process.env.OPENFEEL_SHELL_GATE.trim() !== ''
203
+ ? process.env.OPENFEEL_SHELL_GATE
204
+ : config.shellGate,
205
+ );
206
+ const guardRegistered = config.enforce !== 'off' && typeof ctx.tools.guard === 'function';
207
+ writeGuardState(config.cwd ?? null, {
208
+ registered: guardRegistered,
209
+ enforce: config.enforce,
210
+ shellGate: gate.label,
211
+ cwd: config.cwd ?? null,
212
+ cwdSource: config.cwd === undefined ? 'unresolved' : 'config',
213
+ degraded: config.cwd === undefined,
214
+ resolvedAt: new Date().toISOString(),
215
+ hostStartedAt: hostMarker?.started_at ?? new Date().toISOString(),
216
+ loaded_hash: hostMarker?.loaded_hash ?? '',
217
+ pid: process.pid,
218
+ });
219
+
180
220
  /* ── 人类命令面 ─────────────────────────────────────────── */
181
221
 
182
222
  ctx.commands.register({
@@ -203,6 +243,10 @@ export function apply(ctx, rawConfig) {
203
243
  text: () => {
204
244
  const agent = currentAgent(ctx);
205
245
  const sessionCwd = agent?.session?.header?.cwd;
246
+ // v1.5.11 D-126-01 登记点 ①:提示装配时把会话 cwd 写进登记表,供门禁在
247
+ // `agent.session.header.cwd` 缺失时兜底(第 3 环)。只有 sessionId 与 cwd
248
+ // 都非空才写 —— 写入点本身不产生「当前 agent ≈ 所有会话」的误记。
249
+ touchSession(agent?.session?.id, sessionCwd);
206
250
  // 拿不到会话且没有显式 cwd 配置 → 不注入(宁可不打扰,也不给错的项目)。
207
251
  if ((typeof sessionCwd !== 'string' || sessionCwd === '') && config.cwd === undefined) return '';
208
252
 
@@ -19,6 +19,10 @@ import { readRecovery } from '../adapters/recovery.js';
19
19
  import { readPreflightInfo } from '../adapters/preflight.js';
20
20
  import { buildObservability } from '../adapters/observability.js';
21
21
  import { computeWorkflowGate } from '../adapters/workflow-gate.js';
22
+ import { buildGuardSection } from '../adapters/guard-state.js';
23
+ import { readHostMarker } from '../adapters/host-state.js';
24
+ import { resolveGuardCwd } from '../guard.js';
25
+ import { touchSession as touchSessionCwd } from '../adapters/session-cwd-registry.js';
22
26
  import { resolveWorkspace } from '../adapters/workspace.js';
23
27
  // v1.5.8 / REQ-029:多会话登记(与 CLI `.openfeel/dev/sessions.json` 同一文件格式)
24
28
  import { readSessions as readSessionEntries, touchSession as touchSessionFile } from '../adapters/sessions.js';
@@ -180,6 +184,9 @@ export function compactStatusSnapshot(snapshot) {
180
184
  stages: snapshot?.stages ?? [],
181
185
  statusSync: snapshot?.statusSync ?? null,
182
186
  workflowGate: snapshot?.workflowGate ?? null,
187
+ // v1.5.11 D-126-04:门禁自检段(registered / cwd / cwdSource / degraded / stale /
188
+ // lastDecision);compact 档同样带,否则「门禁是否生效」在默认档看不见。
189
+ guard: snapshot?.guard ?? null,
183
190
  preflight: snapshot?.preflight ?? null,
184
191
  recovery: {
185
192
  stage: recovery.stage ?? null,
@@ -203,6 +210,31 @@ export function compactStatusSnapshot(snapshot) {
203
210
  return compact;
204
211
  }
205
212
 
213
+ /**
214
+ * 门禁自检段的摘要告警(v1.5.11 D-126-04):让「门禁没生效 / 判定不可信 /
215
+ * cwd 降级」在 summary 里一眼可见,而不是藏在 JSON 深处。
216
+ * @param {Record<string, any> | null | undefined} guard
217
+ * @returns {string}
218
+ */
219
+ function guardWarnings(guard) {
220
+ if (guard === null || guard === undefined) return '';
221
+ if (guard.registered === false) {
222
+ return '⚠ 写入门禁未生效(guard-state 缺失或 guard 未注册),源码写入当前无门禁保护。';
223
+ }
224
+ if (guard.stale === true) {
225
+ // op-005 / P1-6:stale 也可能是「guard-state 被整体重写」(HMAC 校验失败),
226
+ // 文案要把「篡改」说清楚,不能只怪旧进程。
227
+ if (guard.staleReason === 'hmac') {
228
+ return '⚠ 门禁状态被篡改或来自旧进程(guard-state 签名校验失败),判定不可信;请重启宿主后确认 feel_status.guard.stale === false。';
229
+ }
230
+ return '⚠ 门禁来自旧进程/旧适配器,判定不可信,请重启宿主后再写入。';
231
+ }
232
+ if (guard.degraded === true && typeof guard.cwdSource === 'string' && guard.cwdSource !== 'agent-session') {
233
+ return `⚠ 门禁 cwd 为降级来源(cwdSource=${guard.cwdSource}),请核对 guard 段。`;
234
+ }
235
+ return '';
236
+ }
237
+
206
238
  /**
207
239
  * 构造全部工具定义。
208
240
  *
@@ -270,6 +302,15 @@ export function createTools(context) {
270
302
  });
271
303
  snapshot.project.root = resolved.cwd;
272
304
  snapshot.statusSync = readStatusSync(resolved.cwd);
305
+ // v1.5.11 D-126-01 登记点 ②:每次 feel_* 也记会话 cwd(门禁第 3 环兜底)。
306
+ touchSessionCwd(exec?.agent?.session?.id, resolved.sessionCwd);
307
+ // v1.5.11 D-126-04:门禁自检段(必须在 computeWorkflowGate 之前装配,
308
+ // 让 workflowGate 能读到 guard.registered / cwd / stale)。
309
+ snapshot.guard = buildGuardSection({
310
+ root: resolved.cwd,
311
+ hostMarker: readHostMarker(),
312
+ live: resolveGuardCwd(exec, { cwd: cli.cwd }),
313
+ });
273
314
  snapshot.workflowGate = computeWorkflowGate(snapshot);
274
315
  snapshot.recovery = readRecovery(resolved.cwd);
275
316
  snapshot.preflight = preflight;
@@ -282,10 +323,11 @@ export function createTools(context) {
282
323
  const focus = snapshot.focus;
283
324
  const gateWarning = snapshot.workflowGate.required ? '⚠ 无活跃阶段:非只读任务先 feel_status→建阶段。' : '';
284
325
  const staleWarning = snapshot.stale ? '⚠ 快照为降级(flow next 缺失),以 flow status 为准。' : '';
326
+ const guardWarning = guardWarnings(snapshot.guard);
285
327
  const data = args.detail === 'full' ? snapshot : compactStatusSnapshot(snapshot);
286
328
  return {
287
329
  data,
288
- summary: `${staleWarning}${gateWarning}pipeline=${snapshot.pipeline.phase || '(空)'} 活跃阶段=${focus.stage || '(无)'} phase=${focus.phase || '(空)'} mode=${snapshot.mode.current}(${snapshot.mode.source}) 负责=${focus.responsibleAgent} 可推进到=[${(focus.legalNextPhases ?? []).join(', ') || '无'}]`,
330
+ summary: `${staleWarning}${gateWarning}${guardWarning}pipeline=${snapshot.pipeline.phase || '(空)'} 活跃阶段=${focus.stage || '(无)'} phase=${focus.phase || '(空)'} mode=${snapshot.mode.current}(${snapshot.mode.source}) 负责=${focus.responsibleAgent} 可推进到=[${(focus.legalNextPhases ?? []).join(', ') || '无'}]`,
289
331
  next: focus.phase === 'done' || focus.phase === ''
290
332
  ? null
291
333
  : { tool: 'feel_next', arguments: {}, why: '获取「下一步该谁做」的明确建议。' },
@@ -315,12 +357,21 @@ export function createTools(context) {
315
357
  const snapshot = await readSnapshot(cli, { cwd: resolved.cwd, signal: exec.signal });
316
358
  snapshot.project.root = resolved.cwd;
317
359
  snapshot.statusSync = readStatusSync(resolved.cwd);
360
+ // v1.5.11 D-126-01 登记点 ②:每次 feel_* 也记会话 cwd(门禁第 3 环兜底)。
361
+ touchSessionCwd(exec?.agent?.session?.id, resolved.sessionCwd);
362
+ // v1.5.11 D-126-04:门禁自检段先装配,workflowGate 才能读到 guard 状态。
363
+ snapshot.guard = buildGuardSection({
364
+ root: resolved.cwd,
365
+ hostMarker: readHostMarker(),
366
+ live: resolveGuardCwd(exec, { cwd: cli.cwd }),
367
+ });
318
368
  snapshot.workflowGate = computeWorkflowGate(snapshot);
319
369
  snapshot.recovery = readRecovery(resolved.cwd);
320
370
  snapshot.preflight = preflight;
321
371
  snapshot.observability = safeObservability(snapshot);
322
372
  const plan = planNextStep(snapshot);
323
373
  plan.workflowGate = snapshot.workflowGate;
374
+ plan.guard = snapshot.guard;
324
375
  plan.preflight = snapshot.preflight;
325
376
  snapshot.recovery.nextAction = plan.suggestedCommand ?? null;
326
377
  plan.recovery = snapshot.recovery;
@@ -329,6 +380,8 @@ export function createTools(context) {
329
380
  if (plan.workflowGate.required) {
330
381
  plan.summary = `⚠ ${plan.workflowGate.message} ${plan.summary}`;
331
382
  }
383
+ const guardWarning = guardWarnings(snapshot.guard);
384
+ if (guardWarning !== '') plan.summary = `${guardWarning} ${plan.summary}`;
332
385
  if (snapshot.stale) {
333
386
  plan.summary = `⚠ 快照为降级(flow next 缺失),以 flow status 为准。 ${plan.summary}`;
334
387
  }
package/dsh/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfeel-dsh",
3
- "version": "1.5.9",
3
+ "version": "1.5.11",
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.9"
36
+ "requiresCli": ">=1.5.11"
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.9",
3
+ "version": "1.5.11",
4
4
  "description": "AI Agent 开发流程治理 CLI 工具",
5
5
  "type": "module",
6
6
  "private": false,