@double-codeing/flow2spec 3.1.0 → 3.1.1
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.
- package/README.md +2 -2
- package/cli.js +122 -11
- package/docs/en/architecture.md +2 -2
- package/docs/en/commands-reference.md +14 -10
- package/docs/en/design-principles.md +8 -5
- package/docs/en/usage-guide.md +10 -4
- package/docs/en/usage-scenarios.md +2 -2
- package/docs//344/275/223/347/263/273/344/270/216/345/216/237/347/220/206.md +2 -2
- 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
- package/docs//344/275/277/347/224/250/350/257/264/346/230/216.md +9 -4
- package/docs//345/221/275/344/273/244/350/257/264/346/230/216.md +13 -10
- package/docs//350/256/276/350/256/241/350/257/264/346/230/216.md +84 -53
- package/lib/claudeSettingsAdapter.js +99 -30
- package/lib/flow2specConfig.js +32 -6
- package/lib/init.js +148 -3
- package/package.json +1 -1
- package/templates/AGENTS.codex-stub.md +2 -0
- package/templates/AGENTS.md +13 -0
- package/templates/flow2spec.config.json +5 -2
- package/templates/hooks/f2s-config-inject.js +9 -147
- package/templates/hooks/f2s-config-session.js +95 -0
- package/templates/hooks/f2s-update-check.js +141 -0
- package/templates/knowledge/topics/f2s-config-precheck.md +2 -2
- package/templates/rules/f2s-config-check.mdc +3 -1
- package/templates/rules/f2s-flow2spec-unified-entry.mdc +13 -0
- package/templates/skills/f2s-git-commit/SKILL.md +21 -5
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 {
|
|
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
|
|
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
|
|
55
|
-
|
|
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 =
|
|
182
|
+
const latest = execFileSync("npm", ["view", pkg.name, "version"], {
|
|
79
183
|
encoding: "utf8",
|
|
80
184
|
}).trim();
|
|
81
|
-
if (latest
|
|
82
|
-
console.log(
|
|
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
|
-
|
|
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
|
|
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);
|
package/docs/en/architecture.md
CHANGED
|
@@ -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
|
|
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.
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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":
|
|
624
|
+
"feat": true,
|
|
621
625
|
"fix": false,
|
|
622
|
-
"implement":
|
|
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-
|
|
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
|
|
566
|
-
changeTracking.
|
|
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)
|
package/docs/en/usage-guide.md
CHANGED
|
@@ -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`) |
|
|
31
|
-
| **Claude Code** | `.claude/hooks/f2s-config-inject.js` + `.claude/settings.json`
|
|
32
|
-
| **Codex** |
|
|
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,12 @@ 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
|
+
|
|
113
119
|
---
|
|
114
120
|
|
|
115
121
|
## 4. Agent Execution Configuration
|
|
@@ -154,4 +160,4 @@ Skills are triggered by matching `name` and `description`. Files are located und
|
|
|
154
160
|
- [Commands Reference](./commands-reference.md)
|
|
155
161
|
- [Directory Conventions](./directory-conventions.md)
|
|
156
162
|
- [Architecture](./architecture.md)
|
|
157
|
-
- [Usage Scenarios](./usage-scenarios.md)
|
|
163
|
+
- [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)
|
|
@@ -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`) |
|
|
34
|
-
| **Claude Code** | `.claude/hooks/f2s-config-inject.js` + `.claude/settings.json
|
|
35
|
-
| **Codex** |
|
|
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,12 @@ 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
|
+
|
|
117
123
|
---
|
|
118
124
|
|
|
119
125
|
## 四、Agent 执行配置
|
|
@@ -159,4 +165,3 @@ f2s-kb-upgrade(流程现行库 V2+:已有 .Knowledge;含 npm v3.x 等,
|
|
|
159
165
|
- [目录与路径约定](./目录与路径约定.md)
|
|
160
166
|
- [体系与原理](./体系与原理.md)
|
|
161
167
|
- [使用案例-模拟对话](./使用案例-模拟对话.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
|
|
340
|
+
**作用**:代码写完后执行 Git 提交。默认自动检查变更文件、比对知识库覆盖情况,未入库的能力会提示用户处理;用户明确说“快捷提交”时跳过知识库覆盖检查。提交前会展示提交信息首行,然后直接执行 commit。
|
|
341
341
|
|
|
342
|
-
**工作原理**:在 `git commit` 之上叠加「知识库覆盖门控」——先通过 `git diff` 推断本次变更涉及的功能模块,再与 `.Knowledge/topics/` 和 `stock-docs/`
|
|
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.
|
|
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`
|
|
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
|
|
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":
|
|
727
|
+
"feat": true,
|
|
724
728
|
"fix": false,
|
|
725
|
-
"implement":
|
|
729
|
+
"implement": true
|
|
726
730
|
}
|
|
727
731
|
}
|
|
728
732
|
```
|
|
@@ -755,4 +759,3 @@
|
|
|
755
759
|
- [目录与路径约定](./目录与路径约定.md)
|
|
756
760
|
- [体系与原理](./体系与原理.md)
|
|
757
761
|
- [使用案例-模拟对话](./使用案例-模拟对话.md)
|
|
758
|
-
|