pi-bifrost 0.1.3 → 0.1.4

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.
package/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Bifrost
2
2
 
3
- Automatic model routing for [pi](https://pi.dev). Reads your prompt, picks the right model, switches automatically. No thinking required.
3
+ Automatic model routing for [pi](https://pi.dev). Reads your prompt, picks the right model, switches automatically.
4
+
5
+ **Why Bifrost over other model routers:**
6
+
7
+ - **Probe-first init** — tests every model before writing config. No dead providers in your tier lists.
8
+ - **Zero-token routing** — 7 selection strategies, all metadata-based. Routing decisions cost nothing.
9
+ - **Production observability** — Performance API traces, JSONL debug logs. AI-parseable.
4
10
 
5
11
  ## Install
6
12
 
@@ -0,0 +1,318 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Bifrost — Automatic model routing for pi</title>
6
+ <meta name="description" content="Bifrost is a query-aware model router for the pi coding agent. It reads your prompt, classifies it, and switches to the best model automatically. No thinking required." />
7
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
8
+ <meta name="robots" content="index, follow" />
9
+ <meta name="theme-color" content="#0a0a0b" />
10
+ <meta property="og:title" content="Bifrost — Automatic model routing for pi" />
11
+ <meta property="og:description" content="Reads your prompt, picks the right model, switches automatically. No thinking required." />
12
+ <meta property="og:type" content="website" />
13
+ <meta property="og:url" content="https://iamaamir.github.io/pi-bifrost/" />
14
+ <meta name="twitter:card" content="summary" />
15
+ <link rel="canonical" href="https://iamaamir.github.io/pi-bifrost/" />
16
+ <script type="application/ld+json">
17
+ {
18
+ "@context": "https://schema.org",
19
+ "@type": "SoftwareApplication",
20
+ "name": "Bifrost",
21
+ "description": "Query-aware model router for the pi coding agent.",
22
+ "applicationCategory": "DeveloperTool",
23
+ "operatingSystem": "Any",
24
+ "url": "https://iamaamir.github.io/pi-bifrost/",
25
+ "author": { "@type": "Person", "name": "Aamir", "url": "https://github.com/iamaamir" }
26
+ }
27
+ </script>
28
+ <style>
29
+ :root {
30
+ --bg: #0a0a0b;
31
+ --surface: #141416;
32
+ --border: #2a2a2e;
33
+ --text: #e4e4e7;
34
+ --muted: #88889a;
35
+ --accent: #7c3aed;
36
+ --accent-glow: #a78bfa;
37
+ }
38
+ * { margin: 0; padding: 0; box-sizing: border-box; }
39
+ body {
40
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
41
+ background: var(--bg);
42
+ color: var(--text);
43
+ line-height: 1.6;
44
+ -webkit-font-smoothing: antialiased;
45
+ }
46
+ a { color: var(--accent-glow); text-decoration: none; }
47
+ a:hover { text-decoration: underline; }
48
+ code {
49
+ font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
50
+ font-size: 0.9em;
51
+ background: var(--surface);
52
+ padding: 2px 6px;
53
+ border-radius: 4px;
54
+ border: 1px solid var(--border);
55
+ }
56
+ pre {
57
+ background: var(--surface);
58
+ border: 1px solid var(--border);
59
+ border-radius: 8px;
60
+ padding: 16px 20px;
61
+ overflow-x: auto;
62
+ font-size: 0.85rem;
63
+ line-height: 1.7;
64
+ }
65
+ pre code { background: none; border: none; padding: 0; }
66
+ .container { max-width: 800px; margin: 0 auto; padding: 0 24px; }
67
+
68
+ header {
69
+ padding: 80px 0 40px;
70
+ text-align: center;
71
+ }
72
+ header h1 {
73
+ font-size: 3rem;
74
+ font-weight: 700;
75
+ letter-spacing: -0.03em;
76
+ background: linear-gradient(135deg, var(--accent-glow), #c084fc, #818cf8);
77
+ -webkit-background-clip: text;
78
+ -webkit-text-fill-color: transparent;
79
+ background-clip: text;
80
+ }
81
+ header p {
82
+ color: var(--muted);
83
+ font-size: 1.15rem;
84
+ margin-top: 12px;
85
+ max-width: 500px;
86
+ margin-left: auto;
87
+ margin-right: auto;
88
+ }
89
+
90
+ .install {
91
+ background: var(--surface);
92
+ border: 1px solid var(--border);
93
+ border-radius: 12px;
94
+ padding: 24px;
95
+ margin-bottom: 48px;
96
+ }
97
+ .install h2 { font-size: 1.1rem; margin-bottom: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
98
+
99
+ section {
100
+ margin-bottom: 56px;
101
+ }
102
+ section h2 {
103
+ font-size: 1.5rem;
104
+ font-weight: 600;
105
+ margin-bottom: 16px;
106
+ letter-spacing: -0.02em;
107
+ }
108
+ section p { color: var(--muted); margin-bottom: 16px; }
109
+
110
+ .grid {
111
+ display: grid;
112
+ grid-template-columns: 1fr 1fr;
113
+ gap: 16px;
114
+ }
115
+ .grid-3 {
116
+ display: grid;
117
+ grid-template-columns: 1fr 1fr 1fr;
118
+ gap: 16px;
119
+ }
120
+ .card {
121
+ background: var(--surface);
122
+ border: 1px solid var(--border);
123
+ border-radius: 12px;
124
+ padding: 20px;
125
+ }
126
+ .card h3 { font-size: 0.95rem; margin-bottom: 6px; font-weight: 600; }
127
+ .card p { font-size: 0.85rem; margin: 0; }
128
+
129
+ table {
130
+ width: 100%;
131
+ border-collapse: collapse;
132
+ font-size: 0.9rem;
133
+ }
134
+ th, td {
135
+ text-align: left;
136
+ padding: 10px 14px;
137
+ border-bottom: 1px solid var(--border);
138
+ }
139
+ th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
140
+
141
+ .badge {
142
+ display: inline-block;
143
+ padding: 2px 10px;
144
+ border-radius: 12px;
145
+ font-size: 0.75rem;
146
+ font-weight: 500;
147
+ }
148
+ .badge-green { background: #065f4620; color: #6ee7b7; border: 1px solid #065f46; }
149
+ .badge-purple { background: #7c3aed20; color: #a78bfa; border: 1px solid #7c3aed; }
150
+
151
+ footer {
152
+ border-top: 1px solid var(--border);
153
+ padding: 32px 0;
154
+ text-align: center;
155
+ color: var(--muted);
156
+ font-size: 0.85rem;
157
+ margin-top: 64px;
158
+ }
159
+ footer a { color: var(--muted); }
160
+
161
+ @media (max-width: 640px) {
162
+ header h1 { font-size: 2rem; }
163
+ .grid, .grid-3 { grid-template-columns: 1fr; }
164
+ }
165
+ </style>
166
+ </head>
167
+ <body>
168
+ <div class="container">
169
+
170
+ <header>
171
+ <h1>Bifrost</h1>
172
+ <p>Reads your prompt, picks the right model, switches automatically.</p>
173
+
174
+ <div class="grid-3" style="margin-top:32px; text-align:left">
175
+ <div class="card">
176
+ <h3>🔬 Probe-first init</h3>
177
+ <p>Tests every model with a real request before writing config. No dead providers, no phantom models.</p>
178
+ </div>
179
+ <div class="card">
180
+ <h3>⚡ Zero-token routing</h3>
181
+ <p>7 selection strategies — cheapest, fastest, largest context — all metadata-based. Routing costs nothing.</p>
182
+ </div>
183
+ <div class="card">
184
+ <h3>📊 Production observability</h3>
185
+ <p>Performance API traces, JSONL debug logs. Every decision timestamped. AI-parseable.</p>
186
+ </div>
187
+ </div>
188
+ </header>
189
+
190
+ <div class="install">
191
+ <h2>Install</h2>
192
+ <pre><code>pi install npm:pi-bifrost</code></pre>
193
+ </div>
194
+
195
+ <section>
196
+ <h2>What it does</h2>
197
+ <p>You type a prompt. Bifrost inspects it — is this a complex task like debugging or architecture? Or something simple like formatting or a greeting? It classifies every prompt into a <strong>tier</strong>, then selects the best available model for that tier using configurable strategies. The model switches before your prompt is sent. You never touch <code>/model</code>.</p>
198
+
199
+ <div class="grid-3" style="margin-top:24px">
200
+ <div class="card">
201
+ <h3>🧠 Classify</h3>
202
+ <p>LLM or regex reads your prompt and picks a tier.</p>
203
+ </div>
204
+ <div class="card">
205
+ <h3>🎯 Select</h3>
206
+ <p>Strategy picks the best model: cheapest, fastest, largest context.</p>
207
+ </div>
208
+ <div class="card">
209
+ <h3>🔄 Switch</h3>
210
+ <p>Model changes automatically before the prompt is sent.</p>
211
+ </div>
212
+ </div>
213
+ </section>
214
+
215
+ <section>
216
+ <h2>Setup</h2>
217
+ <p>One command. It probes every model you have access to, finds the ones that actually work, and writes a config.</p>
218
+ <pre><code>/bifrost init</code></pre>
219
+ <p style="font-size:0.85rem; margin-top:8px">Say yes. Done. Bifrost is now routing every prompt.</p>
220
+ </section>
221
+
222
+ <section>
223
+ <h2>Selection Strategies</h2>
224
+ <p>How Bifrost picks from a tier's model list. Set globally or per-tier.</p>
225
+
226
+ <table>
227
+ <thead><tr><th>Strategy</th><th>Picks</th></tr></thead>
228
+ <tbody>
229
+ <tr><td><code>cheapest</code></td><td>Lowest input + output cost</td></tr>
230
+ <tr><td><code>cheapest_input</code></td><td>Lowest input cost</td></tr>
231
+ <tr><td><code>cheapest_output</code></td><td>Lowest output cost</td></tr>
232
+ <tr><td><code>largest_context</code></td><td>Biggest context window</td></tr>
233
+ <tr><td><code>random</code></td><td>Random pick</td></tr>
234
+ <tr><td><code>first</code> / <code>fastest</code></td><td>First in list (init orders by speed)</td></tr>
235
+ </tbody>
236
+ </table>
237
+ </section>
238
+
239
+ <section>
240
+ <h2>Commands</h2>
241
+ <table>
242
+ <thead><tr><th>Command</th><th>What it does</th></tr></thead>
243
+ <tbody>
244
+ <tr><td><code>/bifrost init</code></td><td>Probe models, generate config</td></tr>
245
+ <tr><td><code>/bifrost probe</code></td><td>Test which models actually respond</td></tr>
246
+ <tr><td><code>/bifrost preview &lt;prompt&gt;</code></td><td>See what would happen without sending</td></tr>
247
+ <tr><td><code>/bifrost on</code> / <code>off</code></td><td>Enable / disable routing</td></tr>
248
+ <tr><td><code>/bifrost pin</code> / <code>unpin</code></td><td>Lock current model / resume routing</td></tr>
249
+ <tr><td><code>/bifrost reload</code></td><td>Reload config after editing</td></tr>
250
+ <tr><td><code>/bifrost</code></td><td>Show current status</td></tr>
251
+ </tbody>
252
+ </table>
253
+ </section>
254
+
255
+ <section>
256
+ <h2>Config</h2>
257
+ <p>Everything lives in <code>.pi/bifrost.json</code>. Editor autocomplete works in VS Code, Zed, Cursor.</p>
258
+
259
+ <pre><code>{
260
+ "enabled": true,
261
+ "default": "economical",
262
+ "strategy": "first",
263
+ "categoryStrategies": { "economical": "cheapest" },
264
+ "models": {
265
+ "economical": [
266
+ "opencode/deepseek-v4-flash-free",
267
+ "lmstudio/openai/gpt-oss-20b"
268
+ ],
269
+ "frontier": [
270
+ "opencode-go/glm-5.1",
271
+ "opencode-go/grok-4.5"
272
+ ]
273
+ },
274
+ "rules": [
275
+ { "pattern": "\\b(debug|fix|implement)\\b", "model": "frontier" },
276
+ { "pattern": "\\b(explain|format|hello)\\b", "model": "economical" }
277
+ ],
278
+ "classifier": {
279
+ "enabled": true,
280
+ "model": "opencode/mimo-v2.5-free"
281
+ }
282
+ }</code></pre>
283
+ </section>
284
+
285
+ <section>
286
+ <h2>Built with</h2>
287
+ <div class="grid">
288
+ <div class="card">
289
+ <h3>⚡ Zero-token strategies</h3>
290
+ <p>All 7 selection strategies use model metadata only — no API calls, no tokens spent on routing.</p>
291
+ </div>
292
+ <div class="card">
293
+ <h3>📊 Probe-verified</h3>
294
+ <p>Init tests every model with a real request. Only working models make it into your config.</p>
295
+ </div>
296
+ <div class="card">
297
+ <h3>🧠 Dual classifier</h3>
298
+ <p>LLM reads your prompt for accuracy. Regex catches what the LLM misses. Cache avoids repeat work.</p>
299
+ </div>
300
+ <div class="card">
301
+ <h3>🔍 Debug logging</h3>
302
+ <p>JSONL trace of every decision, timing, and model switch. AI-parseable.</p>
303
+ </div>
304
+ </div>
305
+ </section>
306
+
307
+ <footer>
308
+ <p>
309
+ <a href="https://github.com/iamaamir/pi-bifrost">GitHub</a> &middot;
310
+ <a href="https://www.npmjs.com/package/pi-bifrost">npm</a> &middot;
311
+ <a href="https://pi.dev/packages">pi.dev/packages</a>
312
+ </p>
313
+ <p style="margin-top:8px"><span class="badge badge-purple">MIT</span> <span class="badge badge-green">v0.1.3</span></p>
314
+ </footer>
315
+
316
+ </div>
317
+ </body>
318
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-bifrost",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Query-aware model router for pi — inspects each prompt and switches to the best available model automatically.",
5
5
  "type": "module",
6
6
  "license": "MIT",