@double-codeing/flow2spec 3.1.0 → 3.1.2

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 (30) hide show
  1. package/README.en.md +2 -2
  2. package/README.md +2 -2
  3. package/cli.js +122 -11
  4. package/docs/en/architecture.md +2 -2
  5. package/docs/en/commands-reference.md +14 -10
  6. package/docs/en/design-principles.md +8 -5
  7. package/docs/en/directory-conventions.md +4 -0
  8. package/docs/en/usage-guide.md +12 -4
  9. package/docs/en/usage-scenarios.md +2 -2
  10. package/docs//344/275/223/347/263/273/344/270/216/345/216/237/347/220/206.md +2 -2
  11. package/docs//344/275/277/347/224/250/346/241/210/344/276/213-/346/250/241/346/213/237/345/257/271/350/257/235.md +1 -1
  12. package/docs//344/275/277/347/224/250/350/257/264/346/230/216.md +11 -4
  13. package/docs//345/221/275/344/273/244/350/257/264/346/230/216.md +13 -10
  14. package/docs//347/233/256/345/275/225/344/270/216/350/267/257/345/276/204/347/272/246/345/256/232.md +4 -0
  15. package/docs//350/256/276/350/256/241/350/257/264/346/230/216.md +86 -53
  16. package/lib/claudeSettingsAdapter.js +133 -29
  17. package/lib/flow2specConfig.js +32 -6
  18. package/lib/init.js +148 -3
  19. package/package.json +1 -1
  20. package/templates/AGENTS.codex-stub.md +2 -0
  21. package/templates/AGENTS.md +13 -0
  22. package/templates/flow2spec.config.json +5 -2
  23. package/templates/hooks/f2s-config-inject.js +9 -147
  24. package/templates/hooks/f2s-config-session.js +95 -0
  25. package/templates/hooks/f2s-update-check.js +187 -0
  26. package/templates/knowledge/topics/f2s-config-precheck.md +2 -2
  27. package/templates/rules/f2s-config-check.mdc +3 -1
  28. package/templates/rules/f2s-flow2spec-unified-entry.mdc +13 -0
  29. package/templates/skills/f2s-git-commit/SKILL.md +21 -5
  30. package/templates/skills/f2s-kb-upgrade/SKILL.md +4 -0
