pi-free 2.0.6 → 2.0.8

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 (36) hide show
  1. package/CHANGELOG.md +540 -421
  2. package/README.md +572 -495
  3. package/config.ts +58 -11
  4. package/constants.ts +12 -0
  5. package/index.ts +66 -2
  6. package/lib/model-detection.ts +1 -0
  7. package/lib/model-enhancer.ts +20 -20
  8. package/lib/open-browser.ts +1 -1
  9. package/lib/quota-monitor.ts +123 -0
  10. package/lib/types.ts +101 -101
  11. package/lib/util.ts +460 -351
  12. package/package.json +68 -68
  13. package/provider-failover/benchmark-lookup.ts +743 -702
  14. package/provider-failover/benchmarks-chunk-0.ts +48 -48
  15. package/provider-failover/benchmarks-chunk-1.ts +44 -44
  16. package/provider-failover/benchmarks-chunk-2.ts +39 -39
  17. package/provider-failover/benchmarks-chunk-3.ts +41 -41
  18. package/provider-failover/benchmarks-chunk-4.ts +33 -33
  19. package/providers/cline/cline-auth.ts +473 -473
  20. package/providers/cline/cline-models.ts +2 -2
  21. package/providers/cline/cline.ts +1 -1
  22. package/providers/codestral/codestral.ts +139 -0
  23. package/providers/crofai/crofai.ts +14 -85
  24. package/providers/deepinfra/deepinfra.ts +109 -0
  25. package/providers/kilo/kilo-auth.ts +155 -155
  26. package/providers/kilo/kilo.ts +1 -1
  27. package/providers/llm7/llm7.ts +156 -0
  28. package/providers/model-fetcher.ts +2 -2
  29. package/providers/nvidia/nvidia.ts +4 -4
  30. package/providers/ollama/ollama.ts +1 -1
  31. package/providers/opencode-session.ts +1 -1
  32. package/providers/qwen/qwen-models.ts +101 -101
  33. package/providers/qwen/qwen.ts +1 -1
  34. package/providers/sambanova/sambanova.ts +109 -0
  35. package/providers/zenmux/zenmux.ts +5 -2
  36. package/scripts/check-extensions.mjs +6 -4
