@bicorne/task-flow 0.1.0 → 0.2.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/README.md CHANGED
@@ -1,119 +1,201 @@
1
1
  # @bicorne/task-flow
2
2
 
3
- A git worktree-based parallel task execution system for zero-conflict multi-task development.
3
+ 需求分析与任务拆分的 Harness Engineering 工具。帮助 AI 梳理用户需求生成 PRD 文档、编写技术规格、拆分多阶段任务文件,并通过 Git worktree 实现零冲突并行开发。适用于新功能开发、Bug 修复、代码重构等场景。
4
4
 
5
- ## Installation
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
- # Install from npm (recommended)
16
+ # 全局安装(推荐)
9
17
  npm install -g @bicorne/task-flow
10
18
 
11
- # Or use via npx
19
+ # 或使用 pnpm
20
+ pnpm add -g @bicorne/task-flow
21
+
22
+ # 或使用 npx(无需安装)
12
23
  npx @bicorne/task-flow init
13
24
  ```
14
25
 
15
- **Requirements:**
26
+ **系统要求:**
16
27
 
17
- | Dependency | Version | Description |
18
- |------------|---------|-------------|
19
- | **Node.js** | >= 22.11.0 | Required for CLI execution |
20
- | **Git** | >= 2.17 | Required for worktree functionality |
21
- | **Bash** | >= 4.0 | Required for bootstrap scripts |
28
+ | 依赖 | 版本 | 说明 |
29
+ |------|------|------|
30
+ | **Node.js** | >= 24.14.0 | CLI 运行环境 |
31
+ | **Git** | >= 2.17 | worktree 功能依赖 |
32
+ | **Bash** | >= 4.0 | 引导脚本依赖 |
22
33
 
23
- **Git Configuration (for worktree tests):**
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
- ## Quick Start
40
+ ## 快速开始
30
41
 
31
- ### Step 1: Initialize Task Flow
42
+ ### 方式一:Slash Commands(推荐)
43
+
44
+ 在 AI 对话中直接输入命令,AI 会自动识别并执行:
32
45
 
33
46
  ```bash
34
- task-flow init
35
- ```
47
+ # 1. 初始化项目
48
+ /tf:init
36
49
 
37
- This creates:
38
- - `.harness/` - Root directory for harness state
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
- ### Step 2: Create PRD Document
53
+ # 3. AI 审查并编辑生成的 PRD 和设计文档
43
54
 
44
- ```bash
45
- task-flow extract --change my-feature
46
- ```
55
+ # 4. 应用并创建工作区
56
+ /tf:apply my-feature
47
57
 
48
- This creates:
49
- - `spec/changes/my-feature/product-requirement.md` - PRD document
58
+ # 5. 在工作区中编码实现
59
+ cd .worktrees/harness-feat-my-feature
50
60
 
51
- ### Step 3: Edit PRD Document Manually
61
+ # 6. 验证并合并
62
+ pnpm build && pnpm test && pnpm lint
63
+ cd ../..
64
+ /tf:merge my-feature
52
65
 
53
- Edit `spec/changes/my-feature/product-requirement.md` to describe your change:
54
- - Project background and goals
55
- - Users and scenarios
56
- - Global design and architecture
57
- - Detailed functional requirements
58
- - Non-functional requirements
59
- - Launch and operations plan
66
+ # 7. 归档
67
+ /tf:archive --task-id my-feature
68
+ ```
60
69
 
61
- ### Step 4: Generate Design
70
+ ### 方式二:传统 CLI 命令
62
71
 
63
72
  ```bash
64
- task-flow design --change my-feature
65
- ```
73
+ # 1. 初始化项目
74
+ task-flow init
66
75
 
67
- This generates:
68
- - `spec/changes/my-feature/design.md` - Technical specification
76
+ # 2. 扫描项目(可选)
77
+ task-flow analyze --output context.json
69
78
 
70
- ### Step 5: Generate Tasks
79
+ # 3. 生成 PRD 文档
80
+ task-flow extract --change my-feature --context-file context.json
71
81
 