package/README.en.md CHANGED
@@ -151,7 +151,7 @@ natural language: implement the proposal above ← AI starts coding (tas
151
151
  | `/f2s-kb-feat` | Add a new capability |
152
152
  | `/f2s-kb-fix` | Fix a bug |
153
153
  | `/f2s-kb-sync` | Sync knowledge base |
154
- | `/f2s-git-commit` | Commit code |
154
+ | `/f2s-git-commit` | Commit code; "quick commit" skips KB coverage check |
155
155
  | `/f2s-kb-add <path>` | Import API module into knowledge base |
156
156
 
157
157
  For the full command list, see [Usage Guide](./docs/en/usage-guide.md) · [Commands Reference](./docs/en/commands-reference.md)
@@ -186,4 +186,4 @@ For the full command list, see [Usage Guide](./docs/en/usage-guide.md) · [Comma
186
186
 
187
187
  ## License
188
188
 
189
- MIT. Copyright © 2026 兰涛
189
+ MIT. Copyright © 2026 兰涛
package/README.md CHANGED
@@ -149,7 +149,7 @@ npx @double-codeing/flow2spec@latest init
149
149
  | `/f2s-kb-feat` | 新增小功能 |
150
150
  | `/f2s-kb-fix` | 改 BUG |
151
151
  | `/f2s-kb-sync` | 同步知识库 |
152
- | `/f2s-git-commit` | 提交代码 |
152
+ | `/f2s-git-commit` | 提交代码;“快捷提交”跳过知识库覆盖检查 |
153
153
  | `/f2s-kb-add <路径>` | 接口模块入知识库 |
154
154
 
155
155
  更多命令详见 [使用说明](./docs/使用说明.md) · [命令说明](./docs/命令说明.md)
@@ -184,4 +184,4 @@ npx @double-codeing/flow2spec@latest init
184
184
 
185
185
  ## 协议
186
186
 
187
- MIT. Copyright © 2026 兰涛
187
+ MIT. Copyright © 2026 兰涛
package/cli.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const path = require("path");
4
4
  const fs = require("fs");
5
+ const os = require("os");
5
6
  const readline = require("readline");
6
7
  const runInit = require("./lib/init");
7
8
  const { AGENTS } = require("./lib/agents");
@@ -12,7 +13,7 @@ const {
12
13
  getMissingConfigFields,
13
14
  } = require("./lib/flow2specConfig");
14
15
 
15
- const { execSync } = require("child_process");
16
+ const { execFileSync } = require("child_process");
16
17
 
17
18
  const args = process.argv.slice(2);
18
19
  const sub = args[0];
@@ -23,6 +24,107 @@ const agentList = Object.entries(AGENTS)
23
24
 
24
25
  const pkg = require("./package.json");
25
26
 
27
+ const UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1000;
28
+
29
+ function parseVersion(version) {
30
+ return String(version || "")
31
+ .replace(/^v/, "")
32
+ .split(/[.-]/)
33
+ .slice(0, 3)
34
+ .map((part) => {
35
+ const n = Number.parseInt(part, 10);
36
+ return Number.isFinite(n) ? n : 0;
37
+ });
38
+ }
39
+
40
+ function compareVersions(a, b) {
41
+ const av = parseVersion(a);
42
+ const bv = parseVersion(b);
43
+ for (let i = 0; i < 3; i += 1) {
44
+ const diff = (av[i] || 0) - (bv[i] || 0);
45
+ if (diff !== 0) return diff;
46
+ }
47
+ return 0;
48
+ }
49
+
50
+ function updateCheckCacheFile() {
51
+ const safeName = String(pkg.name || "flow2spec").replace(/[^a-z0-9_.-]+/gi, "_");
52
+ return path.join(os.homedir(), ".flow2spec", `${safeName}-update-check.json`);
53
+ }
54
+
55
+ function readUpdateCheckCache() {
56
+ const file = updateCheckCacheFile();
57
+ if (!fs.existsSync(file)) return null;
58
+ try {
59
+ const data = JSON.parse(fs.readFileSync(file, "utf8"));
60
+ if (!data || typeof data !== "object") return null;
61
+ if (Date.now() - Number(data.checkedAt || 0) > UPDATE_CHECK_TTL_MS) {
62
+ return null;
63
+ }
64
+ return data;
65
+ } catch {
66
+ return null;
67
+ }
68
+ }
69
+
70
+ function writeUpdateCheckCache(latest) {
71
+ try {
72
+ const file = updateCheckCacheFile();
73
+ fs.mkdirSync(path.dirname(file), { recursive: true });
74
+ fs.writeFileSync(
75
+ file,
76
+ `${JSON.stringify({ latest, checkedAt: Date.now() }, null, 2)}\n`,
77
+ "utf8",
78
+ );
79
+ } catch {
80
+ // 更新检查不能影响主命令。
81
+ }
82
+ }
83
+
84
+ function queryLatestPackageVersion() {
85
+ const cached = readUpdateCheckCache();
86
+ if (cached?.latest) return cached.latest;
87
+ const latest = execFileSync("npm", ["view", pkg.name, "version"], {
88
+ encoding: "utf8",
89
+ timeout: 2000,
90
+ stdio: ["ignore", "pipe", "ignore"],
91
+ }).trim();
92
+ if (latest) writeUpdateCheckCache(latest);
93
+ return latest;
94
+ }
95
+
96
+ function shouldCheckForUpdates() {
97
+ if (process.env.FLOW2SPEC_SKIP_UPDATE_CHECK === "1") return false;
98
+ if (process.env.CI) return false;
99
+ if (!process.stdout.isTTY) return false;
100
+ return Boolean(pkg.name && pkg.version);
101
+ }
102
+
103
+ function printKnowledgeUpgradeHint(latest) {
104
+ console.log(`
105
+ ⚠ Flow2Spec 有新版本 v${latest}(当前 v${pkg.version})
106
+ 建议先更新包:
107
+ flow2spec update
108
+
109
+ 更新后请在 Agent 对话中执行:
110
+ f2s-kb-upgrade
111
+
112
+ 用于对齐项目知识库模板、manifest/matchers 与配置根产物;不要把单独 flow2spec init 当作知识库升级。
113
+ `);
114
+ }
115
+
116
+ function maybePrintUpdateNotice() {
117
+ if (!shouldCheckForUpdates()) return;
118
+ try {
119
+ const latest = queryLatestPackageVersion();
120
+ if (latest && compareVersions(latest, pkg.version) > 0) {
121
+ printKnowledgeUpgradeHint(latest);
122
+ }
123
+ } catch {
124
+ // 静默跳过,不能因为网络或 npm registry 影响主命令。
125
+ }
126
+ }
127
+
26
128
  const help = `
27
129
  Flow2Spec - 统一知识库工作流(AI 配置入口) v${pkg.version}
28
130
 
@@ -30,7 +132,7 @@ Flow2Spec - 统一知识库工作流(AI 配置入口) v${pkg.version}
30
132
  flow2spec init [agent ...] [--reset-knowledge] [--yes] 在当前项目初始化:写入 .Knowledge 与所选 agent 入口
31
133
  flow2spec config 打印项目根 ${CONFIG_FILENAME} 的解析结果(缺省值合并后)
32
134
  flow2spec version 显示当前 flow2spec 版本
33
- flow2spec update 更新 flow2spec 到最新版本
135
+ flow2spec update 更新 flow2spec 到最新版本;更新后提示执行 f2s-kb-upgrade
34
136
  flow2spec --help 显示本说明
35
137
 
36
138
  agent(可多个,空格分隔;省略时交互选择):
@@ -47,13 +149,14 @@ init 会:
47
149
  1. 交互询问要初始化的 AI 工具(cursor / claude / codex,可多选);已通过参数指定则跳过。
48
150
  传 --yes 或非 TTY 环境时跳过问答,使用默认值。
49
151
  2. 对 ${CONFIG_FILENAME} 中缺失的配置字段逐项提问(已有字段不覆盖)。
50
- 传 --yes 时所有缺失字段使用默认值(均为 false)。
152
+ 传 --yes 时所有缺失字段使用各自默认值。
51
153
  3. 默认仅补齐 .Knowledge 缺失模板,并对路由清单做包级/结构增量对齐(manifest-routing + matcherPath 分片;关键词仅写在 matchers/*.json);不替代 f2s-* 对业务文档与路由内容的写入。
52
154
  传 --reset-knowledge 时才会强制用模板覆盖 .Knowledge 中模板承载部分。
53
155
  4. 在各 agent 配置根写入 rules、skills(Claude 规则自动转 .md;Codex 在仓库根写入完整 AGENTS.md,.codex/ 写入指针)。
54
- Claude 额外写入 .claude/hooks/f2s-config-inject.js 与 .claude/settings.json(PreToolUse hook),
55
- 在调用 f2s-* Skill 时注入配置摘要;配置缺失、JSON 无效或 hook 异常时也会注入默认语义说明,避免静默。
56
- Cursor 额外写入 f2s-config-check.mdc(alwaysApply),强制在技能首步读取配置文件。
156
+ Claude 额外写入 .claude/hooks/f2s-config-session.js、f2s-config-inject.js 与 .claude/settings.json
157
+ SessionStart 注入一次配置摘要;PreToolUse 仅在调用 f2s-* Skill 时提示首步必须 Read 配置。
158
+ Cursor 额外写入 f2s-config-check.mdc(alwaysApply),强制在技能首步读取配置文件;
159
+ 并写入 .cursor/hooks.json,在 sessionStart 自动检测知识库版本。
57
160
  Codex:仓库根 AGENTS.md(CLI 自动发现,完整条令);.codex/AGENTS.md 为指针。
58
161
  5. 每次 init 将包内 templates/knowledge/index.md 复制到 .Knowledge/template/index.template.md,供 f2s-kb-upgrade 技能与 .Knowledge/index.md 对照;不自动改写 index.md。(「知识库升级」指 f2s-kb-upgrade 技能,init 本身不是升级命令。)
59
162
  6. 规则与技能在各 agent 配置根加载;其他模版类文件在 .Knowledge/template/ 等目录。
@@ -68,6 +171,7 @@ if (sub === "--help" || sub === "-h" || !sub) {
68
171
 
69
172
  if (sub === "version" || sub === "--version" || sub === "-v") {
70
173
  console.log(`flow2spec v${pkg.version}`);
174
+ maybePrintUpdateNotice();
71
175
  process.exit(0);
72
176
  }
73
177
 
@@ -75,19 +179,25 @@ if (sub === "update") {
75
179
  console.log(`当前版本: v${pkg.version}`);
76
180
  console.log("正在检查最新版本...");
77
181
  try {
78
- const latest = execSync(`npm view ${pkg.name} version`, {
182
+ const latest = execFileSync("npm", ["view", pkg.name, "version"], {
79
183
  encoding: "utf8",
80
184
  }).trim();
81
- if (latest === pkg.version) {
82
- console.log(`已是最新版本 v${latest}`);
185
+ if (compareVersions(latest, pkg.version) <= 0) {
186
+ console.log(`当前版本不低于 npm 最新版本 v${latest}`);
83
187
  process.exit(0);
84
188
  }
85
189
  console.log(`发现新版本: v${latest}`);
86
190
  console.log("正在更新...");
87
- execSync(`npm install -g ${pkg.name}@latest`, {
191
+ execFileSync("npm", ["install", "-g", `${pkg.name}@latest`], {
88
192
  stdio: "inherit",
89
193
  });
90
194
  console.log(`\n✓ 已更新到 v${latest}`);
195
+ console.log(`
196
+ 下一步:请在需要升级的项目 Agent 对话中执行:
197
+ f2s-kb-upgrade
198
+
199
+ 用于对齐项目知识库模板、manifest/matchers 与配置根产物;不要把单独 flow2spec init 当作知识库升级。
200
+ `);
91
201
  } catch (e) {
92
202
  console.error("更新失败:", e.message || e);
93
203
  process.exit(1);
@@ -296,7 +406,7 @@ if (sub === "init") {
296
406
  return ` - ${root}/:(${label})skills/、topics/、AGENTS.md(指针);仓库根 AGENTS.md(完整)`;
297
407
  if (id === "claude") {
298
408
  const hookLine = claudeHooksResult?.settingsChanged
299
- ? "rules/、skills/、hooks/f2s-config-inject.js、settings.json(已写入 f2s PreToolUse hook)"
409
+ ? "rules/、skills/、hooks/f2s-config-session.js、hooks/f2s-config-inject.js、settings.json(已写入 f2s SessionStart/PreToolUse hooks)"
300
410
  : "rules/、skills/(settings.json 中 f2s hook 已存在,跳过)";
301
411
  return ` - ${root}/:(${label})${hookLine}`;
302
412
  }
@@ -326,6 +436,7 @@ ${lines.join("\n")}
326
436
 
327
437
  建议阅读 README 或 docs/使用说明.md,按「规则在配置根、文档在 .Knowledge」的方式使用。
328
438
  `);
439
+ maybePrintUpdateNotice();
329
440
  })
