opencode-model-router 2.4.0 → 2.6.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
@@ -7,6 +7,109 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.6.0] - 2026-10-09
11
+
12
+ ### Changed
13
+
14
+ - **Bundled `anthropic` preset values.** `@fast` is now `anthropic/claude-haiku-5-5` with variant/effort `medium`
15
+ (was `low`); `@medium` is now `anthropic/claude-sonnet-5-5` with variant/effort `high` (was `medium`). `@heavy` is
16
+ unchanged.
17
+ - **Bundled `hybrid` preset values.** `@fast` is now `anthropic/claude-haiku-5-5` with variant and effort `medium`
18
+ (was OpenAI `gpt-6-luna-fast`); `@medium` is now `openai/gpt-6.1-sol-fast` with variant `xhigh` and no `effort`
19
+ (was `gpt-6-astra-fast`). `@heavy` is unchanged.
20
+ - **A preset chosen with `/preset` that no layer defines is now reported.** The config load adds one notice,
21
+ `the preset '<name>' chosen with /preset is not defined (defined: …); using '<active>'`, and keeps routing on the
22
+ configured `activePreset` (OpenCode v1 and v2 alike, since both load the same config). An overrides file whose own
23
+ `activePreset` names an undefined preset still drops that whole layer, as before.
24
+
25
+ ### Removed
26
+
27
+ - **Bundled presets `hybrid-2` and `fable-effort`.** The bundled presets are now `anthropic`, `openai`,
28
+ `github-copilot`, `google`, `hybrid` and `zai`.
29
+
30
+ **Migration.** If you use `hybrid-2` or `fable-effort`, or want the previous `hybrid` values back, copy that block
31
+ into `presets` in `opencode-model-router.overrides.jsonc` and keep `activePreset` pointing at it. The 2.5.0
32
+ `fable-effort` block:
33
+
34
+ ```jsonc
35
+ {
36
+ "presets": {
37
+ "fable-effort": {
38
+ "fast": {
39
+ "readOnly": true,
40
+ "model": "anthropic/claude-fable-5-1",
41
+ "effort": "low",
42
+ "costRatio": 1,
43
+ "description": "Fable 5 at low effort for exploration, search, and simple reads (token-spend ratios are estimates; same model across tiers preserves prompt cache)",
44
+ "steps": 30,
45
+ "whenToUse": [
46
+ "Codebase exploration and search",
47
+ "Simple file reads and listing",
48
+ "Grep/glob operations",
49
+ "Quick lookups and research"
50
+ ]
51
+ },
52
+ "medium": {
53
+ "model": "anthropic/claude-fable-5-1",
54
+ "effort": "high",
55
+ "costRatio": 3,
56
+ "description": "Fable 5 at high effort for implementation and standard coding (costRatio is an estimated token-spend multiplier, not a price difference)",
57
+ "steps": 50,
58
+ "whenToUse": [
59
+ "Feature implementation",
60
+ "Refactoring",
61
+ "Writing tests",
62
+ "Bug fixes"
63
+ ]
64
+ },
65
+ "heavy": {
66
+ "model": "anthropic/claude-fable-5-1",
67
+ "effort": "xhigh",
68
+ "costRatio": 6,
69
+ "description": "Fable 5 at xhigh effort for architecture, complex debugging, and security (costRatio is an estimated token-spend multiplier, not a price difference)",
70
+ "steps": 120,
71
+ "whenToUse": [
72
+ "Architecture decisions",
73
+ "Complex debugging (after 2+ failures)",
74
+ "Security review",
75
+ "Performance optimization"
76
+ ]
77
+ }
78
+ }
79
+ },
80
+ "activePreset": "fable-effort"
81
+ }
82
+ ```
83
+
84
+ The 2.5.0 `hybrid-2` block and the previous `hybrid` block are in `git show v2.5.0:tiers.json` (or in the 2.5.0
85
+ package's `tiers.json`); copy a block under its own name. For the previous `hybrid`, use a new name (for example `hybrid-2-5-0`) and set`n `activePreset` to it: preset overrides merge key by key, so a block copied under `hybrid` would keep keys the new`n bundled tiers set and the old ones do not (the new `@fast` has `effort: "medium"`).
86
+
87
+ **Define the preset in the same file as `activePreset`.** An overrides file whose `activePreset` names a preset no
88
+ layer defines is dropped as a whole layer, so its other settings are lost too. A preset you last chose with
89
+ `/preset` and that is no longer defined only produces the notice above and routes on the configured `activePreset`.
90
+
91
+ ## [2.5.0] - 2026-10-09
92
+
93
+ ### Added
94
+
95
+ - **OpenCode v2 TUI status (#90).** The package ships a TUI entry, `tui.ts` (plugin id `opencode-model-router.status`),
96
+ that OpenCode v2 (2.0.24 or later) auto-loads for every package listed in `opencode.json` `plugins` when the server
97
+ entry loads. The main session's prompt footer shows `effort <value>` when no variant is selected; a delegated
98
+ session's view shows `<agent> · <model> · <effort>` above the composer. Opt-in (off by default, so the main session
99
+ shows only the footer's effort): with `"options": { "runningRow": true }` the main session lists running delegates
100
+ above the composer, one `<agent> · <model> · <effort>` row each, at most `maxRows`, then `+<k> more`. Options
101
+ `enabled`, `footer`, `childView`, `runningRow` and `maxRows` go in OpenCode v2's TUI config file `cli.json`; turn it
102
+ off with `enabled: false` or `"-opencode-model-router.status"`. The v2 server plugin answers the plugin rpc
103
+ `opencode-model-router.effort` (`effortOf`) with the effort each session's latest turn carried; while it has no
104
+ answer, the footer shows `effort default` and the delegate rows show the message's variant. Inert on OpenCode v1,
105
+ which never loads `tui.ts`. See [TUI status](docs/TUI_STATUS.md).
106
+
107
+ ### Changed
108
+
109
+ - OpenCode v1 support is in feature freeze: v1 keeps working and gets fixes for regressions and security issues only;
110
+ every new feature targets OpenCode v2 and stays inert on v1 (at most one notice, no behaviour). See
111
+ [AGENTS.md](AGENTS.md#host-support-policy).
112
+
10
113
  ## [2.4.0] - 2026-10-09
11
114
 
12
115
  Role × tier × assurance delegation (#84), opt-in on OpenCode v2: role agents, tier floors from authority × detection,
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **Use the cheapest model that can do the job. Automatically.**
6
6
 
7
- An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,248–6,356 characters of system-prompt overhead depending on the orchestrator and enforcement mode.
7
+ An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,249–6,357 characters of system-prompt overhead depending on the orchestrator and enforcement mode.
8
8
 
9
9
  ## Why it's different
10
10
 
@@ -24,7 +24,7 @@ Most AI coding tools give you one model for everything. You pay Opus prices to r
24
24
  The orchestrator runs on *every* message. Put Sonnet there, not Opus. Sonnet reads a routing protocol and delegates just as well as Opus — at 4x lower cost. Reserve Opus for when it genuinely matters.
25
25
 
26
26
  **Inject a compressed, LLM-optimized routing protocol.**
27
- Instead of duplicated prose, the plugin injects a dense, machine-readable routing protocol. The protocol itself is 3,248 characters; a Claude orchestrator receives 4,020 characters after its authority prefix (roughly 1,005–1,117 tokens at 3.6–4.0 characters per token). Every message, every session.
27
+ Instead of duplicated prose, the plugin injects a dense, machine-readable routing protocol. The protocol itself is 3,249 characters; a Claude orchestrator receives 4,021 characters after its authority prefix (roughly 1,005–1,117 tokens at 3.6–4.0 characters per token). Every message, every session.
28
28
 
29
29
  **Match task to tier using a configurable taxonomy.**
30
30
  A keyword routing guide (`@fast→search/grep/read`, `@medium→impl/refactor/test`, `@heavy→arch/debug/security`) tells the orchestrator exactly which tier fits each task type. Fully customizable. No ambiguity.
@@ -45,7 +45,7 @@ Every tier carries its `costRatio` (fast=1x, medium=5x, heavy=20x) injected into
45
45
  If the orchestrator is already running on Opus, the rule `self∈opus→never→@heavy` fires — it does the heavy work itself rather than delegating to another Opus instance.
46
46
 
47
47
  **Multi-provider support with automatic fallback.**
48
- Eight presets out of the box: Anthropic, OpenAI, GitHub Copilot, Google, hybrid, hybrid-2, fable-effort, and Zai (GLM). Switch with `/preset`. If a provider fails, the fallback chain tries the next one automatically.
48
+ Six presets out of the box: Anthropic, OpenAI, GitHub Copilot, Google, hybrid, and Zai (GLM). Switch with `/preset`. If a provider fails, the fallback chain tries the next one automatically.
49
49
 
50
50
  **Plan annotation for long tasks.**
51
51
  `/annotate-plan` reads a markdown plan and tags each step with `[tier:fast]`, `[tier:medium]`, or `[tier:heavy]` — removing all routing ambiguity from multi-step workflows.
@@ -77,7 +77,7 @@ opencode-model-router injects a **delegation protocol** into the system prompt t
77
77
  4. **Never over-qualify** — use the cheapest tier that can reliably handle the task
78
78
  5. **Fallback** across providers when one fails
79
79
 
80
- All of this adds 3,248 characters for a non-Claude orchestrator or 4,020 characters for a Claude orchestrator (roughly 812–1,117 tokens at 3.6–4.0 characters per token).
80
+ All of this adds 3,249 characters for a non-Claude orchestrator or 4,021 characters for a Claude orchestrator (roughly 812–1,117 tokens at 3.6–4.0 characters per token).
81
81
 
82
82
  ## Understanding how it works
83
83
 
@@ -178,7 +178,7 @@ Task distribution: 18 exploration (60%), 10 implementation (33%), 2 architecture
178
178
 
179
179
  ## How it works
180
180
 
181
- On every message, the plugin injects a 3,248-character routing protocol. A Claude orchestrator receives 4,020 characters after its authority prefix (roughly 1,005–1,117 tokens at 3.6–4.0 characters per token). The notation is intentionally dense and compressed — it's **optimized for LLM comprehension, not human readability**. An agent reads it as a precise routing grammar; a human might squint at it.
181
+ On every message, the plugin injects a 3,249-character routing protocol. A Claude orchestrator receives 4,021 characters after its authority prefix (roughly 1,005–1,117 tokens at 3.6–4.0 characters per token). The notation is intentionally dense and compressed — it's **optimized for LLM comprehension, not human readability**. An agent reads it as a precise routing grammar; a human might squint at it.
182
182
 
183
183
  What the orchestrator sees (Anthropic preset, normal mode):
184
184
 
@@ -230,7 +230,7 @@ With router → split:
230
230
  | Cross-provider fallback | ✅ | ❌ | ❌ | ❌ | ❌ |
231
231
  | Cost ratio awareness | ✅ | ❌ | ❌ | ❌ | ❌ |
232
232
  | Plan annotation with tiers | ✅ | ❌ | ❌ | ❌ | ❌ |
233
- | Measured prompt overhead: 3,248–6,356 chars | ✅ | — | ❌ | ❌ | ❌ |
233
+ | Measured prompt overhead: 3,249–6,357 chars | ✅ | — | ❌ | ❌ | ❌ |
234
234
 
235
235
  **Claude native**: single model for everything, no cost routing. If you're using claude.ai or OpenCode without plugins, you're paying the same price for `grep` as for architecture design.
236
236
 
@@ -275,6 +275,11 @@ For a local checkout, replace the package name with its absolute directory path.
275
275
  V2 loads the package's `server.ts` definition; v1 continues to load the original
276
276
  function from `src/index.ts`. Existing v1 configuration does not need to change.
277
277
 
278
+ > **OpenCode v1: feature freeze.** Since 2026-10-09, v1 support gets fixes for
279
+ > regressions and security issues only. Every new feature targets OpenCode v2 and
280
+ > stays inert on v1 (at most one notice, no behaviour), as roles mode already does.
281
+ > See the [changelog entry](CHANGELOG.md#250---2026-10-09).
282
+
278
283
  Routing, tool guards and verification use the same engine on both versions. V2
279
284
  uses its native `subagent` tool to create real child sessions, preserving the
280
285
  host's permissions and cancellation. There are a few host differences:
@@ -425,13 +430,13 @@ For an npm install, `tiers.json` is **inside the cached package directory**, not
425
430
 
426
431
  ### Presets
427
432
 
428
- The plugin ships with eight presets (switch with `/preset <name>`):
433
+ The plugin ships with six presets (switch with `/preset <name>`):
429
434
 
430
435
  **anthropic** (default):
431
436
  | Tier | Model | Cost ratio |
432
437
  |------|-------|-----------|
433
- | @fast | `anthropic/claude-haiku-5-5` (variant/effort: low) | 1x |
434
- | @medium | `anthropic/claude-sonnet-5-5` (variant/effort: medium) | 5x |
438
+ | @fast | `anthropic/claude-haiku-5-5` (variant/effort: medium) | 1x |
439
+ | @medium | `anthropic/claude-sonnet-5-5` (variant/effort: high) | 5x |
435
440
  | @heavy | `anthropic/claude-opus-5-5` (variant/effort: xhigh) | 20x |
436
441
 
437
442
  **openai**:
@@ -455,29 +460,22 @@ The plugin ships with eight presets (switch with `/preset <name>`):
455
460
  | @medium | `google/gemini-3.7-flash` | 5x |
456
461
  | @heavy | `google/gemini-3.1-pro-preview` | 20x |
457
462
 
458
- **hybrid** — OpenAI for exploration and implementation, Anthropic for heavy analysis:
459
- | Tier | Model | Cost ratio |
460
- |------|-------|-----------|
461
- | @fast | `openai/gpt-6-luna-fast` (medium) | 1x |
462
- | @medium | `openai/gpt-6-astra-fast` (high) | 5x |
463
- | @heavy | `anthropic/claude-opus-5-5` (variant/effort: xhigh) | 20x |
464
-
465
- **hybrid-2** — OpenAI for exploration, Anthropic for implementation and heavy analysis:
463
+ **hybrid** — Anthropic for exploration and heavy analysis, OpenAI for implementation:
466
464
  | Tier | Model | Cost ratio |
467
465
  |------|-------|-----------|
468
- | @fast | `openai/gpt-6-luna-fast` (medium) | 1x |
469
- | @medium | `anthropic/claude-sonnet-5-5` (variant/effort: xhigh) | 5x |
466
+ | @fast | `anthropic/claude-haiku-5-5` (variant/effort: medium) | 1x |
467
+ | @medium | `openai/gpt-6.1-sol-fast` (xhigh) | 5x |
470
468
  | @heavy | `anthropic/claude-opus-5-5` (variant/effort: xhigh) | 20x |
471
469
 
472
- **fable-effort** — one model, three reasoning depths (see [per-tier `effort`](#per-tier-effort)):
473
- | Tier | Model | Effort | Cost ratio |
474
- |------|-------|--------|-----------|
475
- | @fast | `anthropic/claude-fable-5-1` | `low` | 1x |
476
- | @medium | `anthropic/claude-fable-5-1` | `high` | 3x |
477
- | @heavy | `anthropic/claude-fable-5-1` | `xhigh` | 6x |
478
-
479
- Because the model string is identical across tiers, escalating a task keeps the prompt
480
- cache warm. The cost ratios are estimated token-spend multipliers, not price differences.
470
+ > **Removed in 2.6.0:** the bundled `hybrid-2` and `fable-effort` presets, and the
471
+ > previous `hybrid` values (OpenAI `gpt-6-luna-fast` / `gpt-6-astra-fast` for `@fast` / `@medium`).
472
+ > To keep any of them, copy its block from the 2.5.0 `tiers.json` into `presets` in
473
+ > `opencode-model-router.overrides.jsonc` and keep `activePreset` there (the previous `hybrid` under a new name:
474
+ > preset overrides merge key by key). See the
475
+ > [changelog](CHANGELOG.md#260---2026-10-09) for the `fable-effort` block and the migration notes.
476
+ > A preset you chose with `/preset` that no layer defines any more is reported as a config notice
477
+ > (`the preset '<name>' chosen with /preset is not defined …`), and the router keeps routing on the
478
+ > configured `activePreset`.
481
479
 
482
480
  **zai** — GLM through the Z.AI Coding Plan (the `zai-coding-plan` provider, which is where `glm-5.3` lives):
483
481
  | Tier | Model | Variant | Cost ratio |
@@ -486,8 +484,8 @@ cache warm. The cost ratios are estimated token-spend multipliers, not price dif
486
484
  | @medium | `zai-coding-plan/glm-5.3` | `high` | 3x |
487
485
  | @heavy | `zai-coding-plan/glm-5.3` | `max` | 6x |
488
486
 
489
- @medium and @heavy share one model, so — as with `fable-effort` — the cost ratios are
490
- estimated token-spend multipliers, not price differences.
487
+ @medium and @heavy share one model, so the cost ratios are estimated token-spend
488
+ multipliers, not price differences.
491
489
 
492
490
  ### Per-tier `effort`
493
491
 
@@ -1016,13 +1014,13 @@ The bump applies to the optional `delegate` tool's automatic ladder, not native
1016
1014
  `/bypass` leaves the ladder and effort bump active; use `effortBump: false` to disable
1017
1015
  the bump.
1018
1016
 
1019
- Among bundled presets, **only `fable-effort` fast and medium are eligible**
1020
- (`low → medium` and `high → xhigh`). Its heavy tier is already at the default
1021
- ceiling; all other presets either set a variant or omit `effort`. In particular,
1022
- the default `anthropic` preset has no bumpable tier. Attempt and cost ceilings
1023
- still apply: starting at fast with the default cost multiple of 4, `fable-effort`
1024
- runs `fast@low → fast@medium → medium@high`, then stops on cost; medium's bump
1025
- is not reached. Raise `enforcement.escalate.costCeiling.multiple` to allow it.
1017
+ **No bundled preset has a bumpable tier**: every tier that sets `effort` also sets a
1018
+ `variant`, and the rest omit `effort`. In particular, the default `anthropic` preset has
1019
+ no bumpable tier. The bump is for presets of your own that set `effort` without a
1020
+ `variant` (for example a one-model preset running at `low`, `high` and `xhigh`). Attempt
1021
+ and cost ceilings still apply: with the default cost multiple of 4, a ladder that
1022
+ starts at the cheapest tier may stop on cost before a later tier's bump is reached.
1023
+ Raise `enforcement.escalate.costCeiling.multiple` to allow it.
1026
1024
 
1027
1025
  See the [configuration reference](docs/CONFIG_REFERENCE.md) for eligibility and
1028
1026
  cost settings, and the [ADR](docs/adr/0004-delegation-depth-and-effort-bump.md) for
@@ -1104,6 +1102,7 @@ Full field notes are in [docs/CONFIG_REFERENCE.md](docs/CONFIG_REFERENCE.md).
1104
1102
  - `docs/adr/0005-cost-aware-routing-engine.md` — the decisions behind the routing engine
1105
1103
  - `docs/ROLES.md` — roles mode: role agents, authority and separation, tier floor, budgets, `router_run`, migration
1106
1104
  - `docs/adr/0006-role-tier-assurance-delegation.md` — the decisions behind roles mode
1105
+ - `docs/TUI_STATUS.md` — the OpenCode v2 TUI status: what it shows, `cli.json` options, the effort channel, limitations
1107
1106
 
1108
1107
  > These files are not included in the npm tarball. This section is the self-contained summary; the docs are available in the repository for contributors and advanced users.
1109
1108
 
@@ -1132,7 +1131,7 @@ What else ships with it:
1132
1131
  - **Observability.** A decision log and an outcome store under the trajectory directory, `/router stats`, and `npm run routing:stats` in a clone.
1133
1132
  - **Classifier backends** for uncertain task classes: `rules` (default, local), `openai-compatible` (Ollama, any OpenAI-style server), `typesafe`, and `host` (**experimental**). Backends receive at most a bounded, scrubbed excerpt of the task, are only configurable from the global override, and never block a dispatch.
1134
1133
 
1135
- On OpenCode v1 the routing engine does not run: the `routing` block is validated and `engine` is forced to `static`; setting `routing.roles` adds an opt-in prose line. Roles mode is inert on v1 too: when `routing.delegation: "roles"`, `roleAgents`, `routing.exploration`, `routing.run` or `routing.workRoots` is set, the plugin logs one notice per process, `roles delegation requires OpenCode v2; using tiers`, and with `routing.delegation: "roles"` `/router` also reports the advisor info `roles-on-legacy-host`. v1 is not entirely unchanged by this release: the #84 guard and verification fixes apply on every host (see the [behaviour change entry](CHANGELOG.md#changed) of the changelog). Every key and default is in [`docs/CONFIG_REFERENCE.md`](docs/CONFIG_REFERENCE.md#routing--cost-aware-routing-engine-74); the full guide is [`docs/ROUTING_ENGINE.md`](docs/ROUTING_ENGINE.md) and the decision record is [`docs/adr/0005-cost-aware-routing-engine.md`](docs/adr/0005-cost-aware-routing-engine.md).
1134
+ On OpenCode v1 the routing engine does not run: the `routing` block is validated and `engine` is forced to `static`; setting `routing.roles` adds an opt-in prose line. Roles mode is inert on v1 too: when `routing.delegation: "roles"`, `roleAgents`, `routing.exploration`, `routing.run` or `routing.workRoots` is set, the plugin logs one notice per process, `roles delegation requires OpenCode v2; using tiers`, and with `routing.delegation: "roles"` `/router` also reports the advisor info `roles-on-legacy-host`. v1 is not entirely unchanged by this release: the #84 guard and verification fixes apply on every host (see the [behaviour change entry](CHANGELOG.md#240---2026-10-09) of the changelog). Every key and default is in [`docs/CONFIG_REFERENCE.md`](docs/CONFIG_REFERENCE.md#routing--cost-aware-routing-engine-74); the full guide is [`docs/ROUTING_ENGINE.md`](docs/ROUTING_ENGINE.md) and the decision record is [`docs/adr/0005-cost-aware-routing-engine.md`](docs/adr/0005-cost-aware-routing-engine.md).
1136
1135
 
1137
1136
  ## Roles mode (opt-in, OpenCode v2)
1138
1137
 
@@ -1155,6 +1154,29 @@ With `routing.delegation: "roles"` the orchestrator stops picking tiers: it disp
1155
1154
 
1156
1155
  Put `{ "routing": { "delegation": "roles" } }` in the global override file and **restart OpenCode** (roles mode is decided at plugin start); restore the previous file and restart to go back. OpenCode v1 keeps the tier model. Guide: [`docs/ROLES.md`](docs/ROLES.md); decision record: [`docs/adr/0006-role-tier-assurance-delegation.md`](docs/adr/0006-role-tier-assurance-delegation.md).
1157
1156
 
1157
+ ## TUI status (OpenCode v2)
1158
+
1159
+ On OpenCode v2 (2.0.24 or later) the package also ships a TUI entry, `tui.ts`, that shows which model and effort the router's sessions run with:
1160
+
1161
+ - **Main session footer:** `effort <value>` in the prompt footer, only when no variant is selected (the host's footer row already shows a selected variant). Root sessions normally show `effort default`, because the router applies no effort to primary agents.
1162
+ - **Delegated session view:** `<agent> · <model> · <effort>` above the composer.
1163
+ - **Main session while delegates run (opt-in, `runningRow`):** one `<agent> · <model> · <effort>` row per running delegate directly above the prompt box, from before the delegate's first token until the delegate finishes (its session is no longer running); at most `maxRows` rows, then `+<k> more`; nothing when no delegate runs. Off by default, so the main session shows only the footer's effort; turn it on with `"options": { "runningRow": true }` in `cli.json`.
1164
+
1165
+ The effort is what the router applied to the session's latest turn, reported by the server plugin over the rpc `opencode-model-router.effort`. While that channel has no answer, the footer shows `effort default` and the delegate rows show the message's variant.
1166
+
1167
+ It is enabled automatically: OpenCode v2 auto-loads the TUI entry of every package listed in `opencode.json` `plugins`, when the server entry loads. Options (`enabled`, `footer`, `childView`, `runningRow`, `maxRows`) go in OpenCode v2's TUI config file `cli.json` (for example `~/.config/opencode/cli.json`), in an entry whose `package` is the package name, or the package directory for a local checkout:
1168
+
1169
+ <!-- cli.json example -->
1170
+ ```json
1171
+ {
1172
+ "plugins": [
1173
+ { "package": "opencode-model-router", "options": { "runningRow": true, "maxRows": 6 } }
1174
+ ]
1175
+ }
1176
+ ```
1177
+
1178
+ Turn it off with `"options": { "enabled": false }`, or with the selector `"-opencode-model-router.status"` placed after any explicit entry for the plugin. On OpenCode v1 it does nothing: v1 never loads `tui.ts`. Guide: [`docs/TUI_STATUS.md`](docs/TUI_STATUS.md); options: [`docs/CONFIG_REFERENCE.md`](docs/CONFIG_REFERENCE.md#tui-status-options-opencode-v2).
1179
+
1158
1180
  ## Commands
1159
1181
 
1160
1182
  | Command | Description |
@@ -1198,7 +1220,7 @@ With the [routing engine](#cost-aware-routing-opt-in-opencode-v2) live on OpenCo
1198
1220
 
1199
1221
  ## Token overhead
1200
1222
 
1201
- Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,248 characters for a non-Claude orchestrator. A Claude orchestrator receives 4,020 characters after its authority prefix, or 6,356 characters when the 2,336-character DoD/enforcement section is enabled. That is roughly 812–1,766 tokens across the three paths at 3.6–4.0 characters per token. The optional anti-narration clause adds another 650 characters to the Claude path.
1223
+ Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,249 characters for a non-Claude orchestrator. A Claude orchestrator receives 4,021 characters after its authority prefix, or 6,357 characters when the 2,336-character DoD/enforcement section is enabled. That is roughly 812–1,766 tokens across the three paths at 3.6–4.0 characters per token. The optional anti-narration clause adds another 650 characters to the Claude path.
1202
1224
 
1203
1225
  These are character counts of the prompts the shipped config actually produces, so they move whenever the protocol text does. `test/unit/docs-drift.test.ts` recomputes all three from `tiers.json` on every run and fails unless this section still quotes them, so a change that grows the protocol cannot land without updating these numbers.
1204
1226
 
@@ -1210,7 +1232,7 @@ These are character counts of the prompts the shipped config actually produces,
1210
1232
 
1211
1233
  ## Requirements
1212
1234
 
1213
- - [OpenCode](https://opencode.ai) v1 (`>=1.0.0 <2.0.0`) or v2 **2.0.20+**
1235
+ - [OpenCode](https://opencode.ai) v1 (`>=1.0.0 <2.0.0`) or v2 **2.0.20+** (TUI status: 2.0.24+)
1214
1236
  - Node.js 20+
1215
1237
  - Provider API keys configured in OpenCode
1216
1238
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-model-router",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "OpenCode plugin that routes tasks to tiered subagents (fast/medium/heavy) based on complexity",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -14,6 +14,7 @@
14
14
  "smoke:v2": "cross-env RUN_OC_SMOKE_V2=1 vitest run --config vitest.smoke.config.ts test/smoke/v2-registration.smoke.test.ts",
15
15
  "smoke:routing": "cross-env RUN_OC_SMOKE_ROUTING=1 vitest run --config vitest.smoke.config.ts test/smoke/routing-engine.smoke.test.ts",
16
16
  "smoke:v2:e2e": "cross-env RUN_OC_SMOKE_V2_E2E=1 vitest run --config vitest.smoke.config.ts test/smoke/v2-provider-e2e.smoke.test.ts",
17
+ "smoke:tui": "cross-env RUN_OC_SMOKE_TUI=1 vitest run --config vitest.smoke.config.ts test/smoke/tui-status.smoke.test.ts",
17
18
  "routing:stats": "node scripts/routing-stats.ts",
18
19
  "typecheck": "tsc --noEmit"
19
20
  },
@@ -45,6 +46,7 @@
45
46
  ],
46
47
  "files": [
47
48
  "server.ts",
49
+ "tui.ts",
48
50
  "src/",
49
51
  "tiers.json",
50
52
  "LICENSE",
@@ -55,11 +57,14 @@
55
57
  "@opencode-ai/plugin": ">=1.0.0 <2.0.0"
56
58
  },
57
59
  "devDependencies": {
60
+ "@lydell/node-pty": "1.2.0-beta.15",
58
61
  "@opencode/plugin": "2.0.22",
59
62
  "@types/node": "^26.2.0",
60
63
  "@vitest/coverage-v8": "^5.0.3",
64
+ "@xterm/headless": "6.0.0",
61
65
  "cross-env": "^10.1.0",
62
66
  "istanbul-lib-coverage": "^3.2.2",
67
+ "solid-js": "1.9.15",
63
68
  "typescript": "^7.0.2",
64
69
  "vitest": "^5.0.3"
65
70
  }
@@ -43,6 +43,7 @@ import { createSystemAugmenter } from "../routing/wire/hint";
43
43
  import { CONTEXT7_DOC_TOOLS, evaluatePermission, permissionMatches, permissionRules, publishReadOnlyPermissions } from "../router/read-only";
44
44
  import { filterSensitiveGrep, isSensitivePath } from "../router/sensitive-paths";
45
45
  import { canonicalAuthorityPath, insideWorkRoot } from "../routing/roles/work-root";
46
+ import { appliedEffort, appliedThinkingBudget, createEffortStore, registerEffortChannel } from "../tui/effort-channel";
46
47
 
47
48
  /** Translate the router's own v1 tool vocabulary at the v2 boundary. */
48
49
  export function v2Instructions(text: string): string {
@@ -657,6 +658,19 @@ export function roleCatalogFailureNotice(agent: string, childSessionID: string):
657
658
  + `again (the router could not build its tool catalog for this dispatch: fail closed, session "${childSessionID}").`;
658
659
  }
659
660
 
661
+ /**
662
+ * Legacy agent-option aliases → the v2 per-turn keys (`reasoning_effort` → `reasoningEffort`, `reasoning_summary` →
663
+ * `reasoningSummary`, `budget_tokens` → `thinking`); an explicit v2 key wins. Returns a copy: `options` is never modified.
664
+ */
665
+ export function normalizeAgentOptions(options: Readonly<Record<string, unknown>>): Record<string, unknown> {
666
+ const { reasoning_effort, reasoning_summary, budget_tokens, ...rest } = options;
667
+ const normalized: Record<string, unknown> = { ...rest };
668
+ if (reasoning_effort !== undefined && normalized.reasoningEffort === undefined) normalized.reasoningEffort = reasoning_effort;
669
+ if (reasoning_summary !== undefined && normalized.reasoningSummary === undefined) normalized.reasoningSummary = reasoning_summary;
670
+ if (budget_tokens !== undefined && normalized.thinking === undefined) normalized.thinking = { type: "enabled", budgetTokens: budget_tokens };
671
+ return normalized;
672
+ }
673
+
660
674
  /** Register the existing router engine on the public OpenCode 2 domain APIs. */
661
675
  export async function registerV2Hooks(
662
676
  ctx: Context,
@@ -700,6 +714,27 @@ export async function registerV2Hooks(
700
714
  // casts confined to this adapter, rather than weakening the v2 event types.
701
715
  const legacy = hooks as unknown as Record<string, LegacyHook | undefined>;
702
716
  const registrations: Array<{ dispose(): Promise<void> }> = [];
717
+ /** #90 P1.2: per session, what the context hook's `chat.params` bridge applied to the latest turn (the TUI's `effortOf`). */
718
+ // One store per adapter instance, not module state: every instance of a location records the same turns; the last registration answers.
719
+ const effortStore = createEffortStore();
720
+ /**
721
+ * #90 P1.2: records what a turn's request carries (read-only: `event.options` is normalised into a copy, never written), root and
722
+ * child sessions alike. Only a non-empty string session id is recorded; a turn that cannot be read is forgotten, never left stale.
723
+ */
724
+ const recordEffortTurn = (event: SessionContext): void => {
725
+ const sessionID: unknown = event.sessionID;
726
+ if (typeof sessionID !== "string" || sessionID === "") return;
727
+ try {
728
+ const applied = normalizeAgentOptions(event.options);
729
+ effortStore.record(sessionID, {
730
+ effort: appliedEffort(applied, { providerID: event.model.providerID, modelID: event.model.id }),
731
+ thinkingBudget: appliedThinkingBudget(applied), variant: event.model.variant,
732
+ providerID: event.model.providerID, modelID: event.model.id, agent: event.agent, at: Date.now(),
733
+ });
734
+ } catch {
735
+ effortStore.forget(sessionID);
736
+ }
737
+ };
703
738
  const abort = new AbortController();
704
739
  const verifyingCalls = new Set<string>();
705
740
  const depthBanners = new Map<string, string>();
@@ -1127,12 +1162,7 @@ export async function registerV2Hooks(
1127
1162
  const nextOptions = new Map<string, Record<string, unknown>>();
1128
1163
  for (const [name, definition] of Object.entries(next.agent)) {
1129
1164
  if (nextOriginals.get(name) === JSON.stringify(definition) || !definition.options) continue;
1130
- const { reasoning_effort, reasoning_summary, budget_tokens, ...options } = definition.options;
1131
- const normalized = { ...options };
1132
- if (reasoning_effort !== undefined && normalized.reasoningEffort === undefined) normalized.reasoningEffort = reasoning_effort;
1133
- if (reasoning_summary !== undefined && normalized.reasoningSummary === undefined) normalized.reasoningSummary = reasoning_summary;
1134
- if (budget_tokens !== undefined && normalized.thinking === undefined) normalized.thinking = { type: "enabled", budgetTokens: budget_tokens };
1135
- nextOptions.set(name, normalized);
1165
+ nextOptions.set(name, normalizeAgentOptions(definition.options));
1136
1166
  }
1137
1167
  config = next;
1138
1168
  originals = nextOriginals;
@@ -1378,6 +1408,10 @@ export async function registerV2Hooks(
1378
1408
  if (!(key in event.options)) event.options[key] = value;
1379
1409
  }
1380
1410
  await legacy["chat.params"]?.(input, event.options);
1411
+ // #90 P1.2 (A3): what this turn's request carries after the router's hook; no effort key records none (clearing a stale one).
1412
+ // The channel never changes the hook's outcome.
1413
+ // Host v2.0.24 core/src/session/model-request.ts:408-411 fires `context` for primary requests only (compaction, generate, title have their own hooks).
1414
+ recordEffortTurn(event);
1381
1415
  const routerConfig = loadConfig(ctx.location.directory);
1382
1416
  const verify = routerConfig.enforcement?.verify;
1383
1417
  if (event.agent === V2_GRADER_AGENT
@@ -1437,6 +1471,12 @@ export async function registerV2Hooks(
1437
1471
  }
1438
1472
  }
1439
1473
  }
1474
+ // #90 P1.2 (A1): the TUI's `effortOf` rpc, answered from `effortStore`; tiers and roles mode alike. Feature-detected (a host
1475
+ // without `ctx.rpc.register` gets nothing), bounded (2 s; a late registration is kept), never throws; disposed with the other
1476
+ // registrations. GA-4: not awaited here, so a slow `register` never delays the hooks below; its dispose waits for the
1477
+ // registration to settle (at most the 2 s bound) and then disposes it.
1478
+ const effortChannel = registerEffortChannel(ctx.rpc, effortStore, ingestLogger).catch(() => async () => {});
1479
+ registrations.push({ dispose: async () => { await (await effortChannel)(); } });
1440
1480
  registrations.push(await ctx.session.hook("context", async (event) => {
1441
1481
  // #84 P2.3 (P-3, I9): a role session's context hook never fails the child. ANY error below empties its catalog (the
1442
1482
  // strictest outcome) and is annotated for the parent's `subagent` result; every other agent keeps today's behaviour.
@@ -1444,8 +1484,13 @@ export async function registerV2Hooks(
1444
1484
  try {
1445
1485
  await buildContext(event, role);
1446
1486
  } catch (error) {
1447
- if (role === undefined) throw error;
1487
+ if (role === undefined) {
1488
+ // #90 P1.2: the request does not go out, so nothing is recorded for it (not even a record made earlier in this turn).
1489
+ if (typeof event.sessionID === "string") effortStore.forget(event.sessionID);
1490
+ throw error;
1491
+ }
1448
1492
  for (const name of Object.keys(event.tools ?? {})) delete event.tools[name];
1493
+ recordEffortTurn(event); // #90 P1.2: the role session goes on fail-closed with these options: they are what is recorded
1449
1494
  warnPermissionOnce(`role tool catalog failed for ${role}: ${String(error)}`);
1450
1495
  const child = String(event.sessionID);
1451
1496
  if (!catalogFailures.has(child)) {
@@ -1799,6 +1844,7 @@ export async function registerV2Hooks(
1799
1844
  lookupNamedAgent.delete(data.sessionID);
1800
1845
  lastCallOfChild.delete(data.sessionID);
1801
1846
  hostBudget.forget(data.sessionID);
1847
+ effortStore.forget(data.sessionID); // #90 P1.2: a deleted session is no longer answered
1802
1848
  }
1803
1849
  await ingesting("session.deleted", () => ingest.onSessionGone(data.sessionID));
1804
1850
  } else if (FLUSH_EVENT_TYPES.has(event.type)) {
@@ -2726,6 +2726,14 @@ function buildConfig(
2726
2726
  const resolved = resolvePresetName(cfg, state.activePreset);
2727
2727
  if (resolved) {
2728
2728
  cfg.activePreset = resolved;
2729
+ } else {
2730
+ // A preset saved by `/preset` that no layer defines any more (2.6.0 removed the bundled
2731
+ // `hybrid-2` and `fable-effort`). The config still loads on the configured activePreset,
2732
+ // but saying so beats routing quietly on a different preset.
2733
+ notices.push({
2734
+ source: statePath(),
2735
+ message: `the preset '${state.activePreset}' chosen with /preset is not defined (defined: ${Object.keys(cfg.presets).join(", ")}); using '${cfg.activePreset}'`,
2736
+ });
2729
2737
  }
2730
2738
  }
2731
2739
  if (state.activeMode && cfg.modes?.[state.activeMode]) {