opencode-model-router 1.10.0 → 1.11.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
@@ -5,6 +5,27 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.11.0] - 2026-08-24
9
+
10
+ ### Added
11
+
12
+ - **A `zai` preset, routing GLM models through the Z.AI Coding Plan.** `@fast` takes
13
+ `glm-4.7`, `@medium` and `@heavy` share `glm-5.3` at `high` and `max` effort. Contributed
14
+ by @MarCYK in
15
+ [#37](https://github.com/marco-jardim/opencode-model-router/pull/37), closing
16
+ [#18](https://github.com/marco-jardim/opencode-model-router/issues/18).
17
+
18
+ Landed with three fixes on top. The preset originally named the `zai` provider, but
19
+ `glm-5.3` is not published under it in the models.dev catalog opencode resolves against
20
+ — it exists only under `zai-coding-plan`, whose reasoning options (`low`/`high`/`max`)
21
+ are also what make the `high` and `max` variants valid. All three tiers now point at
22
+ `zai-coding-plan/*` and say so in their descriptions, since the plan is a prerequisite.
23
+ `fallback.global` gained a `zai-coding-plan` chain, so a Z.AI outage now fails over
24
+ instead of dead-ending. And `costRatio` follows the `fable-effort` precedent — `1`/`3`/`6`
25
+ as an estimated token-spend multiplier, not a price difference, because `@medium` and
26
+ `@heavy` are the same model on a flat-rate plan where the catalog prices every model at
27
+ zero.
28
+
8
29
  ## [1.10.0] - 2026-08-20
9
30
 
10
31
  Minor release. Config errors are caught at load instead of drifting to a later turn,
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **Use the cheapest model that can do the job. Automatically.**
4
4
 
5
- An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,084–4,654 characters of system-prompt overhead depending on the orchestrator and enforcement mode.
5
+ An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,116–4,686 characters of system-prompt overhead depending on the orchestrator and enforcement mode.
6
6
 
7
7
  ## Why it's different
8
8
 
@@ -12,7 +12,7 @@ Most AI coding tools give you one model for everything. You pay Opus prices to r
12
12
  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.
13
13
 
14
14
  **Inject a compressed, LLM-optimized routing protocol.**
15
- Instead of duplicated prose, the plugin injects a dense, machine-readable routing protocol. The protocol itself is 3,084 characters; a Claude orchestrator receives 3,856 characters after its authority prefix (roughly 965–1,075 tokens at 3.6–4.0 characters per token). Every message, every session.
15
+ Instead of duplicated prose, the plugin injects a dense, machine-readable routing protocol. The protocol itself is 3,116 characters; a Claude orchestrator receives 3,888 characters after its authority prefix (roughly 965–1,075 tokens at 3.6–4.0 characters per token). Every message, every session.
16
16
 
17
17
  **Match task to tier using a configurable taxonomy.**
18
18
  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.
@@ -33,7 +33,7 @@ Every tier carries its `costRatio` (fast=1x, medium=5x, heavy=20x) injected into
33
33
  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.
34
34
 
35
35
  **Multi-provider support with automatic fallback.**
36
- Four presets out of the box: Anthropic, OpenAI, GitHub Copilot, Google. Switch with `/preset`. If a provider fails, the fallback chain tries the next one automatically.
36
+ Seven presets out of the box: Anthropic, OpenAI, GitHub Copilot, Google, hybrid, fable-effort, and Zai (GLM). Switch with `/preset`. If a provider fails, the fallback chain tries the next one automatically.
37
37
 
38
38
  **Plan annotation for long tasks.**
39
39
  `/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.
@@ -65,7 +65,7 @@ opencode-model-router injects a **delegation protocol** into the system prompt t
65
65
  4. **Never over-qualify** — use the cheapest tier that can reliably handle the task
66
66
  5. **Fallback** across providers when one fails
67
67
 
68
- All of this adds 3,084 characters for a non-Claude orchestrator or 3,856 characters for a Claude orchestrator (roughly 770–1,075 tokens at 3.6–4.0 characters per token).
68
+ All of this adds 3,116 characters for a non-Claude orchestrator or 3,888 characters for a Claude orchestrator (roughly 770–1,075 tokens at 3.6–4.0 characters per token).
69
69
 
70
70
  ## Understanding how it works
71
71
 
@@ -166,7 +166,7 @@ Task distribution: 18 exploration (60%), 10 implementation (33%), 2 architecture
166
166
 
167
167
  ## How it works
168
168
 
169
- On every message, the plugin injects a 3,084-character routing protocol. A Claude orchestrator receives 3,856 characters after its authority prefix (roughly 965–1,075 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.
169
+ On every message, the plugin injects a 3,116-character routing protocol. A Claude orchestrator receives 3,888 characters after its authority prefix (roughly 965–1,075 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.
170
170
 
171
171
  What the orchestrator sees (Anthropic preset, normal mode):
172
172
 
@@ -218,7 +218,7 @@ With router → split:
218
218
  | Cross-provider fallback | ✅ | ❌ | ❌ | ❌ | ❌ |
219
219
  | Cost ratio awareness | ✅ | ❌ | ❌ | ❌ | ❌ |
220
220
  | Plan annotation with tiers | ✅ | ❌ | ❌ | ❌ | ❌ |
221
- | Measured prompt overhead: 3,084–4,654 chars | ✅ | — | ❌ | ❌ | ❌ |
221
+ | Measured prompt overhead: 3,116–4,686 chars | ✅ | — | ❌ | ❌ | ❌ |
222
222
 
223
223
  **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.
224
224
 
@@ -371,7 +371,7 @@ For an npm install, `tiers.json` is **inside the cached package directory**, not
371
371
 
372
372
  ### Presets
373
373
 
374
- The plugin ships with six presets (switch with `/preset <name>`):
374
+ The plugin ships with seven presets (switch with `/preset <name>`):
375
375
 
376
376
  **anthropic** (default):
377
377
  | Tier | Model | Cost ratio |
@@ -418,6 +418,16 @@ The plugin ships with six presets (switch with `/preset <name>`):
418
418
  Because the model string is identical across tiers, escalating a task keeps the prompt
419
419
  cache warm. The cost ratios are estimated token-spend multipliers, not price differences.
420
420
 
421
+ **zai** — GLM through the Z.AI Coding Plan (the `zai-coding-plan` provider, which is where `glm-5.3` lives):
422
+ | Tier | Model | Variant | Cost ratio |
423
+ |------|-------|---------|-----------|
424
+ | @fast | `zai-coding-plan/glm-4.7` | — | 1x |
425
+ | @medium | `zai-coding-plan/glm-5.3` | `high` | 3x |
426
+ | @heavy | `zai-coding-plan/glm-5.3` | `max` | 6x |
427
+
428
+ @medium and @heavy share one model, so — as with `fable-effort` — the cost ratios are
429
+ estimated token-spend multipliers, not price differences.
430
+
421
431
  ### Per-tier `effort`
422
432
 
423
433
  Any tier may set `effort`: `low`, `medium`, `high`, `xhigh`, or `max`. Precedence,
@@ -983,7 +993,7 @@ After `/annotate-plan`:
983
993
 
984
994
  ## Token overhead
985
995
 
986
- Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,084 characters for a non-Claude orchestrator. A Claude orchestrator receives 3,856 characters after its authority prefix, or 4,654 characters when the 798-character DoD/enforcement section is enabled. That is roughly 770–1,295 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.
996
+ Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,116 characters for a non-Claude orchestrator. A Claude orchestrator receives 3,888 characters after its authority prefix, or 4,686 characters when the 798-character DoD/enforcement section is enabled. That is roughly 770–1,295 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.
987
997
 
988
998
  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.
989
999
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-model-router",
3
- "version": "1.10.0",
3
+ "version": "1.11.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",
@@ -9,7 +9,7 @@
9
9
  "test:watch": "vitest",
10
10
  "test:coverage": "vitest run --coverage",
11
11
  "smoke": "cross-env RUN_OC_SMOKE=1 vitest run --config vitest.smoke.config.ts test/smoke",
12
- "smoke:keyless": "cross-env RUN_OC_SMOKE_KEYLESS=1 vitest run --config vitest.smoke.config.ts test/smoke/registration.smoke.test.ts test/smoke/subagent-tiers.smoke.test.ts",
12
+ "smoke:keyless": "cross-env RUN_OC_SMOKE_KEYLESS=1 vitest run --config vitest.smoke.config.ts test/smoke/registration.smoke.test.ts test/smoke/subagent-tiers.smoke.test.ts test/smoke/deferred-catalog.smoke.test.ts",
13
13
  "typecheck": "tsc --noEmit"
14
14
  },
15
15
  "license": "GPL-3.0-only",
package/tiers.json CHANGED
@@ -203,6 +203,47 @@
203
203
  ]
204
204
  }
205
205
  },
206
+ "zai": {
207
+ "fast": {
208
+ "model": "zai-coding-plan/glm-4.7",
209
+ "costRatio": 1,
210
+ "description": "GLM-4.7 for read-only exploration, search, and simple lookups (requires the Z.AI Coding Plan; token-spend ratios are estimates, not price differences)",
211
+ "steps": 30,
212
+ "whenToUse": [
213
+ "Codebase exploration and search",
214
+ "Simple file reads and listing",
215
+ "Grep/glob operations",
216
+ "Quick lookups and research"
217
+ ]
218
+ },
219
+ "medium": {
220
+ "model": "zai-coding-plan/glm-5.3",
221
+ "variant": "high",
222
+ "costRatio": 3,
223
+ "description": "GLM-5.3 at high effort for implementation, refactoring, and tests (requires the Z.AI Coding Plan; costRatio is an estimated token-spend multiplier, not a price difference)",
224
+ "steps": 50,
225
+ "whenToUse": [
226
+ "Feature implementation",
227
+ "Refactoring",
228
+ "Writing tests",
229
+ "Code review",
230
+ "Bug fixes"
231
+ ]
232
+ },
233
+ "heavy": {
234
+ "model": "zai-coding-plan/glm-5.3",
235
+ "variant": "max",
236
+ "costRatio": 6,
237
+ "description": "GLM-5.3 at max effort for architecture, complex debugging, and security (requires the Z.AI Coding Plan; costRatio is an estimated token-spend multiplier, not a price difference)",
238
+ "steps": 120,
239
+ "whenToUse": [
240
+ "Architecture decisions",
241
+ "Complex debugging (after 2+ failures)",
242
+ "Security review",
243
+ "Performance optimization"
244
+ ]
245
+ }
246
+ },
206
247
  "hybrid": {
207
248
  "fast": {
208
249
  "model": "anthropic/claude-haiku-4-5",
@@ -387,6 +428,11 @@
387
428
  "openai",
388
429
  "anthropic",
389
430
  "github-copilot"
431
+ ],
432
+ "zai-coding-plan": [
433
+ "anthropic",
434
+ "openai",
435
+ "google"
390
436
  ]
391
437
  }
392
438
  },