330
441
  .catch((e) => {
331
442
  console.error(e.message || e);
@@ -136,9 +136,9 @@ Design intent: Cross-verification introduces an external perspective, reducing t
136
136
  ```json
137
137
  {
138
138
  "changeTracking": {
139
- "feat": false,
139
+ "feat": true,
140
140
  "fix": false,
141
- "implement": false
141
+ "implement": true
142
142
  }
143
143
  }
144
144
  ```
@@ -15,7 +15,7 @@
15
15
  | `/f2s-req-clarify` | Clarify requirements via multi-round Q&A | Requirements |
16
16
  | `/f2s-req-backend` | Generate backend technical proposal from clarified requirements | Requirements |
17
17
  | `/f2s-req-plan` | Break a technical proposal into a task checklist and implement (always creates tasks, regardless of `changeTracking.*` config) | Requirements |
18
- | `/f2s-git-commit` | Commit code with automatic knowledge base coverage check | Commit |
18
+ | `/f2s-git-commit` | Commit code; checks knowledge base coverage by default, skips that check in "quick commit" mode | Commit |
19
19
  | `/f2s-kb-feat` | Add new capability + sync knowledge base | KB Maintenance |
20
20
  | `/f2s-kb-fix` | Fix a bug + auto-sync knowledge base | KB Maintenance |
21
21
  | `/f2s-kb-sync` | Sink implemented capabilities from the conversation into the knowledge base | KB Maintenance |
@@ -288,13 +288,14 @@
288
288
 
289
289
  ### `f2s-git-commit`
290
290
 
291
- **Purpose**: Executes a Git commit after code is written. Automatically checks changed files, compares knowledge base coverage, prompts the user about capabilities not yet imported, and performs the commit after the commit message is confirmed.
291
+ **Purpose**: Executes a Git commit after code is written. By default it checks changed files and knowledge base coverage, prompting the user about capabilities not yet imported. If the user explicitly asks for a "quick commit", it skips the knowledge base coverage check. Before committing, it displays the commit message subject and then runs `git commit`.
292
292
 
293
- **How It Works**: Layers a "knowledge base coverage gate" on top of `git commit` — infer touched capability areas from `git diff`, cross-check against `.Knowledge/topics/` and `stock-docs/`, and decide whether changed capabilities are documented in the knowledge base. If not covered, block and offer three choices (document first / skip / cancel) to avoid silent drift where "code exists but the knowledge base does not know." Commit messages use emoji + Conventional Commits for consistent, machine-friendly `git log`.
293
+ **How It Works**: Layers a "knowledge base coverage gate" on top of `git commit` — infer touched capability areas from `git diff`, cross-check against `.Knowledge/topics/` and `stock-docs/`, and decide whether changed capabilities are documented in the knowledge base. If not covered, block and offer three choices (document first / skip / cancel) to avoid silent drift where "code exists but the knowledge base does not know." Quick commit mode only skips this coverage gate; it does not skip conflict checks, message display, precise `git add`, or git hooks. Commit messages use emoji + Conventional Commits for consistent, machine-friendly `git log`.
294
294
 
295
295
  **Use Cases**:
296
296
  - Committing code after each feature implementation or bug fix
297
297
  - Wanting reminders about knowledge base coverage at commit time
298
+ - Explicitly wanting to skip this commit's coverage check with a quick commit
298
299
  - Needing AI help to generate meaningful commit messages
299
300
 
300
301
  **Relationships**:
@@ -304,7 +305,7 @@
304
305
 
305
306
  **Execution Flow**:
306
307
  1. `git status --short` + `git diff HEAD` to classify files into staged / unstaged / untracked; immediately terminates if merge conflict markers are found
307
- 2. Compare `.Knowledge/topics/` and `stock-docs/` to determine whether the changed capabilities have been imported; skips and notifies if `.Knowledge` does not exist
308
+ 2. By default, compare `.Knowledge/topics/` and `stock-docs/` to determine whether the changed capabilities have been imported; skips and notifies if `.Knowledge` does not exist; skips this step when the user asks for a quick commit
308
309
  3. If not covered, prompt the user to choose: A) Import first, then commit / B) Commit now, import later / C) Cancel
