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.
Files changed (82) hide show
  1. package/README.en.md +7 -0
  2. package/README.zh-CN.md +7 -0
  3. package/dist/commands/flow.d.ts.map +1 -1
  4. package/dist/commands/flow.js +117 -23
  5. package/dist/commands/flow.js.map +1 -1
  6. package/dist/commands/lint.d.ts +3 -1
  7. package/dist/commands/lint.d.ts.map +1 -1
  8. package/dist/commands/lint.js +96 -0
  9. package/dist/commands/lint.js.map +1 -1
  10. package/dist/commands/req.d.ts.map +1 -1
  11. package/dist/commands/req.js +392 -17
  12. package/dist/commands/req.js.map +1 -1
  13. package/dist/commands/stage.d.ts.map +1 -1
  14. package/dist/commands/stage.js +19 -0
  15. package/dist/commands/stage.js.map +1 -1
  16. package/dist/core/dev-status.d.ts +25 -0
  17. package/dist/core/dev-status.d.ts.map +1 -1
  18. package/dist/core/dev-status.js +35 -0
  19. package/dist/core/dev-status.js.map +1 -1
  20. package/dist/core/errors.d.ts +13 -3
  21. package/dist/core/errors.d.ts.map +1 -1
  22. package/dist/core/errors.js +9 -3
  23. package/dist/core/errors.js.map +1 -1
  24. package/dist/core/flow-manager.d.ts +109 -3
  25. package/dist/core/flow-manager.d.ts.map +1 -1
  26. package/dist/core/flow-manager.js +326 -14
  27. package/dist/core/flow-manager.js.map +1 -1
  28. package/dist/core/i18n-data/en.d.ts.map +1 -1
  29. package/dist/core/i18n-data/en.js +56 -2
  30. package/dist/core/i18n-data/en.js.map +1 -1
  31. package/dist/core/i18n-data/zh-CN.d.ts.map +1 -1
  32. package/dist/core/i18n-data/zh-CN.js +56 -2
  33. package/dist/core/i18n-data/zh-CN.js.map +1 -1
  34. package/dist/core/lint-req.d.ts +17 -1
  35. package/dist/core/lint-req.d.ts.map +1 -1
  36. package/dist/core/lint-req.js +14 -2
  37. package/dist/core/lint-req.js.map +1 -1
  38. package/dist/core/plan/body-lint.d.ts +58 -0
  39. package/dist/core/plan/body-lint.d.ts.map +1 -0
  40. package/dist/core/plan/body-lint.js +197 -0
  41. package/dist/core/plan/body-lint.js.map +1 -0
  42. package/dist/core/plan/filled.d.ts +143 -0
  43. package/dist/core/plan/filled.d.ts.map +1 -0
  44. package/dist/core/plan/filled.js +244 -0
  45. package/dist/core/plan/filled.js.map +1 -0
  46. package/dist/core/plan/path.d.ts +24 -0
  47. package/dist/core/plan/path.d.ts.map +1 -1
  48. package/dist/core/plan/path.js +56 -0
  49. package/dist/core/plan/path.js.map +1 -1
  50. package/dist/core/req/aggregate.d.ts.map +1 -1
  51. package/dist/core/req/aggregate.js +5 -0
  52. package/dist/core/req/aggregate.js.map +1 -1
  53. package/dist/core/req/body-file.d.ts +66 -0
  54. package/dist/core/req/body-file.d.ts.map +1 -1
  55. package/dist/core/req/body-file.js +184 -2
  56. package/dist/core/req/body-file.js.map +1 -1
  57. package/dist/core/req/requirement-ops.d.ts +128 -14
  58. package/dist/core/req/requirement-ops.d.ts.map +1 -1
  59. package/dist/core/req/requirement-ops.js +341 -16
  60. package/dist/core/req/requirement-ops.js.map +1 -1
  61. package/dist/core/req/types.d.ts +55 -0
  62. package/dist/core/req/types.d.ts.map +1 -1
  63. package/dist/core/template-loader.d.ts.map +1 -1
  64. package/dist/core/template-loader.js +75 -0
  65. package/dist/core/template-loader.js.map +1 -1
  66. package/dsh/ACTION-GUIDE.md +41 -8
  67. package/dsh/ADAPTER.md +58 -13
  68. package/dsh/README.md +45 -24
  69. package/dsh/docs/compat/persistence.md +13 -0
  70. package/dsh/docs/compat/pipeline.md +12 -0
  71. package/dsh/docs/compat/req.md +14 -0
  72. package/dsh/docs/compat/stage.md +13 -0
  73. package/dsh/lib/adapters/dashboard.js +10 -0
  74. package/dsh/lib/adapters/dispatch-ledger.js +293 -0
  75. package/dsh/lib/adapters/dispatch.js +54 -6
  76. package/dsh/lib/adapters/next-action.js +336 -0
  77. package/dsh/lib/guard.js +9 -2
  78. package/dsh/lib/index.js +37 -0
  79. package/dsh/lib/surface/prompt.js +62 -173
  80. package/dsh/lib/tools/index.js +435 -9
  81. package/dsh/package.json +2 -2
  82. package/package.json +1 -1
