@boyingliu01/xp-gate 0.12.13 → 0.13.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/adapters/typescript.sh +5 -2
- package/build-integrity/__tests__/ccn-refactor-gate10.test.ts +133 -0
- package/build-integrity/gate-10.ts +111 -123
- package/hooks/gate-3.sh +68 -0
- package/hooks/gate-4.sh +80 -0
- package/hooks/gate-7.sh +45 -0
- package/hooks/gate-8.sh +56 -0
- package/hooks/pre-commit +15 -3
- package/mock-policy/AGENTS.md +4 -4
- package/mutation/AGENTS.md +4 -4
- package/package.json +1 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +4 -4
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +50 -62
- package/plugins/claude-code/skills/sprint-flow/SKILL.md +200 -238
- package/plugins/claude-code/skills/sprint-flow/references/force-levels.md +13 -14
- package/plugins/claude-code/skills/sprint-flow/references/orchestration-rules.md +61 -197
- package/plugins/claude-code/skills/sprint-flow/references/phase-1-prep.md +294 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-2-design.md +194 -0
- package/{skills/sprint-flow/references/phase-2-build.md → plugins/claude-code/skills/sprint-flow/references/phase-3-build.md} +11 -11
- package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +153 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-5-ship.md +40 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-6-close.md +134 -0
- package/plugins/claude-code/skills/sprint-flow/templates/auto-estimate-learning-log.md +1 -1
- package/plugins/claude-code/skills/sprint-flow/templates/auto-estimate-output-template.md +15 -37
- package/plugins/claude-code/skills/sprint-flow/templates/emergent-issues-template.md +7 -7
- package/plugins/claude-code/skills/sprint-flow/templates/pain-document-template.md +5 -5
- package/plugins/claude-code/skills/sprint-flow/templates/sprint-progress-template.md +36 -47
- package/plugins/claude-code/skills/sprint-flow/templates/sprint-summary-template.md +16 -15
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +4 -4
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +4 -4
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +50 -62
- package/plugins/opencode/skills/sprint-flow/SKILL.md +200 -238
- package/plugins/opencode/skills/sprint-flow/references/force-levels.md +13 -14
- package/plugins/opencode/skills/sprint-flow/references/orchestration-rules.md +61 -197
- package/plugins/opencode/skills/sprint-flow/references/phase-1-prep.md +294 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-2-design.md +194 -0
- package/plugins/{claude-code/skills/sprint-flow/references/phase-2-build.md → opencode/skills/sprint-flow/references/phase-3-build.md} +11 -11
- package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +153 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-5-ship.md +40 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-6-close.md +134 -0
- package/plugins/opencode/skills/sprint-flow/templates/auto-estimate-learning-log.md +1 -1
- package/plugins/opencode/skills/sprint-flow/templates/auto-estimate-output-template.md +15 -37
- package/plugins/opencode/skills/sprint-flow/templates/emergent-issues-template.md +7 -7
- package/plugins/opencode/skills/sprint-flow/templates/pain-document-template.md +5 -5
- package/plugins/opencode/skills/sprint-flow/templates/sprint-progress-template.md +36 -47
- package/plugins/opencode/skills/sprint-flow/templates/sprint-summary-template.md +16 -15
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +4 -4
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +4 -4
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +50 -62
- package/plugins/qoder/skills/sprint-flow/SKILL.md +274 -208
- package/plugins/qoder/skills/sprint-flow/references/components/middleware.md +5 -2
- package/plugins/qoder/skills/sprint-flow/references/force-levels.md +13 -14
- package/plugins/qoder/skills/sprint-flow/references/orchestration-rules.md +61 -197
- package/plugins/qoder/skills/sprint-flow/references/phase-1-prep.md +294 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-2-design.md +194 -0
- package/plugins/{opencode/skills/sprint-flow/references/phase-2-build.md → qoder/skills/sprint-flow/references/phase-3-build.md} +11 -11
- package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +153 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-5-ship.md +40 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-6-close.md +134 -0
- package/plugins/qoder/skills/sprint-flow/templates/auto-estimate-learning-log.md +1 -1
- package/plugins/qoder/skills/sprint-flow/templates/auto-estimate-output-template.md +15 -37
- package/plugins/qoder/skills/sprint-flow/templates/emergent-issues-template.md +7 -7
- package/plugins/qoder/skills/sprint-flow/templates/pain-document-template.md +5 -5
- package/plugins/qoder/skills/sprint-flow/templates/sprint-progress-template.md +36 -47
- package/plugins/qoder/skills/sprint-flow/templates/sprint-summary-template.md +16 -15
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +4 -4
- package/principles/AGENTS.md +4 -4
- package/principles/lint-baseline.ts +35 -40
- package/skills/delphi-review/AGENTS.md +4 -4
- package/skills/sprint-flow/AGENTS.md +50 -62
- package/skills/sprint-flow/SKILL.md +200 -238
- package/skills/sprint-flow/references/force-levels.md +13 -14
- package/skills/sprint-flow/references/orchestration-rules.md +61 -197
- package/skills/sprint-flow/references/phase-1-prep.md +294 -0
- package/skills/sprint-flow/references/phase-2-design.md +194 -0
- package/skills/sprint-flow/references/phase-3-build.md +147 -0
- package/skills/sprint-flow/references/phase-4-verify.md +153 -0
- package/skills/sprint-flow/references/phase-5-ship.md +40 -0
- package/skills/sprint-flow/references/phase-6-close.md +134 -0
- package/skills/sprint-flow/templates/auto-estimate-learning-log.md +1 -1
- package/skills/sprint-flow/templates/auto-estimate-output-template.md +15 -37
- package/skills/sprint-flow/templates/emergent-issues-template.md +7 -7
- package/skills/sprint-flow/templates/pain-document-template.md +5 -5
- package/skills/sprint-flow/templates/sprint-progress-template.md +36 -47
- package/skills/sprint-flow/templates/sprint-summary-template.md +16 -15
- package/skills/test-specification-alignment/AGENTS.md +4 -4
- package/plugins/claude-code/skills/sprint-flow/references/phase-0-think.md +0 -115
- package/plugins/claude-code/skills/sprint-flow/references/phase-1-plan.md +0 -178
- package/plugins/claude-code/skills/sprint-flow/references/phase-3-review.md +0 -215
- package/plugins/claude-code/skills/sprint-flow/references/phase-4-uat.md +0 -125
- package/plugins/claude-code/skills/sprint-flow/references/phase-5-feedback.md +0 -100
- package/plugins/claude-code/skills/sprint-flow/references/phase-6-ship.md +0 -9
- package/plugins/claude-code/skills/sprint-flow/references/phase-7-land.md +0 -9
- package/plugins/claude-code/skills/sprint-flow/references/phase-8-cleanup.md +0 -9
- package/plugins/claude-code/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +0 -263
- package/plugins/claude-code/skills/sprint-flow/references/phase-minus-1-isolate.md +0 -58
- package/plugins/opencode/skills/sprint-flow/references/phase-0-think.md +0 -115
- package/plugins/opencode/skills/sprint-flow/references/phase-1-plan.md +0 -178
- package/plugins/opencode/skills/sprint-flow/references/phase-3-review.md +0 -215
- package/plugins/opencode/skills/sprint-flow/references/phase-4-uat.md +0 -125
- package/plugins/opencode/skills/sprint-flow/references/phase-5-feedback.md +0 -100
- package/plugins/opencode/skills/sprint-flow/references/phase-6-ship.md +0 -9
- package/plugins/opencode/skills/sprint-flow/references/phase-7-land.md +0 -9
- package/plugins/opencode/skills/sprint-flow/references/phase-8-cleanup.md +0 -9
- package/plugins/opencode/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +0 -263
- package/plugins/opencode/skills/sprint-flow/references/phase-minus-1-isolate.md +0 -58
- package/plugins/qoder/skills/sprint-flow/references/phase-0-think.md +0 -115
- package/plugins/qoder/skills/sprint-flow/references/phase-1-plan.md +0 -178
- package/plugins/qoder/skills/sprint-flow/references/phase-2-build.md +0 -43
- package/plugins/qoder/skills/sprint-flow/references/phase-3-review.md +0 -215
- package/plugins/qoder/skills/sprint-flow/references/phase-4-uat.md +0 -125
- package/plugins/qoder/skills/sprint-flow/references/phase-5-feedback.md +0 -100
- package/plugins/qoder/skills/sprint-flow/references/phase-6-ship.md +0 -9
- package/plugins/qoder/skills/sprint-flow/references/phase-7-land.md +0 -9
- package/plugins/qoder/skills/sprint-flow/references/phase-8-cleanup.md +0 -9
- package/plugins/qoder/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +0 -263
- package/plugins/qoder/skills/sprint-flow/references/phase-minus-1-isolate.md +0 -58
- package/skills/sprint-flow/references/phase-0-think.md +0 -115
- package/skills/sprint-flow/references/phase-1-plan.md +0 -178
- package/skills/sprint-flow/references/phase-3-review.md +0 -215
- package/skills/sprint-flow/references/phase-4-uat.md +0 -125
- package/skills/sprint-flow/references/phase-5-feedback.md +0 -100
- package/skills/sprint-flow/references/phase-6-ship.md +0 -9
- package/skills/sprint-flow/references/phase-7-land.md +0 -9
- package/skills/sprint-flow/references/phase-8-cleanup.md +0 -9
- package/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +0 -263
- package/skills/sprint-flow/references/phase-minus-1-isolate.md +0 -58
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
# Phase -0.5: AUTO-ESTIMATE(自动化规模评估与流程路由)
|
|
2
|
-
|
|
3
|
-
**执行时机**: Phase -1 ISOLATE 完成后、Phase 0 THINK 之前。**自动执行**。
|
|
4
|
-
|
|
5
|
-
**目的**: 自动评估需求规模,匹配适度流程,避免小需求走重量级流程造成资源浪费。
|
|
6
|
-
|
|
7
|
-
**核心原则**:
|
|
8
|
-
- **客观指标 > 主观判断**:依赖代码结构分析,不依赖人/AI 的主观直觉
|
|
9
|
-
- **显式告知**:用户看到客观指标,不是 AI 主观结论
|
|
10
|
-
- **可纠偏**:用户可接受/修改/取消
|
|
11
|
-
- **学习闭环**:记录用户 override,优化阈值
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 执行流程
|
|
16
|
-
|
|
17
|
-
### 步骤 1: 识别需求类型
|
|
18
|
-
|
|
19
|
-
分析用户输入的需求描述,判定变更类型:
|
|
20
|
-
|
|
21
|
-
| 关键词模式 | 变更类型 | AUTO-ESTIMATE 时机 |
|
|
22
|
-
|-----------|---------|-------------------|
|
|
23
|
-
| 删除、移除、去掉、砍掉、清理 + 已有模块名 | 删除已存在代码 | 立即执行 |
|
|
24
|
-
| 修改、改、调整、重构、优化 + 已有模块名 | 修改已存在代码 | 立即执行 |
|
|
25
|
-
| 新增、添加、开发、实现、创建 + 新模块名 | 新增功能 | brainstorming 后执行 |
|
|
26
|
-
| 修复、fix、bug | Bug 修复 | 立即执行 |
|
|
27
|
-
| 无法判断 | 询问用户 | — |
|
|
28
|
-
|
|
29
|
-
**IF 新增功能**: 跳过当前 AUTO-ESTIMATE,先执行 Phase 0 brainstorming,brainstorming 完成后以设计文档为输入重新执行 AUTO-ESTIMATE。
|
|
30
|
-
|
|
31
|
-
**IF 删除/修改/Bug 修复**: 继续执行以下步骤。
|
|
32
|
-
|
|
33
|
-
### 步骤 2: 收集指标
|
|
34
|
-
|
|
35
|
-
#### 2.1 引用计数
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
# 从用户输入中提取目标关键词(模块名、函数名、类名)
|
|
39
|
-
# 示例:删除平面维护界面 → target="plane", "平面"
|
|
40
|
-
grep -rn "{target_pattern}" --include="*.{ext}" . | grep -v node_modules | grep -v .git | wc -l
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
**阈值**:
|
|
44
|
-
- ≤3: 轻量
|
|
45
|
-
- 4-10: 标准
|
|
46
|
-
- >10: 复杂
|
|
47
|
-
|
|
48
|
-
#### 2.2 跨模块依赖
|
|
49
|
-
|
|
50
|
-
分析引用出现的目录分布:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
# 提取引用所在的目录(取前两级目录)
|
|
54
|
-
grep -rn "{target_pattern}" --include="*.{ext}" . | grep -v node_modules | grep -v .git | \
|
|
55
|
-
awk -F: '{print $1}' | sed 's|/[^/]*$||' | sort -u
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**阈值**:
|
|
59
|
-
- 1 个目录: 轻量
|
|
60
|
-
- 2 个目录: 标准
|
|
61
|
-
- 3+ 个目录: 复杂
|
|
62
|
-
|
|
63
|
-
#### 2.3 循环依赖检测
|
|
64
|
-
|
|
65
|
-
简单检查:如果 A 引用 B 且 B 引用 A,则存在循环依赖。
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
# 简化检测:检查目标是否导入其调用者
|
|
69
|
-
# 这需要根据具体语言调整。对于 TS/JS:
|
|
70
|
-
grep -rn "import.*{target}" --include="*.ts" --include="*.tsx" .
|
|
71
|
-
grep -rn "import.*{caller}" --include="*.ts" --include="*.tsx" {target_dir}/
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**阈值**:
|
|
75
|
-
- 无: 正常
|
|
76
|
-
- 存在: 高风险 → 无论如何输出风险警告
|
|
77
|
-
|
|
78
|
-
#### 2.4 Public API 暴露
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
# 统计目标模块中 export 的数量
|
|
82
|
-
grep -rn "^export " {target_dir}/ --include="*.ts" | wc -l
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**阈值**:
|
|
86
|
-
- ≤2: 低影响
|
|
87
|
-
- 3-5: 中影响
|
|
88
|
-
- >5: 高影响 → 输出风险警告
|
|
89
|
-
|
|
90
|
-
#### 2.5 相关测试文件
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
# 统计与目标相关的测试文件数
|
|
94
|
-
find . -name "*{target}*.test.*" -o -name "*{target}*.spec.*" | grep -v node_modules | wc -l
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**阈值**:
|
|
98
|
-
- 0: 无测试覆盖(风险提示)
|
|
99
|
-
- 1-2: 正常
|
|
100
|
-
- >3: 重构工作量大 → 提示
|
|
101
|
-
|
|
102
|
-
### 步骤 3: 汇总评估
|
|
103
|
-
|
|
104
|
-
根据各指标得分,汇总整体评估结果:
|
|
105
|
-
|
|
106
|
-
```
|
|
107
|
-
总分计算:
|
|
108
|
-
- 引用计数:轻量=1, 标准=2, 复杂=3
|
|
109
|
-
- 跨模块:轻量=1, 标准=2, 复杂=3
|
|
110
|
-
- 循环依赖:无=0, 存在=5(强制复杂)
|
|
111
|
-
- Public API:低=0, 中=1, 高=2
|
|
112
|
-
- 测试文件:正常=0, 多=1
|
|
113
|
-
|
|
114
|
-
总分:1-3 = 轻量 | 4-6 = 标准 | 7+ 或 循环依赖存在 = 复杂
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### 步骤 4: 输出评估结果
|
|
118
|
-
|
|
119
|
-
使用 `templates/auto-estimate-output-template.md` 的标准格式向用户展示评估结果。
|
|
120
|
-
|
|
121
|
-
**MUST** 遵循模板格式,包含:
|
|
122
|
-
- 需求描述 + 变更类型
|
|
123
|
-
- 影响级别标识
|
|
124
|
-
- 各项指标的具体数值
|
|
125
|
-
- 建议流程
|
|
126
|
-
- 风险警告(如有)
|
|
127
|
-
- 用户操作选项
|
|
128
|
-
|
|
129
|
-
### 步骤 5: 处理用户选择
|
|
130
|
-
|
|
131
|
-
#### 用户选择「接受建议」
|
|
132
|
-
|
|
133
|
-
> 按推荐流程执行。保存评估结果到 sprint-state.json。
|
|
134
|
-
|
|
135
|
-
```json
|
|
136
|
-
{
|
|
137
|
-
"auto_estimate": {
|
|
138
|
-
"change_type": "删除已存在代码",
|
|
139
|
-
"metrics": {
|
|
140
|
-
"ref_count": 12,
|
|
141
|
-
"cross_module_count": 3,
|
|
142
|
-
"modules": ["auth", "user", "admin"],
|
|
143
|
-
"circular_dep": true,
|
|
144
|
-
"public_api_count": 5,
|
|
145
|
-
"test_file_count": 4
|
|
146
|
-
},
|
|
147
|
-
"estimated_level": "复杂",
|
|
148
|
-
"recommended_flow": "完整 Sprint Flow (Phase 0-8)",
|
|
149
|
-
"risk_warnings": ["循环依赖: user ↔ plane"],
|
|
150
|
-
"user_decision": "accepted"
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
#### 用户选择「修改流程」
|
|
156
|
-
|
|
157
|
-
> 展示修改流程子菜单(3 个选项:轻量/标准/完整)。
|
|
158
|
-
> 要求用户输入修改原因(必填)。
|
|
159
|
-
|
|
160
|
-
记录到学习日志:
|
|
161
|
-
```json
|
|
162
|
-
{
|
|
163
|
-
"sprint_id": "{sprint_id}",
|
|
164
|
-
"task_description": "{需求描述}",
|
|
165
|
-
"estimated_level": "标准",
|
|
166
|
-
"user_override_level": "轻量",
|
|
167
|
-
"override_reason": "{用户输入原因}",
|
|
168
|
-
"timestamp": "{当前时间}"
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
数据写入 `.sprint-state/auto-estimate-learning.json`(追加模式)。
|
|
173
|
-
|
|
174
|
-
#### 用户选择「取消」
|
|
175
|
-
|
|
176
|
-
> 停止本次 sprint。
|
|
177
|
-
> 输出:`[CANCELLED] 用户取消 Sprint,AUTO-ESTIMATE 评估结果为 {estimated_level}`。
|
|
178
|
-
|
|
179
|
-
### 步骤 6: 路由执行
|
|
180
|
-
|
|
181
|
-
根据最终确定的流程级别,进入对应 Phase:
|
|
182
|
-
|
|
183
|
-
| 流程级别 | 路由 |
|
|
184
|
-
|---------|------|
|
|
185
|
-
| **轻量** | → Phase 0 THINK(reduced-intensity 流程,见 references/force-levels.md) |
|
|
186
|
-
| **标准** | → Phase 0 THINK(正常流程) |
|
|
187
|
-
| **复杂** | → Phase 0 THINK(完整流程 + 风险警告提示) |
|
|
188
|
-
|
|
189
|
-
**DELPHI-GATE invariant**: 所有流程级别(轻量/标准/复杂)的 Phase 2 BUILD 启动前,**必须**检查 `.sprint-state/delphi-reviewed.json` 的 verdict 为 `APPROVED`。未通过 delphi-review 直接路由到 BUILD 属于严重违规。
|
|
190
|
-
|
|
191
|
-
**轻量级的正确理解**: 轻量级意味着 reduced-intensity 的 delphi-review(**2 专家、1 轮、2/2 APPROVED、较短上下文**),**不是**跳过 delphi-review,**不是** 1 专家评审。见 references/force-levels.md 的轻量级流程定义。
|
|
192
|
-
|
|
193
|
-
**自动 escalation 规则**(检测到以下情况时,自动提升流程级别):
|
|
194
|
-
|
|
195
|
-
| 触发条件 | 原级别 | 提升级别 | 理由 |
|
|
196
|
-
|---------|--------|---------|------|
|
|
197
|
-
| 风险警告(循环依赖、Public API > 5) | 轻量 | 标准 | 技术风险需要标准流程 |
|
|
198
|
-
| 多位专家 disagreement 或 REQUEST_CHANGES | 轻量/标准 | 复杂 | 意见分歧需要更全面评审 |
|
|
199
|
-
| 涉及文件数 > 10 或 LOC > 500 | 轻量 | 标准 | 超出轻量级预算 |
|
|
200
|
-
| 修改公共 API(export 接口) | 轻量/标准 | 复杂 | API 变更影响范围广 |
|
|
201
|
-
| 检测到循环依赖 | 任何级别 | 复杂 | 架构风险强制复杂流程 |
|
|
202
|
-
| 相关测试文件缺失或覆盖率 < 80% | 轻量/标准 | 标准 | 需要补充测试 |
|
|
203
|
-
|
|
204
|
-
**跨参考**: 详见 references/force-levels.md 的各级别流程定义和强制规则。
|
|
205
|
-
|
|
206
|
-
---
|
|
207
|
-
|
|
208
|
-
## 特殊场景处理
|
|
209
|
-
|
|
210
|
-
### 场景 1: 小改动(总计 < 20 行新增/删除代码)
|
|
211
|
-
|
|
212
|
-
```bash
|
|
213
|
-
# 检查预估改动量
|
|
214
|
-
git diff --stat HEAD 2>/dev/null # 如果有局部修改
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
**处理**: 如果预估改动 < 20 行且涉及 ≤ 2 个文件,自动判定为「轻量」并告知用户,不强制展示完整 AUTO-ESTIMATE 面板。
|
|
218
|
-
|
|
219
|
-
**注意**: 轻量级仍需要完整的 Sprint Flow 流程(包括 delphi-review),只是 reduced-intensity。见 references/force-levels.md 的轻量级定义。**不会**绕过 DELPHI-GATE 直接路由到 BUILD。
|
|
220
|
-
|
|
221
|
-
### 场景 2: 无法提取目标关键词
|
|
222
|
-
|
|
223
|
-
**处理**: 询问用户「无法自动识别目标模块,请指定要分析的关键词(函数名/类名/模块名):」
|
|
224
|
-
|
|
225
|
-
### 场景 3: 用户输入包含多个独立需求
|
|
226
|
-
|
|
227
|
-
**处理**: 提示用户「检测到多个独立需求,建议分别执行 sprint。是否拆分?」→ 等待确认
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
## 编排注意事项
|
|
232
|
-
|
|
233
|
-
Phase -0.5 经常使用并行 background explore agents 评估代码影响范围。Agent dispatch 后必须遵循 **Background Task Resume Protocol**(参见 `orchestration-rules.md`),在所有 background task 返回后自动恢复继续,不得等待人工消息(Issue #248)。
|
|
234
|
-
|
|
235
|
-
---
|
|
236
|
-
|
|
237
|
-
## 与学习循环的集成
|
|
238
|
-
|
|
239
|
-
### 数据收集
|
|
240
|
-
|
|
241
|
-
每次 sprint 完成(Phase 8 CLEANUP)后,将以下数据记录到 `.sprint-state/auto-estimate-learning.json`:
|
|
242
|
-
|
|
243
|
-
```json
|
|
244
|
-
{
|
|
245
|
-
"entries": [
|
|
246
|
-
{
|
|
247
|
-
"sprint_id": "sprint-YYYY-MM-DD-NN",
|
|
248
|
-
"estimated_level": "标准",
|
|
249
|
-
"user_decision": "accepted",
|
|
250
|
-
"actual_effort_phase_count": 5,
|
|
251
|
-
"actual_duration_minutes": 45,
|
|
252
|
-
"was_accurate": true
|
|
253
|
-
}
|
|
254
|
-
]
|
|
255
|
-
}
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
### 阈值优化
|
|
259
|
-
|
|
260
|
-
当积累 ≥ 20 条记录后,提示用户可以运行阈值分析:
|
|
261
|
-
|
|
262
|
-
> 已积累 {n} 条 AUTO-ESTIMATE 记录。是否运行阈值优化分析?
|
|
263
|
-
> 分析会检查:过度估计(建议标准但实际轻量)、低估(建议轻量但实际复杂),并推荐阈值调整。
|
|
@@ -1,58 +0,0 @@
|
|
|
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/` 中的历史记录。
|