309
310
  4. Generate a commit message draft based on `git diff` content, wait for user confirmation or changes
310
311
  5. `git add <specific files>` + `git commit`; if a hook fails, prompt for fix, do not skip
@@ -314,7 +315,7 @@
314
315
  - `git add -A` / `git add .` is forbidden; only add confirmed changed files
315
316
  - `--no-verify` is forbidden; hook failures must be fixed and retried
316
317
  - Auto-push is forbidden
317
- - The commit message must be confirmed by the user; silent commits are not allowed
318
+ - The commit message subject must be displayed before committing; an extra user confirmation round is not required
318
319
 
319
320
  **Sub-Agent Invocation**: None (full interactive confirmation, handled within the main agent)
320
321
 
@@ -497,6 +498,9 @@
497
498
  **Use Cases**:
498
499
  - After a `flow2spec` package version upgrade, upgrade the project knowledge base template
499
500
  - Upgrade an old project to the latest structure
501
+ - When interactive `flow2spec version` / `flow2spec init` detects a newer npm version, the CLI prompts you to run `flow2spec update`, then execute this skill in the Agent conversation
502
+ - When Cursor detects an older knowledge-base version through `.cursor/hooks.json` on `sessionStart`, it prompts you to execute this skill
503
+ - When Codex detects an older knowledge-base version through `.codex/hooks.json` on `SessionStart`, it prompts you to execute this skill (new or changed hooks must be trusted through `/hooks` first)
500
504
 
501
505
  **Relationships**:
502
506
  - **Prerequisite**: `f2s-kb-migrate` (V1 flow) or an existing `.Knowledge/`
@@ -590,11 +594,11 @@ The following are not skill commands but rules activated by trigger words to gui
590
594
 
591
595
  ## 6) Sub-Agent Configuration
592
596
 
593
- Controlled via `flow2spec.config.json` at the project root (all fields default to `false`).
597
+ Controlled via `flow2spec.config.json` at the project root. Defaults: `subAgent=false`, `switchAgentVerification=false`, `changeTracking.feat=true`, `changeTracking.fix=false`, `changeTracking.implement=true`.
594
598
 
595
599
  ### How Different Products "See" the Configuration (use with the field table below)
596
600
 
597
- `subAgent` and similar fields are written to the **on-disk JSON**; products do not guarantee automatic file opening. Therefore, multi-layered hints are provided via **Cursor rules / Claude hooks / Codex AGENTS snapshot table / knowledge base `config-precheck` summary**, but **the authoritative source remains `Read("flow2spec.config.json")`** (design rationale in [design-principles.md — Agent Orchestration § 5.1](./design-principles.md); talk / deck pacing in [intro deck HTML](../../presentations/flow2spec-intro-public-en/index.html) (internal); Chinese source in `flow2spec-intro-draft`, config section). **The full path and table are maintained in one place**: [usage-guide.md Sec. 1, `f2s-*` and `flow2spec.config.json`](./usage-guide.md).
601
+ `subAgent` and similar fields are written to the **on-disk JSON**; products do not guarantee automatic file opening. Therefore, multi-layered hints are provided via **Cursor rules / Claude SessionStart summary + PreToolUse guard / Codex AGENTS snapshot table / knowledge base `config-precheck` summary**, but **the authoritative source remains `Read("flow2spec.config.json")`** (design rationale in [design-principles.md — Agent Orchestration § 5.1](./design-principles.md); talk / deck pacing in [intro deck HTML](../../presentations/flow2spec-intro-public-en/index.html) (internal); Chinese source in `flow2spec-intro-draft`, config section). **The full path and table are maintained in one place**: [usage-guide.md Sec. 1, `f2s-*` and `flow2spec.config.json`](./usage-guide.md).
598
602
 
599
603
  ### `subAgent` Field
600
604
 
@@ -617,9 +621,9 @@ A nested object, with each skill independently controlled:
617
621
  ```json
618
622
  {
619
623
  "changeTracking": {
620
- "feat": false,
624
+ "feat": true,
621
625
  "fix": false,
622
- "implement": false
626
+ "implement": true
623
627
  }
624
628
  }
625
629
  ```
@@ -648,4 +652,4 @@ Related Documents:
648
652
  - [Usage Guide](./usage-guide.md)
649
653
  - [Directory Conventions](./directory-conventions.md)
650
654
  - [Architecture](./architecture.md)
651
- - [Usage Scenarios](./usage-scenarios.md)
655
+ - [Usage Scenarios](./usage-scenarios.md)
@@ -477,8 +477,10 @@ Session context itself is an information source · no need for users to organi
477
477
 
478
478
  | Mechanism | Design Intent |
479
479
  | --- | --- |