package/README.en.md CHANGED
@@ -79,6 +79,13 @@ openfeel flow next # 5. Iterate as
79
79
  - **general**: pipeline-free ad-hoc work, requirement-level only;
80
80
  - requirements auto-close once every linked stage is done.
81
81
 
82
+ ### Real requirement bodies and a plan before execution (v1.6.0)
83
+
84
+ - **Bodies must be real**: after creating a requirement, fill it with `openfeel req body REQ-NNN --section 摘要 --text "…"` (then `--section 目标与验收`); a skeleton requirement is refused on **status transitions** (`→scheduled` / `→in_progress` / `→done`) with `REQ_BODY_GATE` (`--force` records a waiver and an audit entry, but the file still has to be written; claim does not check the body).
85
+ - **A requirement-level plan is required before execution**: `→in_progress` needs a filled `.openfeel/plan/reqs/REQ-NNN.plan.md`; entering `exec_running` also checks the stage `plan.md` and every in-flight requirement plan (`STAGE_PLAN_GATE`), and `flow stage reset --to exec_running` follows the same rule.
86
+ - **Every mode enforces plan → exec → review**: `general` / `fast` / `full` all require "requirement plan → execute → review"; only the stage-level trimming of scheme/test differs, and `general` remains **requirement-level only** (its stage-level transition table stays empty).
87
+ - `--force` is a **recorded override** (waiver + `flow.json.log` audit), never a bypass of the done gate (review + verify), blocking REVs or archive criteria; existing skeletons are listed by `openfeel lint fill`.
88
+
82
89
  ## Claude Code Adapter (since v1.1.6)
83
90
 
84
91
  > Coexists with the opencode adapter; **disabled by default** (requires explicit `--tools claude`).
package/README.zh-CN.md CHANGED
@@ -79,6 +79,13 @@ openfeel flow next # 5. 按调度
79
79
  - **general**:无流水线的零散任务,仅需求级合法;
80
80
  - 需求关联阶段后,全部关联阶段 done 时自动收口需求。
81
81
 