72
- ```bash
73
- task-flow tasks --change my-feature
74
- ```
82
+ # 4. 编辑 PRD 文档
83
+ # 文件位置: spec/changes/my-feature/product-requirement.md
75
84
 
76
- This generates:
77
- - `spec/changes/my-feature/tasks.md` - Task list
78
- - `spec/changes/my-feature/tasks/PHASE-*.json` - Individual task files
79
- - `spec/changes/my-feature/manifest.json` - Execution config
85
+ # 5. 生成技术设计(可选)
86
+ task-flow design --change my-feature --context-file context.json
80
87
 
81
- ### Step 6: Create Worktree
88
+ # 6. 生成任务文件
89
+ task-flow tasks --change my-feature --yes
82
90
 
83
- ```bash
84
- task-flow worktree --change my-feature
91
+ # 7. 创建隔离工作区
92
+ task-flow worktree --change my-feature --yes
93
+
94
+ # 8. 在工作区中开发
95
+ cd .worktrees/harness-feat-my-feature
96
+
97
+ # 9. 验证并合并
98
+ pnpm build && pnpm test && pnpm lint
99
+ cd ../..
100
+ task-flow merge my-feature
85
101
  ```
86
102
 
87
- This creates:
88
- - `.worktrees/harness-feat-my-feature/` - Isolated worktree
89
- - `.harness/` symlink in worktree
103
+ ## 命令参考
104
+
105
+ ### Slash Commands
106
+
107
+ | 命令 | 说明 | 示例 |
108
+ |------|------|------|
109
+ | `/tf:init` | 初始化项目 | `/tf:init` |
110
+ | `/tf:propose <name>` | 一键创建变更提案(extract + design + tasks) | `/tf:propose add-oauth` |
111
+ | `/tf:apply <name>` | 应用并创建工作区 | `/tf:apply add-oauth` |
112
+ | `/tf:extract <name>` | 生成 PRD 文档 | `/tf:extract add-oauth` |
113
+ | `/tf:design <name>` | 生成技术设计 | `/tf:design add-oauth` |
114
+ | `/tf:tasks <name>` | 生成任务文件 | `/tf:tasks add-oauth` |
115
+ | `/tf:worktree <name>` | 创建隔离工作区 | `/tf:worktree add-oauth` |
116
+ | `/tf:merge <id>` | 合并代码 | `/tf:merge add-oauth` |
117
+ | `/tf:archive --task-id <id>` | 归档已完成任务 | `/tf:archive --task-id add-oauth` |
118
+ | `/tf:status` | 显示当前状态 | `/tf:status` |
119
+ | `/tf:sync --task-id <id>` | 同步状态到 spec | `/tf:sync --task-id add-oauth` |
120
+
121
+ ### CLI 命令
122
+
123
+ | 命令 | 说明 | 关键参数 |
124
+ |------|------|----------|
125
+ | `init` | 初始化项目 | `--force` 强制覆盖 |
126
+ | `analyze` | 扫描项目生成 context | `--output <path>` |
127
+ | `extract` | 生成 PRD 文档 | `--change <name> --context-file <path>` |
128
+ | `design` | 生成技术设计 | `--change <name> --context-file <path> --skip-prompt` |
129
+ | `tasks` | 生成任务文件 | `--change <name> --yes --input <json>` |
130
+ | `worktree` | 创建隔离工作区 | `--change <name> --yes` |
131
+ | `status` | 显示当前状态 | - |
132
+ | `merge` | 合并代码 | `<task-id> --dry-run` |
133
+ | `archive` | 归档任务 | `--task-id <id> --event <event>` |
134
+ | `sync` | 同步状态到 spec | `--task-id <id>` |
135
+
136
+ 详细用法请参考 [CLI 使用教程](references/CLI-TUTORIAL.md)。
137
+
138
+ ## 核心概念
139
+
140
+ ### AI 调用模型
141
+
142
+ ```
143
+ AI 分析项目 → 生成 context.json → 调用 CLI 生成文档 → AI 审查并填充 → 执行任务
144
+ ```
145
+
146
+ - **AI 是"大脑"**:理解项目、做决策、填充内容
147
+ - **CLI 是"手"**:文件操作、格式转换、状态管理
148
+
149
+ ### Context 协议
150
+
151
+ AI 在调用命令前生成 context JSON,传递项目理解:
152
+
153
+ ```typescript
154
+ interface AiContext {
155
+ version: '1.0';
156
+ project: {
157
+ name: string;
158
+ type?: 'library' | 'application' | 'service' | 'cli' | 'monorepo';
159
+ techStack?: { language?: string; framework?: string; runtime?: string; };
160
+ };
161
+ analysis?: {
162
+ architectureSummary?: string;
163
+ coreModules?: Array<{ name: string; path: string; description: string }>;
164
+ risks?: string[];
165
+ };
166
+ task?: {
167
+ type?: 'feat' | 'fix' | 'refactor' | 'test' | 'docs' | 'chore';
168
+ priority?: 'high' | 'medium' | 'low';
169
+ affectedFiles?: string[];
170
+ constraints?: string[];
171
+ };
172
+ }
173
+ ```
90
174
 