480
- | **Cursor `f2s-config-check.mdc`** | Rule-layer enforcement: "Read before skill body." |
481
- | **Claude `f2s-config-inject` PreToolUse** | Injects parsed results when calling **`f2s-*` Skill**; **missing file / broken JSON / hook exception** still outputs a note with default semantics, no silent failure. |
480
+ | **Cursor `f2s-config-check.mdc`** | Rule-layer enforcement: "Read before skill body"; Cursor hooks are used for update checks only, not automatic config reads. |
481
+ | **Claude `f2s-config-session` SessionStart** | Injects one config summary when the conversation starts, reducing the chance that the setting is forgotten. |
482
+ | **Claude `f2s-config-inject` PreToolUse** | Only guards **`f2s-*` Skill** calls by reminding the agent that the first skill-body action must be Read; it no longer repeatedly injects the full config. |
483
+ | **Codex `AGENTS.md` / `.codex/topics/f2s-config-check.md`** | Text-layer enforcement: "Read before skill body"; Codex hooks are used for update checks only, not automatic config reads. |
482
484
  | **Codex `AGENTS.md` + `renderProjectConfigBlock`** | Top-level **Read** hard constraint + **init snapshot table** (if inconsistent with disk, Read takes precedence). |
483
485
  | **Knowledge base `config-precheck` topic** | When routing hits, provides only **summary** and a pointer to the Codex full text, **not** a substitute for Read JSON. |
484
486
 
@@ -562,8 +564,9 @@ flow2spec.config.json
562
564
  switchAgentVerification: false → writer-side self-verify, daily use
563
565
  switchAgentVerification: true → cross-verification, high-confidence critical scenarios
564
566
 
565
- changeTracking.feat/fix/implement: false no task checklist created
566
- changeTracking.feat/fix/implement: true automatic task checklist creation when corresponding skills run, supporting cross-session continuation
567
+ changeTracking.feat: true f2s-kb-feat creates a task checklist by default
568
+ changeTracking.fix: false f2s-kb-fix does not create a task checklist by default
569
+ changeTracking.implement: true → implement-tech-design creates a task checklist by default
567
570
 
568
571
  Three orthogonal dimensions · each skill can further refine and override global config
569
572
  ```
@@ -615,4 +618,4 @@ Best suited when: has scale · long-term iteration · multi-tool or multi-person
615
618
  - [Usage Guide](./usage-guide.md)
616
619
  - [Commands Reference](./commands-reference.md)
617
620
  - [Architecture](./architecture.md)
618
- - [Usage Scenarios](./usage-scenarios.md)
621
+ - [Usage Scenarios](./usage-scenarios.md)
@@ -65,6 +65,10 @@ Type meanings:
65
65
  | `config` | Configuration items, switches, defaults, initialization parameters |
66
66
  | `policy` | Process, rule, constraint, gate, prohibition, agent orchestration, skill step |
67
67
 
68
+ ## Topic Granularity
69
+
70
+ A topic is a routing summary plus key boundaries; details belong in `stock-docs/`. Consider splitting into a main topic plus independently matchable sub-topics when its stock-doc exceeds 300-500 lines, matcher `includeAny` exceeds 12 terms, or the body spans more than 3 unrelated responsibility areas.
71
+
68
72
  ---
69
73
 
70
74
  ## Related Documents
@@ -27,9 +27,9 @@ Before executing any **`f2s-*` skill**, the Agent needs to obtain the actual val
27
27
 
28
28
  | Client | `init` Output & Behavior | Description |
29
29
  | --- | --- | --- |
30
- | **Cursor** | `.cursor/rules/f2s-config-check.mdc` (`alwaysApply`) | Rule requires: **Read(`flow2spec.config.json`)** before entering skill body. |
31
- | **Claude Code** | `.claude/hooks/f2s-config-inject.js` + `.claude/settings.json` (PreToolUse, `Skill` matching) | Injects a config summary when invoking **`f2s-*` Skill**; when **file is missing, JSON is invalid, or hook throws an unexpected exception**, it also injects a **notice + default semantics consistent with "file not found"** to avoid silent failure; it is still recommended to **Read** for confirmation when in doubt or after config changes. |
32
- | **Codex** | `.codex/AGENTS.md` top-level mandatory step + `{{FLOW2SPEC_PROJECT_CONFIG}}` expansion table | **Read** is a hard requirement; the config table is a **snapshot from the last `flow2spec init`** when it differs from disk, **Read** takes precedence. The adjacent **`.codex/topics/f2s-config-check.md`** shares its origin with the Cursor rule (including the **changeTracking** detail table); open it **as needed** — it does not need to be grouped with the three "topic long-form" examples as required reading. |
30
+ | **Cursor** | `.cursor/rules/f2s-config-check.mdc` (`alwaysApply`) | Config reading remains rule-based: **Read(`flow2spec.config.json`)** before entering skill body. Cursor hooks are used for update checks only, not automatic config reads. |
31
+ | **Claude Code** | `.claude/hooks/f2s-config-session.js` + `.claude/hooks/f2s-config-inject.js` + `.claude/settings.json` | `SessionStart` injects one config summary; `PreToolUse` only guards **`f2s-*` Skill** calls by reminding the agent that the first skill-body action must be **Read**. Neither replaces the disk read. |
32
+ | **Codex** | root `AGENTS.md` mandatory step + `.codex/topics/f2s-config-check.md` + `{{FLOW2SPEC_PROJECT_CONFIG}}` expansion table | Config reading remains rule-based: **Read** is a hard requirement; the config table is a **snapshot from the last `flow2spec init`** and disk Read takes precedence. Codex hooks are used for update checks only, not automatic config reads. |
33
33
  | **Knowledge Base (optional)** | When `.Knowledge/manifest-routing` hits **`config-precheck`** | `.Knowledge/topics/f2s-config-precheck.md` is a **routing summary** that links to the Codex long-form article; Flow2Spec does **not** maintain a second full copy in `.Knowledge`, nor does it replace a `Read` of the JSON. |
34
34
 
35
35
  For field semantics and default value rules, see [Commands Reference § 6) Sub-Agent Configuration](./commands-reference.md). For the design perspective, see [Design Principles § 4.5.1](./design-principles.md).
@@ -110,6 +110,14 @@ f2s-kb-migrate (Legacy V1: old knowledge base) → f2s-kb-upgrade
110
110
  f2s-kb-upgrade (Current V2+: already has .Knowledge; includes npm v3.x projects, etc.; see skill step 0)
111
111
  ```
112
112
 
