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/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 {
|
|
32
|
+
import { setGuardRuntimeIdentity, 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,10 +140,18 @@ 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
|
}
|
|
147
|
+
// v1.5.12 / stage-127 D1:登记**当前进程**的运行时身份(pid / marker 的 started_at+loaded_hash)。
|
|
148
|
+
// guard-state 写入时用它在 seed 之后覆盖旧身份;旧工作区文件的身份一律剥离,
|
|
149
|
+
// 因此重启后首条判定即可自证可信(不再因旧 hostStartedAt 恒 stale)。
|
|
150
|
+
setGuardRuntimeIdentity({
|
|
151
|
+
pid: process.pid,
|
|
152
|
+
hostStartedAt: hostMarker?.started_at ?? new Date().toISOString(),
|
|
153
|
+
loaded_hash: hostMarker?.loaded_hash ?? '',
|
|
154
|
+
});
|
|
134
155
|
const log = typeof ctx.logger === 'function'
|
|
135
156
|
? ctx.logger('openfeel-dsh')
|
|
136
157
|
: {
|
|
@@ -167,6 +188,7 @@ export function apply(ctx, rawConfig) {
|
|
|
167
188
|
allowGeneral: config.allowGeneral,
|
|
168
189
|
language: config.language,
|
|
169
190
|
cwd: config.cwd,
|
|
191
|
+
shellGate: config.shellGate,
|
|
170
192
|
}));
|
|
171
193
|
if (typeof ctx.effect === 'function') {
|
|
172
194
|
ctx.effect(registerGuard);
|
|
@@ -177,6 +199,32 @@ export function apply(ctx, rawConfig) {
|
|
|
177
199
|
}
|
|
178
200
|
}
|
|
179
201
|
|
|
202
|
+
/* ── 门禁自检状态(v1.5.11 D-126-04) ──────────────────── */
|
|
203
|
+
|
|
204
|
+
// 注册段写一次:registered / enforce / shellGate / cwd / cwdSource / degraded /
|
|
205
|
+
// resolvedAt + 自证三键(hostStartedAt / loaded_hash / pid,与宿主标记同源同值)。
|
|
206
|
+
// 启动期还不知道会话 cwd:profile 未配 cwd 时写 `null` → **固定落
|
|
207
|
+
// `os.tmpdir()/openfeel-guard/guard-state.json`**,绝不用 `process.cwd()`
|
|
208
|
+
// (那会把宿主启动目录误当会话工作区,正是原 bug 的形态)。
|
|
209
|
+
const gate = resolveShellGate(
|
|
210
|
+
typeof process.env.OPENFEEL_SHELL_GATE === 'string' && process.env.OPENFEEL_SHELL_GATE.trim() !== ''
|
|
211
|
+
? process.env.OPENFEEL_SHELL_GATE
|
|
212
|
+
: config.shellGate,
|
|
213
|
+
);
|
|
214
|
+
const guardRegistered = config.enforce !== 'off' && typeof ctx.tools.guard === 'function';
|
|
215
|
+
writeGuardState(config.cwd ?? null, {
|
|
216
|
+
registered: guardRegistered,
|
|
217
|
+
enforce: config.enforce,
|
|
218
|
+
shellGate: gate.label,
|
|
219
|
+
cwd: config.cwd ?? null,
|
|
220
|
+
cwdSource: config.cwd === undefined ? 'unresolved' : 'config',
|
|
221
|
+
degraded: config.cwd === undefined,
|
|
222
|
+
resolvedAt: new Date().toISOString(),
|
|
223
|
+
hostStartedAt: hostMarker?.started_at ?? new Date().toISOString(),
|
|
224
|
+
loaded_hash: hostMarker?.loaded_hash ?? '',
|
|
225
|
+
pid: process.pid,
|
|
226
|
+
});
|
|
227
|
+
|
|
180
228
|
/* ── 人类命令面 ─────────────────────────────────────────── */
|
|
181
229
|
|
|
182
230
|
ctx.commands.register({
|
|
@@ -203,6 +251,10 @@ export function apply(ctx, rawConfig) {
|
|
|
203
251
|
text: () => {
|
|
204
252
|
const agent = currentAgent(ctx);
|
|
205
253
|
const sessionCwd = agent?.session?.header?.cwd;
|
|
254
|
+
// v1.5.11 D-126-01 登记点 ①:提示装配时把会话 cwd 写进登记表,供门禁在
|
|
255
|
+
// `agent.session.header.cwd` 缺失时兜底(第 3 环)。只有 sessionId 与 cwd
|
|
256
|
+
// 都非空才写 —— 写入点本身不产生「当前 agent ≈ 所有会话」的误记。
|
|
257
|
+
touchSession(agent?.session?.id, sessionCwd);
|
|
206
258
|
// 拿不到会话且没有显式 cwd 配置 → 不注入(宁可不打扰,也不给错的项目)。
|
|
207
259
|
if ((typeof sessionCwd !== 'string' || sessionCwd === '') && config.cwd === undefined) return '';
|
|
208
260
|
|
package/dsh/lib/tools/index.js
CHANGED
|
@@ -18,7 +18,11 @@ import { buildDispatchTemplate } from '../adapters/dispatch.js';
|
|
|
18
18
|
import { readRecovery } from '../adapters/recovery.js';
|
|
19
19
|
import { readPreflightInfo } from '../adapters/preflight.js';
|
|
20
20
|
import { buildObservability } from '../adapters/observability.js';
|
|
21
|
-
import { computeWorkflowGate } from '../adapters/workflow-gate.js';
|
|
21
|
+
import { computeWorkflowGate, headlineWarning } from '../adapters/workflow-gate.js';
|
|
22
|
+
import { buildGuardSection, maybeSelfHealGuardState, repairGuardState } 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,55 @@ 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
|
+
*
|
|
217
|
+
* v1.5.12 / stage-127 §3-E:
|
|
218
|
+
* - `skipGateCovered:true`(由调用方按 `workflowGate.reason` 以 `guard-` 开头传入)跳过
|
|
219
|
+
* `registered === false` 与 `stale` 两条 —— 它们已由门禁标题(`headlineWarning`)
|
|
220
|
+
* 逐字覆盖,避免同一原因在 summary 里堆两遍;`degraded` 仍保留。
|
|
221
|
+
* - `hmacWarn`(验签失败但 pid/loaded_hash 都对)只在这里渲染一行提示:不进
|
|
222
|
+
* `workflowGate`、不置 stale,见 guard-state 的 P1-6 设计。
|
|
223
|
+
*
|
|
224
|
+
* @param {Record<string, any> | null | undefined} guard
|
|
225
|
+
* @param {{ skipGateCovered?: boolean }} [options]
|
|
226
|
+
* @returns {string}
|
|
227
|
+
*/
|
|
228
|
+
export function guardWarnings(guard, options = {}) {
|
|
229
|
+
if (guard === null || guard === undefined) return '';
|
|
230
|
+
const skipGateCovered = options.skipGateCovered === true;
|
|
231
|
+
if (guard.registered === false && !skipGateCovered) {
|
|
232
|
+
return '⚠ 写入门禁未生效(guard-state 缺失或 guard 未注册),源码写入当前无门禁保护。';
|
|
233
|
+
}
|
|
234
|
+
if (guard.stale === true && !skipGateCovered) {
|
|
235
|
+
// op-005 / P1-6:stale 也可能是「guard-state 被整体重写」(HMAC 校验失败),
|
|
236
|
+
// 文案要把「篡改」说清楚,不能只怪旧进程。
|
|
237
|
+
if (guard.staleReason === 'hmac') {
|
|
238
|
+
return '⚠ 门禁状态被篡改或来自旧进程(guard-state 签名校验失败),判定不可信;请重启宿主后确认 feel_status.guard.stale === false。';
|
|
239
|
+
}
|
|
240
|
+
return '⚠ 门禁来自旧进程/旧适配器,判定不可信,请重启宿主后再写入。';
|
|
241
|
+
}
|
|
242
|
+
if (guard.hmacWarn === true) {
|
|
243
|
+
// v1.5.12 / P1-6:签名失配但 pid/loaded_hash 都通过 → 仅提示,不影响判定
|
|
244
|
+
return '⚠ 门禁状态签名失配(仅提示,不影响判定);如显示异常可完全重启宿主。';
|
|
245
|
+
}
|
|
246
|
+
if (guard.degraded === true && typeof guard.cwdSource === 'string' && guard.cwdSource !== 'agent-session') {
|
|
247
|
+
return `⚠ 门禁 cwd 为降级来源(cwdSource=${guard.cwdSource}),请核对 guard 段。`;
|
|
248
|
+
}
|
|
249
|
+
return '';
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 门禁标题已覆盖的原因(`guard-*`)——此时 `guardWarnings` 跳过重复项。
|
|
254
|
+
*
|
|
255
|
+
* @param {Record<string, any> | null | undefined} gate
|
|
256
|
+
* @returns {boolean}
|
|
257
|
+
*/
|
|
258
|
+
function gateCoversGuardWarning(gate) {
|
|
259
|
+
return typeof gate?.reason === 'string' && gate.reason.startsWith('guard-');
|
|
260
|
+
}
|
|
261
|
+
|
|
206
262
|
/**
|
|
207
263
|
* 构造全部工具定义。
|
|
208
264
|
*
|
|
@@ -214,15 +270,28 @@ export function createTools(context) {
|
|
|
214
270
|
|
|
215
271
|
/**
|
|
216
272
|
* 在目标项目上执行(把 cwd 锚定到解析出的项目根)。
|
|
273
|
+
*
|
|
274
|
+
* v1.5.12 / stage-127 §3-F:所有 `feel_*` 公共入口都先尝试**自动自愈** guard-state
|
|
275
|
+
* (重启后首次 `feel_*` 即修,不要求删除任何文件)。`OPENFEEL_GUARD_SELF_HEAL=off`
|
|
276
|
+
* 可关;活着的异 pid 不自动修(见 `maybeSelfHealGuardState`)。best-effort,绝不阻断。
|
|
277
|
+
*
|
|
217
278
|
* @param {object} exec
|
|
218
279
|
* @param {Record<string, any>} args
|
|
219
|
-
* @
|
|
280
|
+
* @param {{ selfHeal?: boolean }} [options] `selfHeal:false` 供显式修复入口接管(避免自动修抢在显式修之前)
|
|
281
|
+
* @returns {{ cwd: string, sessionCwd: string, initialized: boolean }}
|
|
220
282
|
*/
|
|
221
|
-
const target = (exec, args) => {
|
|
283
|
+
const target = (exec, args, options = {}) => {
|
|
222
284
|
const workspace = resolveWorkspace(exec, {
|
|
223
285
|
projectPath: typeof args.project === 'string' ? args.project : undefined,
|
|
224
286
|
fallback: cli.cwd,
|
|
225
287
|
});
|
|
288
|
+
if (options.selfHeal !== false && workspace.initialized === true) {
|
|
289
|
+
try {
|
|
290
|
+
maybeSelfHealGuardState(workspace.projectRoot);
|
|
291
|
+
} catch {
|
|
292
|
+
/* 自愈是 best-effort:任何异常都不得阻断 feel_* */
|
|
293
|
+
}
|
|
294
|
+
}
|
|
226
295
|
return { cwd: workspace.projectRoot, sessionCwd: workspace.sessionCwd, initialized: workspace.initialized };
|
|
227
296
|
};
|
|
228
297
|
|
|
@@ -270,6 +339,15 @@ export function createTools(context) {
|
|
|
270
339
|
});
|
|
271
340
|
snapshot.project.root = resolved.cwd;
|
|
272
341
|
snapshot.statusSync = readStatusSync(resolved.cwd);
|
|
342
|
+
// v1.5.11 D-126-01 登记点 ②:每次 feel_* 也记会话 cwd(门禁第 3 环兜底)。
|
|
343
|
+
touchSessionCwd(exec?.agent?.session?.id, resolved.sessionCwd);
|
|
344
|
+
// v1.5.11 D-126-04:门禁自检段(必须在 computeWorkflowGate 之前装配,
|
|
345
|
+
// 让 workflowGate 能读到 guard.registered / cwd / stale)。
|
|
346
|
+
snapshot.guard = buildGuardSection({
|
|
347
|
+
root: resolved.cwd,
|
|
348
|
+
hostMarker: readHostMarker(),
|
|
349
|
+
live: resolveGuardCwd(exec, { cwd: cli.cwd }),
|
|
350
|
+
});
|
|
273
351
|
snapshot.workflowGate = computeWorkflowGate(snapshot);
|
|
274
352
|
snapshot.recovery = readRecovery(resolved.cwd);
|
|
275
353
|
snapshot.preflight = preflight;
|
|
@@ -280,12 +358,16 @@ export function createTools(context) {
|
|
|
280
358
|
touchSessionFile(resolved.cwd, snapshot.focus?.stage ?? '');
|
|
281
359
|
snapshot.sessions = readSessionEntries(resolved.cwd);
|
|
282
360
|
const focus = snapshot.focus;
|
|
283
|
-
|
|
361
|
+
// v1.5.12 / stage-127 §3-E:标题按 workflowGate.reason 选择,与 feel_next 同源(headlineWarning)
|
|
362
|
+
const gateWarning = headlineWarning(snapshot);
|
|
284
363
|
const staleWarning = snapshot.stale ? '⚠ 快照为降级(flow next 缺失),以 flow status 为准。' : '';
|
|
364
|
+
const guardWarning = guardWarnings(snapshot.guard, {
|
|
365
|
+
skipGateCovered: gateCoversGuardWarning(snapshot.workflowGate),
|
|
366
|
+
});
|
|
285
367
|
const data = args.detail === 'full' ? snapshot : compactStatusSnapshot(snapshot);
|
|
286
368
|
return {
|
|
287
369
|
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(', ') || '无'}]`,
|
|
370
|
+
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
371
|
next: focus.phase === 'done' || focus.phase === ''
|
|
290
372
|
? null
|
|
291
373
|
: { tool: 'feel_next', arguments: {}, why: '获取「下一步该谁做」的明确建议。' },
|
|
@@ -315,20 +397,35 @@ export function createTools(context) {
|
|
|
315
397
|
const snapshot = await readSnapshot(cli, { cwd: resolved.cwd, signal: exec.signal });
|
|
316
398
|
snapshot.project.root = resolved.cwd;
|
|
317
399
|
snapshot.statusSync = readStatusSync(resolved.cwd);
|
|
400
|
+
// v1.5.11 D-126-01 登记点 ②:每次 feel_* 也记会话 cwd(门禁第 3 环兜底)。
|
|
401
|
+
touchSessionCwd(exec?.agent?.session?.id, resolved.sessionCwd);
|
|
402
|
+
// v1.5.11 D-126-04:门禁自检段先装配,workflowGate 才能读到 guard 状态。
|
|
403
|
+
snapshot.guard = buildGuardSection({
|
|
404
|
+
root: resolved.cwd,
|
|
405
|
+
hostMarker: readHostMarker(),
|
|
406
|
+
live: resolveGuardCwd(exec, { cwd: cli.cwd }),
|
|
407
|
+
});
|
|
318
408
|
snapshot.workflowGate = computeWorkflowGate(snapshot);
|
|
319
409
|
snapshot.recovery = readRecovery(resolved.cwd);
|
|
320
410
|
snapshot.preflight = preflight;
|
|
321
411
|
snapshot.observability = safeObservability(snapshot);
|
|
322
412
|
const plan = planNextStep(snapshot);
|
|
323
413
|
plan.workflowGate = snapshot.workflowGate;
|
|
414
|
+
plan.guard = snapshot.guard;
|
|
324
415
|
plan.preflight = snapshot.preflight;
|
|
325
416
|
snapshot.recovery.nextAction = plan.suggestedCommand ?? null;
|
|
326
417
|
plan.recovery = snapshot.recovery;
|
|
327
418
|
plan.dispatch = buildDispatchTemplate(snapshot);
|
|
328
419
|
plan.observability = snapshot.observability;
|
|
329
420
|
if (plan.workflowGate.required) {
|
|
330
|
-
|
|
421
|
+
// v1.5.12 / stage-127 §3-E:与 feel_status 同一 helper(标题文案只在 workflow-gate.js)
|
|
422
|
+
const gateWarning = headlineWarning({ workflowGate: plan.workflowGate });
|
|
423
|
+
if (gateWarning !== '') plan.summary = `${gateWarning} ${plan.summary}`;
|
|
331
424
|
}
|
|
425
|
+
const guardWarning = guardWarnings(snapshot.guard, {
|
|
426
|
+
skipGateCovered: gateCoversGuardWarning(snapshot.workflowGate),
|
|
427
|
+
});
|
|
428
|
+
if (guardWarning !== '') plan.summary = `${guardWarning} ${plan.summary}`;
|
|
332
429
|
if (snapshot.stale) {
|
|
333
430
|
plan.summary = `⚠ 快照为降级(flow next 缺失),以 flow status 为准。 ${plan.summary}`;
|
|
334
431
|
}
|
|
@@ -1218,8 +1315,11 @@ export function createTools(context) {
|
|
|
1218
1315
|
},
|
|
1219
1316
|
output: { schema: envelopeSchema(), render: renderEnvelope },
|
|
1220
1317
|
async execute(args, exec) {
|
|
1221
|
-
const { cwd } = target(exec, args);
|
|
1222
1318
|
const action = args.action;
|
|
1319
|
+
// v1.5.12 / stage-127 §3-F:显式修复入口(`health fix=true`)由本工具接管自愈,
|
|
1320
|
+
// 避免 `target()` 的自动自愈抢在显式修复之前把「旧→新」证据修掉。
|
|
1321
|
+
const repairing = action === 'health' && args.fix === true && args.dry_run !== true;
|
|
1322
|
+
const { cwd } = target(exec, args, { selfHeal: !repairing });
|
|
1223
1323
|
const opts = { cwd, signal: exec.signal };
|
|
1224
1324
|
|
|
1225
1325
|
switch (action) {
|
|
@@ -1229,8 +1329,25 @@ export function createTools(context) {
|
|
|
1229
1329
|
pushFlag(argv, '--fix', args.fix);
|
|
1230
1330
|
pushFlag(argv, '--dry-run', args.dry_run);
|
|
1231
1331
|
return envelope(action, async () => {
|
|
1232
|
-
|
|
1233
|
-
|
|
1332
|
+
// 显式修复:身份只来自 marker + 当前宿主 pid(不接受工具参数)。
|
|
1333
|
+
const guardRepair = repairing
|
|
1334
|
+
? repairGuardState(cwd, { hostMarker: readHostMarker(), tool: 'feel_verify' })
|
|
1335
|
+
: null;
|
|
1336
|
+
let data = await cli.json(argv, opts);
|
|
1337
|
+
let repairNote = '';
|
|
1338
|
+
if (guardRepair !== null) {
|
|
1339
|
+
if (guardRepair.ok === true) {
|
|
1340
|
+
const health = typeof data?.health === 'object' && data.health !== null ? data.health : {};
|
|
1341
|
+
data = { ...data, health: { ...health, guardRepair } };
|
|
1342
|
+
repairNote = guardRepair.changed === true
|
|
1343
|
+
? `门禁自证已修复(pid ${guardRepair.old?.pid ?? '(无)'}→${guardRepair.next?.pid ?? process.pid},hash ${String(guardRepair.old?.loaded_hash ?? '(无)').slice(0, 8)}→${String(guardRepair.next?.loaded_hash ?? '').slice(0, 8)})。`
|
|
1344
|
+
: '门禁自证已可信(无需修复)。';
|
|
1345
|
+
} else {
|
|
1346
|
+
data = { ...data, health: { ...(typeof data?.health === 'object' && data.health !== null ? data.health : {}), guardRepair } };
|
|
1347
|
+
repairNote = `⚠ 门禁自愈失败:${guardRepair.reason ?? 'unknown'}(marker 缺失请重启宿主)。`;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
return { data, summary: `已执行流水线健康检查。${repairNote}` };
|
|
1234
1351
|
});
|
|
1235
1352
|
}
|
|
1236
1353
|
case 'lint': {
|
package/dsh/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openfeel-dsh",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.12",
|
|
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.
|
|
36
|
+
"requiresCli": ">=1.5.12"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|
|
39
39
|
"openfeel",
|