jsharness 1.0.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/.harness/README.md +199 -0
- package/.harness/agents/code-reviewer/contract.yaml +64 -0
- package/.harness/agents/developer/contract.yaml +72 -0
- package/.harness/agents/gate-controller/contract.yaml +64 -0
- package/.harness/agents/project-manager/contract.yaml +77 -0
- package/.harness/agents/prompt-templates.md +352 -0
- package/.harness/agents/requirements-analyst/contract.yaml +64 -0
- package/.harness/agents/solution-designer/contract.yaml +75 -0
- package/.harness/agents/tester/contract.yaml +92 -0
- package/.harness/config/models.yaml +67 -0
- package/.harness/dev-map/backend/api-definition.md +131 -0
- package/.harness/dev-map/backend/auth-security.md +131 -0
- package/.harness/dev-map/backend/conventions-java.md +471 -0
- package/.harness/dev-map/backend/conventions.md +192 -0
- package/.harness/dev-map/backend/database.md +106 -0
- package/.harness/dev-map/backend/structure.md +140 -0
- package/.harness/dev-map/decisions.md +275 -0
- package/.harness/dev-map/frontend/api-integration.md +139 -0
- package/.harness/dev-map/frontend/components.md +178 -0
- package/.harness/dev-map/frontend/conventions.md +416 -0
- package/.harness/dev-map/frontend/state-management.md +170 -0
- package/.harness/dev-map/frontend/structure.md +103 -0
- package/.harness/dev-map/overview.md +267 -0
- package/.harness/docs/integration-test-plan.md +248 -0
- package/.harness/docs/team-guidelines/README.md +161 -0
- package/.harness/docs/team-guidelines/arch-team.md +811 -0
- package/.harness/docs/team-guidelines/collaboration.md +556 -0
- package/.harness/docs/team-guidelines/pm-team.md +337 -0
- package/.harness/docs/team-guidelines/qa-team.md +562 -0
- package/.harness/docs/team-guidelines/rd-team.md +714 -0
- package/.harness/docs/training-materials.md +280 -0
- package/.harness/gate/baseline.js +220 -0
- package/.harness/gate/checks/build-gates-frontend.js +152 -0
- package/.harness/gate/checks/build-gates-java.js +155 -0
- package/.harness/gate/checks/build-gates.js +119 -0
- package/.harness/gate/checks/engineering-consistency.js +138 -0
- package/.harness/gate/checks/security-quality.js +129 -0
- package/.harness/gate/checks/static-compliance.js +313 -0
- package/.harness/gate/checks/test-compliance.js +114 -0
- package/.harness/gate/index.js +315 -0
- package/.harness/mcp/config.yaml +435 -0
- package/.harness/rules/global/coding-standard.md +232 -0
- package/.harness/rules/global/commit-convention.md +165 -0
- package/.harness/rules/global/process-discipline.md +192 -0
- package/.harness/rules/global/security-baseline.md +306 -0
- package/.harness/rules/project/frontend-vue3.md +293 -0
- package/.harness/rules/project/java-backend.md +460 -0
- package/.harness/rules/project/web-specific.md +231 -0
- package/.harness/skills/build.md +192 -0
- package/.harness/skills/code-review.md +251 -0
- package/.harness/skills/docker-build.md +227 -0
- package/.harness/skills/docs-update.md +164 -0
- package/.harness/skills/java-build.md +261 -0
- package/.harness/skills/lint-check.md +482 -0
- package/.harness/skills/task-board-maintenance.md +105 -0
- package/.harness/skills/test-api.md +461 -0
- package/.harness/skills/test-e2e.md +431 -0
- package/.harness/skills/test-unit.md +649 -0
- package/.harness/skills/vue-frontend-build.md +344 -0
- package/.harness/specs/quality-feedback/implementation-guide.md +350 -0
- package/.harness/task-board.md +121 -0
- package/.harness/workflow/definition.yaml +504 -0
- package/.harness/workflow/validate.js +320 -0
- package/.harness/workflow/variants.yaml +253 -0
- package/README.md +237 -0
- package/bin/jsharness.js +53 -0
- package/lib/index.mjs +778 -0
- package/package.json +1 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness Workflow 校验脚本
|
|
3
|
+
*
|
|
4
|
+
* 用途:检查 workflow 定义文件的完整性和一致性
|
|
5
|
+
* 运行:node .harness/workflow/validate.js
|
|
6
|
+
*
|
|
7
|
+
* 校验项目:
|
|
8
|
+
* 1. 阶段完整性 — 7 个核心阶段是否全部定义
|
|
9
|
+
* 2. Agent-阶段映射一致性 — 每个 stage 有对应的 agent 定义
|
|
10
|
+
* 3. 回退引用有效性 — 所有的 transition.to 引用的阶段都存在
|
|
11
|
+
* 4. 契约文件齐全性 — 每个 agent 目录下都有 contract.yaml
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
|
|
17
|
+
// ============================================================
|
|
18
|
+
// 配置常量
|
|
19
|
+
// ============================================================
|
|
20
|
+
|
|
21
|
+
const HARNESS_ROOT = path.resolve(__dirname, '..');
|
|
22
|
+
const WORKFLOW_DIR = path.join(HARNESS_ROOT, 'workflow');
|
|
23
|
+
const AGENTS_DIR = path.join(HARNESS_ROOT, 'agents');
|
|
24
|
+
const DEFINITION_FILE = path.join(WORKFLOW_DIR, 'definition.yaml');
|
|
25
|
+
const VARIANTS_FILE = path.join(WORKFLOW_DIR, 'variants.yaml');
|
|
26
|
+
|
|
27
|
+
// 核心阶段 ID 列表(必须存在)
|
|
28
|
+
const REQUIRED_STAGES = [
|
|
29
|
+
'requirements-analysis',
|
|
30
|
+
'solution-design',
|
|
31
|
+
'gate-evaluation',
|
|
32
|
+
'development',
|
|
33
|
+
'code-review',
|
|
34
|
+
'testing',
|
|
35
|
+
'delivery'
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
// Agent ID 到目录名的映射
|
|
39
|
+
const AGENT_MAP = {
|
|
40
|
+
'project-manager': 'project-manager',
|
|
41
|
+
'requirements-analyst': 'requirements-analyst',
|
|
42
|
+
'solution-designer': 'solution-designer',
|
|
43
|
+
'gate-controller': 'gate-controller',
|
|
44
|
+
'developer': 'developer',
|
|
45
|
+
'code-reviewer': 'code-reviewer',
|
|
46
|
+
'tester': 'tester'
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// ============================================================
|
|
50
|
+
// 校验逻辑
|
|
51
|
+
// ============================================================
|
|
52
|
+
|
|
53
|
+
class WorkflowValidator {
|
|
54
|
+
constructor() {
|
|
55
|
+
this.errors = [];
|
|
56
|
+
this.warnings = [];
|
|
57
|
+
this.passed = [];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 执行所有校验
|
|
62
|
+
*/
|
|
63
|
+
validateAll() {
|
|
64
|
+
console.log('=== Harness Workflow Validator ===\n');
|
|
65
|
+
|
|
66
|
+
this.checkStageCompleteness();
|
|
67
|
+
this.checkAgentMapping();
|
|
68
|
+
this.checkTransitionValidity();
|
|
69
|
+
this.checkContractFiles();
|
|
70
|
+
this.checkVariantsFile();
|
|
71
|
+
|
|
72
|
+
this.printResults();
|
|
73
|
+
return this.errors.length === 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ----------------------------------------------------------
|
|
77
|
+
// 1. 阶段完整性检查
|
|
78
|
+
// ----------------------------------------------------------
|
|
79
|
+
checkStageCompleteness() {
|
|
80
|
+
console.log('📋 检查 1/5: 阶段完整性...');
|
|
81
|
+
|
|
82
|
+
if (!fs.existsSync(DEFINITION_FILE)) {
|
|
83
|
+
this.errors.push(`❌ 定义文件不存在: ${DEFINITION_FILE}`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const content = fs.readFileSync(DEFINITION_FILE, 'utf-8');
|
|
88
|
+
|
|
89
|
+
for (const stageId of REQUIRED_STAGES) {
|
|
90
|
+
// 使用正则匹配阶段定义
|
|
91
|
+
const pattern = new RegExp(`id:\\s*${stageId.replace('-', '\\-')}`, 'i');
|
|
92
|
+
if (pattern.test(content)) {
|
|
93
|
+
this.passed.push(` ✅ 阶段 "${stageId}" 已定义`);
|
|
94
|
+
} else {
|
|
95
|
+
this.errors.push(` ❌ 缺少阶段定义: ${stageId}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 检查顺序连续性
|
|
100
|
+
const orderPattern = /order:\s*(\d+)/g;
|
|
101
|
+
let orders = [];
|
|
102
|
+
let match;
|
|
103
|
+
while ((match = orderPattern.exec(content)) !== null) {
|
|
104
|
+
orders.push(parseInt(match[1]));
|
|
105
|
+
}
|
|
106
|
+
orders.sort((a, b) => a - b);
|
|
107
|
+
|
|
108
|
+
if (orders.length >= REQUIRED_STAGES.length) {
|
|
109
|
+
for (let i = 0; i < orders.length; i++) {
|
|
110
|
+
if (orders[i] !== i + 1) {
|
|
111
|
+
this.warnings.push(` ⚠️ 阶段序号可能不连续: 期望 ${i+1}, 找到 ${orders[i]}`);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ----------------------------------------------------------
|
|
119
|
+
// 2. Agent-阶段映射检查
|
|
120
|
+
// ----------------------------------------------------------
|
|
121
|
+
checkAgentMapping() {
|
|
122
|
+
console.log('📋 检查 2/5: Agent-阶段映射一致性...');
|
|
123
|
+
|
|
124
|
+
if (!fs.existsSync(AGENTS_DIR)) {
|
|
125
|
+
this.errors.push(`❌ Agents 目录不存在: ${AGENTS_DIR}`);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const content = fs.readFileSync(DEFINITION_FILE, 'utf-8');
|
|
130
|
+
|
|
131
|
+
for (const [agentId, dirName] of Object.entries(AGENT_MAP)) {
|
|
132
|
+
const contractPath = path.join(AGENTS_DIR, dirName, 'contract.yaml');
|
|
133
|
+
|
|
134
|
+
// 检查契约文件是否存在
|
|
135
|
+
if (fs.existsSync(contractPath)) {
|
|
136
|
+
this.passed.push(` ✅ Agent "${agentId}" 契约文件存在`);
|
|
137
|
+
|
|
138
|
+
// 检查 workflow 中是否引用了此 agent
|
|
139
|
+
const agentPattern = new RegExp(`agent:\\s*${agentId.replace('-', '\\-')}`, 'i');
|
|
140
|
+
if (agentPattern.test(content)) {
|
|
141
|
+
this.passed.push(` ✅ Agent "${agentId}" 在 workflow 中被使用`);
|
|
142
|
+
} else {
|
|
143
|
+
this.warnings.push(` ⚠️ Agent "${agentId}" 有契约但在 workflow 中未被分配阶段`);
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
this.errors.push(` ❌ Agent "${agentId}" 缺少契约文件: ${contractPath}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 检查 Prompt 模板
|
|
150
|
+
const promptPath = path.join(AGENTS_DIR, dirName, 'prompt.md') ||
|
|
151
|
+
path.join(AGENTS_DIR, 'prompt-templates.md');
|
|
152
|
+
// prompt 可以在统一文件中,这里只做警告
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ----------------------------------------------------------
|
|
157
|
+
// 3. 回退引用有效性检查
|
|
158
|
+
// ----------------------------------------------------------
|
|
159
|
+
checkTransitionValidity() {
|
|
160
|
+
console.log('📋 检查 3/5: Transition 引用有效性...');
|
|
161
|
+
|
|
162
|
+
if (!fs.existsSync(DEFINITION_FILE)) return;
|
|
163
|
+
|
|
164
|
+
const content = fs.readFileSync(DEFINITION_FILE, 'utf-8');
|
|
165
|
+
|
|
166
|
+
// 收集所有已定义的阶段 ID(包括特殊状态)
|
|
167
|
+
const validTargets = new Set([
|
|
168
|
+
...REQUIRED_STAGES,
|
|
169
|
+
'cancelled', 'completed', 'self', '*'
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
// 匹配所有 transition targets
|
|
173
|
+
const transPattern = /to:\s*([\w-]+)/g;
|
|
174
|
+
let match;
|
|
175
|
+
const foundTargets = new Set();
|
|
176
|
+
|
|
177
|
+
while ((match = transPattern.exec(content)) !== null) {
|
|
178
|
+
const target = match[1];
|
|
179
|
+
foundTargets.add(target);
|
|
180
|
+
|
|
181
|
+
if (validTargets.has(target)) {
|
|
182
|
+
// 有效引用
|
|
183
|
+
} else {
|
|
184
|
+
// 可能是子流程中的自定义目标,只警告
|
|
185
|
+
if (!target.startsWith('_')) {
|
|
186
|
+
this.warnings.push(
|
|
187
|
+
` ⚠️ Transition 目标 "${target}" 可能不在已知阶段列表中`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
this.passed.push(` ✅ 检查了 ${foundTargets.size} 个 transition 目标`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ----------------------------------------------------------
|
|
197
|
+
// 4. 契约文件齐全性检查
|
|
198
|
+
// ----------------------------------------------------------
|
|
199
|
+
checkContractFiles() {
|
|
200
|
+
console.log('📋 检查 4/5: Agent 契约文件齐全性...');
|
|
201
|
+
|
|
202
|
+
if (!fs.existsSync(AGENTS_DIR)) {
|
|
203
|
+
this.errors.push(` ❌ Agents 目录不存在`);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const dirs = fs.readdirSync(AGENTS_DIR, { withFileTypes: true })
|
|
208
|
+
.filter(d => d.isDirectory())
|
|
209
|
+
.map(d => d.name);
|
|
210
|
+
|
|
211
|
+
for (const dirName of dirs) {
|
|
212
|
+
const dirPath = path.join(AGENTS_DIR, dirName);
|
|
213
|
+
const files = fs.readdirSync(dirPath);
|
|
214
|
+
|
|
215
|
+
const hasContract = files.some(f => f === 'contract.yaml' || f === 'contract.yml');
|
|
216
|
+
const hasPrompt = files.some(f =>
|
|
217
|
+
f === 'prompt.md' || f === 'prompt.yaml' || f === 'prompt.yml'
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
if (hasContract && hasPrompt) {
|
|
221
|
+
this.passed.push(` ✅ ${dirName}/: contract + prompt 都存在`);
|
|
222
|
+
} else if (hasContract) {
|
|
223
|
+
this.warnings.push(` ⚠️ ${dirName}/: 有 contract 但缺少 prompt`);
|
|
224
|
+
} else {
|
|
225
|
+
this.errors.push(` ❌ ${dirName}/: 缺少 contract.yaml`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ----------------------------------------------------------
|
|
231
|
+
// 5. 变体文件检查
|
|
232
|
+
// ----------------------------------------------------------
|
|
233
|
+
checkVariants() {
|
|
234
|
+
console.log('📋 检查 5/5: 变体定义文件...');
|
|
235
|
+
|
|
236
|
+
if (fs.existsSync(VARIANTS_FILE)) {
|
|
237
|
+
const content = fs.readFileSync(VARIANTS_FILE, 'utf-8');
|
|
238
|
+
const variantCount = (content.match(/variant_id:/g) || []).length;
|
|
239
|
+
this.passed.push(` ✅ variants.yaml 存在,包含 ${variantCount} 个变体定义`);
|
|
240
|
+
|
|
241
|
+
// 检查必要变体
|
|
242
|
+
const expectedVariants = ['bugfix-lightweight', 'hotfix-emergency', 'doc-config-micro'];
|
|
243
|
+
for (const v of expectedVariants) {
|
|
244
|
+
if (content.includes(v)) {
|
|
245
|
+
this.passed.push(` ✅ 变体 "${v}" 已定义`);
|
|
246
|
+
} else {
|
|
247
|
+
this.warnings.push(` ⚠️ 推荐的变体 "${v}" 未找到`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
this.warnings.push(` ⚠️ variants.yaml 不存在(变体流程将不可用)`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ----------------------------------------------------------
|
|
256
|
+
// 结果输出
|
|
257
|
+
// ----------------------------------------------------------
|
|
258
|
+
printResults() {
|
|
259
|
+
console.log('\n═════════════════════════════════════════');
|
|
260
|
+
console.log('校验结果\n');
|
|
261
|
+
|
|
262
|
+
if (this.passed.length > 0) {
|
|
263
|
+
console.log(`✅ 通过 (${this.passed.length}):`);
|
|
264
|
+
this.passed.forEach(p => console.log(p));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (this.warnings.length > 0) {
|
|
268
|
+
console.log(`\n⚠️ 警告 (${this.warnings.length}):`);
|
|
269
|
+
this.warnings.forEach(w => console.log(w));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (this.errors.length > 0) {
|
|
273
|
+
console.log(`\n❌ 错误 (${this.errors.length}):`);
|
|
274
|
+
this.errors.forEach(e => console.log(e));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
console.log('\n═════════════════════════════════════════');
|
|
278
|
+
|
|
279
|
+
const status = this.errors.length === 0 ? '✅ PASSED' : '❌ FAILED';
|
|
280
|
+
const summary = `总计: ${this.passed.length} 通过, ${this.warnings.length} 警告, ${this.errors.length} 错误`;
|
|
281
|
+
console.log(`${status} | ${summary}\n`);
|
|
282
|
+
|
|
283
|
+
// 输出 JSON 格式供程序调用
|
|
284
|
+
const resultJson = JSON.stringify({
|
|
285
|
+
status: this.errors.length === 0 ? 'pass' : 'fail',
|
|
286
|
+
passed: this.passed.length,
|
|
287
|
+
warnings: this.warnings.length,
|
|
288
|
+
errors: this.errors.length,
|
|
289
|
+
details: {
|
|
290
|
+
passed: this.passed,
|
|
291
|
+
warnings: this.warnings,
|
|
292
|
+
errors: this.errors
|
|
293
|
+
}
|
|
294
|
+
}, null, 2);
|
|
295
|
+
|
|
296
|
+
// 写入校验结果文件
|
|
297
|
+
const outputPath = path.join(HARNESS_ROOT, '..', '..', '.workflow-validation-result.json');
|
|
298
|
+
try {
|
|
299
|
+
// 尝试写到 openspec 目录层级
|
|
300
|
+
fs.writeFileSync(
|
|
301
|
+
path.join(__dirname, '..', '..', '..', '.workflow-validation-result.json'),
|
|
302
|
+
resultJson
|
|
303
|
+
);
|
|
304
|
+
} catch (e) {
|
|
305
|
+
// 如果写失败就跳过,不影响主流程
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ============================================================
|
|
311
|
+
// 执行入口
|
|
312
|
+
// ============================================================
|
|
313
|
+
|
|
314
|
+
if (require.main === module) {
|
|
315
|
+
const validator = new WorkflowValidator();
|
|
316
|
+
const success = validator.validateAll();
|
|
317
|
+
process.exit(success ? 0 : 1);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
module.exports = WorkflowValidator;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Workflow 流程变体定义
|
|
2
|
+
|
|
3
|
+
> 除了标准的七阶段流程外,针对不同场景提供轻量化的变体流程。
|
|
4
|
+
> PM Agent 根据需求分类选择合适的变体。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 变体一:Bug 修复轻量流程
|
|
9
|
+
|
|
10
|
+
**适用场景**: 已知 Bug 的修复,不需要从需求分析开始
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
PM路由 → Gate快速评估(影响面) → 开发修复 → 代码审查 → 测试验证 → 交付归档
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
variant_id: bugfix-lightweight
|
|
18
|
+
name: "Bug 修复轻量流程"
|
|
19
|
+
trigger_condition: |
|
|
20
|
+
需求来源为 Bug Report / Issue
|
|
21
|
+
且 已有复现步骤和期望行为
|
|
22
|
+
stages:
|
|
23
|
+
- id: impact-assessment
|
|
24
|
+
name: "影响面快速评估"
|
|
25
|
+
agent: gate-controller
|
|
26
|
+
model_tier: lite
|
|
27
|
+
purpose: "判断 Bug 的严重程度和影响范围,决定是否走完整流程"
|
|
28
|
+
outputs:
|
|
29
|
+
- severity_rating: [P0/P1/P2/P3]
|
|
30
|
+
- affected_modules: []
|
|
31
|
+
- recommended_variant: [this | hotfix | full_flow]
|
|
32
|
+
|
|
33
|
+
- id: fix-development
|
|
34
|
+
name: "Bug 修复"
|
|
35
|
+
agent: developer
|
|
36
|
+
steps:
|
|
37
|
+
- 定位根因(阅读相关代码)
|
|
38
|
+
- 编写修复代码
|
|
39
|
+
- 编写/更新回归测试用例
|
|
40
|
+
- 运行 Build + Test + Lint
|
|
41
|
+
- 提交 Fix Commit(`fix(scope): description (#issue)`)
|
|
42
|
+
- 创建 PR
|
|
43
|
+
|
|
44
|
+
- id: fix-review
|
|
45
|
+
name: "修复审查"
|
|
46
|
+
agent: code-reviewer
|
|
47
|
+
focus_areas:
|
|
48
|
+
- "修复是否彻底(是否引入新问题)"
|
|
49
|
+
- "回归测试是否充分"
|
|
50
|
+
- "是否影响了其他模块"
|
|
51
|
+
|
|
52
|
+
- id: regression-testing
|
|
53
|
+
name: "回归验证"
|
|
54
|
+
agent: tester
|
|
55
|
+
focus_areas:
|
|
56
|
+
- "原 Bug 是否已修复"
|
|
57
|
+
- "关联功能是否受影响"
|
|
58
|
+
- "是否有新的回归问题"
|
|
59
|
+
|
|
60
|
+
skipped_stages: [requirements-analysis, solution-design]
|
|
61
|
+
estimated_time_reduction: "50-70% vs full flow"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 变体二:紧急热修复最快路径
|
|
67
|
+
|
|
68
|
+
**适用场景**: 生产环境严重故障,需要最短时间内上线修复
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
PM确认 → 紧急授权 → 开发热修 → 最小化审查 → 冒烟测试 → 直接发布
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
variant_id: hotfix-emergency
|
|
76
|
+
name: "热修复最快路径"
|
|
77
|
+
trigger_condition: |
|
|
78
|
+
P0/P1 级生产事故
|
|
79
|
+
且 需要在 4 小时内修复上线
|
|
80
|
+
approval_required: true # 需要技术负责人或 on-call 授权
|
|
81
|
+
approval_role: "tech_lead / on_call_engineer"
|
|
82
|
+
|
|
83
|
+
stages:
|
|
84
|
+
- id: emergency-routing
|
|
85
|
+
name: "紧急路由"
|
|
86
|
+
agent: project-manager
|
|
87
|
+
special_rules:
|
|
88
|
+
- "立即通知相关人员"
|
|
89
|
+
- "暂停该模块其他任务避免冲突"
|
|
90
|
+
- "记录事件时间线"
|
|
91
|
+
|
|
92
|
+
- id: hotfix-dev
|
|
93
|
+
name: "热修复开发"
|
|
94
|
+
agent: developer
|
|
95
|
+
time_box: "2 hours"
|
|
96
|
+
constraints:
|
|
97
|
+
- 只修复问题,不做优化
|
|
98
|
+
- 最小化改动范围
|
|
99
|
+
- 必须附带回归测试
|
|
100
|
+
branch_naming: "hotfix/{description}-{issue}"
|
|
101
|
+
|
|
102
|
+
- id: expedited-review
|
|
103
|
+
name: "加急审查"
|
|
104
|
+
agent: code-reviewer
|
|
105
|
+
time_box: "30 minutes"
|
|
106
|
+
simplified_checklist:
|
|
107
|
+
- 安全性(必须)
|
|
108
|
+
- 修复正确性(必须)
|
|
109
|
+
- 回归风险(必须)
|
|
110
|
+
- 跳过:风格、优化建议
|
|
111
|
+
|
|
112
|
+
- id: smoke-test
|
|
113
|
+
name: "冒烟测试"
|
|
114
|
+
agent: tester
|
|
115
|
+
scope: "仅修复点 + 关联路径"
|
|
116
|
+
test_types:
|
|
117
|
+
- 单元测试(修改的函数)
|
|
118
|
+
- API 测试(影响的端点)
|
|
119
|
+
- E2E 测试(核心用户路径)
|
|
120
|
+
|
|
121
|
+
- id: direct-deploy
|
|
122
|
+
name: "直接发布"
|
|
123
|
+
deploy_method: "hotfix branch → main (fast-forward)"
|
|
124
|
+
post_deploy:
|
|
125
|
+
- 监控告警 30 分钟
|
|
126
|
+
- 确认修复生效
|
|
127
|
+
- 补充完整事后文档
|
|
128
|
+
|
|
129
|
+
skipped_stages: [requirements-analysis, solution-design, full-gate-evaluation, full-test-suite]
|
|
130
|
+
post_completion_required:
|
|
131
|
+
- 事后复盘(Post-mortem)
|
|
132
|
+
- 补充完整的测试覆盖
|
|
133
|
+
- 更新 dev-map 和文档
|
|
134
|
+
- 如果是安全漏洞 → 更新 security-baseline 规则
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 变体三:文档/配置微型流程
|
|
140
|
+
|
|
141
|
+
**适用场景**: 仅涉及文档更新、配置调整、非功能性变更
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
PM路由 → 直接执行 → Lint检查 → 交付归档
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
```yaml
|
|
148
|
+
variant_id: doc-config-micro
|
|
149
|
+
name: "文档/配置微型流程"
|
|
150
|
+
trigger_condition: |
|
|
151
|
+
变更范围仅限于:
|
|
152
|
+
- README / CHANGELOG / 文档文件
|
|
153
|
+
- 配置文件(非敏感)
|
|
154
|
+
- 类型定义文件
|
|
155
|
+
- 测试文件(新增测试用例)
|
|
156
|
+
excluded_changes:
|
|
157
|
+
- 源代码业务逻辑
|
|
158
|
+
- 数据库迁移
|
|
159
|
+
- API 接口变更
|
|
160
|
+
- 依赖版本变更
|
|
161
|
+
|
|
162
|
+
stages:
|
|
163
|
+
- id: micro-change
|
|
164
|
+
name: "微型变更执行"
|
|
165
|
+
agent: developer 或 project-manager(根据内容)
|
|
166
|
+
steps:
|
|
167
|
+
- 执行变更
|
|
168
|
+
- 运行 Lint Check
|
|
169
|
+
- 如涉及代码 → 运行 Build + Test
|
|
170
|
+
- 提交 Commit
|
|
171
|
+
review_requirement:
|
|
172
|
+
- "文档变更": 可选审查
|
|
173
|
+
- "配置变更": 需要 1 人审查(ack 即可)
|
|
174
|
+
- "测试文件": 不需要审查
|
|
175
|
+
|
|
176
|
+
skipped_stages: [requirements-analysis, solution-design, gate-evaluation, code-review(conditional), full-testing]
|
|
177
|
+
estimated_time_reduction: "80% vs full flow"
|
|
178
|
+
quality_gates:
|
|
179
|
+
- Lint 必须通过
|
|
180
|
+
- 如涉及代码 → Build 和 Unit Test 必须通过
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 变体四:安全漏洞响应流程
|
|
186
|
+
|
|
187
|
+
**适用场景**: 安全扫描发现漏洞或收到安全报告
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
安全确认 → 风险评级 → (P0→热修复) / (P1-P2→标准流程加严) → 安全复查 → 发布
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
```yaml
|
|
194
|
+
variant_id: security-response
|
|
195
|
+
name: "安全漏洞响应流程"
|
|
196
|
+
trigger_condition: |
|
|
197
|
+
来源为:
|
|
198
|
+
- npm audit / Snyk 报告
|
|
199
|
+
- 安全团队报告
|
|
200
|
+
- 渗透测试发现
|
|
201
|
+
- HackerOne / SRC 报告
|
|
202
|
+
|
|
203
|
+
special_roles:
|
|
204
|
+
- security_reviewer: "安全专员参与每个阶段"
|
|
205
|
+
- tech_lead: "P0 必须 Tech Lead 审批"
|
|
206
|
+
|
|
207
|
+
severity_routing:
|
|
208
|
+
CRITICAL:
|
|
209
|
+
variant: hotfix-emergency
|
|
210
|
+
additional_steps:
|
|
211
|
+
- 安全团队深度分析
|
|
212
|
+
- 影响面全面排查(不只修一点)
|
|
213
|
+
- 强制安全培训回顾
|
|
214
|
+
HIGH:
|
|
215
|
+
variant: full_flow
|
|
216
|
+
modifications:
|
|
217
|
+
gate_evaluation: "安全专员共同评审"
|
|
218
|
+
code_review: "增加安全审计维度(权重提升至 40%)"
|
|
219
|
+
testing: "增加渗透测试和安全回归"
|
|
220
|
+
MODERATE:
|
|
221
|
+
variant: bugfix-lightweight
|
|
222
|
+
modifications:
|
|
223
|
+
code_review: "安全检查项必查"
|
|
224
|
+
testing: "安全回归测试必跑"
|
|
225
|
+
LOW:
|
|
226
|
+
variant: doc-config-micro or next_sprint
|
|
227
|
+
based_on_effort: true
|
|
228
|
+
|
|
229
|
+
post_completion:
|
|
230
|
+
- 更新 security-baseline 规则(如需要)
|
|
231
|
+
- 记录到 security-incidents.md(dev-map 中)
|
|
232
|
+
- 如果是外部报告 → 按 disclosure policy 处理
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 变体选择决策树
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
收到需求
|
|
241
|
+
│
|
|
242
|
+
┌────────┼────────┐
|
|
243
|
+
▼ ▼ ▼
|
|
244
|
+
安全漏洞? Bug? 新功能?
|
|
245
|
+
│ │ │
|
|
246
|
+
┌───┴───┐ ┌──┴──┐ 标准七阶段流程
|
|
247
|
+
▼ ▼ ▼ ▼
|
|
248
|
+
CRITICAL HIGH P0/P1 P2-P3
|
|
249
|
+
│ │ │ │
|
|
250
|
+
▼ ▼ ▼ ▼
|
|
251
|
+
热修复 标准+加严 热修复 Bug轻量
|
|
252
|
+
安全重点 轻量 流程
|
|
253
|
+
```
|