91
- ## Commands
175
+ ### 工作流程
92
176
 
93
- | Command | Description |
94
- |---------|-------------|
95
- | `init` | Initialize task flow in current project |
96
- | `extract` | Extract project requirements and generate PRD document |
97
- | `design` | Generate design.md from product-requirement.md |
98
- | `tasks` | Generate tasks.md and PHASE-*.json files |
99
- | `worktree` | Create isolated git worktree |
100
- | `status` | Show current task and phase status |
101
- | `archive` | Archive current task state |
102
- | `merge` | Merge completed worktree back to main |
103
- | `sync` | Sync task execution status to spec |
177
+ ```
178
+ analyze → extract → design → tasks → worktree → implement → review → merge
179
+ │ │ │ │ │
180
+ │ │ │ │ └── 创建隔离 git worktree
181
+ │ │ │ └── 生成 PHASE-*.json 任务文件
182
+ │ │ └── 分析 PRD 生成技术规格(可选)
183
+ │ └── 提取需求生成 PRD 文档
184
+ └── 自动扫描项目结构,生成 context.json 骨架
185
+ ```
104
186
 
105
- ## Configuration
187
+ ## 配置
106
188
 
107
- ### Environment Variables
189
+ ### 环境变量
108
190
 
109
- | Variable | Default | Description |
110
- |----------|---------|-------------|
111
- | `HARNESS_ROOT` | `.harness` | Root directory for harness state |
112
- | `HARNESS_WORKTREES_DIR` | `.worktrees` | Directory for worktree checkouts |
113
- | `HARNESS_CONFIG_FILE` | `.harnessrc` | Path to config file |
114
- | `HARNESS_SPEC_ROOT` | `spec` | Root directory for spec files |
191
+ | 变量 | 默认值 | 说明 |
192
+ |------|--------|------|
193
+ | `HARNESS_ROOT` | `.harness` | Harness 状态根目录 |
194
+ | `HARNESS_WORKTREES_DIR` | `.worktrees` | worktree 检出目录 |
195
+ | `HARNESS_CONFIG_FILE` | `.harnessrc` | 配置文件路径 |
196
+ | `HARNESS_SPEC_ROOT` | `spec` | spec 文件根目录 |
115
197
 
116
- ### Config File (`.harnessrc`)
198
+ ### 配置文件 (`.harnessrc`)
117
199
 
118
200
  ```json
119
201
  {
@@ -123,30 +205,169 @@ This creates:
123
205
  "snapshotsDir": "snapshots",
124
206
  "archiveDir": "archive",
125
207
  "reportsDir": "reports",
126
- "plansDir": "plans",
127
208
  "specRoot": "spec"
128
209
  }
129
210
  ```
130
211
 
131
- ## Directory Structure
212
+ ### Hooks 配置
132
213
 
