pi-free 2.0.7 → 2.0.9

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 (42) hide show
  1. package/CHANGELOG.md +96 -10
  2. package/README.md +572 -495
  3. package/config.ts +58 -11
  4. package/constants.ts +12 -0
  5. package/index.ts +67 -3
  6. package/lib/built-in-toggle.ts +2 -2
  7. package/lib/model-detection.ts +2 -1
  8. package/lib/model-enhancer.ts +1 -1
  9. package/lib/open-browser.ts +1 -1
  10. package/lib/provider-compat.ts +1 -1
  11. package/lib/quota-monitor.ts +123 -0
  12. package/lib/registry.ts +1 -1
  13. package/lib/types.ts +101 -101
  14. package/lib/util.ts +460 -351
  15. package/package.json +4 -4
  16. package/provider-failover/benchmark-lookup.ts +743 -702
  17. package/provider-failover/benchmarks-chunk-0.ts +48 -48
  18. package/provider-failover/benchmarks-chunk-1.ts +44 -44
  19. package/provider-failover/benchmarks-chunk-2.ts +39 -39
  20. package/provider-failover/benchmarks-chunk-3.ts +41 -41
  21. package/provider-failover/benchmarks-chunk-4.ts +33 -33
  22. package/provider-helper.ts +1 -1
  23. package/providers/cline/cline-auth.ts +473 -473
  24. package/providers/cline/cline-models.ts +2 -2
  25. package/providers/cline/cline.ts +3 -3
  26. package/providers/codestral/codestral.ts +139 -0
  27. package/providers/crofai/crofai.ts +14 -85
  28. package/providers/deepinfra/deepinfra.ts +109 -0
  29. package/providers/dynamic-built-in/index.ts +1 -1
  30. package/providers/kilo/kilo-auth.ts +155 -155
  31. package/providers/kilo/kilo.ts +3 -3
  32. package/providers/llm7/llm7.ts +156 -0
  33. package/providers/model-fetcher.ts +2 -2
  34. package/providers/nvidia/nvidia.ts +5 -5
  35. package/providers/ollama/ollama.ts +2 -2
  36. package/providers/opencode-session.ts +1 -1
  37. package/providers/qwen/qwen-auth.ts +1 -1
  38. package/providers/qwen/qwen-models.ts +1 -1
  39. package/providers/qwen/qwen.ts +3 -3
  40. package/providers/sambanova/sambanova.ts +109 -0
  41. package/providers/zenmux/zenmux.ts +6 -3
  42. package/scripts/check-extensions.mjs +6 -4
