@phi-code-admin/phi-code 0.76.12 → 0.76.14
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 +54 -0
- package/package.json +1 -1
package/extensions/phi/init.ts
CHANGED
|
@@ -680,4 +680,58 @@ _Edit this file to customize Phi Code's behavior for your project._
|
|
|
680
680
|
}
|
|
681
681
|
},
|
|
682
682
|
});
|
|
683
|
+
|
|
684
|
+
// ─── /plan-models : lightweight per-role model reconfiguration ─────
|
|
685
|
+
// Standalone alternative to re-running the full /phi-init wizard. Sources the
|
|
686
|
+
// model list from the already-loaded model registry (no provider probing),
|
|
687
|
+
// shows the current routing, and lets you reassign each /plan role with the
|
|
688
|
+
// same provider-qualified picker (id [provider]).
|
|
689
|
+
pi.registerCommand("plan-models", {
|
|
690
|
+
description: "Reconfigure the per-role models used by /plan (provider-qualified, cross-provider)",
|
|
691
|
+
handler: async (_args, ctx) => {
|
|
692
|
+
try {
|
|
693
|
+
const registryModels: Array<{ provider?: string; id?: string }> =
|
|
694
|
+
ctx.modelRegistry?.getAvailable?.() || [];
|
|
695
|
+
const available: Array<{ ref: string; display: string }> = [];
|
|
696
|
+
const seen = new Set<string>();
|
|
697
|
+
for (const m of registryModels) {
|
|
698
|
+
if (!m?.provider || !m?.id) continue;
|
|
699
|
+
const ref = `${m.provider}/${m.id}`;
|
|
700
|
+
if (seen.has(ref)) continue;
|
|
701
|
+
seen.add(ref);
|
|
702
|
+
available.push({ ref, display: `${m.id} [${m.provider}]` });
|
|
703
|
+
}
|
|
704
|
+
if (available.length === 0) {
|
|
705
|
+
ctx.ui.notify(
|
|
706
|
+
"No configured models found. Add a provider via `/phi-init` or `/setup` first.",
|
|
707
|
+
"warning",
|
|
708
|
+
);
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// Show the current per-role assignment as the starting point.
|
|
713
|
+
let current: { routes?: Record<string, { preferredModel?: string; fallback?: string }> } = {};
|
|
714
|
+
try {
|
|
715
|
+
current = JSON.parse(await readFile(join(agentDir, "routing.json"), "utf-8"));
|
|
716
|
+
} catch {
|
|
717
|
+
/* no routing config yet */
|
|
718
|
+
}
|
|
719
|
+
const currentLines = TASK_ROLES.map((r) => {
|
|
720
|
+
const route = current.routes?.[r.key];
|
|
721
|
+
return ` ${r.label}: ${route?.preferredModel || "default"} (fallback: ${route?.fallback || "default"})`;
|
|
722
|
+
}).join("\n");
|
|
723
|
+
ctx.ui.notify(`Current /plan models:\n${currentLines}\n`, "info");
|
|
724
|
+
|
|
725
|
+
const assignments = await manualMode(available, ctx);
|
|
726
|
+
|
|
727
|
+
await ensureDirs();
|
|
728
|
+
const routing = createRouting(assignments);
|
|
729
|
+
await writeFile(join(agentDir, "routing.json"), JSON.stringify(routing, null, 2), "utf-8");
|
|
730
|
+
ctx.ui.notify("Updated `~/.phi/agent/routing.json`. `/plan` will use these per-role models.", "info");
|
|
731
|
+
} catch (error) {
|
|
732
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
733
|
+
ctx.ui.notify(`/plan-models failed: ${message}`, "error");
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
});
|
|
683
737
|
}
|