openfeel 1.5.16 → 1.5.18

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 (52) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/config.d.ts.map +1 -1
  3. package/dist/commands/config.js +8 -1
  4. package/dist/commands/config.js.map +1 -1
  5. package/dist/commands/flow.d.ts.map +1 -1
  6. package/dist/commands/flow.js +6 -2
  7. package/dist/commands/flow.js.map +1 -1
  8. package/dist/commands/req.d.ts.map +1 -1
  9. package/dist/commands/req.js +7 -2
  10. package/dist/commands/req.js.map +1 -1
  11. package/dist/commands/shared/preflight-gate.d.ts.map +1 -1
  12. package/dist/commands/shared/preflight-gate.js +2 -1
  13. package/dist/commands/shared/preflight-gate.js.map +1 -1
  14. package/dist/core/config.d.ts +55 -6
  15. package/dist/core/config.d.ts.map +1 -1
  16. package/dist/core/config.js +66 -2
  17. package/dist/core/config.js.map +1 -1
  18. package/dist/core/flow-archive/archive-ops.d.ts +14 -1
  19. package/dist/core/flow-archive/archive-ops.d.ts.map +1 -1
  20. package/dist/core/flow-archive/archive-ops.js +29 -0
  21. package/dist/core/flow-archive/archive-ops.js.map +1 -1
  22. package/dist/core/flow-manager.d.ts +4 -2
  23. package/dist/core/flow-manager.d.ts.map +1 -1
  24. package/dist/core/flow-manager.js +17 -8
  25. package/dist/core/flow-manager.js.map +1 -1
  26. package/dist/core/i18n-data/en.js +1 -1
  27. package/dist/core/i18n-data/zh-CN.js +1 -1
  28. package/dist/core/preflight.d.ts +13 -0
  29. package/dist/core/preflight.d.ts.map +1 -1
  30. package/dist/core/preflight.js +27 -1
  31. package/dist/core/preflight.js.map +1 -1
  32. package/dist/core/req/requirement-ops.d.ts +13 -0
  33. package/dist/core/req/requirement-ops.d.ts.map +1 -1
  34. package/dist/core/req/requirement-ops.js +22 -0
  35. package/dist/core/req/requirement-ops.js.map +1 -1
  36. package/dist/core/template-loader.d.ts.map +1 -1
  37. package/dist/core/template-loader.js +16 -1
  38. package/dist/core/template-loader.js.map +1 -1
  39. package/dist/core/update.d.ts.map +1 -1
  40. package/dist/core/update.js +16 -1
  41. package/dist/core/update.js.map +1 -1
  42. package/dsh/ACTION-GUIDE.md +1 -0
  43. package/dsh/ADAPTER.md +1 -1
  44. package/dsh/README.md +1 -0
  45. package/dsh/docs/compat/pipeline.md +13 -5
  46. package/dsh/lib/adapters/feel-mode.js +135 -0
  47. package/dsh/lib/adapters/workflow-gate.js +9 -0
  48. package/dsh/lib/index.js +8 -1
  49. package/dsh/lib/surface/prompt.js +49 -6
  50. package/dsh/lib/tools/index.js +29 -2
  51. package/dsh/package.json +2 -2
  52. package/package.json +1 -1
@@ -314,6 +314,7 @@ DSH 适配器已并入本仓库 `dsh/`(与 `claude/`、`kilo/` 同级),但
314
314
  | A2 + A3 + A4 交付 | 7 处 `cli.text()` 改为 `cli.json()`,文本回显 **8 → 1**(仅剩 `instructions` XML 形态),`--json` 调用点 **25 → 32** |
315
315
  | A1 交付 | 视方案更新 `feel_archive` 的 `stage_summary` 语义(`--force` 透传 / 返回合并标记) |
316
316
  | A5 交付 | `feel_verify action=config_get` 支持无 key 全量读取 |
317
+ | v1.5.17 `feel_mode` 交付 | `feel_status` / `feel_next` 输出新增 `feelMode`(`{value, source}`);`config get --all` 四键→五键、`config get --global` 6 键→7 键;适配器新增 `lib/adapters/feel-mode.js`(CLI `resolveFeelMode` 的镜像);断言已增补到 `dsh/test/contract.js`(compact 保留 `feelMode`)与 `dsh/test/verify.js`(gate / prompt / 镜像矩阵) |
317
318
  | 任意新出口 | 在 `dsh/test/contract.js` + `verify.js` 增补断言;`openfeel.requiresCli` 跟随升级 |
318
319
 
319
320
  同时 DSH 侧会把这轮复核结论同步回