82
+ ### 需求写实与执行前计划(v1.6.0)
83
+
84
+ - **正文必须写实**:新建需求后用 `openfeel req body REQ-NNN --section 摘要 --text "…"`(再 `--section 目标与验收`)写实正文;空壳需求在**状态流转**(`→scheduled` / `→in_progress` / `→done`)时被 `REQ_BODY_GATE` 拦住(`--force` 留痕放行,文件仍须补写;认领不校验正文)。
85
+ - **执行前必须有需求级计划**:`.openfeel/plan/reqs/REQ-NNN.plan.md` 写实后才可 `→in_progress`;阶段进入 `exec_running` 前还会检查阶段 `plan.md` 与全部在办需求计划(`STAGE_PLAN_GATE`),复位(`flow stage reset --to exec_running`)同口径。
86
+ - **全模式强制 plan → exec → review**:`general` / `fast` / `full` 一律要求「需求级计划 → 执行 → 审查」,区别只在阶段级是否裁剪 scheme/test;`general` 仍**仅需求级合法**,阶段级转移表保持为空。
87
+ - `--force` 只做**留痕放行**(waiver + `flow.json.log` 审计),**不能**绕过 done 门(review + verify)、blocking REV 与版本归档判据;存量空壳可用 `openfeel lint fill` 枚举。
88
+
82
89
  ## Claude Code 适配器(v1.1.6 起)
83
90
 
84
91
  > 与 opencode 适配器**并存**,**默认不启用**(须显式 `--tools claude`)。
@@ -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;AA+B7R,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAs6F1D;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,EAAwS,MAAM,yBAAyB,CAAC;AA+B5V,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsgG1D;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,7 +1,7 @@
1
1
  import { execSync } from 'node:child_process';
2
2
  import { existsSync, copyFileSync, readFileSync, rmSync } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
- import { FlowManager, isFlowConcurrentError, normalizeAgentName, detectFillState, MODE_DERIVED_TIER, listStageBlockingOpenReviews, PHASE_PATH_MAX_DEPTH } from '../core/flow-manager.js';
4
+ import { FlowManager, isFlowConcurrentError, normalizeAgentName, detectFillState, MODE_DERIVED_TIER, listStageBlockingOpenReviews, isStagePlanGateBlocked, StagePlanGateError, DevSyncStaleError, PHASE_PATH_MAX_DEPTH } from '../core/flow-manager.js';
5
5
  import { PipelinePhaseSchema, PIPELINE_PHASES, REVIEW_TIERS, TIER_PRUNED_PHASES, DEFAULT_EFFECTIVE_REVIEW_TIER } from '../core/pipeline-schema.js';
6
6
  import { validateStageId, suggestStageId, normalizeStageId, findStageStatusPath, isArchivedVersionOf } from '../core/plan/path.js';
7
7
  import { getConfigFieldLegalValues, setConfigValue, readExplicitConfigDefaults } from '../core/config.js';
@@ -16,7 +16,7 @@ import { recordPreflight, readPreflight } from '../core/preflight.js';
16
16
  import { findPhaseEnteredAtMs } from '../core/phase-entered.js';
17
17
  import { computeProcessHealth, formatProcessHealth } from '../core/process-health.js';
18
18
  import { enforcePreflightOrFail } from './shared/preflight-gate.js';
19
- import { getDevStatus, isSyncNodePhase, syncDevStatus } from '../core/dev-status.js';
19
+ import { maybeSyncDevStatus } from '../core/dev-status.js';
20
20
  import { ARCHIVE_SCHEMA_VERSION } from '../core/flow-archive/archive-file.js';
21
21
  import { listArchivableCandidates, listBlockingOpenRevsForVersion, splitForArchive } from '../core/flow-archive/grouping.js';
22
22
  import { normalizeArchiveVersion, writeArchiveFile, addArchivedVersion, applyArchivePipelineDisposition, listArchiveVersions, readArchiveFile, maxRequirementSeq } from '../core/flow-archive/archive-ops.js';
@@ -881,12 +881,13 @@ export function registerFlowCommand(program) {
881
881
  deps: deps.length > 0 ? deps.join(', ') : t('common.none', lang),
882
882
  }));
883
883
  });
884
- // flow stage reset <stageId> --to <phase> [--dry-run]
884
+ // flow stage reset <stageId> --to <phase> [--dry-run] [--force]
885
885
  stageCmd
886
886
  .command('reset <stageId>')
