opencode-model-router 1.5.0 → 1.7.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 ADDED
@@ -0,0 +1,357 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.7.0] - 2026-08-19
9
+
10
+ Minor release: live model-catalog discovery and validation — `/router models`, stale-model
11
+ and fallback-chain checks, orphaned strong-pattern detection with near-miss naming — plus
12
+ `subagentTiers` for routing pre-existing subagents, resolved prompt style in `/tiers`, and
13
+ a set of enforcement and noise fixes. Routing behavior is unchanged unless you opt into
14
+ the new keys.
15
+
16
+ ### Added
17
+
18
+ - **Near-miss reporting for orphaned strong-model patterns.** When a pattern matches
19
+ nothing served, `/router models` and the startup warning now name any served model
20
+ that matches once `.`, `-` and `_` are normalized away. The known failure is a
21
+ provider moving between separator styles rather than a wrong name, so this turns
22
+ "this matches nothing" into "this matches nothing, and here is the id it means".
23
+
24
+ - **`subagentTiers`, opt-in routing for your own subagents.** A map of agent name to
25
+ tier name repoints pre-existing custom subagents at the active preset's models, so
26
+ they follow `/preset` instead of pinning a model id in their own agent files. A
27
+ subagent that declares no `model` otherwise inherits the model of whoever invoked it,
28
+ which quietly runs cheap read-only helpers at orchestrator prices. Absent or empty
29
+ means no agent is touched.
30
+ - **`/router models [provider]`** lists valid model ids from opencode's live provider
31
+ catalog, with each provider's default and any `deprecated`/`alpha`/`beta` status.
32
+ - **Stale-model validation.** Bare `/router` checks the active preset's tier models
33
+ against the catalog and reports missing or deprecated ids with the closest valid
34
+ suggestions; the same check is logged once per session. Report-only, so the plugin
35
+ never changes a model for you. A bad model id previously failed silently on every
36
+ subagent dispatch.
37
+
38
+ ### Fixed
39
+
40
+ - **Orphaned-pattern warnings the user could not act on.** A pattern from the shipped
41
+ default list is now reported only when a near-miss proves the model is served under a
42
+ drifted separator; a pattern you wrote in `modelGenerations.strong` is still always
43
+ reported. An anthropic-only install no longer warns that `claude-mythos-5` matches
44
+ nothing — that provider simply does not sell it.
45
+
46
+ - **Dormant fallback chains reported as broken.** `fallback-provider-unknown` now fires
47
+ only when the active preset actually routes to that provider. The shipped chains cover
48
+ every provider, so a single-provider install was warning about chains that are inert by
49
+ design. Chain entries naming a preset that does not exist are still reported.
50
+
51
+ - Removed a stale `buildAgentOptions` from `src/commands/output.ts`. It was live when
52
+ the presentation layer was extracted, but `src/router/agent-options.ts` later became
53
+ the real implementation and gained `effort` handling. The orphan was reachable only
54
+ from its own test, and importing it by mistake would have silently dropped `effort`.
55
+
56
+ - **`thinking.budgetTokens: 0` no longer swallows a tier's `effort`.** Behavior change:
57
+ suppression used `budgetTokens != null` while emission required a truthy value, so a
58
+ Claude tier with `thinking: { budgetTokens: 0 }` plus `effort` warned that "explicit
59
+ thinking wins" and then registered neither key. A truthy `budgetTokens` is now the
60
+ single notion of "thinking was asked for": `0` is ignored (one-time notice per tier)
61
+ and `effort` applies normally.
62
+ - **Enforced-mode hard blocks now apply to non-trivial `@fast` recon.** Trivial
63
+ classification exempted *any* `fast`-tier dispatch whose text matched a `fast`
64
+ taskPattern stem (`read`, `search`, `grep`, …) from enforcement, so a multi-file
65
+ recon dispatch was treated as "trivial" and `guardBeforeCall` downgraded
66
+ `enforced` → `advisory`. The `read_budget` guard could therefore never
67
+ hard-block a `@fast` subagent — the precise runaway it exists to bound.
68
+ `classifyTrivial` now additionally requires single-shot shape: at most one named
69
+ file path (well-known extensionless files like `Makefile` or `LICENSE` count),
70
+ no multi-step marker (numbered or colon-numbered lists, sequencing words, `;`,
71
+ `&&`), no enumeration of three or more subjects, no multiple imperative lines,
72
+ no distributive breadth quantifier (`every` / `all` over a plural or collective
73
+ target class, as in `read all guard modules` — partitive depth over a single
74
+ file such as `read every line of package.json` stays trivial), and a length
75
+ backstop. Genuine single-shot lookups stay exempt, and real work
76
+ was never trivial either way. Present since
77
+ proportional enforcement landed (`80abf05`) and shipped in every release that
78
+ included it. The `enforcement.proportional.trivialBypass` knob and its semantics
79
+ are unchanged.
80
+
81
+ ## [1.6.0] - 2026-08-18
82
+
83
+ Minor release: a salvage port of the features worth keeping from an abandoned branch —
84
+ per-tier reasoning effort, goal-oriented prompts, session-resume accounting, time-boxes
85
+ on every verification hop, and idle eviction for the delegation store. Routing behavior
86
+ is unchanged unless you opt into the new keys.
87
+
88
+ ### Added
89
+
90
+ - **Per-tier `effort`.** Each tier may declare a reasoning-effort level that is forwarded
91
+ to the provider on dispatch. The bundled `fable-effort` preset uses it to run all three
92
+ tiers on the same model at different effort levels, so the cost ladder comes from
93
+ reasoning depth rather than model size.
94
+ - **Goal-oriented prompt styles.** `promptStyle` (`auto` | `prescriptive` | `goal-oriented`),
95
+ `modelGenerations`, and `tierPromptsGoalOriented` let a tier ship a goal-oriented prompt
96
+ instead of the terse rule list. Under `auto` a tier switches to the goal-oriented text
97
+ when its model matches a declared newer generation; everything else keeps the prescriptive
98
+ prompt.
99
+ - **Session-resume accounting.** A resumed session no longer restarts its budget: the
100
+ cumulative ceiling carries across resumes, and registration now returns a `RegisterResult`
101
+ so callers can see whether a dispatch was newly counted or replayed.
102
+ - **Time-boxes on delegate, grader, and gate.** `delegateTimeoutMs` (default 600000),
103
+ `graderTimeoutMs` (default 60000), and `gateBudgetMs` (default 90000) bound each hop.
104
+ They are fail-closed: a hop that runs out of budget is reported as unmet, never as
105
+ silently satisfied.
106
+ - **Idle-TTL eviction for the delegation store.** Entries idle for more than an hour are
107
+ swept, throttled to at most one sweep every five minutes. The sweep is timer-less — it
108
+ piggybacks on store access — so it adds no background handles and nothing to unref in
109
+ tests.
110
+ - **`cwd`-scoped verification.** A delegation may carry a `cwd`, which scopes the
111
+ deterministic file checks and the grader's session lookup to that directory.
112
+ - **Evidence-grounding clauses in the medium and heavy tier prompts.** Subagents are told
113
+ to check each reported claim against a tool result from the same session and to say so
114
+ explicitly when a claim is unverified.
115
+ - **An explicit `enforcement` block in `tiers.json`.** Every key is now written out at the
116
+ value that was previously the effective default, so the shipped behavior is unchanged and
117
+ readable rather than implicit. `validateEnforcement` type-checks every shipped key.
118
+
119
+ ### Changed
120
+
121
+ - **`CAP:none` now requires a `reason:` line.** A dispatch that says `CAP:none` without a
122
+ `reason:` line in its text falls back to the tier's baseline cap instead of lifting it.
123
+ The protocol states this in two places (rule 7 and the per-dispatch paragraph), which is
124
+ the whole of this release's prompt growth: the routing protocol goes from 2,970 to 3,089
125
+ characters, and the Claude and enforcement paths grow by the same 119 characters. See the
126
+ token-overhead table in the README.
127
+ - **Under `promptStyle: "auto"`, some bundled tiers switch to goal-oriented prompts.** Tiers
128
+ whose model is `claude-fable-5` or `claude-opus-4-8` — `anthropic.heavy`, `hybrid.heavy`,
129
+ and all three `fable-effort` tiers — now receive the goal-oriented text. Set
130
+ `promptStyle` to `prescriptive` to keep the previous prompts.
131
+
132
+ ### Fixed
133
+
134
+ - **Child-session disposal is idempotent.** Disposing a session that was already disposed
135
+ is a no-op instead of throwing.
136
+ - **Gate-timeout aborts are scoped per delegation.** A gate that runs out of budget aborts
137
+ only its own delegation; concurrent delegations are no longer cancelled with it.
138
+ - **`fileExists` reasons are honest about absolute paths.** The reason string reports the
139
+ path that was actually checked rather than the relative form that was passed in.
140
+ - **No more orphan `lastTouch` entries.** Touch records are removed with their delegation
141
+ instead of accumulating for the lifetime of the process.
142
+
143
+ ### Deliberately not ported
144
+
145
+ Several things from the source branch were left behind on purpose. The **lessons memory store**
146
+ (~800 lines) has no measurement behind it — if it is revisited it must arrive opt-in and
147
+ default-false rather than as a new always-on subsystem. The **anti-context-anxiety clause**,
148
+ the **INTENT section**, and the **workspace-root line** would re-add the prose that [#21]
149
+ deliberately removed. Flipping `activePreset` to `"opus"` would change the default for every
150
+ user, and flipping `enforcement.mode` to `"enforced"` would turn an advisory layer into a
151
+ blocking one; both stay as they are. `src/guard/smoke-evidence.ts` is test-support only and
152
+ carries no runtime behavior, so it was left as optional and not ported.
153
+
154
+ ### Credits
155
+
156
+ Refactors [#26], [#27], and [#28] by Lucas Húngaro were merged while this port was in
157
+ progress, and the ported code is built on top of them.
158
+
159
+ [#26]: https://github.com/marco-jardim/opencode-model-router/pull/26
160
+ [#27]: https://github.com/marco-jardim/opencode-model-router/pull/27
161
+ [#28]: https://github.com/marco-jardim/opencode-model-router/pull/28
162
+
163
+ ## [1.5.0] - 2026-08-18
164
+
165
+ Minor release: update-safe configuration overrides, so customizations survive the plugin
166
+ updates that overwrite the cached package file.
167
+
168
+ ### Added
169
+
170
+ - **Update-safe config overrides.** `~/.config/opencode/opencode-model-router.overrides.jsonc`
171
+ (global) and `<repo>/.opencode/opencode-model-router.overrides.jsonc` (project) are
172
+ deep-merged over the bundled `tiers.json` — specify only the keys you want to change.
173
+ The project file is located by searching upward to the repo root and wins over the
174
+ global file, which wins over the bundled defaults. Models, tiers, and whole presets can
175
+ now be customized without editing the cached package file, which every plugin update
176
+ overwrites. An overrides file can also define an entirely new preset — `model` is the
177
+ only required field per tier: `costRatio`/`steps` default to the conventional `1`/`5`/`20`
178
+ and `30`/`50`/`120` by tier name when omitted, and `description`/`whenToUse` are optional.
179
+ Contributed by Lucas Húngaro. ([#22], closes [#2] and [#4])
180
+ - **JSONC in the override files.** `//` and `/* */` comments and trailing commas are
181
+ accepted, via a small zero-dependency parser (`src/router/jsonc.ts`). No new runtime
182
+ dependencies.
183
+ - **`/router overrides`** — prints the global and project override paths, which of them
184
+ exist, and the merge precedence.
185
+
186
+ ### Fixed
187
+
188
+ - **The upward search for the project override file is now bounded.** It stops at a
189
+ `.git`, `.hg`, or `.svn` marker, at 16 levels above the working directory, or at the
190
+ user's home directory. A tree containing no repo marker previously walked all the way
191
+ to the filesystem root, so running opencode from a non-repo directory could silently
192
+ adopt an unrelated ancestor's override file. `package.json` is deliberately not treated
193
+ as a repo marker: in a monorepo it would stop the walk at `packages/<pkg>/` before
194
+ reaching the repo-root `.opencode/`. ([`8710a84`])
195
+
196
+ [`8710a84`]: https://github.com/marco-jardim/opencode-model-router/commit/8710a84
197
+ [#2]: https://github.com/marco-jardim/opencode-model-router/issues/2
198
+ [#4]: https://github.com/marco-jardim/opencode-model-router/issues/4
199
+ [#22]: https://github.com/marco-jardim/opencode-model-router/pull/22
200
+
201
+ ## [1.4.0] - 2026-08-18
202
+
203
+ Minor release: session lifecycle fixes, more reliable read-only delegation, and a
204
+ smaller routing protocol with measured overhead documentation.
205
+
206
+ ### Fixed
207
+
208
+ - **Grader and producer child sessions are now parented and disposed.** The plugin
209
+ previously created backend sessions for every grader and producer attempt but never
210
+ aborted or deleted them, including on the happy path, leaving orphaned top-level
211
+ sessions in the TUI. ([`40c9b94`])
212
+ - **Layer-2 grading now skips read-only research delegations** when the DoD is inferred,
213
+ checker-only, and no files changed. This prevents false "not accepted" notes on
214
+ legitimate research results. Contributed by Lucas Húngaro. ([#20])
215
+ - README prompt-overhead figures now use measured character counts and explicit token
216
+ estimate ranges. The previous `~210 tokens` claim understated the former default
217
+ Claude path by roughly eight to nine times.
218
+
219
+ ### Added
220
+
221
+ - A drift test now pins the acceptance-check grammar shared by the `/annotate-plan`
222
+ template, `parseAcceptanceBlock`, and the delegation protocol. ([`19171ea`])
223
+
224
+ ### Changed
225
+
226
+ - **The delegation protocol was rewritten without dropping routing rules.** On the
227
+ default Claude path it is 46.6% smaller, from 7,006 to 3,742 characters. Contributed
228
+ by Lucas Húngaro. ([#21])
229
+ - **The anti-narration guardrail is now opt-in.** Set the top-level `antiNarration`
230
+ boolean to `true` to restore the prompt clause and detector; the default is `false`.
231
+ ([#21])
232
+ - The package now declares Node.js 20 or later through `engines.node`. ([`6fa9bab`])
233
+
234
+ [`19171ea`]: https://github.com/marco-jardim/opencode-model-router/commit/19171ea
235
+ [`40c9b94`]: https://github.com/marco-jardim/opencode-model-router/commit/40c9b94
236
+ [`6fa9bab`]: https://github.com/marco-jardim/opencode-model-router/commit/6fa9bab
237
+ [#20]: https://github.com/marco-jardim/opencode-model-router/pull/20
238
+ [#21]: https://github.com/marco-jardim/opencode-model-router/pull/21
239
+
240
+ ## [1.3.1] - 2026-08-16
241
+
242
+ Patch release: bug fixes, documentation, and release-engineering only. No runtime
243
+ behaviour changes beyond the corrected `github-copilot` model identifiers.
244
+
245
+ ### Fixed
246
+
247
+ - **`github-copilot` preset model IDs** now use the dot-separated form the provider
248
+ actually serves (`claude-haiku-4.5`, `claude-sonnet-4.6`, `claude-opus-4.6`) instead of
249
+ the dash-separated variants, and the non-existent `/thinking` suffix has been dropped
250
+ from the `@heavy` tier. Delegations under this preset previously referenced models that
251
+ could not be resolved. ([#10], fixes [#9])
252
+ - Golden snapshot for the `github-copilot` delegation protocol realigned with the
253
+ corrected identifiers above.
254
+
255
+ ### Added
256
+
257
+ - **Continuous integration.** A `Test` workflow runs `npm ci`, the full suite, and
258
+ `npm run typecheck` on Node 24 for every pull request and every push to `master`.
259
+ - **Automated publishing via npm Trusted Publishing (OIDC).** Pushing a `v*` tag builds
260
+ and publishes from GitHub Actions with SLSA provenance attestation and no long-lived
261
+ npm token. Third-party actions are pinned by commit SHA.
262
+ - **`package-lock.json` is now tracked**, making installs reproducible across
263
+ contributors and CI. It is not included in the published tarball.
264
+
265
+ ### Changed
266
+
267
+ - README install and configuration instructions corrected and expanded, including how the
268
+ `tiers.json` cache behaves. ([#7])
269
+ - Development dependencies `vitest` and `@vitest/coverage-v8` upgraded to 4.x. Both are
270
+ bumped in lockstep because `@vitest/coverage-v8` pins an exact `vitest` peer; Dependabot
271
+ is now configured to group them. Dev-only — no effect on the published package. ([#8])
272
+
273
+ [#7]: https://github.com/marco-jardim/opencode-model-router/pull/7
274
+ [#8]: https://github.com/marco-jardim/opencode-model-router/pull/8
275
+ [#9]: https://github.com/marco-jardim/opencode-model-router/issues/9
276
+ [#10]: https://github.com/marco-jardim/opencode-model-router/pull/10
277
+
278
+ ## [1.3.0]
279
+
280
+ ### Changed — advisory enforcement is now the default
281
+
282
+ - **Default enforcement mode flipped `off` → `advisory`.** With `enforcement.mode`
283
+ unset, every non-trivial delegation is now verified and any miss surfaces a
284
+ non-blocking forcing-note; the orchestrator system prompt grows by ~200 tokens for
285
+ the DoD/acceptance section, and subagents may receive non-blocking guard banners.
286
+ Nothing is ever hard-blocked in `advisory`. To restore the previous byte-identical
287
+ behaviour (zero added tokens, zero new latency), set `"mode": "off"` explicitly, run
288
+ `/router enforce off`, or set `MODEL_ROUTER_ENFORCE=0`.
289
+ - **The custom `delegate` tool is now hidden by default.** Delegation routes through the
290
+ native `Task()` tool so subagents render inline in the TUI instead of running in an
291
+ invisible orphan session (fixes the `delegate [tier=…, task=…]` stall). The
292
+ independently-verified `delegate` tool remains available behind an opt-in flag.
293
+ - The acceptance forcing-note now includes tier-escalation guidance
294
+ (`Task(subagent_type="<nextTier>")`) when a delegated result is not accepted.
295
+
296
+ ### Added
297
+
298
+ - `experimental.verifiedDelegateTool` config flag in `tiers.json`, and the
299
+ `MODEL_ROUTER_VERIFIED_DELEGATE=1` environment variable, to opt back into the
300
+ authoritative `delegate` tool.
301
+
302
+ ## [1.2.0]
303
+
304
+ ### Added — Enforced delegation (opt-in, default OFF)
305
+
306
+ A three-layer enforcement system that makes tiered delegation *reliable* instead of
307
+ advisory. **It is opt-in and disabled by default**: with `enforcement.mode` unset (or
308
+ `"off"`), behaviour is byte-identical to previous releases — no added prompt tokens, no
309
+ new runtime behaviour. Enable per repo via `enforcement.mode` in `tiers.json`, per run
310
+ via the `MODEL_ROUTER_ENFORCE=1` environment variable, or per session via
311
+ `/router enforce <off|advisory|enforced>`. Enforcement applies only to subagent/delegate
312
+ sessions; the orchestrator session is never gated.
313
+
314
+ - **Layer 1 — hard-block guard** (`tool.execute.before`): an in-band, throw-to-block
315
+ guard for subagent sessions. Enforces a tool-call budget ceiling, anti-redundancy
316
+ (repeated identical reads), and anti-self-script (ad-hoc `bash` execution such as
317
+ heredocs / `node -e` / `cat >`), with an optional deliverable-first rule. Writing
318
+ source files is *never* blocked by default (`blockScriptWrites` is opt-in).
319
+ `off` is a no-op, `advisory` surfaces a banner, `enforced` blocks.
320
+ - **Layer 2 — independent acceptance gate**: turns "the producer says it's done" into
321
+ "the output was objectively accepted". A Definition-of-Done is parsed from an
322
+ `[acceptance]` block (Mode B) or auto-inferred from the dispatch (Mode A) and checked
323
+ either deterministically (`run` / `fileExists` / `schemaMatch` / `testsPass` /
324
+ `buildPasses` / `lintClean` behind an allowlisted exec/fs seam) or by an **independent
325
+ grader** in a fresh session at a tier ≥ the producer's. Fail-closed: any error,
326
+ unparseable verdict, or non-independent grader counts as a failure. Never silently
327
+ accepts a non-trivial delegation that lacks a checkable DoD.
328
+ - **Layer 3 — quality-escalation ladder**: on a failed gate the authoritative `delegate`
329
+ tool retries, then escalates `fast → medium → heavy`, then returns an honest
330
+ `status: unmet` — never a fake pass. Provably terminating (bounded by
331
+ `maxAttemptsPerTier`, `maxTotalAttempts`, and a cost ceiling) and composes with the
332
+ existing advisory provider-failover chain without double-counting attempts.
333
+
334
+ ### Added — tooling & APIs
335
+
336
+ - New `delegate` tool (authoritative produce → verify → escalate in one call) alongside
337
+ the existing raw `Task()` path (advisory-grade verify-dispatch).
338
+ - New `/router enforce <off|advisory|enforced>` command (persisted atomically).
339
+ - New `enforcement` configuration block in `tiers.json` (fully validated; see
340
+ `docs/CONFIG_REFERENCE.md`). Per-mode example presets in `docs/ENFORCEMENT_PRESETS.md`.
341
+ - TypeScript + Vitest test infrastructure, golden-snapshot characterization tests, and a
342
+ coverage gate. Documentation suite: `docs/ENFORCEMENT.md`, `docs/VERIFICATION.md`,
343
+ `docs/ESCALATION.md`, `docs/CONFIG_REFERENCE.md`, `docs/MIGRATION.md`, and ADRs
344
+ `docs/adr/0000`–`0002`.
345
+
346
+ ### Security
347
+
348
+ - Secret scrubbing (`scrubText`) is applied to every model-visible string the enforcement
349
+ layers emit — forcing messages, grader prompts, scorecards, and trajectory dumps.
350
+ - The deterministic verifier runs only allowlisted binaries, rejects shell
351
+ metacharacters, and blocks interpreter eval flags (`node -e`, `python -c`, …).
352
+
353
+ ### Notes
354
+
355
+ - Default is OFF; upgrading changes nothing until you opt in. See `docs/MIGRATION.md`.
356
+ - The bundled per-mode enforcement presets are **preliminary** (tuned from fixtures, not
357
+ field telemetry) and are documented rather than written into `tiers.json`.