package/dsh/ADAPTER.md CHANGED
@@ -15,7 +15,7 @@
15
15
  - **契约**:CLI 的 `--json` 出口以 [`docs/json-contract.md`](https://github.com/Liuary/OpenFeel/blob/master/docs/json-contract.md) 为**单一权威**
16
16
  (v1.5.10 起 43 个成功出口 / 44 个注册 `--json` 选项);本适配器只消费、不重实现。
17
17
  - **升级**:`npm i -g openfeel@latest` → 重启 DSH。适配器版本要求见 `package.json`
18
- 的 `openfeel.requiresCli`(≥1.5.16)。
18
+ 的 `openfeel.requiresCli`(≥1.5.18)。
19
19
 
20
20
  ## 设计边界
21
21
 
package/dsh/README.md CHANGED
@@ -220,6 +220,7 @@ provider 桥接层会把「只有 description、没有 type」的节点转成 `t
220
220
  - **preflight(v1.5.5)**:适配器 CLI 调用默认 `OPENFEEL_PREFLIGHT=strict`;`feel_status`/`feel_next` 返回 `preflight`;写命令要求 10 分钟内读过状态。提示段禁止 shell 写状态命令。
221
221
  - **观测摘要(v1.5.6)**:`feel_status`/`feel_next` 返回 `observability`(`stale` + `preflightAgeMs`/`preflightOk` 复制副本 + `statusSync` 三键 + 一句摘要);健康账本**先于 snapshot** 读取(读取次数不变、零新增 I/O),年龄反映「上一次读状态 → 现在」。两者均只增字段,既有键不变。
222
222
  - **多会话收束 P0(v1.5.8 / REQ-029)**:`feel_status`/`feel_next` 返回 `sessions`(`[{id, cwd, lastSeen, stage}]`,来自 `.openfeel/dev/sessions.json`,缺失 → `[]`);每次 `feel_*` 执行 upsert 一条会话心跳(失败静默)。该文件为运行时状态(不入库),与 CLI `src/core/dev/sessions.ts` 同格式;CLI 自动提交在检测到并发会话时跳过。
223
+ - **feel_mode 开关(v1.5.17;v1.5.18 起默认宽松)**:`feel_status`/`feel_next` 返回 `feelMode`(`{value, source}`,`source ∈ config.yaml / profile.yaml / builtin`)。缺省(未显式声明)时 `value=disabled`(v1.5.18 起开箱宽松):系统提示注入「自由模式」节(不强制建需求/阶段、`preflight` 降级为提示),`workflowGate` 的 `no-active-stage` 分支替换为 `feel-mode-off`(`required:false`,**无标题文案**);显式 `enabled` 则恢复严格。`guard-*` 自检、状态机 / `done` 门 / 归档判据 / 写入门禁保持不变。层级:项目 `.openfeel/config.yaml` 的 `defaults.feel_mode` > 全局 `~/.config/openfeel/profile.yaml` 的 `preferences.feel_mode` > `builtin=disabled`;适配器每轮现读(即时生效),解析实现是 CLI `src/core/config.ts:resolveFeelMode` 的镜像(`lib/adapters/feel-mode.js`,两侧同矩阵测试)。
223
224
 
224
225
  段落正文每次装配时探测 `.openfeel/` 是否存在,因此提示会随工作区状态变化。
225
226
 
@@ -861,23 +861,30 @@ Invariants:
861
861
 
862
862
  ---
863
863
 
864
- ## 8. Config cascade — precedence and the four managed keys
864
+ ## 8. Config cascade — precedence and the five managed keys
865
865
 
866
- ### 8.1 The four managed keys
866
+ ### 8.1 The five managed keys
867
867
 
868
868
  `EFFECTIVE_CONFIG_KEYS` and `DEFAULT_CONFIG`:
869
869
 
870
870
  ```ts
871
- const EFFECTIVE_CONFIG_KEYS = ['execution_mode', 'auto_advance', 'merge_mode', 'workflow_mode'] as const;
871
+ const EFFECTIVE_CONFIG_KEYS = ['execution_mode', 'auto_advance', 'merge_mode', 'workflow_mode', 'feel_mode'] as const;
872
872
 
873
873
  export const DEFAULT_CONFIG: Config = {
874
874
  execution_mode: 'manual',
875
875
  auto_advance: 'enabled', // 裁定 E:部署级默认自动推进开启(与 workflow_mode 无关)
876
876
  merge_mode: 'manual',
877
877
  workflow_mode: 'fast', // 裁定 B:新建默认 fast
878
+ feel_mode: 'disabled', // v1.5.18:默认宽松(显式 enabled 钉死严格)
878
879
  };
879
880
  ```
880
881
 
882
+ `feel_mode`(v1.5.17 引入;v1.5.18 起默认宽松):项目 `defaults.feel_mode` > 全局 profile `preferences.feel_mode` > `builtin=disabled`;
883
+ 未显式声明即为宽松;显式 `enabled` 钉死严格。
884
+ 它**没有阶段级字段**(`status.md` 不承载,故来源永不为 `status.md`)。`disabled` 时 CLI 侧
885
+ `preflight` 的 `strict` 降级为 `warn`,适配器侧 `workflowGate` 的 `no-active-stage` 分支替换为
886
+ `feel-mode-off`(`required:false`、message 为空),但 `guard-*` 自检与数据完整性硬门保持不变。
887
+
881
888
  `ConfigDefaultsSchema` (per-key `.default()` **must** stay in sync with `DEFAULT_CONFIG`):
882
889
 
883
890
  ```ts
@@ -886,6 +893,7 @@ export const ConfigDefaultsSchema = z.object({
886
893
  auto_advance: z.enum(['disabled', 'enabled']).optional().default('enabled'),
887
894
  merge_mode: z.enum(['manual', 'auto']).optional().default('manual'),
888
895
  workflow_mode: z.enum(WORKFLOW_MODES).optional().default('fast'),
896
+ feel_mode: z.enum(FEEL_MODES).optional().default('disabled'),
889
897
  }).passthrough();
890
898
  ```
891
899
 
@@ -1519,8 +1527,8 @@ Errors surface as `错误:{msg}` (`common.errorTmpl`) → exit 1; `isFlowConcu
1519
1527
  | `PHASE_PATH_MAX_DEPTH` | `8` |
1520
1528
  | `CHECKPOINT_MAX_KEEP` | `20` |
1521
1529
  | `STAGE_STATUS_VALUES` | `['planned','review_failed','review_passed','testing','archiving','done']` |
1522
- | `EFFECTIVE_CONFIG_KEYS` | `['execution_mode','auto_advance','merge_mode','workflow_mode']` |
1523
- | `DEFAULT_CONFIG` | `{ execution_mode:'manual', auto_advance:'enabled', merge_mode:'manual', workflow_mode:'fast' }` |
1530
+ | `EFFECTIVE_CONFIG_KEYS` | `['execution_mode','auto_advance','merge_mode','workflow_mode','feel_mode']` |
1531
+ | `DEFAULT_CONFIG` | `{ execution_mode:'manual', auto_advance:'enabled', merge_mode:'manual', workflow_mode:'fast', feel_mode:'enabled' }` |
1524
1532
  | `DEFAULT_SERIES` / `DEFAULT_STAGE_VERSION` | `'v1'` / `'v1.0.0'` |
1525
1533
  | `SKELETON_PHASES` | `['exec_running','review_pending','test_pending','archiving']` |
1526
1534
  | `flow phases --json` key count | `7` |
@@ -0,0 +1,135 @@
1
+ /**
2
+ * feel_mode 解析(v1.5.17 引入;v1.5.18 起内置默认 disabled)— 适配器侧的**只读镜像**
3
+ *
4
+ * CLI 单点:`src/core/config.ts:resolveFeelMode`。本模块与之同构(层级 / 显式声明语义 /
5
+ * 读侧宽容必须一致),因为系统提示段落 `text()` 的签名是同步 `() => string`,
6
+ * 无法等待 CLI 异步返回;为「即时生效」又必须每轮重新读取(不缓存)。
7
+ *
8
+ * 层级(项目覆盖全局,与 CLI 一致):
9
+ * 1. `<projectRoot>/.openfeel/config.yaml` 的 `defaults.feel_mode:`
10
+ * 2. `~/.config/openfeel/profile.yaml` 的 `preferences.feel_mode:`
11
+ * 3. 内置默认 `disabled`(v1.5.18 起开箱宽松;与 CLI `DEFAULT_CONFIG.feel_mode` 单点一致)
12
+ *
13
+ * 只认**显式声明**:非法值 / 文件缺失 / YAML 读失败 / 键缺失 → 跳到下一层,
14
+ * 不做 DEFAULT_PROFILE 合并(否则「未设置」会被误判为 profile 来源)。
15
+ *
16
+ * 为什么不做「CLI 写 `.feel-mode.json` 账本、适配器读文件」:账本在「刚改配置、尚未发生
17
+ * 任何 CLI 调用」的窗口里会滞后,违背「切换即时生效」。这里解析的是一个标量,
18
+ * 采用窄解析(不引入 YAML 依赖),矩阵用例(dsh/test/verify.js)与 CLI 单测同夹具。
19
+ *
20
+ * 已知的窄解析限制(正常写法不会触发;与 CLI `yaml.parse` 的残余分叉):
21
+ * ① 同一块内重复声明 `feel_mode`:CLI 侧 yaml 唯一键校验抛错 → 视为未声明并回落下层;
22
+ * 本镜像取**首个**出现值。
23
+ * ② 跨行 flow map(`defaults: {\n feel_mode: disabled\n}`):镜像只认单行内联,识别不了 → 回落下层。
24
+ * 两处都只会让镜像**更保守**(多回落,不会误判为 disabled 以外的值);真需要绝对同构时应
25
+ * 改走 CLI 单点(或后续引入账本方案)。
26
+ */
27
+ import { existsSync, readFileSync } from 'node:fs';
28
+ import { homedir } from 'node:os';
29
+ import { join } from 'node:path';
30
+
31
+ /** 合法值(与 CLI 的 FEEL_MODES 一致) */
32
+ export const FEEL_MODES = Object.freeze(['enabled', 'disabled']);
33
+
34
+ /** 全局画像路径(与 CLI `global-paths.ts:getGlobalProfilePath` 同形) */
35
+ export function getGlobalProfilePath(homeDir = homedir()) {
36
+ return join(homeDir, '.config', 'openfeel', 'profile.yaml');
37
+ }
38
+
39
+ /** 行首缩进宽度(空格计;Tab 按 1 计——YAML 规范禁止 Tab 缩进,容错即可) */
40
+ function indentWidth(line) {
41
+ let n = 0;
42
+ while (n < line.length && (line[n] === ' ' || line[n] === '\t')) n += 1;
43
+ return n;
44
+ }
45
+
46
+ /** 去掉行内注释与包裹引号(只处理窄场景:`disabled` / `"disabled"` / `disabled # x`) */
47
+ function normalizeScalar(raw) {
48
+ const withoutComment = raw.replace(/\s+#.*$/, '').trim();
49
+ if (withoutComment.length >= 2) {
50
+ const first = withoutComment[0];
51
+ const last = withoutComment[withoutComment.length - 1];
52
+ if ((first === '"' || first === "'") && first === last) {
53
+ return withoutComment.slice(1, -1).trim();
54
+ }
55
+ }
56
+ return withoutComment;
57
+ }
58
+
59
+ /**
60
+ * 在 YAML 文本的指定顶层块中读取 `key` 的标量值(窄解析)。
61
+ *
62
+ * 只认**直接子键**(与 `yaml.parse` 后取 `defaults.feel_mode` 同义):
63
+ * 更深嵌套的 `defaults:\n nested:\n feel_mode: x` **不算**(CLI 读到的是 undefined)。
64
+ * 同时支持 flow 内联写法 `defaults: { feel_mode: disabled }`(CLI 能读到;镜像不得分叉)。
65
+ * @param {string} text YAML 原文
66
+ * @param {string} holder 块名(`defaults` / `preferences`)
67
+ * @param {string} key 块内键名(`feel_mode`)
68
+ * @returns {string|undefined} 标量原文;块/键缺失或块为空 → undefined
69
+ */
70
+ function readBlockScalar(text, holder, key) {
71
+ const lines = text.split(/\r?\n/);
72
+ const holderPattern = new RegExp(`^${holder}:\\s*(?:#.*)?$`);
73
+ const inlinePattern = new RegExp(`^${holder}:\\s*\\{(.*)\\}\\s*(?:#.*)?$`);
74
+ const keyPattern = new RegExp(`^${key}:\\s*(.*)$`);
75
+ let holderIndent = null;
76
+ let childIndent = null;
77
+ for (const line of lines) {
78
+ const trimmed = line.trim();
79
+ if (trimmed === '' || trimmed.startsWith('#')) continue;
80
+ if (holderIndent === null) {
81
+ const inline = inlinePattern.exec(trimmed);
82
+ if (inline) {
83
+ // flow map:按顶层逗号切分(窄场景足够;嵌套 flow map 不在支持范围)
84
+ for (const item of inline[1].split(',')) {
85
+ const match = keyPattern.exec(item.trim());
86
+ if (match) return normalizeScalar(match[1]);
87
+ }
88
+ return undefined;
89
+ }
90
+ if (holderPattern.test(trimmed)) holderIndent = indentWidth(line);
91
+ continue;
92
+ }
93
+ const indent = indentWidth(line);
94
+ if (indent <= holderIndent) return undefined; // 块结束(下一个同层键)
95
+ // 块内首个键的缩进 = 直接子键缩进;更深层级一律不算(与 yaml 取值语义一致)
96
+ if (childIndent === null) childIndent = indent;
97
+ if (indent !== childIndent) continue;
98
+ const match = keyPattern.exec(trimmed);
99
+ if (match) return normalizeScalar(match[1]);
100
+ }
101
+ return undefined;
102
+ }
103
+
104
+ /**
105
+ * 读取某个 YAML 文件的**显式** feel_mode(缺失 / 非法 / 读取失败 → undefined)。
106
+ * @param {string} filePath
107
+ * @param {'defaults'|'preferences'} holder
108
+ * @returns {'enabled'|'disabled'|undefined}
109
+ */
110
+ function readExplicitFeelMode(filePath, holder) {
111
+ if (!existsSync(filePath)) return undefined;
112
+ try {
113
+ const text = readFileSync(filePath, 'utf-8');
114
+ const value = readBlockScalar(text, holder, 'feel_mode');
115
+ return value === 'enabled' || value === 'disabled' ? value : undefined;
116
+ } catch {
117
+ return undefined;
118
+ }
119
+ }
120
+
121
+ /**
122
+ * 解析 feel_mode 有效值与来源(与 CLI `resolveFeelMode` 同构)。
123
+ * @param {string} projectRoot 项目根(`.openfeel/` 所在目录)
124
+ * @param {{ homeDir?: string }} [options] 测试注入(缺省 os.homedir())
125
+ * @returns {{ value: 'enabled'|'disabled', source: 'config.yaml'|'profile.yaml'|'builtin' }}
126
+ */
127
+ export function resolveFeelMode(projectRoot, options = {}) {
128
+ const project = readExplicitFeelMode(join(projectRoot, '.openfeel', 'config.yaml'), 'defaults');
129
+ if (project !== undefined) return { value: project, source: 'config.yaml' };
130
+
131
+ const global = readExplicitFeelMode(getGlobalProfilePath(options.homeDir), 'preferences');
132
+ if (global !== undefined) return { value: global, source: 'profile.yaml' };
133
+
134
+ return { value: 'disabled', source: 'builtin' };
135
+ }
@@ -70,6 +70,15 @@ export function computeWorkflowGate(snapshot) {
70
70
  if (hasOpenStage) {
71
71
  return { required: false, reason: null, message: '', actions: [] };
72
72
  }
73
+ // v1.5.17:feel_mode=disabled(软关闭)→ 不催建需求/阶段。
74
+ // 注意:本分支只替换 `no-active-stage`;`guard-*` 三条自检在上面且优先级更高
75
+ // (写入门禁失活比「没开阶段」严重,disabled 也不得吞掉)。
76
+ // `message` 恒为 '':`workflowGateTitle` 的 default 分支会返回 message 原文,
77
+ // 一旦给文案就会产生「⚠ 自由模式」类噪声标题。
78
+ const feelMode = snapshot?.feelMode;
79
+ if (feelMode !== null && typeof feelMode === 'object' && feelMode.value === 'disabled') {
80
+ return { required: false, reason: 'feel-mode-off', message: '', actions: [] };
81
+ }
73
82
  return {
74
83
  required: true,
75
84
  reason: 'no-active-stage',
package/dsh/lib/index.js CHANGED
@@ -30,6 +30,7 @@ import { FeelCli } from './adapters/cli.js';
30
30
  import { resolveWorkspace } from './adapters/workspace.js';
31
31
  import { writeHostMarker } from './adapters/host-state.js';
32
32
  import { setGuardRuntimeIdentity, writeGuardState } from './adapters/guard-state.js';
33
+ import { resolveFeelMode } from './adapters/feel-mode.js';
33
34
  import { touchSession } from './adapters/session-cwd-registry.js';
34
35
  import { createOpenFeelGuard, resolveShellGate } from './guard.js';
35
36
  import { createFeelCommandHandler } from './surface/command.js';
@@ -270,7 +271,13 @@ export function apply(ctx, rawConfig) {
270
271
  // - 未初始化 + activation=auto → 短 bootstrap;
271
272
  // - activation=off → 外层不注册 section。
272
273
  if (resolved.initialized) {
273
- return renderFeelPrompt({ projectRoot: resolved.projectRoot, detected: true, language: config.language });
274
+ // v1.5.17:每轮重新解析 feel_mode(即时生效;镜像 CLI resolveFeelMode,只读两个小文件)
275
+ return renderFeelPrompt({
276
+ projectRoot: resolved.projectRoot,
277
+ detected: true,
278
+ language: config.language,
279
+ feelMode: resolveFeelMode(resolved.projectRoot),
280
+ });
274
281
  }
275
282
  if (config.activation === 'always') {
276
283
  return renderFeelPrompt({ projectRoot: resolved.projectRoot, detected: false, language: config.language });
@@ -27,8 +27,47 @@ export const FEEL_PROMPT_NAME = 'feel-mode';
27
27
  */
28
28
  export function renderFeelPrompt(options = {}) {
29
29
  const language = options.language ?? 'zh-CN';
30
- if (language === 'en') return renderEnglish(options);
31
- return renderChinese(options);
30
+ // v1.5.17:feel_mode=disabled → 软关闭(只放松流程强制;硬门与写入门禁不变)
31
+ const feelDisabled = options?.feelMode?.value === 'disabled';
32
+ const merged = { ...options, feelDisabled };
33
+ if (language === 'en') return renderEnglish(merged);
34
+ return renderChinese(merged);
35
+ }
36
+
37
+ /**
38
+ * 自由模式节(中文;v1.5.17)。
39
+ * 只放松「流程强制」:需求/阶段由 AI 自行判断、preflight 降级为提示;
40
+ * 状态机 / done 门 / 阶段验证 / 归档判据 / blocking REV / 写入门禁全部保留。
41
+ * @returns {string}
42
+ */
43
+ function renderFreeModeChinese() {
44
+ return `
45
+ ## 自由模式(\`feel_mode=disabled\`;与后文冲突时以本节为准)
46
+ - **不强制流程**:是否创建需求(REQ)、是否建立阶段/工作流,由你判断;不再催你「先建阶段」。
47
+ - **可以直接干活**:只读任务直接做;改代码/写文档直接做(写入门禁仍生效)。
48
+ - **先读后写降级**:preflight 从「拒绝」降为「提示」——不必先 \`feel_status\` 才能写;写状态前读一眼仍是好习惯。
49
+ - **后文流程动作均为可选**:「每次动手前」「需求导向与流程入口」「写命令与 preflight」中的强制动作在本模式下不强制。
50
+ - **仍然不可协商**:禁止手改 \`flow.json\` / \`status.md\` / \`pipeline.yaml\` / \`config.yaml\`;状态机合法性、\`done\` 门、阶段验证门、版本归档判据、blocking REV 门、写入门禁**全部照旧**。
51
+ - **归档 / 发布仍需用户确认**;需要历史时用 \`feel_archive\` 查询。
52
+ - **若选择走流程**:\`feel_req add\` → \`claim\` → \`feel_stage add\`;一旦进入流水线,相位门禁照常执行。
53
+ `;
54
+ }
55
+
56
+ /**
57
+ * 自由模式节(英文;v1.5.17)。
58
+ * @returns {string}
59
+ */
60
+ function renderFreeModeEnglish() {
61
+ return `
62
+ ## Free mode (\`feel_mode=disabled\`; this section wins over later conflicts)
63
+ - **Workflow is optional**: whether to create a requirement (REQ) or open a stage/workflow is your call; nobody nags you to open a stage.
64
+ - **Work directly when appropriate**: read-only work proceeds immediately; code/doc edits proceed immediately (the write guard still applies).
65
+ - **Read-before-write is relaxed**: preflight downgrades from "refuse" to "warn" — you no longer need \`feel_status\` before writing; still a good habit before state writes.
66
+ - **Later mandatory-looking steps are optional**: "Before acting", "Requirement-first & workflow entry", and "Write commands & preflight" are advisory in this mode.
67
+ - **Still non-negotiable**: never hand-edit \`flow.json\` / \`status.md\` / \`pipeline.yaml\` / \`config.yaml\`; the state machine, \`done\` gate, stage verification gate, version-archive criteria, blocking-REV gate and the write guard all remain in force.
68
+ - **Archive / release still needs user confirmation**; use \`feel_archive\` to inspect history.
69
+ - **If you do choose the workflow**: \`feel_req add\` → \`claim\` → \`feel_stage add\`; once in the pipeline, phase gates apply as usual.
70
+ `;
32
71
  }
33
72
 
34
73
  /**
@@ -114,11 +153,13 @@ function renderChinese(options) {
114
153
  const where = options.detected === true && options.projectRoot !== undefined
115
154
  ? `当前项目:\`${options.projectRoot}\`(已初始化 \`.openfeel/\`)。`
116
155
  : '当前工作区尚未检测到 `.openfeel/`:若用户要求使用 Feel 流程,先提示运行 `openfeel init`。';
117
- const status = options.detected === true ? 'Feel 模式已启用' : 'Feel 模式未初始化';
156
+ const status = options.detected === true
157
+ ? (options.feelDisabled === true ? 'Feel 模式已启用(`feel_mode=disabled`:自由模式)' : 'Feel 模式已启用')
158
+ : 'Feel 模式未初始化';
118
159
 
119
160
  return `<feel_mode>
120
161
  ${status}:本会话在 OpenFeel 流程治理下工作。${where}
121
-
162
+ ${options.feelDisabled === true ? renderFreeModeChinese() : ''}
122
163
  ## 你的角色:调度者,不是执行者
123
164
  你的价值是判断「该谁做」,而不是自己做。OpenFeel 的 15 个相位各有负责 Agent:
124
165
  planner(计划)/ schemer(方案)/ executor(执行)/ reviewer(审查)/ feel-tester(测试)/ archiver(归档)。
@@ -201,11 +242,13 @@ function renderEnglish(options) {
201
242
  const where = options.detected === true && options.projectRoot !== undefined
202
243
  ? `Project: \`${options.projectRoot}\` (initialized \`.openfeel/\`).`
203
244
  : 'No `.openfeel/` detected in this workspace: if the user asks for the Feel process, suggest `openfeel init` first.';
204
- const status = options.detected === true ? 'Feel mode is active' : 'Feel mode is not initialized';
245
+ const status = options.detected === true
246
+ ? (options.feelDisabled === true ? 'Feel mode is active (`feel_mode=disabled`: free mode)' : 'Feel mode is active')
247
+ : 'Feel mode is not initialized';
205
248
 
206
249
  return `<feel_mode>
207
250
  ${status}: this session works under OpenFeel process governance. ${where}
208
-
251
+ ${options.feelDisabled === true ? renderFreeModeEnglish() : ''}
209
252
  ## Your role: orchestrator, not implementer
210
253
  Your value is deciding WHO acts, not acting yourself. The 15 pipeline phases each have an owning agent:
211
254
  planner / schemer / executor / reviewer / feel-tester / archiver. **The authoritative mapping comes from
@@ -19,6 +19,7 @@ import { readRecovery } from '../adapters/recovery.js';
19
19
  import { readPreflightInfo } from '../adapters/preflight.js';
20
20
  import { buildObservability } from '../adapters/observability.js';
21
21
  import { computeWorkflowGate, headlineWarning } from '../adapters/workflow-gate.js';
22
+ import { resolveFeelMode } from '../adapters/feel-mode.js';
22
23
  import { buildGuardSection, maybeSelfHealGuardState, repairGuardState } from '../adapters/guard-state.js';
23
24
  import { readHostMarker } from '../adapters/host-state.js';
24
25
  import { resolveGuardCwd } from '../guard.js';
@@ -141,6 +142,22 @@ function safeObservability(snapshot) {
141
142
  }
142
143
  }
143
144
 
145
+ /**
146
+ * 展示层对齐(v1.5.17):`feel_mode=disabled` 时 CLI 的 preflight 有效模式已降级为 warn
147
+ * (`src/core/preflight.ts:resolvePreflightMode`),而适配器读到的是**宿主 env**(可能仍是 strict)。
148
+ * 这里同步展示为 warn,避免出现「报告 strict 却实际放行」的矛盾视图。
149
+ * @param {Record<string, any>|null|undefined} preflight readPreflightInfo 结果
150
+ * @param {{ value?: string }|null|undefined} feelMode resolveFeelMode 结果
151
+ * @returns {Record<string, any>|null|undefined}
152
+ */
153
+ function applyFeelModeToPreflight(preflight, feelMode) {
154
+ if (preflight === null || preflight === undefined || typeof preflight !== 'object') return preflight;
155
+ if (feelMode?.value === 'disabled' && preflight.mode === 'strict') {
156
+ return { ...preflight, mode: 'warn', downgradedByFeelMode: true };
157
+ }
158
+ return preflight;
159
+ }
160
+
144
161
  /**
145
162
  * `feel_status` 的默认精简视图(v1.5.7):只保留调度必需字段。
146
163
  *
@@ -184,6 +201,8 @@ export function compactStatusSnapshot(snapshot) {
184
201
  stages: snapshot?.stages ?? [],
185
202
  statusSync: snapshot?.statusSync ?? null,
186
203
  workflowGate: snapshot?.workflowGate ?? null,
204
+ // v1.5.17:feel_mode 及来源(default 档/compact 档都要能看见闸是否被软关闭)
205
+ feelMode: snapshot?.feelMode ?? null,
187
206
  // v1.5.11 D-126-04:门禁自检段(registered / cwd / cwdSource / degraded / stale /
188
207
  // lastDecision);compact 档同样带,否则「门禁是否生效」在默认档看不见。
189
208
  guard: snapshot?.guard ?? null,
@@ -331,13 +350,17 @@ export function createTools(context) {
331
350
  // `readSnapshot` 会跑 `flow status --json` / `flow next --json`,二者在 JSON 早返回前
332
351
  // 就 recordPreflight(src/commands/flow.ts),读晚了会把本次调用刚写的账本当历史 ⇒ 指标自测。
333
352
  // 读取次数不变(仍 1 次/工具),零新增 I/O。
334
- const preflight = readPreflightInfo(resolved.cwd);
353
+ const preflightInfo = readPreflightInfo(resolved.cwd);
335
354
  const snapshot = await readSnapshot(cli, {
336
355
  cwd: resolved.cwd,
337
356
  signal: exec.signal,
338
357
  withRequirements: args.with_requirements === true,
339
358
  });
340
359
  snapshot.project.root = resolved.cwd;
360
+ // v1.5.17:feel_mode 每轮现读(即时生效),供 workflowGate 与输出使用
361
+ snapshot.feelMode = resolveFeelMode(resolved.cwd);
362
+ // 展示一致:disabled 时 preflight 实际按 warn 放行(CLI 侧降级),这里同步展示模式
363
+ const preflight = applyFeelModeToPreflight(preflightInfo, snapshot.feelMode);
341
364
  snapshot.statusSync = readStatusSync(resolved.cwd);
342
365
  // v1.5.11 D-126-01 登记点 ②:每次 feel_* 也记会话 cwd(门禁第 3 环兜底)。
343
366
  touchSessionCwd(exec?.agent?.session?.id, resolved.sessionCwd);
@@ -393,9 +416,12 @@ export function createTools(context) {
393
416
  requireInitialized(resolved);
394
417
  return envelope('next', async () => {
395
418
  // v1.5.6 / REV-022:同 feel_status —— 账本先读,再跑会写账本的 CLI 调用。
396
- const preflight = readPreflightInfo(resolved.cwd);
419
+ const preflightInfo = readPreflightInfo(resolved.cwd);
397
420
  const snapshot = await readSnapshot(cli, { cwd: resolved.cwd, signal: exec.signal });
398
421
  snapshot.project.root = resolved.cwd;
422
+ // v1.5.17:feel_mode 每轮现读(即时生效);preflight 展示与 CLI 降级语义对齐
423
+ snapshot.feelMode = resolveFeelMode(resolved.cwd);
424
+ const preflight = applyFeelModeToPreflight(preflightInfo, snapshot.feelMode);
399
425
  snapshot.statusSync = readStatusSync(resolved.cwd);
400
426
  // v1.5.11 D-126-01 登记点 ②:每次 feel_* 也记会话 cwd(门禁第 3 环兜底)。
401
427
  touchSessionCwd(exec?.agent?.session?.id, resolved.sessionCwd);
@@ -411,6 +437,7 @@ export function createTools(context) {
411
437
  snapshot.observability = safeObservability(snapshot);
412
438
  const plan = planNextStep(snapshot);
413
439
  plan.workflowGate = snapshot.workflowGate;
440
+ plan.feelMode = snapshot.feelMode ?? null;
414
441
  plan.guard = snapshot.guard;
415
442
  plan.preflight = snapshot.preflight;
416
443
  snapshot.recovery.nextAction = plan.suggestedCommand ?? null;
package/dsh/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfeel-dsh",
3
- "version": "1.5.16",
3
+ "version": "1.5.18",
4
4
  "description": "OpenFeel × DSH — Feel 模式适配器:把 OpenFeel 的流水线、需求分发、版本归档与知识库接入 DeepSeek Harness",
5
5
  "type": "module",
6
6
  "private": true,
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "openfeel": {
35
35
  "adapter": "dsh",
36
- "requiresCli": ">=1.5.16"
36
+ "requiresCli": ">=1.5.18"
37
37
  },
38
38
  "keywords": [
39
39
  "openfeel",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfeel",
3
- "version": "1.5.16",
3
+ "version": "1.5.18",
4
4
  "description": "AI Agent 开发流程治理 CLI 工具",
5
5
  "type": "module",
6
6
  "private": false,