113
+ In interactive terminals, the Flow2Spec CLI checks the latest npm version with a cache when running `flow2spec version` / `flow2spec init`. If a newer version exists, it prompts you to run `flow2spec update`, then execute `f2s-kb-upgrade` in the Agent conversation to align the project knowledge templates, manifest/matchers, and agent config roots. Failed update checks are skipped silently and do not affect the current command; checks are disabled in `CI`, non-TTY sessions, or when `FLOW2SPEC_SKIP_UPDATE_CHECK=1` is set.
114
+
115
+ After `flow2spec init codex`, Codex projects include `.codex/hooks.json` and `.codex/hooks/f2s-update-check.js`. The hook runs on Codex `SessionStart` for `startup|resume` and checks the knowledge-base version automatically. When the hook is first generated or changed, trust it through `/hooks` in Codex. Set `updateCheck.enabled=false` in `flow2spec.config.json` to skip the check.
116
+
117
+ After `flow2spec init cursor`, Cursor projects include `.cursor/hooks.json` and `.cursor/hooks/f2s-update-check.js`. The hook runs on Cursor `sessionStart` and injects upgrade reminders through `additional_context`. Set `updateCheck.enabled=false` in `flow2spec.config.json` to skip the check.
118
+
119
+ After `flow2spec init claude`, Claude projects include `.claude/settings.json` and `.claude/hooks/f2s-update-check.js`. All three integrations now use a single SessionStart hook. The script injects an agent-instruction notice through `additional_context`, requiring the agent to relay the message verbatim to the user. The notice format is: "Current project `<project>` knowledge-base version v<current>, lower than latest package version v<latest>. Run the f2s-kb-upgrade skill to align templates and routing." If today's cache still flags a needed upgrade, every new session re-injects the reminder; after a successful upgrade, `f2s-kb-upgrade` clears `.Knowledge/update-check.json` so stale reminders disappear.
120
+
113
121
  ---
114
122
 
115
123
  ## 4. Agent Execution Configuration
@@ -154,4 +162,4 @@ Skills are triggered by matching `name` and `description`. Files are located und
154
162
  - [Commands Reference](./commands-reference.md)
155
163
  - [Directory Conventions](./directory-conventions.md)
156
164
  - [Architecture](./architecture.md)
157
- - [Usage Scenarios](./usage-scenarios.md)
165
+ - [Usage Scenarios](./usage-scenarios.md)
@@ -4,7 +4,7 @@
4
4
 
5
5
  The following examples revolve around the same e-commerce project, covering the full pipeline from requirements clarification through post-launch maintenance.
6
6
 
7
- **Prerequisite**: The project has executed `flow2spec init`, and `flow2spec.config.json` uses the default configuration (`subAgent: false`). `f2s-*` skills do not modify the configuration root `rules/` or `skills/` files.
7
+ **Prerequisite**: The project has executed `flow2spec init`, and `flow2spec.config.json` uses the default configuration (`subAgent: false`; `changeTracking.feat/implement: true`, `changeTracking.fix: false`). `f2s-*` skills do not modify the configuration root `rules/` or `skills/` files.
8
8
 
9
9
  ---
10
10
 
@@ -193,4 +193,4 @@ The following examples revolve around the same e-commerce project, covering the
193
193
  - [Usage Guide](./usage-guide.md)
194
194
  - [Commands Reference](./commands-reference.md)
195
195
  - [Directory Conventions](./directory-conventions.md)
196
- - [Architecture](./architecture.md)
196
+ - [Architecture](./architecture.md)
@@ -138,9 +138,9 @@ Flow2Spec 通过项目根 `flow2spec.config.json` 的 `subAgent`、`switchAgentV
138
138
  ```json
139
139
  {
140
140
  "changeTracking": {
141
- "feat": false,
141
+ "feat": true,
142
142
  "fix": false,
143
- "implement": false
143
+ "implement": true
144
144
  }
145
145
  }
146
146
  ```
@@ -4,7 +4,7 @@
4
4
 
5
5
  以下示例围绕同一个电商项目展开,贯穿从需求澄清到上线后维护的完整流程。
6
6
 
7
- **前提**:项目已执行 `flow2spec init`,`flow2spec.config.json` 使用默认配置(`subAgent: false`)。`f2s-*` 技能不改动配置根 `rules/`、`skills/` 文件。
7
+ **前提**:项目已执行 `flow2spec init`,`flow2spec.config.json` 使用默认配置(`subAgent: false`;`changeTracking.feat/implement: true`,`changeTracking.fix: false`)。`f2s-*` 技能不改动配置根 `rules/`、`skills/` 文件。
8
8
 
9
9
  ---
10
10
 
@@ -30,9 +30,9 @@ flow2spec init [cursor|claude|codex ...] --reset-knowledge
30
30
 
31
31
  | 端 | `init` 落盘与行为 | 说明 |
32
32
  | --------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
33
- | **Cursor** | `.cursor/rules/f2s-config-check.mdc`(`alwaysApply`) | 规则要求:技能正文前先 **Read(`flow2spec.config.json`)**。 |
34
- | **Claude Code** | `.claude/hooks/f2s-config-inject.js` + `.claude/settings.json`(PreToolUse,`Skill` 匹配) | 在调用 **`f2s-*` Skill** 时注入配置摘要;**文件缺失、JSON 无效或 hook 未预期异常**时也会注入**说明 + 与「文件不存在」一致的默认语义**,避免静默;仍建议在存疑或刚改过配置时 **Read** 核对。 |
35
- | **Codex** | `.codex/AGENTS.md` 顶部强制步骤 + `{{FLOW2SPEC_PROJECT_CONFIG}}` 展开表 | **Read** 为硬要求;配置表为 **最近一次 `flow2spec init` 的快照**,与磁盘不一致时以 **Read** 为准。同目录 **`.codex/topics/f2s-config-check.md`** Cursor 规则同源(含 **changeTracking** 细表),**按需**打开即可,不必与「专题长文」三条示例并列必读。 |
33
+ | **Cursor** | `.cursor/rules/f2s-config-check.mdc`(`alwaysApply`) | 配置读取走文本约束:技能正文前先 **Read(`flow2spec.config.json`)**;Cursor hook 仅用于版本更新检测,不自动读取配置。 |
34
+ | **Claude Code** | `.claude/hooks/f2s-config-session.js` + `.claude/hooks/f2s-config-inject.js` + `.claude/settings.json` | `SessionStart` 仅注入一次配置摘要;`PreToolUse` 仅在调用 **`f2s-*` Skill** 时做守门提示,提醒首步必须 **Read**。两者都不替代磁盘 Read。 |
35
+ | **Codex** | 根 `AGENTS.md` 顶部强制步骤 + `.codex/topics/f2s-config-check.md` + `{{FLOW2SPEC_PROJECT_CONFIG}}` 展开表 | 配置读取走文本约束:**Read** 为硬要求;配置表为 **最近一次 `flow2spec init` 的快照**,与磁盘不一致时以 **Read** 为准。Codex hook 仅用于版本更新检测,不自动读取配置。 |
36
36
  | **知识库(可选)** | `.Knowledge/manifest-routing` 命中 **`config-precheck`** 时 | `.Knowledge/topics/f2s-config-precheck.md` 为**路由摘要**,链向 Codex 长文;**不**在 `.Knowledge` 再维护第二份全文,也**不**替代 Read JSON。 |
37
37
 
38
38
 
@@ -114,6 +114,14 @@ f2s-kb-migrate(流程 V1:旧库)→ f2s-kb-upgrade
114
114
  f2s-kb-upgrade(流程现行库 V2+:已有 .Knowledge;含 npm v3.x 等,见技能步骤 0)
115
115
  ```
