pi-free 1.0.9 → 2.0.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/README.md +393 -367
  3. package/config.ts +170 -121
  4. package/constants.ts +23 -61
  5. package/index.ts +148 -0
  6. package/lib/built-in-toggle.ts +206 -0
  7. package/lib/json-persistence.ts +11 -10
  8. package/lib/logger.ts +2 -2
  9. package/lib/model-enhancer.ts +20 -20
  10. package/lib/open-browser.ts +41 -0
  11. package/lib/provider-cache.ts +106 -0
  12. package/lib/registry.ts +144 -0
  13. package/package.json +8 -23
  14. package/provider-factory.ts +25 -41
  15. package/provider-failover/benchmark-lookup.ts +247 -0
  16. package/provider-failover/benchmarks-chunk-0.ts +2010 -0
  17. package/provider-failover/benchmarks-chunk-1.ts +1988 -0
  18. package/provider-failover/benchmarks-chunk-2.ts +2010 -0
  19. package/provider-failover/benchmarks-chunk-3.ts +2010 -0
  20. package/provider-failover/benchmarks-chunk-4.ts +1969 -0
  21. package/provider-failover/hardcoded-benchmarks.ts +22 -10025
  22. package/provider-helper.ts +260 -259
  23. package/providers/{cline-auth.ts → cline/cline-auth.ts} +2 -2
  24. package/providers/cline/cline-models.ts +128 -0
  25. package/providers/{cline.ts → cline/cline.ts} +298 -257
  26. package/providers/cloudflare/cloudflare.ts +368 -0
  27. package/providers/dynamic-built-in/index.ts +432 -0
  28. package/providers/{kilo-auth.ts → kilo/kilo-auth.ts} +3 -20
  29. package/providers/{kilo-models.ts → kilo/kilo-models.ts} +2 -2
  30. package/providers/kilo/kilo.ts +235 -0
  31. package/providers/{modal.ts → modal/modal.ts} +4 -3
  32. package/providers/{nvidia.ts → nvidia/nvidia.ts} +152 -113
  33. package/providers/ollama/ollama.ts +172 -0
  34. package/providers/opencode-session.ts +34 -34
  35. package/providers/{qwen-auth.ts → qwen/qwen-auth.ts} +24 -40
  36. package/providers/{qwen-models.ts → qwen/qwen-models.ts} +101 -95
  37. package/providers/{qwen.ts → qwen/qwen.ts} +83 -13
  38. package/provider-failover/auto-switch.ts +0 -350
  39. package/provider-failover/errors.ts +0 -275
  40. package/provider-failover/index.ts +0 -238
  41. package/providers/cline-models.ts +0 -77
  42. package/providers/factory.ts +0 -125
  43. package/providers/fireworks.ts +0 -49
  44. package/providers/go.ts +0 -216
  45. package/providers/kilo.ts +0 -146
  46. package/providers/mistral.ts +0 -144
  47. package/providers/ollama.ts +0 -113
  48. package/providers/openrouter.ts +0 -175
  49. package/providers/zen.ts +0 -371
  50. package/usage/commands.ts +0 -17
  51. package/usage/cumulative.ts +0 -193
  52. package/usage/formatters.ts +0 -115
  53. package/usage/index.ts +0 -46
  54. package/usage/limits.ts +0 -148
  55. package/usage/metrics.ts +0 -222
  56. package/usage/sessions.ts +0 -355
  57. package/usage/store.ts +0 -99
  58. package/usage/tracking.ts +0 -329
  59. package/usage/types.ts +0 -26
  60. package/usage/widget.ts +0 -90
  61. package/widget/data.ts +0 -113
  62. package/widget/format.ts +0 -26
  63. package/widget/render.ts +0 -117
