forked from NoeFabris/opencode-antigravity-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-models.ts
More file actions
175 lines (144 loc) · 5.93 KB
/
test-models.ts
File metadata and controls
175 lines (144 loc) · 5.93 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env npx tsx
import { spawn } from "child_process";
interface ModelTest {
model: string;
category: "gemini-cli" | "antigravity-gemini" | "antigravity-claude";
}
const MODELS: ModelTest[] = [
// Gemini CLI (direct Google API)
{ model: "google/gemini-3-flash-preview", category: "gemini-cli" },
{ model: "google/gemini-3-pro-preview", category: "gemini-cli" },
{ model: "google/gemini-2.5-pro", category: "gemini-cli" },
{ model: "google/gemini-2.5-flash", category: "gemini-cli" },
// Antigravity Gemini
{ model: "google/antigravity-gemini-3-pro-low", category: "antigravity-gemini" },
{ model: "google/antigravity-gemini-3-pro-high", category: "antigravity-gemini" },
{ model: "google/antigravity-gemini-3-flash", category: "antigravity-gemini" },
// Antigravity Claude
{ model: "google/antigravity-claude-sonnet-4-5", category: "antigravity-claude" },
{ model: "google/antigravity-claude-sonnet-4-5-thinking-low", category: "antigravity-claude" },
{ model: "google/antigravity-claude-sonnet-4-5-thinking-medium", category: "antigravity-claude" },
{ model: "google/antigravity-claude-sonnet-4-5-thinking-high", category: "antigravity-claude" },
{ model: "google/antigravity-claude-opus-4-5-thinking-low", category: "antigravity-claude" },
{ model: "google/antigravity-claude-opus-4-5-thinking-medium", category: "antigravity-claude" },
{ model: "google/antigravity-claude-opus-4-5-thinking-high", category: "antigravity-claude" },
{ model: "google/antigravity-claude-opus-4-6-thinking-low", category: "antigravity-claude" },
{ model: "google/antigravity-claude-opus-4-6-thinking-medium", category: "antigravity-claude" },
{ model: "google/antigravity-claude-opus-4-6-thinking-high", category: "antigravity-claude" },
];
const TEST_PROMPT = "Reply with exactly one word: WORKING";
const DEFAULT_TIMEOUT_MS = 120_000;
const OPENCODE_BIN = process.platform === "win32" ? "opencode.cmd" : "opencode";
interface TestResult {
success: boolean;
error?: string;
duration: number;
}
async function testModel(model: string, timeoutMs: number): Promise<TestResult> {
const start = Date.now();
return new Promise((resolve) => {
const proc = spawn(OPENCODE_BIN, ["run", TEST_PROMPT, "--model", model], {
stdio: ["ignore", "pipe", "pipe"],
shell: process.platform === "win32",
});
let stdout = "";
let stderr = "";
const timer = setTimeout(() => {
proc.kill("SIGKILL");
resolve({ success: false, error: `Timeout after ${timeoutMs}ms`, duration: Date.now() - start });
}, timeoutMs);
proc.stdout?.on("data", (data) => { stdout += data.toString(); });
proc.stderr?.on("data", (data) => { stderr += data.toString(); });
proc.on("close", (code) => {
clearTimeout(timer);
const duration = Date.now() - start;
if (code !== 0) {
resolve({ success: false, error: `Exit ${code}: ${stderr || stdout}`.slice(0, 200), duration });
} else {
resolve({ success: true, duration });
}
});
proc.on("error", (err) => {
clearTimeout(timer);
resolve({ success: false, error: err.message, duration: Date.now() - start });
});
});
}
function parseArgs(): { filterModel: string | null; filterCategory: string | null; dryRun: boolean; help: boolean; timeout: number } {
const args = process.argv.slice(2);
const modelIdx = args.indexOf("--model");
const catIdx = args.indexOf("--category");
const timeoutIdx = args.indexOf("--timeout");
return {
filterModel: modelIdx !== -1 ? args[modelIdx + 1] ?? null : null,
filterCategory: catIdx !== -1 ? args[catIdx + 1] ?? null : null,
dryRun: args.includes("--dry-run"),
help: args.includes("--help") || args.includes("-h"),
timeout: timeoutIdx !== -1 ? parseInt(args[timeoutIdx + 1] || "120000", 10) : DEFAULT_TIMEOUT_MS,
};
}
function printHelp(): void {
console.log(`
E2E Model Test Script
Usage:
npx tsx script/test-models.ts [options]
Options:
--model <model> Test specific model
--category <cat> Test by category (gemini-cli, antigravity-gemini, antigravity-claude)
--timeout <ms> Timeout per model (default: 120000)
--dry-run List models without testing
--help, -h Show this help
Examples:
npx tsx script/test-models.ts --dry-run
npx tsx script/test-models.ts --model google/gemini-3-flash-preview
npx tsx script/test-models.ts --category antigravity-claude
`);
}
async function main(): Promise<void> {
const { filterModel, filterCategory, dryRun, help, timeout } = parseArgs();
if (help) {
printHelp();
return;
}
let tests = MODELS;
if (filterModel) tests = tests.filter((t) => t.model === filterModel || t.model.endsWith(filterModel));
if (filterCategory) tests = tests.filter((t) => t.category === filterCategory);
if (tests.length === 0) {
console.log("No models match the filter.");
return;
}
console.log(`\n🧪 E2E Model Tests (${tests.length} models)\n${"=".repeat(50)}\n`);
if (dryRun) {
for (const t of tests) {
console.log(` ${t.model.padEnd(50)} [${t.category}]`);
}
console.log(`\n${tests.length} models would be tested.\n`);
return;
}
let passed = 0;
let failed = 0;
const failures: { model: string; error: string }[] = [];
for (const t of tests) {
process.stdout.write(`Testing ${t.model.padEnd(50)} ... `);
const result = await testModel(t.model, timeout);
if (result.success) {
console.log(`✅ (${(result.duration / 1000).toFixed(1)}s)`);
passed++;
} else {
console.log(`❌ FAIL`);
console.log(` ${result.error}`);
failures.push({ model: t.model, error: result.error || "Unknown" });
failed++;
}
}
console.log(`\n${"=".repeat(50)}`);
console.log(`Summary: ${passed} passed, ${failed} failed\n`);
if (failures.length > 0) {
console.log("Failed models:");
for (const f of failures) {
console.log(` - ${f.model}`);
}
process.exit(1);
}
}
main().catch(console.error);