@kylebrodeur/pi-model-router 0.2.0 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [0.2.1] - 2026-06-05
2
+
3
+ - Bumped @earendil-works/pi-coding-agent SDK to 0.78.1.
4
+ - Updated tool `execute` signatures to match the new SDK API.
5
+
1
6
  # Changelog
2
7
 
3
8
  All notable changes to this project will be documented in this file.
@@ -7,6 +12,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
12
 
8
13
  ## [Unreleased]
9
14
 
15
+ ## [0.3.0] - 2026-06-28
16
+
17
+ ### Removed
18
+ - Removed router-owned Ollama sync and the models.json writer; Ollama registration is delegated to @kylebrodeur/pi-model-discovery.
19
+ - Removed pi-qmd-ledger integration config and checked-in ledger JSONL artifacts.
20
+ - Removed checked-in pi-session HTML artifacts and ignored future pi-session-*.html files.
21
+
22
+ ### Changed
23
+ - /router ollama-sync now delegates to /providers sync when pi-model-discovery is installed and otherwise shows install guidance.
24
+
10
25
  ## [0.2.0] - 2026-05-17
11
26
 
12
27
  ### Added
@@ -50,7 +65,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
50
65
  - Scope shim module
51
66
  - Progressive enhancement with plugin detection
52
67
 
53
- [Unreleased]: https://github.com/kylebrodeur/pi-model-router/compare/v0.2.0...HEAD
68
+ [Unreleased]: https://github.com/kylebrodeur/pi-model-router/compare/v0.3.0...HEAD
69
+ [0.3.0]: https://github.com/kylebrodeur/pi-model-router/compare/v0.2.2...v0.3.0
54
70
  [0.2.0]: https://github.com/kylebrodeur/pi-model-router/compare/v0.1.4...v0.2.0
55
71
  [0.1.4]: https://github.com/kylebrodeur/pi-model-router/compare/v0.1.3...v0.1.4
56
72
  [0.1.3]: https://github.com/kylebrodeur/pi-model-router/compare/v0.1.2...v0.1.3
package/CONTRIBUTING.md CHANGED
@@ -10,7 +10,7 @@ yeliu84/pi-model-router (upstream)
10
10
  └── your-github/pi-model-router-fork (this repo)
11
11
 
12
12
  ├── branch: main (tracks upstream)
13
- ├── branch: feature/ollama-sync
13
+ ├── branch: feature/model-discovery-shim
14
14
  ├── branch: feature/rate-limit-fallback
15
15
  └── branch: feature/feature-toggles
16
16
  ```
@@ -23,7 +23,7 @@ Separate your work into **independent PRs** for maximum merge probability:
23
23
  **Commit message:** `feat: add feature toggle system for modular extensions`
24
24
 
25
25
  **Files touched:**
26
- - `extensions/types.ts` — add `FeatureToggles`, `OllamaSyncConfig`, `RateLimitFallbackConfig`
26
+ - `extensions/types.ts` — add `FeatureToggles` and `RateLimitFallbackConfig`
27
27
  - `extensions/config.ts` — add feature fields to `mergeConfig()` and `normalizeConfig()`
28
28
 
29
29
  **Rationale:**
@@ -32,17 +32,18 @@ Separate your work into **independent PRs** for maximum merge probability:
32
32
  - Enables future features
33
33
  - Easy to review and merge
34
34
 
35
- ### PR 2: Ollama Auto-Sync Feature
36
- **Commit message:** `feat: add ollama-sync for auto-registering local models`
35
+ ### PR 2: Model Discovery Compatibility Shim
36
+ **Commit message:** `feat: delegate ollama discovery to pi-model-discovery`
37
37
 
38
38
  **Files touched:**
39
- - `extensions/ollama-sync.ts` — new file
40
- - `extensions/index.ts` — conditionally initialize from toggles
39
+ - `extensions/model-discovery.ts` — discovery command detection helper
40
+ - `extensions/commands.ts` — compatibility shim for `/router ollama-sync`
41
+ - `extensions/index.ts` — advisory warning when model discovery is absent
41
42
 
42
43
  **Rationale:**
43
- - Self-contained module
44
- - Uses existing patterns (pi.exec, config merge)
45
- - Useful to upstream community (many Pi users use Ollama)
44
+ - Keeps existing user command muscle memory
45
+ - Avoids duplicating provider discovery ownership
46
+ - Leaves local model registration to pi-model-discovery
46
47
 
47
48
  ### PR 3: Rate Limit Fallback
48
49
  **Commit message:** `feat: add rate-limit fallback with manual restore`
@@ -134,15 +135,13 @@ For each PR:
134
135
  Follow upstream conventions:
135
136
 
136
137
  ```
