openfeel 1.5.24 → 1.6.0
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.en.md +7 -0
- package/README.zh-CN.md +7 -0
- package/dist/commands/flow.d.ts.map +1 -1
- package/dist/commands/flow.js +117 -23
- package/dist/commands/flow.js.map +1 -1
- package/dist/commands/lint.d.ts +3 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +96 -0
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/req.d.ts.map +1 -1
- package/dist/commands/req.js +392 -17
- package/dist/commands/req.js.map +1 -1
- package/dist/commands/stage.d.ts.map +1 -1
- package/dist/commands/stage.js +19 -0
- package/dist/commands/stage.js.map +1 -1
- package/dist/core/dev-status.d.ts +25 -0
- package/dist/core/dev-status.d.ts.map +1 -1
- package/dist/core/dev-status.js +35 -0
- package/dist/core/dev-status.js.map +1 -1
- package/dist/core/errors.d.ts +13 -3
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +9 -3
- package/dist/core/errors.js.map +1 -1
- package/dist/core/flow-manager.d.ts +109 -3
- package/dist/core/flow-manager.d.ts.map +1 -1
- package/dist/core/flow-manager.js +326 -14
- package/dist/core/flow-manager.js.map +1 -1
- package/dist/core/i18n-data/en.d.ts.map +1 -1
- package/dist/core/i18n-data/en.js +56 -2
- package/dist/core/i18n-data/en.js.map +1 -1
- package/dist/core/i18n-data/zh-CN.d.ts.map +1 -1
- package/dist/core/i18n-data/zh-CN.js +56 -2
- package/dist/core/i18n-data/zh-CN.js.map +1 -1
- package/dist/core/lint-req.d.ts +17 -1
- package/dist/core/lint-req.d.ts.map +1 -1
- package/dist/core/lint-req.js +14 -2
- package/dist/core/lint-req.js.map +1 -1
- package/dist/core/plan/body-lint.d.ts +58 -0
- package/dist/core/plan/body-lint.d.ts.map +1 -0
- package/dist/core/plan/body-lint.js +197 -0
- package/dist/core/plan/body-lint.js.map +1 -0
- package/dist/core/plan/filled.d.ts +143 -0
- package/dist/core/plan/filled.d.ts.map +1 -0
- package/dist/core/plan/filled.js +244 -0
- package/dist/core/plan/filled.js.map +1 -0
- package/dist/core/plan/path.d.ts +24 -0
- package/dist/core/plan/path.d.ts.map +1 -1
- package/dist/core/plan/path.js +56 -0
- package/dist/core/plan/path.js.map +1 -1
- package/dist/core/req/aggregate.d.ts.map +1 -1
- package/dist/core/req/aggregate.js +5 -0
- package/dist/core/req/aggregate.js.map +1 -1
- package/dist/core/req/body-file.d.ts +66 -0
- package/dist/core/req/body-file.d.ts.map +1 -1
- package/dist/core/req/body-file.js +184 -2
- package/dist/core/req/body-file.js.map +1 -1
- package/dist/core/req/requirement-ops.d.ts +128 -14
- package/dist/core/req/requirement-ops.d.ts.map +1 -1
- package/dist/core/req/requirement-ops.js +341 -16
- package/dist/core/req/requirement-ops.js.map +1 -1
- package/dist/core/req/types.d.ts +55 -0
- package/dist/core/req/types.d.ts.map +1 -1
- package/dist/core/template-loader.d.ts.map +1 -1
- package/dist/core/template-loader.js +75 -0
- package/dist/core/template-loader.js.map +1 -1
- package/dsh/ACTION-GUIDE.md +41 -8
- package/dsh/ADAPTER.md +58 -13
- package/dsh/README.md +45 -24
- package/dsh/docs/compat/persistence.md +13 -0
- package/dsh/docs/compat/pipeline.md +12 -0
- package/dsh/docs/compat/req.md +14 -0
- package/dsh/docs/compat/stage.md +13 -0
- package/dsh/lib/adapters/dashboard.js +10 -0
- package/dsh/lib/adapters/dispatch-ledger.js +293 -0
- package/dsh/lib/adapters/dispatch.js +54 -6
- package/dsh/lib/adapters/next-action.js +336 -0
- package/dsh/lib/guard.js +9 -2
- package/dsh/lib/index.js +37 -0
- package/dsh/lib/surface/prompt.js +62 -173
- package/dsh/lib/tools/index.js +435 -9
- package/dsh/package.json +2 -2
- package/package.json +1 -1
package/dsh/lib/tools/index.js
CHANGED
|
@@ -11,10 +11,24 @@
|
|
|
11
11
|
* 3. 在拒绝时给出**可操作的下一步**(改哪个参数、先跑哪条命令)。
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
15
|
+
import { join, relative, sep } from 'node:path';
|
|
16
|
+
|
|
14
17
|
import { FeelError } from '../adapters/cli.js';
|
|
15
18
|
import { legalNextPhases, planNextStep, readSnapshot } from '../adapters/dashboard.js';
|
|
16
19
|
import { readStatusSync } from '../adapters/dev-status.js';
|
|
17
20
|
import { buildDispatchTemplate } from '../adapters/dispatch.js';
|
|
21
|
+
// v1.6.0 / T10:动作型 next(`nextAction`)与每步提醒的状态喂入
|
|
22
|
+
import { deriveNextAction, nextActionLine, rememberFocus, toWireNext } from '../adapters/next-action.js';
|
|
23
|
+
// v1.6.0 / REQ-057:派发台账(与 CLI `.openfeel/dev/dispatch.jsonl` 同一文件格式)
|
|
24
|
+
import {
|
|
25
|
+
DISPATCH_LEDGER_REL_PATH,
|
|
26
|
+
DISPATCH_ROLES,
|
|
27
|
+
appendDispatch,
|
|
28
|
+
dispatchLedgerPath,
|
|
29
|
+
dispatchSummary,
|
|
30
|
+
readDispatches,
|
|
31
|
+
} from '../adapters/dispatch-ledger.js';
|
|
18
32
|
import { readRecovery } from '../adapters/recovery.js';
|
|
19
33
|
import { readPreflightInfo } from '../adapters/preflight.js';
|
|
20
34
|
import { buildObservability } from '../adapters/observability.js';
|
|
@@ -26,7 +40,11 @@ import { resolveGuardCwd } from '../guard.js';
|
|
|
26
40
|
import { touchSession as touchSessionCwd } from '../adapters/session-cwd-registry.js';
|
|
27
41
|
import { resolveWorkspace } from '../adapters/workspace.js';
|
|
28
42
|
// v1.5.8 / REQ-029:多会话登记(与 CLI `.openfeel/dev/sessions.json` 同一文件格式)
|
|
29
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
readSessions as readSessionEntries,
|
|
45
|
+
resolveSessionId,
|
|
46
|
+
touchSession as touchSessionFile,
|
|
47
|
+
} from '../adapters/sessions.js';
|
|
30
48
|
import {
|
|
31
49
|
boolean,
|
|
32
50
|
compileParameters,
|
|
@@ -143,6 +161,177 @@ function safeObservability(snapshot) {
|
|
|
143
161
|
}
|
|
144
162
|
}
|
|
145
163
|
|
|
164
|
+
/**
|
|
165
|
+
* 派发台账提示段(v1.6.0 / REQ-057)。
|
|
166
|
+
*
|
|
167
|
+
* **提示级,不做硬拦**(用户裁定 ②):`required` 恒 true 只表示「建议走台账」,
|
|
168
|
+
* 不阻断任何工具调用。台账读取失败降级为空台账(观测数据绝不影响 feel_status)。
|
|
169
|
+
*
|
|
170
|
+
* 形状与 `dispatchSummary` 单点对齐:`{required, total, sincePhase, missingRoles, records}`。
|
|
171
|
+
*
|
|
172
|
+
* @param {string} projectRoot
|
|
173
|
+
* @param {{ stage?: string, phase?: string }} [focus]
|
|
174
|
+
* @returns {{ required: true, total: number, sincePhase: number, missingRoles: string[], records: Array<Record<string, any>> }}
|
|
175
|
+
*/
|
|
176
|
+
function safeDispatchSection(projectRoot, focus = {}) {
|
|
177
|
+
try {
|
|
178
|
+
return dispatchSummary(projectRoot, { stage: focus.stage ?? '', phase: focus.phase ?? '' });
|
|
179
|
+
} catch {
|
|
180
|
+
return { required: true, total: 0, sincePhase: 0, missingRoles: [...DISPATCH_ROLES], records: [] };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 写命令 + `--json`(v1.6.0 / T9)。
|
|
186
|
+
*
|
|
187
|
+
* 为什么要绕一层:`cli.json` 不跑 preflight 自愈,而 `cli.write` 只回人类文本。
|
|
188
|
+
* `req body` 是写命令且需要结构化出口(path/lines/created),所以用 `write`
|
|
189
|
+
* 保证「账本过期先真实读一次状态」的既有语义,再从 stdout 解析 JSON 文档。
|
|
190
|
+
* 解析失败不抛错(出口契约归 CLI),返回 `null` 由调用方降级。
|
|
191
|
+
*
|
|
192
|
+
* @param {import('../adapters/cli.js').FeelCli} cliInstance
|
|
193
|
+
* @param {string[]} argv 必须含 `--json`
|
|
194
|
+
* @param {object} options CLI 执行选项
|
|
195
|
+
* @returns {Promise<Record<string, any> | null>}
|
|
196
|
+
*/
|
|
197
|
+
async function writeJsonDoc(cliInstance, argv, options) {
|
|
198
|
+
const out = await cliInstance.write(argv, options);
|
|
199
|
+
const text = typeof out?.text === 'string' ? out.text.trim() : '';
|
|
200
|
+
if (text === '') return null;
|
|
201
|
+
try {
|
|
202
|
+
const doc = JSON.parse(text);
|
|
203
|
+
return doc !== null && typeof doc === 'object' && !Array.isArray(doc) ? doc : null;
|
|
204
|
+
} catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* 账本同步会重写的「文档类」目标(`dev_last.md` + `dev/current.md`)。
|
|
211
|
+
*
|
|
212
|
+
* **不把 `.sync.json` 算进去**:它是同步元数据(每次 sync 必写),
|
|
213
|
+
* 而 `wrote[]` 的语义是「哪些账本文档内容真的变了」(plan §5.5)。
|
|
214
|
+
*
|
|
215
|
+
* 用户目录名由 CLI 从 `.info.json` / 环境推导,适配器不重复那套规则:
|
|
216
|
+
* 直接枚举每个用户的 `dev_last.md`(`.openfeel/users/<user>/dev_last.md`,存在即纳入候选)。
|
|
217
|
+
*
|
|
218
|
+
* @param {string} projectRoot
|
|
219
|
+
* @returns {string[]} 绝对路径候选(可能不存在)
|
|
220
|
+
*/
|
|
221
|
+
function devDocCandidates(projectRoot) {
|
|
222
|
+
const files = [];
|
|
223
|
+
const usersDir = join(projectRoot, '.openfeel', 'users');
|
|
224
|
+
let entries = [];
|
|
225
|
+
try {
|
|
226
|
+
entries = readdirSync(usersDir, { withFileTypes: true });
|
|
227
|
+
} catch {
|
|
228
|
+
entries = [];
|
|
229
|
+
}
|
|
230
|
+
for (const entry of entries) {
|
|
231
|
+
if (entry.isDirectory()) files.push(join(usersDir, entry.name, 'dev_last.md'));
|
|
232
|
+
}
|
|
233
|
+
files.push(join(projectRoot, '.openfeel', 'dev', 'current.md'));
|
|
234
|
+
return files;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 快照账本文档内容(不存在 → `null`;读失败 → `null`)。
|
|
239
|
+
* @param {string} projectRoot
|
|
240
|
+
* @returns {Map<string, string | null>}
|
|
241
|
+
*/
|
|
242
|
+
function snapshotDevDocs(projectRoot) {
|
|
243
|
+
/** @type {Map<string, string | null>} */
|
|
244
|
+
const snapshot = new Map();
|
|
245
|
+
for (const file of devDocCandidates(projectRoot)) {
|
|
246
|
+
try {
|
|
247
|
+
snapshot.set(file, readFileSync(file, 'utf-8'));
|
|
248
|
+
} catch {
|
|
249
|
+
snapshot.set(file, null);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return snapshot;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 对比同步前后的账本文档,得出**实际变更**的相对路径(POSIX 风格)。
|
|
257
|
+
* @param {Map<string, string | null>} before
|
|
258
|
+
* @param {Map<string, string | null>} after
|
|
259
|
+
* @param {string} projectRoot
|
|
260
|
+
* @returns {string[]}
|
|
261
|
+
*/
|
|
262
|
+
function diffDevDocs(before, after, projectRoot) {
|
|
263
|
+
const wrote = [];
|
|
264
|
+
for (const [file, content] of after) {
|
|
265
|
+
if (content === null) continue;
|
|
266
|
+
if (before.get(file) === content) continue;
|
|
267
|
+
const rel = relative(projectRoot, file);
|
|
268
|
+
wrote.push(rel.split(sep).join('/'));
|
|
269
|
+
}
|
|
270
|
+
return wrote;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* `feel_dispatch` 的当前阶段/相位解析(v1.6.0 / REQ-057)。
|
|
275
|
+
*
|
|
276
|
+
* 参数显式给出时零 CLI 调用;缺省时读一次 `flow next --json`(与 feel_next 同源权威)。
|
|
277
|
+
* 无阶段上下文或 CLI 不可用时留空,台账行照样记录(不因派发工具阻塞调度)。
|
|
278
|
+
*
|
|
279
|
+
* @param {import('../adapters/cli.js').FeelCli} cli
|
|
280
|
+
* @param {object} opts CLI 执行选项
|
|
281
|
+
* @param {Record<string, any>} args
|
|
282
|
+
* @returns {Promise<{ stage: string, phase: string }>}
|
|
283
|
+
*/
|
|
284
|
+
async function resolveDispatchFocus(cli, opts, args) {
|
|
285
|
+
let stage = optionalArg(args, 'stage') ?? '';
|
|
286
|
+
let phase = optionalArg(args, 'phase') ?? '';
|
|
287
|
+
if (stage !== '' && phase !== '') return { stage, phase };
|
|
288
|
+
try {
|
|
289
|
+
const doc = await cli.json(['flow', 'next', '--json'], opts);
|
|
290
|
+
if (stage === '' && typeof doc?.stage === 'string') stage = doc.stage;
|
|
291
|
+
if (phase === '' && typeof doc?.phase === 'string') phase = doc.phase;
|
|
292
|
+
} catch {
|
|
293
|
+
// 取不到阶段 / 旧版 CLI / 未初始化:留空即可,派发记录仍然成立
|
|
294
|
+
}
|
|
295
|
+
return { stage, phase };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* 打派发方的来源标识(v1.6.0 / REQ-057)。
|
|
300
|
+
*
|
|
301
|
+
* `origin` / `delegationDepth` 的 DSH 读取路径**尚未由 spike 验证**(plan §2 T9:
|
|
302
|
+
* 不可读则省略字段;本步按 schema 要求保留,用 `'root'` / `1` 作保守缺省,
|
|
303
|
+
* 可读时取真实值)。绝不为读这两个字段改变主流程。
|
|
304
|
+
*
|
|
305
|
+
* @param {object} exec
|
|
306
|
+
* @returns {{ origin: string, dispatchDepth: number }}
|
|
307
|
+
*/
|
|
308
|
+
function dispatchOriginOf(exec) {
|
|
309
|
+
const session = exec?.agent?.session ?? {};
|
|
310
|
+
const header = session.header ?? {};
|
|
311
|
+
const origin = typeof header.origin === 'string' && header.origin !== ''
|
|
312
|
+
? header.origin
|
|
313
|
+
: (typeof session.origin === 'string' && session.origin !== '' ? session.origin : 'root');
|
|
314
|
+
const rawDepth = header.delegationDepth ?? session.delegationDepth ?? header.delegation_depth;
|
|
315
|
+
const dispatchDepth = Number.isInteger(rawDepth) && rawDepth >= 0 ? rawDepth : 1;
|
|
316
|
+
return { origin, dispatchDepth };
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 派发方会话标识(`exec.agent.session.id` 优先,缺省沿用 CLI 三级链的会话标识)。
|
|
321
|
+
* @param {object} exec
|
|
322
|
+
* @param {string} projectRoot
|
|
323
|
+
* @returns {string}
|
|
324
|
+
*/
|
|
325
|
+
function dispatchSessionOf(exec, projectRoot) {
|
|
326
|
+
const id = exec?.agent?.session?.id;
|
|
327
|
+
if (typeof id === 'string' && id !== '') return id;
|
|
328
|
+
try {
|
|
329
|
+
return resolveSessionId(projectRoot);
|
|
330
|
+
} catch {
|
|
331
|
+
return '';
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
146
335
|
/**
|
|
147
336
|
* 展示层对齐(v1.5.17):`feel_mode=disabled` 时 CLI 的 preflight 有效模式已降级为 warn
|
|
148
337
|
* (`src/core/preflight.ts:resolvePreflightMode`),而适配器读到的是**宿主 env**(可能仍是 strict)。
|
|
@@ -222,6 +411,10 @@ export function compactStatusSnapshot(snapshot) {
|
|
|
222
411
|
stale: snapshot?.stale === true,
|
|
223
412
|
// v1.5.8 / REQ-029:会话登记(compact 档同样暴露,体积可控——只含存活/近期会话)
|
|
224
413
|
sessions: snapshot?.sessions ?? [],
|
|
414
|
+
// v1.6.0 / REQ-057:派发台账提示段(提示级,不做硬拦;键缺失时显式 null 保持形状)
|
|
415
|
+
dispatch: snapshot?.dispatch ?? null,
|
|
416
|
+
// v1.6.0 / T10:动作型 next(`dispatch` / `command` / `idle`)——与 wire 的 `next` 同源
|
|
417
|
+
nextAction: snapshot?.nextAction ?? null,
|
|
225
418
|
};
|
|
226
419
|
// 需求概览是显式开关(with_requirements),compact 档同样只在请求时带上
|
|
227
420
|
if (snapshot?.requirements !== undefined) {
|
|
@@ -381,6 +574,17 @@ export function createTools(context) {
|
|
|
381
574
|
// touchSessionFile 内部已 try/catch 静默,读失败同样降级为 [](绝不阻断主流程)。
|
|
382
575
|
touchSessionFile(resolved.cwd, snapshot.focus?.stage ?? '');
|
|
383
576
|
snapshot.sessions = readSessionEntries(resolved.cwd);
|
|
577
|
+
// v1.6.0 / REQ-057:派发台账提示段(required / total / sincePhase / missingRoles / records)。
|
|
578
|
+
// 提示级:只告知「本相位哪些角色还没派发过」,不做任何硬拦(用户裁定 ②)。
|
|
579
|
+
snapshot.dispatch = safeDispatchSection(resolved.cwd, {
|
|
580
|
+
stage: snapshot.focus?.stage,
|
|
581
|
+
phase: snapshot.focus?.phase,
|
|
582
|
+
});
|
|
583
|
+
// v1.6.0 / T10:动作型 next(`dispatch` / `command` / `idle`)。
|
|
584
|
+
// 同时喂给每步提醒(`rememberFocus`),让「该派发了」出现在决策点。
|
|
585
|
+
snapshot.nextAction = deriveNextAction(snapshot);
|
|
586
|
+
rememberFocus(snapshot, snapshot.nextAction);
|
|
587
|
+
snapshot.recovery.nextAction = nextActionLine(snapshot.nextAction);
|
|
384
588
|
const focus = snapshot.focus;
|
|
385
589
|
// v1.5.12 / stage-127 §3-E:标题按 workflowGate.reason 选择,与 feel_next 同源(headlineWarning)
|
|
386
590
|
const gateWarning = headlineWarning(snapshot);
|
|
@@ -392,9 +596,8 @@ export function createTools(context) {
|
|
|
392
596
|
return {
|
|
393
597
|
data,
|
|
394
598
|
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(', ') || '无'}]`,
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
: { tool: 'feel_next', arguments: {}, why: '获取「下一步该谁做」的明确建议。' },
|
|
599
|
+
// v1.6.0 / T10:`next` 保留(旧键),内容改成动作型(dispatch/command;idle → null)
|
|
600
|
+
next: toWireNext(snapshot.nextAction),
|
|
398
601
|
};
|
|
399
602
|
});
|
|
400
603
|
},
|
|
@@ -436,12 +639,21 @@ export function createTools(context) {
|
|
|
436
639
|
snapshot.recovery = readRecovery(resolved.cwd);
|
|
437
640
|
snapshot.preflight = preflight;
|
|
438
641
|
snapshot.observability = safeObservability(snapshot);
|
|
642
|
+
// v1.6.0 / T10:动作型 next 依赖派发台账(与 feel_status 同源;读本地 jsonl,零新增 CLI)。
|
|
643
|
+
// 注意:`plan.dispatch` 是派发模板(buildDispatchTemplate),台账走 `snapshot.dispatch`。
|
|
644
|
+
snapshot.dispatch = safeDispatchSection(resolved.cwd, {
|
|
645
|
+
stage: snapshot.focus?.stage,
|
|
646
|
+
phase: snapshot.focus?.phase,
|
|
647
|
+
});
|
|
439
648
|
const plan = planNextStep(snapshot);
|
|
440
649
|
plan.workflowGate = snapshot.workflowGate;
|
|
441
650
|
plan.feelMode = snapshot.feelMode ?? null;
|
|
442
651
|
plan.guard = snapshot.guard;
|
|
443
652
|
plan.preflight = snapshot.preflight;
|
|
444
|
-
|
|
653
|
+
// v1.6.0 / T10:动作型 next(与 feel_status 同一纯函数、同一提醒状态)
|
|
654
|
+
plan.nextAction = deriveNextAction(snapshot);
|
|
655
|
+
rememberFocus(snapshot, plan.nextAction);
|
|
656
|
+
snapshot.recovery.nextAction = nextActionLine(plan.nextAction);
|
|
445
657
|
plan.recovery = snapshot.recovery;
|
|
446
658
|
plan.dispatch = buildDispatchTemplate(snapshot);
|
|
447
659
|
plan.observability = snapshot.observability;
|
|
@@ -466,9 +678,10 @@ export function createTools(context) {
|
|
|
466
678
|
return {
|
|
467
679
|
data: plan,
|
|
468
680
|
summary: plan.summary,
|
|
469
|
-
|
|
681
|
+
// v1.6.0 / T10:优先动作型 next;`idle` 时才回落到既有 toolCall(不破坏旧语义)
|
|
682
|
+
next: toWireNext(plan.nextAction) ?? (plan.toolCall === null || plan.toolCall === undefined
|
|
470
683
|
? null
|
|
471
|
-
: { tool: plan.toolCall.tool, arguments: plan.toolCall.arguments, why: `推进到 ${plan.toolCall.arguments.to}` },
|
|
684
|
+
: { tool: plan.toolCall.tool, arguments: plan.toolCall.arguments, why: `推进到 ${plan.toolCall.arguments.to}` }),
|
|
472
685
|
};
|
|
473
686
|
});
|
|
474
687
|
},
|
|
@@ -863,9 +1076,9 @@ export function createTools(context) {
|
|
|
863
1076
|
const feelReq = {
|
|
864
1077
|
name: 'feel_req',
|
|
865
1078
|
description:
|
|
866
|
-
'需求分发系统(openfeel req,7 状态)。action=add 创建需求(ID 自动分配,**单调计数器 meta.last_req_seq**:归档移走条目后也不复用 ID
|
|
1079
|
+
'需求分发系统(openfeel req,7 状态)。action=add 创建需求(ID 自动分配,**单调计数器 meta.last_req_seq**:归档移走条目后也不复用 ID;可带 summary / problem / goal / acceptance / plan 一步写入正文小节——正文门要求 `## 摘要` 与 `## 目标与验收` 都写实,缺 summary 时 add start=true 会被 REQ_BODY 拦);body 写入需求正文的业务小节(`.openfeel/requirements/*.md` 是 guard 受保护路径,`feel_req action=body` 是唯一写入口:section 必填,text 与 file 二选一,append/replace 互斥);list 过滤列表(include_archived=true 合并已随版本归档的需求);show 详情(已归档需求回退读归档文件);board 看板(7 组固定顺序);next 推荐下一个可接取需求;claim 认领(占用校验、无 TTL);release 释放;set 更新白名单字段;link 关联/解绑阶段;advance 显式推进状态(**done 门:关联阶段须已进入 exec_running 及之后相位即可完成——阶段是版本容器,不必先 done**);split 拆分(子需求直接入 scheduled,父需求仅留 parent_id 溯源);review 记录需求审查;verify 记录需求验证(**v1.5.8 完成必审验:done 门额外要求 review.result=pass 且 verification.result=pass**);release-check 发布门(软,只读):列出该版本 done / 未完成 / 其它需求;rollover 顺延:把未完成需求的 target_version 改到新版本并记录 carried_from。',
|
|
867
1080
|
parameters: {
|
|
868
|
-
action: stringEnum(['add', 'list', 'show', 'board', 'next', 'claim', 'release', 'set', 'link', 'advance', 'split', 'review', 'verify', 'complete', 'waive', 'trivial', 'release-check', 'rollover'], '操作。', { required: true }),
|
|
1081
|
+
action: stringEnum(['add', 'body', 'list', 'show', 'board', 'next', 'claim', 'release', 'set', 'link', 'advance', 'split', 'review', 'verify', 'complete', 'waive', 'trivial', 'release-check', 'rollover'], '操作。', { required: true }),
|
|
869
1082
|
id: string('需求 ID(如 REQ-001)。show/claim/release/set/advance/split/review/verify/rollover 必需(rollover 与 all 互斥)。'),
|
|
870
1083
|
title: string('需求标题(add 必需;set 为改标题)。'),
|
|
871
1084
|
target_version: string('预估版本(如 v1.3.0;纯展示/过滤维度,非门禁)。'),
|
|
@@ -890,8 +1103,22 @@ export function createTools(context) {
|
|
|
890
1103
|
evidence: string('verify 的证据(测试命令 / 报告路径)。'),
|
|
891
1104
|
independent: boolean('review 是否独立审查(缺省 false = 自我审查,须显式标注 self-review)。'),
|
|
892
1105
|
claim: boolean('add 时立即认领(v1.5.23)。'),
|
|
1106
|
+
start: boolean('add 时直接进入 in_progress(自动 scheduled → in_progress;v1.5.25;正文未写实会被 REQ_BODY 门拒绝)。'),
|
|
1107
|
+
// v1.6.0-stage-132 / T13:add 时直接写正文业务小节(CLI `req add --summary/--problem/--goal/--acceptance/--plan`)。
|
|
1108
|
+
// 正文门(REQ_BODY_GATE)在 scheduled / in_progress / done 生效,缺省字段不传。
|
|
1109
|
+
summary: string('add 时写入正文 `## 摘要` 小节(Markdown;正文门要求它写实)。'),
|
|
1110
|
+
problem: string('add 时写入正文 `## 问题` 小节(Markdown)。'),
|
|
1111
|
+
goal: string('add 时写入正文 `## 目标与验收` 的「目标」子节(Markdown;正文门要求该节写实)。'),
|
|
1112
|
+
acceptance: string('add 时写入正文 `## 目标与验收` 的「验收」子节(Markdown;至少 1 条 `- ` / `验收` 开头的判据行)。'),
|
|
1113
|
+
plan: string('add 时写入正文 `## 初步规划` 小节(Markdown)。'),
|
|
893
1114
|
reason: string('waive / trivial 的原因(标记时必需)。'),
|
|
894
1115
|
revoke: boolean('waive / trivial 时撤销标记。'),
|
|
1116
|
+
// v1.6.0 / REQ-055(T2):需求正文的唯一写入口(`.openfeel/requirements/*.md` 是受保护路径)
|
|
1117
|
+
section: string('req body 的小节名(如 摘要 / 目标与验收;元信息小节不可写)。body 必需。'),
|
|
1118
|
+
text: string('req body 的小节正文(Markdown;与 file 二选一)。'),
|
|
1119
|
+
file: string('req body 的正文来源文件(与 text 二选一;相对路径按项目根解析)。'),
|
|
1120
|
+
append: boolean('req body 追加到该小节末尾(缺省替换整节)。'),
|
|
1121
|
+
replace: boolean('req body 显式替换整节(缺省行为;与 append 互斥)。'),
|
|
895
1122
|
project: string('项目根目录。'),
|
|
896
1123
|
},
|
|
897
1124
|
output: { schema: envelopeSchema(), render: renderEnvelope },
|
|
@@ -908,11 +1135,62 @@ export function createTools(context) {
|
|
|
908
1135
|
pushOption(argv, '--workflow-mode', args.workflow_mode);
|
|
909
1136
|
pushFlag(argv, '--claim', args.claim);
|
|
910
1137
|
pushOption(argv, '--stage', args.stage);
|
|
1138
|
+
pushFlag(argv, '--start', args.start);
|
|
1139
|
+
// v1.6.0-stage-132 / T13:正文业务小节在 CLI 侧先于 `--start` 落盘,
|
|
1140
|
+
// 所以「add 带 summary/goal/acceptance + start」不再被正文门(REQ_BODY)拦。
|
|
1141
|
+
pushOption(argv, '--summary', args.summary);
|
|
1142
|
+
pushOption(argv, '--problem', args.problem);
|
|
1143
|
+
pushOption(argv, '--goal', args.goal);
|
|
1144
|
+
pushOption(argv, '--acceptance', args.acceptance);
|
|
1145
|
+
pushOption(argv, '--plan', args.plan);
|
|
911
1146
|
return envelope(action, async () => {
|
|
912
1147
|
const out = await cli.write(argv, opts);
|
|
913
1148
|
return { data: { output: out.text }, summary: '需求已创建。' };
|
|
914
1149
|
});
|
|
915
1150
|
}
|
|
1151
|
+
case 'body': {
|
|
1152
|
+
// v1.6.0 / REQ-055(T2):正文写入唯一入口。
|
|
1153
|
+
// `.openfeel/requirements/*.md` 是 guard 受保护路径,agent 工具直写会被拒,
|
|
1154
|
+
// shell 跑 openfeel 写命令同样被拒 —— 这是给正文开的唯一通道。
|
|
1155
|
+
const id = requireArg(args, 'id', action);
|
|
1156
|
+
const section = requireArg(args, 'section', action);
|
|
1157
|
+
const text = optionalArg(args, 'text');
|
|
1158
|
+
const file = optionalArg(args, 'file');
|
|
1159
|
+
if (text === undefined && file === undefined) {
|
|
1160
|
+
throw new FeelError('req body 需要 text 或 file 之一(小节正文来源)', {
|
|
1161
|
+
kind: 'usage',
|
|
1162
|
+
code: 'FEEL_BAD_USAGE',
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
if (text !== undefined && file !== undefined) {
|
|
1166
|
+
throw new FeelError('req body 的 text 与 file 互斥:只能给一个', {
|
|
1167
|
+
kind: 'usage',
|
|
1168
|
+
code: 'FEEL_BAD_USAGE',
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
if (args.append === true && args.replace === true) {
|
|
1172
|
+
throw new FeelError('req body 的 append 与 replace 互斥:只能给一个', {
|
|
1173
|
+
kind: 'usage',
|
|
1174
|
+
code: 'FEEL_BAD_USAGE',
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
const argv = ['req', 'body', id, '--section', section, '--json'];
|
|
1178
|
+
pushOption(argv, '--text', text);
|
|
1179
|
+
pushOption(argv, '--file', file);
|
|
1180
|
+
pushFlag(argv, '--append', args.append);
|
|
1181
|
+
pushFlag(argv, '--replace', args.replace);
|
|
1182
|
+
return envelope(action, async () => {
|
|
1183
|
+
const doc = await writeJsonDoc(cli, argv, opts);
|
|
1184
|
+
const created = doc?.created === true;
|
|
1185
|
+
const lines = typeof doc?.lines === 'number' ? doc.lines : null;
|
|
1186
|
+
const path = typeof doc?.path === 'string' ? doc.path : null;
|
|
1187
|
+
const mode = created ? '新建小节' : (args.append === true ? '追加' : '替换');
|
|
1188
|
+
return {
|
|
1189
|
+
data: { ok: true, id, section, path, lines, created },
|
|
1190
|
+
summary: `需求 ${id} 的「${section}」已${mode}${lines === null ? '' : `(${lines} 行)`}${path === null ? '' : ` → ${path}`}。`,
|
|
1191
|
+
};
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
916
1194
|
case 'list': {
|
|
917
1195
|
const argv = ['req', 'list', '--json'];
|
|
918
1196
|
pushOption(argv, '--status', args.status);
|
|
@@ -1663,6 +1941,152 @@ export function createTools(context) {
|
|
|
1663
1941
|
presentCall: (args) => presentCall(`Feel 模型 ${args.action}`, args.action, args.agent),
|
|
1664
1942
|
};
|
|
1665
1943
|
|
|
1944
|
+
/* ══════════════════════════ 14. feel_dispatch ══════════════════════════ */
|
|
1945
|
+
|
|
1946
|
+
const feelDispatch = {
|
|
1947
|
+
name: 'feel_dispatch',
|
|
1948
|
+
description:
|
|
1949
|
+
'派发台账:把「派给谁、派什么、允许写哪些文件」记进 `.openfeel/dev/dispatch.jsonl`(一行一条 JSON,字段见 plan §5.4)。action=record 记录一次派发(同 `leadSessionId+taskId+goal` 5 分钟内去重,返回既有 `dispatchId`);action=list 读最近 20 条。该文件受 guard 保护:只能经本工具写入,`write`/`edit`/shell 直写会被拒绝。台账是**提示级观测**(不做硬拦),`feel_status.dispatch` 汇总 `required / total / sincePhase / missingRoles / records`。',
|
|
1950
|
+
parameters: {
|
|
1951
|
+
action: stringEnum(['record', 'list'], '操作。', { required: true }),
|
|
1952
|
+
target_agent: string('目标子 agent 名(如 executor-a-cli)。record 必需。'),
|
|
1953
|
+
role: stringEnum(DISPATCH_ROLES, '目标角色。record 必需。'),
|
|
1954
|
+
goal: string('一句话任务(含验收命令,可直接粘贴进 subagent prompt)。record 必需。'),
|
|
1955
|
+
task_id: string('任务编号(如 T9),用于 5 分钟去重。record 必需。'),
|
|
1956
|
+
files: stringArray('本任务允许写的文件 / 目录清单(可选,写入台账的 files[])。'),
|
|
1957
|
+
stage: string('阶段 ID(可选;缺省取当前活跃阶段,读一次 flow next)。'),
|
|
1958
|
+
phase: string('相位(可选;缺省取当前阶段相位)。'),
|
|
1959
|
+
project: string('项目根目录。'),
|
|
1960
|
+
},
|
|
1961
|
+
output: { schema: envelopeSchema(), render: renderEnvelope },
|
|
1962
|
+
async execute(args, exec) {
|
|
1963
|
+
const resolved = target(exec, args);
|
|
1964
|
+
requireInitialized(resolved);
|
|
1965
|
+
const action = args.action;
|
|
1966
|
+
const opts = { cwd: resolved.cwd, signal: exec.signal };
|
|
1967
|
+
|
|
1968
|
+
switch (action) {
|
|
1969
|
+
case 'record': {
|
|
1970
|
+
const targetAgent = requireArg(args, 'target_agent', action);
|
|
1971
|
+
const role = requireArg(args, 'role', action);
|
|
1972
|
+
const goal = requireArg(args, 'goal', action);
|
|
1973
|
+
const taskId = requireArg(args, 'task_id', action);
|
|
1974
|
+
if (!DISPATCH_ROLES.includes(role)) {
|
|
1975
|
+
throw new FeelError(`非法 role: ${role}(合法值:${DISPATCH_ROLES.join(' / ')})`, {
|
|
1976
|
+
kind: 'usage',
|
|
1977
|
+
code: 'FEEL_INVALID_ARGUMENT',
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
return envelope(action, async () => {
|
|
1981
|
+
const focus = await resolveDispatchFocus(cli, opts, args);
|
|
1982
|
+
const origin = dispatchOriginOf(exec);
|
|
1983
|
+
const result = appendDispatch(resolved.cwd, {
|
|
1984
|
+
leadSessionId: dispatchSessionOf(exec, resolved.cwd),
|
|
1985
|
+
origin: origin.origin,
|
|
1986
|
+
stage: focus.stage,
|
|
1987
|
+
phase: focus.phase,
|
|
1988
|
+
targetAgent,
|
|
1989
|
+
role,
|
|
1990
|
+
taskId,
|
|
1991
|
+
goal,
|
|
1992
|
+
files: Array.isArray(args.files) ? args.files : [],
|
|
1993
|
+
returnFormat: '≤10 行:结论/改动文件/验证/阻塞',
|
|
1994
|
+
dispatchDepth: origin.dispatchDepth,
|
|
1995
|
+
});
|
|
1996
|
+
const where = focus.stage === '' ? '(无阶段)' : `${focus.stage}/${focus.phase || '(无相位)'}`;
|
|
1997
|
+
const summary = result.duplicate
|
|
1998
|
+
? `重复派发(5 分钟内同 leadSessionId+taskId+goal):沿用 ${result.dispatchId}(${where})。`
|
|
1999
|
+
: `已记录派发 ${result.dispatchId}:${role} → ${targetAgent}(${where})。`;
|
|
2000
|
+
return {
|
|
2001
|
+
data: { dispatchId: result.dispatchId, path: result.path, duplicate: result.duplicate },
|
|
2002
|
+
summary,
|
|
2003
|
+
next: { tool: 'feel_status', arguments: {}, why: '确认 dispatch.records / missingRoles 已更新。' },
|
|
2004
|
+
};
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
case 'list': {
|
|
2008
|
+
return envelope(action, async () => {
|
|
2009
|
+
const all = readDispatches(resolved.cwd);
|
|
2010
|
+
const records = all.slice(-20);
|
|
2011
|
+
return {
|
|
2012
|
+
data: { total: all.length, limit: 20, path: dispatchLedgerPath(resolved.cwd), records },
|
|
2013
|
+
summary: `派发台账共 ${all.length} 条,返回最近 ${records.length} 条(${DISPATCH_LEDGER_REL_PATH})。`,
|
|
2014
|
+
};
|
|
2015
|
+
});
|
|
2016
|
+
}
|
|
2017
|
+
default:
|
|
2018
|
+
throw new FeelError(`未知 action: ${action}`, { kind: 'usage', code: 'FEEL_UNKNOWN_ACTION' });
|
|
2019
|
+
}
|
|
2020
|
+
},
|
|
2021
|
+
presentCall: (args) => presentCall('Feel 派发台账', args.action, args?.target_agent),
|
|
2022
|
+
};
|
|
2023
|
+
|
|
2024
|
+
/* ══════════════════════════ 15. feel_dev ══════════════════════════ */
|
|
2025
|
+
|
|
2026
|
+
const feelDev = {
|
|
2027
|
+
name: 'feel_dev',
|
|
2028
|
+
description:
|
|
2029
|
+
'开发账本(openfeel dev):把提示里「更新交接摘要后运行 openfeel dev sync」这条**死指令**变成可执行工具。action=sync 立即同步受管 AUTO 块(`.openfeel/users/<u>/dev_last.md` + `.openfeel/dev/current.md`)并刷新 `.openfeel/dev/.sync.json`;action=status 只读查看 lastSync / due(与 CLI `openfeel dev status` 同源 `.openfeel/dev/.sync.json`)。CLI 的 `dev status` 没有 `--json`(零 JSON 契约),所以适配器跑真实命令作权威、结构化字段直接读同一份 `.sync.json`。返回 `{ok, lastSync, due, changed, wrote[]}`。',
|
|
2030
|
+
parameters: {
|
|
2031
|
+
action: stringEnum(['sync', 'status'], '操作。sync=立即同步账本;status=只读查看是否到期。', { required: true }),
|
|
2032
|
+
project: string('项目根目录。'),
|
|
2033
|
+
},
|
|
2034
|
+
output: { schema: envelopeSchema(), render: renderEnvelope },
|
|
2035
|
+
async execute(args, exec) {
|
|
2036
|
+
const resolved = target(exec, args);
|
|
2037
|
+
requireInitialized(resolved);
|
|
2038
|
+
const action = args.action;
|
|
2039
|
+
const opts = { cwd: resolved.cwd, signal: exec.signal };
|
|
2040
|
+
|
|
2041
|
+
if (action === 'status') {
|
|
2042
|
+
return envelope(action, async () => {
|
|
2043
|
+
// 真实命令校验「CLI 可用 + 项目已初始化」;字段与 CLI 同源(同一 .sync.json)。
|
|
2044
|
+
await cli.text(['dev', 'status'], opts);
|
|
2045
|
+
const status = readStatusSync(resolved.cwd);
|
|
2046
|
+
return {
|
|
2047
|
+
data: {
|
|
2048
|
+
ok: true,
|
|
2049
|
+
lastSync: status.lastSync,
|
|
2050
|
+
due: status.due,
|
|
2051
|
+
changed: false,
|
|
2052
|
+
wrote: [],
|
|
2053
|
+
},
|
|
2054
|
+
summary: `账本同步状态:lastSync=${status.lastSync ?? '(无)'} due=${status.due}(间隔 ${status.intervalMinutes} 分钟)。`,
|
|
2055
|
+
next: status.due
|
|
2056
|
+
? { tool: 'feel_dev', arguments: { action: 'sync' }, why: '状态记录已到期:立即同步一次。' }
|
|
2057
|
+
: null,
|
|
2058
|
+
};
|
|
2059
|
+
});
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
if (action !== 'sync') {
|
|
2063
|
+
throw new FeelError(`未知 action: ${action}`, { kind: 'usage', code: 'FEEL_UNKNOWN_ACTION' });
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
return envelope(action, async () => {
|
|
2067
|
+
// `wrote[]` 是**观测结果**,不是承诺:状态未变时 CLI 跳过重写(blockChanged),
|
|
2068
|
+
// 因此这里用同步前后内容对比得出真实变更,不硬编码「写到哪两个文件」。
|
|
2069
|
+
const before = snapshotDevDocs(resolved.cwd);
|
|
2070
|
+
await cli.write(['dev', 'sync'], opts);
|
|
2071
|
+
const wrote = diffDevDocs(before, snapshotDevDocs(resolved.cwd), resolved.cwd);
|
|
2072
|
+
const status = readStatusSync(resolved.cwd);
|
|
2073
|
+
return {
|
|
2074
|
+
data: {
|
|
2075
|
+
ok: true,
|
|
2076
|
+
lastSync: status.lastSync,
|
|
2077
|
+
due: status.due,
|
|
2078
|
+
changed: wrote.length > 0,
|
|
2079
|
+
wrote,
|
|
2080
|
+
},
|
|
2081
|
+
summary: wrote.length === 0
|
|
2082
|
+
? `账本已同步:状态未变(无文件重写),lastSync=${status.lastSync ?? '(无)'}。`
|
|
2083
|
+
: `账本已同步:重写 ${wrote.length} 个文件(${wrote.join(' / ')}),lastSync=${status.lastSync ?? '(无)'}。`,
|
|
2084
|
+
};
|
|
2085
|
+
});
|
|
2086
|
+
},
|
|
2087
|
+
presentCall: (args) => presentCall(`Feel 账本 ${args.action}`, args.action),
|
|
2088
|
+
};
|
|
2089
|
+
|
|
1666
2090
|
const tools = [
|
|
1667
2091
|
feelStatus,
|
|
1668
2092
|
feelNext,
|
|
@@ -1677,6 +2101,8 @@ export function createTools(context) {
|
|
|
1677
2101
|
feelReview,
|
|
1678
2102
|
feelPlan,
|
|
1679
2103
|
feelModel,
|
|
2104
|
+
feelDispatch,
|
|
2105
|
+
feelDev,
|
|
1680
2106
|
// 注册表既不编译也不校验 parameters(本插件不经 defineTool),
|
|
1681
2107
|
// 因此在交给注册表前统一转成子集接受的裸 JSON Schema。
|
|
1682
2108
|
].map((tool) => ({ ...tool, parameters: compileParameters(tool.parameters) }));
|
package/dsh/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openfeel-dsh",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "将 OpenFeel 的工作记录与开发流程接入 DeepSeek Harness:记住项目做到哪、下一步做什么,默认自由模式,也可切到按步骤走的流程模式",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"openfeel": {
|
|
38
38
|
"adapter": "dsh",
|
|
39
|
-
"requiresCli": ">=1.
|
|
39
|
+
"requiresCli": ">=1.6.0"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"openfeel",
|