openfeel 1.5.6 → 1.5.8

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 (94) hide show
  1. package/README.md +3 -1
  2. package/dist/commands/archive.d.ts.map +1 -1
  3. package/dist/commands/archive.js +29 -3
  4. package/dist/commands/archive.js.map +1 -1
  5. package/dist/commands/flow.d.ts.map +1 -1
  6. package/dist/commands/flow.js +77 -6
  7. package/dist/commands/flow.js.map +1 -1
  8. package/dist/commands/plan.d.ts.map +1 -1
  9. package/dist/commands/plan.js +9 -1
  10. package/dist/commands/plan.js.map +1 -1
  11. package/dist/commands/req.d.ts +1 -1
  12. package/dist/commands/req.d.ts.map +1 -1
  13. package/dist/commands/req.js +397 -75
  14. package/dist/commands/req.js.map +1 -1
  15. package/dist/commands/shared/errors.d.ts +18 -1
  16. package/dist/commands/shared/errors.d.ts.map +1 -1
  17. package/dist/commands/shared/errors.js +32 -2
  18. package/dist/commands/shared/errors.js.map +1 -1
  19. package/dist/commands/shared/json-output.d.ts.map +1 -1
  20. package/dist/commands/shared/json-output.js +1 -0
  21. package/dist/commands/shared/json-output.js.map +1 -1
  22. package/dist/commands/stage.d.ts.map +1 -1
  23. package/dist/commands/stage.js +76 -2
  24. package/dist/commands/stage.js.map +1 -1
  25. package/dist/core/archive/merge.d.ts +35 -5
  26. package/dist/core/archive/merge.d.ts.map +1 -1
  27. package/dist/core/archive/merge.js +275 -5
  28. package/dist/core/archive/merge.js.map +1 -1
  29. package/dist/core/dev/sessions.d.ts +106 -0
  30. package/dist/core/dev/sessions.d.ts.map +1 -0
  31. package/dist/core/dev/sessions.js +197 -0
  32. package/dist/core/dev/sessions.js.map +1 -0
  33. package/dist/core/dev-status.d.ts.map +1 -1
  34. package/dist/core/dev-status.js +3 -1
  35. package/dist/core/dev-status.js.map +1 -1
  36. package/dist/core/flow-archive/archive-file.d.ts +14 -3
  37. package/dist/core/flow-archive/archive-file.d.ts.map +1 -1
  38. package/dist/core/flow-archive/archive-file.js.map +1 -1
  39. package/dist/core/flow-archive/archive-ops.d.ts +24 -0
  40. package/dist/core/flow-archive/archive-ops.d.ts.map +1 -1
  41. package/dist/core/flow-archive/archive-ops.js +52 -5
  42. package/dist/core/flow-archive/archive-ops.js.map +1 -1
  43. package/dist/core/flow-archive/grouping.d.ts +5 -0
  44. package/dist/core/flow-archive/grouping.d.ts.map +1 -1
  45. package/dist/core/flow-archive/grouping.js +31 -0
  46. package/dist/core/flow-archive/grouping.js.map +1 -1
  47. package/dist/core/flow-manager.d.ts +131 -2
  48. package/dist/core/flow-manager.d.ts.map +1 -1
  49. package/dist/core/flow-manager.js +259 -19
  50. package/dist/core/flow-manager.js.map +1 -1
  51. package/dist/core/harness.d.ts +15 -0
  52. package/dist/core/harness.d.ts.map +1 -0
  53. package/dist/core/harness.js +75 -0
  54. package/dist/core/harness.js.map +1 -0
  55. package/dist/core/i18n-data/en.d.ts.map +1 -1
  56. package/dist/core/i18n-data/en.js +97 -8
  57. package/dist/core/i18n-data/en.js.map +1 -1
  58. package/dist/core/i18n-data/zh-CN.d.ts.map +1 -1
  59. package/dist/core/i18n-data/zh-CN.js +97 -8
  60. package/dist/core/i18n-data/zh-CN.js.map +1 -1
  61. package/dist/core/plan/path.d.ts +52 -0
  62. package/dist/core/plan/path.d.ts.map +1 -1
  63. package/dist/core/plan/path.js +109 -3
  64. package/dist/core/plan/path.js.map +1 -1
  65. package/dist/core/plan/stage.d.ts.map +1 -1
  66. package/dist/core/plan/stage.js +24 -2
  67. package/dist/core/plan/stage.js.map +1 -1
  68. package/dist/core/req/aggregate.d.ts +20 -4
  69. package/dist/core/req/aggregate.d.ts.map +1 -1
  70. package/dist/core/req/aggregate.js +55 -40
  71. package/dist/core/req/aggregate.js.map +1 -1
  72. package/dist/core/req/body-file.js +1 -1
  73. package/dist/core/req/body-file.js.map +1 -1
  74. package/dist/core/req/requirement-ops.d.ts +140 -12
  75. package/dist/core/req/requirement-ops.d.ts.map +1 -1
  76. package/dist/core/req/requirement-ops.js +331 -38
  77. package/dist/core/req/requirement-ops.js.map +1 -1
  78. package/dist/core/req/stage-links.d.ts +35 -0
  79. package/dist/core/req/stage-links.d.ts.map +1 -0
  80. package/dist/core/req/stage-links.js +46 -0
  81. package/dist/core/req/stage-links.js.map +1 -0
  82. package/dist/core/req/types.d.ts +53 -0
  83. package/dist/core/req/types.d.ts.map +1 -1
  84. package/dist/core/req/types.js +4 -0
  85. package/dist/core/req/types.js.map +1 -1
  86. package/dsh/ADAPTER.md +9 -4
  87. package/dsh/README.md +25 -4
  88. package/dsh/lib/adapters/sessions.js +183 -0
  89. package/dsh/lib/adapters/workflow-gate.js +12 -8
  90. package/dsh/lib/guard.js +4 -4
  91. package/dsh/lib/surface/prompt.js +24 -6
  92. package/dsh/lib/tools/index.js +240 -11
  93. package/dsh/package.json +4 -3
  94. package/package.json +4 -2
