@phi-code-admin/phi-code 0.58.3 → 0.58.4
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/extensions/phi/init.ts +22 -16
- package/package.json +1 -1
package/extensions/phi/init.ts
CHANGED
|
@@ -149,12 +149,12 @@ function getAllAvailableModels(providers: DetectedProvider[]): string[] {
|
|
|
149
149
|
// ─── Routing Presets ─────────────────────────────────────────────────────
|
|
150
150
|
|
|
151
151
|
const TASK_ROLES = [
|
|
152
|
-
{ key: "code", label: "Code Generation", desc: "Writing and modifying code", agent: "code", defaultModel: "
|
|
153
|
-
{ key: "debug", label: "Debugging", desc: "Finding and fixing bugs", agent: "code", defaultModel: "
|
|
154
|
-
{ key: "plan", label: "Planning", desc: "Architecture and design", agent: "plan", defaultModel: "
|
|
155
|
-
{ key: "explore", label: "Exploration", desc: "Code reading and analysis", agent: "explore", defaultModel: "
|
|
156
|
-
{ key: "test", label: "Testing", desc: "Running and writing tests", agent: "test", defaultModel: "
|
|
157
|
-
{ key: "review", label: "Code Review", desc: "Quality and security review", agent: "review", defaultModel: "
|
|
152
|
+
{ key: "code", label: "Code Generation", desc: "Writing and modifying code", agent: "code", defaultModel: "default" },
|
|
153
|
+
{ key: "debug", label: "Debugging", desc: "Finding and fixing bugs", agent: "code", defaultModel: "default" },
|
|
154
|
+
{ key: "plan", label: "Planning", desc: "Architecture and design", agent: "plan", defaultModel: "default" },
|
|
155
|
+
{ key: "explore", label: "Exploration", desc: "Code reading and analysis", agent: "explore", defaultModel: "default" },
|
|
156
|
+
{ key: "test", label: "Testing", desc: "Running and writing tests", agent: "test", defaultModel: "default" },
|
|
157
|
+
{ key: "review", label: "Code Review", desc: "Quality and security review", agent: "review", defaultModel: "default" },
|
|
158
158
|
] as const;
|
|
159
159
|
|
|
160
160
|
const KEYWORDS: Record<string, string[]> = {
|
|
@@ -455,16 +455,12 @@ _Edit this file to customize Phi Code's behavior for your project._
|
|
|
455
455
|
// ─── MODE: Benchmark ─────────────────────────────────────────────
|
|
456
456
|
|
|
457
457
|
async function benchmarkMode(availableModels: string[], ctx: any): Promise<Record<string, { preferred: string; fallback: string }>> {
|
|
458
|
-
ctx.ui.notify("🧪 Benchmark mode: running tests on available models...", "info");
|
|
459
|
-
ctx.ui.notify("This will test each model with 6 coding tasks. It may take 10-15 minutes.", "info");
|
|
460
|
-
ctx.ui.notify("💡 Tip: You can run `/benchmark all` separately and use `/benchmark results` to see rankings.\n", "info");
|
|
461
|
-
|
|
462
458
|
// Check if benchmark results already exist
|
|
463
459
|
const benchmarkPath = join(phiDir, "benchmark", "results.json");
|
|
464
460
|
let existingResults: any = null;
|
|
465
461
|
try {
|
|
466
462
|
await access(benchmarkPath);
|
|
467
|
-
const content = await
|
|
463
|
+
const content = await readFile(benchmarkPath, "utf-8");
|
|
468
464
|
existingResults = JSON.parse(content);
|
|
469
465
|
} catch {
|
|
470
466
|
// No existing results
|
|
@@ -473,18 +469,28 @@ _Edit this file to customize Phi Code's behavior for your project._
|
|
|
473
469
|
if (existingResults?.results?.length > 0) {
|
|
474
470
|
const useExisting = await ctx.ui.confirm(
|
|
475
471
|
"Use existing benchmarks?",
|
|
476
|
-
`Found ${existingResults.results.length}
|
|
472
|
+
`Found ${existingResults.results.length} benchmark results from a previous run. Use them?`
|
|
477
473
|
);
|
|
478
474
|
if (useExisting) {
|
|
475
|
+
ctx.ui.notify("📊 Using existing benchmark results for model assignment.\n", "info");
|
|
479
476
|
return assignFromBenchmark(existingResults.results, availableModels);
|
|
480
477
|
}
|
|
481
478
|
}
|
|
482
479
|
|
|
483
|
-
//
|
|
484
|
-
ctx.ui.notify("
|
|
485
|
-
ctx.ui.notify("
|
|
480
|
+
// No existing results or user declined — run benchmarks now
|
|
481
|
+
ctx.ui.notify("🧪 Benchmark mode: launching model tests...", "info");
|
|
482
|
+
ctx.ui.notify("This tests each model with 6 coding tasks via real API calls.", "info");
|
|
483
|
+
ctx.ui.notify("⏱️ Estimated time: 2-3 minutes per model.\n", "info");
|
|
484
|
+
|
|
485
|
+
// Trigger benchmark via sendUserMessage — this runs /benchmark all
|
|
486
|
+
// which saves results to the same results.json path
|
|
487
|
+
ctx.sendUserMessage("/benchmark all");
|
|
488
|
+
ctx.ui.notify("⏳ Benchmarks started. Once complete, run `/phi-init` again and select benchmark mode to use the results.\n", "info");
|
|
489
|
+
ctx.ui.notify("💡 The benchmark runs in the background. You'll see live results in the terminal.\n", "info");
|
|
486
490
|
|
|
487
|
-
//
|
|
491
|
+
// Return auto mode assignments as temporary defaults
|
|
492
|
+
// (will be overwritten when user re-runs /phi-init with benchmark results)
|
|
493
|
+
ctx.ui.notify("📋 Setting auto-mode defaults while benchmarks run...\n", "info");
|
|
488
494
|
return autoMode(availableModels, ctx);
|
|
489
495
|
}
|
|
490
496
|
|