@boyingliu01/xp-gate 0.8.19 → 0.8.21
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/lib/init.js +2 -2
- package/lib/install-skill.js +13 -4
- package/lib/principles.js +5 -0
- package/mock-policy/AGENTS.md +3 -3
- package/mutation/AGENTS.md +3 -3
- package/package.json +1 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
- package/plugins/claude-code/skills/sprint-flow/SKILL.md +135 -1091
- package/plugins/claude-code/skills/sprint-flow/references/orchestration-rules.md +333 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-1-plan.md +17 -46
- package/plugins/claude-code/skills/sprint-flow/references/phase-2-build.md +4 -193
- package/plugins/claude-code/skills/sprint-flow/references/phase-3-review.md +13 -30
- package/plugins/claude-code/skills/sprint-flow/references/phase-6-ship.md +4 -181
- package/plugins/claude-code/skills/sprint-flow/references/phase-7-land.md +4 -135
- package/plugins/claude-code/skills/sprint-flow/references/phase-8-cleanup.md +4 -187
- package/plugins/claude-code/skills/sprint-flow/references/phase-minus-1-isolate.md +58 -0
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
- package/plugins/opencode/skills/sprint-flow/SKILL.md +135 -1091
- package/plugins/opencode/skills/sprint-flow/references/orchestration-rules.md +333 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-1-plan.md +17 -46
- package/plugins/opencode/skills/sprint-flow/references/phase-2-build.md +4 -193
- package/plugins/opencode/skills/sprint-flow/references/phase-3-review.md +13 -30
- package/plugins/opencode/skills/sprint-flow/references/phase-6-ship.md +4 -181
- package/plugins/opencode/skills/sprint-flow/references/phase-7-land.md +4 -135
- package/plugins/opencode/skills/sprint-flow/references/phase-8-cleanup.md +4 -187
- package/plugins/opencode/skills/sprint-flow/references/phase-minus-1-isolate.md +58 -0
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
- package/plugins/qoder/bin/xp-gate-check +5 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
- package/principles/AGENTS.md +3 -3
- package/skills/delphi-review/AGENTS.md +3 -3
- package/skills/sprint-flow/AGENTS.md +3 -3
- package/skills/sprint-flow/SKILL.md +135 -1091
- package/skills/sprint-flow/references/orchestration-rules.md +333 -0
- package/skills/sprint-flow/references/phase-1-plan.md +17 -46
- package/skills/sprint-flow/references/phase-2-build.md +4 -193
- package/skills/sprint-flow/references/phase-3-review.md +13 -30
- package/skills/sprint-flow/references/phase-6-ship.md +4 -181
- package/skills/sprint-flow/references/phase-7-land.md +4 -135
- package/skills/sprint-flow/references/phase-8-cleanup.md +4 -187
- package/skills/sprint-flow/references/phase-minus-1-isolate.md +58 -0
- package/skills/test-specification-alignment/AGENTS.md +3 -3
|
@@ -34,37 +34,22 @@ Web 前端项目额外增加:系统化 QA、视觉审计、性能基线。
|
|
|
34
34
|
|
|
35
35
|
### Step 1: 调用 delphi-review --mode code-walkthrough
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
task(
|
|
41
|
-
category="deep",
|
|
42
|
-
load_skills=["delphi-review"],
|
|
43
|
-
run_in_background=false,
|
|
44
|
-
prompt="--mode code-walkthrough (设计文档 + MVP 代码)"
|
|
45
|
-
)
|
|
37
|
+
```
|
|
38
|
+
skill(name="delphi-review", user_message="--mode code-walkthrough")
|
|
46
39
|
```
|
|
47
40
|
|
|
48
|
-
delphi code-walkthrough
|
|
41
|
+
delphi code-walkthrough 执行:
|
|
49
42
|
- 2-3 位国内模型专家匿名独立评审(DeepSeek-v4-pro + Kimi-K2.6 + Qwen3.6-Plus)
|
|
50
43
|
- Round 1: 匿名独立评审(防止 anchoring bias)
|
|
51
|
-
- Round 2:
|
|
52
|
-
- Round 3:
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
**如果最终 REQUEST_CHANGES(subagent 尝试自动修复)**:
|
|
61
|
-
- subagent 尝试自动修复常见问题(措辞不清晰、缺少用例覆盖等)
|
|
62
|
-
- 修复成功后自动回到 Round 2 重新评审
|
|
63
|
-
- 如果仍然 REQUEST_CHANGES → subagent 输出详细失败报告
|
|
64
|
-
- ⚠️ Orchestrator 暂停等待用户修复 Critical Issues + 处理 Major Concerns
|
|
65
|
-
- 用户修复后通过 task_id 延续 subagent 重新评审
|
|
66
|
-
|
|
67
|
-
**如果最终 APPROVED**:
|
|
44
|
+
- Round 2: 交换意见,响应关切
|
|
45
|
+
- Round 3: 最终立场(如需)
|
|
46
|
+
- ≥90% 共识 + APPROVED 才通过
|
|
47
|
+
|
|
48
|
+
**如果 REQUEST_CHANGES**:
|
|
49
|
+
- ⚠️ 暂停等待用户修复 Critical Issues + 处理 Major Concerns
|
|
50
|
+
- 修复后回到 Round 2 重新评审
|
|
51
|
+
|
|
52
|
+
**如果 APPROVED**:
|
|
68
53
|
- 写入 `.code-walkthrough-result.json`(1 小时有效期)
|
|
69
54
|
- 进入 Step 2
|
|
70
55
|
|
|
@@ -209,15 +194,13 @@ browse 执行:
|
|
|
209
194
|
|
|
210
195
|
| 暂停点 | 触发条件 | 用户操作 |
|
|
211
196
|
|--------|---------|---------|
|
|
212
|
-
| delphi code-walkthrough REQUEST_CHANGES
|
|
197
|
+
| delphi code-walkthrough REQUEST_CHANGES | Critical Issues 未修复 | 用户修复 → 重新评审 → APPROVED → 继续 |
|
|
213
198
|
| test-alignment 失败 | 自动回退 Phase 2(不暂停) | 自动迭代 |
|
|
214
199
|
| qa 发现问题 (web) | 自动回退修复(不暂停) | 自动迭代 |
|
|
215
200
|
| design-review 发现问题 (web) | 自动回退修复(不暂停) | 自动迭代 |
|
|
216
201
|
| api-test 失败 (backend) | 自动回退 Phase 2(不暂停) | 自动迭代 |
|
|
217
202
|
| browse 发现问题 | 自动回退 Phase 2(不暂停) | 自动迭代 |
|
|
218
203
|
|
|
219
|
-
> **#218 规则**: Delphi code-walkthrough 的 Round 1→2→3 自动调度在 subagent 内部完成,不暂停。只有 subagent 尝试自动修复后仍 REQUEST_CHANGES 时才需要用户介入。
|
|
220
|
-
|
|
221
204
|
---
|
|
222
205
|
|
|
223
206
|
## 输出
|
|
@@ -1,186 +1,9 @@
|
|
|
1
1
|
# Phase 6: SHIP + DEPLOY(发布)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**完整指令**: @see SKILL.md `## Phase 6: SHIP` section.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**摘要**: 结构化分支完成决策, 创建 PR, 合并部署, 监控. 生成 Sprint Summary.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**关键链**: PHASE5-GATE → verification → finishing-a-development-branch(4选项) → ship → land-and-deploy → canary → Sprint Summary
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- **`finishing-a-development-branch`** _(新增)_ — 结构化完成流:4 选项决策(merge/PR/discard/keep)
|
|
12
|
-
- `ship` (gstack) — 创建 PR
|
|
13
|
-
- `land-and-deploy` (gstack) — 合并部署
|
|
14
|
-
- `canary` (gstack) — 监控告警
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## 执行步骤
|
|
19
|
-
|
|
20
|
-
### Step 0: ⚠️ PHASE 5 硬门禁验证(不可跳过)
|
|
21
|
-
|
|
22
|
-
**必须首先验证 Phase 5 已完成**:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
if [ ! -f ".sprint-state/phase-outputs/feedback-log.md" ]; then
|
|
26
|
-
echo "[BLOCKED] Phase 5 FEEDBACK not completed. feedback-log.md not found."
|
|
27
|
-
echo "Phase 5 must execute: learn + retro → generate feedback-log.md"
|
|
28
|
-
echo "Return to Phase 5 before proceeding to SHIP."
|
|
29
|
-
exit 1
|
|
30
|
-
fi
|
|
31
|
-
echo "✅ Phase 5 FEEDBACK verified — feedback-log.md exists"
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**失败**: ⚠️ BLOCK → 返回 Phase 5 执行 learn + retro
|
|
35
|
-
**通过**: 进入 Step 1
|
|
36
|
-
|
|
37
|
-
### Step 1: 最终验证
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
skill(name="verification-before-completion", user_message="最终验证: [MVP v1] 完整性")
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
**验证内容**:
|
|
44
|
-
- 测试全部通过
|
|
45
|
-
- Lint 无错误
|
|
46
|
-
- 覆盖率 ≥ 80%
|
|
47
|
-
|
|
48
|
-
**失败**: ⚠️ BLOCK → 回退 Phase 2 修复
|
|
49
|
-
|
|
50
|
-
**通过**: 进入 Step 2
|
|
51
|
-
|
|
52
|
-
### Step 2: 结构化完成决策 — 调用 finishing-a-development-branch(新增 — ISSUE31)
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
skill(name="finishing-a-development-branch")
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
finishing-a-development-branch 执行 4 选项决策:
|
|
59
|
-
|
|
60
|
-
| 选项 | 行为 | 适用场景 |
|
|
61
|
-
|------|------|---------|
|
|
62
|
-
| **merge** | 直接合并到主分支 | 小功能、确信变更正确 |
|
|
63
|
-
| **PR** | 创建 PR 等待 review | 标准流程、需要团队审核 |
|
|
64
|
-
| **discard** | 删除分支、丢弃变更 | 实验失败、不再需要 |
|
|
65
|
-
| **keep** | 保留分支待后续处理 | 半成品、暂时搁置 |
|
|
66
|
-
|
|
67
|
-
**决策逻辑**:
|
|
68
|
-
```
|
|
69
|
-
IF 测试全部通过 + 用户确信 → merge → land-and-deploy (Step 4)
|
|
70
|
-
IF 测试全部通过 + 需要 review → PR → ship (Step 3a) → land-and-deploy (Step 4)
|
|
71
|
-
IF 实验失败 → discard → 清理 worktree → 结束 Sprint
|
|
72
|
-
IF 半成品 → keep → 保留分支 → 结束 Sprint
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
> **#218**: `finishing-a-development-branch` 的 4 选项决策已包含用户确认(Step 2),不再需要独立的 Step 3 重复确认。用户选择后直接路由到对应步骤。
|
|
76
|
-
|
|
77
|
-
**worktree 清理**: finishing-a-development-branch 自动清理不再需要的 worktree。
|
|
78
|
-
|
|
79
|
-
**分支完成选项路由**:
|
|
80
|
-
| 用户选择 | 路由 |
|
|
81
|
-
|---------|------|
|
|
82
|
-
| **merge** | → Step 4 (land-and-deploy) |
|
|
83
|
-
| **PR** | → Step 3a (ship) → PR URL → Step 4 (land-and-deploy) |
|
|
84
|
-
| **discard** | → Step 5 (cleanup + summary) |
|
|
85
|
-
| **keep** | → Step 5 (cleanup + summary) |
|
|
86
|
-
|
|
87
|
-
### Step 3a: 调用 ship skill(PR 路径)
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
skill(name="ship", user_message="[MVP v1 代码]")
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
ship 执行:
|
|
94
|
-
- 检测 base branch
|
|
95
|
-
- run tests
|
|
96
|
-
- review diff
|
|
97
|
-
- bump VERSION
|
|
98
|
-
- update CHANGELOG
|
|
99
|
-
- commit, push, create PR
|
|
100
|
-
|
|
101
|
-
**输出**: PR URL
|
|
102
|
-
|
|
103
|
-
> **注意**: PR 创建后不暂停等待用户确认合并。用户已通过 finishing-a-development-branch 选择了 PR 路径(Step 2),ship 自动完成后直接进入 Step 4 land-and-deploy 继续执行。如果用户需要暂停审查 PR,应在 Sprint 开始时指定 `--stop-at ship`。
|
|
104
|
-
|
|
105
|
-
### Step 4: 调用 land-and-deploy(用户确认后)
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
skill(name="land-and-deploy", user_message="--pr [PR URL]")
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
执行:
|
|
112
|
-
- merge PR(或直接合并当前分支)
|
|
113
|
-
- wait for CI
|
|
114
|
-
- verify production health
|
|
115
|
-
|
|
116
|
-
**如果失败**:
|
|
117
|
-
- ⚠️ 暂停等待用户处理
|
|
118
|
-
|
|
119
|
-
**如果成功**:
|
|
120
|
-
- 自动进入 Step 5
|
|
121
|
-
|
|
122
|
-
### Step 5: 调用 canary skill
|
|
123
|
-
|
|
124
|
-
```
|
|
125
|
-
skill(name="canary", user_message="--url [production URL]")
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
执行:
|
|
129
|
-
- post-deploy monitoring
|
|
130
|
-
- console errors detection
|
|
131
|
-
- performance regression check
|
|
132
|
-
|
|
133
|
-
**如果发现异常**:
|
|
134
|
-
- 回退或修复
|
|
135
|
-
|
|
136
|
-
**如果正常**:
|
|
137
|
-
- 进入 Step 6
|
|
138
|
-
|
|
139
|
-
### Step 6: 生成 Sprint Summary
|
|
140
|
-
|
|
141
|
-
使用模板:`@templates/sprint-summary-template.md`
|
|
142
|
-
|
|
143
|
-
包含:
|
|
144
|
-
- Sprint ID
|
|
145
|
-
- 执行阶段统计
|
|
146
|
-
- 分支完成决策结果(merge/PR/discard/keep)
|
|
147
|
-
- emergent 发现统计
|
|
148
|
-
- Sprint 2 是否需要
|
|
149
|
-
|
|
150
|
-
### Step 7: 保存 Sprint Summary
|
|
151
|
-
|
|
152
|
-
保存到 `<project-root>/.sprint-state/phase-outputs/sprint-summary.md`
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## 暂停点
|
|
157
|
-
|
|
158
|
-
| 暂停点 | 触发条件 | 用户操作 |
|
|
159
|
-
|--------|---------|---------|
|
|
160
|
-
| finishing-a-development-branch | 4 选项决策 | 用户选择 merge/PR/discard/keep |
|
|
161
|
-
| land-and-deploy 失败 | CI 或部署失败 | 用户处理问题 |
|
|
162
|
-
|
|
163
|
-
> **#218**: PR 创建后不再暂停等待确认 — 用户已通过 finishing-a-development-branch 选择了 PR 路径,ship 自动完成后直接进入 land-and-deploy。如果用户需要暂停审查 PR,应在 Sprint 开始时指定 `--stop-at ship`。
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## Sprint 2 提示
|
|
168
|
-
|
|
169
|
-
如果 Sprint Summary 显示有 emergent issues:
|
|
170
|
-
```
|
|
171
|
-
Sprint 完成!发现 N 个 emergent issues。
|
|
172
|
-
|
|
173
|
-
是否开始 Sprint 2?
|
|
174
|
-
- "开始 Sprint 2" → 使用 sprint2-pain.md 重新进入 Phase 0
|
|
175
|
-
- "结束" → 记录未解决的问题,结束流程
|
|
176
|
-
|
|
177
|
-
Critical issues 将自动进入 Sprint 2。
|
|
178
|
-
Major/Minor issues 需您确认是否纳入。
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## 输出
|
|
184
|
-
|
|
185
|
-
- Sprint Summary (`sprint-summary.md`)
|
|
186
|
-
- Sprint 完成(或 Sprint 2 开始)
|
|
9
|
+
**输出**: PR URL, Sprint Summary
|
|
@@ -1,140 +1,9 @@
|
|
|
1
1
|
# Phase 7: LAND(合并 + 部署)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**完整指令**: @see SKILL.md `## Phase 7: LAND` section.
|
|
4
4
|
|
|
5
|
-
自动合并 PR
|
|
5
|
+
**摘要**: 自动合并 PR, 等待 CI, 执行部署, Canary Health Check, 失败自动回滚.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**关键链**: merge PR → wait CI(10min) → wait Deploy(10min) → Canary Health Check(5min) → auto-rollback on failure
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- Phase 6 SHIP 输出的 PR URL
|
|
12
|
-
- 或 `--phase ship-only` 时手动提供 PR 编号
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## 调用 Skills
|
|
17
|
-
|
|
18
|
-
- `land-and-deploy` (gstack) — 合并部署
|
|
19
|
-
- `canary` (gstack) — 监控告警
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## 执行步骤
|
|
24
|
-
|
|
25
|
-
### Step 1: 合并 PR
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
gh pr merge <PR_NUMBER> --squash
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
**失败**: 输出 `[ERROR] PR merge failed` → 询问用户是否重试或手动处理
|
|
32
|
-
|
|
33
|
-
**成功**: 进入 Step 2
|
|
34
|
-
|
|
35
|
-
### Step 2: 等待 CI 完成
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
# Poll CI checks every 10s, timeout after 10min
|
|
39
|
-
gh pr checks <PR_NUMBER> --watch --interval 10
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
**超时 (10min)**: 输出 `[WARN] CI checks timed out after 10min` → 询问用户是否继续
|
|
43
|
-
|
|
44
|
-
**CI 失败**: 输出 `[ERROR] CI checks failed, aborting deployment` → BLOCK
|
|
45
|
-
|
|
46
|
-
**CI 成功**: 进入 Step 3
|
|
47
|
-
|
|
48
|
-
### Step 3: 等待 Deploy 完成
|
|
49
|
-
|
|
50
|
-
**条件**: 项目已配置部署平台(Fly.io/Vercel/Render/GitHub Actions 等)
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
# Poll deploy status every 10s, timeout after 10min
|
|
54
|
-
gh pr checks <PR_NUMBER> --watch --interval 10
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**无部署配置**: 跳过 Step 3-4,直接进入 Phase 8
|
|
58
|
-
|
|
59
|
-
**部署成功**: 进入 Step 4
|
|
60
|
-
|
|
61
|
-
**部署失败**: 进入 Step 5(自动回滚)
|
|
62
|
-
|
|
63
|
-
### Step 4: Canary Health Check
|
|
64
|
-
|
|
65
|
-
**健康检查端点**:
|
|
66
|
-
- 默认:项目根路径 `/`
|
|
67
|
-
- 自定义:`$HEALTH_CHECK_URL` 环境变量或 `.sprint-load-test.yaml` 中的 `health_endpoint`
|
|
68
|
-
|
|
69
|
-
**SLA 指标**:
|
|
70
|
-
| 指标 | 阈值 | 说明 |
|
|
71
|
-
|------|------|------|
|
|
72
|
-
| HTTP 响应状态 | 200 | 服务正常运行 |
|
|
73
|
-
| 错误率 | <1% | 5 分钟窗口内 5xx 错误占比 |
|
|
74
|
-
| p99 响应时间 | <2s | 99 分位响应时间 |
|
|
75
|
-
| 超时总时长 | 5min | health check 最长等待时间 |
|
|
76
|
-
| Polling 间隔 | 10s | 健康检查轮询频率 |
|
|
77
|
-
|
|
78
|
-
**实现**:
|
|
79
|
-
```bash
|
|
80
|
-
START_TIME=$(date +%s)
|
|
81
|
-
while [ $(( $(date +%s) - START_TIME )) -lt 300 ]; do
|
|
82
|
-
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$HEALTH_CHECK_URL" 2>/dev/null || echo "000")
|
|
83
|
-
if [ "$RESPONSE" = "200" ]; then
|
|
84
|
-
echo "✅ Canary health check passed: HTTP 200"
|
|
85
|
-
break
|
|
86
|
-
fi
|
|
87
|
-
echo "[WARN] Canary health check returned HTTP $RESPONSE, retrying in 10s..."
|
|
88
|
-
sleep 10
|
|
89
|
-
done
|
|
90
|
-
|
|
91
|
-
if [ "$RESPONSE" != "200" ]; then
|
|
92
|
-
echo "[ERROR] Canary health check failed after 5min timeout"
|
|
93
|
-
# Auto-rollback
|
|
94
|
-
LAST_MERGE_COMMIT=$(git log -1 --oneline --format="%H" 2>/dev/null)
|
|
95
|
-
git revert "$LAST_MERGE_COMMIT" --no-edit
|
|
96
|
-
echo "[ROLLBACK] Auto-reverted merge commit: $LAST_MERGE_COMMIT"
|
|
97
|
-
exit 1
|
|
98
|
-
fi
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
**通过**: 进入 Phase 8 CLEANUP
|
|
102
|
-
|
|
103
|
-
**失败**: 自动回滚 → 输出 `[ERROR] Deploy failed, auto-rolled back merge` → Phase 8 仍执行(清理 worktree)
|
|
104
|
-
|
|
105
|
-
### Step 5: 自动回滚(部署失败时)
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
# Revert the last merge commit
|
|
109
|
-
LAST_MERGE_COMMIT=$(git log -1 --oneline --format="%H" 2>/dev/null)
|
|
110
|
-
git revert "$LAST_MERGE_COMMIT" --no-edit
|
|
111
|
-
echo "[ERROR] Deploy failed, auto-rolled back merge commit: $LAST_MERGE_COMMIT"
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
## 输出
|
|
117
|
-
|
|
118
|
-
- 部署状态: success | failure | skipped
|
|
119
|
-
- Canary 报告: SLA 指标是否达标
|
|
120
|
-
- 如果自动回滚:reverted commit hash
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## 暂停点
|
|
125
|
-
|
|
126
|
-
- **CI 超时**: 用户确认是否继续等待或跳过
|
|
127
|
-
- **部署失败**: 用户确认自动回滚或手动处理
|
|
128
|
-
- **Canary 失败**: 用户确认回滚或保留状态调查
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## 错误处理
|
|
133
|
-
|
|
134
|
-
| 错误场景 | 处理 |
|
|
135
|
-
|---------|------|
|
|
136
|
-
| PR 合并冲突 | 输出错误 → 询问用户是否 rebase 或手动解决 |
|
|
137
|
-
| CI 超时 (10min) | 输出警告 → 询问是否继续或跳过部署 |
|
|
138
|
-
| 部署失败 | 自动 `git revert` merge commit + 输出错误 |
|
|
139
|
-
| Canary 失败 | 自动回滚 + 输出 `[ERROR] Canary health check failed` |
|
|
140
|
-
| 无部署配置 | 跳过部署/canary,仅 merge + CI checks |
|
|
9
|
+
**输出**: 部署状态 (success/failure/skipped), Canary 报告
|
|
@@ -1,192 +1,9 @@
|
|
|
1
1
|
# Phase 8: CLEANUP(清理 + 总结)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**完整指令**: @see SKILL.md `## Phase 8: CLEANUP` section.
|
|
4
4
|
|
|
5
|
-
自动清理 worktree
|
|
5
|
+
**摘要**: 自动清理 worktree, 更新 sprint-state.json, 输出 Sprint Summary, 处理 emergent issues.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**关键链**: worktree detection → remove(retry×3) → residual check → sprint-state update → Sprint Summary → emergent issues(→Sprint 2?)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- Phase 7 LAND 完成后的部署状态
|
|
12
|
-
- 或 Phase 6 Option 1(本地 Merge)后的完成状态
|
|
13
|
-
- `.sprint-state/sprint-state.json`(包含 worktree 路径信息)
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## 执行步骤
|
|
18
|
-
|
|
19
|
-
### Step 1: 检测 worktree 是否存在
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
# Read worktree path from sprint-state.json
|
|
23
|
-
WORKTREE_PATH=$(node -e "const fs=require('fs'); const state=JSON.parse(fs.readFileSync('.sprint-state/sprint-state.json','utf8')); console.log(state.isolation?.worktree_path || '')" 2>/dev/null)
|
|
24
|
-
|
|
25
|
-
if [ -z "$WORKTREE_PATH" ]; then
|
|
26
|
-
echo "[CLEANUP] No worktree path found in sprint-state.json — skipping cleanup"
|
|
27
|
-
exit 0
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
if [ ! -d "$WORKTREE_PATH" ]; then
|
|
31
|
-
echo "[CLEANUP] Worktree already removed: $WORKTREE_PATH"
|
|
32
|
-
HAS_WORKTREE=false
|
|
33
|
-
else
|
|
34
|
-
HAS_WORKTREE=true
|
|
35
|
-
fi
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**跳过**: `--no-isolate` 路径(无 worktree 可清理)或 worktree 已不存在
|
|
39
|
-
|
|
40
|
-
**存在**: 进入 Step 2
|
|
41
|
-
|
|
42
|
-
### Step 2: 删除 worktree(带重试机制)
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
MAX_RETRIES=3
|
|
46
|
-
RETRY_COUNT=0
|
|
47
|
-
REMOVED=false
|
|
48
|
-
|
|
49
|
-
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
|
50
|
-
if git worktree remove "$WORKTREE_PATH" 2>/dev/null; then
|
|
51
|
-
REMOVED=true
|
|
52
|
-
echo "[CLEANUP] ✅ Worktree removed: $WORKTREE_PATH"
|
|
53
|
-
break
|
|
54
|
-
else
|
|
55
|
-
RETRY_COUNT=$((RETRY_COUNT + 1))
|
|
56
|
-
if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
|
|
57
|
-
echo "[WARN] Worktree remove failed, retry $RETRY_COUNT/$MAX_RETRIES in 1s..."
|
|
58
|
-
sleep 1
|
|
59
|
-
fi
|
|
60
|
-
fi
|
|
61
|
-
done
|
|
62
|
-
|
|
63
|
-
if [ "$REMOVED" = "false" ]; then
|
|
64
|
-
echo "[WARN] Failed to remove worktree after $MAX_RETRIES attempts."
|
|
65
|
-
echo "[WARN] Please manually run: git worktree remove $WORKTREE_PATH"
|
|
66
|
-
fi
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**成功**: 进入 Step 3
|
|
70
|
-
|
|
71
|
-
**失败**: 输出警告 + 手动命令提示 → 进入 Step 3
|
|
72
|
-
|
|
73
|
-
### Step 3: 检测残留目录
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
if [ -d "$WORKTREE_PATH" ]; then
|
|
77
|
-
echo "[WARN] ⚠️ Residual worktree directory detected: $WORKTREE_PATH"
|
|
78
|
-
echo "[WARN] Please manually remove it if needed"
|
|
79
|
-
else
|
|
80
|
-
echo "[CLEANUP] ✅ No residual directory detected"
|
|
81
|
-
fi
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
**残留**: 输出警告
|
|
85
|
-
|
|
86
|
-
**干净**: 输出成功消息 → 进入 Step 4
|
|
87
|
-
|
|
88
|
-
### Step 4: 更新 sprint-state.json
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
node -e "
|
|
92
|
-
const fs = require('fs');
|
|
93
|
-
const statePath = '.sprint-state/sprint-state.json';
|
|
94
|
-
const state = JSON.parse(fs.readFileSync(statePath, 'utf8'));
|
|
95
|
-
state.phase = 8;
|
|
96
|
-
state.status = 'merged';
|
|
97
|
-
if (!state.metrics) state.metrics = {};
|
|
98
|
-
state.metrics.completed_at = new Date().toISOString();
|
|
99
|
-
fs.writeFileSync(statePath, JSON.stringify(state, null, 2) + '\n');
|
|
100
|
-
console.log('[CLEANUP] sprint-state.json updated → phase: 8, status: merged');
|
|
101
|
-
"
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Step 5: 输出 Sprint Summary
|
|
105
|
-
|
|
106
|
-
根据 `.sprint-state/phase-outputs/sprint-summary-template.md` 生成总结:
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
110
|
-
SPRINT SUMMARY
|
|
111
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
112
|
-
Sprint ID: sprint-2026-05-28-01
|
|
113
|
-
Status: merged
|
|
114
|
-
Phase: 8 (CLEANUP complete)
|
|
115
|
-
|
|
116
|
-
Timeline:
|
|
117
|
-
- Phase -1 ISOLATE: ✅
|
|
118
|
-
- Phase 0 THINK: ✅
|
|
119
|
-
- Phase 1 PLAN: ✅
|
|
120
|
-
- Phase 2 BUILD: ✅
|
|
121
|
-
- Phase 3 REVIEW: ✅
|
|
122
|
-
- Phase 4 ACCEPTANCE: ✅
|
|
123
|
-
- Phase 5 FEEDBACK: ✅
|
|
124
|
-
- Phase 6 SHIP: ✅
|
|
125
|
-
- Phase 7 LAND: ✅ (deploy: success/failure/skipped)
|
|
126
|
-
- Phase 8 CLEANUP: ✅ (worktree: clean/residual)
|
|
127
|
-
|
|
128
|
-
Emergent Issues: <N> found
|
|
129
|
-
- IF Critical → Sprint 2 auto-triggered
|
|
130
|
-
- IF Major/Minor → Ask user
|
|
131
|
-
|
|
132
|
-
Worktree cleaned: <yes/no/manual>
|
|
133
|
-
PR merged: <PR_URL>
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Step 6: 处理 Emergent Issues
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
# Check for emergent issues file
|
|
140
|
-
if [ -f ".sprint-state/phase-outputs/emergent-issues.md" ]; then
|
|
141
|
-
ISSUE_COUNT=$(grep -c "^## " ".sprint-state/phase-outputs/emergent-issues.md" 2>/dev/null || echo "0")
|
|
142
|
-
|
|
143
|
-
if [ "$ISSUE_COUNT" -gt 0 ]; then
|
|
144
|
-
HAS_CRITICAL=$(grep -i "critical" ".sprint-state/phase-outputs/emergent-issues.md" 2>/dev/null || echo "")
|
|
145
|
-
|
|
146
|
-
if [ -n "$HAS_CRITICAL" ]; then
|
|
147
|
-
echo ""
|
|
148
|
-
echo "⚠️ Critical emergent issues detected — auto-triggering Sprint 2"
|
|
149
|
-
echo "Sprint 2 Pain Document will be generated from emergent-issues.md"
|
|
150
|
-
# Auto-trigger Sprint 2
|
|
151
|
-
else
|
|
152
|
-
echo ""
|
|
153
|
-
echo "ℹ️ $ISSUE_COUNT emergent issue(s) found — ask user about Sprint 2"
|
|
154
|
-
fi
|
|
155
|
-
else
|
|
156
|
-
echo ""
|
|
157
|
-
echo "✅ No emergent issues — sprint completed successfully"
|
|
158
|
-
fi
|
|
159
|
-
else
|
|
160
|
-
echo ""
|
|
161
|
-
echo "✅ No emergent issues — sprint completed successfully"
|
|
162
|
-
fi
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## 输出
|
|
168
|
-
|
|
169
|
-
- Cleanup Report:
|
|
170
|
-
- Worktree removed: ✅ / ⚠️ residual / ❌ manual required
|
|
171
|
-
- sprint-state.json: phase 8, status merged
|
|
172
|
-
- Sprint Summary
|
|
173
|
-
- IF emergent issues with Critical → Sprint 2 auto-trigger
|
|
174
|
-
- IF emergent issues without Critical → ask user
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
## 暂停点
|
|
179
|
-
|
|
180
|
-
- **Worktree 手动清理**: 用户确认已手动清理或保留残留
|
|
181
|
-
- **Sprint 2 决策**: 用户确认是否开始 Sprint 2(仅 Major/Minor issues 时)
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
## 错误处理
|
|
186
|
-
|
|
187
|
-
| 错误场景 | 处理 |
|
|
188
|
-
|---------|------|
|
|
189
|
-
| worktree 路径不存在于 sprint-state.json | 跳过清理,输出警告 |
|
|
190
|
-
| `git worktree remove` 失败 | 重试 3 次 → 输出手动命令提示 |
|
|
191
|
-
| 残留目录检测 | 输出警告,用户决策 |
|
|
192
|
-
| sprint-state.json 更新失败 | 输出错误,不影响最终完成状态 |
|
|
9
|
+
**输出**: Cleanup Report, Sprint Summary
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Phase -1: ISOLATE(git worktree 隔离)
|
|
2
|
+
|
|
3
|
+
**执行时机**: `/sprint-flow` 启动后、Phase 0 THINK 之前。**自动执行**。
|
|
4
|
+
|
|
5
|
+
**目的**: 默认在 git worktree 中隔离 sprint 工作,防止在保护分支上直接运行导致代码污染。
|
|
6
|
+
|
|
7
|
+
**AI agent 直接执行 bash 命令**(不需要调用外部 skill),步骤如下:
|
|
8
|
+
|
|
9
|
+
| 步骤 | 动作 | 说明 |
|
|
10
|
+
|------|------|------|
|
|
11
|
+
| 0 | **检测当前环境** | 运行 `git rev-parse --git-dir` 和 `git rev-parse --git-common-dir`。如果 `GIT_DIR != GIT_COMMON`:已在 worktree 中 → 输出 "Already in isolated worktree" → 进入 Phase 0 |
|
|
12
|
+
| 0.5 | **Sprint Lock 检测(Issue #144)** | 检查 `.sprint-state/sprint.lock` 是否存在: `[ -f .sprint-state/sprint.lock ]`。如果存在: 读取锁内容,检查是否 stale(超过 24 小时或 worktree 目录不存在)→ stale → 输出 `[WARN] 发现过期 sprint lock,将覆盖` → 更新锁。非 stale → 输出 `[BLOCK] 已有活跃 sprint (ID: {sprint_id}, started: {started_at})。请先完成当前 sprint 或手动删除 .sprint-state/sprint.lock` → 退出。锁不存在 → 创建锁: `echo '{"sprint_id":"sprint-YYYY-MM-DD-NN","started_at":"<ISO8601>"}' > .sprint-state/sprint.lock` |
|
|
13
|
+
| 1 | **检查保护分支** | 获取当前分支名 `git branch --show-current`。保护分支列表: `main, master, develop, trunk, mainline`。保护分支 → 强制创建 worktree。非保护分支 → 依然创建 worktree(推荐,不阻断) |
|
|
14
|
+
| 2 | **创建 worktree** | 创建目录: `mkdir -p .worktrees/sprint`。检测已有 NN 编号: `ls .worktrees/sprint/ 2>/dev/null \| grep -oE '[0-9]{2}$' \| sort -n \| tail -1`(取最后两位数字,数值排序,取最大),NN = 结果 + 1(无结果则从 01 开始)。运行 `git worktree add .worktrees/sprint/sprint-YYYY-MM-DD-NN -b sprint/YYYY-MM-DD-NN`。**注意**: `cd` 在 AI agent 单次工具调用中不保持状态,步骤 3-6 必须通过 `workdir` 参数或 `&&` 链式命令在新 worktree 目录下执行 |
|
|
15
|
+
| 3 | **项目 setup** | 在 worktree 目录下: 检测项目类型: `package.json` → `npm install`, `go.mod` → `go mod download`, `pyproject.toml` → `pip/poetry install` |
|
|
16
|
+
| 4 | **.gitignore 校验** | 在**仓库根目录**(非 worktree)执行: `git check-ignore -q .worktrees`。如果未忽略 → 将 `.worktrees/` 添加到 `.gitignore` → `git add .gitignore` → `git commit -m 'chore: ignore .worktrees directory'` |
|
|
17
|
+
| 5 | **Sprint State 记录** | `mkdir -p .sprint-state` 在 worktree 目录下。写入 `.sprint-state/sprint-state.json`(如已存在则合并,保留原有字段),新增/更新 `isolation` 对象,设置 `phase: -1`,`status: "running"` |
|
|
18
|
+
| 6 | **基线验证** | 在 worktree 目录下: 检测测试方式(package.json 有 "test" script → `npm test`, go.mod → `go test ./...`, pyproject.toml → `pytest`)。测试失败 → 输出失败信息 → 询问用户是否继续 |
|
|
19
|
+
|
|
20
|
+
## 参数处理
|
|
21
|
+
|
|
22
|
+
- `--no-isolate`: 跳过自动创建,输出 ⚠️ 警告 `'[WARN] 未创建 worktree 隔离,在 {branch} 分支上直接运行 sprint 有污染风险'` → 进入 Phase 0
|
|
23
|
+
- `--branch-name <name>`: 使用自定义分支名(默认自动生成 `sprint/YYYY-MM-DD-NN`),分支名中的 `/` 在 worktree 路径中自动替换为 `-`(如 `feat/user-login` → 分支名 `feat/user-login`,路径 `.worktrees/sprint/feat-user-login`)
|
|
24
|
+
- `--force`: 强制在当前分支继续(即使已是保护分支),**要求用户显式确认**: 输出 ⚠️ 警告 `'[WARN] 使用 --force 在 {branch} 分支上直接运行 sprint。此操作绕过隔离保护,请确认风险。'` → 等待用户确认("继续" / "取消") → 确认后进入 Phase 0
|
|
25
|
+
|
|
26
|
+
## 参数交互规则
|
|
27
|
+
|
|
28
|
+
| 参数组合 | 行为 |
|
|
29
|
+
|---------|------|
|
|
30
|
+
| `--no-isolate` 单独 | 跳过隔离,输出警告 → Phase 0 |
|
|
31
|
+
| `--force` 单独 | 跳过隔离,要求确认 → Phase 0 |
|
|
32
|
+
| `--no-isolate` + `--branch-name` | `--branch-name` 忽略,仅 `--no-isolate` 生效 |
|
|
33
|
+
| `--force` + `--branch-name` | `--branch-name` 忽略,仅 `--force` 生效 |
|
|
34
|
+
| `--no-isolate` + `--force` | 等效,输出 `--no-isolate` 警告 → Phase 0 |
|
|
35
|
+
| `--resume-from build` + `--no-isolate` | `--resume-from` 优先,直接跳过 Phase -1 |
|
|
36
|
+
|
|
37
|
+
## 错误处理和回退
|
|
38
|
+
|
|
39
|
+
| 错误场景 | 回退行为 |
|
|
40
|
+
|---------|---------|
|
|
41
|
+
| `git worktree add` 失败(沙箱/权限问题) | 输出 `[ERROR] git worktree add 失败: {error}` → `[WARN] 无法创建 worktree 隔离,将在当前目录继续。请手动设置隔离分支。` → 在当前目录继续 |
|
|
42
|
+
| `.gitignore` 自动添加失败 | 输出 `[WARN] 无法自动添加 .gitignore,请手动将 .worktrees/ 添加到 .gitignore` → 继续 |
|
|
43
|
+
| 基线测试失败 | 输出 `[FAIL] 基线测试未通过:` + 失败详情 → 询问用户 `'基线测试失败,是否继续 sprint?(y/N)'` |
|
|
44
|
+
|
|
45
|
+
## sprint-state.json isolation 对象格式
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"isolation": {
|
|
50
|
+
"worktree_path": ".worktrees/sprint/sprint-2026-05-24-01",
|
|
51
|
+
"branch": "sprint/2026-05-24-01",
|
|
52
|
+
"created_from": "main",
|
|
53
|
+
"created_from_commit": "abc123def..."
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
> **清理提示**: Sprint 完成(Phase 6 SHIP)后,执行 `git worktree remove <worktree_path>` 清理 worktree 目录,同时保留 `.sprint-state/` 中的历史记录。
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
|
|
2
2
|
|
|
3
3
|
**Generated:** 2026-06-17
|
|
4
|
-
**Commit:**
|
|
5
|
-
**Branch:**
|
|
6
|
-
**Version:** 0.8.
|
|
4
|
+
**Commit:** c0c52f4
|
|
5
|
+
**Branch:** main
|
|
6
|
+
**Version:** 0.8.21.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|