package/dsh/lib/guard.js CHANGED
@@ -510,8 +510,8 @@ export function createOpenFeelGuard(options = {}) {
510
510
  paths: targets,
511
511
  });
512
512
  return t(
513
- 'OpenFeel 写入门禁:研究/方案产物(docs/research/**)要求有活跃阶段。请先 feel_req add → claim → feel_stage add 建立阶段,再写调研/方案。纯只读问答无需落盘。',
514
- 'OpenFeel write guard: research/proposal artifacts (docs/research/**) require an active stage. Create one via feel_req add → claim → feel_stage add before writing. Pure read-only Q&A needs no file.',
513
+ 'OpenFeel 写入门禁:研究/方案产物(docs/research/**)要求有开启的阶段。请先按当前小版本开一个阶段(保持 exec_running),再 feel_req add → claim 建需求并写调研/方案。纯只读问答无需落盘。',
514
+ 'OpenFeel write guard: research/proposal artifacts (docs/research/**) require an open stage. Open a stage for the current minor version (keep it in exec_running), then feel_req add → claim before writing. Pure read-only Q&A needs no file.',
515
515
  );
516
516
  }
517
517
  if (active.length === 0) {
@@ -528,8 +528,8 @@ export function createOpenFeelGuard(options = {}) {
528
528
  return undefined;
529
529
  }
530
530
  return t(
531
- 'OpenFeel 写入门禁:当前无活跃阶段,不能修改源码/文档。请先 feel_req add → claim → feel_stage add 建立阶段。',
532
- 'OpenFeel write guard: no active stage, so source/docs are read-only. Create a stage via feel_req add → claim → feel_stage add.',
531
+ 'OpenFeel 写入门禁:无活跃阶段,不能修改源码/文档(当前没有开启的阶段)。默认按当前小版本开一个阶段并保持 exec_running(feel_stage add stage=<vX.Y.Z-stage-N>),再在该版本下建需求推进;需求完成不要求关闭阶段。',
532
+ 'OpenFeel write guard: no active stage (no open stage), so source/docs are read-only. Open a stage for the current minor version and keep it in exec_running (feel_stage add stage=<vX.Y.Z-stage-N>), then add requirements under that version; requirement completion does not require closing the stage.',
533
533
  );
534
534
  }
535
535
 