package/CHANGELOG.md CHANGED
@@ -5,6 +5,102 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ### Changed
11
+
12
+ - **Package scope migration** — Updated all peer dependency imports from `@mariozechner/*` to `@earendil-works/*` (`pi-ai`, `pi-coding-agent`, `pi-tui`) to match the upstream scope rename in `@earendil-works/pi` v0.74.0.
13
+
14
+ ## [2.0.8] - 2026-05-07
15
+
16
+ ### Added
17
+
18
+ - **Codestral provider** — Mistral's code-focused model via codestral.mistral.ai.
19
+ Free tier (Experiment plan): 2 req/min, 500K tokens/min, 1B tokens/month.
20
+ Uses pi's built-in Mistral SDK (`mistral-conversations` API type).
21
+
22
+ - **LLM7.io provider** — OpenAI-compatible API gateway routing across
23
+ multiple providers (OpenAI, Mistral, Google, DeepSeek, etc.). Free tier:
24
+ default/fast selectors, 100 req/hr, 20 req/min.
25
+
26
+ - **DeepInfra provider** — AI inference cloud with 100+ open-source models.
27
+ $5 one-time credit on signup (no credit card). Models fetched dynamically.
28
+ Shown as trial credit provider in `/free-providers`.
29
+
30
+ - **SambaNova provider** — Fast inference on custom RDU hardware with
31
+ OpenAI-compatible API. All models accessible on free tier (no credit card):
32
+ 20-480 RPM. Models include Llama 3.3 70B, DeepSeek-V3/R1, Llama 4 Maverick.
33
+ Shown as freemium provider in `/free-providers`.
34
+
35
+ ### Changed
36
+
37
+ - **Codestral: fixed HTTP 422 error** — Switched API type from
38
+ `openai-completions` to `mistral-conversations`. The OpenAI completions
39
+ adapter was sending unrecognized fields (`stream_options`, `store`,
40
+ `max_completion_tokens`) that Mistral's API rejects with 422.
41
+
42
+ ### Fixed
43
+
44
+ - **Toggle commands persist across sessions for all providers** — Providers using
45
+ `setupProvider` (zenmux, crofai, llm7, sambanova, deepinfra) were always
46
+ registering `freeModels` on startup, ignoring the persisted `show_paid` config.
47
+ Now each provider reads its config getter and registers the correct initial
48
+ model set. Fixes #149.
49
+
50
+ ### Security
51
+
52
+ - **Log injection prevention** — `scripts/update-benchmarks.ts` sanitizes external
53
+ API data (CRLF stripping) before logging. Fixes SonarCloud S1075.
54
+
55
+ ### Reliability
56
+
57
+ - **Prefer `String#replaceAll()` over `String#replace()`** — Replaced all 7 flagged
58
+ instances. Where regex is unnecessary (2/7), switched to string literal form.
59
+ Fixes SonarCloud S4144.
60
+
61
+ ### Added
62
+
63
+ - **`agents.md`** — Codebase guide for AI agents covering architecture, patterns,
64
+ conventions, testing, and the Pi extension API.
65
+
66
+ ### Added
67
+
68
+ - **Passive quota monitoring** — Extracts rate-limit headers from every
69
+ provider response via `after_provider_response` event (no extra API calls).
70
+ Tries 6 header format variants (`x-ratelimit-remaining`,
71
+ `ratelimit-remaining-requests-day`, etc.). Shows remaining quota in the
72
+ status bar with warning icons when ≤25% or ≤10%. Fixes #147.
73
+
74
+ ### Fixed
75
+
76
+ - **Missing `g` flag on `replaceAll` regexps broke model filtering** —
77
+ `String.prototype.replaceAll()` requires a global RegExp; 20+ patterns in
78
+ `benchmark-lookup.ts` were missing it, causing a `TypeError` that prevented
79
+ models from appearing for providers like cline and kilo. Added `/g` flag to
80
+ all affected patterns. Fixes #151.
81
+
82
+ ### Changed
83
+
84
+ - **Resolved ~280 SonarCloud issues across 21 files** — Bulk code-quality
85
+ cleanup including: stripping trailing zeros from `toFixed()` (S7748),
86
+ `global` → `globalThis` (S7764), `parseFloat` → `Number.parseFloat` (S7773),
87
+ naming unnamed async exports (S7726), `String.raw` for path strings (S7780),
88
+ top-level await over promise chains (S7785), re-export from source (S7763),
89
+ `.at(-1)` over `[length-1]` (S7755), `node:fs` protocol imports (S7772),
90
+ and logging user-controlled data sanitization (S5145). Fixes #148.
91
+
92
+ ### Security
93
+
94
+ - **Bump `basic-ftp` 5.3.0 → 5.3.1** — Patches GHSA-rpmf-866q-6p89 (high
95
+ severity): malicious FTP server could cause client-side DoS via unbounded
96
+ multiline control response buffering. Fixes `npm audit` finding.
97
+
98
+ ### Refactored
99
+
100
+ - **Extracted shared model-fetch helper** — `fetchOpenAICompatibleModels()`
101
+ in `lib/util.ts` eliminates ~120 lines of duplicated fetch→parse→map
102
+ boilerplate across CrofAI, DeepInfra, and SambaNova providers.
103
+
8
104
  ## [2.0.6] - 2026-05-02
9
105
 
10
106
  ### Security
@@ -61,7 +157,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
61
157
  ### Added
62
158
 
63
159
  - **Consistent `isFreeModel` helper with Route A/B logic** — Created a unified helper for free model detection that automatically detects whether a provider exposes pricing:
64
-
65
160
  - **Route A (pricing-exposed)**: Model is free if `cost === 0` OR `"free"` in name (OR logic)
66
161
  - **Route B (non-pricing-exposed)**: Model is free only if `"free"` in name
67
162
  - Dynamic detection: If ALL models have cost === 0, assumes pricing not exposed → uses Route B
@@ -123,7 +218,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
123
218
  ### Added
124
219
 
125
220
  - **Model matching debug logging** — Added `~/.pi/modelmatch.log` to diagnose which models get Coding Index scores and which don't:
126
-
127
221
  - Logs every matching attempt with provider, model ID, normalization strategy, and result
128
222
  - CSV-like format: `timestamp|provider|modelId|modelName|action|strategy|normalizedId|matchKey|codingIndex|details`
129
223
  - Provider-specific normalizers for better matching:
@@ -138,7 +232,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
138
232
  - **Enhanced benchmark lookup** — `enhanceModelNameWithCodingIndex()` now accepts optional `provider` parameter for provider-aware normalization
139
233
 
140
234
  - **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:
141
-
142
235
  - Covers discontinued models (`databricks/dbrx-instruct`, `meta/codellama-70b`, `meta/llama2-70b`, `ibm/granite-*`, etc.)
143
236
  - Covers embedding-only models listed as chat-capable (`nvidia/nv-embed-v1`, `nvidia/nv-embedqa-*`, `snowflake/arctic-embed-l`, etc.)
144
237
  - Covers stale API catalog entries (`mistralai/mistral-large`, `mistralai/mistral-large-2-instruct`, `writer/palmyra-*`, etc.)
@@ -149,7 +242,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
149
242
  - **`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.
150
243
 
151
244
  - **Ollama Cloud 403 handling** — Same pattern as NVIDIA 404s for Ollama Cloud:
152
-
153
245
  - `OLLAMA_KNOWN_403_MODELS` blocklist for models that return 403 "access denied"
154
246
  - `/probe-ollama` command to test all models on-demand, auto-hide broken ones, and re-register
155
247
  - `scripts/probe-ollama.mjs` standalone script for blocklist maintenance
@@ -173,7 +265,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
173
265
  ### Changed
174
266
 
175
267
  - **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`:
176
-
177
268
  - Automatically discovers all 30+ text generation models (was manually maintaining 19)
178
269
  - Smart filtering excludes embeddings, image generation, speech, translation, and vision-only models via regex patterns
179
270
  - Metadata inference from model IDs: detects vision (`vision`/`multimodal`), reasoning (`r1`/`thinking`/`qwq`), context windows, and estimated costs
@@ -201,7 +292,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
201
292
  ### Changed
202
293
 
203
294
  - **OpenRouter moved to built-in toggle system** — OpenRouter is now handled by `lib/built-in-toggle.ts` alongside OpenCode for a unified approach:
204
-
205
295
  - Removed from `providers/dynamic-built-in/index.ts`
206
296
  - Eliminated duplicate toggle command registration logic
207
297
  - Consolidated toggle persistence with other built-in providers
@@ -233,7 +323,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
233
323
  ### Breaking Changes
234
324
 
235
325
  - **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:
236
-
237
326
  - Deleted `providers/fireworks/fireworks.ts` and `tests/fireworks.test.ts`
238
327
  - Removed all Fireworks configuration options from `config.ts` (`fireworks_api_key`, `fireworks_show_paid`)
239
328
  - Users should now use Pi's built-in Fireworks support with `FIREWORKS_API_KEY`
@@ -256,7 +345,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
256
345
  ### Removed
257
346
 
258
347
  - **Removed paid model warning on selection** — Deleted the `model_select` event handler that showed:
259
-
260
348
  - `⚠️ Paid model selected (${model.id}). Use "/free off" to enable paid models.`
261
349
  - This warning was redundant since the global `/free` toggle and provider toggles already control model visibility
262
350
 
@@ -274,7 +362,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
274
362
  ### Added
275
363
 
276
364
  - **Cloudflare Workers AI provider** — New provider for Cloudflare's serverless GPU platform:
277
-
278
365
  - 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
279
366
  - **10,000 Neurons/day FREE tier** (resets daily at 00:00 UTC)
280
367
  - **$0.011 per 1,000 Neurons** beyond free allocation
@@ -283,7 +370,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
283
370
  - Create token at https://dash.cloudflare.com/profile/api-tokens
284
371
 
285
372
  - **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:
286
-
287
373
  - **Mistral** (`MISTRAL_API_KEY`) — Fetches from `api.mistral.ai/v1/models`
288
374
  - **Groq** (`GROQ_API_KEY`) — Fetches from `api.groq.com/openai/v1/models`
289
375
  - **Cerebras** (`CEREBRAS_API_KEY`) — Fetches from `api.cerebras.ai/v1/models`