openfeel 1.5.13 → 1.5.14

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 (37) 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 +11 -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 +11 -1
  28. package/dist/core/update.js.map +1 -1
  29. package/dsh/ADAPTER.md +9 -2
  30. package/dsh/lib/adapters/cli.js +15 -0
  31. package/dsh/lib/adapters/dashboard.js +8 -1
  32. package/dsh/lib/adapters/preflight.js +23 -1
  33. package/dsh/lib/guard.js +75 -4
  34. package/dsh/lib/surface/prompt.js +1 -1
  35. package/dsh/lib/tools/index.js +1 -1
  36. package/dsh/package.json +2 -2
  37. package/package.json +1 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  OpenFeel 是一个 TypeScript CLI 工具,为 AI Agent 开发提供端到端的流程治理。核心理念:**「提示词瘦身,流程入工具」** —— Agent 不靠读长文本理解流程,而是通过 `flow.json` 获取当前状态和下一步指令。
12
12
 
13
- > 📦 **最新版本 v1.5.13**(提交相位放宽 + skill frontmatter 修复) — ① `git commit` 允许相位由 `exec_running|archiving` 扩为 **`exec_running|review_passed|test_passed|archiving`**(审查/测试通过即可提交,无需先推进到 archiving;写侧未放宽,其余源码写仍只认 `exec_running`);② 修复 `openfeel-cli-usage` skill frontmatter 被裸 `#` 截断(`出口 #43` → `出口 No.43`,`description` 解析长度 2455 → 2766,v1.5.10/11/12 能力串重回 frontmatter)+ 新增 S6 回归测试。版本能力概览见 [docs/VERSIONS.md](docs/VERSIONS.md)。
13
+ > 📦 **最新版本 v1.5.14**(外部长会话反馈修复:op 落盘 / preflight 自愈 / 归档收尾提交 / 门禁体验) — ① `flow attempt` / `flow retry` 支持 op 短 ID,未找到/歧义列出候选并非 0 退出(不再静默 no-op);② preflight 窗口可用 `OPENFEEL_PREFLIGHT_MAX_AGE_MS` 放宽,适配器写前账本过期会真实自愈一次;③ 归档后无活跃阶段时新增 `git-commit-idle` 收尾提交通道;④ `flow next` 建议走通过路径、`archiving` 前提示先 verify、关联需求全完成时提示收口;⑤ `OPENFEEL_SHELL_ALLOW` 整条命令白名单 + 命令截断 200→500。版本能力概览见 [docs/VERSIONS.md](docs/VERSIONS.md)。
14
14
 
