@bicorne/task-flow 0.1.0 → 0.2.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 +337 -145
- package/SKILL.md +9 -5
- package/assets/.harnessrc +0 -1
- package/dist/commands/analyze.js +160 -318
- package/dist/commands/archive.js +44 -48
- package/dist/commands/design.js +225 -400
- package/dist/commands/extract.js +174 -303
- package/dist/commands/init.js +103 -148
- package/dist/commands/merge/index.js +184 -295
- package/dist/commands/merge/merger.js +112 -134
- package/dist/commands/merge/types.js +3 -5
- package/dist/commands/merge/validators.js +115 -132
- package/dist/commands/merge.js +46 -13
- package/dist/commands/start.js +155 -248
- package/dist/commands/status.js +68 -129
- package/dist/commands/sync.js +37 -53
- package/dist/commands/tasks-gen/doc-parser.js +148 -228
- package/dist/commands/tasks-gen/generators.js +104 -116
- package/dist/commands/tasks-gen/index.js +206 -314
- package/dist/commands/tasks-gen/parsers.js +131 -232
- package/dist/commands/tasks-gen/templates.js +9 -10
- package/dist/commands/tasks-gen/types.js +36 -14
- package/dist/commands/tasks-gen/validators.js +33 -49
- package/dist/commands/tasks.js +58 -20
- package/dist/commands/worktree.js +167 -249
- package/dist/hooks/check-prd-exists.js +45 -55
- package/dist/hooks/check-worktree-conflict.js +68 -101
- package/dist/hooks/hook-runner/executor.js +134 -126
- package/dist/hooks/hook-runner/index.js +181 -196
- package/dist/hooks/hook-runner/loader.js +74 -113
- package/dist/hooks/hook-runner/types.js +3 -5
- package/dist/hooks/hook-runner.js +94 -28
- package/dist/hooks/phase-complete-detector.js +125 -191
- package/dist/hooks/phase-gate-validator.js +315 -376
- package/dist/hooks/save-checkpoint.js +87 -130
- package/dist/hooks/start-mcp-servers.js +50 -65
- package/dist/hooks/stop-mcp-servers.js +40 -49
- package/dist/index.js +84 -153
- package/dist/lib/archive.js +126 -209
- package/dist/lib/config.d.ts +0 -2
- package/dist/lib/config.js +141 -230
- package/dist/lib/constants.js +155 -145
- package/dist/lib/interactive.js +98 -148
- package/dist/lib/mcp-client.js +197 -320
- package/dist/lib/state.js +142 -253
- package/dist/slash/executor.js +309 -233
- package/dist/slash/index.js +69 -43
- package/dist/slash/parser.js +84 -97
- package/dist/slash/registry.js +100 -88
- package/dist/spec/openspec-to-task/builders.js +96 -109
- package/dist/spec/openspec-to-task/index.js +112 -173
- package/dist/spec/openspec-to-task/parsers.js +148 -219
- package/dist/spec/openspec-to-task/types.js +3 -5
- package/dist/spec/sync-openspec-to-task.js +47 -19
- package/dist/spec/sync-task-to-openspec.js +241 -272
- package/dist/types/ai-context.js +3 -8
- package/package.json +9 -7
- package/references/CLI-TUTORIAL.md +4 -10
package/README.md
CHANGED
|
@@ -1,119 +1,199 @@
|
|
|
1
1
|
# @bicorne/task-flow
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
需求分析与任务拆分的 Harness Engineering 工具。帮助 AI 梳理用户需求生成 PRD 文档、编写技术规格、拆分多阶段任务文件,并通过 Git worktree 实现零冲突并行开发。适用于新功能开发、Bug 修复、代码重构等场景。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 核心特性
|
|
6
|
+
|
|
7
|
+
- **🤖 AI-First 设计**:支持 Slash Commands,在 AI 对话中直接执行任务
|
|
8
|
+
- **🌳 零冲突开发**:基于 Git worktree 实现多任务并行开发
|
|
9
|
+
- **📋 标准化流程**:从需求分析到代码合并的完整工作流
|
|
10
|
+
- **🔄 Hooks 机制**:支持生命周期钩子,实现自动化检查和验证
|
|
11
|
+
- **📦 标准任务格式**:PHASE-*.json 格式,支持依赖管理和进度跟踪
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
6
14
|
|
|
7
15
|
```bash
|
|
8
|
-
#
|
|
16
|
+
# 全局安装(推荐)
|
|
9
17
|
npm install -g @bicorne/task-flow
|
|
10
18
|
|
|
11
|
-
#
|
|
19
|
+
# 或使用 pnpm
|
|
20
|
+
pnpm add -g @bicorne/task-flow
|
|
21
|
+
|
|
22
|
+
# 或使用 npx(无需安装)
|
|
12
23
|
npx @bicorne/task-flow init
|
|
13
24
|
```
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
**系统要求:**
|
|
16
27
|
|
|
17
|
-
|
|
|
18
|
-
|
|
19
|
-
| **Node.js** | >=
|
|
20
|
-
| **Git** | >= 2.17 |
|
|
21
|
-
| **Bash** | >= 4.0 |
|
|
28
|
+
| 依赖 | 版本 | 说明 |
|
|
29
|
+
|------|------|------|
|
|
30
|
+
| **Node.js** | >= 24.14.0 | CLI 运行环境 |
|
|
31
|
+
| **Git** | >= 2.17 | worktree 功能依赖 |
|
|
32
|
+
| **Bash** | >= 4.0 | 引导脚本依赖 |
|
|
22
33
|
|
|
23
|
-
**Git
|
|
34
|
+
**Git 配置(worktree 测试需要):**
|
|
24
35
|
```bash
|
|
25
36
|
git config --global user.name "Your Name"
|
|
26
37
|
git config --global user.email "your@email.com"
|
|
27
38
|
```
|
|
28
39
|
|
|
29
|
-
##
|
|
40
|
+
## 快速开始
|
|
30
41
|
|
|
31
|
-
###
|
|
42
|
+
### 方式一:Slash Commands(推荐)
|
|
43
|
+
|
|
44
|
+
在 AI 对话中直接输入命令,AI 会自动识别并执行:
|
|
32
45
|
|
|
33
46
|
```bash
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
# 1. 初始化项目
|
|
48
|
+
/tf:init
|
|
36
49
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- `.harness/state.json` - Current state file
|
|
40
|
-
- `.harnessrc.example` - Configuration template
|
|
50
|
+
# 2. 一键创建变更提案(extract + design + tasks)
|
|
51
|
+
/tf:propose my-feature
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
# 3. AI 审查并编辑生成的 PRD 和设计文档
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```
|
|
55
|
+
# 4. 应用并创建工作区
|
|
56
|
+
/tf:apply my-feature
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
# 5. 在工作区中编码实现
|
|
59
|
+
cd .worktrees/harness-feat-my-feature
|
|
50
60
|
|
|
51
|
-
|
|
61
|
+
# 6. 完成后合并
|
|
62
|
+
cd ../..
|
|
63
|
+
/tf:merge my-feature
|
|
52
64
|
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
- Global design and architecture
|
|
57
|
-
- Detailed functional requirements
|
|
58
|
-
- Non-functional requirements
|
|
59
|
-
- Launch and operations plan
|
|
65
|
+
# 7. 归档
|
|
66
|
+
/tf:archive --task-id my-feature
|
|
67
|
+
```
|
|
60
68
|
|
|
61
|
-
###
|
|
69
|
+
### 方式二:传统 CLI 命令
|
|
62
70
|
|
|
63
71
|
```bash
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
# 1. 初始化项目
|
|
73
|
+
task-flow init
|
|
66
74
|
|
|
67
|
-
|
|
68
|
-
-
|
|
75
|
+
# 2. 扫描项目(可选)
|
|
76
|
+
task-flow analyze --output context.json
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
# 3. 生成 PRD 文档
|
|
79
|
+
task-flow extract --change my-feature --context-file context.json
|
|
71
80
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
```
|
|
81
|
+
# 4. 编辑 PRD 文档
|
|
82
|
+
# 文件位置: spec/changes/my-feature/product-requirement.md
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
- `spec/changes/my-feature/tasks/PHASE-*.json` - Individual task files
|
|
79
|
-
- `spec/changes/my-feature/manifest.json` - Execution config
|
|
84
|
+
# 5. 生成技术设计(可选)
|
|
85
|
+
task-flow design --change my-feature --context-file context.json
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
# 6. 生成任务文件
|
|
88
|
+
task-flow tasks --change my-feature --yes
|
|
82
89
|
|
|
83
|
-
|
|
84
|
-
task-flow worktree --change my-feature
|
|
90
|
+
# 7. 创建隔离工作区
|
|
91
|
+
task-flow worktree --change my-feature --yes
|
|
92
|
+
|
|
93
|
+
# 8. 在工作区中开发
|
|
94
|
+
cd .worktrees/harness-feat-my-feature
|
|
95
|
+
|
|
96
|
+
# 9. 完成后合并
|
|
97
|
+
cd ../..
|
|
98
|
+
task-flow merge my-feature
|
|
85
99
|
```
|
|
86
100
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
## 命令参考
|
|
102
|
+
|
|
103
|
+
### Slash Commands
|
|
104
|
+
|
|
105
|
+
| 命令 | 说明 | 示例 |
|
|
106
|
+
|------|------|------|
|
|
107
|
+
| `/tf:init` | 初始化项目 | `/tf:init` |
|
|
108
|
+
| `/tf:propose <name>` | 一键创建变更提案(extract + design + tasks) | `/tf:propose add-oauth` |
|
|
109
|
+
| `/tf:apply <name>` | 应用并创建工作区 | `/tf:apply add-oauth` |
|
|
110
|
+
| `/tf:extract <name>` | 生成 PRD 文档 | `/tf:extract add-oauth` |
|
|
111
|
+
| `/tf:design <name>` | 生成技术设计 | `/tf:design add-oauth` |
|
|
112
|
+
| `/tf:tasks <name>` | 生成任务文件 | `/tf:tasks add-oauth` |
|
|
113
|
+
| `/tf:worktree <name>` | 创建隔离工作区 | `/tf:worktree add-oauth` |
|
|
114
|
+
| `/tf:merge <id>` | 合并代码 | `/tf:merge add-oauth` |
|
|
115
|
+
| `/tf:archive --task-id <id>` | 归档已完成任务 | `/tf:archive --task-id add-oauth` |
|
|
116
|
+
| `/tf:status` | 显示当前状态 | `/tf:status` |
|
|
117
|
+
| `/tf:sync --task-id <id>` | 同步状态到 spec | `/tf:sync --task-id add-oauth` |
|
|
118
|
+
|
|
119
|
+
### CLI 命令
|
|
120
|
+
|
|
121
|
+
| 命令 | 说明 | 关键参数 |
|
|
122
|
+
|------|------|----------|
|
|
123
|
+
| `init` | 初始化项目 | `--force` 强制覆盖 |
|
|
124
|
+
| `analyze` | 扫描项目生成 context | `--output <path>` |
|
|
125
|
+
| `extract` | 生成 PRD 文档 | `--change <name> --context-file <path>` |
|
|
126
|
+
| `design` | 生成技术设计 | `--change <name> --context-file <path> --skip-prompt` |
|
|
127
|
+
| `tasks` | 生成任务文件 | `--change <name> --yes --input <json>` |
|
|
128
|
+
| `worktree` | 创建隔离工作区 | `--change <name> --yes` |
|
|
129
|
+
| `status` | 显示当前状态 | - |
|
|
130
|
+
| `merge` | 合并代码 | `<task-id> --dry-run` |
|
|
131
|
+
| `archive` | 归档任务 | `--task-id <id> --event <event>` |
|
|
132
|
+
| `sync` | 同步状态到 spec | `--task-id <id>` |
|
|
133
|
+
|
|
134
|
+
详细用法请参考 [CLI 使用教程](references/CLI-TUTORIAL.md)。
|
|
135
|
+
|
|
136
|
+
## 核心概念
|
|
137
|
+
|
|
138
|
+
### AI 调用模型
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
AI 分析项目 → 生成 context.json → 调用 CLI 生成文档 → AI 审查并填充 → 执行任务
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- **AI 是"大脑"**:理解项目、做决策、填充内容
|
|
145
|
+
- **CLI 是"手"**:文件操作、格式转换、状态管理
|
|
146
|
+
|
|
147
|
+
### Context 协议
|
|
148
|
+
|
|
149
|
+
AI 在调用命令前生成 context JSON,传递项目理解:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
interface AiContext {
|
|
153
|
+
version: '1.0';
|
|
154
|
+
project: {
|
|
155
|
+
name: string;
|
|
156
|
+
type?: 'library' | 'application' | 'service' | 'cli' | 'monorepo';
|
|
157
|
+
techStack?: { language?: string; framework?: string; runtime?: string; };
|
|
158
|
+
};
|
|
159
|
+
analysis?: {
|
|
160
|
+
architectureSummary?: string;
|
|
161
|
+
coreModules?: Array<{ name: string; path: string; description: string }>;
|
|
162
|
+
risks?: string[];
|
|
163
|
+
};
|
|
164
|
+
task?: {
|
|
165
|
+
type?: 'feat' | 'fix' | 'refactor' | 'test' | 'docs' | 'chore';
|
|
166
|
+
priority?: 'high' | 'medium' | 'low';
|
|
167
|
+
affectedFiles?: string[];
|
|
168
|
+
constraints?: string[];
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
```
|
|
90
172
|
|
|
91
|
-
|
|
173
|
+
### 工作流程
|
|
92
174
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
| `merge` | Merge completed worktree back to main |
|
|
103
|
-
| `sync` | Sync task execution status to spec |
|
|
175
|
+
```
|
|
176
|
+
analyze → extract → design → tasks → worktree → implement → review → merge
|
|
177
|
+
│ │ │ │ │
|
|
178
|
+
│ │ │ │ └── 创建隔离 git worktree
|
|
179
|
+
│ │ │ └── 生成 PHASE-*.json 任务文件
|
|
180
|
+
│ │ └── 分析 PRD 生成技术规格(可选)
|
|
181
|
+
│ └── 提取需求生成 PRD 文档
|
|
182
|
+
└── 自动扫描项目结构,生成 context.json 骨架
|
|
183
|
+
```
|
|
104
184
|
|
|
105
|
-
##
|
|
185
|
+
## 配置
|
|
106
186
|
|
|
107
|
-
###
|
|
187
|
+
### 环境变量
|
|
108
188
|
|
|
109
|
-
|
|
|
110
|
-
|
|
111
|
-
| `HARNESS_ROOT` | `.harness` |
|
|
112
|
-
| `HARNESS_WORKTREES_DIR` | `.worktrees` |
|
|
113
|
-
| `HARNESS_CONFIG_FILE` | `.harnessrc` |
|
|
114
|
-
| `HARNESS_SPEC_ROOT` | `spec` |
|
|
189
|
+
| 变量 | 默认值 | 说明 |
|
|
190
|
+
|------|--------|------|
|
|
191
|
+
| `HARNESS_ROOT` | `.harness` | Harness 状态根目录 |
|
|
192
|
+
| `HARNESS_WORKTREES_DIR` | `.worktrees` | worktree 检出目录 |
|
|
193
|
+
| `HARNESS_CONFIG_FILE` | `.harnessrc` | 配置文件路径 |
|
|
194
|
+
| `HARNESS_SPEC_ROOT` | `spec` | spec 文件根目录 |
|
|
115
195
|
|
|
116
|
-
###
|
|
196
|
+
### 配置文件 (`.harnessrc`)
|
|
117
197
|
|
|
118
198
|
```json
|
|
119
199
|
{
|
|
@@ -123,30 +203,169 @@ This creates:
|
|
|
123
203
|
"snapshotsDir": "snapshots",
|
|
124
204
|
"archiveDir": "archive",
|
|
125
205
|
"reportsDir": "reports",
|
|
126
|
-
"plansDir": "plans",
|
|
127
206
|
"specRoot": "spec"
|
|
128
207
|
}
|
|
129
208
|
```
|
|
130
209
|
|
|
131
|
-
|
|
210
|
+
### Hooks 配置
|
|
132
211
|
|
|
212
|
+
在 `.harness/hooks.json` 中配置生命周期钩子:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"version": "1.0",
|
|
217
|
+
"hooks": {
|
|
218
|
+
"pre-design": [
|
|
219
|
+
{ "name": "check-prd-exists", "script": "src/hooks/check-prd-exists.js", "enabled": true }
|
|
220
|
+
],
|
|
221
|
+
"pre-worktree": [
|
|
222
|
+
{ "name": "check-worktree-conflict", "script": "src/hooks/check-worktree-conflict.js", "enabled": true }
|
|
223
|
+
],
|
|
224
|
+
"post-task-complete": [
|
|
225
|
+
{ "name": "phase-gate-validator", "script": "src/hooks/phase-gate-validator.js", "enabled": true }
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
}
|
|
133
229
|
```
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
│
|
|
143
|
-
│
|
|
144
|
-
│
|
|
145
|
-
├──
|
|
146
|
-
|
|
230
|
+
|
|
231
|
+
## 目录结构
|
|
232
|
+
|
|
233
|
+
### 项目目录
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
harness-task-flow/
|
|
237
|
+
├── src/
|
|
238
|
+
│ ├── index.ts # CLI 入口
|
|
239
|
+
│ ├── commands/ # 命令实现
|
|
240
|
+
│ │ ├── init.ts
|
|
241
|
+
│ │ ├── extract.ts
|
|
242
|
+
│ │ ├── design.ts
|
|
243
|
+
│ │ ├── tasks.ts
|
|
244
|
+
│ │ ├── worktree.ts
|
|
245
|
+
│ │ ├── status.ts
|
|
246
|
+
│ │ ├── archive.ts
|
|
247
|
+
│ │ ├── merge.ts
|
|
248
|
+
│ │ ├── sync.ts
|
|
249
|
+
│ │ ├── analyze.ts
|
|
250
|
+
│ │ ├── merge/ # 合并命令子模块
|
|
251
|
+
│ │ └── tasks-gen/ # 任务生成子模块
|
|
252
|
+
│ ├── lib/ # 核心工具库
|
|
253
|
+
│ │ ├── config.ts # 配置管理
|
|
254
|
+
│ │ ├── state.ts # 状态管理
|
|
255
|
+
│ │ ├── archive.ts # 归档管理
|
|
256
|
+
│ │ ├── constants.ts # 常量定义
|
|
257
|
+
│ │ ├── interactive.ts # 交互式 CLI
|
|
258
|
+
│ │ └── mcp-client.ts # MCP 客户端
|
|
259
|
+
│ ├── hooks/ # 事件钩子
|
|
260
|
+
│ │ ├── hook-runner/ # Hook 执行引擎
|
|
261
|
+
│ │ ├── check-prd-exists.ts
|
|
262
|
+
│ │ ├── check-worktree-conflict.ts
|
|
263
|
+
│ │ ├── phase-gate-validator.ts
|
|
264
|
+
│ │ ├── phase-complete-detector.ts
|
|
265
|
+
│ │ ├── save-checkpoint.ts
|
|
266
|
+
│ │ ├── start-mcp-servers.ts
|
|
267
|
+
│ │ └── stop-mcp-servers.ts
|
|
268
|
+
│ ├── slash/ # Slash Commands
|
|
269
|
+
│ │ ├── parser.ts
|
|
270
|
+
│ │ ├── registry.ts
|
|
271
|
+
│ │ └── executor.ts
|
|
272
|
+
│ ├── spec/ # Spec 集成
|
|
273
|
+
│ │ ├── openspec-to-task/ # OpenSpec 转换
|
|
274
|
+
│ │ ├── sync-openspec-to-task.ts
|
|
275
|
+
│ │ └── sync-task-to-openspec.ts
|
|
276
|
+
│ └── types/ # 类型定义
|
|
277
|
+
│ └── ai-context.ts
|
|
278
|
+
├── assets/ # 文件模板
|
|
279
|
+
│ ├── schema.json # 任务 JSON Schema
|
|
280
|
+
│ ├── product-requirement.md # PRD 模板
|
|
281
|
+
│ ├── design.md # 技术规格模板
|
|
282
|
+
│ ├── tasks.md # 任务清单模板
|
|
283
|
+
│ ├── PHASE-task.json.example # 任务 JSON 示例
|
|
284
|
+
│ ├── hooks.json # Hooks 配置示例
|
|
285
|
+
│ └── .harnessrc # 配置文件示例
|
|
286
|
+
├── tests/ # 测试文件
|
|
287
|
+
├── references/ # 参考文档
|
|
288
|
+
│ ├── CLI-TUTORIAL.md
|
|
289
|
+
│ ├── AI-CONVERSATION-TUTORIAL.md
|
|
290
|
+
│ └── GIT-WORKTREE-SOP.md
|
|
291
|
+
├── SKILL.md # Skill 文档
|
|
292
|
+
└── package.json
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### 运行时目录
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
project/
|
|
299
|
+
├── .harness/ # Harness 运行时目录
|
|
300
|
+
│ ├── state.json # 当前运行状态
|
|
301
|
+
│ ├── hooks.json # Hooks 配置
|
|
302
|
+
│ ├── skills.json # 技能工具注册(可选)
|
|
303
|
+
│ ├── mcp.json # MCP 服务器注册(可选)
|
|
304
|
+
│ └── archive/ # 归档目录
|
|
305
|
+
├── spec/ # 规格文档目录
|
|
306
|
+
│ └── changes/ # 变更提案目录
|
|
307
|
+
│ └── <change-name>/ # 具体变更
|
|
308
|
+
│ ├── product-requirement.md # 产品需求文档
|
|
309
|
+
│ ├── design.md # 技术规格(可选)
|
|
310
|
+
│ ├── tasks.md # 任务清单
|
|
311
|
+
│ ├── tasks/ # 多阶段任务 JSON
|
|
312
|
+
│ │ ├── PHASE-1-1-1.json
|
|
313
|
+
│ │ ├── PHASE-1-1-2.json
|
|
314
|
+
│ │ └── ...
|
|
315
|
+
│ └── manifest.json # 执行配置清单
|
|
316
|
+
└── .worktrees/ # Git worktree 目录
|
|
317
|
+
└── harness-feat-<name>/ # 隔离工作区
|
|
147
318
|
```
|
|
148
319
|
|
|
149
|
-
##
|
|
320
|
+
## 任务文件格式
|
|
321
|
+
|
|
322
|
+
PHASE-*.json 任务文件遵循标准 Schema:
|
|
323
|
+
|
|
324
|
+
```json
|
|
325
|
+
{
|
|
326
|
+
"id": "PHASE-1-1-1",
|
|
327
|
+
"type": "feat",
|
|
328
|
+
"title": "实现用户认证",
|
|
329
|
+
"priority": "high",
|
|
330
|
+
"phase": 1,
|
|
331
|
+
"dependencies": [],
|
|
332
|
+
"docs_to_read": ["spec/changes/my-feature/design.md"],
|
|
333
|
+
"spec": {
|
|
334
|
+
"description": "实现基于 JWT 的用户认证系统",
|
|
335
|
+
"files": ["src/auth/jwt.ts", "src/auth/middleware.ts"],
|
|
336
|
+
"context": ["spec/changes/my-feature/product-requirement.md"]
|
|
337
|
+
},
|
|
338
|
+
"acceptance_criteria": [
|
|
339
|
+
"用户可以登录并获取 JWT token",
|
|
340
|
+
"受保护的路由需要验证 token",
|
|
341
|
+
"token 过期后自动刷新"
|
|
342
|
+
],
|
|
343
|
+
"implementation": {
|
|
344
|
+
"steps": [
|
|
345
|
+
{ "step": "安装依赖", "details": "npm install jsonwebtoken" },
|
|
346
|
+
{ "step": "实现 JWT 工具函数", "details": "创建 sign 和 verify 函数" },
|
|
347
|
+
{ "step": "实现认证中间件", "details": "验证 token 并注入用户信息" }
|
|
348
|
+
],
|
|
349
|
+
"notes": "使用 RS256 算法"
|
|
350
|
+
},
|
|
351
|
+
"validation": {
|
|
352
|
+
"commands": [
|
|
353
|
+
"pnpm build",
|
|
354
|
+
"pnpm test",
|
|
355
|
+
"pnpm lint"
|
|
356
|
+
],
|
|
357
|
+
"manual_checks": [
|
|
358
|
+
"验证登录流程正常",
|
|
359
|
+
"检查 token 刷新机制"
|
|
360
|
+
]
|
|
361
|
+
},
|
|
362
|
+
"status": "pending"
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
完整 Schema 定义见 [assets/schema.json](assets/schema.json)。
|
|
367
|
+
|
|
368
|
+
## 工具注册
|
|
150
369
|
|
|
151
370
|
### skills.json
|
|
152
371
|
|
|
@@ -181,72 +400,45 @@ spec/
|
|
|
181
400
|
}
|
|
182
401
|
```
|
|
183
402
|
|
|
184
|
-
##
|
|
185
|
-
|
|
186
|
-
### New Slash Command Workflow (v2)
|
|
187
|
-
|
|
188
|
-
```
|
|
189
|
-
extract → design → tasks → worktree → implement → review → merge
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## Architecture
|
|
193
|
-
|
|
194
|
-
```
|
|
195
|
-
harness-task-flow/
|
|
196
|
-
├── src/
|
|
197
|
-
│ ├── index.ts # CLI entry point
|
|
198
|
-
│ ├── commands/ # Command implementations
|
|
199
|
-
│ │ ├── init.ts
|
|
200
|
-
│ │ ├── extract.ts # Extract requirements → PRD
|
|
201
|
-
│ │ ├── design.ts # Analyze PRD → tech spec (optional)
|
|
202
|
-
│ │ ├── tasks.ts # Generate PHASE-*.json task files
|
|
203
|
-
│ │ ├── worktree.ts # Create isolated worktree
|
|
204
|
-
│ │ ├── status.ts
|
|
205
|
-
│ │ ├── archive.ts
|
|
206
|
-
│ │ ├── merge.ts
|
|
207
|
-
│ │ └── sync.ts
|
|
208
|
-
│ ├── lib/ # Core utilities
|
|
209
|
-
│ │ ├── config.ts
|
|
210
|
-
│ │ ├── state.ts
|
|
211
|
-
│ │ ├── archive.ts
|
|
212
|
-
│ │ └── tool-registry.ts
|
|
213
|
-
│ ├── hooks/ # Event hooks
|
|
214
|
-
│ │ ├── hook-runner.ts
|
|
215
|
-
│ │ ├── check-prd-exists.ts
|
|
216
|
-
│ │ ├── phase-gate-validator.ts
|
|
217
|
-
│ │ ├── phase-complete-detector.ts
|
|
218
|
-
│ │ ├── save-checkpoint.ts
|
|
219
|
-
│ │ └── check-worktree-conflict.ts
|
|
220
|
-
│ └── spec/ # Spec integration
|
|
221
|
-
│ ├── sync-openspec-to-task.ts
|
|
222
|
-
│ └── sync-task-to-openspec.ts
|
|
223
|
-
├── assets/ # File templates
|
|
224
|
-
│ ├── schema.json # Task JSON schema
|
|
225
|
-
│ ├── product-requirement.md # PRD template
|
|
226
|
-
│ ├── design.md # Tech spec template
|
|
227
|
-
│ └── tasks.md # Tasks template
|
|
228
|
-
├── SKILL.md
|
|
229
|
-
└── package.json
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## Development
|
|
403
|
+
## 开发
|
|
233
404
|
|
|
234
405
|
```bash
|
|
235
|
-
#
|
|
406
|
+
# 安装依赖
|
|
236
407
|
pnpm install
|
|
237
408
|
|
|
238
|
-
#
|
|
409
|
+
# 运行测试
|
|
239
410
|
pnpm test
|
|
240
411
|
|
|
241
|
-
#
|
|
412
|
+
# 代码检查
|
|
242
413
|
pnpm lint
|
|
414
|
+
|
|
415
|
+
# 类型检查
|
|
416
|
+
pnpm typecheck
|
|
417
|
+
|
|
418
|
+
# 构建
|
|
419
|
+
pnpm build
|
|
420
|
+
|
|
421
|
+
# 监听模式构建
|
|
422
|
+
pnpm build:watch
|
|
423
|
+
|
|
424
|
+
# 发布(使用 changesets)
|
|
425
|
+
pnpm changeset
|
|
426
|
+
pnpm version
|
|
427
|
+
pnpm release
|
|
243
428
|
```
|
|
244
429
|
|
|
245
|
-
##
|
|
430
|
+
## 文档
|
|
431
|
+
|
|
432
|
+
- [CLI 使用教程](references/CLI-TUTORIAL.md) - 人类开发者如何使用 CLI 命令
|
|
433
|
+
- [AI 对话教程](references/AI-CONVERSATION-TUTORIAL.md) - 如何通过 AI 对话完成任务
|
|
434
|
+
- [Git Worktree SOP](references/GIT-WORKTREE-SOP.md) - Git worktree 使用规范
|
|
435
|
+
|
|
436
|
+
## 许可证
|
|
246
437
|
|
|
247
|
-
MIT License -
|
|
438
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件
|
|
248
439
|
|
|
249
|
-
##
|
|
440
|
+
## 链接
|
|
250
441
|
|
|
251
442
|
- [Agent Skills Specification](https://agentskills.io/specification)
|
|
252
|
-
- [
|
|
443
|
+
- [GitHub Repository](https://github.com/didengren/harness-task-flow)
|
|
444
|
+
- [Issue Tracker](https://github.com/didengren/harness-task-flow/issues)
|
package/SKILL.md
CHANGED
|
@@ -75,7 +75,7 @@ analyze → extract → design → tasks → worktree → implement → review
|
|
|
75
75
|
|
|
76
76
|
| Slash Command | 说明 | AI 执行的操作 |
|
|
77
77
|
|---------------|------|---------------|
|
|
78
|
-
| `/tf:propose <name>` | 一键创建变更提案 | extract → design → tasks |
|
|
78
|
+
| `/tf:propose <name>` | 一键创建变更提案 | analyze → extract → design → tasks |
|
|
79
79
|
| `/tf:apply <name>` | 应用并创建工作区 | worktree |
|
|
80
80
|
| `/tf:archive --task-id <id>` | 归档已完成任务 | archive → sync |
|
|
81
81
|
| `/tf:init` | 初始化项目 | init |
|
|
@@ -87,6 +87,12 @@ analyze → extract → design → tasks → worktree → implement → review
|
|
|
87
87
|
| `/tf:merge <id>` | 合并代码 | merge |
|
|
88
88
|
| `/tf:sync --task-id <id>` | 同步状态到 spec | sync |
|
|
89
89
|
|
|
90
|
+
> **`/tf:propose` 自动处理 context**:
|
|
91
|
+
> - 优先查找现有 context 文件(`context.json`、`.harness/context.json`、`.tmp/context.json`)
|
|
92
|
+
> - 若不存在则自动执行 `analyze` 生成临时 context 文件到 `.tmp/context.json`
|
|
93
|
+
> - 生成的 context 会传递给后续的 `extract` 和 `design` 步骤
|
|
94
|
+
> - AI 可在执行后审查并补充 context 内容,再次运行 `/tf:propose` 时会复用已有 context
|
|
95
|
+
|
|
90
96
|
> **使用方式**:直接在 AI 对话中输入 `/tf:init` 即可,无需加 `task-flow` 前缀。
|
|
91
97
|
> AI 读取本 Skill 文档后,会自动识别并执行对应的 CLI 命令。
|
|
92
98
|
|
|
@@ -127,8 +133,7 @@ analyze → extract → design → tasks → worktree → implement → review
|
|
|
127
133
|
# 5. 在工作区中编码实现
|
|
128
134
|
cd .worktrees/harness-feat-add-oauth
|
|
129
135
|
|
|
130
|
-
# 6.
|
|
131
|
-
pnpm build && pnpm test && pnpm lint
|
|
136
|
+
# 6. 完成后合并
|
|
132
137
|
cd ../..
|
|
133
138
|
/tf:merge add-oauth
|
|
134
139
|
|
|
@@ -160,8 +165,7 @@ task-flow worktree --change add-oauth --yes
|
|
|
160
165
|
# 7. 在工作区中编码实现
|
|
161
166
|
cd .worktrees/harness-feat-add-oauth
|
|
162
167
|
|
|
163
|
-
# 8.
|
|
164
|
-
pnpm build && pnpm test && pnpm lint
|
|
168
|
+
# 8. 完成后合并
|
|
165
169
|
cd ../..
|
|
166
170
|
task-flow merge add-oauth
|
|
167
171
|
```
|