137
- feat: add ollama-sync for auto-registering local models
138
+ feat: delegate ollama discovery to pi-model-discovery
138
139
 
139
- - Detect new Ollama models on session start/reload
140
- - Infer capabilities (vision, reasoning, context window)
141
- - Update models.json with sensible defaults
142
- - Toggle via features.ollamaSync in config
140
+ - Detect the pi-model-discovery `/providers` command when available
141
+ - Delegate `/router ollama-sync` to `/providers sync`
142
+ - Show install guidance when model discovery is absent
143
143
 
144
144
  Refs: #upstream-issue-if-any
145
- ```
146
145
 
147
146
  ```
148
147
  feat: add rate-limit fallback to local Ollama models
@@ -159,7 +158,7 @@ Refs: #upstream-issue-if-any
159
158
  feat: add feature toggle system for modular extension
160
159
 
161
160
  - features config key for enabling/disabling features
162
- - ollamaSync and rateLimitFallback as first features
161
+ - rateLimitFallback as the first feature
163
162
  - Per-turn routing preserved as default behavior
164
163
  - Project-level override support
165
164
  ```
@@ -270,14 +269,14 @@ Your options:
270
269
  ### PR 1: Feature Toggles (minimal)
271
270
  | File | Change |
272
271
  |------|--------|
273
- | `extensions/types.ts` | +FeatureToggles, +OllamaSyncConfig, +RateLimitFallbackConfig, add fields to RouterConfig |
272
+ | `extensions/types.ts` | +FeatureToggles, +RateLimitFallbackConfig, add fields to RouterConfig |
274
273
  | `extensions/config.ts` | preserve feature fields in mergeConfig/normalizeConfig |
275
274
 
276
- ### PR 2: Ollama Sync
275
+ ### PR 2: Model Discovery Compatibility Shim
277
276
  | File | Change |
278
277
  |------|--------|
279
- | `extensions/ollama-sync.ts` | New file |
280
- | `extensions/index.ts` | Import + conditional init |
278
+ | `extensions/model-discovery.ts` | New helper file |
279
+ | `extensions/commands.ts` | Delegate `/router ollama-sync` |
281
280
 
282
281
  ### PR 3: Rate Limit Fallback
283
282
  | File | Change |
package/LEARNINGS.md CHANGED
@@ -20,7 +20,7 @@ The extension strictly separates responsibilities into dedicated modules:
20
20
  * `extensions/state.ts`: Session-persisted state management
21
21
  * `extensions/ui.ts`: Status line and widget rendering
22
22
  * `extensions/commands.ts`: CLI command registrations and completions
23
- * `extensions/feature-module.ts`: Feature-specific modules (e.g., `ollama-sync.ts`, `rate-limit.ts`)
23
+ * `extensions/feature-module.ts`: Feature-specific modules (e.g., `rate-limit.ts`)
24
24
 
25
25
  * **When to use**: For any extension with complex logic that will benefit from maintainability and testing benefits.
26
26
  * **Key benefit**: Each module can be unit tested in isolation. Changes to one concern (e.g., updating heuristics) don't risk breaking unrelated logic (e.g., command registration).
@@ -86,7 +86,6 @@ A `features` object in `model-router.json` allows enabling/disabling features at
86
86
  ```json
