@double-codeing/flow2spec 3.0.8 → 3.0.11
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.en.md +114 -0
- package/README.md +78 -80
- package/cli.js +36 -1
- package/docs/README-/345/221/275/344/273/244/350/257/264/346/230/216.md +227 -71
- package/docs/architecture.en.md +122 -0
- package/docs/commands-reference.en.md +651 -0
- package/docs/design-principles.en.md +592 -0
- package/docs/directory-conventions.en.md +49 -0
- package/docs/usage-guide.en.md +165 -0
- package/docs/usage-scenarios.en.md +222 -0
- package/package.json +1 -1
- package/templates/knowledge/manifest-routing.json +3 -0
- package/templates/rules/f2s-task.mdc +8 -0
- package/templates/skills/f2s-ctx-build/SKILL.md +1 -0
- package/templates/skills/f2s-req-plan/SKILL.md +101 -58
package/README.en.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Flow2Spec — Let AI Always Know What You're Doing
|
|
2
|
+
|
|
3
|
+
> Cures the "amnesia" of Cursor / Claude Code — with one `init` command, AI
|
|
4
|
+
> remembers project context across sessions. No more re-explaining every time.
|
|
5
|
+
>
|
|
6
|
+
> 🌐 **[中文](./README.md)** · 中 / EN
|
|
7
|
+
|
|
8
|
+
🎬 **[Live Demo (English)](https://lands-1203.github.io/Flow2Spec/en/)** | **[中文演示](https://lands-1203.github.io/Flow2Spec/)** (13-slide HTML PPT, `←` `→` to navigate, `S` for presenter mode)
|
|
9
|
+
|
|
10
|
+
🔧 **Quick start**:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npx @double-codeing/flow2spec@latest init
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Before / After
|
|
19
|
+
|
|
20
|
+
The exact same request, two conversations:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
> Update the batch re-scoring of the review template library
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Without Flow2Spec**:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
AI: Which module has this table?
|
|
30
|
+
AI: Is batchReScore sync or async?
|
|
31
|
+
AI: Is there a lock? What's the idempotency key?
|
|
32
|
+
AI: What's the response format? What's the error code?
|
|
33
|
+
AI: (Digging through 416 APIs, 796 files, 4.7 MB of source code…)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Repeated introductions · Repeated code searches · Repeated mistakes
|
|
37
|
+
|
|
38
|
+
**With Flow2Spec**:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
[matcher hit] m-product-review-template-library
|
|
42
|
+
[loading deps] 4 topics · ~300 lines
|
|
43
|
+
AI: Known — fire-and-forget
|
|
44
|
+
Redis lock smp:product-review:template-library:batch-rescore:lock (TTL 10 min)
|
|
45
|
+
Max 100 items per batch · error code 101
|
|
46
|
+
AI: Starting implementation, 3 files affected.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
4.7 MB → 300 lines · Pinpoint accuracy in seconds
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## What Flow2Spec Does (3 Things)
|
|
54
|
+
|
|
55
|
+
**① Remembers project context across devices and sessions**
|
|
56
|
+
`.Knowledge/` structured knowledge base: routing manifest (`manifest-routing.json`) + keyword indices (matchers) + topic shards (topics). AI only loads what's relevant.
|
|
57
|
+
|
|
58
|
+
**② Routing manifest means AI doesn't dig through your repo**
|
|
59
|
+
Each task hits 1–4 topics, ~300 lines. Business constraints — Redis lock keys, error codes, batch limits — are all in the topics. AI doesn't have to guess from source code.
|
|
60
|
+
|
|
61
|
+
**③ f2s-* skills update knowledge as you code**
|
|
62
|
+
`/f2s-kb-feat` writes topics while writing features, `/f2s-kb-fix` corrects topics while fixing bugs, `/f2s-git-commit` checks topic coverage before committing. Changing code == updating knowledge. No separate "documentation maintenance."
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Getting Started
|
|
67
|
+
|
|
68
|
+
**Minimum viable setup is an empty skeleton.**
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx @double-codeing/flow2spec@latest init
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
1 minute generates the directory structure + routing config. Empty, ready to use. **Next requirement hits whichever area → you document that area.** No upfront investment needed.
|
|
75
|
+
|
|
76
|
+
Real data from a production repo running for 3 months:
|
|
77
|
+
|
|
78
|
+
| Metric | Value |
|
|
79
|
+
|---|---|
|
|
80
|
+
| Public APIs | 416 |
|
|
81
|
+
| Source code | 796 files / 4.7 MB / ~100K lines |
|
|
82
|
+
| Flow2Spec per-task load | **≈ 300 lines** (99% noise removed) |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## When NOT to Use
|
|
87
|
+
|
|
88
|
+
- **One-off scripts** — throwaway code is faster with a few Markdown files for AI context
|
|
89
|
+
- **Solo small projects** — a single CLAUDE.md is enough; routing overhead > benefits
|
|
90
|
+
- **Team won't maintain .Knowledge/** — tools can't replace discipline
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Documentation
|
|
95
|
+
|
|
96
|
+
### English
|
|
97
|
+
- [Usage Guide](./docs/usage-guide.en.md) — skill chains, config details
|
|
98
|
+
- [Commands Reference](./docs/commands-reference.en.md) — all f2s-* command reference
|
|
99
|
+
- [Directory Conventions](./docs/directory-conventions.en.md)
|
|
100
|
+
- [Architecture & Principles](./docs/architecture.en.md)
|
|
101
|
+
- [Usage Scenarios](./docs/usage-scenarios.en.md)
|
|
102
|
+
- [Design Principles](./docs/design-principles.en.md)
|
|
103
|
+
|
|
104
|
+
### 中文
|
|
105
|
+
- [使用说明](./docs/Flow2Spec使用说明.md)
|
|
106
|
+
- [命令说明](./docs/README-命令说明.md)
|
|
107
|
+
- [目录与路径约定](./docs/README-目录与路径约定.md)
|
|
108
|
+
- [体系与原理](./docs/README-体系与原理.md)
|
|
109
|
+
- [使用案例·模拟对话](./docs/Flow2Spec-使用案例-模拟对话.md)
|
|
110
|
+
- [设计说明](./docs/Flow2Spec-设计说明.md)
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT. Copyright © 2026 兰涛
|
package/README.md
CHANGED
|
@@ -1,117 +1,115 @@
|
|
|
1
|
-
# Flow2Spec
|
|
1
|
+
# Flow2Spec — 让 AI 一直知道你在做什么
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
集中管理项目知识,同时不破坏各工具原生的 rules/skills 加载机制。
|
|
9
|
-
|
|
10
|
-
> 🎬 **在线演示**:组内分享用的 13 页 HTML PPT(脱敏版)——**<https://lands-1203.github.io/Flow2Spec/>**
|
|
11
|
-
> `←` `→` 翻页,`S` 打开演讲者模式。源文件见 [presentations/flow2spec-intro-public/](./presentations/flow2spec-intro-public/)。
|
|
3
|
+
> 解决 Cursor / Claude Code 的「失忆症」——用一个命令初始化,让 AI
|
|
4
|
+
> 跨会话记住项目上下文,不用每轮重新交代。
|
|
5
|
+
>
|
|
6
|
+
> 🌐 **[English](./README.en.md)** · 中 / EN
|
|
12
7
|
|
|
13
|
-
|
|
8
|
+
🎬 **[在线演示(中文)](https://lands-1203.github.io/Flow2Spec/)** | **[English Demo](https://lands-1203.github.io/Flow2Spec/en/)**(13 页 HTML PPT,`←` `→` 翻页,`S` 演讲者模式)
|
|
14
9
|
|
|
15
|
-
|
|
10
|
+
🔧 **快速体验**:
|
|
16
11
|
|
|
17
12
|
```bash
|
|
18
13
|
npx @double-codeing/flow2spec@latest init
|
|
19
|
-
npx @double-codeing/flow2spec@latest init cursor claude codex
|
|
20
14
|
```
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
---
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
npm install -g @double-codeing/flow2spec@latest
|
|
26
|
-
```
|
|
18
|
+
## Before / After
|
|
27
19
|
|
|
28
|
-
|
|
20
|
+
同样一句话,两段对话:
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
| `.Knowledge/req-docs/` | 需求澄清与技术方案 |
|
|
34
|
-
| `.Knowledge/topics/` | 主题路由摘要 |
|
|
35
|
-
| `.Knowledge/template/` | 终稿与技术方案模板 |
|
|
36
|
-
| `.Knowledge/manifest-routing.json` + `matchers/` | 机器可读路由与关键词索引 |
|
|
37
|
-
| `配置根/rules/` + `配置根/skills/` | 各工具规则与技能入口 |
|
|
38
|
-
| `flow2spec.config.json` | 控制 `subAgent`、`switchAgentVerification`、`changeTracking`(各技能独立子项),默认均为 `false` |
|
|
22
|
+
```
|
|
23
|
+
> 改一下评价模板文案库的批量重评分
|
|
24
|
+
```
|
|
39
25
|
|
|
40
|
-
|
|
26
|
+
**没有 Flow2Spec**:
|
|
41
27
|
|
|
42
|
-
|
|
28
|
+
```
|
|
29
|
+
AI: 这个模块的表在哪?
|
|
30
|
+
AI: batchReScore 是同步还是异步?
|
|
31
|
+
AI: 有没有锁?幂等键是什么?
|
|
32
|
+
AI: 返回格式是什么?错误码是多少?
|
|
33
|
+
AI: (翻遍 416 个接口、796 份文件、4.7 MB 源码…)
|
|
34
|
+
```
|
|
35
|
+
反复介绍 · 反复翻代码 · 反复踩坑
|
|
43
36
|
|
|
44
|
-
|
|
37
|
+
**有 Flow2Spec**:
|
|
45
38
|
|
|
46
|
-
|
|
39
|
+
```
|
|
40
|
+
[matcher 命中] m-product-review-template-library
|
|
41
|
+
[加载依赖] 4 个 topic · 约 300 行
|
|
42
|
+
AI: 已知 — fire-and-forget
|
|
43
|
+
Redis 锁 smp:product-review:template-library:batch-rescore:lock(TTL 10 分钟)
|
|
44
|
+
单次最多 100 条 · 错误码 101
|
|
45
|
+
AI: 开始改,预计 3 处文件。
|
|
46
|
+
```
|
|
47
|
+
4.7 MB → 300 行 · 秒级定位到硬约束
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
---
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
>
|
|
52
|
-
> ```bash
|
|
53
|
-
> npm install -g @double-codeing/flow2spec@latest
|
|
54
|
-
> ```
|
|
55
|
-
>
|
|
56
|
-
> 其余场景以仓库内已初始化的规则与技能为准。
|
|
51
|
+
## Flow2Spec 做三件事
|
|
57
52
|
|
|
58
|
-
|
|
53
|
+
**① 跨设备会话记住项目上下文**
|
|
54
|
+
`.Knowledge/` 结构化知识库:路由清单(manifest-routing.json)+ 关键词索引(matchers)+ 主题分片(topics)。AI
|
|
55
|
+
启动时只读该读的。
|
|
59
56
|
|
|
60
|
-
|
|
57
|
+
**② 路由清单让 AI 不翻仓库,只拿该拿的**
|
|
58
|
+
每次需求命中 1~4 个 topic,约 300 行。业务的硬约束——锁的 key、错误码、上限——都在
|
|
59
|
+
topic 里,AI 不用从源码猜。
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
**③ f2s-* 技能改代码顺手更新知识**
|
|
62
|
+
`/f2s-kb-feat` 写功能时同步写 topic,`/f2s-kb-fix` 修 bug 时更正 topic,
|
|
63
|
+
`/f2s-git-commit` 提交前检查 topic 覆盖。改代码就是记知识,没有"单独维护文档"这件事。
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
| ------------------------------ | ----------------------------------------------------------------------------------- | --------------------------------- |
|
|
66
|
-
| 有 PRD,需澄清后出方案并落地 | `f2s-req-clarify` → `f2s-req-backend` → `f2s-implement-tech-design` → `f2s-kb-feat` | 澄清纪要 → 技术方案 → 实现+知识库 |
|
|
67
|
-
| 已有方案,需强制任务清单后实现 | `f2s-req-plan`
|
|
68
|
-
| 可确认任务清单与实现编排 |
|
|
65
|
+
---
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
## 上手成本
|
|
71
68
|
|
|
72
|
-
|
|
69
|
+
**最小可用集是一个空骨架。**
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
| 外部文档转知识库 | `f2s-doc-final` → `f2s-ctx-build` | 可检索 Markdown + 路由索引 |
|
|
78
|
-
| 存量代码/散稿补录 | `f2s-doc-add` 或 `f2s-kb-sync` | 自动提取能力 → 主题索引 |
|
|
71
|
+
```bash
|
|
72
|
+
npx @double-codeing/flow2spec@latest init
|
|
73
|
+
```
|
|
79
74
|
|
|
80
|
-
|
|
75
|
+
1 分钟生成目录结构 + 路由配置,空的,直接跑。**下次需求命中哪块,写哪块**,不提前建设。
|
|
81
76
|
|
|
82
|
-
|
|
77
|
+
真实仓库跑了三个月的数据:
|
|
83
78
|
|
|
84
|
-
|
|
|
85
|
-
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
| 解决合并冲突 | `f2s-kb-merge` |
|
|
79
|
+
| 指标 | 数值 |
|
|
80
|
+
|---|---|
|
|
81
|
+
| 对外接口数 | 416 |
|
|
82
|
+
| 源码体积 | 796 文件 / 4.7 MB / ~10 万行 |
|
|
83
|
+
| Flow2Spec 每次加载 | **≈ 300 行**(噪声切掉 99%) |
|
|
90
84
|
|
|
91
|
-
|
|
85
|
+
---
|
|
92
86
|
|
|
93
|
-
|
|
87
|
+
## 什么时候别用
|
|
94
88
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
| 模板对齐(包升级后同步) | `f2s-kb-upgrade` | 可重复执行 |
|
|
89
|
+
- **一次性脚本** — 写完就删的东西,直接丢几个 Markdown 给 AI 更快
|
|
90
|
+
- **单人小项目** — 一份 CLAUDE.md 就够,路由和分片的开销大于收益
|
|
91
|
+
- **团队不愿同步 .Knowledge/** — 工具不能替代纪律
|
|
99
92
|
|
|
100
93
|
---
|
|
101
94
|
|
|
102
|
-
##
|
|
95
|
+
## 详细文档
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
97
|
+
### 中文
|
|
98
|
+
- [使用说明](./docs/Flow2Spec使用说明.md) — 技能链、配置详解
|
|
99
|
+
- [命令说明](./docs/README-命令说明.md) — 所有 f2s-* 命令速查
|
|
100
|
+
- [目录与路径约定](./docs/README-目录与路径约定.md)
|
|
101
|
+
- [体系与原理](./docs/README-体系与原理.md)
|
|
102
|
+
- [使用案例·模拟对话](./docs/Flow2Spec-使用案例-模拟对话.md)
|
|
103
|
+
- [设计说明](./docs/Flow2Spec-设计说明.md)
|
|
107
104
|
|
|
108
|
-
|
|
105
|
+
### English
|
|
106
|
+
- [Usage Guide](./docs/usage-guide.en.md)
|
|
107
|
+
- [Commands Reference](./docs/commands-reference.en.md)
|
|
108
|
+
- [Directory Conventions](./docs/directory-conventions.en.md)
|
|
109
|
+
- [Architecture & Principles](./docs/architecture.en.md)
|
|
110
|
+
- [Usage Scenarios](./docs/usage-scenarios.en.md)
|
|
111
|
+
- [Design Principles](./docs/design-principles.en.md)
|
|
109
112
|
|
|
110
|
-
##
|
|
113
|
+
## 协议
|
|
111
114
|
|
|
112
|
-
|
|
113
|
-
- [README-命令说明](./docs/README-命令说明.md)
|
|
114
|
-
- [README-目录与路径约定](./docs/README-目录与路径约定.md)
|
|
115
|
-
- [README-体系与原理](./docs/README-体系与原理.md)
|
|
116
|
-
- [Flow2Spec-使用案例-模拟对话](./docs/Flow2Spec-使用案例-模拟对话.md)
|
|
117
|
-
- [Flow2Spec-设计说明](./docs/Flow2Spec-设计说明.md)
|
|
115
|
+
MIT. Copyright © 2026 兰涛
|
package/cli.js
CHANGED
|
@@ -12,6 +12,8 @@ const {
|
|
|
12
12
|
getMissingConfigFields,
|
|
13
13
|
} = require("./lib/flow2specConfig");
|
|
14
14
|
|
|
15
|
+
const { execSync } = require("child_process");
|
|
16
|
+
|
|
15
17
|
const args = process.argv.slice(2);
|
|
16
18
|
const sub = args[0];
|
|
17
19
|
|
|
@@ -19,12 +21,16 @@ const agentList = Object.entries(AGENTS)
|
|
|
19
21
|
.map(([id, { label }]) => `${id}(${label})`)
|
|
20
22
|
.join(", ");
|
|
21
23
|
|
|
24
|
+
const pkg = require("./package.json");
|
|
25
|
+
|
|
22
26
|
const help = `
|
|
23
|
-
Flow2Spec - 统一知识库工作流(AI 配置入口)
|
|
27
|
+
Flow2Spec - 统一知识库工作流(AI 配置入口) v${pkg.version}
|
|
24
28
|
|
|
25
29
|
用法:
|
|
26
30
|
flow2spec init [agent ...] [--reset-knowledge] [--yes] 在当前项目初始化:写入 .Knowledge 与所选 agent 入口
|
|
27
31
|
flow2spec config 打印项目根 ${CONFIG_FILENAME} 的解析结果(缺省值合并后)
|
|
32
|
+
flow2spec version 显示当前 flow2spec 版本
|
|
33
|
+
flow2spec update 更新 flow2spec 到最新版本
|
|
28
34
|
flow2spec --help 显示本说明
|
|
29
35
|
|
|
30
36
|
agent(可多个,空格分隔;省略时交互选择):
|
|
@@ -60,6 +66,35 @@ if (sub === "--help" || sub === "-h" || !sub) {
|
|
|
60
66
|
process.exit(0);
|
|
61
67
|
}
|
|
62
68
|
|
|
69
|
+
if (sub === "version" || sub === "--version" || sub === "-v") {
|
|
70
|
+
console.log(`flow2spec v${pkg.version}`);
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (sub === "update") {
|
|
75
|
+
console.log(`当前版本: v${pkg.version}`);
|
|
76
|
+
console.log("正在检查最新版本...");
|
|
77
|
+
try {
|
|
78
|
+
const latest = execSync(`npm view ${pkg.name} version`, {
|
|
79
|
+
encoding: "utf8",
|
|
80
|
+
}).trim();
|
|
81
|
+
if (latest === pkg.version) {
|
|
82
|
+
console.log(`已是最新版本 v${latest}`);
|
|
83
|
+
process.exit(0);
|
|
84
|
+
}
|
|
85
|
+
console.log(`发现新版本: v${latest}`);
|
|
86
|
+
console.log("正在更新...");
|
|
87
|
+
execSync(`npm install -g ${pkg.name}@latest`, {
|
|
88
|
+
stdio: "inherit",
|
|
89
|
+
});
|
|
90
|
+
console.log(`\n✓ 已更新到 v${latest}`);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
console.error("更新失败:", e.message || e);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
process.exit(0);
|
|
96
|
+
}
|
|
97
|
+
|
|
63
98
|
if (sub === "config") {
|
|
64
99
|
const cwd = process.cwd();
|
|
65
100
|
const abs = path.join(cwd, CONFIG_FILENAME);
|