116
116
 
117
+ Flow2Spec CLI 在交互式执行 `flow2spec version` / `flow2spec init` 时会按缓存检查 npm 最新版本;若发现新版本,会提示先执行 `flow2spec update`,随后在 Agent 对话中执行 `f2s-kb-upgrade`,用于对齐项目知识库模板、manifest/matchers 与配置根产物。更新检查失败会静默跳过,不影响当前命令;`CI`、非 TTY 或设置 `FLOW2SPEC_SKIP_UPDATE_CHECK=1` 时不检查。
118
+
119
+ Codex 项目执行 `flow2spec init codex` 后会写入 `.codex/hooks.json` 与 `.codex/hooks/f2s-update-check.js`,在 Codex `SessionStart` 的 `startup|resume` 事件自动检查知识库版本;首次生成或 hook 内容变化后,需要在 Codex 中通过 `/hooks` 信任该项目 hook。`flow2spec.config.json` 中 `updateCheck.enabled=false` 时跳过检查。
120
+
121
+ Cursor 项目执行 `flow2spec init cursor` 后会写入 `.cursor/hooks.json` 与 `.cursor/hooks/f2s-update-check.js`,在 Cursor `sessionStart` 自动检查知识库版本;脚本通过 `additional_context` 把升级提示注入会话。`flow2spec.config.json` 中 `updateCheck.enabled=false` 时跳过检查。
122
+
123
+ Claude 项目执行 `flow2spec init claude` 后会写入 `.claude/settings.json` 与 `.claude/hooks/f2s-update-check.js`,在 Claude `SessionStart` 自动检查知识库版本——三端均为单脚本架构。脚本通过 `additional_context` 注入命令式升级提示(agent-instruction 文案要求 agent 必须原文转告用户),格式为:"当前项目「<项目名>」知识库版本 v<当前版本>,低于最新包版本 v<最新版本>。可执行 f2s-kb-upgrade skill 对齐模板与路由。"若当天缓存仍标记需升级,新会话每次都会重新注入提示;升级成功后 `f2s-kb-upgrade` 会清理 `.Knowledge/update-check.json`,避免旧提示残留。
124
+
117
125
  ---
118
126
 
119
127
  ## 四、Agent 执行配置
@@ -159,4 +167,3 @@ f2s-kb-upgrade(流程现行库 V2+:已有 .Knowledge;含 npm v3.x 等,
159
167
  - [目录与路径约定](./目录与路径约定.md)
160
168
  - [体系与原理](./体系与原理.md)
161
169
  - [使用案例-模拟对话](./使用案例-模拟对话.md)
162
-
@@ -15,7 +15,7 @@
15
15
  | `/f2s-req-clarify` | 需求澄清,多轮问答明确需求边界 | 需求与方案 |
16
16
  | `/f2s-req-backend` | 基于澄清结果生成后端技术方案文档 | 需求与方案 |
17
17
  | `/f2s-req-plan` | 按技术方案拆任务清单,支持并行实现 (不依赖 `changeTracking.*` 配置) | 需求与方案 |
18
- | `/f2s-git-commit` | 提交代码,自动检查知识库覆盖情况 | 提交 |
18
+ | `/f2s-git-commit` | 提交代码,默认检查知识库覆盖;说“快捷提交”时跳过覆盖检查 | 提交 |
19
19
  | `/f2s-kb-feat` | 新增能力,补全实现 + 同步知识库 | 知识库维护 |
20
20
  | `/f2s-kb-fix` | 修复 BUG + 自动同步知识库 | 知识库维护 |
21
21
  | `/f2s-kb-sync` | 将会话中已实现能力沉淀回知识库 | 知识库维护 |
@@ -337,14 +337,15 @@
337
337
 
338
338
  ### `f2s-git-commit`
339
339
 
340
- **作用**:代码写完后执行 Git 提交。自动检查变更文件、比对知识库覆盖情况,未入库的能力会提示用户处理,确认提交信息后执行 commit。
340
+ **作用**:代码写完后执行 Git 提交。默认自动检查变更文件、比对知识库覆盖情况,未入库的能力会提示用户处理;用户明确说“快捷提交”时跳过知识库覆盖检查。提交前会展示提交信息首行,然后直接执行 commit。
341
341
 
342
- **工作原理**:在 `git commit` 之上叠加「知识库覆盖门控」——先通过 `git diff` 推断本次变更涉及的功能模块,再与 `.Knowledge/topics/` 和 `stock-docs/` 交叉比对,判断变更能力是否已有知识库记录。未覆盖时阻断并提示三选(补录/跳过/取消),避免「代码有了但知识库不知道」的静默漂移。提交信息强制 emoji + Conventional Commits 格式,保证 git log 的机读一致性。
342
+ **工作原理**:在 `git commit` 之上叠加「知识库覆盖门控」——先通过 `git diff` 推断本次变更涉及的功能模块,再与 `.Knowledge/topics/` 和 `stock-docs/` 交叉比对,判断变更能力是否已有知识库记录。未覆盖时阻断并提示三选(补录/跳过/取消),避免「代码有了但知识库不知道」的静默漂移。快捷提交模式只跳过这层覆盖门控,不跳过冲突检查、提交信息展示、精确 `git add`、git hooks。提交信息强制 emoji + Conventional Commits 格式,保证 git log 的机读一致性。
343
343
 
344
344
  **使用场景**:
345
345
 
346
346
  - 每次功能实现或 Bug 修复后提交代码
347
347
  - 希望在提交时得到知识库覆盖情况的提醒
348
+ - 已明确不需要本次覆盖检查,只想快捷提交
348
349
  - 需要 AI 帮助生成有意义的提交信息
349
350
 
350
351
  **关联关系**:
@@ -356,7 +357,7 @@
356
357
  **执行流程**:
357
358
 
358
359
  1. `git status --short` + `git diff HEAD` 区分 staged / unstaged / untracked 三类文件;发现 merge conflict 标记立即终止
359
- 2. 对比 `.Knowledge/topics/` 与 `stock-docs/`,判断本次变更能力是否已入库;`.Knowledge` 不存在时跳过并提示
360
+ 2. 默认对比 `.Knowledge/topics/` 与 `stock-docs/`,判断本次变更能力是否已入库;`.Knowledge` 不存在时跳过并提示;用户说“快捷提交”时跳过本步
360
361
  3. 未覆盖时提示用户选择:A) 先补录再提交 / B) 先提交稍后补录 / C) 取消
