@phi-code-admin/phi-code 0.96.1 → 0.97.0

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.
@@ -21,6 +21,7 @@ import { access, mkdir, readFile, writeFile } from "node:fs/promises";
21
21
  import { homedir } from "node:os";
22
22
  import { join } from "node:path";
23
23
  import { type ExtensionAPI, type ExtensionContext, getApiKeyStore } from "phi-code";
24
+ import { getProviderCatalog } from "./providers/catalog.js";
24
25
 
25
26
  // ─── Types ───────────────────────────────────────────────────────────────
26
27
 
@@ -340,56 +341,9 @@ function extractCode(response: string): string {
340
341
  return match ? match[1].trim() : response.trim();
341
342
  }
342
343
 
343
- interface ProviderConfig {
344
- name: string;
345
- envVar: string;
346
- baseUrl: string;
347
- models: string[];
348
- }
349
-
350
- function getProviderConfigs(): ProviderConfig[] {
351
- return [
352
- {
353
- name: "alibaba-codingplan",
354
- envVar: "ALIBABA_CODING_PLAN_KEY",
355
- baseUrl: "https://coding-intl.dashscope.aliyuncs.com/v1",
356
- models: [
357
- "qwen3.5-plus",
358
- "qwen3-max-2026-01-23",
359
- "qwen3-coder-plus",
360
- "qwen3-coder-next",
361
- "kimi-k2.5",
362
- "glm-5",
363
- "glm-4.7",
364
- "MiniMax-M2.5",
365
- ],
366
- },
367
- {
368
- name: "openai",
369
- envVar: "OPENAI_API_KEY",
370
- baseUrl: "https://api.openai.com/v1",
371
- models: ["gpt-4o", "gpt-4o-mini"],
372
- },
373
- {
374
- name: "anthropic-openai",
375
- envVar: "ANTHROPIC_API_KEY",
376
- baseUrl: "https://api.anthropic.com/v1",
377
- models: [],
378
- },
379
- {
380
- name: "openrouter",
381
- envVar: "OPENROUTER_API_KEY",
382
- baseUrl: "https://openrouter.ai/api/v1",
383
- models: [],
384
- },
385
- {
386
- name: "groq",
387
- envVar: "GROQ_API_KEY",
388
- baseUrl: "https://api.groq.com/openai/v1",
389
- models: [],
390
- },
391
- ];
392
- }
344
+ // Provider list comes from the shared catalog (providers/catalog.ts) — the
345
+ // same source /setup and /phi-init use. Cloud entries expose `benchModels`
346
+ // (the subset /benchmark exercises); local servers are discovered separately.
393
347
 
394
348
  async function getAvailableModels(): Promise<Array<{ id: string; provider: string; baseUrl: string; apiKey: string }>> {
395
349
  const models: Array<{ id: string; provider: string; baseUrl: string; apiKey: string }> = [];
@@ -398,21 +352,23 @@ async function getAvailableModels(): Promise<Array<{ id: string; provider: strin
398
352
  // models.json via /setup or /keys (the store resolves env-var names and
399
353
  // "!cmd" values the same way the model registry does at request time).
400
354
  const store = getApiKeyStore();
401
- for (const provider of getProviderConfigs()) {
355
+ for (const provider of getProviderCatalog()) {
356
+ if (provider.local) continue;
357
+ const benchModels = provider.benchModels ?? [];
402
358
  let apiKey = process.env[provider.envVar];
403
359
  if (!apiKey) {
404
360
  try {
405
- apiKey = store.getKey(provider.name);
361
+ apiKey = store.getKey(provider.id);
406
362
  } catch {
407
363
  /* unreadable models.json — env-only behavior */
408
364
  }
409
365
  }
410
366
  if (!apiKey) continue;
411
367
 
412
- for (const modelId of provider.models) {
368
+ for (const modelId of benchModels) {
413
369
  models.push({
414
370
  id: modelId,
415
- provider: provider.name,
371
+ provider: provider.id,
416
372
  baseUrl: provider.baseUrl,
417
373
  apiKey,
418
374
  });
@@ -744,8 +700,8 @@ Scoring: S (80+), A (65+), B (50+), C (35+), D (<35)`,
744
700
  // Get available models (validates API keys are non-empty and reasonable length)
745
701
  const available = await getAvailableModels();
746
702
  if (available.length === 0) {
747
- const providers = getProviderConfigs();
748
- const hint = providers
703
+ const hint = getProviderCatalog()
704
+ .filter((p) => !p.local)
749
705
  .map((p) => ` ${p.envVar}: ${process.env[p.envVar] ? "set but no models configured" : "not set"}`)
750
706
  .join("\n");
751
707
  ctx.ui.notify(