Skip to content

Commit 01c9567

Browse files
committed
0.5.43 - 📖 Pi extension documentation
1 parent 674ada5 commit 01c9567

5 files changed

Lines changed: 331 additions & 115 deletions

File tree

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,84 @@ When a tool mode is active (via `Z`), models incompatible with that tool are hig
466466

467467
---
468468

469+
## π Pi Extension — FCM-Pi
470+
471+
**FCM-Pi** is a native [Pi coding agent](https://pi.dev) extension that integrates `free-coding-models` directly into your Pi session. It auto-selects the best free model on startup, shows a live animated scan in the Pi status bar, and lets you hot-swap models mid-session.
472+
473+
> **Requires**: Pi coding agent (pi.dev) + free-coding-models installed and configured with at least one API key.
474+
475+
### Installation
476+
477+
Add the extension to your Pi settings (`~/.pi/agent/settings.json`):
478+
479+
```json
480+
{
481+
"packages": [
482+
"../../Documents/GitHub/free-coding-models/pi-extension"
483+
]
484+
}
485+
```
486+
487+
Or install directly from the Pi shell once published to npm:
488+
```bash
489+
pi install npm:fcm-pi
490+
```
491+
492+
### What it does
493+
494+
| Feature | Description |
495+
|---------|-------------|
496+
| **Auto-scan on startup** | On every Pi session start, FCM pings ~30 candidate models in parallel and selects the best one automatically |
497+
| **Animated progress scan** | While scanning, the Pi status bar shows a live magenta spinner with the model + provider being probed and a real-time % progress |
498+
| **Provider in status bar** | The active model is displayed as `GLM 4.7 (Cerebras) [FCM S+]` so you always know exactly what's running |
499+
| **10-minute disk cache** | Results are cached to `~/.pi/agent/fcm-cache.json` — subsequent session starts are instant |
500+
| **Auto-failover** | If a request fails (HTTP 4xx/5xx), FCM auto-triggers a fresh scan and switches to the next best model |
501+
| **Daemon integration** | If the FCM router daemon is running (`free-coding-models --daemon-bg`), scan results are fetched instantly from its cache |
502+
503+
### Scan progress display
504+
505+
During `/fcm` or on session start, the Pi footer status shows:
506+
507+
```
508+
⠸ Probing: Kimi K2.6 [Nvidia], Step 3.5 Flash [Stepfun] — 47% (14/30)
509+
⠼ Benchmarking: GLM 4.7 [Cerebras] — 60% (3/5)
510+
```
511+
512+
- **Spinner** — 10-frame Braille animation at 80ms
513+
- **Phase label**`Probing` (ping phase) or `Benchmarking` (AI latency phase)
514+
- **Live model name + provider** — shows the last 2 models being probed, scrolling as results come in
515+
- **Progress %** and counter always visible
516+
517+
### Commands
518+
519+
| Command | Description |
520+
|---------|-------------|
521+
| `/fcm` | Re-scan and pick a model interactively from the top 10 ranked |
522+
| `/fcm-list` | Display a ranked table of top 20 available models (SWE / Latency / TPS / Provider) |
523+
| `/fcm-router` | Connect Pi to the local FCM Smart Router daemon (auto-failover across providers) |
524+
| `/fcm-status` | Show diagnostics: active model, last scan source, daemon state |
525+
526+
### Composite ranking
527+
528+
Models are ranked using a composite score:
529+
530+
| Weight | Metric | Description |
531+
|--------|--------|-------------|
532+
| **60%** | SWE-bench score | Coding capability |
533+
| **20%** | Latency | Network round-trip response time |
534+
| **10%** | TPS | Token throughput speed |
535+
| **10%** | Stability | Uptime + success rate |
536+
537+
### Context window limits
538+
539+
Cerebras free-tier API has a strict **8192 total token limit** (prompt + tools + completion). The FCM catalog reflects this accurately so Pi allocates the right budget and doesn't overflow the context silently.
540+
541+
### Full documentation
542+
543+
See [`pi-extension/README.md`](./pi-extension/README.md) for the complete architecture diagram, config format, and troubleshooting guide.
544+
545+
---
546+
469547
## ⌨️ TUI Keys
470548

471549
### Keyboard

changelog/v0.5.43.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog v0.5.43 - 2026-07-07
2+
3+
### Added
4+
- **Pi Extension documentation**: Added a full `## π Pi Extension — FCM-Pi` section to the main `README.md` covering installation, scan progress display, commands, composite ranking, and context window notes.
5+
- **Rewrote `pi-extension/README.md`**: Complete documentation rewrite covering all current features — animated progress scan, provider-in-status-bar, auto-failover, daemon integration, file structure, and provider-specific notes (Cerebras limits, NVIDIA NIM quota).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "free-coding-models",
3-
"version": "0.5.42",
3+
"version": "0.5.43",
44
"description": "Find the fastest coding LLM models in seconds — ping free models from multiple providers, pick the best one for OpenCode, Cursor, or any AI coding assistant.",
55
"keywords": [
66
"nvidia",

pi-extension/README.md

Lines changed: 142 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,83 @@
11
# FCM-Pi — Pi Extension for free-coding-models
22

3-
A lightweight JavaScript extension for the **Pi coding agent (pi.dev)** that connects to **free-coding-models** (FCM). It runs round-trip pings and real-answer AI latency benchmarks on your configured free models, and automatically activates the most performant, usable model before your coding session starts.
3+
A native JavaScript extension for the **[Pi coding agent](https://pi.dev)** that wires **free-coding-models** directly into your Pi session. It pings ~30 candidate models in parallel, benchmarks the top 5, auto-selects the best one on startup, and displays a real-time animated progress scan in the Pi status bar.
44

55
---
66

77
## ✨ Features
88

9-
- **Auto-scan on session startup**: Runs a quick scan when Pi boots up, updating status dynamically in the terminal footer.
10-
- **Smart model selection**: Auto-configures Pi to use the highest-performing model based on a composite score:
11-
- **60% SWE-bench score** (Coding capability)
12-
- **20% Latency** (Network round-trip response speed)
13-
- **10% TPS** (Throughput token speed)
14-
- **10% Stability** (Success rates / uptime)
15-
- **Interactive selection (`/fcm`)**: Allows manually selecting from the top 10 best-performing models in real-time.
16-
- **Diagnostics (`/fcm-list` / `/fcm-status`)**: Displays ranked models in clean, structured terminal tables, and checks local daemon status.
17-
- **Smart Router Integration (`/fcm-router`)**: Routes requests through a local model-routing daemon with automatic failover fallback chains.
9+
| Feature | Description |
10+
|---------|-------------|
11+
| **Auto-scan on session start** | Pings ~30 models in parallel on every Pi boot. Selects and activates the best one before your first prompt |
12+
| **Animated status bar** | Live magenta Braille spinner with scrolling model + provider names and real-time % progress |
13+
| **Provider visible in Pi TUI** | Active model shown as `GLM 4.7 (Cerebras) [FCM S+]` — model, provider, tier, all at a glance |
14+
| **Smart composite ranking** | Scores models on SWE-bench (60%), latency (20%), TPS (10%), stability (10%) |
15+
| **10-minute disk cache** | Results cached to `~/.pi/agent/fcm-cache.json`. Subsequent session starts are instant (< 100ms) |
16+
| **Auto-failover on error** | When a request fails (4xx/5xx), FCM automatically re-scans and switches to the next best working model |
17+
| **Daemon integration** | If the FCM daemon is running (`free-coding-models --daemon-bg`), fetches pre-cached stats in < 1s instead of scanning |
18+
| **Interactive model picker** | `/fcm` re-scans live and presents an interactive selection of the top 10 models |
1819

1920
---
2021

2122
## 🚀 Quick Start
2223

2324
### Prerequisites
2425

25-
1. **free-coding-models** must be installed and configured:
26+
1. **free-coding-models** must be installed globally and configured:
2627
```bash
2728
npm install -g free-coding-models
28-
29-
# Run once to configure your API keys (Groq, Google AI Studio, Nvidia NIM, etc.)
29+
30+
# Run once to configure your API keys (Groq, Nvidia NIM, Cerebras, etc.)
3031
free-coding-models
3132
```
3233

3334
2. **Pi coding agent (pi.dev)** must be installed on your system.
3435

35-
### Installation
36+
### Installation (local path)
3637

37-
Install the extension directly inside the Pi shell or terminal:
38+
Add the extension to `~/.pi/agent/settings.json`:
3839

39-
```bash
40-
pi install /Users/vava/Documents/GitHub/free-coding-models/pi-extension
40+
```json
41+
{
42+
"packages": [
43+
"../../Documents/GitHub/free-coding-models/pi-extension"
44+
]
45+
}
4146
```
4247

43-
*Or, if published to npm:*
48+
Adjust the path to match where you cloned `free-coding-models` on your machine.
49+
50+
### Installation (npm — when published)
4451

4552
```bash
4653
pi install npm:fcm-pi
4754
```
4855

4956
---
5057

51-
## 📐 Architecture & Scan Strategies
58+
## 📊 Scan Progress Display
59+
60+
While scanning during `/fcm` or session start, the Pi footer status bar shows a live animated readout:
61+
62+
```
63+
⠸ Probing: Kimi K2.6 [Nvidia], Step 3.5 Flash [Stepfun] — 47% (14/30)
64+
⠼ Benchmarking: GLM 4.7 [Cerebras] — 60% (3/5)
65+
```
66+
67+
- **Magenta Braille spinner** — 10-frame animation at 80ms refresh rate
68+
- **Yellow phase label**`Probing` during the ping phase, `Benchmarking` during the AI latency phase
69+
- **Cyan model + provider** — the last 2 actively probed models scroll in real time
70+
- **Progress %** and `(completed/total)` counter always shown
71+
72+
Once complete, the status bar settles on:
73+
74+
```
75+
✅ GLM 4.7 (Cerebras) [FCM S+] — 340ms
76+
```
77+
78+
---
79+
80+
## 🏗️ Architecture & Scan Strategies
5281

5382
```
5483
[Pi Session Starting]
@@ -60,35 +89,116 @@ pi install npm:fcm-pi
6089
YES NO
6190
/ \
6291
[Daemon Scan (~1s)] [Direct Scan (~8-15s)]
63-
Query cache & stats Ping 30 candidate models
64-
directly from daemon Benchmark top 5 candidates
92+
Query cache & stats Ping top 30 models in parallel
93+
directly from daemon Benchmark top 5 survivors
6594
\ /
6695
\ /
6796
Filter: status === 'up'
6897
Rank: Compute composite scores
69-
Select: Write Pi configurations
98+
Select: Write Pi config + switch session
7099
71100
72101
[Pi Session Ready to Code!]
73102
```
74103

75-
- **Daemon Mode**: Checks if the FCM background daemon is active. If so, fetches pre-cached latency and stats in under 1 second.
76-
- **Direct Mode (Fallback)**: Performs a parallel ping of the top 30 models from the FCM registry, then benchmarks the top 5 smartest models, completing in ~8-15 seconds.
77-
- **Config Persistence**: Modifies `~/.pi/agent/models.json` and `~/.pi/agent/settings.json` to store provider URLs and default model choices.
104+
### Daemon Mode (fast path)
105+
When `free-coding-models --daemon-bg` is running, the extension queries `localhost:19280/api/models` and `/stats` directly. Scan completes in under 1 second using pre-cached latency data.
106+
107+
### Direct Mode (fallback)
108+
If the daemon is not running, the extension:
109+
1. Loads the FCM model catalog (~191 models across 20 providers)
110+
2. Filters to models with a configured API key
111+
3. Sorts by SWE-bench score and takes top 30 candidates
112+
4. Pings all 30 in parallel (15s timeout each)
113+
5. Filters to models that returned HTTP 200
114+
6. Benchmarks top 5 by SWE score (measures real AI output latency + TPS)
115+
7. Ranks and selects the winner
78116

79117
---
80118

81119
## ⌨️ Command Reference
82120

83-
| Command | Action |
84-
|---------|--------|
85-
| `/fcm` | Re-runs diagnostic scan and presents interactive top 10 model list |
86-
| `/fcm-list` | Renders a styled table of the top 20 available models with SWE/Latency/TPS |
87-
| `/fcm-router` | Configures Pi to route completions through the FCM Smart Router daemon |
88-
| `/fcm-status` | Shows status diagnostics (active model, scan latency, daemon state) |
121+
| Command | Description |
122+
|---------|-------------|
123+
| `/fcm` | Re-scan live and pick a model interactively from the top 10 ranked results |
124+
| `/fcm-list` | Render a styled ASCII table of the top 20 models (SWE / Latency / TPS / Provider) |
125+
| `/fcm-router` | Route Pi completions through the FCM Smart Router daemon (auto-failover across providers) |
126+
| `/fcm-status` | Show diagnostics: active model, last scan source, scan cache age, daemon state |
127+
128+
---
129+
130+
## 🧠 Composite Ranking
131+
132+
| Weight | Metric | Details |
133+
|--------|--------|---------|
134+
| **60%** | SWE-bench score | Coding task success rate from `sources.js` catalog |
135+
| **20%** | Latency (ms) | Normalized: lower is better. 100ms = perfect, 5000ms = worst |
136+
| **10%** | TPS | Tokens per second from AI latency benchmark |
137+
| **10%** | Stability | Model stability score from FCM ping history (0-100) |
138+
139+
---
140+
141+
## 🗂️ Config Files Modified
142+
143+
| File | What's stored |
144+
|------|---------------|
145+
| `~/.pi/agent/models.json` | Provider URL, API key, model ID and capabilities |
146+
| `~/.pi/agent/settings.json` | Default provider and model selection |
147+
| `~/.pi/agent/fcm-cache.json` | Last scan results with 10-minute TTL |
148+
149+
---
150+
151+
## ⚠️ Provider-Specific Notes
152+
153+
### Cerebras
154+
Cerebras free-tier has a **strict 8192 total token limit** (prompt + tools + completion combined). The FCM catalog reflects this accurately — Pi allocates a smaller context budget when using Cerebras models, preventing silent overflow errors.
155+
156+
Cerebras also enforces **5 RPM** on the free tier. FCM uses a single ping per model scan (no thinking parameters that trigger double-requests) to stay within quota.
157+
158+
### NVIDIA NIM
159+
NIM has ~40 RPM on the no-credit-card tier. The parallel ping scan may exhaust this temporarily on the first scan; subsequent scans use the cache.
160+
161+
---
162+
163+
## 🔄 Auto-Failover
164+
165+
When the active model returns an HTTP 4xx or 5xx error, FCM automatically:
166+
167+
1. Detects the failure via the `agent_end` hook
168+
2. Notifies you with a banner: `⚠️ Le modèle actif a renvoyé une erreur. Recherche d'une alternative...`
169+
3. Triggers a fresh full scan
170+
4. Switches to the next best working model
171+
5. Shows a confirmation notification
172+
173+
This runs silently — you don't need to manually `/fcm` when a model goes down.
174+
175+
---
176+
177+
## 📁 File Structure
178+
179+
```
180+
pi-extension/
181+
├── package.json — Extension manifest (fcm-pi)
182+
├── extensions/
183+
│ └── index.js — Pi extension entry point (hooks + commands)
184+
└── lib/
185+
├── scanner.js — Orchestrator (daemon → direct fallback)
186+
├── direct-scanner.js — Parallel ping + benchmark with animated progress
187+
├── model-ranker.js — Composite score + ranking logic
188+
├── config-writer.js — Writes ~/.pi/agent/models.json + settings.json
189+
├── daemon-client.js — HTTP client for FCM daemon (localhost:19280)
190+
└── api-keys.js — Loads API keys from FCM config + env vars
191+
```
89192

90193
---
91194

92195
## 🧹 Telemetry & Security
93196

94-
This extension does not collect or transmit API keys, source code, or personal data. It works entirely offline or connects only to your configured AI providers and local loopback address (`http://localhost:19280`).
197+
This extension does **not** collect or transmit:
198+
- API keys
199+
- Source code or project files
200+
- Personal data or usage patterns
201+
202+
It operates entirely offline or connects only to:
203+
- Your configured AI provider APIs (Cerebras, Nvidia, Groq, etc.)
204+
- The local FCM daemon at `http://localhost:19280` (optional)

pi-extension/request-params.json

Lines changed: 105 additions & 82 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)