214
+ 在 `.harness/hooks.json` 中配置生命周期钩子:
215
+
216
+ ```json
217
+ {
218
+ "version": "1.0",
219
+ "hooks": {
220
+ "pre-design": [
221
+ { "name": "check-prd-exists", "script": "src/hooks/check-prd-exists.js", "enabled": true }
222
+ ],
223
+ "pre-worktree": [
224
+ { "name": "check-worktree-conflict", "script": "src/hooks/check-worktree-conflict.js", "enabled": true }
225
+ ],
226
+ "post-task-complete": [
227
+ { "name": "phase-gate-validator", "script": "src/hooks/phase-gate-validator.js", "enabled": true }
228
+ ]
229
+ }
230
+ }
133
231
  ```
134
- spec/
135
- ├── changes/
136
- │ └── <change-name>/
137
- │ ├── product-requirement.md # 产品需求文档(AI 生成)
138
- │ ├── design.md # 技术规格(可选,AI 生成)
139
- │ ├── tasks.md # 任务清单(AI 生成)
140
- │ ├── tasks/ # 多阶段任务 JSON
141
- │ │ ├── PHASE-1-1-1.json
142
- ├── PHASE-1-1-2.json
143
- └── ...
144
- └── manifest.json # 执行配置
145
- ├── skills.json # 技能工具注册(可选)
146
- └── mcp.json # MCP 工具注册(可选)
232
+
233
+ ## 目录结构
234
+
235
+ ### 项目目录
236
+
237
+ ```
238
+ harness-task-flow/
239
+ ├── src/
240
+ │ ├── index.ts # CLI 入口
241
+ ├── commands/ # 命令实现
242
+ │ ├── init.ts
243
+ │ │ ├── extract.ts
244
+ │ │ ├── design.ts
245
+ │ │ ├── tasks.ts
246
+ │ │ ├── worktree.ts
247
+ │ │ ├── status.ts
248
+ │ │ ├── archive.ts
249
+ │ │ ├── merge.ts
250
+ │ │ ├── sync.ts
251
+ │ │ ├── analyze.ts
252
+ │ │ ├── merge/ # 合并命令子模块
253
+ │ │ └── tasks-gen/ # 任务生成子模块
254
+ │ ├── lib/ # 核心工具库
255
+ │ │ ├── config.ts # 配置管理
256
+ │ │ ├── state.ts # 状态管理
257
+ │ │ ├── archive.ts # 归档管理
258
+ │ │ ├── constants.ts # 常量定义
259
+ │ │ ├── interactive.ts # 交互式 CLI
260
+ │ │ └── mcp-client.ts # MCP 客户端
261
+ │ ├── hooks/ # 事件钩子
262
+ │ │ ├── hook-runner/ # Hook 执行引擎
263
+ │ │ ├── check-prd-exists.ts
264
+ │ │ ├── check-worktree-conflict.ts
265
+ │ │ ├── phase-gate-validator.ts
266
+ │ │ ├── phase-complete-detector.ts
267
+ │ │ ├── save-checkpoint.ts
268
+ │ │ ├── start-mcp-servers.ts
269
+ │ │ └── stop-mcp-servers.ts
270
+ │ ├── slash/ # Slash Commands
271
+ │ │ ├── parser.ts
272
+ │ │ ├── registry.ts
273
+ │ │ └── executor.ts
274
+ │ ├── spec/ # Spec 集成
275
+ │ │ ├── openspec-to-task/ # OpenSpec 转换
276
+ │ │ ├── sync-openspec-to-task.ts
277
+ │ │ └── sync-task-to-openspec.ts
278
+ │ └── types/ # 类型定义
279
+ │ └── ai-context.ts
280
+ ├── assets/ # 文件模板
281
+ │ ├── schema.json # 任务 JSON Schema
282
+ │ ├── product-requirement.md # PRD 模板
283
+ │ ├── design.md # 技术规格模板
284
+ │ ├── tasks.md # 任务清单模板
285
+ │ ├── PHASE-task.json.example # 任务 JSON 示例
286
+ │ ├── hooks.json # Hooks 配置示例
287
+ │ └── .harnessrc # 配置文件示例
288
+ ├── tests/ # 测试文件
289
+ ├── references/ # 参考文档
290
+ │ ├── CLI-TUTORIAL.md
291
+ │ ├── AI-CONVERSATION-TUTORIAL.md
292
+ │ └── GIT-WORKTREE-SOP.md
293
+ ├── SKILL.md # Skill 文档
294
+ └── package.json
295
+ ```
296
+
297
+ ### 运行时目录
298
+
299
+ ```
300
+ project/
301
+ ├── .harness/ # Harness 运行时目录
302
+ │ ├── state.json # 当前运行状态
303
+ │ ├── hooks.json # Hooks 配置
304
+ │ ├── skills.json # 技能工具注册(可选)
305
+ │ ├── mcp.json # MCP 服务器注册(可选)
306
+ │ └── archive/ # 归档目录
307
+ ├── spec/ # 规格文档目录
308
+ │ └── changes/ # 变更提案目录
309
+ │ └── <change-name>/ # 具体变更
310
+ │ ├── product-requirement.md # 产品需求文档
311
+ │ ├── design.md # 技术规格(可选)
312
+ │ ├── tasks.md # 任务清单
313
+ │ ├── tasks/ # 多阶段任务 JSON
314
+ │ │ ├── PHASE-1-1-1.json
315
+ │ │ ├── PHASE-1-1-2.json
316
+ │ │ └── ...
317
+ │ └── manifest.json # 执行配置清单
318
+ └── .worktrees/ # Git worktree 目录
319
+ └── harness-feat-<name>/ # 隔离工作区
147
320
  ```
