smoke-test.js
2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* 进化引擎端到端冒烟测试
*
* 用法:
* node packages/evolution/smoke-test.js code-review
* node packages/evolution/smoke-test.js --phase2 <runId>
*/
const { RunController } = require('./run-controller');
const path = require('path');
const DEFAULT_SKILLS_DIR = path.join(require('os').homedir(), '.gemini/antigravity/skills');
async function main() {
const args = process.argv.slice(2);
const skillName = args.find(a => !a.startsWith('--')) || 'code-review';
const isPhase2 = args.includes('--phase2');
const generations = parseInt(args.find(a => a.startsWith('--gens='))?.split('=')[1]) || 1;
const controller = new RunController({
skillsDir: DEFAULT_SKILLS_DIR,
populationSize: 3, // 冒烟测试用小种群
convergenceThreshold: 0.95,
});
console.log('╔════════════════════════════════════════╗');
console.log('║ 进化引擎 — 端到端冒烟测试 ║');
console.log('╚════════════════════════════════════════╝\n');
if (isPhase2) {
if (!skillName || skillName.startsWith('--')) {
console.error('Usage: node smoke-test.js --phase2 <runId> [--gens=1]');
process.exit(1);
}
console.log(`🧪 Phase 2: 自然选择 [${skillName}] × ${generations} 代\n`);
const result = await controller.runPhase2(skillName, generations);
printResult('Phase 2', result);
} else {
console.log(`🧪 Phase 1: 初始化 [${skillName}]\n`);
const result = await controller.runPhase1(skillName);
printResult('Phase 1', result);
if (result.success && result.runId) {
console.log(`\n🧪 Phase 2: 自然选择 [${skillName}] × ${generations} 代\n`);
const p2Result = await controller.runPhase2(result.runId, generations);
printResult('Phase 2', p2Result);
}
}
}
function printResult(phase, result) {
console.log('\n┌────────────────────────────────────────┐');
console.log(`│ ${phase} 结果`);
console.log('├────────────────────────────────────────┤');
for (const [key, value] of Object.entries(result)) {
if (key === 'generationLog') continue;
const val = typeof value === 'object' ? JSON.stringify(value) : value;
console.log(`│ ${key}: ${val}`);
}
console.log('└────────────────────────────────────────┘');
}
main()
.then(() => {
console.log('\n✅ 冒烟测试完成');
})
.catch(err => {
console.error('\n💥 冒烟测试失败:', err.message);
console.error(err.stack);
process.exitCode = 1;
});