package/CHANGELOG.md CHANGED
@@ -7,6 +7,144 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.1] - 2026-04-24
11
+
12
+ ### Added
13
+ - **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:
14
+ - **OpenCode (`/toggle-opencode`)** — Captures built-in OpenCode models on session start and filters to free-only by default
15
+ - **OpenRouter (`/toggle-openrouter`)** — Now uses the built-in toggle system for consistency
16
+ - Toggle works in the current session (no restart needed)
17
+ - Persisted via `opencode_show_paid` and `openrouter_show_paid` in `~/.pi/free.json`
18
+
19
+ ### Changed
20
+ - **OpenRouter moved to built-in toggle system** — OpenRouter is now handled by `lib/built-in-toggle.ts` alongside OpenCode for a unified approach:
21
+ - Removed from `providers/dynamic-built-in/index.ts`
22
+ - Eliminated duplicate toggle command registration logic
23
+ - Consolidated toggle persistence with other built-in providers
24
+
25
+ - **Standardized all toggle commands to `toggle-{provider}`** — Renamed from `{provider}-toggle` for consistency:
26
+ - `/kilo-toggle` → `/toggle-kilo`
27
+ - `/cline-toggle` → `/toggle-cline`
28
+ - `/openrouter-toggle` → `/toggle-openrouter`
29
+ - `/nvidia-toggle` → `/toggle-nvidia`
30
+ - `/cloudflare-toggle` → `/toggle-cloudflare`
31
+ - `/ollama-toggle` → `/toggle-ollama`
32
+ - `/mistral-toggle` → `/toggle-mistral`
33
+ - `/groq-toggle` → `/toggle-groq`
34
+ - `/cerebras-toggle` → `/toggle-cerebras`
35
+ - `/toggle-opencode` (new)
36
+
37
+ ### Fixed
38
+ - **Ollama Cloud model fetching endpoint** — Corrected the `/v1/models` → `/models` endpoint path in `providers/ollama/ollama.ts`:
39
+ - 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
40
+ - This ensures model fetching works correctly with the OpenAI-compatible API
41
+
42
+ ### Removed
43
+ - **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.
44
+
45
+ ## [2.0.0] - 2026-04-23
46
+
47
+ ### Breaking Changes
48
+ - **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:
49
+ - Deleted `providers/fireworks/fireworks.ts` and `tests/fireworks.test.ts`
50
+ - Removed all Fireworks configuration options from `config.ts` (`fireworks_api_key`, `fireworks_show_paid`)
51
+ - Users should now use Pi's built-in Fireworks support with `FIREWORKS_API_KEY`
52
+
53
+ - **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:
54
+ - This prevents provider ID conflicts when both are registered
55
+ - All log messages and documentation now reference "Ollama Cloud"
56
+
57
+ ### Removed
58
+ - **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.
59
+
60
+ ### Fixed
61
+ - **Ollama Cloud API endpoint** — Fixed broken Ollama Cloud integration:
62
+ - Changed `BASE_URL_OLLAMA` from `https://ollama.com` to `https://ollama.com/v1` — the OpenAI-compatible API endpoint
63
+ - Fixed model fetching to use `/v1/models` instead of `/api/tags` — ensures model IDs work with chat completions endpoint
64
+ - Previously calls went to HTML homepage instead of API endpoints, causing 404 errors
65
+
66
+ ### Removed
67
+ - **Removed paid model warning on selection** — Deleted the `model_select` event handler that showed:
68
+ - `⚠️ Paid model selected (${model.id}). Use "/free off" to enable paid models.`
69
+ - This warning was redundant since the global `/free` toggle and provider toggles already control model visibility
70
+
71
+ - **Removed pointless `/modal-toggle` command** — Modal provider only has 1 free model (GLM-5.1 FP8), so there was nothing meaningful to toggle:
72
+ - Added `skipToggle` option to `ProviderDefinition` and `ProviderSetupConfig` interfaces
73
+ - Modal provider now sets `skipToggle: true` to prevent toggle command creation
74
+
75
+ ### Changed
76
+ - **Marked Qwen provider as fully deprecated** — Updated messaging to clarify the provider is broken:
77
+ - Changed model name from `"Qwen Coder — Free 1k/day"` to `"Qwen Coder — DEPRECATED (free tier discontinued)"`
78
+ - Updated all JSDoc comments to clearly state auth is broken and free tier is no longer available
79
+ - Provider remains for backward compatibility but should not be used
80
+
81
+ ### Added
82
+ - **Cloudflare Workers AI provider** — New provider for Cloudflare's serverless GPU platform:
83
+ - 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
84
+ - **10,000 Neurons/day FREE tier** (resets daily at 00:00 UTC)
85
+ - **$0.011 per 1,000 Neurons** beyond free allocation
86
+ - Only requires `CLOUDFLARE_API_TOKEN` — account ID auto-derived from token
87
+ - Toggle with `/cloudflare-toggle`
88
+ - Create token at https://dash.cloudflare.com/profile/api-tokens
89
+
90
+ - **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:
91
+ - **Mistral** (`MISTRAL_API_KEY`) — Fetches from `api.mistral.ai/v1/models`
92
+ - **Groq** (`GROQ_API_KEY`) — Fetches from `api.groq.com/openai/v1/models`
93
+ - **Cerebras** (`CEREBRAS_API_KEY`) — Fetches from `api.cerebras.ai/v1/models`
94
+ - **xAI** (`XAI_API_KEY`) — Fetches from `api.x.ai/v1/models`
95
+ - **Hugging Face** (`HF_TOKEN` — optional) — Fetches public + authenticated models
96
+ - **OpenRouter** — Moved from `index.ts` to unified module with dynamic fetch
97
+ - All integrate with global `/free` toggle and have per-provider toggle commands (`/mistral-toggle`, `/groq-toggle`, etc.)
98
+
99
+ - **Global `/free` toggle system** — New centralized free/paid filtering across ALL providers:
100
+ - `/free on/off/status` — Toggle free-only view globally
101
+ - `/free-providers` — Show free/paid model counts by provider
102
+ - `FREE_ONLY` config option and `PI_FREE_ONLY` environment variable
103
+ - Providers register via `registerWithGlobalToggle()` for unified filtering
104
+
105
+ ### Fixed
106
+ - **Toggle commands now actually filter models from UI** — Previously, toggle commands only showed notifications but didn't remove paid models from the model picker:
107
+ - **OpenRouter (`/openrouter-toggle`)**: Now uses `registerProvider`/`unregisterProvider` to actually filter models from the picker UI
108
+ - **NVIDIA (`/nvidia-toggle`)**: Added dynamic `showPaid` parameter to `fetchNvidiaModels()` so toggle properly switches between free and paid model sets
109
+ - **Fireworks**: Removed broken toggle command — all models are paid with no free tier, so there was nothing to toggle
110
+
111
+ ### Added
112
+ - **OpenRouter per-provider free model toggle** — Added `/openrouter-toggle` command for the built-in OpenRouter provider:
113
+ - `/openrouter-toggle` — Switch between showing only free models vs all models (including paid)
114
+ - New config flag `openrouter_show_paid` in `~/.pi/free.json` (default: `false`)
115
+ - Environment variable: `OPENROUTER_SHOW_PAID=true` to show paid models by default
116
+ - This brings OpenRouter (a built-in pi provider) in line with extension providers that have per-provider toggles
117
+
118
+ ### Deprecated
119
+ - **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:
120
+ - Added `@deprecated` JSDoc tags to all Qwen-related exports
121
+ - Added deprecation warning when Qwen provider loads
122
+ - Added warning when `QWEN_SHOW_PAID` config is used
123
+ - Consider migrating to other free providers: Kilo, Cline, NVIDIA, or Modal
124
+
125
+ ### Added
126
+ - **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
127
+ - Set `OPENCODE_GO_API_KEY` or `opencode_go_api_key` in `~/.pi/free.json`
128
+ - Toggle with `/go-toggle`
129
+
130
+ ### Fixed
131
+ - **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).
132
+
133
+ - **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:
134
+ - **zen**: Added model caching to `~/.pi/provider-cache.json` for immediate registration + dynamic refresh
135
+ - **openrouter**: Immediate model registration at extension load (like kilo/cline)
136
+ - **go**: Immediate registration with static model list (no API to fetch from)
137
+ - All 11 providers now visible in `--list-models`
138
+
139
+ ### Changed
140
+ - Updated README with clear free vs paid provider distinction (9 free + 2 paid-only: Go, Fireworks)
141
+ - Added Go and Fireworks provider documentation under new "💳 Paid-Only Providers" section
142
+ - Added `opencode_go_api_key` to config file template
143
+ - Updated package.json description and keywords to include all 11 providers
144
+
145
+ ### Added
146
+ - **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.
147
+
10
148
  ## [1.0.9] - 2026-04-14
11
149
 
12
150
  ### Fixed