|
| 1 | +# FCM-Pi — Pi Extension for free-coding-models |
| 2 | + |
| 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. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## ✨ Features |
| 8 | + |
| 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. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## 🚀 Quick Start |
| 22 | + |
| 23 | +### Prerequisites |
| 24 | + |
| 25 | +1. **free-coding-models** must be installed and configured: |
| 26 | + ```bash |
| 27 | + npm install -g free-coding-models |
| 28 | + |
| 29 | + # Run once to configure your API keys (Groq, Google AI Studio, Nvidia NIM, etc.) |
| 30 | + free-coding-models |
| 31 | + ``` |
| 32 | + |
| 33 | +2. **Pi coding agent (pi.dev)** must be installed on your system. |
| 34 | + |
| 35 | +### Installation |
| 36 | + |
| 37 | +Install the extension directly inside the Pi shell or terminal: |
| 38 | + |
| 39 | +```bash |
| 40 | +pi install /Users/vava/Documents/GitHub/free-coding-models/pi-extension |
| 41 | +``` |
| 42 | + |
| 43 | +*Or, if published to npm:* |
| 44 | + |
| 45 | +```bash |
| 46 | +pi install npm:fcm-pi |
| 47 | +``` |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## 📐 Architecture & Scan Strategies |
| 52 | + |
| 53 | +``` |
| 54 | + [Pi Session Starting] |
| 55 | + │ |
| 56 | + ▼ |
| 57 | + Check: Is FCM Daemon active? |
| 58 | + (http://localhost:19280) |
| 59 | + / \ |
| 60 | + YES NO |
| 61 | + / \ |
| 62 | + [Daemon Scan (~1s)] [Direct Scan (~8-15s)] |
| 63 | + Query cache & stats Ping 30 candidate models |
| 64 | + directly from daemon Benchmark top 5 candidates |
| 65 | + \ / |
| 66 | + \ / |
| 67 | + Filter: status === 'up' |
| 68 | + Rank: Compute composite scores |
| 69 | + Select: Write Pi configurations |
| 70 | + │ |
| 71 | + ▼ |
| 72 | + [Pi Session Ready to Code!] |
| 73 | +``` |
| 74 | + |
| 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. |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## ⌨️ Command Reference |
| 82 | + |
| 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) | |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## 🧹 Telemetry & Security |
| 93 | + |
| 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`). |
0 commit comments