15
15
  > 📌 本项目基于 [AI_Prompt](https://github.com/Liuary/AI_Prompt) 开发,参考了 [OpenSpec](https://github.com/Fission-AI/OpenSpec) 等工具的设计思路。
16
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../src/commands/flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,WAAW,EAAyO,MAAM,yBAAyB,CAAC;AAwB7R,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsxF1D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAE9G;AAwHD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwCzE"}
1
+ {"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../src/commands/flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,WAAW,EAAyO,MAAM,yBAAyB,CAAC;AA+B7R,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAy3F1D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAE9G;AAwHD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwCzE"}
@@ -22,7 +22,13 @@ import { listArchivableCandidates, listBlockingOpenRevsForVersion, splitForArchi
22
22
  import { normalizeArchiveVersion, writeArchiveFile, addArchivedVersion, applyArchivePipelineDisposition, listArchiveVersions, readArchiveFile } from '../core/flow-archive/archive-ops.js';
23
23
  import { archiveHealthItems } from '../core/flow-archive/archive-health.js';
24
24
  import { requirementHealthItems, stageRequirementIds } from '../core/req/aggregate.js'; // 需求对账项(stage-83 T3)/ 关联读取单点(REQ-028)
25
- import { releaseCheckRequirements } from '../core/req/requirement-ops.js'; // 发布软门(v1.5.8 / REQ-030)
25
+ import { releaseCheckRequirements, isTerminalRequirementStatus } from '../core/req/requirement-ops.js'; // 发布软门(v1.5.8 / REQ-030)/ 终态判定单点(OF-07)
26
+ /**
27
+ * OF-07 悬挂阶段提醒的相位集:执行后、尚未被 done 门收口的活跃相位。
28
+ * 仅在这些相位提示「关联需求已全部完成,可考虑阶段收口/归档」——
29
+ * 需求完成与阶段关闭解耦后,阶段会长期停留在 exec_running(REQ-023)。
30
+ */
31
+ const HUNG_STAGE_PHASES = ['exec_running', 'review_passed', 'test_passed'];
26
32
  export function registerFlowCommand(program) {
27
33
  const flow = program
28
34
  .command('flow')
@@ -201,8 +207,15 @@ export function registerFlowCommand(program) {
201
207
  reviewTier = MODE_DERIVED_TIER[workflowMode];
202
208
  effectiveReviewTier = DEFAULT_EFFECTIVE_REVIEW_TIER;
203
209
  legalNextPhases = mgr.getAvailablePhases(activeKey);
204
- suggestedCommand = legalNextPhases.length > 0
205
- ? `openfeel flow advance --stage ${activeKey} --to ${legalNextPhases[0]}`
210
+ // OF-06:通过路径优先(review_pending → review_passed / test_pending → test_passed)。
211
+ // `legalNextPhases` 数组**顺序不变**(测试有 toEqual 顺序断言),仅「建议命令」的选项目标变化。
212
+ const suggestedPhase = currentPhase === 'review_pending' && legalNextPhases.includes('review_passed')
213
+ ? 'review_passed'
214
+ : currentPhase === 'test_pending' && legalNextPhases.includes('test_passed')
215
+ ? 'test_passed'
216
+ : legalNextPhases[0];
217
+ suggestedCommand = legalNextPhases.length > 0 && suggestedPhase
218
+ ? `openfeel flow advance --stage ${activeKey} --to ${suggestedPhase}`
206
219
  : null;
207
220
  blockingReviews = listStageBlockingOpenReviews(data.reviews, activeKey).map((r) => ({
208
221
  id: r.id, title: r.title, priority: r.priority, op: r.op,
@@ -233,6 +246,28 @@ export function registerFlowCommand(program) {
233
246
  if (derivedFromStages) {
234
247
  guards.push(t('flow.next.guardDerivedStage', lang));
235
248
  }
249
+ // OF-06:archiving 收口前置提示(固定追加在既有守卫之后;`suggestedCommand` 仍为 advance --to done)
250
+ if (currentPhase === 'archiving') {
251
+ guards.push(t('flow.next.guardArchivingVerifyTmpl', lang, { stage: activeKey }));
252
+ }
253
+ // OF-07:悬挂阶段提醒(关联需求 ≥1 且全部终态)——固定末位(archiving 提示之后)
254
+ if (HUNG_STAGE_PHASES.includes(currentPhase)) {
255
+ const linkedReqIds = stageRequirementIds(data.stages[activeKey]);
256
+ if (linkedReqIds.length > 0) {
257
+ const requirementList = Array.isArray(data.requirements) ? data.requirements : [];
258
+ const allTerminal = linkedReqIds.every((id) => {
259
+ const req = requirementList.find((r) => r.id === id);
260
+ // 关联需求查不到(孤儿关联)保守视为未完成,不提示
261
+ return req !== undefined && isTerminalRequirementStatus(req.status);
262
+ });
263
+ if (allTerminal) {
264
+ guards.push(t('flow.next.guardRequirementAllDoneTmpl', lang, {
265
+ n: String(linkedReqIds.length),
266
+ stage: activeKey,
267
+ }));
268
+ }
269
+ }
270
+ }
236
271
  }
237
272
  else {
238
273
  guards.push(t('flow.next.guardNoActiveStage', lang));
@@ -1318,7 +1353,9 @@ export function registerFlowCommand(program) {
1318
1353
  }
1319
1354
  }
1320
1355
  if (options.op && !options.quiet) {
1321
- console.log(t('flow.advance.opLabelTmpl', lang, { op: options.op }));
1356
+ // OF-02:`--op` 走 parseOpId(短 ID 可解析为 `<stage>.<op>` 全名);无法解析时原样回显,不阻断推进
1357
+ const opRef = mgr.resolveOpRef(options.op);
1358
+ console.log(t('flow.advance.opLabelTmpl', lang, { op: opRef?.fullId ?? options.op }));
1322
1359
  }
1323
1360
  });
1324
1361
  // flow attempt --op <id> --result <pass|fail>
@@ -1338,19 +1375,36 @@ export function registerFlowCommand(program) {
1338
1375
  console.error(t('flow.attempt.errorInvalidResult', lang));
1339
1376
  process.exit(1);
1340
1377
  }
1378
+ // OF-02:先解析 op 引用(全名 `<stage>.<op>` 或阶段内短 ID),未命中/歧义必须报错退出,
1379
+ // 禁止「getOp 返回 null → recordAttempt 静默 no-op → 仍打印成功」。
1380
+ const resolvedOp = mgr.resolveOpRef(options.op);
1381
+ if (!resolvedOp) {
1382
+ const diagnosis = mgr.diagnoseOpRef(options.op);
1383
+ const ambiguous = diagnosis?.reason === 'ambiguous';
1384
+ const message = ambiguous
1385
+ ? t('flow.opRef.ambiguousTmpl', lang, {
1386
+ op: options.op,
1387
+ matches: (diagnosis?.matches ?? []).join(', ') || t('common.none', lang),
1388
+ })
1389
+ : t('flow.opRef.notFoundTmpl', lang, { op: options.op });
1390
+ console.error(message);
1391
+ const candidates = diagnosis?.candidates ?? [];
1392
+ if (candidates.length > 0) {
1393
+ console.error(t('flow.opRef.candidatesTmpl', lang, { candidates: candidates.join(', ') }));
1394
+ }
1395
+ process.exit(1);
1396
+ return;
1397
+ }
1341
1398
  // B4-5(A1 第 5 条)/ REV-52-002:draft op 拒绝记录执行结果(命令层守卫;核心层 recordAttempt 另有兜底)
1342
- if (mgr.getOpState(options.op) === 'draft') {
1343
- const dotIdx = options.op.lastIndexOf('.');
1344
- const stageId = dotIdx >= 0 ? options.op.substring(0, dotIdx) : '';
1345
- const localOpId = dotIdx >= 0 ? options.op.substring(dotIdx + 1) : options.op;
1346
- console.error(t('flow.attempt.draftRefusedTmpl', lang, { stage: stageId, opId: localOpId }));
1399
+ if (mgr.getOpState(resolvedOp.fullId) === 'draft') {
1400
+ console.error(t('flow.attempt.draftRefusedTmpl', lang, { stage: resolvedOp.stage, opId: resolvedOp.op }));
1347
1401
  process.exit(1);
1348
1402
  return;
1349
1403
  }
1350
1404
  // v1.5.6-stage-114:写前 preflight(strict 拒绝;warn 仅 TTY 提示)
1351
1405
  if (!enforcePreflightOrFail(process.cwd(), lang))
1352
1406
  return;
1353
- const outcome = mgr.recordAttempt(options.op, options.result);
1407
+ const outcome = mgr.recordAttempt(resolvedOp.fullId, options.result);
1354
1408
  mgr.save();
1355
1409
  if (options.result === 'pass') {
1356
1410
  console.log(t('flow.attempt.passTmpl', lang, { op: options.op }));
@@ -1361,7 +1415,7 @@ export function registerFlowCommand(program) {
1361
1415
  else if (outcome.shouldReplan) {
1362
1416
  console.log(t('flow.attempt.failReplanTmpl', lang, { op: options.op }));
1363
1417
  // BUG-03 修复:shouldReplan 时自动推进到 scheme_pending
1364
- mgr.advancePhase(options.op, 'scheme_pending');
1418
+ mgr.advancePhase(resolvedOp.fullId, 'scheme_pending');
1365
1419
  mgr.save();
1366
1420
  console.log(t('flow.attempt.autoReplan', lang));
1367
1421
  }
@@ -1743,30 +1797,49 @@ export function registerFlowCommand(program) {
1743
1797
  });
1744
1798
  return;
1745
1799
  }
1746
- // 解析 opId 查找 op
1747
- const dotIdx = options.op.lastIndexOf('.');
1748
- if (dotIdx === -1) {
1800
+ // OF-02:统一 op 引用解析(全名 / 短 ID 同语义);不再自带 lastIndexOf('.') 拒绝(同仓禁双套 ID 语义)
1801
+ const resolvedOp = mgr.resolveOpRef(options.op);
1802
+ if (!resolvedOp) {
1803
+ const diagnosis = mgr.diagnoseOpRef(options.op);
1804
+ const ambiguous = diagnosis?.reason === 'ambiguous';
1805
+ const message = ambiguous
1806
+ ? t('flow.opRef.ambiguousTmpl', lang, {
1807
+ op: options.op,
1808
+ matches: (diagnosis?.matches ?? []).join(', ') || t('common.none', lang),
1809
+ })
1810
+ : t('flow.opRef.notFoundTmpl', lang, { op: options.op });
1811
+ const candidates = diagnosis?.candidates ?? [];
1812
+ // v1.5.14:全名引用的阶段不存在 → 保留既有 STAGE_NOT_FOUND 契约
1813
+ // (docs/commands.md `flow retry` 与 json-contract;短 ID 未命中仍走 INVALID_ARGUMENT)。
1814
+ const dotIdx = options.op.lastIndexOf('.');
1815
+ if (dotIdx > 0) {
1816
+ const rawStageId = options.op.substring(0, dotIdx);
1817
+ const stageId = normalizeStageId(rawStageId) ?? rawStageId;
1818
+ if (!data.stages[stageId] && !data.stages[rawStageId]) {
1819
+ failRefusal({
1820
+ code: 'STAGE_NOT_FOUND',
1821
+ message: t('flow.retry.errorStageNotFoundTmpl', lang, { stage: stageId }),
1822
+ detail: { reason: 'stage-not-found', stage: stageId },
1823
+ });
1824
+ return;
1825
+ }
1826
+ }
1827
+ const stderrLines = candidates.length > 0
1828
+ ? [message, t('flow.opRef.candidatesTmpl', lang, { candidates: candidates.join(', ') })]
1829
+ : [message];
1749
1830
  failRefusal({
1750
1831
  code: 'INVALID_ARGUMENT',
1751
- message: t('common.invalidOpId', lang),
1752
- detail: { reason: 'invalid-op-id', op: options.op },
1753
- });
1754
- return;
1755
- }
1756
- const rawStageId = options.op.substring(0, dotIdx);
1757
- const opLocalId = options.op.substring(dotIdx + 1);
1758
- // REV-007:短名前缀归一化(与 op-012 advance 同范式)+ 双键回退(归一化键优先)
1759
- const stageId = normalizeStageId(rawStageId) ?? rawStageId;
1760
- const stage = data.stages[stageId] ?? data.stages[rawStageId];
1761
- if (!stage) {
1762
- failRefusal({
1763
- code: 'STAGE_NOT_FOUND',
1764
- message: t('flow.retry.errorStageNotFoundTmpl', lang, { stage: stageId }),
1765
- detail: { reason: 'stage-not-found', stage: stageId },
1832
+ message,
1833
+ detail: {
1834
+ reason: diagnosis?.reason ?? 'op-not-found',
1835
+ op: options.op,
1836
+ candidates,
1837
+ },
1838
+ stderrLines,
1766
1839
  });
1767
1840
  return;
1768
1841
  }
1769
- const op = stage.ops[opLocalId];
1842
+ const op = data.stages[resolvedOp.stage]?.ops?.[resolvedOp.op];
1770
1843
  if (!op) {
1771
1844
  failRefusal({
1772
1845
  code: 'INVALID_ARGUMENT',
@@ -1775,7 +1848,7 @@ export function registerFlowCommand(program) {
1775
1848
  });
1776
1849
  return;
1777
1850
  }
1778
- const retryCount = mgr.getRetryCount(options.op);
1851
+ const retryCount = mgr.getRetryCount(resolvedOp.fullId);
1779
1852
  // JSON 与人类输出共享同一业务判定(attempts / exhausted 计算单点)
1780
1853
  const exhausted = retryCount >= op.max_attempts;
1781
1854
  if (options.json) {
@@ -2186,6 +2259,40 @@ export function registerFlowCommand(program) {
2186
2259
  };
2187
2260
  if (!options.dryRun && !enforcePreflightOrFail(projectPath, lang, { reject }))
2188
2261
  return;
2262
+ // OF-02:归档前提示候选阶段内未完成的 op(仅人类模式;不阻断、不改退出码、`--json` 零变化)。
2263
+ // 位置:preflight 之后、切分之前——判据门外仍可见,避免「op 未标记完成却被静默归档」。
2264
+ if (options.json !== true) {
2265
+ for (const stageId of candidate.stages) {
2266
+ const stage = data.stages[stageId];
2267
+ if (!stage)
2268
+ continue;
2269
+ for (const [opLocalId, op] of Object.entries(stage.ops ?? {})) {
2270
+ if (op && op.state !== 'done') {
2271
+ console.error(t('flow.archive.opNotDoneTmpl', lang, {
2272
+ op: `${stageId}.${opLocalId}`,
2273
+ state: op.state,
2274
+ }));
2275
+ }
2276
+ }
2277
+ }
2278
+ }
2279
+ // OF-04:归档前脏区提示(仅人类模式;不阻断、不改退出码、`--json` 零变化)。
2280
+ // 归档后收尾提交走 `git-commit-idle` 通道,但「先提交再归档」仍是更干净的顺序。
2281
+ if (options.json !== true) {
2282
+ try {
2283
+ const dirty = execSync('git status --porcelain', {
2284
+ cwd: projectPath,
2285
+ encoding: 'utf-8',
2286
+ timeout: 5000,
2287
+ }).trim();
2288
+ if (dirty !== '') {
2289
+ console.error(t('flow.archive.gitDirtyWarnTmpl', lang, { version }));
2290
+ }
2291
+ }
2292
+ catch {
2293
+ /* 非 git 仓库 / git 不可用:静默跳过(与 flow advance 的脏区检查同语义) */
2294
+ }
2295
+ }
2189
2296
  // 切分(纯函数;禁命令层第二套解析/切分)
2190
2297
  const { archive, remainder } = splitForArchive(data, version);
2191
2298
  const counts = archive.counts;