887
887
  .description('复位阶段 phase(允许回退;受合法值域与 to=done 的 REV 阻塞约束)')
888
888
  .requiredOption('--to <phase>', '目标 phase(如 review_pending / test_pending / done);合法值见 openfeel flow phases')
889
889
  .option('--dry-run', '仅预览,不写盘')
890
+ .option('--force', '越过进入 exec_running 的计划门(放行并在 flow.json.log 记录 gate_overrides/gate_missing)')
890
891
  .action((stageId, options) => {
891
892
  const lang = getCliLang(process.cwd());
892
893
  const mgr = createManager();
@@ -896,7 +897,10 @@ export function registerFlowCommand(program) {
896
897
  }
897
898
  const stageArg = normalizeStageId(stageId) ?? stageId;
898
899
  try {
899
- const result = mgr.resetStagePhase(stageArg, options.to, { dryRun: options.dryRun });
900
+ const result = mgr.resetStagePhase(stageArg, options.to, {
901
+ dryRun: options.dryRun,
902
+ allowGateOverride: options.force === true,
903
+ });
900
904
  if (options.dryRun) {
901
905
  console.log(t('flow.stage.reset.previewTitle', lang));
902
906
  console.log(t('flow.stage.reset.previewTmpl', lang, {
@@ -927,6 +931,23 @@ export function registerFlowCommand(program) {
927
931
  }));
928
932
  }
929
933
  catch (err) {
934
+ // v1.6.0 / REQ-056 T5:复位到 exec_running 与 exec 门同口径复检计划;拒绝给两条出路
935
+ // (补计划文件 / 加 --force 留痕放行),零写盘。
936
+ if (err instanceof StagePlanGateError) {
937
+ const lines = mgr.formatStagePlanGate(stageArg, err.gate, lang);
938
+ failRefusal({
939
+ code: 'STAGE_PLAN_GATE',
940
+ message: lines[0] ?? err.message,
941
+ detail: {
942
+ stagePlanMissing: err.gate.stagePlanMissing,
943
+ stagePlanUnfilled: err.gate.stagePlanUnfilled,
944
+ requirementsMissingPlan: err.gate.requirementsMissingPlan,
945
+ requirementsUnfilledPlan: err.gate.requirementsUnfilledPlan,
946
+ },
947
+ stderrLines: lines,
948
+ });
949
+ return;
950
+ }
930
951
  // 并发写冲突:统一单点(i18n 文案 + 退出码 2);JSON 模式置码返回 → 显式 return 防落入通用分支
931
952
  if (isFlowConcurrentError(err)) {
932
953
  handleConcurrentConflict(err, lang);
@@ -1204,6 +1225,30 @@ export function registerFlowCommand(program) {
1204
1225
  return;
1205
1226
  }
1206
1227
  }
1228
+ // v1.6.0 / REQ-056 T5「执行前有计划」硬门(命令层镜像):**进入** exec_running 要求
1229
+ // 阶段 plan.md 与每个在办需求的 REQ-NNN.plan.md 存在且写实。
1230
+ // 判据单源 = mgr.describeStagePlanGate / isStagePlanGateBlocked(与 advanceStagePhase 内同一谓词);
1231
+ // `--force` 不绕过拦截:它只把 allowGateOverride 传给核心层做**留痕放行**(gate_overrides)。
1232
+ // 位置:done 门镜像之后、逐步推进之前;多步路径中 exec_running 为中间步时由循环 catch 兜底。
1233
+ const entersExecRunning = phasePath.some((p, i) => p === 'exec_running' && (i > 0 ? phasePath[i - 1] : startPhase) !== 'exec_running');
1234
+ if (entersExecRunning && options.force !== true) {
1235
+ const planGate = mgr.describeStagePlanGate(stageArg);
1236
+ if (isStagePlanGateBlocked(planGate)) {
1237
+ const lines = mgr.formatStagePlanGate(stageArg, planGate, lang);
1238
+ failRefusal({
1239
+ code: 'STAGE_PLAN_GATE',
1240
+ message: lines[0] ?? t('common.errorTmpl', lang, { msg: 'plan gate' }),
1241
+ detail: {
1242
+ stagePlanMissing: planGate.stagePlanMissing,
1243
+ stagePlanUnfilled: planGate.stagePlanUnfilled,
1244
+ requirementsMissingPlan: planGate.requirementsMissingPlan,
1245
+ requirementsUnfilledPlan: planGate.requirementsUnfilledPlan,
1246
+ },
1247
+ stderrLines: lines,
1248
+ });
1249
+ return;
1250
+ }
1251
+ }
1207
1252
  // 逐步推进(B5-2 / A3):唯一路径 → 依次调用 advanceStagePhase(保留每步校验/日志/checkpoint)
1208
1253
  // 中间态不回滚(A3);失败 → 输出「已完成 / 失败点 / 剩余路径」+ exit 1
1209
1254
  // T1:recordRun 接线(命令层;--dry-run 已于上方提前 return——天然排除)
@@ -1228,14 +1273,51 @@ export function registerFlowCommand(program) {
1228
1273
  : undefined;
1229
1274
  if (reworkReason !== undefined)
1230
1275
  reasonUsed = true;
1231
- const stepOpts = {};
1276
+ // v1.6.0 / REQ-056 T5:`--force` → 计划门留痕放行(只传开关,判定仍在核心层)
1277
+ const stepOpts = {
1278
+ allowGateOverride: options.force === true,
1279
+ };
1232
1280
  if (explicitTier)
1233
1281
  stepOpts.reviewTier = explicitTier;
1234
1282
  if (reworkReason !== undefined)
1235
1283
  stepOpts.reworkReason = reworkReason;
1236
- archived = mgr.advanceStagePhase(stageArg, next, 'cli', Object.keys(stepOpts).length > 0 ? stepOpts : undefined);
1284
+ archived = mgr.advanceStagePhase(stageArg, next, 'cli', stepOpts);
1237
1285
  }
1238
1286
  catch (err) {
1287
+ // v1.6.0 / REQ-056 T5:计划门拒绝按预期拒绝出口(exit 1 + STAGE_PLAN_GATE envelope),
1288
+ // 不归内部错误(多步循环中 exec_running 为中间步时同样命中)。
1289
+ if (err instanceof StagePlanGateError) {
1290
+ const lines = mgr.formatStagePlanGate(stageArg, err.gate, lang);
1291
+ failRefusal({
1292
+ code: 'STAGE_PLAN_GATE',
1293
+ message: lines[0] ?? err.message,
1294
+ detail: {
1295
+ stagePlanMissing: err.gate.stagePlanMissing,
1296
+ stagePlanUnfilled: err.gate.stagePlanUnfilled,
1297
+ requirementsMissingPlan: err.gate.requirementsMissingPlan,
1298
+ requirementsUnfilledPlan: err.gate.requirementsUnfilledPlan,
1299
+ },
1300
+ stderrLines: lines,
1301
+ });
1302
+ return;
1303
+ }
1304
+ // v1.6.0 / REQ-059 T8:账本陈旧门(done 前同步失败)同样按预期拒绝出口
1305
+ // (exit 1 + DEV_SYNC_STALE envelope);`--force` 已在核心层留痕放行,走不到这里。
1306
+ if (err instanceof DevSyncStaleError) {
1307
+ const lines = mgr.formatDevSyncStale(stageArg, err.reason, lang);
1308
+ failRefusal({
1309
+ code: 'DEV_SYNC_STALE',
1310
+ message: lines[0] ?? err.message,
1311
+ detail: {
1312
+ stage: stageArg,
1313
+ to: 'done',
1314
+ due: true,
1315
+ error: err.reason,
1316
+ },
1317
+ stderrLines: lines,
1318
+ });
1319
+ return;
1320
+ }
1239
1321
  // v1.5.23 / REQ-042(六期缺陷 A):失败也要记账。
1240
1322
  // 旧实现只在成功分支 recordRun(..., 'success'),导致 metrics.json 的
1241
1323
  // failedRuns / 成功率永远是「零失败」——读出来不是空,是静默误导。
@@ -1322,17 +1404,17 @@ export function registerFlowCommand(program) {
1322
1404
  }
1323
1405
  }
1324
1406
  }
1325
- // v1.5.0:状态记录瘦身——节点(开始/转折/结束)或超过 30 分钟时 CLI 自动同步简要状态;
1326
- // 失败不影响推进(状态记录不是门禁)。
1327
- try {
1328
- const projectPath = process.cwd();
1329
- if (getDevStatus(projectPath).due || isSyncNodePhase(options.to)) {
1330
- syncDevStatus(projectPath);
1407
+ // v1.5.0 / v1.6.0(REQ-059 T8;REV-019):状态记录瘦身——节点(开始/转折/结束)或超过 30 分钟时
1408
+ // CLI 自动同步简要状态。失败**不阻断推进**(状态记录不是门禁),但也不再静默吞掉:
1409
+ // 一行 stderr 告知原因;done 前的硬门(DEV_SYNC_STALE)在核心层承担拦截。
1410
+ // 去重:`--to done` 已在 `advanceStagePhase` 的 done 门**先**跑过一次 `maybeSyncDevStatus`
1411
+ // (同一命令、同一 projectPath),此处不再重复调用;其余出口仍需自动同步。
1412
+ if (options.to !== 'done') {
1413
+ const sync = maybeSyncDevStatus(process.cwd());
1414
+ if (sync.error !== undefined) {
1415
+ console.warn(t('flow.dev.syncFailedTmpl', lang, { err: sync.error }));
1331
1416
  }
1332
1417
  }
1333
- catch {
1334
- /* best-effort */
1335
- }
1336
1418
  // T1:仅本命令内有记录时落盘一次(低并发非关键路径;推进失败提前 exit 则不 save)
1337
1419
  if (metricsRecorded) {
1338
1420
  metricsStore.save();
@@ -1624,14 +1706,26 @@ export function registerFlowCommand(program) {
1624
1706
  const blocking = options.blocking !== undefined
1625
1707
  ? !(options.blocking === 'false' || options.blocking === false)
1626
1708
  : true;
1627
- const result = addReviewEntry(process.cwd(), {
1628
- opId: options.op,
1629
- stageId: options.stage,
1630
- title: options.title || t('flow.review.detail', lang) + `: ${options.op ?? options.stage}`,
1631
- priority: 'medium',
1632
- autoFixDetail: options.autoFix,
1633
- blocking,
1634
- });
1709
+ let result;
1710
+ try {
1711
+ result = addReviewEntry(process.cwd(), {
1712
+ opId: options.op,
1713
+ stageId: options.stage,
1714
+ title: options.title || t('flow.review.detail', lang) + `: ${options.op ?? options.stage}`,
1715
+ priority: 'medium',
1716
+ autoFixDetail: options.autoFix,
1717
+ blocking,
1718
+ });
1719
+ }
1720
+ catch (err) {
1721
+ // v1.6.0 / REQ-056 T5:--auto-fix 会跨越进入 exec_running;计划门拒绝时给可读拒绝而非未捕获栈
1722
+ if (err instanceof StagePlanGateError) {
1723
+ console.error(err.message);
1724
+ process.exit(1);
1725
+ return;
1726
+ }
1727
+ throw err;
1728
+ }
1635
1729
  if (result.error) {
1636
1730
  // 错误路径:按错误码分流 i18n 文案(单点返回 code,命令层只负责呈现)
1637
1731
  switch (result.error.code) {