361
362
  4. 基于 `git diff` 实际内容生成提交信息草稿,等待用户确认或修改
362
363
  5. `git add <具体文件>` + `git commit`;hook 失败则提示修复,不跳过
@@ -367,7 +368,7 @@
367
368
  - 禁止 `git add -A` / `git add .`,只 add 已确认的变更文件
368
369
  - 禁止 `--no-verify`,hook 失败须修复后重试
369
370
  - 禁止自动 push
370
- - 提交信息必须经用户确认,不可静默提交
371
+ - 提交前必须展示提交信息首行;不要求用户额外确认 commit
371
372
 
372
373
  **子 agent 调用**:无(全程交互确认,主 agent 内完成)
373
374
 
@@ -585,6 +586,9 @@
585
586
 
586
587
  - flow2spec 包版本升级后,升级项目知识库模板
587
588
  - 旧项目升级到最新结构
589
+ - CLI 在交互式 `flow2spec version` / `flow2spec init` 中发现 npm 有新版本后,会提示先 `flow2spec update`,再在 Agent 对话中执行本技能
590
+ - Cursor 通过 `.cursor/hooks.json` 在 `sessionStart` 自动检测到知识库版本落后后,会提示执行本技能
591
+ - Codex 通过 `.codex/hooks.json` 在 `SessionStart` 自动检测到知识库版本落后后,会提示执行本技能(首次或变更后需在 Codex `/hooks` 中信任)
588
592
 
589
593
  **关联关系**:
590
594
 
@@ -689,11 +693,11 @@
689
693
 
690
694
  ## 6) 子 Agent 配置说明
691
695
 
692
- 通过项目根 `flow2spec.config.json` 控制(字段默认均为 `false`)。
696
+ 通过项目根 `flow2spec.config.json` 控制。默认值:`subAgent=false`、`switchAgentVerification=false`、`changeTracking.feat=true`、`changeTracking.fix=false`、`changeTracking.implement=true`。
693
697
 
694
698
  ### 多端如何「看到」配置(与下文字段表配合)
695
699
 
696
- `subAgent` 等写在 **磁盘 JSON**;各产品不保证自动打开文件,故用 **Cursor 规则 / Claude hook / Codex AGENTS 快照表 / 知识库 `config-precheck` 摘要** 多层提示,**权威仍为 Read(`flow2spec.config.json`)**(设计意图见 [设计说明 § 四、5.1](./设计说明.md),演讲口径见 [Flow2Spec-演讲稿 Slide 13b](./Flow2Spec-演讲稿.md))。**完整路径与表格只维护一处**:[使用说明 § 一、`f2s-`* 与 `flow2spec.config.json](./使用说明.md)`。
700
+ `subAgent` 等写在 **磁盘 JSON**;各产品不保证自动打开文件,故用 **Cursor 规则 / Claude SessionStart 摘要 + PreToolUse 守门 / Codex AGENTS 快照表 / 知识库 `config-precheck` 摘要** 多层提示,**权威仍为 Read(`flow2spec.config.json`)**(设计意图见 [设计说明 § 四、5.1](./设计说明.md),演讲口径见 [Flow2Spec-演讲稿 Slide 13b](./Flow2Spec-演讲稿.md))。**完整路径与表格只维护一处**:[使用说明 § 一、`f2s-`* 与 `flow2spec.config.json](./使用说明.md)`。
697
701
 
698
702
  ### `subAgent` 字段
699
703
 
@@ -720,9 +724,9 @@
720
724
  ```json
721
725
  {
722
726
  "changeTracking": {
723
- "feat": false,
727
+ "feat": true,
724
728
  "fix": false,
725
- "implement": false
729
+ "implement": true
726
730
  }
727
731
  }
728
732
  ```
@@ -755,4 +759,3 @@
755
759
  - [目录与路径约定](./目录与路径约定.md)
756
760
  - [体系与原理](./体系与原理.md)
757
761
  - [使用案例-模拟对话](./使用案例-模拟对话.md)
758
-
@@ -65,6 +65,10 @@ Memory Coding 四环总览见 [体系与原理 §1](./体系与原理.md)。
65
65
  | `config` | 配置项、开关、默认值、初始化参数 |
66
66
  | `policy` | 流程、规则、约束、门禁、禁止项、agent 编排、技能步骤 |
67
67
 
68
+ ## 主题粒度
69
+
70
+ topic 是路由摘要与关键边界,细节放在 `stock-docs/`。若对应 stock-doc 超过 300–500 行、matcher `includeAny` 超过 12 个,或正文出现 3 个以上不相干职责域,建议拆成主 topic + 可独立命中的子 topic。
71
+
68
72
  ---
69
73
 
70
74
  ## 相关文档