@@ -151,11 +151,19 @@ Feel(你)只做编排、决策与门禁判断。
151
151
  - **先读后写**:核心写命令(advance / stage add / req add / claim)要求 10 分钟内调用过 \`feel_status\` / \`feel_next\`;遇到 preflight 拒绝先 \`feel_status\` 再重试。
152
152
  - **审查独立**:fast 单轮审查也应由独立 reviewer 完成;Feel 自审必须在 REV 标题标注 \`self-review\`,归档摘要记录原因。
153
153
 
154
- ## 流程入口(v1.5.2)
155
- - **先 \`feel_status\`**:任何会产出仓库文件(含 \`docs/research/**\`、方案、计划)或需要多步调查/实现的任务,先读状态;无活跃阶段 → \`feel_req add\` → \`claim\` → \`feel_stage add\`,再开始。
156
- - **不得以「调研 / 只读」为由跳过阶段**:纯只读问答可直接回答;研究/方案产物写入门禁要求活跃阶段(\`docs/research/**\` 无阶段会被拒)。
154
+ ## 需求导向与流程入口(v1.5.7)
155
+ - **默认需求导向**:需求(REQ)是工作单元;阶段是**版本容器**,长期保持 \`exec_running\`,一个阶段容纳多个需求。**不要每完成一个需求就推进 / 关闭阶段**。
156
+ - **先 \`feel_status\`**:无开启阶段 → 默认按当前小版本开一个阶段(如 \`v1.5.7-stage-N\`,保持 \`exec_running\`),再 \`feel_req add\` → \`claim\`;已有开启阶段 → 直接在其版本下建需求(\`target_version\` 取阶段版本)。
157
+ - **需求完成与阶段关闭解耦**:阶段进入 \`exec_running\` 后,关联需求即可 \`feel_req advance --to done\`;零关联需求也可显式完成。等阶段 done 不是需求完成的前提。
158
+ - **归档 / 发布只在用户确认后**:只有当用户明确说「归档 / 发布这个版本」时,才把阶段推进到 review / test / archiving / done 并执行 \`feel_archive create\`。需求规模足够支撑发版时可**建议**用户归档,但**不得自行归档或发布**。
159
+ - **不得以「调研 / 只读」为由跳过阶段**:纯只读问答可直接回答;研究/方案产物(\`docs/research/**\`)仍需开启阶段。
157
160
  - **判据**:只要任务可能改变仓库内容或需要跨轮次承接,就属于流程任务。
158
161
 
162
+ ## 完成必审验(v1.5.8)
163
+ - **需求 done 需审查 + 验证**:\`feel_req action=review\`(result/by/note/independent)与 \`action=verify\`(result/kind/by/note/evidence)都记录且 \`result=pass\` 才可 \`feel_req advance --to done\`;缺一项即被拒(无 force)。
164
+ - **阶段 archiving → done 需阶段验证 + 关联需求全部 done**:先 \`feel_stage action=verify\`(仅 archiving 相位可记录),再推进;关联需求 cancelled / rejected 也算未完成(保守口径)。
165
+ - **独立审查**:能派独立 reviewer 就派;自我审查必须显式标注(\`--self\` / \`independent=false\`),归档摘要会记录 self-review。
166
+
159
167
  ## 状态与记录(v1.5.0)
160
168
  - **只有 Feel 写状态**:\`dev_last*\`、\`dev/current.md\`、\`status.md\`、\`flow.json\` 只由 Feel 更新;**子 agent 一律不读不写**(上下文由派发 prompt / 交接文档提供)。
161
169
  - **日志不强制**:不写流水账;\`flow.json.log\` 由 CLI 自动维护(仅保留最近 200 条)。跨会话信息用一条 ≤5 行交接摘要。
@@ -176,6 +184,7 @@ Feel(你)只做编排、决策与门禁判断。
176
184
  需求是排期层(\`REQ-NNN\`,7 状态:draft/scheduled/in_progress/done/blocked/cancelled/rejected)。
177
185
  接取流程:\`feel_req action=next\` → \`claim\` → \`link\` 到阶段 → 阶段推进驱动聚合 → 全部关联阶段 done 时需求自动收口。
178
186
  \`done\` 门:非 general 需求必须**全部关联阶段 done**;general 需求在零关联阶段时走双完成路径。
187
+ **发布前先检查**:归档前先 \`feel_req action=release-check\`(只读);仍有未完成需求时先 \`feel_req action=rollover\` 顺延,或归档时显式 \`allow_unfinished=true\`(缺省拒绝)。
179
188
 
180
189
  ## 收尾
181
190
  多步骤任务(≥3 步)开始即建 todo 列表并持续更新。阶段推进与需求流转后,向用户汇报「做了什么 / 卡在哪 / 建议下一步」。
@@ -227,11 +236,19 @@ planner / schemer / executor / reviewer / feel-tester / archiver. **The authorit
227
236
  - **Read before write**: core write commands (advance / stage add / req add / claim) require a \`feel_status\` / \`feel_next\` within 10 minutes; on preflight refusal, call \`feel_status\` and retry.
228
237
  - **Independent review**: even the single fast-mode review should be done by an independent reviewer; if Feel self-reviews, mark the REV title \`self-review\` and record why in the archive summary.
229
238
 
230
- ## Workflow entry (v1.5.2)
231
- - **Call \`feel_status\` first**: any task that may produce repo files (including \`docs/research/**\`, proposals, plans) or needs multi-step investigation/implementation must read state first; with no active stage → \`feel_req add\` → \`claim\` → \`feel_stage add\`, then start.
232
- - **Never skip the stage under the pretext of "research / read-only"**: pure read-only Q&A may answer directly; research/proposal artifacts require an active stage (\`docs/research/**\` writes are rejected without one).
239
+ ## Requirement-first & workflow entry (v1.5.7)
240
+ - **Requirement-first by default**: a requirement (REQ) is the unit of work; a stage is a **version container** that stays in \`exec_running\` and holds many requirements. **Do not advance / close the stage after each requirement.**
241
+ - **Call \`feel_status\` first**: no open stage → open one for the current minor version (e.g. \`v1.5.7-stage-N\`, keep it in \`exec_running\`), then \`feel_req add\` → \`claim\`; with an open stage → create the requirement under that version (\`target_version\` = the stage version).
242
+ - **Requirement done is decoupled from stage closure**: once the stage is in \`exec_running\`, linked requirements may be completed with \`feel_req advance --to done\`; requirements with no linked stage may be completed explicitly too. Stage completion is not a prerequisite.
243
+ - **Archive / release only after the user confirms**: advance the stage to review / test / archiving / done and run \`feel_archive create\` only when the user explicitly says "archive / release this version". You may **suggest** archiving when the accumulated requirements justify a release, but **never archive or publish on your own**.
244
+ - **Never skip the stage under the pretext of "research / read-only"**: pure read-only Q&A may answer directly; research/proposal artifacts (\`docs/research/**\`) still require an open stage.
233
245
  - **Rule of thumb**: if it may change repo content or span multiple turns, it is a workflow task.
234
246
 
247
+ ## Review + verification are mandatory for done (v1.5.8)
248
+ - **Requirement done needs a review AND a verification**: record both via \`feel_req action=review\` (result/by/note/independent) and \`action=verify\` (result/kind/by/note/evidence) with \`result=pass\` before \`feel_req advance --to done\`; missing either one is refused (no force).
249
+ - **Stage archiving → done needs stage verification AND all linked requirements done**: run \`feel_stage action=verify\` first (recordable only in the archiving phase), then advance; cancelled / rejected linked requirements still count as incomplete (conservative).
250
+ - **Independent review**: dispatch an independent reviewer when possible; self-review must be declared explicitly (\`--self\` / \`independent=false\`) and the archive summary records it.
251
+
235
252
  ## State & records (v1.5.0)
236
253
  - **Only Feel writes state**: \`dev_last*\`, \`dev/current.md\`, \`status.md\`, \`flow.json\` are updated by Feel only; **subagents never read or write them** (context comes from the dispatch prompt / handoff docs).
237
254
  - **No mandatory logs**: do not keep a per-step diary; \`flow.json.log\` is maintained by the CLI (last 200 entries only). For cross-session info, write a <=5-line handoff summary.
@@ -252,6 +269,7 @@ planner / schemer / executor / reviewer / feel-tester / archiver. **The authorit
252
269
  Requirements are the scheduling layer (\`REQ-NNN\`, 7 statuses: draft/scheduled/in_progress/done/blocked/cancelled/rejected).
253
270
  Flow: \`feel_req action=next\` → \`claim\` → \`link\` to a stage → stage advancement drives aggregation → auto-close when every linked stage is done.
254
271
  The \`done\` gate: a non-general requirement needs ALL linked stages done; a general requirement with zero linked stages uses the dual completion path.
272
+ **Check before release**: run \`feel_req action=release-check\` (read-only) before archiving; if unfinished requirements remain, roll them over with \`feel_req action=rollover\`, or archive with an explicit \`allow_unfinished=true\` (default: refused).
255
273
 
256
274
  ## Wrap-up
257
275
  Create a todo list at the start of any multi-step task (≥3 steps) and keep it current. After advancing a phase or requirement, report what changed, what blocked, and the suggested next step.
@@ -20,6 +20,8 @@ import { readPreflightInfo } from '../adapters/preflight.js';
20
20
  import { buildObservability } from '../adapters/observability.js';
21
21
  import { computeWorkflowGate } from '../adapters/workflow-gate.js';
22
22
  import { resolveWorkspace } from '../adapters/workspace.js';
23
+ // v1.5.8 / REQ-029:多会话登记(与 CLI `.openfeel/dev/sessions.json` 同一文件格式)
24
+ import { readSessions as readSessionEntries, touchSession as touchSessionFile } from '../adapters/sessions.js';
23
25
  import {
24
26
  boolean,
25
27
  compileParameters,
@@ -135,6 +137,72 @@ function safeObservability(snapshot) {
135
137
  }
136
138
  }
137
139
 
140
+ /**
141
+ * `feel_status` 的默认精简视图(v1.5.7):只保留调度必需字段。
142
+ *
143
+ * 去掉的三块日常用不到、但每次都占大量上下文的冗余:
144
+ * - `mode.transitionsByMode`(三份转移表,约 60 行)→ 需要时用 `feel_flow action=phases` 现取;
145
+ * - `recovery.handoff`(交接摘要全文)→ 需要时读 `dev_last/pending.md`;
146
+ * - `observability`(preflight/statusSync 的复制副本,与顶层字段重复)。
147
+ *
148
+ * 需要完整快照时传 `detail: "full"`。
149
+ * @param {Record<string, any>} snapshot
150
+ * @returns {Record<string, any>}
151
+ */
152
+ export function compactStatusSnapshot(snapshot) {
153
+ const focus = snapshot?.focus ?? {};
154
+ const mode = snapshot?.mode ?? {};
155
+ const recovery = snapshot?.recovery ?? {};
156
+ const compact = {
157
+ schemaVersion: snapshot?.schemaVersion,
158
+ project: snapshot?.project,
159
+ pipeline: snapshot?.pipeline,
160
+ focus: {
161
+ stage: focus.stage ?? '',
162
+ phase: focus.phase ?? '',
163
+ phaseLabel: focus.phaseLabel ?? '',
164
+ status: focus.status ?? '',
165
+ deps: focus.deps ?? [],
166
+ workflowMode: focus.workflowMode ?? null,
167
+ reviewTier: focus.reviewTier ?? null,
168
+ effectiveReviewTier: focus.effectiveReviewTier ?? null,
169
+ legalNextPhases: focus.legalNextPhases ?? [],
170
+ suggestedCommand: focus.suggestedCommand ?? null,
171
+ responsibleAgent: focus.responsibleAgent ?? null,
172
+ guards: focus.guards ?? [],
173
+ blockingReviews: focus.blockingReviews ?? [],
174
+ },
175
+ mode: {
176
+ current: mode.current ?? null,
177
+ source: mode.source ?? null,
178
+ skippedPhases: mode.skippedPhases ?? [],
179
+ },
180
+ stages: snapshot?.stages ?? [],
181
+ statusSync: snapshot?.statusSync ?? null,
182
+ workflowGate: snapshot?.workflowGate ?? null,
183
+ preflight: snapshot?.preflight ?? null,
184
+ recovery: {
185
+ stage: recovery.stage ?? null,
186
+ phase: recovery.phase ?? null,
187
+ requirement: recovery.requirement ?? null,
188
+ lastTransition: recovery.lastTransition ?? null,
189
+ lastError: recovery.lastError ?? null,
190
+ hasDevLast: recovery.hasDevLast === true,
191
+ nextAction: recovery.nextAction ?? null,
192
+ },
193
+ revision: snapshot?.revision ?? null,
194
+ snapshotAt: snapshot?.snapshotAt ?? null,
195
+ stale: snapshot?.stale === true,
196
+ // v1.5.8 / REQ-029:会话登记(compact 档同样暴露,体积可控——只含存活/近期会话)
197
+ sessions: snapshot?.sessions ?? [],
198
+ };
199
+ // 需求概览是显式开关(with_requirements),compact 档同样只在请求时带上
200
+ if (snapshot?.requirements !== undefined) {
201
+ compact.requirements = snapshot.requirements;
202
+ }
203
+ return compact;
204
+ }
205
+
138
206
  /**
139
207
  * 构造全部工具定义。
140
208
  *
@@ -175,11 +243,15 @@ export function createTools(context) {
175
243
  const feelStatus = {
176
244
  name: 'feel_status',
177
245
  description:
178
- '读取 OpenFeel 项目当前状态快照:宏观 pipeline 相位、**每个阶段的相位**(调度目标是 phase!=done 的活跃阶段)、当前工作流模式与来源、该阶段在此模式下的**合法下一相位**、负责 Agent、审查档位、守卫与阻塞审查。调度字段优先消费 `flow next --json` 权威输出(失败时回退 `flow status`/`flow mode`)。做任何推进/委派前先调用它。',
246
+ '读取 OpenFeel 项目状态快照:宏观 pipeline 相位、**每个阶段的相位**(调度目标是 phase!=done 的活跃阶段)、当前工作流模式与来源、该阶段在此模式下的**合法下一相位**、负责 Agent、审查档位、守卫与阻塞审查。默认返回 **compact** 档(调度必需字段);`detail: "full"` 返回完整快照(含模式转移表 / 交接摘要 / 观测摘要)。模式来源的转移表请按需用 `feel_flow action=phases` / `action=mode` 现取。调度字段优先消费 `flow next --json` 权威输出(失败时回退 `flow status`/`flow mode`)。做任何推进/委派前先调用它。',
179
247
  parameters: {
180
248
  action: stringConst('status', '固定为 status(读取快照)。'),
181
249
  project: string('项目根目录(相对会话工作区或绝对路径)。缺省时从会话工作区向上回溯 .openfeel/。'),
182
250
  with_requirements: boolean('是否附带需求概览(多一次 CLI 调用)。'),
251
+ detail: stringEnum(
252
+ ['compact', 'full'],
253
+ '输出档位:compact=默认,只给调度必需字段(省上下文);full=完整快照(含 mode.transitionsByMode / recovery.handoff / observability)。',
254
+ ),
183
255
  },
184
256
  output: { schema: envelopeSchema(), render: renderEnvelope },
185
257
  async execute(args, exec) {
@@ -203,11 +275,16 @@ export function createTools(context) {
203
275
  snapshot.preflight = preflight;
204
276
  snapshot.observability = safeObservability(snapshot);
205
277
  snapshot.recovery.nextAction = snapshot.focus.suggestedCommand ?? null;
278
+ // v1.5.8 / REQ-029:先登记本会话心跳,再读登记表(保证本次调用即可见自身条目);
279
+ // touchSessionFile 内部已 try/catch 静默,读失败同样降级为 [](绝不阻断主流程)。
280
+ touchSessionFile(resolved.cwd, snapshot.focus?.stage ?? '');
281
+ snapshot.sessions = readSessionEntries(resolved.cwd);
206
282
  const focus = snapshot.focus;
207
283
  const gateWarning = snapshot.workflowGate.required ? '⚠ 无活跃阶段:非只读任务先 feel_status→建阶段。' : '';
208
284
  const staleWarning = snapshot.stale ? '⚠ 快照为降级(flow next 缺失),以 flow status 为准。' : '';
285
+ const data = args.detail === 'full' ? snapshot : compactStatusSnapshot(snapshot);
209
286
  return {
210
- data: snapshot,
287
+ data,
211
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(', ') || '无'}]`,
212
289
  next: focus.phase === 'done' || focus.phase === ''