148
321
 
149
- ## Tool Registration
322
+ ## 任务文件格式
323
+
324
+ PHASE-*.json 任务文件遵循标准 Schema:
325
+
326
+ ```json
327
+ {
328
+ "id": "PHASE-1-1-1",
329
+ "type": "feat",
330
+ "title": "实现用户认证",
331
+ "priority": "high",
332
+ "phase": 1,
333
+ "dependencies": [],
334
+ "docs_to_read": ["spec/changes/my-feature/design.md"],
335
+ "spec": {
336
+ "description": "实现基于 JWT 的用户认证系统",
337
+ "files": ["src/auth/jwt.ts", "src/auth/middleware.ts"],
338
+ "context": ["spec/changes/my-feature/product-requirement.md"]
339
+ },
340
+ "acceptance_criteria": [
341
+ "用户可以登录并获取 JWT token",
342
+ "受保护的路由需要验证 token",
343
+ "token 过期后自动刷新"
344
+ ],
345
+ "implementation": {
346
+ "steps": [
347
+ { "step": "安装依赖", "details": "npm install jsonwebtoken" },
348
+ { "step": "实现 JWT 工具函数", "details": "创建 sign 和 verify 函数" },
349
+ { "step": "实现认证中间件", "details": "验证 token 并注入用户信息" }
350
+ ],
351
+ "notes": "使用 RS256 算法"
352
+ },
353
+ "validation": {
354
+ "commands": [
355
+ "pnpm build",
356
+ "pnpm test",
357
+ "pnpm lint"
358
+ ],
359
+ "manual_checks": [
360
+ "验证登录流程正常",
361
+ "检查 token 刷新机制"
362
+ ]
363
+ },
364
+ "status": "pending"
365
+ }
366
+ ```
367
+
368
+ 完整 Schema 定义见 [assets/schema.json](assets/schema.json)。
369
+
370
+ ## 工具注册
150
371
 
151
372
  ### skills.json
152
373
 
@@ -181,72 +402,45 @@ spec/
181
402
  }
182
403
  ```
183
404
 
184
- ## Workflow
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
405
+ ## 开发
233
406
 
234
407
  ```bash
235
- # Install dependencies
408
+ # 安装依赖
236
409
  pnpm install
237
410
 
238
- # Run tests
411
+ # 运行测试
239
412
  pnpm test
240
413
 
241
- # Lint
414
+ # 代码检查
242
415
  pnpm lint
