@bicorne/task-flow 0.1.0
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/LICENSE +21 -0
- package/README.md +252 -0
- package/SKILL.md +250 -0
- package/assets/.harnessrc +10 -0
- package/assets/PHASE-task.json.example +50 -0
- package/assets/design.md +69 -0
- package/assets/hooks.json +15 -0
- package/assets/product-requirement.md +82 -0
- package/assets/schema.json +127 -0
- package/assets/tasks.md +26 -0
- package/dist/commands/analyze.d.ts +32 -0
- package/dist/commands/analyze.js +338 -0
- package/dist/commands/archive.d.ts +11 -0
- package/dist/commands/archive.js +53 -0
- package/dist/commands/design.d.ts +38 -0
- package/dist/commands/design.js +492 -0
- package/dist/commands/extract.d.ts +31 -0
- package/dist/commands/extract.js +477 -0
- package/dist/commands/init.d.ts +24 -0
- package/dist/commands/init.js +165 -0
- package/dist/commands/merge/index.d.ts +17 -0
- package/dist/commands/merge/index.js +322 -0
- package/dist/commands/merge/merger.d.ts +18 -0
- package/dist/commands/merge/merger.js +151 -0
- package/dist/commands/merge/types.d.ts +67 -0
- package/dist/commands/merge/types.js +6 -0
- package/dist/commands/merge/validators.d.ts +14 -0
- package/dist/commands/merge/validators.js +147 -0
- package/dist/commands/merge.d.ts +7 -0
- package/dist/commands/merge.js +15 -0
- package/dist/commands/start.d.ts +32 -0
- package/dist/commands/start.js +265 -0
- package/dist/commands/status.d.ts +15 -0
- package/dist/commands/status.js +143 -0
- package/dist/commands/sync.d.ts +11 -0
- package/dist/commands/sync.js +58 -0
- package/dist/commands/tasks-gen/doc-parser.d.ts +7 -0
- package/dist/commands/tasks-gen/doc-parser.js +259 -0
- package/dist/commands/tasks-gen/generators.d.ts +33 -0
- package/dist/commands/tasks-gen/generators.js +141 -0
- package/dist/commands/tasks-gen/index.d.ts +30 -0
- package/dist/commands/tasks-gen/index.js +345 -0
- package/dist/commands/tasks-gen/parsers.d.ts +29 -0
- package/dist/commands/tasks-gen/parsers.js +272 -0
- package/dist/commands/tasks-gen/templates.d.ts +8 -0
- package/dist/commands/tasks-gen/templates.js +37 -0
- package/dist/commands/tasks-gen/types.d.ts +71 -0
- package/dist/commands/tasks-gen/types.js +17 -0
- package/dist/commands/tasks-gen/validators.d.ts +14 -0
- package/dist/commands/tasks-gen/validators.js +54 -0
- package/dist/commands/tasks.d.ts +9 -0
- package/dist/commands/tasks.js +22 -0
- package/dist/commands/worktree.d.ts +28 -0
- package/dist/commands/worktree.js +275 -0
- package/dist/hooks/check-prd-exists.d.ts +20 -0
- package/dist/hooks/check-prd-exists.js +61 -0
- package/dist/hooks/check-worktree-conflict.d.ts +34 -0
- package/dist/hooks/check-worktree-conflict.js +107 -0
- package/dist/hooks/hook-runner/executor.d.ts +18 -0
- package/dist/hooks/hook-runner/executor.js +143 -0
- package/dist/hooks/hook-runner/index.d.ts +64 -0
- package/dist/hooks/hook-runner/index.js +220 -0
- package/dist/hooks/hook-runner/loader.d.ts +23 -0
- package/dist/hooks/hook-runner/loader.js +126 -0
- package/dist/hooks/hook-runner/types.d.ts +59 -0
- package/dist/hooks/hook-runner/types.js +6 -0
- package/dist/hooks/hook-runner.d.ts +9 -0
- package/dist/hooks/hook-runner.js +30 -0
- package/dist/hooks/phase-complete-detector.d.ts +35 -0
- package/dist/hooks/phase-complete-detector.js +203 -0
- package/dist/hooks/phase-gate-validator.d.ts +76 -0
- package/dist/hooks/phase-gate-validator.js +407 -0
- package/dist/hooks/save-checkpoint.d.ts +43 -0
- package/dist/hooks/save-checkpoint.js +144 -0
- package/dist/hooks/start-mcp-servers.d.ts +50 -0
- package/dist/hooks/start-mcp-servers.js +75 -0
- package/dist/hooks/stop-mcp-servers.d.ts +40 -0
- package/dist/hooks/stop-mcp-servers.js +58 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +238 -0
- package/dist/lib/archive.d.ts +31 -0
- package/dist/lib/archive.js +226 -0
- package/dist/lib/config.d.ts +93 -0
- package/dist/lib/config.js +251 -0
- package/dist/lib/constants.d.ts +222 -0
- package/dist/lib/constants.js +247 -0
- package/dist/lib/interactive.d.ts +31 -0
- package/dist/lib/interactive.js +166 -0
- package/dist/lib/mcp-client.d.ts +156 -0
- package/dist/lib/mcp-client.js +370 -0
- package/dist/lib/state.d.ts +119 -0
- package/dist/lib/state.js +293 -0
- package/dist/slash/executor.d.ts +22 -0
- package/dist/slash/executor.js +259 -0
- package/dist/slash/index.d.ts +11 -0
- package/dist/slash/index.js +45 -0
- package/dist/slash/parser.d.ts +24 -0
- package/dist/slash/parser.js +101 -0
- package/dist/slash/registry.d.ts +22 -0
- package/dist/slash/registry.js +155 -0
- package/dist/spec/openspec-to-task/builders.d.ts +107 -0
- package/dist/spec/openspec-to-task/builders.js +138 -0
- package/dist/spec/openspec-to-task/index.d.ts +20 -0
- package/dist/spec/openspec-to-task/index.js +182 -0
- package/dist/spec/openspec-to-task/parsers.d.ts +65 -0
- package/dist/spec/openspec-to-task/parsers.js +232 -0
- package/dist/spec/openspec-to-task/types.d.ts +49 -0
- package/dist/spec/openspec-to-task/types.js +6 -0
- package/dist/spec/sync-openspec-to-task.d.ts +7 -0
- package/dist/spec/sync-openspec-to-task.js +21 -0
- package/dist/spec/sync-task-to-openspec.d.ts +27 -0
- package/dist/spec/sync-task-to-openspec.js +288 -0
- package/dist/types/ai-context.d.ts +108 -0
- package/dist/types/ai-context.js +9 -0
- package/package.json +66 -0
- package/references/AI-CONVERSATION-TUTORIAL.md +270 -0
- package/references/CLI-TUTORIAL.md +447 -0
- package/references/GIT-WORKTREE-SOP.md +109 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# 人类与 AI 对话教程
|
|
2
|
+
|
|
3
|
+
本文档描述人类用户如何通过与预装 task-flow skill 的 AI 对话来完成开发任务。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 前置条件
|
|
8
|
+
|
|
9
|
+
1. AI 已预装 `task-flow` skill
|
|
10
|
+
2. 项目已初始化:`task-flow init`
|
|
11
|
+
3. AI 可访问项目代码库
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 场景一:新功能开发
|
|
16
|
+
|
|
17
|
+
### 步骤 1:描述需求
|
|
18
|
+
|
|
19
|
+
**人类**:
|
|
20
|
+
> 我想给项目添加 OAuth 登录功能,支持 Google 和 GitHub 登录。
|
|
21
|
+
|
|
22
|
+
**AI 行为**:
|
|
23
|
+
1. 分析项目结构和现有代码
|
|
24
|
+
2. 调用 `task-flow analyze` 生成 context
|
|
25
|
+
3. 调用 `task-flow extract` 生成 PRD 文档
|
|
26
|
+
|
|
27
|
+
**AI 回复**:
|
|
28
|
+
> 我已分析项目并生成了 PRD 文档。请确认以下需求:
|
|
29
|
+
>
|
|
30
|
+
> **功能清单**:
|
|
31
|
+
> 1. Google OAuth 登录
|
|
32
|
+
> 2. GitHub OAuth 登录
|
|
33
|
+
> 3. 用户信息存储
|
|
34
|
+
> 4. 登录状态管理
|
|
35
|
+
>
|
|
36
|
+
> 是否需要调整?
|
|
37
|
+
|
|
38
|
+
### 步骤 2:确认需求
|
|
39
|
+
|
|
40
|
+
**人类**:
|
|
41
|
+
> 还需要支持微信登录,并且登录后跳转到用户仪表盘。
|
|
42
|
+
|
|
43
|
+
**AI 行为**:
|
|
44
|
+
1. 更新 PRD 文档
|
|
45
|
+
2. 调用 `task-flow design` 生成技术设计
|
|
46
|
+
|
|
47
|
+
**AI 回复**:
|
|
48
|
+
> 已更新需求并生成技术设计。技术方案:
|
|
49
|
+
>
|
|
50
|
+
> - 使用 Passport.js 作为 OAuth 中间件
|
|
51
|
+
> - 用户信息存储在 PostgreSQL
|
|
52
|
+
> - JWT 作为会话管理
|
|
53
|
+
>
|
|
54
|
+
> 是否继续生成任务?
|
|
55
|
+
|
|
56
|
+
### 步骤 3:确认技术方案
|
|
57
|
+
|
|
58
|
+
**人类**:
|
|
59
|
+
> 可以,继续。
|
|
60
|
+
|
|
61
|
+
**AI 行为**:
|
|
62
|
+
1. 调用 `task-flow tasks` 生成任务文件
|
|
63
|
+
2. 调用 `task-flow worktree` 创建隔离工作区
|
|
64
|
+
|
|
65
|
+
**AI 回复**:
|
|
66
|
+
> 已生成任务文件并创建隔离工作区:
|
|
67
|
+
>
|
|
68
|
+
> ```
|
|
69
|
+
> Phase 1: 基础设施
|
|
70
|
+
> - Task 1.1: 安装依赖
|
|
71
|
+
> - Task 1.2: 配置 OAuth Provider
|
|
72
|
+
>
|
|
73
|
+
> Phase 2: 核心功能
|
|
74
|
+
> - Task 2.1: 实现 Google 登录
|
|
75
|
+
> - Task 2.2: 实现 GitHub 登录
|
|
76
|
+
> - Task 2.3: 实现微信登录
|
|
77
|
+
>
|
|
78
|
+
> Phase 3: 集成测试
|
|
79
|
+
> - Task 3.1: E2E 测试
|
|
80
|
+
> ```
|
|
81
|
+
>
|
|
82
|
+
> 开始实现吗?
|
|
83
|
+
|
|
84
|
+
### 步骤 4:开始实现
|
|
85
|
+
|
|
86
|
+
**人类**:
|
|
87
|
+
> 开始。
|
|
88
|
+
|
|
89
|
+
**AI 行为**:
|
|
90
|
+
1. 进入 worktree 目录
|
|
91
|
+
2. 按任务顺序编码实现
|
|
92
|
+
3. 运行测试验证
|
|
93
|
+
|
|
94
|
+
**AI 回复**:
|
|
95
|
+
> 正在实现...
|
|
96
|
+
>
|
|
97
|
+
> ✅ Task 1.1: 安装依赖 - 完成
|
|
98
|
+
> ✅ Task 1.2: 配置 OAuth Provider - 完成
|
|
99
|
+
> ✅ Task 2.1: 实现 Google 登录 - 完成
|
|
100
|
+
> ...
|
|
101
|
+
>
|
|
102
|
+
> 所有任务已完成,测试通过。是否合并到主分支?
|
|
103
|
+
|
|
104
|
+
### 步骤 5:合并
|
|
105
|
+
|
|
106
|
+
**人类**:
|
|
107
|
+
> 合并。
|
|
108
|
+
|
|
109
|
+
**AI 行为**:
|
|
110
|
+
1. 创建审查报告
|
|
111
|
+
2. 调用 `task-flow merge` 合并代码
|
|
112
|
+
|
|
113
|
+
**AI 回复**:
|
|
114
|
+
> ✅ 代码已合并到主分支
|
|
115
|
+
> ✅ worktree 已清理
|
|
116
|
+
>
|
|
117
|
+
> OAuth 登录功能开发完成!
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 场景二:Bug 修复
|
|
122
|
+
|
|
123
|
+
### 步骤 1:描述问题
|
|
124
|
+
|
|
125
|
+
**人类**:
|
|
126
|
+
> 用户反馈登录后有时会自动退出,怀疑是 token 过期问题。
|
|
127
|
+
|
|
128
|
+
**AI 行为**:
|
|
129
|
+
1. 分析认证相关代码
|
|
130
|
+
2. 调用 `task-flow extract --type fix` 生成修复 PRD
|
|
131
|
+
|
|
132
|
+
**AI 回复**:
|
|
133
|
+
> 我分析了认证模块,发现问题:
|
|
134
|
+
>
|
|
135
|
+
> 1. JWT 刷新逻辑在并发请求时存在竞态条件
|
|
136
|
+
> 2. Token 过期时间未正确设置时区
|
|
137
|
+
>
|
|
138
|
+
> 建议修复方案:
|
|
139
|
+
> 1. 添加分布式锁防止并发刷新
|
|
140
|
+
> 2. 使用 UTC 时间计算过期时间
|
|
141
|
+
>
|
|
142
|
+
> 是否继续?
|
|
143
|
+
|
|
144
|
+
### 步骤 2:确认并修复
|
|
145
|
+
|
|
146
|
+
**人类**:
|
|
147
|
+
> 继续。
|
|
148
|
+
|
|
149
|
+
**AI 行为**:
|
|
150
|
+
1. 生成修复任务
|
|
151
|
+
2. 创建隔离 worktree
|
|
152
|
+
3. 实现修复
|
|
153
|
+
|
|
154
|
+
**AI 回复**:
|
|
155
|
+
> ✅ 修复完成,已添加单元测试
|
|
156
|
+
> ✅ 测试通过
|
|
157
|
+
>
|
|
158
|
+
> 是否合并?
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 场景三:技术咨询
|
|
163
|
+
|
|
164
|
+
### 步骤 1:提问
|
|
165
|
+
|
|
166
|
+
**人类**:
|
|
167
|
+
> 这个项目的架构是什么样的?
|
|
168
|
+
|
|
169
|
+
**AI 行为**:
|
|
170
|
+
1. 读取 SKILL.md 了解项目规范
|
|
171
|
+
2. 分析代码结构
|
|
172
|
+
3. 生成架构说明
|
|
173
|
+
|
|
174
|
+
**AI 回复**:
|
|
175
|
+
> 根据 SKILL.md 和代码分析:
|
|
176
|
+
>
|
|
177
|
+
> **项目架构**:
|
|
178
|
+
> - 类型:CLI 工具 + Skill 包
|
|
179
|
+
> - 技术栈:TypeScript + Node.js 22
|
|
180
|
+
> - 构建工具:tsc
|
|
181
|
+
> - 测试框架:Node.js 内置测试
|
|
182
|
+
>
|
|
183
|
+
> **核心模块**:
|
|
184
|
+
> 1. `src/commands/` - CLI 命令实现
|
|
185
|
+
> 2. `src/lib/` - 核心工具库
|
|
186
|
+
> 3. `src/hooks/` - 生命周期钩子
|
|
187
|
+
>
|
|
188
|
+
> **工作流**:
|
|
189
|
+
> ```
|
|
190
|
+
> extract → design → tasks → worktree → implement → review → merge
|
|
191
|
+
> ```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 场景四:跳过技术设计
|
|
196
|
+
|
|
197
|
+
### 步骤 1:简单需求
|
|
198
|
+
|
|
199
|
+
**人类**:
|
|
200
|
+
> 给 README 添加一个安装说明章节。
|
|
201
|
+
|
|
202
|
+
**AI 行为**:
|
|
203
|
+
1. 判断需求简单,无需技术设计
|
|
204
|
+
2. 直接调用 `task-flow extract` 和 `task-flow tasks`
|
|
205
|
+
3. 跳过 `task-flow design`
|
|
206
|
+
|
|
207
|
+
**AI 回复**:
|
|
208
|
+
> 这是一个简单任务,我将跳过技术设计直接实现。
|
|
209
|
+
>
|
|
210
|
+
> ✅ 已更新 README.md
|
|
211
|
+
>
|
|
212
|
+
> 完成!
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 常见对话模式
|
|
217
|
+
|
|
218
|
+
### 提供额外上下文
|
|
219
|
+
|
|
220
|
+
**人类**:
|
|
221
|
+
> 这个功能需要兼容 IE11。
|
|
222
|
+
|
|
223
|
+
**AI 行为**:
|
|
224
|
+
调用命令时添加 `--context` 参数:
|
|
225
|
+
```bash
|
|
226
|
+
task-flow design --change <name> --context "兼容性: IE11"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 指定优先级
|
|
230
|
+
|
|
231
|
+
**人类**:
|
|
232
|
+
> 这个是紧急需求。
|
|
233
|
+
|
|
234
|
+
**AI 行为**:
|
|
235
|
+
```bash
|
|
236
|
+
task-flow extract --change <name> --priority high
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 强制覆盖
|
|
240
|
+
|
|
241
|
+
**人类**:
|
|
242
|
+
> 重新生成 PRD。
|
|
243
|
+
|
|
244
|
+
**AI 行为**:
|
|
245
|
+
```bash
|
|
246
|
+
task-flow extract --change <name> --force
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## AI 调用命令速查
|
|
252
|
+
|
|
253
|
+
| 场景 | AI 调用的命令 |
|
|
254
|
+
|------|--------------|
|
|
255
|
+
| 分析项目 | `task-flow analyze --output context.json` |
|
|
256
|
+
| 生成 PRD | `task-flow extract --change <name> --context-file context.json` |
|
|
257
|
+
| 生成技术设计 | `task-flow design --change <name> --context-file context.json` |
|
|
258
|
+
| 生成任务 | `task-flow tasks --change <name> --yes` |
|
|
259
|
+
| 创建工作区 | `task-flow worktree --change <name> --yes` |
|
|
260
|
+
| 查看状态 | `task-flow status` |
|
|
261
|
+
| 合并代码 | `task-flow merge <name>` |
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 注意事项
|
|
266
|
+
|
|
267
|
+
1. **AI 主动确认**:在关键步骤(需求确认、技术方案、合并)AI 会主动询问人类
|
|
268
|
+
2. **透明执行**:AI 会告知正在执行的命令和结果
|
|
269
|
+
3. **错误处理**:如果命令失败,AI 会解释原因并建议解决方案
|
|
270
|
+
4. **上下文传递**:AI 会自动维护 context.json,确保信息一致性
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
# 人类 CLI 使用教程
|
|
2
|
+
|
|
3
|
+
本文档描述人类开发者如何直接使用 `task-flow` CLI 命令完成开发任务。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 全局安装
|
|
11
|
+
npm install -g @bicorne/task-flow
|
|
12
|
+
|
|
13
|
+
# 或使用 pnpm
|
|
14
|
+
pnpm add -g @bicorne/task-flow
|
|
15
|
+
|
|
16
|
+
# 验证安装
|
|
17
|
+
task-flow --version
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 快速开始
|
|
23
|
+
|
|
24
|
+
### 1. 初始化项目
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# 在项目根目录执行
|
|
28
|
+
task-flow init
|
|
29
|
+
|
|
30
|
+
# 强制重新初始化(覆盖现有配置)
|
|
31
|
+
task-flow init --force
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
初始化后创建的目录结构:
|
|
35
|
+
```
|
|
36
|
+
project/
|
|
37
|
+
├── .harness/
|
|
38
|
+
│ ├── state.json # 运行状态
|
|
39
|
+
│ ├── hooks.json # Hooks 配置
|
|
40
|
+
│ └── archive/ # 归档目录
|
|
41
|
+
├── spec/
|
|
42
|
+
│ └── changes/ # 变更目录
|
|
43
|
+
└── .harnessrc # 配置文件
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. 创建新功能
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# 步骤 1: 分析项目(可选,生成上下文骨架)
|
|
50
|
+
task-flow analyze --output context.json
|
|
51
|
+
|
|
52
|
+
# 步骤 2: 编辑 context.json,补充项目理解
|
|
53
|
+
# ...
|
|
54
|
+
|
|
55
|
+
# 步骤 3: 生成 PRD
|
|
56
|
+
task-flow extract --change my-feature --context-file context.json
|
|
57
|
+
|
|
58
|
+
# 步骤 4: 编辑 PRD 文档
|
|
59
|
+
# 文件位置: spec/changes/my-feature/product-requirement.md
|
|
60
|
+
|
|
61
|
+
# 步骤 5: 生成技术设计(可选)
|
|
62
|
+
task-flow design --change my-feature --context-file context.json
|
|
63
|
+
|
|
64
|
+
# 步骤 6: 编辑技术设计文档
|
|
65
|
+
# 文件位置: spec/changes/my-feature/design.md
|
|
66
|
+
|
|
67
|
+
# 步骤 7: 生成任务文件
|
|
68
|
+
task-flow tasks --change my-feature --yes
|
|
69
|
+
|
|
70
|
+
# 步骤 8: 创建隔离工作区
|
|
71
|
+
task-flow worktree --change my-feature --yes
|
|
72
|
+
|
|
73
|
+
# 步骤 9: 在工作区中开发
|
|
74
|
+
cd .worktrees/harness-feat-my-feature
|
|
75
|
+
# 编码...
|
|
76
|
+
|
|
77
|
+
# 步骤 10: 验证
|
|
78
|
+
pnpm build && pnpm test && pnpm lint
|
|
79
|
+
|
|
80
|
+
# 步骤 11: 合并
|
|
81
|
+
cd ../.. # 回到主仓库
|
|
82
|
+
task-flow merge my-feature
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 命令详解
|
|
88
|
+
|
|
89
|
+
### `task-flow init`
|
|
90
|
+
|
|
91
|
+
初始化项目配置。
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
task-flow init [--force]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| 参数 | 说明 |
|
|
98
|
+
|------|------|
|
|
99
|
+
| `--force` | 强制覆盖现有配置 |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### `task-flow analyze`
|
|
104
|
+
|
|
105
|
+
自动扫描项目,生成上下文 JSON。
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
task-flow analyze # 输出到 stdout
|
|
109
|
+
task-flow analyze --output ctx.json # 输出到文件
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**扫描内容**:
|
|
113
|
+
- `package.json`:项目名称、描述、依赖
|
|
114
|
+
- `tsconfig.json`:TypeScript 配置
|
|
115
|
+
- 目录结构:src/、tests/、docs/ 等
|
|
116
|
+
- 技术栈推断:框架、构建工具、测试框架
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### `task-flow extract`
|
|
121
|
+
|
|
122
|
+
生成产品需求文档(PRD)。
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
task-flow extract --change <name> [options]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
| 参数 | 说明 |
|
|
129
|
+
|------|------|
|
|
130
|
+
| `--change <name>` | 变更名称(必需) |
|
|
131
|
+
| `--context-file <path>` | 上下文 JSON 文件路径 |
|
|
132
|
+
| `--input <text>` | 直接输入内容 |
|
|
133
|
+
| `--type <type>` | 任务类型:feat/fix/refactor/test/docs/chore |
|
|
134
|
+
| `--priority <level>` | 优先级:high/medium/low |
|
|
135
|
+
| `--force` | 覆盖现有文件 |
|
|
136
|
+
|
|
137
|
+
**输入优先级**:`--input` > `--context-file` > stdin > 模板
|
|
138
|
+
|
|
139
|
+
**示例**:
|
|
140
|
+
```bash
|
|
141
|
+
# 基本用法
|
|
142
|
+
task-flow extract --change add-oauth
|
|
143
|
+
|
|
144
|
+
# 带上下文
|
|
145
|
+
task-flow extract --change add-oauth --context-file context.json
|
|
146
|
+
|
|
147
|
+
# 指定类型和优先级
|
|
148
|
+
task-flow extract --change fix-login --type fix --priority high
|
|
149
|
+
|
|
150
|
+
# 从 stdin 读取
|
|
151
|
+
echo '{"projectName": "my-app"}' | task-flow extract --change add-oauth
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### `task-flow design`
|
|
157
|
+
|
|
158
|
+
生成技术设计文档。
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
task-flow design --change <name> [options]
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| 参数 | 说明 |
|
|
165
|
+
|------|------|
|
|
166
|
+
| `--change <name>` | 变更名称(必需) |
|
|
167
|
+
| `--context-file <path>` | 上下文 JSON 文件路径 |
|
|
168
|
+
| `--context <text>` | 直接传入上下文信息 |
|
|
169
|
+
| `--input <text>` | 直接输入设计内容 |
|
|
170
|
+
| `--force` | 覆盖现有文件 |
|
|
171
|
+
| `--skip-prompt` | 非 TTY 环境跳过交互 |
|
|
172
|
+
|
|
173
|
+
**示例**:
|
|
174
|
+
```bash
|
|
175
|
+
# 基本用法
|
|
176
|
+
task-flow design --change add-oauth
|
|
177
|
+
|
|
178
|
+
# 带上下文
|
|
179
|
+
task-flow design --change add-oauth --context-file context.json
|
|
180
|
+
|
|
181
|
+
# 直接传入上下文
|
|
182
|
+
task-flow design --change add-oauth --context "技术栈: React, 架构: 微前端"
|
|
183
|
+
|
|
184
|
+
# 跳过交互(生成空模板)
|
|
185
|
+
task-flow design --change add-oauth --skip-prompt
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### `task-flow tasks`
|
|
191
|
+
|
|
192
|
+
生成任务文件。
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
task-flow tasks --change <name> [options]
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
| 参数 | 说明 |
|
|
199
|
+
|------|------|
|
|
200
|
+
| `--change <name>` | 变更名称(必需) |
|
|
201
|
+
| `--yes` | 跳过确认 |
|
|
202
|
+
| `--input <text>` | 直接输入任务 JSON |
|
|
203
|
+
|
|
204
|
+
**生成文件**:
|
|
205
|
+
- `spec/changes/<name>/tasks.md` - 任务清单
|
|
206
|
+
- `spec/changes/<name>/tasks/PHASE-*.json` - 任务文件
|
|
207
|
+
- `spec/changes/<name>/manifest.json` - 执行配置
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### `task-flow worktree`
|
|
212
|
+
|
|
213
|
+
创建隔离的 git worktree 工作区。
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
task-flow worktree --change <name> [options]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
| 参数 | 说明 |
|
|
220
|
+
|------|------|
|
|
221
|
+
| `--change <name>` | 变更名称(必需) |
|
|
222
|
+
| `--yes` | 跳过确认 |
|
|
223
|
+
|
|
224
|
+
**工作区位置**:`.worktrees/harness-feat-<name>/`
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### `task-flow status`
|
|
229
|
+
|
|
230
|
+
显示当前状态。
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
task-flow status
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
输出示例:
|
|
237
|
+
```
|
|
238
|
+
Current Task: add-oauth
|
|
239
|
+
Phase: 2 (Implementation)
|
|
240
|
+
Status: in_progress
|
|
241
|
+
|
|
242
|
+
Active Tasks:
|
|
243
|
+
- PHASE-2-1-1: Implement OAuth callback
|
|
244
|
+
- PHASE-2-1-2: Add user session management
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### `task-flow merge`
|
|
250
|
+
|
|
251
|
+
合并完成的 worktree。
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
task-flow merge <task-id> [options]
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
| 参数 | 说明 |
|
|
258
|
+
|------|------|
|
|
259
|
+
| `<task-id>` | 任务 ID 或变更名称 |
|
|
260
|
+
| `--dry-run` | 模拟执行,不实际合并 |
|
|
261
|
+
| `--skip-review-check` | 跳过审查检查 |
|
|
262
|
+
|
|
263
|
+
**示例**:
|
|
264
|
+
```bash
|
|
265
|
+
# 先检查
|
|
266
|
+
task-flow merge add-oauth --dry-run
|
|
267
|
+
|
|
268
|
+
# 实际合并
|
|
269
|
+
task-flow merge add-oauth
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
### `task-flow archive`
|
|
275
|
+
|
|
276
|
+
归档任务状态。
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
task-flow archive --task-id <id> --event <event>
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
| 参数 | 说明 |
|
|
283
|
+
|------|------|
|
|
284
|
+
| `--task-id <id>` | 任务 ID |
|
|
285
|
+
| `--event <event>` | 事件类型:completed/abandoned/blocked |
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
### `task-flow sync`
|
|
290
|
+
|
|
291
|
+
同步任务状态到 spec 文档。
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
task-flow sync --task-id <id>
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## 完整工作流示例
|
|
300
|
+
|
|
301
|
+
### 场景:添加用户认证功能
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# 1. 初始化(首次)
|
|
305
|
+
task-flow init
|
|
306
|
+
|
|
307
|
+
# 2. 分析项目
|
|
308
|
+
task-flow analyze --output /tmp/context.json
|
|
309
|
+
|
|
310
|
+
# 3. 编辑 context.json(可选)
|
|
311
|
+
# 补充项目理解、风险分析等
|
|
312
|
+
|
|
313
|
+
# 4. 生成 PRD
|
|
314
|
+
task-flow extract --change add-auth --context-file /tmp/context.json
|
|
315
|
+
|
|
316
|
+
# 5. 编辑 PRD
|
|
317
|
+
vim spec/changes/add-auth/product-requirement.md
|
|
318
|
+
|
|
319
|
+
# 6. 生成技术设计
|
|
320
|
+
task-flow design --change add-auth --context-file /tmp/context.json
|
|
321
|
+
|
|
322
|
+
# 7. 编辑技术设计
|
|
323
|
+
vim spec/changes/add-auth/design.md
|
|
324
|
+
|
|
325
|
+
# 8. 生成任务
|
|
326
|
+
task-flow tasks --change add-auth --yes
|
|
327
|
+
|
|
328
|
+
# 9. 创建工作区
|
|
329
|
+
task-flow worktree --change add-auth --yes
|
|
330
|
+
|
|
331
|
+
# 10. 开发
|
|
332
|
+
cd .worktrees/harness-feat-add-auth
|
|
333
|
+
pnpm install
|
|
334
|
+
# ... 编码 ...
|
|
335
|
+
|
|
336
|
+
# 11. 验证
|
|
337
|
+
pnpm build && pnpm test && pnpm lint
|
|
338
|
+
|
|
339
|
+
# 12. 提交
|
|
340
|
+
git add .
|
|
341
|
+
git commit -m "feat: add user authentication"
|
|
342
|
+
|
|
343
|
+
# 13. 回到主仓库并合并
|
|
344
|
+
cd ../..
|
|
345
|
+
task-flow merge add-auth --dry-run # 先检查
|
|
346
|
+
task-flow merge add-auth # 实际合并
|
|
347
|
+
|
|
348
|
+
# 14. 查看状态
|
|
349
|
+
task-flow status
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## 配置文件
|
|
355
|
+
|
|
356
|
+
### `.harnessrc`
|
|
357
|
+
|
|
358
|
+
项目配置文件:
|
|
359
|
+
|
|
360
|
+
```json
|
|
361
|
+
{
|
|
362
|
+
"projectRoot": ".",
|
|
363
|
+
"specRoot": "spec",
|
|
364
|
+
"worktreeDir": ".worktrees",
|
|
365
|
+
"hooks": {
|
|
366
|
+
"enabled": true,
|
|
367
|
+
"configPath": ".harness/hooks.json"
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### `.harness/hooks.json`
|
|
373
|
+
|
|
374
|
+
Hooks 配置:
|
|
375
|
+
|
|
376
|
+
```json
|
|
377
|
+
{
|
|
378
|
+
"version": "1.0",
|
|
379
|
+
"hooks": {
|
|
380
|
+
"pre-design": [
|
|
381
|
+
{
|
|
382
|
+
"name": "check-prd-exists",
|
|
383
|
+
"script": "src/hooks/check-prd-exists.js",
|
|
384
|
+
"enabled": true,
|
|
385
|
+
"timeout": 5000
|
|
386
|
+
}
|
|
387
|
+
],
|
|
388
|
+
"post-task-complete": [
|
|
389
|
+
{
|
|
390
|
+
"name": "phase-gate-validator",
|
|
391
|
+
"script": "src/hooks/phase-gate-validator.js",
|
|
392
|
+
"enabled": true,
|
|
393
|
+
"timeout": 30000
|
|
394
|
+
}
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## 故障排除
|
|
403
|
+
|
|
404
|
+
### 命令执行失败
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# 检查状态
|
|
408
|
+
task-flow status
|
|
409
|
+
|
|
410
|
+
# 查看日志
|
|
411
|
+
cat .harness/state.json
|
|
412
|
+
|
|
413
|
+
# 强制重新初始化
|
|
414
|
+
task-flow init --force
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### Worktree 冲突
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
# 检查现有 worktree
|
|
421
|
+
git worktree list
|
|
422
|
+
|
|
423
|
+
# 删除冲突的 worktree
|
|
424
|
+
git worktree remove .worktrees/harness-feat-xxx
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### 合并失败
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
# 跳过审查检查
|
|
431
|
+
task-flow merge <name> --skip-review-check
|
|
432
|
+
|
|
433
|
+
# 手动合并
|
|
434
|
+
cd .worktrees/harness-feat-xxx
|
|
435
|
+
git checkout main
|
|
436
|
+
git merge feat-xxx
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## 环境变量
|
|
442
|
+
|
|
443
|
+
| 变量 | 说明 |
|
|
444
|
+
|------|------|
|
|
445
|
+
| `TASK_FLOW_DEBUG` | 启用调试模式 |
|
|
446
|
+
| `TASK_FLOW_CONFIG` | 自定义配置文件路径 |
|
|
447
|
+
| `TASK_FLOW_NO_COLOR` | 禁用彩色输出 |
|