@devcxl/opencode-cabbage 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 +57 -54
- package/README.zh.md +91 -0
- package/assets/agents/dev-lifecycle.md +23 -15
- package/assets/agents/team/backend.md +8 -0
- package/assets/agents/team/frontend.md +8 -0
- package/assets/agents/team/reviewer.md +29 -13
- package/assets/skills/flow-code/SKILL.md +78 -9
- package/assets/skills/flow-design/SKILL.md +55 -6
- package/assets/skills/flow-handoff/SKILL.md +29 -0
- package/assets/skills/flow-release/SKILL.md +37 -1
- package/assets/skills/flow-requirements/SKILL.md +34 -0
- package/assets/skills/flow-review/SKILL.md +76 -5
- package/assets/skills/flow-setup/SKILL.md +32 -0
- package/assets/skills/flow-tasks/SKILL.md +43 -3
- package/assets/skills/flow-test/SKILL.md +31 -0
- package/dist/plugin/agents.d.ts +10 -0
- package/dist/plugin/agents.js +13 -0
- package/dist/plugin/agents.js.map +1 -1
- package/dist/plugin/goal.js +8 -2
- package/dist/plugin/goal.js.map +1 -1
- package/dist/plugin/prompt-lint.d.ts +10 -0
- package/dist/plugin/prompt-lint.js +160 -0
- package/dist/plugin/prompt-lint.js.map +1 -0
- package/dist/plugin/server.d.ts +8 -0
- package/dist/plugin/server.js +18 -3
- package/dist/plugin/server.js.map +1 -1
- package/dist/plugin/skills.d.ts +1 -1
- package/dist/plugin/skills.js +7 -1
- package/dist/plugin/skills.js.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>@devcxl/opencode-cabbage</h1>
|
|
3
|
+
<p>A full-lifecycle development plugin for OpenCode, covering requirements, design, tasks, coding, testing, review, and release with automated orchestration and parallel subagents.</p>
|
|
4
|
+
<p>
|
|
5
|
+
<a href="https://www.npmjs.com/package/@devcxl/opencode-cabbage"><img src="https://img.shields.io/npm/v/@devcxl/opencode-cabbage" alt="npm version"></a>
|
|
6
|
+
<a href="https://github.com/devcxl/opencode-cabbage/actions/workflows/ci.yml"><img src="https://github.com/devcxl/opencode-cabbage/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
|
|
7
|
+
<a href="https://devcxl.github.io/opencode-cabbage"><img src="https://github.com/devcxl/opencode-cabbage/actions/workflows/pages.yml/badge.svg?branch=main" alt="GitHub Pages"></a>
|
|
8
|
+
</p>
|
|
9
|
+
<p>English | <a href="README.zh.md">简体中文</a></p>
|
|
10
|
+
</div>
|
|
8
11
|
|
|
9
12
|
---
|
|
10
13
|
|
|
11
|
-
##
|
|
14
|
+
## Installation
|
|
12
15
|
|
|
13
16
|
```json
|
|
14
17
|
// opencode.json
|
|
@@ -17,72 +20,72 @@
|
|
|
17
20
|
}
|
|
18
21
|
```
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
Once started, the plugin automatically injects 9 slash commands, 9 flow skills, and 5 agents.
|
|
21
24
|
|
|
22
|
-
##
|
|
25
|
+
## Command Overview
|
|
23
26
|
|
|
24
|
-
|
|
|
25
|
-
|
|
26
|
-
| `/setup` |
|
|
27
|
-
| `/requirements` |
|
|
28
|
-
| `/design` |
|
|
29
|
-
| `/tasks` |
|
|
30
|
-
| `/code` |
|
|
31
|
-
| `/test` |
|
|
32
|
-
| `/review` |
|
|
33
|
-
| `/release` | ⚠️
|
|
34
|
-
| `/handoff` |
|
|
27
|
+
| Command | Stage | Output |
|
|
28
|
+
|---------|-------|--------|
|
|
29
|
+
| `/setup` | Setup | `docs/` directory structure and environment validation |
|
|
30
|
+
| `/requirements` | Requirements | PRD → `docs/prd/` + GitHub Issue |
|
|
31
|
+
| `/design` | Design | Technical specification + ADR → `docs/dev/specs/` + `docs/adr/` |
|
|
32
|
+
| `/tasks` | Task decomposition | DAG tasks + Sub Issues → `docs/dev/tasks/` |
|
|
33
|
+
| `/code` | Coding | Branch + code + unit tests + PR |
|
|
34
|
+
| `/test` | Testing | Trigger CI + monitor + report |
|
|
35
|
+
| `/review` | Review | Dual-axis review + automatic merge |
|
|
36
|
+
| `/release` | ⚠️ Manual release | Version → Changelog → Release → npm publish |
|
|
37
|
+
| `/handoff` | Handoff | Package context for transfer across sessions |
|
|
35
38
|
|
|
36
|
-
##
|
|
39
|
+
## Quick Start
|
|
37
40
|
|
|
38
41
|
```bash
|
|
39
|
-
# 1.
|
|
42
|
+
# 1. Install
|
|
40
43
|
npm install @devcxl/opencode-cabbage
|
|
41
44
|
|
|
42
|
-
# 2.
|
|
45
|
+
# 2. Add the plugin to opencode.json
|
|
43
46
|
# { "plugin": ["@devcxl/opencode-cabbage"] }
|
|
44
47
|
|
|
45
|
-
# 3.
|
|
48
|
+
# 3. Run in OpenCode
|
|
46
49
|
# /setup → /requirements → @dev-lifecycle
|
|
47
50
|
```
|
|
48
51
|
|
|
49
|
-
##
|
|
52
|
+
## Two Modes
|
|
50
53
|
|
|
51
|
-
-
|
|
52
|
-
-
|
|
54
|
+
- **Manual mode** — Run each command sequentially for fine-grained control
|
|
55
|
+
- **Automatic mode** — Once the requirements are confirmed, enter `@dev-lifecycle` to automatically complete the remaining workflow
|
|
53
56
|
|
|
54
|
-
##
|
|
57
|
+
## Architecture
|
|
55
58
|
|
|
56
59
|
```
|
|
57
|
-
src/ # TypeScript
|
|
58
|
-
├── index.ts #
|
|
59
|
-
├── plugin.ts #
|
|
60
|
+
src/ # Thin TypeScript layer
|
|
61
|
+
├── index.ts # Plugin entry point
|
|
62
|
+
├── plugin.ts # Package root resolution
|
|
60
63
|
└── plugin/
|
|
61
|
-
├── server.ts #
|
|
62
|
-
├── commands.ts # Command
|
|
63
|
-
├── skills.ts # Skill
|
|
64
|
-
├── prompts.ts # Prompt
|
|
65
|
-
├── bootstrap.ts #
|
|
66
|
-
└── agents.ts # Agent
|
|
67
|
-
|
|
68
|
-
assets/ #
|
|
69
|
-
├── commands/ # 9
|
|
70
|
-
├── skills/ # 9
|
|
71
|
-
├── agents/ # 5
|
|
72
|
-
├── context/ #
|
|
73
|
-
└── prompts/ #
|
|
64
|
+
├── server.ts # Main factory: injects skills, commands, and agents
|
|
65
|
+
├── commands.ts # Command loader
|
|
66
|
+
├── skills.ts # Skill loader
|
|
67
|
+
├── prompts.ts # Prompt loader
|
|
68
|
+
├── bootstrap.ts # Startup guidance
|
|
69
|
+
└── agents.ts # Agent injection
|
|
70
|
+
|
|
71
|
+
assets/ # Runtime assets
|
|
72
|
+
├── commands/ # 9 slash commands
|
|
73
|
+
├── skills/ # 9 flow-* skills
|
|
74
|
+
├── agents/ # 5 agent definitions
|
|
75
|
+
├── context/ # Domain glossary
|
|
76
|
+
└── prompts/ # Guidance prompts and templates
|
|
74
77
|
```
|
|
75
78
|
|
|
76
|
-
##
|
|
79
|
+
## Documentation
|
|
77
80
|
|
|
78
|
-
|
|
|
79
|
-
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
81
|
+
| Document | Link |
|
|
82
|
+
|----------|------|
|
|
83
|
+
| Quick Start | [docs/guides/quickstart.md](docs/guides/quickstart.md) |
|
|
84
|
+
| Configuration Guide | [docs/guides/configuration.md](docs/guides/configuration.md) |
|
|
85
|
+
| Usage Guide | [docs/guides/usage.md](docs/guides/usage.md) |
|
|
86
|
+
| Architecture Overview | [docs/guides/architecture.md](docs/guides/architecture.md) |
|
|
87
|
+
| Contributing Guide | [docs/dev/guides/contributing.md](docs/dev/guides/contributing.md) |
|
|
85
88
|
|
|
86
|
-
##
|
|
89
|
+
## License
|
|
87
90
|
|
|
88
91
|
MIT
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>@devcxl/opencode-cabbage</h1>
|
|
3
|
+
<p>全流程开发 OpenCode 插件 — 覆盖需求、设计、任务、编码、测试、审查和发布完整开发生命周期,支持自动编排与并行 Subagent。</p>
|
|
4
|
+
<p>
|
|
5
|
+
<a href="https://www.npmjs.com/package/@devcxl/opencode-cabbage"><img src="https://img.shields.io/npm/v/@devcxl/opencode-cabbage" alt="npm version"></a>
|
|
6
|
+
<a href="https://github.com/devcxl/opencode-cabbage/actions/workflows/ci.yml"><img src="https://github.com/devcxl/opencode-cabbage/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
|
|
7
|
+
<a href="https://devcxl.github.io/opencode-cabbage"><img src="https://github.com/devcxl/opencode-cabbage/actions/workflows/pages.yml/badge.svg?branch=main" alt="GitHub Pages"></a>
|
|
8
|
+
</p>
|
|
9
|
+
<p><a href="README.md">English</a> | 简体中文</p>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
// opencode.json
|
|
18
|
+
{
|
|
19
|
+
"plugin": ["@devcxl/opencode-cabbage"]
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
插件启动后自动注入 9 个 slash command、9 个 flow skill、5 个 agent。
|
|
24
|
+
|
|
25
|
+
## 命令一览
|
|
26
|
+
|
|
27
|
+
| 命令 | 阶段 | 产出 |
|
|
28
|
+
|------|------|------|
|
|
29
|
+
| `/setup` | 初始化 | `docs/` 目录结构、环境验证 |
|
|
30
|
+
| `/requirements` | 需求 | PRD → `docs/prd/` + GitHub Issue |
|
|
31
|
+
| `/design` | 设计 | 技术方案 + ADR → `docs/dev/specs/` + `docs/adr/` |
|
|
32
|
+
| `/tasks` | 任务拆解 | DAG 任务 + Sub Issues → `docs/dev/tasks/` |
|
|
33
|
+
| `/code` | 编码 | 分支 + 代码 + 单测 + PR |
|
|
34
|
+
| `/test` | 测试 | 触发 CI + 监控 + 汇报 |
|
|
35
|
+
| `/review` | 审查 | 双轴审查 + 自动合并 |
|
|
36
|
+
| `/release` | ⚠️ 手动发布 | 版本 → Changelog → Release → npm publish |
|
|
37
|
+
| `/handoff` | 交接 | 打包上下文,跨会话传递 |
|
|
38
|
+
|
|
39
|
+
## 快速开始
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 1. 安装
|
|
43
|
+
npm install @devcxl/opencode-cabbage
|
|
44
|
+
|
|
45
|
+
# 2. 在 opencode.json 中添加
|
|
46
|
+
# { "plugin": ["@devcxl/opencode-cabbage"] }
|
|
47
|
+
|
|
48
|
+
# 3. 在 OpenCode 中执行
|
|
49
|
+
# /setup → /requirements → @dev-lifecycle
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 两种模式
|
|
53
|
+
|
|
54
|
+
- **手动模式** — 按顺序逐一执行命令,适合精细控制
|
|
55
|
+
- **自动模式** — 需求确认后输入 `@dev-lifecycle`,全自动完成剩余流程
|
|
56
|
+
|
|
57
|
+
## 架构
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
src/ # TypeScript 薄层
|
|
61
|
+
├── index.ts # 插件入口
|
|
62
|
+
├── plugin.ts # 包路径解析
|
|
63
|
+
└── plugin/
|
|
64
|
+
├── server.ts # 主工厂:注入 skills/commands/agents
|
|
65
|
+
├── commands.ts # Command 加载器
|
|
66
|
+
├── skills.ts # Skill 加载器
|
|
67
|
+
├── prompts.ts # Prompt 加载器
|
|
68
|
+
├── bootstrap.ts # 启动引导
|
|
69
|
+
└── agents.ts # Agent 注入
|
|
70
|
+
|
|
71
|
+
assets/ # 运行时资源
|
|
72
|
+
├── commands/ # 9 个 slash command
|
|
73
|
+
├── skills/ # 9 个 flow-* skill
|
|
74
|
+
├── agents/ # 5 个 agent 定义
|
|
75
|
+
├── context/ # 领域词汇表
|
|
76
|
+
└── prompts/ # 引导提示词 + 模板
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 文档
|
|
80
|
+
|
|
81
|
+
| 文档 | 链接 |
|
|
82
|
+
|------|------|
|
|
83
|
+
| 快速开始 | [docs/guides/quickstart.md](docs/guides/quickstart.md) |
|
|
84
|
+
| 配置指南 | [docs/guides/configuration.md](docs/guides/configuration.md) |
|
|
85
|
+
| 使用指南 | [docs/guides/usage.md](docs/guides/usage.md) |
|
|
86
|
+
| 架构概览 | [docs/guides/architecture.md](docs/guides/architecture.md) |
|
|
87
|
+
| 贡献指南 | [docs/dev/guides/contributing.md](docs/dev/guides/contributing.md) |
|
|
88
|
+
|
|
89
|
+
## 许可
|
|
90
|
+
|
|
91
|
+
MIT
|
|
@@ -20,14 +20,15 @@ color: '#00bcd4'
|
|
|
20
20
|
1. 首先调用 `goal({op:"create", objective:"<一句话描述>", completion_criterion:"所有阶段完成的标准"})`
|
|
21
21
|
2. 然后按下方 Phase 顺序执行
|
|
22
22
|
3. 每个阶段完成后,Plugin 会自动 continuation,进入下一阶段
|
|
23
|
-
4.
|
|
23
|
+
4. 最终全部完成后,直接使用 Task 工具派发 `@goal-verify` 做独立验证
|
|
24
24
|
|
|
25
25
|
## 调度团队
|
|
26
26
|
|
|
27
27
|
- @architect:技术方案、ADR、DAG 任务拆解
|
|
28
|
-
- @backend:后端代码 TDD
|
|
29
|
-
- @frontend:前端代码 TDD
|
|
30
|
-
- @reviewer
|
|
28
|
+
- @backend:后端代码 TDD 实现(编码 + 测试 + commit + push,不创建 PR)
|
|
29
|
+
- @frontend:前端代码 TDD 实现(编码 + 测试 + commit + push,不创建 PR)
|
|
30
|
+
- @reviewer:只读代码审查,输出结构化审查报告(不操作 git/GitHub,不写文件)
|
|
31
|
+
- @goal-verify:独立验证 Goal 完成状态(**只有它可以调用 goal({op:"complete"})**)
|
|
31
32
|
|
|
32
33
|
## 全局约束
|
|
33
34
|
|
|
@@ -77,22 +78,28 @@ color: '#00bcd4'
|
|
|
77
78
|
For each batch:
|
|
78
79
|
For each task in batch (可并行):
|
|
79
80
|
0. 安全检查:提交设计阶段可能遗留的未提交文档
|
|
81
|
+
BASE=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')
|
|
80
82
|
if [ -n "$(git status --short docs/)" ]; then
|
|
81
83
|
git add docs/ && git commit -m "docs: 提交设计阶段未提交的文档"
|
|
82
|
-
git push origin
|
|
84
|
+
git push origin $BASE
|
|
83
85
|
fi
|
|
84
86
|
1. 检查 worktree 是否存在
|
|
85
|
-
- 不存在 → git worktree add
|
|
86
|
-
-
|
|
87
|
+
- 不存在 → git worktree add -b feat/<task-slug> .worktree/<task-slug> $BASE
|
|
88
|
+
- 存在 → 验证分支一致,一致则复用,不一致则报错
|
|
87
89
|
2. 并行派发 @backend/@frontend 到各 worktree 路径
|
|
88
|
-
3. 每个 agent 在 worktree
|
|
90
|
+
3. 每个 agent 在 worktree 内(不创建 PR):
|
|
89
91
|
- npm install(如未安装)
|
|
90
92
|
- 编码 + 单测
|
|
91
|
-
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
- commit + push
|
|
94
|
+
- 返回 branch、commit、test result
|
|
95
|
+
4. 编排器(你)为每个完成的 task 创建 PR:
|
|
96
|
+
gh pr create --title "<title>" --body "Closes #<issue-num>"
|
|
97
|
+
5. 等待 batch 内所有 PR 就绪
|
|
98
|
+
6. 委派 @reviewer 审查各 PR,接收结构化审查报告
|
|
99
|
+
7. 编排器发布审查结果:
|
|
100
|
+
gh pr review <pr-number> --approve|--request-changes --body "<报告>"
|
|
101
|
+
8. CI 通过后合并 PR
|
|
102
|
+
9. 合并后清理 worktree
|
|
96
103
|
|
|
97
104
|
串行 task(有依赖关系)使用清理后重建策略:
|
|
98
105
|
上一 task 合并 → git worktree remove → git worktree add 新 task
|
|
@@ -102,6 +109,7 @@ For each batch:
|
|
|
102
109
|
- 并行 task 使用不同分支名 `feat/<task-slug>`,避免 `git worktree add` 的分支冲突
|
|
103
110
|
- 每个 agent 启动时显式 `cd .worktree/<task-slug>` 并验证 `pwd`
|
|
104
111
|
- 分支冲突时暂停并提示用户手动清理
|
|
112
|
+
- @backend / @frontend 不创建 PR、不操作 Issue — 编排器负责所有 GitHub 操作
|
|
105
113
|
|
|
106
114
|
---
|
|
107
115
|
|
|
@@ -120,9 +128,9 @@ For each batch:
|
|
|
120
128
|
|
|
121
129
|
## 完成
|
|
122
130
|
|
|
123
|
-
|
|
131
|
+
所有阶段完成后,直接使用 Task 工具派发 `@goal-verify` 子 agent 做独立验证。
|
|
124
132
|
|
|
125
|
-
|
|
133
|
+
无需先调用 `goal({op:"complete"})`。主会话不能自行完成 Goal,只有 goal-verify 验证通过后可以完成。
|
|
126
134
|
|
|
127
135
|
---
|
|
128
136
|
|
|
@@ -8,35 +8,47 @@ tools:
|
|
|
8
8
|
bash: false
|
|
9
9
|
write: false
|
|
10
10
|
edit: false
|
|
11
|
+
capabilities:
|
|
12
|
+
create_pr: false
|
|
13
|
+
merge_pr: false
|
|
14
|
+
modify_files: false
|
|
15
|
+
run_tests: false
|
|
16
|
+
push_branch: false
|
|
17
|
+
approve_review: false
|
|
18
|
+
complete_goal: false
|
|
11
19
|
---
|
|
12
20
|
|
|
13
21
|
<system-reminder>
|
|
14
22
|
你是团队中的 @reviewer,负责代码审查和质量把关。
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
你是一个**只读**审查者:
|
|
25
|
+
- 你可以读取代码、PR diff、文档和规格
|
|
26
|
+
- 你**不执行** git push、gh pr merge、gh pr review、gh pr close
|
|
27
|
+
- 你**不写**任何文件
|
|
28
|
+
- 你**不调用** goal({op:"complete"}) — 只有 goal-verify 可以完成 Goal
|
|
17
29
|
|
|
18
|
-
|
|
19
|
-
1. 先调用 `goal({op:"get"})` 获取目标
|
|
20
|
-
2. 然后按下方流程审查
|
|
21
|
-
3. 如果全部通过,调用 `goal({op:"complete"})` 完成验证
|
|
22
|
-
4. 只有你可以调用 complete,主 agent 被 BLOCKED
|
|
30
|
+
你的职责是输出结构化审查报告,由编排器使用你的报告执行后续操作。
|
|
23
31
|
</system-reminder>
|
|
24
32
|
|
|
25
33
|
## 审查流程
|
|
26
34
|
|
|
27
35
|
### 1. 获取变更
|
|
28
|
-
|
|
29
|
-
gh pr diff <pr-number>
|
|
30
|
-
gh pr view <pr-number> --json title,body,files
|
|
31
|
-
```
|
|
36
|
+
查阅 PR diff 和元数据,了解变更范围。
|
|
32
37
|
|
|
33
38
|
### 2. 双轴审查
|
|
34
39
|
- **规范轴**:代码是否符合编码标准?参考代码气味基线
|
|
35
40
|
- **规格轴**:代码是否忠实实现了 PRD/技术方案?
|
|
36
41
|
|
|
37
42
|
### 3. 输出审查报告
|
|
43
|
+
以结构化文本返回审查结论:
|
|
38
44
|
|
|
39
45
|
```
|
|
46
|
+
## 审查结论: APPROVED | CHANGES_REQUESTED
|
|
47
|
+
|
|
48
|
+
### 审查摘要
|
|
49
|
+
...
|
|
50
|
+
|
|
51
|
+
### 发现
|
|
40
52
|
[CRITICAL] 标题 - 必须修复
|
|
41
53
|
- 文件:path:行号
|
|
42
54
|
- 问题
|
|
@@ -44,11 +56,15 @@ gh pr view <pr-number> --json title,body,files
|
|
|
44
56
|
|
|
45
57
|
[HIGH] 标题 - 应该修复
|
|
46
58
|
[MEDIUM] 标题 - 建议修复
|
|
59
|
+
|
|
60
|
+
### 规范轴
|
|
61
|
+
...
|
|
62
|
+
|
|
63
|
+
### 规格轴
|
|
64
|
+
...
|
|
47
65
|
```
|
|
48
66
|
|
|
49
|
-
|
|
50
|
-
- Critical/High 存在 → 先将审查报告写入 `docs/dev/handoff/review-report.md`,然后 `gh pr review <pr-number> --request-changes --body-file docs/dev/handoff/review-report.md`,**不可调 goal({op:"complete"})**
|
|
51
|
-
- 无 Critical/High → 写入 `docs/dev/handoff/review-report.md` 后 `gh pr review <pr-number> --approve --body-file docs/dev/handoff/review-report.md`,然后调 `goal({op:"complete"})` 完成验证
|
|
67
|
+
编排器将使用此报告执行 gh pr review。
|
|
52
68
|
|
|
53
69
|
## 原则
|
|
54
70
|
- 不修改代码
|
|
@@ -22,18 +22,39 @@ description: 分支 → 编码 + 单测 → PR 提交(Worktree 模式)
|
|
|
22
22
|
|
|
23
23
|
### 3. 创建/复用 Worktree
|
|
24
24
|
```bash
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
# 探测默认分支
|
|
26
|
+
BASE=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name' 2>/dev/null || git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main")
|
|
27
|
+
|
|
28
|
+
# 检查和创建 worktree
|
|
29
|
+
WORKTREE=".worktree/<task-slug>"
|
|
30
|
+
BRANCH="feat/<task-slug>"
|
|
31
|
+
|
|
32
|
+
if [ -d "$WORKTREE" ]; then
|
|
33
|
+
# Worktree 目录已存在 → 验证一致性
|
|
34
|
+
EXISTING=$(git -C "$WORKTREE" rev-parse --abbrev-ref HEAD 2>/dev/null)
|
|
35
|
+
if [ "$EXISTING" != "$BRANCH" ]; then
|
|
36
|
+
echo "ERROR: $WORKTREE exists but tracks branch '$EXISTING' (expected '$BRANCH')"
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
echo "Worktree 已存在,复用:$WORKTREE"
|
|
40
|
+
else
|
|
41
|
+
# 检查分支是否已存在
|
|
42
|
+
if git show-ref --verify "refs/heads/$BRANCH" >/dev/null 2>&1; then
|
|
43
|
+
# 分支已存在,检查是否已合并
|
|
44
|
+
if git branch --merged "$BASE" | grep -q "$BRANCH"; then
|
|
45
|
+
git branch -D "$BRANCH"
|
|
46
|
+
else
|
|
47
|
+
echo "ERROR: 分支 '$BRANCH' 已存在,请先处理"
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
50
|
+
fi
|
|
51
|
+
# 创建 worktree + 分支
|
|
52
|
+
git worktree add -b "$BRANCH" "$WORKTREE" "$BASE"
|
|
28
53
|
fi
|
|
29
54
|
|
|
30
55
|
# 进入 worktree
|
|
31
|
-
cd
|
|
56
|
+
cd "$WORKTREE"
|
|
32
57
|
```
|
|
33
|
-
|
|
34
|
-
> **串行 task 说明**:当 DAG 存在依赖关系时,flow-review 会在上一 task 合并后自动清理其 worktree。
|
|
35
|
-
> 因此下一 task 执行时 worktree 不存在,会触发新建流程,天然实现"清理后重建"策略。
|
|
36
|
-
> 无需额外处理,worktree 创建逻辑对串行/并行场景透明。
|
|
37
58
|
### 4. 安装依赖
|
|
38
59
|
|
|
39
60
|
```bash
|
|
@@ -65,7 +86,18 @@ npm test
|
|
|
65
86
|
### 7. 提交 PR
|
|
66
87
|
```bash
|
|
67
88
|
# 在 worktree 内执行
|
|
68
|
-
|
|
89
|
+
|
|
90
|
+
# 根据 task 预期文件和 git status 确定待暂存文件
|
|
91
|
+
# Task 文件通常包含 frontmatter expected_files 字段
|
|
92
|
+
git status --short
|
|
93
|
+
|
|
94
|
+
# 显式暂存任务相关文件(不是 git add .)
|
|
95
|
+
# 示例:git add src/plugin/goal.ts test/goal.test.ts assets/agents/team/reviewer.md
|
|
96
|
+
git add <file1> <file2> ...
|
|
97
|
+
|
|
98
|
+
# 提交前检查:确保无密钥、无超大文件、无任务范围外文件
|
|
99
|
+
git diff --cached --name-only
|
|
100
|
+
|
|
69
101
|
git commit -m "feat(<scope>): <title>"
|
|
70
102
|
git push origin feat/<task-slug>
|
|
71
103
|
mkdir -p docs/dev/handoff
|
|
@@ -91,3 +123,40 @@ gh pr create --title "<title>" --body-file docs/dev/handoff/pr-body.md
|
|
|
91
123
|
## 后续
|
|
92
124
|
- **/test** — 触发 CI E2E 测试
|
|
93
125
|
- **/review** — 审查 PR
|
|
126
|
+
|
|
127
|
+
## Contract
|
|
128
|
+
|
|
129
|
+
### Trigger
|
|
130
|
+
由 `/code` 命令或 `@dev-lifecycle` Phase 3 触发。
|
|
131
|
+
|
|
132
|
+
### Inputs
|
|
133
|
+
- Sub Issue 编号(来源:`/tasks` 产出)
|
|
134
|
+
- task 文件 frontmatter 中的 `worktree_root`(来源:task 文件)
|
|
135
|
+
|
|
136
|
+
### Preconditions
|
|
137
|
+
- `/tasks` 已完成 → Sub Issues 就绪
|
|
138
|
+
- 前置依赖任务已合并
|
|
139
|
+
|
|
140
|
+
### Procedure
|
|
141
|
+
1. 选择依赖已满足的 Sub Issue
|
|
142
|
+
2. 创建或复用 Worktree(`git worktree add -b`)
|
|
143
|
+
3. 安装依赖 → 编码 + 单测 → commit + push
|
|
144
|
+
4. 编排器创建 PR
|
|
145
|
+
|
|
146
|
+
### Outputs
|
|
147
|
+
- Worktree 已创建(`.worktree/<task-slug>/`)
|
|
148
|
+
- 代码已推送
|
|
149
|
+
- PR 已创建(Orchestrator 执行)
|
|
150
|
+
|
|
151
|
+
### Failure
|
|
152
|
+
- Worktree 创建失败 → 检查分支冲突或目录残留
|
|
153
|
+
- 测试失败 → 修复后重试
|
|
154
|
+
|
|
155
|
+
### Idempotency
|
|
156
|
+
- Worktree 已存在 → 复用
|
|
157
|
+
- 代码已提交 → 追加提交
|
|
158
|
+
|
|
159
|
+
### Prohibited Actions
|
|
160
|
+
- Worker 不创建 PR、不操作 Issue
|
|
161
|
+
- 不使用 `git add .`
|
|
162
|
+
- 不直接 push 到默认分支
|
|
@@ -9,7 +9,7 @@ description: 技术方案设计 → 方案文档 + ADR 输出
|
|
|
9
9
|
|
|
10
10
|
## Prerequisites
|
|
11
11
|
- `/requirements` 已完成 → `docs/prd/<title>.md` + Parent Issue 存在
|
|
12
|
-
- 阅读 `../CONTEXT.md` 了解领域术语
|
|
12
|
+
- 阅读 `../_context/CONTEXT.md` 了解领域术语
|
|
13
13
|
|
|
14
14
|
## Workflow
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@ description: 技术方案设计 → 方案文档 + ADR 输出
|
|
|
27
27
|
|
|
28
28
|
### 3. 记录 ADR
|
|
29
29
|
为每个关键决策记录 ADR 到 `docs/adr/<YYYY-MM-DD>-<slug>.md`。
|
|
30
|
-
ADR 格式参考
|
|
30
|
+
ADR 格式参考 `_prompts/adr-format` 中的格式要求。
|
|
31
31
|
|
|
32
32
|
ADR 至少记录:
|
|
33
33
|
- 技术选型决策
|
|
@@ -51,20 +51,69 @@ EOF
|
|
|
51
51
|
gh issue comment <issue-number> --body-file docs/dev/handoff/design-comment.md
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
### 5.
|
|
55
|
-
设计文档和 ADR
|
|
54
|
+
### 5. 提交文档(Planning PR)
|
|
55
|
+
设计文档和 ADR 通过 Planning PR 合入,确保分支保护下也能正常工作:
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
+
# 探测默认分支
|
|
59
|
+
BASE=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name' 2>/dev/null || echo "main")
|
|
60
|
+
|
|
61
|
+
# 创建 planning 分支
|
|
62
|
+
git checkout -b chore/plan-<slug> $BASE
|
|
58
63
|
git add docs/dev/specs/<title>.md docs/adr/<date>-<slug>.md
|
|
59
64
|
git commit -m "docs: <title> — 技术方案 + ADR"
|
|
60
|
-
git push origin
|
|
65
|
+
git push origin chore/plan-<slug>
|
|
66
|
+
|
|
67
|
+
# 创建 PR
|
|
68
|
+
gh pr create --title "docs: <title> — 技术方案 + ADR" \
|
|
69
|
+
--body "Planning PR:完整技术方案和架构决策记录" \
|
|
70
|
+
--base $BASE
|
|
71
|
+
|
|
72
|
+
# 合并 PR 后切回 $BASE
|
|
73
|
+
git checkout $BASE && git pull origin $BASE
|
|
61
74
|
```
|
|
62
75
|
|
|
63
76
|
## Output
|
|
64
77
|
- `docs/dev/specs/<title>.md` — 技术方案
|
|
65
78
|
- `docs/adr/<date>-<slug>.md` — ADR 决议
|
|
66
79
|
- Parent Issue 收到设计评论
|
|
67
|
-
-
|
|
80
|
+
- 文档通过 Planning PR 合入默认分支
|
|
68
81
|
|
|
69
82
|
## 后续
|
|
70
83
|
- **/tasks** — 基于设计方案拆解为 DAG 任务
|
|
84
|
+
|
|
85
|
+
## Contract
|
|
86
|
+
|
|
87
|
+
### Trigger
|
|
88
|
+
由 `/design` 命令或 `@dev-lifecycle` Phase 1 触发。
|
|
89
|
+
|
|
90
|
+
### Inputs
|
|
91
|
+
- `docs/prd/<title>.md` — 上游 PRD(来源:requirements 阶段产出)
|
|
92
|
+
- Parent Issue 编号(来源:Goal metadata 或 `/requirements` 阶段产出)
|
|
93
|
+
|
|
94
|
+
### Preconditions
|
|
95
|
+
- `/requirements` 已完成 → `docs/prd/<title>.md` 存在
|
|
96
|
+
- Parent Issue 存在
|
|
97
|
+
|
|
98
|
+
### Procedure
|
|
99
|
+
1. 阅读 PRD、已有 ADR、Out of Scope
|
|
100
|
+
2. 输出技术方案到 `docs/dev/specs/<title>.md`
|
|
101
|
+
3. 记录 ADR 到 `docs/adr/<YYYY-MM-DD>-<slug>.md`
|
|
102
|
+
4. 附设计评论到 Parent Issue
|
|
103
|
+
5. 通过 Planning PR 提交文档
|
|
104
|
+
|
|
105
|
+
### Outputs
|
|
106
|
+
- `docs/dev/specs/<title>.md` — 技术方案
|
|
107
|
+
- `docs/adr/<date>-<slug>.md` — ADR 决议
|
|
108
|
+
|
|
109
|
+
### Failure
|
|
110
|
+
- ADR 与已有决策冲突 → 记录冲突并标注
|
|
111
|
+
- Planning PR 合并失败 → 通知用户手动处理
|
|
112
|
+
|
|
113
|
+
### Idempotency
|
|
114
|
+
- 技术方案已存在 → 读取并更新
|
|
115
|
+
- ADR 已存在 → 不重复创建
|
|
116
|
+
|
|
117
|
+
### Prohibited Actions
|
|
118
|
+
- 不直接 push 到默认分支
|
|
119
|
+
- 不跳过 ADR 兼容性检查
|
|
@@ -45,3 +45,32 @@ description: 打包上下文,跨会话传递进度
|
|
|
45
45
|
|
|
46
46
|
## Output
|
|
47
47
|
- `docs/dev/handoff-<date>.md`
|
|
48
|
+
|
|
49
|
+
## Contract
|
|
50
|
+
|
|
51
|
+
### Trigger
|
|
52
|
+
由 `/handoff` 命令触发。上下文窗口接近极限或需跨会话传递进度时使用。
|
|
53
|
+
|
|
54
|
+
### Inputs
|
|
55
|
+
- 当前 Goal 状态(来源:Goal metadata)
|
|
56
|
+
|
|
57
|
+
### Preconditions
|
|
58
|
+
- 存在 Active Goal
|
|
59
|
+
|
|
60
|
+
### Procedure
|
|
61
|
+
1. 打包当前流程状态(阶段、任务、进度)
|
|
62
|
+
2. 列出已完成和待完成项
|
|
63
|
+
3. 确定下一步骤
|
|
64
|
+
4. 保存到 handoff 文件
|
|
65
|
+
|
|
66
|
+
### Outputs
|
|
67
|
+
- `docs/dev/handoff-<date>.md` — 交接文件
|
|
68
|
+
|
|
69
|
+
### Failure
|
|
70
|
+
- 无 Goal → 仅输出当前会话摘要
|
|
71
|
+
|
|
72
|
+
### Idempotency
|
|
73
|
+
- 同一天多次执行 → 覆盖前一次 handoff
|
|
74
|
+
|
|
75
|
+
### Prohibited Actions
|
|
76
|
+
- 不修改代码或文档
|