416
+
417
+ # 类型检查
418
+ pnpm typecheck
419
+
420
+ # 构建
421
+ pnpm build
422
+
423
+ # 监听模式构建
424
+ pnpm build:watch
425
+
426
+ # 发布(使用 changesets)
427
+ pnpm changeset
428
+ pnpm version
429
+ pnpm release
243
430
  ```
244
431
 
245
- ## License
432
+ ## 文档
433
+
434
+ - [CLI 使用教程](references/CLI-TUTORIAL.md) - 人类开发者如何使用 CLI 命令
435
+ - [AI 对话教程](references/AI-CONVERSATION-TUTORIAL.md) - 如何通过 AI 对话完成任务
436
+ - [Git Worktree SOP](references/GIT-WORKTREE-SOP.md) - Git worktree 使用规范
437
+
438
+ ## 许可证
246
439
 
247
- MIT License - See LICENSE file for details.
440
+ MIT License - 详见 [LICENSE](LICENSE) 文件
248
441
 
249
- ## Links
442
+ ## 链接
250
443
 
251
444
  - [Agent Skills Specification](https://agentskills.io/specification)
252
- - [Task Flow](https://github.com/didengren/harness-task-flow)
445
+ - [GitHub Repository](https://github.com/didengren/harness-task-flow)
446
+ - [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
 
package/assets/.harnessrc CHANGED
@@ -5,6 +5,5 @@
5
5
  "snapshotsDir": "snapshots",
6
6
  "archiveDir": "archive",
7
7
  "reportsDir": "reports",
8
- "plansDir": "plans",
9
8
  "specRoot": "spec"
10
9
  }
@@ -109,7 +109,6 @@ function initHarness(options = {}) {
109
109
  snapshotsDir: 'snapshots',
110
110
  archiveDir: 'archive',
111
111
  reportsDir: 'reports',
112
- plansDir: 'plans',
113
112
  specRoot: 'spec',
114
113
  };
115
114
  try {
@@ -21,7 +21,6 @@ export interface Config {
21
21
  snapshotsDir?: string;
22
22
  archiveDir?: string;
23
23
  reportsDir?: string;
24
- plansDir?: string;
25
24
  specRoot?: string;
26
25
  configFile?: string;
27
26
  harnessRootAbs?: string;
@@ -30,7 +29,6 @@ export interface Config {
30
29
  snapshotsDirAbs?: string;
31
30
  archiveDirAbs?: string;
32
31
  reportsDirAbs?: string;
33
- plansDirAbs?: string;
34
32
  specRootAbs?: string;
35
33
  projectRoot?: string;
36
34
  configPath?: string;
@@ -62,7 +62,6 @@ exports.DEFAULTS = {
62
62
  snapshotsDir: 'snapshots',
63
63
  archiveDir: 'archive',
64
64
  reportsDir: 'reports',
65
- plansDir: 'plans',
66
65
  specRoot: 'spec',
67
66
  };
68
67
  /**
@@ -75,7 +74,6 @@ const ENV_MAPPING = {
75
74
  HARNESS_SNAPSHOTS_DIR: 'snapshotsDir',
76
75
  HARNESS_ARCHIVE_DIR: 'archiveDir',
77
76
  HARNESS_REPORTS_DIR: 'reportsDir',
78
- HARNESS_PLANS_DIR: 'plansDir',
79
77
  HARNESS_SPEC_ROOT: 'specRoot',
80
78
  HARNESS_CONFIG_FILE: 'configFile',
81
79
  };
@@ -190,7 +188,7 @@ function loadConfig(options = {}) {
190
188
  ...envConfig,
191
189
  };
192
190
  // Resolve all paths to absolute
193
- const pathKeys = ['harnessRoot', 'worktreesDir', 'tasksDir', 'snapshotsDir', 'archiveDir', 'reportsDir', 'plansDir', 'specRoot'];
191
+ const pathKeys = ['harnessRoot', 'worktreesDir', 'tasksDir', 'snapshotsDir', 'archiveDir', 'reportsDir', 'specRoot'];
194
192
  for (const key of pathKeys) {
195
193
  const value = config[key];
196
194
  if (typeof value === 'string') {
@@ -204,7 +202,6 @@ function loadConfig(options = {}) {
204
202
  config.snapshotsDirAbs = resolvePath(config.snapshotsDir, config.harnessRootAbs);
205
203
  config.archiveDirAbs = resolvePath(config.archiveDir, config.harnessRootAbs);
206
204
  config.reportsDirAbs = resolvePath(config.reportsDir, config.harnessRootAbs);
207
- config.plansDirAbs = resolvePath(config.plansDir, config.harnessRootAbs);
208
205
  config.worktreesDirAbs = resolvePath(config.worktreesDir, projectRoot);
209
206
  config.specRootAbs = resolvePath(config.specRoot, projectRoot);
210
207
  // Add metadata
@@ -240,7 +237,6 @@ function ensureDirectories(config) {
240
237
  config.snapshotsDirAbs,
241
238
  config.archiveDirAbs,
242
239
  config.reportsDirAbs,
243
- config.plansDirAbs,
244
240
  config.worktreesDirAbs,
245
241
  ];
246
242
  for (const dir of dirs) {
@@ -4,8 +4,43 @@
4
4
  * Execute slash commands by dispatching to the appropriate command modules.
5
5
  * Supports both single commands and composite (multi-step) commands.
6
6
  */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
7
40
  Object.defineProperty(exports, "__esModule", { value: true });
8
41
  exports.executeSlashCommand = executeSlashCommand;
42
+ const fs = __importStar(require("fs"));
43
+ const path = __importStar(require("path"));
9
44
  const registry_1 = require("./registry");
10
45
  const extract_1 = require("../commands/extract");
11
46
  const design_1 = require("../commands/design");
@@ -16,6 +51,8 @@ const status_1 = require("../commands/status");
16
51
  const archive_1 = require("../lib/archive");
17
52
  const merge_1 = require("../commands/merge");
18
53
  const sync_task_to_openspec_1 = require("../spec/sync-task-to-openspec");
54
+ const analyze_1 = require("../commands/analyze");
55
+ const config_1 = require("../lib/config");
19
56
  function extractChangeName(parsed) {
20
57
  const firstArg = parsed.args[0];
21
58
  if (firstArg && !firstArg.startsWith('--')) {
@@ -50,7 +87,8 @@ function extractFlagValue(parsed, flag) {
50
87
  function hasFlag(parsed, flag) {
51
88
  return parsed.args.includes(`--${flag}`) || parsed.args.includes(`-${flag}`);
52
89
  }
53
- async function executeSingleCommand(commandName, changeName, taskId, parsed) {
90
+ async function executeSingleCommand(commandName, changeName, taskId, parsed, extraContextFile) {
91
+ const contextFile = extractFlagValue(parsed, 'context-file') || extraContextFile;
54
92
  switch (commandName) {
55
93
  case 'extract': {
56
94
  if (!changeName) {
@@ -59,7 +97,7 @@ async function executeSingleCommand(commandName, changeName, taskId, parsed) {
59
97
  const result = await (0, extract_1.extract)({
60
98
  change: changeName,
61
99
  force: hasFlag(parsed, 'force'),
62
- contextFile: extractFlagValue(parsed, 'context-file'),
100
+ contextFile,
63
101
  });
64
102
  return {
65
103
  step: 'extract',
@@ -76,7 +114,7 @@ async function executeSingleCommand(commandName, changeName, taskId, parsed) {
76
114
  change: changeName,
77
115
  force: hasFlag(parsed, 'force'),
78
116
  skipPrompt: true,
79
- contextFile: extractFlagValue(parsed, 'context-file'),
117
+ contextFile,
80
118
  });
81
119
  return {
82
120
  step: 'design',
@@ -179,15 +217,84 @@ async function executeSingleCommand(commandName, changeName, taskId, parsed) {
179
217
  return { step: commandName, success: false, message: `Unknown command: ${commandName}` };
180
218
  }
181
219
  }
220
+ function findExistingContextFile(projectRoot) {
221
+ const candidatePaths = [
222
+ path.resolve(projectRoot, 'context.json'),
223
+ path.resolve(projectRoot, '.harness', 'context.json'),
224
+ path.resolve(projectRoot, '.tmp', 'context.json'),
225
+ ];
226
+ for (const p of candidatePaths) {
227
+ if (fs.existsSync(p)) {
228
+ return p;
229
+ }
230
+ }
231
+ return null;
232
+ }
233
+ function generateTempContextFile(projectRoot) {
234
+ const tmpDir = path.resolve(projectRoot, '.tmp');
235
+ if (!fs.existsSync(tmpDir)) {
236
+ fs.mkdirSync(tmpDir, { recursive: true });
237
+ }
238
+ const contextPath = path.resolve(tmpDir, 'context.json');
239
+ const result = (0, analyze_1.analyzeProject)({ cwd: projectRoot, output: contextPath });
240
+ if (!result.success || !result.outputPath) {
241
+ throw new Error(`Failed to generate context: ${result.message}`);
242
+ }
243
+ return result.outputPath;
244
+ }
182
245
  async function executeCompositeCommand(cmdDef, changeName, taskId, parsed) {
183
246
  const steps = cmdDef.steps || [];
184
247
  const stepResults = [];
248
+ let contextFile;
185
249
  console.log(`[SLASH] Executing composite command: /tf:${cmdDef.name}`);
186
250
  console.log(`[SLASH] Steps: ${steps.join(' → ')}`);
187
251
  console.log('');
252
+ if (cmdDef.name === 'propose') {
253
+ const explicitContextFile = extractFlagValue(parsed, 'context-file');
254
+ if (explicitContextFile) {
255
+ console.log(`[SLASH] ✓ Using explicit context: ${explicitContextFile}`);
256
+ contextFile = explicitContextFile;
257
+ }
258
+ else {
259
+ const config = (0, config_1.loadConfig)({});
260
+ const projectRoot = config.projectRoot || process.cwd();
261
+ const existingContext = findExistingContextFile(projectRoot);
262
+ if (existingContext) {
263
+ console.log(`[SLASH] ✓ Using existing context: ${existingContext}`);
264
+ contextFile = existingContext;
265
+ }
266
+ else {
267
+ console.log('[SLASH] → Step: analyze (auto)');
268
+ try {
269
+ contextFile = generateTempContextFile(projectRoot);
270
+ console.log(`[SLASH] ✓ analyze: Context generated at ${contextFile}`);
271
+ stepResults.push({
272
+ step: 'analyze',
273
+ success: true,
274
+ message: `Context generated: ${contextFile}`,
275
+ detail: { contextPath: contextFile },
276
+ });
277
+ }
278
+ catch (error) {
279
+ const errorMsg = error instanceof Error ? error.message : 'Unknown error';
280
+ console.log(`[SLASH] ✗ analyze: ${errorMsg}`);
281
+ return {
282
+ success: false,
283
+ command: cmdDef.name,
284
+ changeName,
285
+ taskId,
286
+ steps: stepResults,
287
+ message: `Failed to generate context: ${errorMsg}`,
288
+ error: errorMsg,
289
+ };
290
+ }
291
+ console.log('');
292
+ }
293
+ }
294
+ }
188
295
  for (const step of steps) {
189
296
  console.log(`[SLASH] → Step: ${step}`);
190
- const result = await executeSingleCommand(step, changeName, taskId, parsed);
297
+ const result = await executeSingleCommand(step, changeName, taskId, parsed, contextFile);
191
298
  stepResults.push(result);
192
299
  if (result.success) {
193
300
  console.log(`[SLASH] ✓ ${step}: ${result.message || 'OK'}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bicorne/task-flow",
3
- "version": "0.1.0",
4
- "description": "Git worktree-based parallel task execution system for zero-conflict multi-task development",
3
+ "version": "0.2.0",
4
+ "description": "Harness Engineering tool for requirements analysis and task decomposition. AI-driven PRD generation, technical specs, and multi-phase task planning with zero-conflict parallel development via Git worktree.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
7
7
  "main": "./dist/index.js",