87
87
  {
88
88
  "features": {
89
- "ollamaSync": true,
90
89
  "respectPiScope": false,
91
90
  "rateLimitFallback": true
92
91
  }
@@ -175,7 +174,7 @@ Commands are registered under `/router` with subcommands (`/router status`, `/ro
175
174
  - Add a "Tier Selection" guide, explaining when to use `high` vs. `medium` vs. `low`.
176
175
 
177
176
  3. **Future Feature Ideas**
178
- - Per-profile Ollama models (different models per router profile).
177
+ - Per-profile local models registered by pi-model-discovery.
179
178
  - Rate limit dashboard (`/router rate-limit show` with history graph).
180
179
  - Config UI wizard (`/router config setup` interactive).
181
180
 
package/QUICKSTART.md CHANGED
@@ -22,29 +22,25 @@ In Pi, run:
22
22
  /reload
23
23
  ```
24
24
 
25
- You should see in console:
26
-
27
- ```
28
- [router] Feature sync complete - ollama: true rate-limit: true
29
- [router] ollama-sync: enabled
30
- [router] rate-limit-fallback: enabled
31
- ```
25
+ You should see the router initialize and report feature sync without an Ollama sync feature state.
32
26
 
33
27
  ## 4. Verify Features
34
28
 
35
- ### Auto-Sync Test
29
+ ### Model Discovery Note
30
+
31
+ Install `pi-model-discovery` when you want local Ollama models registered with Pi:
36
32
 
37
33
  ```bash
38
- # In another terminal
39
- ollama pull llama3.2:3b
34
+ pi install npm:@kylebrodeur/pi-model-discovery
40
35
  ```
41
36
 
37
+ Then run:
38
+
42
39
  ```
43
- # In Pi
44
- /router ollama-sync
40
+ /providers sync
45
41
  ```
46
42
 
47
- Expected: `Added: llama3.2:3b`
43
+ Use `/router ollama-sync` only as a delegation shortcut to `/providers sync`.
48
44
 
49
45
  ### Fallback Test
50
46
 
@@ -56,7 +52,7 @@ Expected: `Added: llama3.2:3b`
56
52
  /router fallback
57
53
  ```
58
54
 
59
- Expected: switches to best available model matching your `fallbackSequence` (e.g., an Ollama model)
55
+ Expected: switches to best available model matching your `fallbackSequence` (for example, an Ollama model registered by pi-model-discovery)
60
56
 
61
57
  ```
62
58
  # Restore
@@ -67,7 +63,7 @@ Expected: switches to best available model matching your `fallbackSequence` (e.g
67
63
 
68
64
  | Command | What it does |
69
65
  | --------------------- | ------------------------------------------ |
70
- | `/router ollama-sync` | Manually sync Ollama models |
66
+ | `/router ollama-sync` | Delegate to /providers sync |
71
67
  | `/router fallback` | Switch to fallback model sequence (manual) |
72
68
  | `/router restore` | Restore original cloud model |
73
69
  | `/router init` | Scaffold default config file |
@@ -80,31 +76,28 @@ All existing `/router *` commands still work unchanged.
80
76
  ## 6. Daily Workflow
81
77
 
82
78
  ```bash
83
- # Pull new Ollama model
79
+ # Pull a new Ollama model when using local fallback models
84
80
  ollama pull qwen3.5:7b
85
81
  ```
86
82
 
87
83
  ```
88
- # In Pi — auto-sync triggers on session start
89
- /new
90
- # → [Router] Added 1 model(s): qwen3.5:7b
91
- # → Run /reload to see: qwen3.5:7b
84
+ # In Pi — model registration belongs to pi-model-discovery
85
+ /providers sync
92
86
 
93
- /reload
94
- # → Model now available in /model
87
+ # Optional router compatibility shortcut
88
+ /router ollama-sync
95
89
  ```
96
90
 
97
91
  ## Troubleshooting
98
92
 
99
- **"Ollama not available"**
100
- Check `ollama list` works in terminal
93
+ **Ollama models missing**
94
+ Install/run pi-model-discovery and check `/providers status`
101
95
 
102
96
  **Models not in registry**
103
- → `/reload` extension reload refreshes model registry
97
+ → `/providers sync` from pi-model-discovery, then `/reload` if the Pi UI needs a refresh
104
98
 
105
99
  **TypeScript errors**
106
100
  → Requires Pi 0.67+ for rate-limit fallback (uses `after_provider_response` event)
107
- → Ollama sync works with current Pi version
108
101
 
109
102
  **Config not applying**
110
103
  → Verify `~/.pi/agent/model-router.json` exists
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
5
  [![Pi Version](https://img.shields.io/badge/pi-%3E%3D0.70.2-blue)](https://github.com/mariozechner/pi-coding-agent)
6
6
 
7
- Intelligent per-turn model router extension for the [pi](https://github.com/mariozechner/pi-coding-agent) coding agent. Automatically selects between high, medium, and low-tier LLMs based on task intent, session budget, context size, and custom rules — with automatic fallbacks, phase awareness, Ollama sync, and transparent rate-limit recovery.
7
+ Intelligent per-turn model router extension for the [pi](https://github.com/mariozechner/pi-coding-agent) coding agent. Automatically selects between high, medium, and low-tier LLMs based on task intent, session budget, context size, and custom rules — with automatic fallbacks, phase awareness, and transparent rate-limit recovery.
8
8
 
9
9
  ## ✨ Features
10
10
 
@@ -21,10 +21,9 @@ Intelligent per-turn model router extension for the [pi](https://github.com/mari
21
21
  | **Phase Memory** | Biased stickiness to keep you in the same tier during multi-turn planning or implementation work. |
22
22
  | **Thinking Control** | Full control over reasoning/thinking levels per tier and profile. |
23
23
  | **Persistent State** | Pins, profiles, costs, and debug history are remembered across agent restarts and conversation branches. |
24
- | **Ollama Auto-Sync** | Auto-detect and register local Ollama models. |
25
24
  | **Rate-Limit Fallback** | Detect HTTP 402/429/503/529 and transparently fall back to local models. |
26
25
  | **Feature Toggles** | Enable/disable features at user or project level. |
27
- | **Progressive Enhancement** | Detects installed plugins (qmd-ledger, agent-bus) and integrates conditionally. |
26
+ | **Optional Agent Bus Integration** | Detects agent-bus when installed and integrates conditionally. |
28
27
 
29
28
  ## 📦 Installation
30
29
 
@@ -105,7 +104,6 @@ Copy the example config to one of:
105
104
  ```json
106
105
  {
107
106
  "features": {
108
- "ollamaSync": true,
109
107
  "rateLimitFallback": true,
110
108
  "scopeShim": true,
111
109
  "perTurnRouting": true,
@@ -113,7 +111,6 @@ Copy the example config to one of:
113
111
  "costBudgeting": true,
114
112
  "phaseMemory": true,
115
113
  "contextCompression": true,
116
- "ledgerIntegration": false,
117
114
  "agentBusIntegration": false
118
115
  }
119
116
  }
@@ -121,6 +118,16 @@ Copy the example config to one of:
121
118
 
122
119
  **Priority:** Project config `.pi/model-router.json` overrides user config `~/.pi/agent/model-router.json`. Both override defaults.
123
120
 
121
+ ### Model Discovery
122
+
123
+ Install `@kylebrodeur/pi-model-discovery` with:
124
+
125
+ ```bash
126
+ pi install npm:@kylebrodeur/pi-model-discovery
127
+ ```
128
+
129
+ Run `/providers sync` to discover Ollama models. `/router ollama-sync` only delegates to `/providers sync`. The router no longer writes `~/.pi/agent/models.json`.
130
+
124
131
  ### Rate Limit Interception & Fallback
125
132
 
126
133
  The router can gracefully handle 429 Rate Limit and Quota errors. If the error specifies a wait time (e.g., "reset after 58s"), the router will pause and automatically retry the prompt if the wait time is under your threshold. If it exceeds the threshold or is unparseable, it fails over to the next available model in your fallback sequence.
@@ -151,9 +158,8 @@ After installing optional extensions, copy one of these to `.pi/model-router.jso
151
158
 
152
159
  | File | Feature |
153
160
  |------|---------|
154
- | `model-router.ledger.json` | Log routing decisions to qmd-ledger |
155
161
  | `model-router.agent-bus.json` | Publish model changes to agent-bus |
156
- | `model-router.essential.json` | All integrations enabled |
162
+ | `model-router.essential.json` | Rate-limit fallback, scope sync, and agent-bus integration |
157
163
 
158
164
  ## ⌨️ Commands
159
165
 
@@ -177,7 +183,7 @@ After installing optional extensions, copy one of these to `.pi/model-router.jso
177
183
 
178
184
  | Command | Feature | Description |
179
185
  |---------|---------|-------------|
180
- | `/router ollama-sync` | ollamaSync | Manually sync Ollama models |
186
+ | `/router ollama-sync` | | Delegates to /providers sync from pi-model-discovery |
181
187
  | `/router fallback` | rateLimitFallback | Switch to fallback model sequence |
182
188
  | `/router restore` | rateLimitFallback | Restore cloud model |
183
189
  | `/router init` | | Scaffold default config file |
@@ -188,7 +194,7 @@ After installing optional extensions, copy one of these to `.pi/model-router.jso
188
194
  ## 🔒 Requirements
189
195
 
190
196
  - **Pi >= 0.70.2** — Required for `after_provider_response` event (rate limit detection)
191
- - **Ollama** — Running locally for Ollama sync and fallback
197
+ - **Ollama** — Optional and only needed for local fallback models; install pi-model-discovery for Ollama model registration.
192
198
  - **Node.js >= 18** — For TypeScript compilation
193
199
 
194
200
  ## 📚 Documentation
package/TESTING.md CHANGED
@@ -4,8 +4,7 @@
4
4
 
5
5
  - [ ] **Pi updated** to 0.67+ (for `after_provider_response` event support)
6
6
  - [ ] **Node.js** 18+ available
7
- - [ ] **Ollama installed and running**
8
- - [ ] At least one Ollama model pulled locally
7
+ - [ ] **Ollama plus pi-model-discovery are required only for local fallback/delegation checks**
9
8
 
10
9
  ## Installation Steps
11
10
 
@@ -41,6 +40,7 @@ pi
41
40
 
42
41
  - [ ] Shows current profile, tier, model
43
42
  - [ ] Shows `Router enabled: true`
43
+ - [ ] `Features:` line includes `rateLimit=` and does not include the removed Ollama sync state
44
44
 
45
45
  ### Test Routing Decision
46
46
 
@@ -66,18 +66,11 @@ Design a full-stack app architecture with React, Node, and PostgreSQL
66
66
 
67
67
  - [ ] Request uses high-tier model
68
68
 
69
- ## Test 2: Ollama Auto-Sync
69
+ ## Test 2: Model Discovery Delegation
70
70
 
71
- **Goal:** Verify new Ollama models are detected and added.
71
+ **Goal:** Verify `/router ollama-sync` delegates Ollama discovery ownership to pi-model-discovery.
72
72
 
73
- ### Step 1: Pull a New Model
74
-
75
- ```bash
76
- # In another terminal
77
- ollama pull llama3.2:3b
78
- ```
79
-
80
- ### Step 2: Trigger Sync in Pi
73
+ ### Check 1: Without pi-model-discovery installed
81
74
 
82
75
  ```
83
76
  # In Pi TUI
@@ -86,49 +79,25 @@ ollama pull llama3.2:3b
86
79
 
87
80
  **Expected:**
88
81
 
89
- - [ ] Notification: `[Router] Added 1 model(s)`
90
- - [ ] Notification: `Run /reload to see: llama3.2:3b`
91
-
92
- ### Step 3: Reload and Verify
93
-
94
- ```
95
- /reload
96
- ```
97
-
98
- **Expected:**
99
-
100
- - [ ] Extension reloads
101
- - [ ] New model appears in `/model` selector under "ollama"
102
-
103
- ### Step 4: Auto-Sync on Session Start
104
-
105
- ```
106
- /model # Switch to a non-router model
107
- /new # Start new session
108
- ```
82
+ - [ ] Notification: `Install pi-model-discovery for Ollama model discovery: pi install npm:@kylebrodeur/pi-model-discovery. Then run /providers sync.`
83
+ - [ ] Router does not access `models.json`
84
+ - [ ] Router does not execute `ollama`
109
85
 
110
- **Expected:**
111
-
112
- - [ ] On session start, Ollama sync runs automatically
113
- - [ ] If new models exist, notifications appear
114
- - [ ] Console log: `[router] ollama-sync: feature enabled`
115
-
116
- ### Step 5: Project-Level Config Override
86
+ ### Check 2: With pi-model-discovery installed
117
87
 
118
88
  ```bash
119
- # In your project directory
120
- echo '{ "features": { "ollamaSync": false } }' > .pi/model-router.json
89
+ pi install npm:@kylebrodeur/pi-model-discovery
121
90
  ```
122
91
 
123
92
  ```
124
- # In Pi TUI (from project directory)
125
- /router
93
+ # In Pi TUI
94
+ /router ollama-sync
126
95
  ```
127
96
 
128
97
  **Expected:**
129
98
 
130
- - [ ] Auto-sync doesn't run on session start
131
- - [ ] Manual `/router ollama-sync` still works
99
+ - [ ] First notification: `Delegating Ollama model discovery to /providers sync.`
100
+ - [ ] Provider extension handles `/providers sync`
132
101
 
133
102
  ## Test 3: Rate Limit Fallback
134
103
 
@@ -197,7 +166,6 @@ echo '{ "features": { "rateLimitFallback": false } }' > ~/.pi/agent/model-router
197
166
  cat > ~/.pi/agent/model-router.json << 'EOF'
198
167
  {
199
168
  "features": {
200
- "ollamaSync": true,
201
169
  "rateLimitFallback": true,
202
170
  "perTurnRouting": true
203
171
  }
@@ -212,7 +180,6 @@ mkdir -p .pi
212
180
  cat > .pi/model-router.json << 'EOF'
213
181
  {
214
182
  "features": {
215
- "ollamaSync": false,
216
183
  "rateLimitFallback": false
217
184
  }
218
185
  }
@@ -229,31 +196,11 @@ EOF
229
196
  **Expected:**
230
197
 
231
198
  - [ ] Console shows `[router] rate-limit-fallback: disabled`
232
- - [ ] Console shows `[router] ollama-sync: disabled`
233
199
  - [ ] Per-turn routing still works (project didn't override it)
234
200
 
235
201
  ## Test 5: Edge Cases
236
202
 
237
- ### Missing Ollama
238
-
239
- ```
240
- # Stop Ollama
241
- ollama stop # or kill process
242
-
243
- # Try sync
244
- /router ollama-sync
245
- ```
246
-
247
- **Expected:**
248
-
249
- - [ ] Notification: `Ollama not available`
250
- - [ ] No crash, graceful failure
251
-
252
- ### Missing models.json
253
-
254
- ```bash
255
- mv ~/.pi/agent/models.json ~/.pi/agent/models.json.bak
256
- ```
203
+ ### Missing Model Discovery Extension
257
204
 
258
205
  ```
259
206
  /router ollama-sync
@@ -261,18 +208,10 @@ mv ~/.pi/agent/models.json ~/.pi/agent/models.json.bak
261
208
 
262
209
  **Expected:**
263
210
 
264
- - [ ] Notification: `models.json not found`
265
-
266
- ```bash
267
- # Restore
268
- mv ~/.pi/agent/models.json.bak ~/.pi/agent/models.json
269
- ```
211
+ - [ ] Notification: `Install pi-model-discovery for Ollama model discovery: pi install npm:@kylebrodeur/pi-model-discovery. Then run /providers sync.`
212
+ - [ ] No crash, graceful guidance
270
213
 
271
- ### No Ollama Models Configured
272
-
273
- ```bash
274
- # Temporarily move models.json ollama section
275
- ```
214
+ ### No Fallback Models Configured
276
215
 
277
216
  ```
278
217
  /router fallback
@@ -280,16 +219,12 @@ mv ~/.pi/agent/models.json.bak ~/.pi/agent/models.json
280
219
 
281
220
  **Expected:**
282
221
 
283
- - [ ] `No Ollama models available` error notification
222
+ - [ ] `No fallback models available` or equivalent error notification
223
+ - [ ] Router remains on the current model
284
224
 
285
225
  ## Test 6: Combined Features (Full Workflow)
286
226
 
287
- **Goal:** Verify all features work together.
288
-
289
- ```bash
290
- # Pull new model
291
- ollama pull qwen3.5:7b
292
- ```
227
+ **Goal:** Verify router features work together.
293
228
 
294
229
  ```
295
230
  # Pi session
@@ -299,13 +234,12 @@ ollama pull qwen3.5:7b
299
234
  **Expected:**
300
235
 
301
236
  1. [ ] Session starts
302
- 2. [ ] Auto-sync detects `qwen3.5:7b`
303
- 3. [ ] Notification: `Added 1 model(s)`
304
- 4. [ ] `/reload` prompt shown
305
- 5. [ ] After `/reload`, routing profiles work
306
- 6. [ ] `/router profile balanced` switches to router
307
- 7. [ ] Simple query routes to low tier (possibly Ollama)
308
- 8. [ ] Complex query routes to high tier (cloud)
237
+ 2. [ ] `/router status` shows no removed Ollama sync feature state
238
+ 3. [ ] `/router config` includes `rateLimitFallback` and does not list the removed Ollama sync feature
239
+ 4. [ ] `/router config ollama-sync` reports `Unknown feature: ollama-sync. Try: rate-limit, classifier, budget, respect-pi-scope`
240
+ 5. [ ] `/router profile balanced` switches to router
241
+ 6. [ ] Simple query routes to low tier
242
+ 7. [ ] Complex query routes to high tier (cloud)
309
243
 
310
244
  ## Regression Tests (Upstream Feature Checklist)
311
245
 
@@ -331,7 +265,7 @@ ollama pull qwen3.5:7b
331
265
  ```bash
332
266
  # Check file paths
333
267
  ls -la ~/.pi/agent/extensions/pi-model-router/
334
- # Should see: index.ts, config.ts, types.ts, routing.ts, provider.ts, commands.ts, state.ts, ui.ts, constants.ts, ollama-sync.ts, rate-limit.ts, features.ts
268
+ # Should see: index.ts, config.ts, types.ts, routing.ts, provider.ts, commands.ts, state.ts, ui.ts, constants.ts, model-discovery.ts, rate-limit.ts
335
269
  ```
336
270
 
337
271
  ### TypeScript Errors After Update
@@ -363,12 +297,13 @@ npm install -g @mariozechner/pi-coding-agent
363
297
  ### Fallback Model Not In Registry
364
298
 
365
299
  ```
366
- /reload
367
- /model # Check if new models appear
300
+ /providers status
301
+ /providers sync
302
+ /model # Check if local models appear
368
303
  ```
369
304
 
370
- If Ollama models don't appear after `/reload`:
305
+ If Ollama models don't appear after `/providers sync`:
371
306
 
372
- 1. Check `models.json` has ollama provider section
373
- 2. Verify `baseUrl` is correct: `http://127.0.0.1:11434/v1`
374
- 3. Check Ollama is running: `ollama list` in terminal
307
+ 1. Verify pi-model-discovery is installed: `/providers status`
308
+ 2. Check Ollama is running: `ollama list` in terminal
309
+ 3. Pull at least one local model for fallback use
@@ -0,0 +1,99 @@
1
+ # Agent Prompt: Remove ollama-sync overlap from pi-model-router
2
+
3
+ ## Context
4
+
5
+ `@kylebrodeur/pi-model-router` contains an `extensions/ollama-sync.ts` module that auto-discovers and registers Ollama models. This functionality has been superseded by `@kylebrodeur/pi-model-discovery` which does the same thing better:
6
+
7
+ | Feature | `ollama-sync.ts` (router) | `pi-model-discovery` |
8
+ |---------|--------------------------|---------------------|
9
+ | Discovery API | Runs `ollama list` + keyword heuristics | Native `/api/tags` + `/api/show` |
10
+ | Registration | Writes to `models.json` (legacy format) | `pi.registerProvider()` (no reload needed) |
11
+ | Timing | `session_start` hook | Async factory (available immediately) |
12
+ | Caching | None | TTL cache at `ollama-model-cache.json` |
13
+ | Scope | Manually updates `models.json` | Writes `settings.json` `enabledModels` |
14
+ | Commands | `/router ollama-sync` | `/providers sync`, `/providers status`, etc. |
15
+
16
+ ## Task
17
+
18
+ Refactor `@kylebrodeur/pi-model-router` to remove the duplicated Ollama discovery logic and instead delegate to `pi-model-discovery` when it's installed.
19
+
20
+ ## Repo
21
+
22
+ `https://github.com/kylebrodeur/pi-model-router` — clone and work from main.
23
+
24
+ ## Changes Required
25
+
26
+ ### 1. Remove `extensions/ollama-sync.ts` internal implementation
27
+
28
+ The `performOllamaSync()` and `initializeOllamaSync()` functions should be removed. The `/router ollama-sync` command and its backing logic should either:
29
+ - (A) Check if `pi-model-discovery` is installed and delegate to `/providers sync` if so
30
+ - (B) Be removed entirely with a notice that `pi-model-discovery` handles this
31
+
32
+ Recommendation: (A) — check for discovery extension, delegate or show helpful message.
33
+
34
+ ### 2. Update `extensions/index.ts`
35
+
36
+ Remove the import and initialization of `initializeOllamaSync`. Replace with a detection check:
37
+
38
+ ```ts
39
+ // Check if pi-model-discovery is installed; if not, warn user
40
+ const hasModelDiscovery = /* check pi extension registry */;
41
+ if (!hasModelDiscovery) {
42
+ ctx.ui.notify(
43
+ "Router: Install pi-model-discovery for Ollama auto-sync (pi install npm:@kylebrodeur/pi-model-discovery)",
44
+ "warning"
45
+ );
46
+ }
47
+ ```
48
+
49
+ ### 3. Update `/router ollama-sync` command in `extensions/commands.ts`
50
+
51
+ Instead of running the internal sync, either:
52
+ - Delegate: `pi.sendUserMessage("/providers sync")` if pi-model-discovery is installed
53
+ - Or remove the command and redirect users to `/providers sync`
54
+
55
+ ### 4. Update `extensions/config.ts`
56
+
57
+ Remove the `OllamaSyncConfig` type and related config from the router config schema. Remove `features.ollamaSync` toggle — it's no longer the router's concern.
58
+
59
+ ### 5. Update `model-router.example.json` and related config files
60
+
61
+ Remove `features.ollamaSync` entries. Add a comment pointing to `pi-model-discovery`.
62
+
63
+ ### 6. Update README
64
+
65
+ - Remove the ollama-sync section from Features table
66
+ - Add a "Model Discovery" section explaining that `pi-model-discovery` handles this
67
+ - Update the `/router ollama-sync` command entry to note it delegates to `/providers sync`
68
+
69
+ ### 7. Update CHANGELOG
70
+
71
+ Document the removal as a "replaced by pi-model-discovery" note.
72
+
73
+ ## What to Keep
74
+
75
+ - `extensions/rate-limit.ts` — this is NOT in pi-model-discovery (rate-limit fallback is router-specific)
76
+ - `extensions/routing.ts` — core routing logic, stays
77
+ - `extensions/provider.ts` — router provider registration, stays
78
+ - All other router features (cost budgeting, phase memory, intent classifier, etc.)
79
+
80
+ ## Detection pattern for pi extensions
81
+
82
+ To check if `pi-model-discovery` is installed, look for:
83
+ ```ts
84
+ // Check if the extension is registered
85
+ const hasDiscovery = pi.getRegisteredExtensions?.()
86
+ ?.some(e => e.name?.includes('pi-model-discovery')) ?? false;
87
+ ```
88
+
89
+ Or check if the `/providers` command is available via the command registry.
90
+
91
+ ## Acceptance Criteria
92
+
93
+ - `extensions/ollama-sync.ts` is deleted
94
+ - `features.ollamaSync` config key removed
95
+ - `/router ollama-sync` command either removed or delegates to `/providers sync`
96
+ - Router still works without pi-model-discovery (graceful degradation)
97
+ - README updated
98
+ - Tests pass (`pnpm test`)
99
+ - No breaking changes to rate-limit, routing, or cost budgeting features