@phi-code-admin/phi-code 0.62.0 → 0.62.1

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.
@@ -80,13 +80,29 @@ export default function smartRouterExtension(pi: ExtensionAPI) {
80
80
  const recommendation = router.getRecommendation(event.text);
81
81
 
82
82
  if (recommendation.category !== "general") {
83
- if (extConfig.notifyOnRecommendation) {
84
- const resolved = resolveModel(recommendation.model, ctx);
85
- const suffix = resolved !== recommendation.model ? ` (→ ${resolved})` : "";
86
- const route = (router as any).config?.routes?.[recommendation.category];
87
- const desc = route?.keywords?.slice(0, 3)?.join(", ") || recommendation.category;
83
+ // Find the recommended model in the registry
84
+ const available = ctx.modelRegistry?.getAvailable?.() || [];
85
+ const targetModel = available.find((m: any) => m.id === recommendation.model);
86
+ const fallbackRoute = (router as any).config?.routes?.[recommendation.category];
87
+ const fallbackModel = fallbackRoute?.fallback
88
+ ? available.find((m: any) => m.id === fallbackRoute.fallback)
89
+ : undefined;
90
+
91
+ const modelToUse = targetModel || fallbackModel;
92
+
93
+ if (modelToUse && modelToUse.id !== ctx.model?.id) {
94
+ // Actually switch the model
95
+ const switched = await pi.setModel(modelToUse);
96
+ if (switched && extConfig.notifyOnRecommendation) {
97
+ ctx.ui.notify(
98
+ `🔀 ${recommendation.category} → \`${modelToUse.id}\`${modelToUse.id !== recommendation.model ? ` (fallback)` : ""}`,
99
+ "info"
100
+ );
101
+ }
102
+ } else if (extConfig.notifyOnRecommendation && !modelToUse) {
103
+ // Model not available — just notify
88
104
  ctx.ui.notify(
89
- `🔀 ${recommendation.category} → \`${recommendation.model}\`${suffix} (${desc})`,
105
+ `🔀 ${recommendation.category} → \`${recommendation.model}\` (not available, keeping current)`,
90
106
  "info"
91
107
  );
92
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phi-code-admin/phi-code",
3
- "version": "0.62.0",
3
+ "version": "0.62.1",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {