@phi-code-admin/phi-code 0.96.0 → 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.
Files changed (39) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/dist/cli/args.d.ts +1 -1
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +43 -1
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/core/api-key-store.d.ts +20 -4
  7. package/dist/core/api-key-store.d.ts.map +1 -1
  8. package/dist/core/api-key-store.js +37 -7
  9. package/dist/core/api-key-store.js.map +1 -1
  10. package/dist/core/compaction/compaction.d.ts +16 -0
  11. package/dist/core/compaction/compaction.d.ts.map +1 -1
  12. package/dist/core/compaction/compaction.js +43 -19
  13. package/dist/core/compaction/compaction.js.map +1 -1
  14. package/dist/core/json-utils.d.ts +11 -0
  15. package/dist/core/json-utils.d.ts.map +1 -0
  16. package/dist/core/json-utils.js +15 -0
  17. package/dist/core/json-utils.js.map +1 -0
  18. package/dist/core/model-registry.d.ts +6 -1
  19. package/dist/core/model-registry.d.ts.map +1 -1
  20. package/dist/core/model-registry.js +10 -9
  21. package/dist/core/model-registry.js.map +1 -1
  22. package/dist/core/slash-commands.d.ts +13 -0
  23. package/dist/core/slash-commands.d.ts.map +1 -1
  24. package/dist/core/slash-commands.js +38 -0
  25. package/dist/core/slash-commands.js.map +1 -1
  26. package/dist/migrations.d.ts.map +1 -1
  27. package/dist/migrations.js +2 -2
  28. package/dist/migrations.js.map +1 -1
  29. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  30. package/dist/modes/interactive/interactive-mode.js +24 -4
  31. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  32. package/extensions/phi/benchmark.ts +43 -83
  33. package/extensions/phi/init.ts +86 -673
  34. package/extensions/phi/memory.ts +1 -1
  35. package/extensions/phi/models.ts +4 -3
  36. package/extensions/phi/providers/catalog.ts +133 -0
  37. package/extensions/phi/setup.ts +180 -280
  38. package/extensions/phi/smart-router.ts +0 -17
  39. package/package.json +5 -5
@@ -689,7 +689,7 @@ violates project rules.
689
689
  const locations = [
690
690
  join(process.cwd(), "AGENTS.md"),
691
691
  join(process.cwd(), ".phi", "AGENTS.md"),
692
- join(sigmaMemory.config.memoryDir, "AGENTS.md"),
692
+ join(sigmaMemory.getConfig().memoryDir, "AGENTS.md"),
693
693
  ];
694
694
 
695
695
  for (const agentsPath of locations) {
@@ -159,10 +159,11 @@ async function refreshOne(
159
159
  resolvedApiKey?: string,
160
160
  ): Promise<RefreshOutcome> {
161
161
  const stored = store.getProvider(providerId);
162
- const storedKey =
163
- stored?.apiKey && !stored.apiKey.startsWith("$") && stored.apiKey !== "local" ? stored.apiKey : undefined;
164
- // Prefer the key stored in models.json, else the one resolved from
162
+ // Prefer the key stored in models.json (resolved through the store: env-var
163
+ // names and "!cmd" values yield a usable key, "local" is a sentinel, an
164
+ // unresolved "$NAME" yields undefined), else the one resolved from
165
165
  // auth.json/env by the model registry (providers set up via /auth only).
166
+ const storedKey = stored?.apiKey && stored.apiKey !== "local" ? store.getKey(providerId) : undefined;
166
167
  const apiKey = storedKey ?? resolvedApiKey;
167
168
 
168
169
  // OpenCode Go is a provider pair the generic fetchLiveModels path can't express
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Single provider catalog shared by /setup, /phi-init and /benchmark.
3
+ *
4
+ * Before 0.97.0 each of those three surfaces hardcoded its own provider list
5
+ * (init.ts, setup.ts, benchmark.ts) and they had already drifted (different
6
+ * ids, env vars and model sets for the same provider). This module is the one
7
+ * source of truth; consumers project the fields they need.
8
+ */
9
+
10
+ import { ALIBABA_ENV_VAR, ALIBABA_MODELS, ALIBABA_PROVIDERS } from "./alibaba.js";
11
+ import { OPENCODE_GO_AUTH_URL, OPENCODE_GO_ENV_VAR } from "./opencode-go.js";
12
+
13
+ export interface ProviderCatalogEntry {
14
+ id: string;
15
+ displayName: string;
16
+ envVar: string;
17
+ baseUrl: string;
18
+ api: string;
19
+ /** Known model ids used as offline fallback by the wizards. */
20
+ staticModels: string[];
21
+ /** Models /benchmark exercises when this provider has a key. */
22
+ benchModels?: string[];
23
+ supportsOAuth?: boolean;
24
+ local?: boolean;
25
+ probeUrl?: string;
26
+ docUrl?: string;
27
+ }
28
+
29
+ export function getProviderCatalog(): ProviderCatalogEntry[] {
30
+ return [
31
+ {
32
+ id: "alibaba-codingplan",
33
+ displayName: "Alibaba Coding Plan",
34
+ envVar: ALIBABA_ENV_VAR,
35
+ baseUrl: ALIBABA_PROVIDERS.openai.baseUrl,
36
+ api: "openai-completions",
37
+ staticModels: ALIBABA_MODELS.map((m) => m.id),
38
+ benchModels: [
39
+ "qwen3.5-plus",
40
+ "qwen3-max-2026-01-23",
41
+ "qwen3-coder-plus",
42
+ "qwen3-coder-next",
43
+ "kimi-k2.5",
44
+ "glm-5",
45
+ "glm-4.7",
46
+ "MiniMax-M2.5",
47
+ ],
48
+ docUrl: "https://www.alibabacloud.com/help/en/model-studio/coding-plan",
49
+ },
50
+ {
51
+ id: "opencode-go",
52
+ displayName: "OpenCode Go (zen)",
53
+ envVar: OPENCODE_GO_ENV_VAR,
54
+ baseUrl: "https://opencode.ai/zen/go/v1",
55
+ api: "openai-completions",
56
+ staticModels: [],
57
+ docUrl: OPENCODE_GO_AUTH_URL,
58
+ },
59
+ {
60
+ id: "opencode",
61
+ displayName: "OpenCode Zen",
62
+ envVar: "OPENCODE_API_KEY",
63
+ baseUrl: "https://opencode.ai/zen/v1",
64
+ api: "openai-completions",
65
+ staticModels: [],
66
+ docUrl: OPENCODE_GO_AUTH_URL,
67
+ },
68
+ {
69
+ id: "openai",
70
+ displayName: "OpenAI",
71
+ envVar: "OPENAI_API_KEY",
72
+ baseUrl: "https://api.openai.com/v1",
73
+ api: "openai-completions",
74
+ staticModels: ["gpt-4o", "gpt-4o-mini", "o1", "o3-mini", "gpt-5"],
75
+ benchModels: ["gpt-4o", "gpt-4o-mini"],
76
+ supportsOAuth: true,
77
+ },
78
+ {
79
+ id: "anthropic",
80
+ displayName: "Anthropic",
81
+ envVar: "ANTHROPIC_API_KEY",
82
+ baseUrl: "https://api.anthropic.com/v1",
83
+ api: "anthropic-messages",
84
+ staticModels: ["claude-opus-4-6", "claude-sonnet-4-6", "claude-3-5-haiku-20241022"],
85
+ supportsOAuth: true,
86
+ },
87
+ {
88
+ id: "google",
89
+ displayName: "Google Gemini",
90
+ envVar: "GOOGLE_API_KEY",
91
+ baseUrl: "https://generativelanguage.googleapis.com/v1beta",
92
+ api: "google",
93
+ staticModels: ["gemini-2.5-pro", "gemini-2.5-flash"],
94
+ supportsOAuth: true,
95
+ },
96
+ {
97
+ id: "openrouter",
98
+ displayName: "OpenRouter",
99
+ envVar: "OPENROUTER_API_KEY",
100
+ baseUrl: "https://openrouter.ai/api/v1",
101
+ api: "openai-completions",
102
+ staticModels: [],
103
+ },
104
+ {
105
+ id: "groq",
106
+ displayName: "Groq",
107
+ envVar: "GROQ_API_KEY",
108
+ baseUrl: "https://api.groq.com/openai/v1",
109
+ api: "openai-completions",
110
+ staticModels: ["llama-3.3-70b-versatile", "openai/gpt-oss-120b"],
111
+ },
112
+ {
113
+ id: "ollama",
114
+ displayName: "Ollama (local)",
115
+ envVar: "OLLAMA",
116
+ baseUrl: "http://localhost:11434/v1",
117
+ api: "openai-completions",
118
+ staticModels: [],
119
+ local: true,
120
+ probeUrl: "http://localhost:11434/v1/models",
121
+ },
122
+ {
123
+ id: "lm-studio",
124
+ displayName: "LM Studio (local)",
125
+ envVar: "LM_STUDIO",
126
+ baseUrl: "http://localhost:1234/v1",
127
+ api: "openai-completions",
128
+ staticModels: [],
129
+ local: true,
130
+ probeUrl: "http://localhost:1234/v1/models",
131
+ },
132
+ ];
133
+ }