package/CHANGELOG.md CHANGED
@@ -1,421 +1,540 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [2.0.4] - 2026-05-02
9
-
10
- ### Fixed
11
-
12
- - **OpenRouter key resolution no longer falls back to `free.json`** —
13
- `getOpenrouterApiKey()` now only checks the `OPENROUTER_API_KEY` environment variable.
14
- Previously it fell back to `~/.pi/free.json`, which could contain stale/revoked keys
15
- that conflict with pi's built-in OpenRouter provider (which reads from
16
- `~/.pi/agent/auth.json`).
17
-
18
- - **Removed `openrouter_api_key` from `PiFreeConfig` interface and config template** —
19
- Prevents future persistence of OpenRouter keys in `free.json`, eliminating the
20
- source of stale key conflicts for built-in providers.
21
-
22
- ## [2.0.3] - 2026-05-02
23
-
24
- ### Added
25
-
26
- - **Consistent `isFreeModel` helper with Route A/B logic** — Created a unified helper for free model detection that automatically detects whether a provider exposes pricing:
27
-
28
- - **Route A (pricing-exposed)**: Model is free if `cost === 0` OR `"free"` in name (OR logic)
29
- - **Route B (non-pricing-exposed)**: Model is free only if `"free"` in name
30
- - Dynamic detection: If ALL models have cost === 0, assumes pricing not exposed → uses Route B
31
- - If ANY model has cost > 0, assumes pricing exposed → uses Route A
32
- - All providers (Cline, Kilo, NVIDIA, Ollama, dynamic built-in) now use this consistent helper
33
-
34
- - **CrofAI provider (PAID)** — Added new **paid** provider for CrofAI (https://crof.ai), an OpenAI-compatible LLM inference API. **Note: CrofAI is a paid provider** — users must have a CrofAI API key with credits. The provider uses Route B detection (name-only) since CrofAI's API doesn't expose per-model pricing. Only models with `"free"` in their names are marked as free (none currently).
35
-
36
- - **ZenMux provider (PAID)** Added new **paid** provider for ZenMux AI gateway (https://zenmux.ai), a unified API for 200+ models from OpenAI, Anthropic, Google, etc. **Note: ZenMux is a paid provider** — users must have a ZenMux API key with credits. The provider uses Route A detection (OR logic) since ZenMux exposes pricing. Models marked as free only if `cost === 0` OR `"free"` in name (2 free models identified: GLM 4.7 Flash Free, GLM 4.6v Flash Free).
37
-
38
- - **Comprehensive `isFreeModel` test suite** — Added 30+ unit tests covering Route A, Route B, freemium behavior, and edge cases. Tests verify correct classification on actual OpenRouter API data (371 models, 30 free).
39
-
40
- - **Toggle commands for dynamic built-in providers** — Added `/toggle-mistral`, `/toggle-groq`,
41
- `/toggle-cerebras`, `/toggle-xai`, and `/toggle-huggingface` commands. These providers were
42
- registered with the global toggle system but lacked per-provider toggle commands, making
43
- free/paid switching inaccessible without editing config files.
44
-
45
- - **Lazy auto-probe for NVIDIA models** — Extracted `runNvidiaProbe()` into a shared function
46
- called automatically on first `session_start` (once per session). Previously, users had to
47
- manually run `/probe-nvidia` to discover 404 models. Now broken models are detected and
48
- auto-hidden on first use.
49
-
50
- ### Changed
51
-
52
- - **Cline provider now uses `isFreeModel`** — Fixed Cline to use the consistent `isFreeModel` helper instead of `m.cost.input === 0`. Previously used cost-only filtering, now uses proper OR logic for pricing-exposed providers.
53
-
54
- - **NVIDIA test expectations updated** — Updated tests to reflect strict Route B behavior (name-only detection for non-pricing-exposed providers). Added test for models with `"free"` in name being marked as free.
55
-
56
- ### Fixed
57
-
58
- - **`provider-factory.ts` — `beforeProviderRequest` hook now scoped to owning provider** —
59
- The hook was firing for **all** provider requests regardless of which provider the factory
60
- was configuring. Now checks `evt.provider !== def.providerId` and returns early if the
61
- event doesn't belong to the owning provider.
62
-
63
- - **`provider-factory.ts` — `reRegister` callback no longer corrupts stored model lists** —
64
- When toggling between free/paid modes, the callback was overwriting `stored.all` with only
65
- the filtered subset, losing the original full model list. Now preserves the original model
66
- lists for correct subsequent toggling.
67
-
68
- - **`lib/types.ts` Removed leftover `LspTestInterface`** Removed a test interface that
69
- was left in production code.
70
-
71
- - **`index.ts` — Removed redundant `.catch()` on deprecated Qwen provider** — The `.catch()`
72
- was unnecessary since `Promise.allSettled` already handles rejections.
73
-
74
- ### Removed
75
-
76
- - **Qwen provider (deprecated)** — Removed Qwen OAuth provider as the 1,000 req/day free tier is no longer available. Provider remains functional for existing authenticated users but new free tier registrations are not supported.
77
-
78
- - **Modal provider** — Removed single-model Modal provider (only had GLM-5.1 FP8). Users should use other providers for GLM models.
79
-
80
- - **Cloudflare provider** Removed Cloudflare Workers AI provider as it's now built into pi core. Users can use pi's built-in Cloudflare provider instead.
81
-
82
- - **Qwen test file** Removed `tests/qwen.test.ts` along with the deprecated provider.
83
-
84
- ## [2.0.2] - 2026-04-26
85
-
86
- ### Added
87
-
88
- - **Model matching debug logging** — Added `~/.pi/modelmatch.log` to diagnose which models get Coding Index scores and which don't:
89
-
90
- - Logs every matching attempt with provider, model ID, normalization strategy, and result
91
- - CSV-like format: `timestamp|provider|modelId|modelName|action|strategy|normalizedId|matchKey|codingIndex|details`
92
- - Provider-specific normalizers for better matching:
93
- - **NVIDIA**: Strips vendor prefixes (`meta/`, `mistralai/`, `microsoft/`, `qwen/`, etc.)
94
- - **Cloudflare**: Strips `@cf/namespace/` prefixes
95
- - **Groq**: Removes `-versatile` and numeric context suffixes (`-32768`)
96
- - **Cerebras**: Normalizes `llama3.1` `llama-3.1`, auto-adds `instruct` suffix
97
- - **Mistral**: Strips `-latest` suffix
98
- - **Ollama**: Converts `model:tag` `model-tag`
99
- - Common suffix stripping: `:free`, date codes (`-20250514`), versions (`-v1.1`), `-it`, `-fp8`/`-bf16`
100
-
101
- - **Enhanced benchmark lookup** — `enhanceModelNameWithCodingIndex()` now accepts optional `provider` parameter for provider-aware normalization
102
-
103
- - **Static 404 model blocklist for NVIDIA** — Probed all 136 models from `integrate.api.nvidia.com/v1/models` and identified 57 that return 404 "Function not found" on `/v1/chat/completions`. These are now hard-filtered so they never appear in the model selector:
104
-
105
- - Covers discontinued models (`databricks/dbrx-instruct`, `meta/codellama-70b`, `meta/llama2-70b`, `ibm/granite-*`, etc.)
106
- - Covers embedding-only models listed as chat-capable (`nvidia/nv-embed-v1`, `nvidia/nv-embedqa-*`, `snowflake/arctic-embed-l`, etc.)
107
- - Covers stale API catalog entries (`mistralai/mistral-large`, `mistralai/mistral-large-2-instruct`, `writer/palmyra-*`, etc.)
108
- - Full list in `NVIDIA_KNOWN_404_MODELS` in `providers/nvidia/nvidia.ts`
109
-
110
- - **`/probe-nvidia` command** — On-demand model health check. Tests every registered NVIDIA model with a minimal `max_tokens: 1` request, auto-hides any new 404s in `~/.pi/free.json`, and re-registers the provider immediately.
111
-
112
- - **`scripts/probe-nvidia.mjs`** — Standalone Node.js script to reproduce the probe. Reads `~/.pi/free.json` for the API key, batches 20 requests at a time with 10s timeout, and prints all broken model IDs for adding to the blocklist.
113
-
114
- - **Ollama Cloud 403 handling** — Same pattern as NVIDIA 404s for Ollama Cloud:
115
-
116
- - `OLLAMA_KNOWN_403_MODELS` blocklist for models that return 403 "access denied"
117
- - `/probe-ollama` command to test all models on-demand, auto-hide broken ones, and re-register
118
- - `scripts/probe-ollama.mjs` standalone script for blocklist maintenance
119
-
120
- - **Provider-scoped hidden models** — Hidden models are now provider-specific:
121
- - Format: `"provider/model-id"` (e.g., `"ollama/kimi-k2.6"`, `"nvidia/broken-model"`)
122
- - A model hidden from one provider doesn't hide it from other providers
123
- - Backward compatible with old global `"model-id"` format
124
- - All providers updated: NVIDIA, Ollama, Cloudflare, Cline, Kilo, Modal
125
-
126
- ### Fixed
127
-
128
- - **Probe commands timeout handling** — Added `fetchWithTimeout` with 10-second timeout to `/probe-nvidia` and `/probe-ollama` commands. Prevents the coding harness from freezing when individual model probe requests hang indefinitely.
129
-
130
- - **NVIDIA provider now sends `authHeader: true`** — Explicitly enables `Authorization: Bearer` header injection. Previously relied on pi's implicit behavior which could fail in some configurations.
131
-
132
- ### Removed
133
-
134
- - **NVIDIA 404 model warning log** — Removed the `console.warn("[nvidia] Skipping known 404 model: ...")` output when filtering out known broken models. The filter still works silently; use `/probe-nvidia` to identify new 404s if needed.
135
-
136
- ### Changed
137
-
138
- - **Cloudflare provider now fetches models dynamically** — Replaced static 19-model hardcoded list with live API fetch from `api.cloudflare.com/client/v4/accounts/{account_id}/ai/models`:
139
-
140
- - Automatically discovers all 30+ text generation models (was manually maintaining 19)
141
- - Smart filtering excludes embeddings, image generation, speech, translation, and vision-only models via regex patterns
142
- - Metadata inference from model IDs: detects vision (`vision`/`multimodal`), reasoning (`r1`/`thinking`/`qwq`), context windows, and estimated costs
143
- - Fixed Mistral Small ID: changed from incorrect `@cf/mistralai/...` to correct `@cf/mistral/...`
144
- - Added new fallback models: Kimi K2.6, OpenAI GPT-OSS 120B/20B, Qwen 2.5 Coder 32B, QwQ 32B, Llama 3.2 11B Vision
145
- - Graceful fallback to expanded 18-model hardcoded list if API fetch fails
146
-
147
- - **NVIDIA provider now queries NVIDIA's API directly** — Source of truth switched from `models.dev` curated JSON to `https://integrate.api.nvidia.com/v1/models`:
148
- - Eliminates 57 missing models and 25 stale entries from the old third-party source
149
- - Models not in `models.dev` get inferred metadata (128k context, 4k output, vision/reasoning heuristics)
150
- - Added regex-based non-chat model filtering for unknown models (embeddings, whisper, reward models, safety guards, parsers, detectors, etc.)
151
- - Graceful fallback to `models.dev` if NVIDIA API is unreachable
152
- - Removed paid/free toggle filtering — NVIDIA is freemium (all models use free credits)
153
-
154
- ## [2.0.1] - 2026-04-24
155
-
156
- ### Added
157
-
158
- - **Built-in provider toggle support** (`lib/built-in-toggle.ts`) Enables free/paid filtering for Pi's built-in providers that expose per-model pricing:
159
- - **OpenCode (`/toggle-opencode`)** Captures built-in OpenCode models on session start and filters to free-only by default
160
- - **OpenRouter (`/toggle-openrouter`)** Now uses the built-in toggle system for consistency
161
- - Toggle works in the current session (no restart needed)
162
- - Persisted via `opencode_show_paid` and `openrouter_show_paid` in `~/.pi/free.json`
163
-
164
- ### Changed
165
-
166
- - **OpenRouter moved to built-in toggle system** — OpenRouter is now handled by `lib/built-in-toggle.ts` alongside OpenCode for a unified approach:
167
-
168
- - Removed from `providers/dynamic-built-in/index.ts`
169
- - Eliminated duplicate toggle command registration logic
170
- - Consolidated toggle persistence with other built-in providers
171
-
172
- - **Standardized all toggle commands to `toggle-{provider}`** — Renamed from `{provider}-toggle` for consistency:
173
- - `/kilo-toggle` `/toggle-kilo`
174
- - `/cline-toggle` `/toggle-cline`
175
- - `/openrouter-toggle` `/toggle-openrouter`
176
- - `/nvidia-toggle` `/toggle-nvidia`
177
- - `/cloudflare-toggle` → `/toggle-cloudflare`
178
- - `/ollama-toggle` → `/toggle-ollama`
179
- - `/mistral-toggle` → `/toggle-mistral`
180
- - `/groq-toggle` `/toggle-groq`
181
- - `/cerebras-toggle` → `/toggle-cerebras`
182
- - `/toggle-opencode` (new)
183
-
184
- ### Fixed
185
-
186
- - **Ollama Cloud model fetching endpoint** Corrected the `/v1/models` `/models` endpoint path in `providers/ollama/ollama.ts`:
187
- - The previous fix (2.0.0) incorrectly used `/v1/models`; Ollama Cloud's models endpoint is `/v1/models` for chat completions but `/models` for listing
188
- - This ensures model fetching works correctly with the OpenAI-compatible API
189
-
190
- ### Removed
191
-
192
- - **Global `/free` command** — Removed the global free-only toggle. Per-provider toggles (`/toggle-{provider}`) are now the only way to switch between free and paid models. The `/free-providers` status command remains.
193
-
194
- ## [2.0.0] - 2026-04-23
195
-
196
- ### Breaking Changes
197
-
198
- - **Removed Fireworks provider** — Fireworks is now a built-in Pi provider (added in pi 0.68.1), so the extension's Fireworks provider has been removed to avoid conflicts:
199
-
200
- - Deleted `providers/fireworks/fireworks.ts` and `tests/fireworks.test.ts`
201
- - Removed all Fireworks configuration options from `config.ts` (`fireworks_api_key`, `fireworks_show_paid`)
202
- - Users should now use Pi's built-in Fireworks support with `FIREWORKS_API_KEY`
203
-
204
- - **Renamed Ollama provider to `ollama-cloud`** Changed provider ID from `"ollama"` to `"ollama-cloud"` to avoid collision with Pi's built-in local Ollama provider:
205
- - This prevents provider ID conflicts when both are registered
206
- - All log messages and documentation now reference "Ollama Cloud"
207
-
208
- ### Removed
209
-
210
- - **Dropped `@sinclair/typebox` peer dependency** — Pi 0.69.0 migrated from `@sinclair/typebox` to `typebox` 1.x. The extension didn't directly import this package, so it was removed from `peerDependencies` to avoid potential conflicts.
211
-
212
- ### Fixed
213
-
214
- - **Ollama Cloud API endpoint** — Fixed broken Ollama Cloud integration:
215
- - Changed `BASE_URL_OLLAMA` from `https://ollama.com` to `https://ollama.com/v1` — the OpenAI-compatible API endpoint
216
- - Fixed model fetching to use `/v1/models` instead of `/api/tags` ensures model IDs work with chat completions endpoint
217
- - Previously calls went to HTML homepage instead of API endpoints, causing 404 errors
218
-
219
- ### Removed
220
-
221
- - **Removed paid model warning on selection** — Deleted the `model_select` event handler that showed:
222
-
223
- - `⚠️ Paid model selected (${model.id}). Use "/free off" to enable paid models.`
224
- - This warning was redundant since the global `/free` toggle and provider toggles already control model visibility
225
-
226
- - **Removed pointless `/modal-toggle` command** Modal provider only has 1 free model (GLM-5.1 FP8), so there was nothing meaningful to toggle:
227
- - Added `skipToggle` option to `ProviderDefinition` and `ProviderSetupConfig` interfaces
228
- - Modal provider now sets `skipToggle: true` to prevent toggle command creation
229
-
230
- ### Changed
231
-
232
- - **Marked Qwen provider as fully deprecated** Updated messaging to clarify the provider is broken:
233
- - Changed model name from `"Qwen Coder — Free 1k/day"` to `"Qwen Coder — DEPRECATED (free tier discontinued)"`
234
- - Updated all JSDoc comments to clearly state auth is broken and free tier is no longer available
235
- - Provider remains for backward compatibility but should not be used
236
-
237
- ### Added
238
-
239
- - **Cloudflare Workers AI provider** — New provider for Cloudflare's serverless GPU platform:
240
-
241
- - 50+ open-source models: Llama 4, Mistral Small 3.1, Qwen 2.5/3, DeepSeek R1, Gemma 4, Kimi K2.5/2.6, and more
242
- - **10,000 Neurons/day FREE tier** (resets daily at 00:00 UTC)
243
- - **$0.011 per 1,000 Neurons** beyond free allocation
244
- - Only requires `CLOUDFLARE_API_TOKEN` — account ID auto-derived from token
245
- - Toggle with `/cloudflare-toggle`
246
- - Create token at https://dash.cloudflare.com/profile/api-tokens
247
-
248
- - **Unified dynamic built-in providers module** — New `providers/dynamic-built-in/` module that dynamically fetches models from Pi's built-in providers when users have API keys:
249
-
250
- - **Mistral** (`MISTRAL_API_KEY`) — Fetches from `api.mistral.ai/v1/models`
251
- - **Groq** (`GROQ_API_KEY`) — Fetches from `api.groq.com/openai/v1/models`
252
- - **Cerebras** (`CEREBRAS_API_KEY`) — Fetches from `api.cerebras.ai/v1/models`
253
- - **xAI** (`XAI_API_KEY`) Fetches from `api.x.ai/v1/models`
254
- - **Hugging Face** (`HF_TOKEN` — optional) — Fetches public + authenticated models
255
- - **OpenRouter**Moved from `index.ts` to unified module with dynamic fetch
256
- - All integrate with global `/free` toggle and have per-provider toggle commands (`/mistral-toggle`, `/groq-toggle`, etc.)
257
-
258
- - **Global `/free` toggle system** — New centralized free/paid filtering across ALL providers:
259
- - `/free on/off/status`Toggle free-only view globally
260
- - `/free-providers` — Show free/paid model counts by provider
261
- - `FREE_ONLY` config option and `PI_FREE_ONLY` environment variable
262
- - Providers register via `registerWithGlobalToggle()` for unified filtering
263
-
264
- ### Fixed
265
-
266
- - **Toggle commands now actually filter models from UI** Previously, toggle commands only showed notifications but didn't remove paid models from the model picker:
267
- - **OpenRouter (`/openrouter-toggle`)**: Now uses `registerProvider`/`unregisterProvider` to actually filter models from the picker UI
268
- - **NVIDIA (`/nvidia-toggle`)**: Added dynamic `showPaid` parameter to `fetchNvidiaModels()` so toggle properly switches between free and paid model sets
269
- - **Fireworks**: Removed broken toggle command all models are paid with no free tier, so there was nothing to toggle
270
-
271
- ### Added
272
-
273
- - **OpenRouter per-provider free model toggle** Added `/openrouter-toggle` command for the built-in OpenRouter provider:
274
- - `/openrouter-toggle` Switch between showing only free models vs all models (including paid)
275
- - New config flag `openrouter_show_paid` in `~/.pi/free.json` (default: `false`)
276
- - Environment variable: `OPENROUTER_SHOW_PAID=true` to show paid models by default
277
- - This brings OpenRouter (a built-in pi provider) in line with extension providers that have per-provider toggles
278
-
279
- ### Deprecated
280
-
281
- - **Qwen provider** — The 1,000 requests/day free tier is no longer available from Qwen/DashScope. The provider code remains for backward compatibility but is now deprecated:
282
- - Added `@deprecated` JSDoc tags to all Qwen-related exports
283
- - Added deprecation warning when Qwen provider loads
284
- - Added warning when `QWEN_SHOW_PAID` config is used
285
- - Consider migrating to other free providers: Kilo, Cline, NVIDIA, or Modal
286
-
287
- ### Added
288
-
289
- - **Go provider** — OpenCode Go subscription gateway (⚠️ paid only — $5 first month, then $10/month, no free tier) with models: GLM-5, Kimi K2.5, MiMo-V2-Pro, MiMo-V2-Omni, MiniMax M2.7, MiniMax M2.5
290
- - Set `OPENCODE_GO_API_KEY` or `opencode_go_api_key` in `~/.pi/free.json`
291
- - Toggle with `/go-toggle`
292
-
293
- ### Fixed
294
-
295
- - **All providers now show Coding Index scores in model selector** — Added `enhanceWithCI()` to factory-based providers (nvidia, fireworks, mistral, modal, ollama) and cline. Now all providers display CI scores in `/models` command (pi-models extension).
296
-
297
- - **All providers now show in `--list-models`** — Providers (zen, openrouter, go) that registered models only in `session_start` were missing from `pi --list-models` which runs before session starts. Added immediate registration for these providers:
298
- - **zen**: Added model caching to `~/.pi/provider-cache.json` for immediate registration + dynamic refresh
299
- - **openrouter**: Immediate model registration at extension load (like kilo/cline)
300
- - **go**: Immediate registration with static model list (no API to fetch from)
301
- - All 11 providers now visible in `--list-models`
302
-
303
- ### Changed
304
-
305
- - Updated README with clear free vs paid provider distinction (9 free + 2 paid-only: Go, Fireworks)
306
- - Added Go and Fireworks provider documentation under new "💳 Paid-Only Providers" section
307
- - Added `opencode_go_api_key` to config file template
308
- - Updated package.json description and keywords to include all 11 providers
309
-
310
- ### Added
311
-
312
- - **Provider model cache** (`lib/provider-cache.ts`) — New utility for caching provider model lists to `~/.pi/provider-cache.json`. Used by zen provider for faster startup and offline access after first successful fetch.
313
-
314
- ## [1.0.9] - 2026-04-14
315
-
316
- ### Fixed
317
-
318
- - **Qwen OAuth breaks other OAuth providers** — `modifyModels` receives all models across every registered provider, not just Qwen's. The previous `map()` stamped the Qwen dashscope `baseUrl` onto every model, causing other OAuth providers (Kilo, OpenRouter, etc.) to return 404 after a `/login qwen` flow. Now only models with `provider === PROVIDER_QWEN` are patched; others pass through unchanged.
319
-
320
- ## [1.0.8] - 2026-04-13
321
-
322
- ### Added
323
-
324
- - **Modal provider** Free access to GLM-5.1 FP8 (128k context, 16k max output) during promotional period (free until April 30, 2026)
325
- - Requires a free Modal API key (`MODAL_API_KEY` or `modal_api_key` in `~/.pi/free.json`)
326
- - Model: `zai-org/GLM-5.1-FP8` 128k context window, 16k max output tokens
327
- - **Qwen provider** Free access to Qwen Coder (1,000 requests/day) via OAuth device flow
328
- - Run `/login qwen` to authenticate through Qwen Studio (chat.qwen.ai)
329
- - Uses `coder-model` alias (maps to Qwen3.6-Plus on the backend)
330
- - 131k context window, 16k max output tokens, zero cost
331
-
332
- ### Fixed
333
-
334
- - **Qwen OAuth browser launch on Windows** — URLs with `&` query params were truncated by `cmd.exe`'s `&` command separator; switched to `powershell.exe Start-Process` which passes the URL as a literal string
335
- - **Qwen API endpoint** — Replicates qwen-code's `getCurrentEndpoint()` logic: uses `resource_url` from OAuth token response (`dashscope.aliyuncs.com` for Chinese accounts, `portal.qwen.ai` for international), with fallback to `dashscope.aliyuncs.com/compatible-mode/v1`
336
- - **Qwen DashScope headers** — Added all headers required by DashScope's OpenAI-compatible API: `X-DashScope-AuthType: qwen-oauth`, `X-DashScope-CacheControl: enable`, `X-DashScope-UserAgent`, `Client-Code: QwenCode`
337
- - **Qwen modifyModels crash** `modifyModels` must be synchronous; making it async caused the pi framework to receive a `Promise` instead of a `Model[]`, breaking `ModelRegistry.find()`
338
-
339
- ## [1.0.5] - 2025-04-03
340
-
341
- ### Fixed
342
-
343
- - **NVIDIA provider non-chat model filtering** (comment/implementation mismatch)
344
- - Added modalities-based filtering to exclude embedding, speech-to-text, OCR, and image-gen models
345
- - Filters models where `output` is not `["text"]` (e.g., image generation like `black-forest-labs/flux.1-dev`)
346
- - Filters models where `input` lacks `"text"` (e.g., OCR like `nvidia/nemoretriever-ocr-v1`, speech-to-text like `openai/whisper-large-v3`)
347
- - Updated file comment to accurately describe the filtering behavior
348
- - Added 8 comprehensive unit tests for model filtering logic
349
-
350
- ## [1.0.4] - 2025-04-03
351
-
352
- ### Fixed
353
-
354
- - **All tests now passing** (127/127)
355
- - Fixed mock paths in kilo.test.ts, zen.test.ts, ollama.test.ts
356
- - Fixed createCtxReRegister mocks in zen.test.ts and openrouter.test.ts
357
- - Fixed cline.test.ts to test actual provider re-registration behavior
358
- - Added missing DEFAULT_MIN_SIZE_B constant to openrouter mock
359
-
360
- ### Changed
361
-
362
- - **Code quality improvements**
363
- - Refactored usage modules to break circular dependency (limits.ts ↔ formatters.ts)
364
- - Created usage/types.ts with shared interfaces (FreeTierLimit, FreeTierUsage)
365
- - Bumped version to 1.0.4
366
-
367
- ## [1.0.3] - 2025-04-03
368
-
369
- ### Changed
370
-
371
- - Updated package.json metadata (name, description, keywords, repository URL)
372
- - Updated .npmignore for cleaner publishes
373
-
374
- ## [1.0.0] - 2024-03-28
375
-
376
- ### Added
377
-
378
- - Initial release with 6 providers: Kilo, Zen, OpenRouter, NVIDIA, Cline, Fireworks
379
- - Free tier usage tracking across all sessions
380
- - Provider failover with model hopping
381
- - Autocompact integration for rate limit recovery
382
- - Usage widget with glimpseui
383
- - Command toggles for free/all model filtering
384
- - Hardcoded benchmark data from Artificial Analysis
385
-
386
- ### Changed
387
-
388
- - **Major refactoring**: Split free-tier-limits.ts into usage/\* modules
389
- - usage/tracking.ts - runtime session tracking
390
- - usage/cumulative.ts - persistent storage
391
- - usage/formatters.ts - display formatting
392
- - 77% line reduction (741 166 lines)
393
- - **Major refactoring**: Split usage-widget.ts into widget/\* modules
394
- - widget/data.ts - data collection
395
- - widget/format.ts - formatting utilities
396
- - widget/render.ts - HTML generation
397
- - 74% line reduction (~350 → 90 lines)
398
- - **Refactoring**: Extracted functions from cline-auth.ts
399
- - fetchAuthorizeUrl() - auth URL fetching
400
- - waitForAuthCode() - callback handling
401
- - exchangeCodeForTokens() - token exchange
402
- - parseManualInput() - manual input parsing
403
- - **Refactoring**: Simplified model-hop.ts complexity
404
- - Extracted handleDowngradeDecision()
405
- - Extracted tryAlternativeModel()
406
- - **Deduplication**: Created shared modules
407
- - lib/json-persistence.ts - file I/O with caching
408
- - lib/logger.ts - structured logging
409
- - providers/model-fetcher.ts - OpenRouter-compatible fetching
410
- - Replaced ~30 console.log statements with structured logging
411
- - Fixed all 9 pre-existing test failures
412
- - fetchWithRetry now throws after last retry
413
- - Fixed auth pattern matching (added key.*not.*valid)
414
- - Updated capability ranking tests
415
- - Added resetUsageStats() for test isolation
416
-
417
- ### Fixed
418
-
419
- - fetchWithRetry() now properly throws after exhausting retries
420
- - Auth error pattern matching now handles more message variants
421
- - Test isolation for free-tier-limits tests
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [2.0.8] - 2026-05-07
11
+
12
+ ### Added
13
+
14
+ - **Codestral provider** Mistral's code-focused model via codestral.mistral.ai.
15
+ Free tier (Experiment plan): 2 req/min, 500K tokens/min, 1B tokens/month.
16
+ Uses pi's built-in Mistral SDK (`mistral-conversations` API type).
17
+
18
+ - **LLM7.io provider** OpenAI-compatible API gateway routing across
19
+ multiple providers (OpenAI, Mistral, Google, DeepSeek, etc.). Free tier:
20
+ default/fast selectors, 100 req/hr, 20 req/min.
21
+
22
+ - **DeepInfra provider** — AI inference cloud with 100+ open-source models.
23
+ $5 one-time credit on signup (no credit card). Models fetched dynamically.
24
+ Shown as trial credit provider in `/free-providers`.
25
+
26
+ - **SambaNova provider** — Fast inference on custom RDU hardware with
27
+ OpenAI-compatible API. All models accessible on free tier (no credit card):
28
+ 20-480 RPM. Models include Llama 3.3 70B, DeepSeek-V3/R1, Llama 4 Maverick.
29
+ Shown as freemium provider in `/free-providers`.
30
+
31
+ ### Changed
32
+
33
+ - **Codestral: fixed HTTP 422 error** — Switched API type from
34
+ `openai-completions` to `mistral-conversations`. The OpenAI completions
35
+ adapter was sending unrecognized fields (`stream_options`, `store`,
36
+ `max_completion_tokens`) that Mistral's API rejects with 422.
37
+
38
+ ### Fixed
39
+
40
+ - **Toggle commands persist across sessions for all providers** — Providers using
41
+ `setupProvider` (zenmux, crofai, llm7, sambanova, deepinfra) were always
42
+ registering `freeModels` on startup, ignoring the persisted `show_paid` config.
43
+ Now each provider reads its config getter and registers the correct initial
44
+ model set. Fixes #149.
45
+
46
+ ### Security
47
+
48
+ - **Log injection prevention** — `scripts/update-benchmarks.ts` sanitizes external
49
+ API data (CRLF stripping) before logging. Fixes SonarCloud S1075.
50
+
51
+ ### Reliability
52
+
53
+ - **Prefer `String#replaceAll()` over `String#replace()`** — Replaced all 7 flagged
54
+ instances. Where regex is unnecessary (2/7), switched to string literal form.
55
+ Fixes SonarCloud S4144.
56
+
57
+ ### Added
58
+
59
+ - **`agents.md`** Codebase guide for AI agents covering architecture, patterns,
60
+ conventions, testing, and the Pi extension API.
61
+
62
+ ### Added
63
+
64
+ - **Passive quota monitoring** Extracts rate-limit headers from every
65
+ provider response via `after_provider_response` event (no extra API calls).
66
+ Tries 6 header format variants (`x-ratelimit-remaining`,
67
+ `ratelimit-remaining-requests-day`, etc.). Shows remaining quota in the
68
+ status bar with warning icons when ≤25% or ≤10%. Fixes #147.
69
+
70
+ ### Fixed
71
+
72
+ - **Missing `g` flag on `replaceAll` regexps broke model filtering** —
73
+ `String.prototype.replaceAll()` requires a global RegExp; 20+ patterns in
74
+ `benchmark-lookup.ts` were missing it, causing a `TypeError` that prevented
75
+ models from appearing for providers like cline and kilo. Added `/g` flag to
76
+ all affected patterns. Fixes #151.
77
+
78
+ ### Changed
79
+
80
+ - **Resolved ~280 SonarCloud issues across 21 files** Bulk code-quality
81
+ cleanup including: stripping trailing zeros from `toFixed()` (S7748),
82
+ `global` `globalThis` (S7764), `parseFloat` `Number.parseFloat` (S7773),
83
+ naming unnamed async exports (S7726), `String.raw` for path strings (S7780),
84
+ top-level await over promise chains (S7785), re-export from source (S7763),
85
+ `.at(-1)` over `[length-1]` (S7755), `node:fs` protocol imports (S7772),
86
+ and logging user-controlled data sanitization (S5145). Fixes #148.
87
+
88
+ ### Security
89
+
90
+ - **Bump `basic-ftp` 5.3.0 5.3.1** Patches GHSA-rpmf-866q-6p89 (high
91
+ severity): malicious FTP server could cause client-side DoS via unbounded
92
+ multiline control response buffering. Fixes `npm audit` finding.
93
+
94
+ ### Refactored
95
+
96
+ - **Extracted shared model-fetch helper** `fetchOpenAICompatibleModels()`
97
+ in `lib/util.ts` eliminates ~120 lines of duplicated fetch→parse→map
98
+ boilerplate across CrofAI, DeepInfra, and SambaNova providers.
99
+
100
+ ## [2.0.6] - 2026-05-02
101
+
102
+ ### Security
103
+
104
+ - **5x S5852 regex super-linear runtime** — Replaced all flagged regex patterns
105
+ (nested quantifiers in model size extraction) with manual char-by-char string
106
+ parsing in `parseModelSize()`, `normalizeSizeTokenOrder()`, and test helpers.
107
+ Eliminates catastrophic backtracking risk.
108
+
109
+ - **4x S4036 PATH variable security** —
110
+ - `open-browser.ts`: Added `resolveExe()` helper that prefers known absolute
111
+ paths (`/usr/bin/open`, `C:\Windows\System32\...\powershell.exe`) before
112
+ falling back to PATH lookup
113
+ - `check-extensions.mjs`: Removed hardcoded PATH override; resolved `npm` via
114
+ `execFileSync` with known absolute paths
115
+
116
+ - **1x S4721 command injection** Replaced `execSync` with `execFileSync` in
117
+ `resolveExe()` helper. `execFileSync` takes separate arguments and never
118
+ spawns a shell, eliminating the injection vector.
119
+
120
+ ### Changed
121
+
122
+ - **Banner image** Converted `banner.svg` to `banner.png` for reliable
123
+ rendering across all GitHub surfaces (mobile, email, dark mode readers).
124
+
125
+ ## [2.0.5] - 2026-05-02
126
+
127
+ ### Added
128
+
129
+ - **NVIDIA model probe auto-discovery** — Lazy auto-probe for NVIDIA models on
130
+ first `session_start` (once per session). Broken 404 models detected and
131
+ auto-hidden without requiring manual `/probe-nvidia`.
132
+
133
+ ### Changed
134
+
135
+ - **Ollama provider updates** — Improved cloud model detection and configuration.
136
+
137
+ ## [2.0.4] - 2026-05-02
138
+
139
+ ### Fixed
140
+
141
+ - **OpenRouter key resolution no longer falls back to `free.json`**
142
+ `getOpenrouterApiKey()` now only checks the `OPENROUTER_API_KEY` environment variable.
143
+ Previously it fell back to `~/.pi/free.json`, which could contain stale/revoked keys
144
+ that conflict with pi's built-in OpenRouter provider (which reads from
145
+ `~/.pi/agent/auth.json`).
146
+
147
+ - **Removed `openrouter_api_key` from `PiFreeConfig` interface and config template** —
148
+ Prevents future persistence of OpenRouter keys in `free.json`, eliminating the
149
+ source of stale key conflicts for built-in providers.
150
+
151
+ ## [2.0.3] - 2026-05-02
152
+
153
+ ### Added
154
+
155
+ - **Consistent `isFreeModel` helper with Route A/B logic** — Created a unified helper for free model detection that automatically detects whether a provider exposes pricing:
156
+ - **Route A (pricing-exposed)**: Model is free if `cost === 0` OR `"free"` in name (OR logic)
157
+ - **Route B (non-pricing-exposed)**: Model is free only if `"free"` in name
158
+ - Dynamic detection: If ALL models have cost === 0, assumes pricing not exposed uses Route B
159
+ - If ANY model has cost > 0, assumes pricing exposed uses Route A
160
+ - All providers (Cline, Kilo, NVIDIA, Ollama, dynamic built-in) now use this consistent helper
161
+
162
+ - **CrofAI provider (PAID)** Added new **paid** provider for CrofAI (https://crof.ai), an OpenAI-compatible LLM inference API. **Note: CrofAI is a paid provider** — users must have a CrofAI API key with credits. The provider uses Route B detection (name-only) since CrofAI's API doesn't expose per-model pricing. Only models with `"free"` in their names are marked as free (none currently).
163
+
164
+ - **ZenMux provider (PAID)** — Added new **paid** provider for ZenMux AI gateway (https://zenmux.ai), a unified API for 200+ models from OpenAI, Anthropic, Google, etc. **Note: ZenMux is a paid provider** — users must have a ZenMux API key with credits. The provider uses Route A detection (OR logic) since ZenMux exposes pricing. Models marked as free only if `cost === 0` OR `"free"` in name (2 free models identified: GLM 4.7 Flash Free, GLM 4.6v Flash Free).
165
+
166
+ - **Comprehensive `isFreeModel` test suite** — Added 30+ unit tests covering Route A, Route B, freemium behavior, and edge cases. Tests verify correct classification on actual OpenRouter API data (371 models, 30 free).
167
+
168
+ - **Toggle commands for dynamic built-in providers** — Added `/toggle-mistral`, `/toggle-groq`,
169
+ `/toggle-cerebras`, `/toggle-xai`, and `/toggle-huggingface` commands. These providers were
170
+ registered with the global toggle system but lacked per-provider toggle commands, making
171
+ free/paid switching inaccessible without editing config files.
172
+
173
+ - **Lazy auto-probe for NVIDIA models** — Extracted `runNvidiaProbe()` into a shared function
174
+ called automatically on first `session_start` (once per session). Previously, users had to
175
+ manually run `/probe-nvidia` to discover 404 models. Now broken models are detected and
176
+ auto-hidden on first use.
177
+
178
+ ### Changed
179
+
180
+ - **Cline provider now uses `isFreeModel`** Fixed Cline to use the consistent `isFreeModel` helper instead of `m.cost.input === 0`. Previously used cost-only filtering, now uses proper OR logic for pricing-exposed providers.
181
+
182
+ - **NVIDIA test expectations updated** — Updated tests to reflect strict Route B behavior (name-only detection for non-pricing-exposed providers). Added test for models with `"free"` in name being marked as free.
183
+
184
+ ### Fixed
185
+
186
+ - **`provider-factory.ts``beforeProviderRequest` hook now scoped to owning provider**
187
+ The hook was firing for **all** provider requests regardless of which provider the factory
188
+ was configuring. Now checks `evt.provider !== def.providerId` and returns early if the
189
+ event doesn't belong to the owning provider.
190
+
191
+ - **`provider-factory.ts` — `reRegister` callback no longer corrupts stored model lists** —
192
+ When toggling between free/paid modes, the callback was overwriting `stored.all` with only
193
+ the filtered subset, losing the original full model list. Now preserves the original model
194
+ lists for correct subsequent toggling.
195
+
196
+ - **`lib/types.ts` — Removed leftover `LspTestInterface`** — Removed a test interface that
197
+ was left in production code.
198
+
199
+ - **`index.ts` — Removed redundant `.catch()` on deprecated Qwen provider** — The `.catch()`
200
+ was unnecessary since `Promise.allSettled` already handles rejections.
201
+
202
+ ### Removed
203
+
204
+ - **Qwen provider (deprecated)**Removed Qwen OAuth provider as the 1,000 req/day free tier is no longer available. Provider remains functional for existing authenticated users but new free tier registrations are not supported.
205
+
206
+ - **Modal provider** Removed single-model Modal provider (only had GLM-5.1 FP8). Users should use other providers for GLM models.
207
+
208
+ - **Cloudflare provider** — Removed Cloudflare Workers AI provider as it's now built into pi core. Users can use pi's built-in Cloudflare provider instead.
209
+
210
+ - **Qwen test file** — Removed `tests/qwen.test.ts` along with the deprecated provider.
211
+
212
+ ## [2.0.2] - 2026-04-26
213
+
214
+ ### Added
215
+
216
+ - **Model matching debug logging** Added `~/.pi/modelmatch.log` to diagnose which models get Coding Index scores and which don't:
217
+ - Logs every matching attempt with provider, model ID, normalization strategy, and result
218
+ - CSV-like format: `timestamp|provider|modelId|modelName|action|strategy|normalizedId|matchKey|codingIndex|details`
219
+ - Provider-specific normalizers for better matching:
220
+ - **NVIDIA**: Strips vendor prefixes (`meta/`, `mistralai/`, `microsoft/`, `qwen/`, etc.)
221
+ - **Cloudflare**: Strips `@cf/namespace/` prefixes
222
+ - **Groq**: Removes `-versatile` and numeric context suffixes (`-32768`)
223
+ - **Cerebras**: Normalizes `llama3.1` `llama-3.1`, auto-adds `instruct` suffix
224
+ - **Mistral**: Strips `-latest` suffix
225
+ - **Ollama**: Converts `model:tag` → `model-tag`
226
+ - Common suffix stripping: `:free`, date codes (`-20250514`), versions (`-v1.1`), `-it`, `-fp8`/`-bf16`
227
+
228
+ - **Enhanced benchmark lookup** `enhanceModelNameWithCodingIndex()` now accepts optional `provider` parameter for provider-aware normalization
229
+
230
+ - **Static 404 model blocklist for NVIDIA** — Probed all 136 models from `integrate.api.nvidia.com/v1/models` and identified 57 that return 404 "Function not found" on `/v1/chat/completions`. These are now hard-filtered so they never appear in the model selector:
231
+ - Covers discontinued models (`databricks/dbrx-instruct`, `meta/codellama-70b`, `meta/llama2-70b`, `ibm/granite-*`, etc.)
232
+ - Covers embedding-only models listed as chat-capable (`nvidia/nv-embed-v1`, `nvidia/nv-embedqa-*`, `snowflake/arctic-embed-l`, etc.)
233
+ - Covers stale API catalog entries (`mistralai/mistral-large`, `mistralai/mistral-large-2-instruct`, `writer/palmyra-*`, etc.)
234
+ - Full list in `NVIDIA_KNOWN_404_MODELS` in `providers/nvidia/nvidia.ts`
235
+
236
+ - **`/probe-nvidia` command** — On-demand model health check. Tests every registered NVIDIA model with a minimal `max_tokens: 1` request, auto-hides any new 404s in `~/.pi/free.json`, and re-registers the provider immediately.
237
+
238
+ - **`scripts/probe-nvidia.mjs`** — Standalone Node.js script to reproduce the probe. Reads `~/.pi/free.json` for the API key, batches 20 requests at a time with 10s timeout, and prints all broken model IDs for adding to the blocklist.
239
+
240
+ - **Ollama Cloud 403 handling** — Same pattern as NVIDIA 404s for Ollama Cloud:
241
+ - `OLLAMA_KNOWN_403_MODELS` blocklist for models that return 403 "access denied"
242
+ - `/probe-ollama` command to test all models on-demand, auto-hide broken ones, and re-register
243
+ - `scripts/probe-ollama.mjs` standalone script for blocklist maintenance
244
+
245
+ - **Provider-scoped hidden models** — Hidden models are now provider-specific:
246
+ - Format: `"provider/model-id"` (e.g., `"ollama/kimi-k2.6"`, `"nvidia/broken-model"`)
247
+ - A model hidden from one provider doesn't hide it from other providers
248
+ - Backward compatible with old global `"model-id"` format
249
+ - All providers updated: NVIDIA, Ollama, Cloudflare, Cline, Kilo, Modal
250
+
251
+ ### Fixed
252
+
253
+ - **Probe commands timeout handling** — Added `fetchWithTimeout` with 10-second timeout to `/probe-nvidia` and `/probe-ollama` commands. Prevents the coding harness from freezing when individual model probe requests hang indefinitely.
254
+
255
+ - **NVIDIA provider now sends `authHeader: true`** Explicitly enables `Authorization: Bearer` header injection. Previously relied on pi's implicit behavior which could fail in some configurations.
256
+
257
+ ### Removed
258
+
259
+ - **NVIDIA 404 model warning log** Removed the `console.warn("[nvidia] Skipping known 404 model: ...")` output when filtering out known broken models. The filter still works silently; use `/probe-nvidia` to identify new 404s if needed.
260
+
261
+ ### Changed
262
+
263
+ - **Cloudflare provider now fetches models dynamically** — Replaced static 19-model hardcoded list with live API fetch from `api.cloudflare.com/client/v4/accounts/{account_id}/ai/models`:
264
+ - Automatically discovers all 30+ text generation models (was manually maintaining 19)
265
+ - Smart filtering excludes embeddings, image generation, speech, translation, and vision-only models via regex patterns
266
+ - Metadata inference from model IDs: detects vision (`vision`/`multimodal`), reasoning (`r1`/`thinking`/`qwq`), context windows, and estimated costs
267
+ - Fixed Mistral Small ID: changed from incorrect `@cf/mistralai/...` to correct `@cf/mistral/...`
268
+ - Added new fallback models: Kimi K2.6, OpenAI GPT-OSS 120B/20B, Qwen 2.5 Coder 32B, QwQ 32B, Llama 3.2 11B Vision
269
+ - Graceful fallback to expanded 18-model hardcoded list if API fetch fails
270
+
271
+ - **NVIDIA provider now queries NVIDIA's API directly** — Source of truth switched from `models.dev` curated JSON to `https://integrate.api.nvidia.com/v1/models`:
272
+ - Eliminates 57 missing models and 25 stale entries from the old third-party source
273
+ - Models not in `models.dev` get inferred metadata (128k context, 4k output, vision/reasoning heuristics)
274
+ - Added regex-based non-chat model filtering for unknown models (embeddings, whisper, reward models, safety guards, parsers, detectors, etc.)
275
+ - Graceful fallback to `models.dev` if NVIDIA API is unreachable
276
+ - Removed paid/free toggle filtering NVIDIA is freemium (all models use free credits)
277
+
278
+ ## [2.0.1] - 2026-04-24
279
+
280
+ ### Added
281
+
282
+ - **Built-in provider toggle support** (`lib/built-in-toggle.ts`) Enables free/paid filtering for Pi's built-in providers that expose per-model pricing:
283
+ - **OpenCode (`/toggle-opencode`)** Captures built-in OpenCode models on session start and filters to free-only by default
284
+ - **OpenRouter (`/toggle-openrouter`)** Now uses the built-in toggle system for consistency
285
+ - Toggle works in the current session (no restart needed)
286
+ - Persisted via `opencode_show_paid` and `openrouter_show_paid` in `~/.pi/free.json`
287
+
288
+ ### Changed
289
+
290
+ - **OpenRouter moved to built-in toggle system** — OpenRouter is now handled by `lib/built-in-toggle.ts` alongside OpenCode for a unified approach:
291
+ - Removed from `providers/dynamic-built-in/index.ts`
292
+ - Eliminated duplicate toggle command registration logic
293
+ - Consolidated toggle persistence with other built-in providers
294
+
295
+ - **Standardized all toggle commands to `toggle-{provider}`** Renamed from `{provider}-toggle` for consistency:
296
+ - `/kilo-toggle` → `/toggle-kilo`
297
+ - `/cline-toggle` `/toggle-cline`
298
+ - `/openrouter-toggle` `/toggle-openrouter`
299
+ - `/nvidia-toggle` `/toggle-nvidia`
300
+ - `/cloudflare-toggle` `/toggle-cloudflare`
301
+ - `/ollama-toggle` `/toggle-ollama`
302
+ - `/mistral-toggle` → `/toggle-mistral`
303
+ - `/groq-toggle` → `/toggle-groq`
304
+ - `/cerebras-toggle` → `/toggle-cerebras`
305
+ - `/toggle-opencode` (new)
306
+
307
+ ### Fixed
308
+
309
+ - **Ollama Cloud model fetching endpoint** — Corrected the `/v1/models` → `/models` endpoint path in `providers/ollama/ollama.ts`:
310
+ - The previous fix (2.0.0) incorrectly used `/v1/models`; Ollama Cloud's models endpoint is `/v1/models` for chat completions but `/models` for listing
311
+ - This ensures model fetching works correctly with the OpenAI-compatible API
312
+
313
+ ### Removed
314
+
315
+ - **Global `/free` command** — Removed the global free-only toggle. Per-provider toggles (`/toggle-{provider}`) are now the only way to switch between free and paid models. The `/free-providers` status command remains.
316
+
317
+ ## [2.0.0] - 2026-04-23
318
+
319
+ ### Breaking Changes
320
+
321
+ - **Removed Fireworks provider** — Fireworks is now a built-in Pi provider (added in pi 0.68.1), so the extension's Fireworks provider has been removed to avoid conflicts:
322
+ - Deleted `providers/fireworks/fireworks.ts` and `tests/fireworks.test.ts`
323
+ - Removed all Fireworks configuration options from `config.ts` (`fireworks_api_key`, `fireworks_show_paid`)
324
+ - Users should now use Pi's built-in Fireworks support with `FIREWORKS_API_KEY`
325
+
326
+ - **Renamed Ollama provider to `ollama-cloud`** — Changed provider ID from `"ollama"` to `"ollama-cloud"` to avoid collision with Pi's built-in local Ollama provider:
327
+ - This prevents provider ID conflicts when both are registered
328
+ - All log messages and documentation now reference "Ollama Cloud"
329
+
330
+ ### Removed
331
+
332
+ - **Dropped `@sinclair/typebox` peer dependency** — Pi 0.69.0 migrated from `@sinclair/typebox` to `typebox` 1.x. The extension didn't directly import this package, so it was removed from `peerDependencies` to avoid potential conflicts.
333
+
334
+ ### Fixed
335
+
336
+ - **Ollama Cloud API endpoint** — Fixed broken Ollama Cloud integration:
337
+ - Changed `BASE_URL_OLLAMA` from `https://ollama.com` to `https://ollama.com/v1` the OpenAI-compatible API endpoint
338
+ - Fixed model fetching to use `/v1/models` instead of `/api/tags` — ensures model IDs work with chat completions endpoint
339
+ - Previously calls went to HTML homepage instead of API endpoints, causing 404 errors
340
+
341
+ ### Removed
342
+
343
+ - **Removed paid model warning on selection** Deleted the `model_select` event handler that showed:
344
+ - `⚠️ Paid model selected (${model.id}). Use "/free off" to enable paid models.`
345
+ - This warning was redundant since the global `/free` toggle and provider toggles already control model visibility
346
+
347
+ - **Removed pointless `/modal-toggle` command** Modal provider only has 1 free model (GLM-5.1 FP8), so there was nothing meaningful to toggle:
348
+ - Added `skipToggle` option to `ProviderDefinition` and `ProviderSetupConfig` interfaces
349
+ - Modal provider now sets `skipToggle: true` to prevent toggle command creation
350
+
351
+ ### Changed
352
+
353
+ - **Marked Qwen provider as fully deprecated** — Updated messaging to clarify the provider is broken:
354
+ - Changed model name from `"Qwen Coder — Free 1k/day"` to `"Qwen Coder — DEPRECATED (free tier discontinued)"`
355
+ - Updated all JSDoc comments to clearly state auth is broken and free tier is no longer available
356
+ - Provider remains for backward compatibility but should not be used
357
+
358
+ ### Added
359
+
360
+ - **Cloudflare Workers AI provider** — New provider for Cloudflare's serverless GPU platform:
361
+ - 50+ open-source models: Llama 4, Mistral Small 3.1, Qwen 2.5/3, DeepSeek R1, Gemma 4, Kimi K2.5/2.6, and more
362
+ - **10,000 Neurons/day FREE tier** (resets daily at 00:00 UTC)
363
+ - **$0.011 per 1,000 Neurons** beyond free allocation
364
+ - Only requires `CLOUDFLARE_API_TOKEN` account ID auto-derived from token
365
+ - Toggle with `/cloudflare-toggle`
366
+ - Create token at https://dash.cloudflare.com/profile/api-tokens
367
+
368
+ - **Unified dynamic built-in providers module** — New `providers/dynamic-built-in/` module that dynamically fetches models from Pi's built-in providers when users have API keys:
369
+ - **Mistral** (`MISTRAL_API_KEY`) — Fetches from `api.mistral.ai/v1/models`
370
+ - **Groq** (`GROQ_API_KEY`) — Fetches from `api.groq.com/openai/v1/models`
371
+ - **Cerebras** (`CEREBRAS_API_KEY`) Fetches from `api.cerebras.ai/v1/models`
372
+ - **xAI** (`XAI_API_KEY`) Fetches from `api.x.ai/v1/models`
373
+ - **Hugging Face** (`HF_TOKEN` — optional) — Fetches public + authenticated models
374
+ - **OpenRouter** — Moved from `index.ts` to unified module with dynamic fetch
375
+ - All integrate with global `/free` toggle and have per-provider toggle commands (`/mistral-toggle`, `/groq-toggle`, etc.)
376
+
377
+ - **Global `/free` toggle system** — New centralized free/paid filtering across ALL providers:
378
+ - `/free on/off/status` Toggle free-only view globally
379
+ - `/free-providers` Show free/paid model counts by provider
380
+ - `FREE_ONLY` config option and `PI_FREE_ONLY` environment variable
381
+ - Providers register via `registerWithGlobalToggle()` for unified filtering
382
+
383
+ ### Fixed
384
+
385
+ - **Toggle commands now actually filter models from UI** — Previously, toggle commands only showed notifications but didn't remove paid models from the model picker:
386
+ - **OpenRouter (`/openrouter-toggle`)**: Now uses `registerProvider`/`unregisterProvider` to actually filter models from the picker UI
387
+ - **NVIDIA (`/nvidia-toggle`)**: Added dynamic `showPaid` parameter to `fetchNvidiaModels()` so toggle properly switches between free and paid model sets
388
+ - **Fireworks**: Removed broken toggle command — all models are paid with no free tier, so there was nothing to toggle
389
+
390
+ ### Added
391
+
392
+ - **OpenRouter per-provider free model toggle** Added `/openrouter-toggle` command for the built-in OpenRouter provider:
393
+ - `/openrouter-toggle` Switch between showing only free models vs all models (including paid)
394
+ - New config flag `openrouter_show_paid` in `~/.pi/free.json` (default: `false`)
395
+ - Environment variable: `OPENROUTER_SHOW_PAID=true` to show paid models by default
396
+ - This brings OpenRouter (a built-in pi provider) in line with extension providers that have per-provider toggles
397
+
398
+ ### Deprecated
399
+
400
+ - **Qwen provider** The 1,000 requests/day free tier is no longer available from Qwen/DashScope. The provider code remains for backward compatibility but is now deprecated:
401
+ - Added `@deprecated` JSDoc tags to all Qwen-related exports
402
+ - Added deprecation warning when Qwen provider loads
403
+ - Added warning when `QWEN_SHOW_PAID` config is used
404
+ - Consider migrating to other free providers: Kilo, Cline, NVIDIA, or Modal
405
+
406
+ ### Added
407
+
408
+ - **Go provider** — OpenCode Go subscription gateway (⚠️ paid only — $5 first month, then $10/month, no free tier) with models: GLM-5, Kimi K2.5, MiMo-V2-Pro, MiMo-V2-Omni, MiniMax M2.7, MiniMax M2.5
409
+ - Set `OPENCODE_GO_API_KEY` or `opencode_go_api_key` in `~/.pi/free.json`
410
+ - Toggle with `/go-toggle`
411
+
412
+ ### Fixed
413
+
414
+ - **All providers now show Coding Index scores in model selector** — Added `enhanceWithCI()` to factory-based providers (nvidia, fireworks, mistral, modal, ollama) and cline. Now all providers display CI scores in `/models` command (pi-models extension).
415
+
416
+ - **All providers now show in `--list-models`** — Providers (zen, openrouter, go) that registered models only in `session_start` were missing from `pi --list-models` which runs before session starts. Added immediate registration for these providers:
417
+ - **zen**: Added model caching to `~/.pi/provider-cache.json` for immediate registration + dynamic refresh
418
+ - **openrouter**: Immediate model registration at extension load (like kilo/cline)
419
+ - **go**: Immediate registration with static model list (no API to fetch from)
420
+ - All 11 providers now visible in `--list-models`
421
+
422
+ ### Changed
423
+
424
+ - Updated README with clear free vs paid provider distinction (9 free + 2 paid-only: Go, Fireworks)
425
+ - Added Go and Fireworks provider documentation under new "💳 Paid-Only Providers" section
426
+ - Added `opencode_go_api_key` to config file template
427
+ - Updated package.json description and keywords to include all 11 providers
428
+
429
+ ### Added
430
+
431
+ - **Provider model cache** (`lib/provider-cache.ts`) — New utility for caching provider model lists to `~/.pi/provider-cache.json`. Used by zen provider for faster startup and offline access after first successful fetch.
432
+
433
+ ## [1.0.9] - 2026-04-14
434
+
435
+ ### Fixed
436
+
437
+ - **Qwen OAuth breaks other OAuth providers** — `modifyModels` receives all models across every registered provider, not just Qwen's. The previous `map()` stamped the Qwen dashscope `baseUrl` onto every model, causing other OAuth providers (Kilo, OpenRouter, etc.) to return 404 after a `/login qwen` flow. Now only models with `provider === PROVIDER_QWEN` are patched; others pass through unchanged.
438
+
439
+ ## [1.0.8] - 2026-04-13
440
+
441
+ ### Added
442
+
443
+ - **Modal provider** — Free access to GLM-5.1 FP8 (128k context, 16k max output) during promotional period (free until April 30, 2026)
444
+ - Requires a free Modal API key (`MODAL_API_KEY` or `modal_api_key` in `~/.pi/free.json`)
445
+ - Model: `zai-org/GLM-5.1-FP8` — 128k context window, 16k max output tokens
446
+ - **Qwen provider** — Free access to Qwen Coder (1,000 requests/day) via OAuth device flow
447
+ - Run `/login qwen` to authenticate through Qwen Studio (chat.qwen.ai)
448
+ - Uses `coder-model` alias (maps to Qwen3.6-Plus on the backend)
449
+ - 131k context window, 16k max output tokens, zero cost
450
+
451
+ ### Fixed
452
+
453
+ - **Qwen OAuth browser launch on Windows** — URLs with `&` query params were truncated by `cmd.exe`'s `&` command separator; switched to `powershell.exe Start-Process` which passes the URL as a literal string
454
+ - **Qwen API endpoint** — Replicates qwen-code's `getCurrentEndpoint()` logic: uses `resource_url` from OAuth token response (`dashscope.aliyuncs.com` for Chinese accounts, `portal.qwen.ai` for international), with fallback to `dashscope.aliyuncs.com/compatible-mode/v1`
455
+ - **Qwen DashScope headers** — Added all headers required by DashScope's OpenAI-compatible API: `X-DashScope-AuthType: qwen-oauth`, `X-DashScope-CacheControl: enable`, `X-DashScope-UserAgent`, `Client-Code: QwenCode`
456
+ - **Qwen modifyModels crash** — `modifyModels` must be synchronous; making it async caused the pi framework to receive a `Promise` instead of a `Model[]`, breaking `ModelRegistry.find()`
457
+
458
+ ## [1.0.5] - 2025-04-03
459
+
460
+ ### Fixed
461
+
462
+ - **NVIDIA provider non-chat model filtering** (comment/implementation mismatch)
463
+ - Added modalities-based filtering to exclude embedding, speech-to-text, OCR, and image-gen models
464
+ - Filters models where `output` is not `["text"]` (e.g., image generation like `black-forest-labs/flux.1-dev`)
465
+ - Filters models where `input` lacks `"text"` (e.g., OCR like `nvidia/nemoretriever-ocr-v1`, speech-to-text like `openai/whisper-large-v3`)
466
+ - Updated file comment to accurately describe the filtering behavior
467
+ - Added 8 comprehensive unit tests for model filtering logic
468
+
469
+ ## [1.0.4] - 2025-04-03
470
+
471
+ ### Fixed
472
+
473
+ - **All tests now passing** (127/127)
474
+ - Fixed mock paths in kilo.test.ts, zen.test.ts, ollama.test.ts
475
+ - Fixed createCtxReRegister mocks in zen.test.ts and openrouter.test.ts
476
+ - Fixed cline.test.ts to test actual provider re-registration behavior
477
+ - Added missing DEFAULT_MIN_SIZE_B constant to openrouter mock
478
+
479
+ ### Changed
480
+
481
+ - **Code quality improvements**
482
+ - Refactored usage modules to break circular dependency (limits.ts ↔ formatters.ts)
483
+ - Created usage/types.ts with shared interfaces (FreeTierLimit, FreeTierUsage)
484
+ - Bumped version to 1.0.4
485
+
486
+ ## [1.0.3] - 2025-04-03
487
+
488
+ ### Changed
489
+
490
+ - Updated package.json metadata (name, description, keywords, repository URL)
491
+ - Updated .npmignore for cleaner publishes
492
+
493
+ ## [1.0.0] - 2024-03-28
494
+
495
+ ### Added
496
+
497
+ - Initial release with 6 providers: Kilo, Zen, OpenRouter, NVIDIA, Cline, Fireworks
498
+ - Free tier usage tracking across all sessions
499
+ - Provider failover with model hopping
500
+ - Autocompact integration for rate limit recovery
501
+ - Usage widget with glimpseui
502
+ - Command toggles for free/all model filtering
503
+ - Hardcoded benchmark data from Artificial Analysis
504
+
505
+ ### Changed
506
+
507
+ - **Major refactoring**: Split free-tier-limits.ts into usage/\* modules
508
+ - usage/tracking.ts - runtime session tracking
509
+ - usage/cumulative.ts - persistent storage
510
+ - usage/formatters.ts - display formatting
511
+ - 77% line reduction (741 → 166 lines)
512
+ - **Major refactoring**: Split usage-widget.ts into widget/\* modules
513
+ - widget/data.ts - data collection
514
+ - widget/format.ts - formatting utilities
515
+ - widget/render.ts - HTML generation
516
+ - 74% line reduction (~350 → 90 lines)
517
+ - **Refactoring**: Extracted functions from cline-auth.ts
518
+ - fetchAuthorizeUrl() - auth URL fetching
519
+ - waitForAuthCode() - callback handling
520
+ - exchangeCodeForTokens() - token exchange
521
+ - parseManualInput() - manual input parsing
522
+ - **Refactoring**: Simplified model-hop.ts complexity
523
+ - Extracted handleDowngradeDecision()
524
+ - Extracted tryAlternativeModel()
525
+ - **Deduplication**: Created shared modules
526
+ - lib/json-persistence.ts - file I/O with caching
527
+ - lib/logger.ts - structured logging
528
+ - providers/model-fetcher.ts - OpenRouter-compatible fetching
529
+ - Replaced ~30 console.log statements with structured logging
530
+ - Fixed all 9 pre-existing test failures
531
+ - fetchWithRetry now throws after last retry
532
+ - Fixed auth pattern matching (added key.*not.*valid)
533
+ - Updated capability ranking tests
534
+ - Added resetUsageStats() for test isolation
535
+
536
+ ### Fixed
537
+
538
+ - fetchWithRetry() now properly throws after exhausting retries
539
+ - Auth error pattern matching now handles more message variants
540
+ - Test isolation for free-tier-limits tests