213
290
  ? null
@@ -258,6 +335,9 @@ export function createTools(context) {
258
335
  plan.revision = snapshot.revision ?? null;
259
336
  plan.snapshotAt = snapshot.snapshotAt ?? null;
260
337
  plan.stale = snapshot.stale === true;
338
+ // v1.5.8 / REQ-029:会话登记(与 feel_status 同源;失败静默)
339
+ touchSessionFile(resolved.cwd, snapshot.focus?.stage ?? '');
340
+ plan.sessions = readSessionEntries(resolved.cwd);
261
341
  return {
262
342
  data: plan,
263
343
  summary: plan.summary,
@@ -416,9 +496,9 @@ export function createTools(context) {
416
496
  const feelStage = {
417
497
  name: 'feel_stage',
418
498
  description:
419
- '工作阶段与 status.md 操作。action=list 列出工作阶段;action=add 添加工作阶段(建目录 + overview/status + 注册 flow.json,这是**唯一完整入口**);action=status 查看阶段状态;action=set 原子更新 status.md 字段(状态/执行模式/自动推进/责任 Agent/工作流模式);action=task 勾选或追加任务;action=deps 设置依赖;action=reset 复位相位;action=remove 移除阶段。禁止直接编辑 status.md 或 flow.json。',
499
+ '工作阶段与 status.md 操作。action=list 列出工作阶段;action=add 添加工作阶段(建目录 + overview/status + 注册 flow.json,这是**唯一完整入口**);action=status 查看阶段状态;action=set 原子更新 status.md 字段(状态/执行模式/自动推进/责任 Agent/工作流模式);action=task 勾选或追加任务;action=deps 设置依赖;action=reset 复位相位;action=remove 移除阶段;action=verify 记录阶段验证证据(仅 archiving 相位;archiving→done 硬门要求 result=pass 且关联需求全部 done)。禁止直接编辑 status.md 或 flow.json。',
420
500
  parameters: {
421
- action: stringEnum(['list', 'add', 'status', 'set', 'task', 'deps', 'reset', 'remove'], '操作。', { required: true }),
501
+ action: stringEnum(['list', 'add', 'status', 'set', 'task', 'deps', 'reset', 'remove', 'verify'], '操作。', { required: true }),
422
502
  stage: string('阶段 ID(如 v1.2.1-stage-93 或 stage-93)。除 list/add 外必需。'),
423
503
  deps: stringArray('依赖阶段 ID 列表(add/deps)。'),
424
504
  tasks: stringArray('初始任务列表(add)。'),
@@ -435,6 +515,11 @@ export function createTools(context) {
435
515
  dry_run: boolean('仅预览(reset/remove)。'),
436
516
  force: boolean('remove 时越过安全校验。'),
437
517
  purge: boolean('remove 时同时删除阶段目录(非 TTY 须配 force)。'),
518
+ result: stringEnum(['pass', 'fail'], 'verify 的验证结论(pass 才满足 done 门)。'),
519
+ kind: stringEnum(['test', 'manual', 'build'], 'verify 的验证种类。'),
520
+ by: string('verify 的验证者(如 feel-tester)。'),
521
+ note: string('verify 的结论摘要(进入归档摘要)。'),
522
+ evidence: string('verify 的证据(测试命令 / 报告路径)。'),
438
523
  project: string('项目根目录。'),
439
524
  },
440
525
  output: { schema: envelopeSchema(), render: renderEnvelope },
@@ -527,6 +612,22 @@ export function createTools(context) {
527
612
  return { data: { stage, output: out.text }, summary: `阶段 ${stage} 已${args.dry_run === true ? '预演移除' : '移除'}。` };
528
613
  });
529
614
  }
615
+ case 'verify': {
616
+ const stage = requireArg(args, 'stage', action);
617
+ const argv = ['stage', 'verify', stage];
618
+ pushOption(argv, '--result', requireArg(args, 'result', action));
619
+ pushOption(argv, '--kind', requireArg(args, 'kind', action));
620
+ pushOption(argv, '--by', requireArg(args, 'by', action));
621
+ pushOption(argv, '--note', requireArg(args, 'note', action));
622
+ pushOption(argv, '--evidence', args.evidence);
623
+ return envelope(action, async () => {
624
+ const out = await cli.write(argv, opts);
625
+ return {
626
+ data: { stage, result: args.result, kind: args.kind, by: args.by, output: out.text },
627
+ summary: `阶段 ${stage} 验证已记录(${args.kind} / ${args.result})。`,
628
+ };
629
+ });
630
+ }
530
631
  default:
531
632
  throw new FeelError(`未知 action: ${action}`, { kind: 'usage', code: 'FEEL_UNKNOWN_ACTION' });
532
633
  }
@@ -638,10 +739,10 @@ export function createTools(context) {
638
739
  const feelReq = {
639
740
  name: 'feel_req',
640
741
  description:
641
- '需求分发系统(openfeel req,7 状态)。action=add 创建需求(ID 自动分配);list 过滤列表;show 详情;board 看板(7 组固定顺序);next 推荐下一个可接取需求;claim 认领(占用校验、无 TTL);release 释放;set 更新白名单字段;link 关联/解绑阶段;advance 显式推进状态(**done 门:非 general 需求须全部关联阶段 done**);split 拆分(子需求直接入 scheduled,父需求仅留 parent_id 溯源)。',
742
+ '需求分发系统(openfeel req,7 状态)。action=add 创建需求(ID 自动分配,**单调计数器 meta.last_req_seq**:归档移走条目后也不复用 ID);list 过滤列表(include_archived=true 合并已随版本归档的需求);show 详情(已归档需求回退读归档文件);board 看板(7 组固定顺序);next 推荐下一个可接取需求;claim 认领(占用校验、无 TTL);release 释放;set 更新白名单字段;link 关联/解绑阶段;advance 显式推进状态(**done 门:非 general 需求须全部关联阶段 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。',
642
743
  parameters: {
643
- action: stringEnum(['add', 'list', 'show', 'board', 'next', 'claim', 'release', 'set', 'link', 'advance', 'split'], '操作。', { required: true }),
644
- id: string('需求 ID(如 REQ-001)。show/claim/release/set/advance/split 必需。'),
744
+ action: stringEnum(['add', 'list', 'show', 'board', 'next', 'claim', 'release', 'set', 'link', 'advance', 'split', 'review', 'verify', 'release-check', 'rollover'], '操作。', { required: true }),
745
+ id: string('需求 ID(如 REQ-001)。show/claim/release/set/advance/split/review/verify/rollover 必需(rollover 与 all 互斥)。'),
645
746
  title: string('需求标题(add 必需;set 为改标题)。'),
646
747
  target_version: string('预估版本(如 v1.3.0;纯展示/过滤维度,非门禁)。'),
647
748
  priority: stringEnum(REQ_PRIORITIES, '优先级。'),
@@ -652,8 +753,18 @@ export function createTools(context) {
652
753
  stage: string('阶段 ID(link 必需)。'),
653
754
  requirement: string('需求 ID(link 关联用)。'),
654
755
  unlink: boolean('link 时解除该阶段的需求关联。'),
655
- to: stringEnum(REQ_STATUSES, 'advance 的目标状态。'),
756
+ to: string('advance 的目标状态(合法目标由引擎判定);rollover 的目标版本。'),
757
+ from: string('rollover 的来源版本(如 v1.5.8)。'),
758
+ all: boolean('rollover 时顺延该版本全部未完成需求(与 id 互斥,二者必选其一)。'),
759
+ include_archived: boolean('list 时合并已随版本归档的需求(只读)。'),
760
+ version: string('版本号(release-check 必填,如 v1.5.8)。'),
656
761
  into: stringArray('split 的子需求标题列表(至少一项)。'),
762
+ result: stringEnum(['pass', 'fail'], 'review/verify 的结论(pass 才满足 done 门)。'),
763
+ kind: stringEnum(['test', 'manual', 'build'], 'verify 的验证种类。'),
764
+ by: string('review/verify 的审查者 / 验证者。'),
765
+ note: string('review/verify 的结论摘要(进入归档摘要)。'),
766
+ evidence: string('verify 的证据(测试命令 / 报告路径)。'),
767
+ independent: boolean('review 是否独立审查(缺省 false = 自我审查,须显式标注 self-review)。'),
657
768
  project: string('项目根目录。'),
658
769
  },
659
770
  output: { schema: envelopeSchema(), render: renderEnvelope },
@@ -678,10 +789,11 @@ export function createTools(context) {
678
789
  pushOption(argv, '--status', args.status);
679
790
  pushOption(argv, '--target-version', args.target_version);
680
791
  pushOption(argv, '--owner', args.owner);
792
+ pushFlag(argv, '--include-archived', args.include_archived);
681
793
  return envelope(action, async () => {
682
794
  const data = await cli.json(argv, opts);
683
795
  const count = Array.isArray(data?.requirements) ? data.requirements.length : 0;
684
- return { data, summary: `共 ${count} 条需求。` };
796
+ return { data, summary: `共 ${count} 条需求${args.include_archived === true ? '(含已归档)' : ''}。` };
685
797
  });
686
798
  }
687
799
  case 'board': {
@@ -790,6 +902,80 @@ export function createTools(context) {
790
902
  };
791
903
  });
792
904
  }
905
+ case 'review': {
906
+ const id = requireArg(args, 'id', action);
907
+ const argv = ['req', 'review', id];
908
+ pushOption(argv, '--result', requireArg(args, 'result', action));
909
+ pushOption(argv, '--by', requireArg(args, 'by', action));
910
+ pushOption(argv, '--note', requireArg(args, 'note', action));
911
+ // 独立 / 自我审查**恒显式标注**(自我审查在归档摘要中必须可见)
912
+ argv.push(args.independent === true ? '--independent' : '--self');
913
+ return envelope(action, async () => {
914
+ const out = await cli.write(argv, opts);
915
+ return {
916
+ data: { id, result: args.result, by: args.by, independent: args.independent === true, output: out.text },
917
+ summary: `需求 ${id} 审查已记录(${args.result}${args.independent === true ? ',独立' : ',自我审查'})。`,
918
+ };
919
+ });
920
+ }
921
+ case 'verify': {
922
+ const id = requireArg(args, 'id', action);
923
+ const argv = ['req', 'verify', id];
924
+ pushOption(argv, '--result', requireArg(args, 'result', action));
925
+ pushOption(argv, '--kind', requireArg(args, 'kind', action));
926
+ pushOption(argv, '--by', requireArg(args, 'by', action));
927
+ pushOption(argv, '--note', requireArg(args, 'note', action));
928
+ pushOption(argv, '--evidence', args.evidence);
929
+ return envelope(action, async () => {
930
+ const out = await cli.write(argv, opts);
931
+ return {
932
+ data: { id, result: args.result, kind: args.kind, by: args.by, output: out.text },
933
+ summary: `需求 ${id} 验证已记录(${args.kind} / ${args.result})。`,
934
+ };
935
+ });
936
+ }
937
+ case 'release-check': {
938
+ const version = requireArg(args, 'version', action);
939
+ return envelope(action, async () => {
940
+ // 只读软门:CLI 恒 exit 0;未完成需求只报告,不拒绝
941
+ const data = await cli.json(['req', 'release-check', version, '--json'], opts);
942
+ const unfinished = Array.isArray(data?.unfinished) ? data.unfinished : [];
943
+ return {
944
+ data,
945
+ summary: unfinished.length === 0
946
+ ? `版本 ${version} 发布检查:无未完成需求,可归档。`
947
+ : `版本 ${version} 有 ${unfinished.length} 条未完成需求:先 feel_req action=rollover 顺延,或归档时显式 allow_unfinished=true。`,
948
+ next: unfinished.length === 0
949
+ ? null
950
+ : {
951
+ tool: 'feel_req',
952
+ arguments: { action: 'rollover', from: version, to: '<新版本>', all: true },
953
+ why: '把未完成需求顺延到新版本,再归档;确需带未完成需求归档时传 allow_unfinished=true。',
954
+ },
955
+ };
956
+ });
957
+ }
958
+ case 'rollover': {
959
+ const from = requireArg(args, 'from', action);
960
+ const to = requireArg(args, 'to', action);
961
+ const all = args.all === true;
962
+ if (all && args.id !== undefined) {
963
+ throw new FeelError('req rollover 的 --id 与 --all 互斥;二者只能选一个', { kind: 'usage', code: 'FEEL_BAD_USAGE' });
964
+ }
965
+ const argv = ['req', 'rollover', '--from', from, '--to', to];
966
+ if (all) {
967
+ argv.push('--all');
968
+ } else {
969
+ argv.push('--id', requireArg(args, 'id', action));
970
+ }
971
+ return envelope(action, async () => {
972
+ const out = await cli.write(argv, opts);
973
+ return {
974
+ data: { from, to, all, id: all ? null : args.id, output: out.text },
975
+ summary: `需求顺延已执行:${from} → ${to}。`,
976
+ };
977
+ });
978
+ }
793
979
  default:
794
980
  throw new FeelError(`未知 action: ${action}`, { kind: 'usage', code: 'FEEL_UNKNOWN_ACTION' });
795
981
  }
@@ -854,12 +1040,13 @@ export function createTools(context) {
854
1040
  const feelArchive = {
855
1041
  name: 'feel_archive',
856
1042
  description:
857
- '版本管理。action=list 列出已归档版本;action=show 查看某归档版本;action=create 执行 flow.json 版本分片归档(判据门:该版本全部阶段 done **且** 无 blocking open REV;**无 force 覆盖**;归档后该版本阶段从 flow.json 移除);action=stage_summary 是**另一个**功能(顶层 openfeel archive <stage>,生成阶段摘要到 .openfeel/log/,不动 flow.json)。v1.2.4 起 stage_summary **拒绝覆盖**已存在的归档文件(`ARCHIVE_EXISTS`,零写盘);确需覆盖须传 force=true。',
1043
+ '版本管理。action=list 列出已归档版本;action=show 查看某归档版本;action=create 执行 flow.json 版本分片归档(判据门:该版本全部阶段 done **且** 无 blocking open REV;**无 force 覆盖**;归档后该版本阶段**与该版本的终态需求**从 flow.json 移除,移入归档文件);action=stage_summary 是**另一个**功能(顶层 openfeel archive <stage>,生成阶段摘要到 .openfeel/log/,不动 flow.json)。**发布软门(v1.5.8 / REQ-030)**:该版本仍有未完成需求(非 done/cancelled/rejected)时缺省拒绝且零写盘,须先 `feel_req action=rollover` 顺延,或显式传 allow_unfinished=true 放行。v1.2.4 起 stage_summary **拒绝覆盖**已存在的归档文件(`ARCHIVE_EXISTS`,零写盘);确需覆盖须传 force=true。',
858
1044
  parameters: {
859
1045
  action: stringEnum(['list', 'show', 'create', 'stage_summary'], '操作。', { required: true }),
860
1046
  version: string('版本号(如 v1.2.0;前缀 v 可省略)。show/create 必需。'),
861
1047
  stage: string('阶段 ID(stage_summary 必需)。'),
862
1048
  dry_run: boolean('create 仅预览判据与将归档内容,零写盘。'),
1049
+ allow_unfinished: boolean('create 显式放行「该版本仍有未完成需求」(发布软门;缺省拒绝)。'),
863
1050
  force: boolean('stage_summary 覆盖已存在的归档文件(默认拒绝;覆盖会冲掉既有摘要)。'),
864
1051
  project: string('项目根目录。'),
865
1052
  },
@@ -887,6 +1074,7 @@ export function createTools(context) {
887
1074
  const version = requireArg(args, 'version', action);
888
1075
  const argv = ['flow', 'archive', version, '--json'];
889
1076
  pushFlag(argv, '--dry-run', args.dry_run);
1077
+ pushFlag(argv, '--allow-unfinished', args.allow_unfinished);
890
1078
  return envelope(action, async () => {
891
1079
  const data = await cli.json(argv, opts);
892
1080
  return {
@@ -1292,7 +1480,7 @@ export function createTools(context) {
1292
1480
  presentCall: (args) => presentCall(`Feel 模型 ${args.action}`, args.action, args.agent),
1293
1481
  };
1294
1482
 
1295
- return [
1483
+ const tools = [
1296
1484
  feelStatus,
1297
1485
  feelNext,
1298
1486
  feelFlow,
@@ -1309,6 +1497,47 @@ export function createTools(context) {
1309
1497
  // 注册表既不编译也不校验 parameters(本插件不经 defineTool),
1310
1498
  // 因此在交给注册表前统一转成子集接受的裸 JSON Schema。
1311
1499
  ].map((tool) => ({ ...tool, parameters: compileParameters(tool.parameters) }));
1500
+
1501
+ // v1.5.8 / REQ-029:会话登记——每次 feel_* 执行都 upsert 一条心跳(stage 从结果派生)。
1502
+ // feel_status / feel_next 已在各自 execute 内登记(能带准确 stage),此处不重复包装。
1503
+ return tools.map((tool) => (tool.name === 'feel_status' || tool.name === 'feel_next'
1504
+ ? tool
1505
+ : {
1506
+ ...tool,
1507
+ async execute(args, exec) {
1508
+ let result;
1509
+ try {
1510
+ result = await tool.execute(args, exec);
1511
+ return result;
1512
+ } finally {
1513
+ try {
1514
+ const workspace = resolveWorkspace(exec, {
1515
+ projectPath: typeof args?.project === 'string' ? args.project : undefined,
1516
+ fallback: cli.cwd,
1517
+ });
1518
+ if (workspace.initialized) touchSessionFile(workspace.projectRoot, stageFromResult(result));
1519
+ } catch {
1520
+ // 静默:会话登记绝不影响工具结果
1521
+ }
1522
+ }
1523
+ },
1524
+ }));
1525
+ }
1526
+
1527
+ /**
1528
+ * 从工具 wire 结果里尽力取活跃阶段(仅用于会话登记,取不到 → 空串)。
1529
+ * @param {any} result 工具返回值(`details` 为 JSON 字符串)
1530
+ * @returns {string}
1531
+ */
1532
+ function stageFromResult(result) {
1533
+ try {
1534
+ const details = typeof result?.details === 'string' ? JSON.parse(result.details) : result?.details;
1535
+ if (details === null || typeof details !== 'object') return '';
1536
+ const stage = details.focus?.stage ?? details.stage;
1537
+ return typeof stage === 'string' ? stage : '';
1538
+ } catch {
1539
+ return '';
1540
+ }
1312
1541
  }
1313
1542
 
1314
1543
  /**
package/dsh/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfeel-dsh",
3
- "version": "1.5.6",
3
+ "version": "1.5.8",
4
4
  "description": "OpenFeel × DSH — Feel 模式适配器:把 OpenFeel 的流水线、需求分发、版本归档与知识库接入 DeepSeek Harness",
5
5
  "type": "module",
6
6
  "private": true,
@@ -18,7 +18,8 @@
18
18
  "docs"
19
19
  ],
20
20
  "engines": {
21
- "node": ">=20.17.0"
21
+ "node": ">=20.17.0",
22
+ "dsh": ">=0.2.0"
22
23
  },
23
24
  "repository": {
24
25
  "type": "git",
@@ -32,7 +33,7 @@
32
33
  },
33
34
  "openfeel": {
34
35
  "adapter": "dsh",
35
- "requiresCli": ">=1.5.6"
36
+ "requiresCli": ">=1.5.8"
36
37
  },
37
38
  "keywords": [
38
39
  "openfeel",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfeel",
3
- "version": "1.5.6",
3
+ "version": "1.5.8",
4
4
  "description": "AI Agent 开发流程治理 CLI 工具",
5
5
  "type": "module",
6
6
  "private": false,
@@ -14,7 +14,9 @@
14
14
  "build": "node build.js",
15
15
  "test": "vitest run",
16
16
  "test:coverage": "vitest run --coverage",
17
- "dev": "vitest"
17
+ "dev": "vitest",
18
+ "market:index": "node scripts/build-market-index.mjs",
19
+ "market:index:check": "node scripts/build-market-index.mjs --check"
18
20
  },
19
21
  "dependencies": {
20
22
  "@inquirer/prompts": "^8.5.2",