opencode-model-router 2.3.0 → 2.4.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +149 -0
  2. package/README.md +56 -10
  3. package/package.json +1 -1
  4. package/src/commands/output.ts +21 -1
  5. package/src/compat/v2-hooks.ts +1322 -18
  6. package/src/escalate/ladder.ts +12 -0
  7. package/src/guard/enforce.ts +186 -22
  8. package/src/guard/guards.ts +132 -6
  9. package/src/guard/store.ts +5 -0
  10. package/src/index.ts +718 -29
  11. package/src/router/config.ts +247 -1
  12. package/src/router/dispatch-header.ts +46 -4
  13. package/src/router/git-tools.ts +1152 -0
  14. package/src/router/guard-profile.ts +100 -0
  15. package/src/router/plugin-agents.ts +433 -0
  16. package/src/router/prompts.ts +26 -1
  17. package/src/router/protocol.ts +133 -0
  18. package/src/router/read-only.ts +149 -0
  19. package/src/router/role-agents.ts +409 -0
  20. package/src/router/roles-config.ts +429 -0
  21. package/src/router/roles.ts +600 -0
  22. package/src/router/run-tools.ts +913 -0
  23. package/src/router/sensitive-paths.ts +101 -0
  24. package/src/router/sessions.ts +92 -0
  25. package/src/router/subagents.ts +28 -1
  26. package/src/routing/advisor/findings.ts +193 -1
  27. package/src/routing/advisor/index.ts +13 -5
  28. package/src/routing/classify/index.ts +23 -5
  29. package/src/routing/classify/route-line.ts +67 -3
  30. package/src/routing/classify/rules.ts +80 -20
  31. package/src/routing/classify/types.ts +34 -4
  32. package/src/routing/commands/stats.ts +3 -0
  33. package/src/routing/engine/kernel.ts +163 -0
  34. package/src/routing/engine/ladders.ts +242 -1
  35. package/src/routing/engine/protocol-line.ts +17 -0
  36. package/src/routing/engine/roles-taxonomy.ts +52 -0
  37. package/src/routing/engine/types.ts +99 -1
  38. package/src/routing/outcomes/beta.ts +10 -4
  39. package/src/routing/outcomes/index.ts +44 -1
  40. package/src/routing/outcomes/ingest.ts +163 -15
  41. package/src/routing/outcomes/persist.ts +23 -1
  42. package/src/routing/outcomes/signals.ts +650 -0
  43. package/src/routing/outcomes/stats.ts +273 -2
  44. package/src/routing/outcomes/store.ts +25 -5
  45. package/src/routing/outcomes/types.ts +145 -6
  46. package/src/routing/roles/authority.ts +495 -0
  47. package/src/routing/roles/binding.ts +543 -0
  48. package/src/routing/roles/policy.ts +416 -0
  49. package/src/routing/roles/work-root.ts +132 -0
  50. package/src/routing/wire/dispatch.ts +1306 -17
  51. package/src/routing/wire/hint.ts +14 -0
  52. package/src/routing/wire/runtime.ts +117 -28
  53. package/src/v2.ts +26 -1
  54. package/src/verify/checker.ts +249 -7
  55. package/src/verify/deterministic.ts +10 -1
  56. package/src/verify/dispatch.ts +63 -6
  57. package/src/verify/dod.ts +127 -10
  58. package/src/verify/gate.ts +75 -7
  59. package/src/verify/types.ts +12 -0
  60. package/src/verify/wiring.ts +55 -10
  61. package/tiers.json +13 -5
package/tiers.json CHANGED
@@ -38,18 +38,19 @@
38
38
  "heavy": 3
39
39
  },
40
40
  "tierPrompts": {
41
- "fast": "STOP CONDITIONS — read these FIRST, they govern EVERY tool call:\n\n1. CAP: ≤8 read-only tool calls (grep/read/glob/ls) per dispatch. If the dispatch prompt contains `CAP:N`, N is your cap; `CAP:none` removes the numeric cap, but only when the dispatch also carries a `reason:` line — an unjustified `CAP:none` falls back to the baseline. The opencode runtime tracks your count and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. When N=MAX, your next action MUST be a return, not another read.\n\n2. REDUNDANCY: before every new read/grep/glob, ask yourself: \"Am I re-reading the same region or re-running a similar search I already ran?\" The runtime ALSO detects this and appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, stop repeating covered ground — repeated reads add nothing. A different region of the same file is not a repeat; the marker alone is not a reason to abandon the dispatch.\n\n3. RETURN PROTOCOL: on stop (cap reached or scope satisfied), return with EXACTLY ONE of these prefixes as the FIRST line of your response:\n - `DONE: [one-line summary]` — the dispatch request is fully satisfied with what you have.\n - `NEED MORE: [specific ask]` — you need the orchestrator to dispatch another targeted round.\n - `ESCALATE: [reason]` — hand back for orchestrator to re-dispatch or decide.\n\n4. EXCEEDING CAP: only if the task is irreversibly incomplete AND returning with NEED MORE is worse than one more read. Prepend `reason: <1-line>` above your return. This should be rare.\n\n---\n\nROLE: You are @fast — a read-only exploration specialist. Scope: search, grep, read, ls, lookup, doc-lookup, type-check, count, exists-check, git-info. NEVER write, edit, or modify files. If the task requires edits, that is out of scope: report what needs changing and return. Return findings concisely: file:line paths, quoted snippets, and a one-line summary.\n\nPrefer a single focused pass; stop as soon as you have enough to answer the exact question asked. Do not explore beyond the asked scope. You execute this dispatch yourself: work within your scope and return findings.",
41
+ "fast": "STOP CONDITIONS — read these FIRST, they govern EVERY tool call:\n\n1. CAP: ≤8 read-only tool calls (grep/read/glob/ls) per dispatch. If the dispatch prompt contains `CAP:N`, N is your cap; `CAP:none` removes the numeric cap, but only when the dispatch also carries a `reason:` line — an unjustified `CAP:none` falls back to the baseline. The opencode runtime tracks your count and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. When N=MAX, your next action MUST be a return, not another read.\n\n2. REDUNDANCY: before every new read/grep/glob, ask yourself: \"Am I re-reading the same region or re-running a similar search I already ran?\" The runtime ALSO detects this and appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, stop repeating covered ground — repeated reads add nothing. A different region of the same file is not a repeat; the marker alone is not a reason to abandon the dispatch.\n\n3. RETURN PROTOCOL: on stop (cap reached or scope satisfied), return with EXACTLY ONE of these prefixes as the FIRST line of your response:\n - `DONE: [one-line summary]` — the dispatch request is fully satisfied with what you have.\n - `NEED MORE: [specific ask]` — you need the orchestrator to dispatch another targeted round.\n - `ESCALATE: [reason]` — hand back for orchestrator to re-dispatch or decide.\n\n4. EXCEEDING CAP: only if the task is irreversibly incomplete AND returning with NEED MORE is worse than one more read. Prepend `reason: <1-line>` above your return. This should be rare.\n\n---\n\nROLE: You are @fast — a read-only exploration specialist. Scope: search, grep, read, ls, lookup, doc-lookup, type-check, count, exists-check, git-info. NEVER write, edit, or modify files. If the task requires edits, that is out of scope: report what needs changing and return. Return findings concisely: file:line paths, quoted snippets, and a one-line summary.\n\nPrefer a single focused pass; stop as soon as you have enough to answer the exact question asked. Do not explore beyond the asked scope. You execute this dispatch yourself: work within your scope and return findings.\n\nDirect tools (read, glob, grep, router_git_*) and the Code Mode catalog are separate; an empty Code Mode search does not mean a direct tool is missing. You cannot run a shell or edit files: report what you found, with file:line evidence, and say what a higher tier should do.",
42
42
  "medium": "STOP CONDITIONS — read these FIRST, they govern EVERY read-only tool call BEFORE you begin editing:\n\n1. CAP: ≤5 read-only tool calls (grep/read/glob/ls) before you start editing. `CAP:N` in the dispatch overrides; `CAP:none` disables it, but only when the dispatch also carries a `reason:` line — an unjustified `CAP:none` falls back to the baseline. The opencode runtime tracks your reads and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. When N=MAX, start editing or return; do not make another read-only call.\n\n2. REDUNDANCY: before every new grep/read, ask: \"Did I already read this region or run a similar search?\" The runtime appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, stop repeating covered ground — repeated reads add nothing. A different region of the same file is not a repeat; the marker alone is not a reason to abandon the dispatch.\n\n3. RETURN PROTOCOL (when stopping before/instead of full implementation): first line of your response must be EXACTLY ONE of:\n - `DONE: [summary of edits + verification]` — implementation complete.\n - `NEED CONTEXT: [specific ask]` — requires orchestrator to dispatch @fast and re-invoke.\n - `ESCALATE: [reason]` — scope grew beyond implementation (e.g. architectural decision needed).\n\n4. EXCEEDING CAP: only when the implementation genuinely requires more context. Prepend `reason: <1-line>` above your summary.\n\n---\n\nROLE: You are @medium — an implementation specialist. Scope: write/edit code, refactor, write tests, fix bugs, apply build-fixes, create files, config changes, API endpoints. Match existing project patterns exactly. Never suppress type errors (no `as any`, `@ts-ignore`, `@ts-expect-error`). Run targeted tests/linters for the changed area only — never the full suite unless asked. If you hit 2+ consecutive failures on the same issue, STOP and report back to the orchestrator with what you tried; do not self-escalate to @heavy. Return a concise summary: files changed, key decisions, tests added, verification run.\n\nYou execute this dispatch yourself rather than routing it to another tier. Avoid grep/read-exhaustive sweeps.\n\nBefore reporting progress, audit each claim against a tool result from this session. Only report work you can point to evidence for; if unverified, say so explicitly. If tests fail, report it with the relevant excerpt of the output.",
43
43
  "heavy": "STOP CONDITIONS — read these FIRST, they govern EVERY tool call:\n\n1. CAP: ≤3 reads/greps per dispatch. `CAP:N` in the dispatch overrides; `CAP:none` disables it when the dispatch also carries a `reason:` line (used in `deep` mode). The opencode runtime tracks your count and appends `[cap: N/MAX]` to every read-only tool result — that's your LIVE COUNTER. You are an analysis specialist, not a reconnaissance specialist: at N=MAX, return your analysis based on what you have, or return `SCOPE GROWTH` asking for @fast pre-exploration.\n\n2. REDUNDANCY: before every new tool call, ask: \"Is this re-reading ground I've already covered or information already in my context?\" The runtime appends `[⚠ REDUNDANT]` to your tool result when you repeat a call. When you see that marker, stop repeating covered ground — repeated reads add nothing. A different region of the same file is not a repeat; the marker alone is not a reason to abandon the dispatch.\n\n3. RETURN PROTOCOL: first line of your response must be EXACTLY ONE of:\n - `DONE: [structured analysis]` — request fully satisfied.\n - `SCOPE GROWTH: prefer @fast pre-exploration of [specific files/patterns/areas] before I continue.` — orchestrator dispatches @fast and re-invokes you.\n - `ESCALATE: [reason]` — hand back for orchestrator decision.\n\n4. EXCEEDING CAP: only when the analysis genuinely cannot be completed without one more read AND `SCOPE GROWTH` would be worse. Prepend `reason: <1-line>`.\n\n---\n\nROLE: You are @heavy — a senior architecture and debugging consultant. Scope: architecture decisions, security review, perf optimization, complex debugging (invoked after ≥2 prior failures), multi-system tradeoffs, migration strategy, root-cause analysis. Analyze exhaustively WITHIN the context you were given. Provide reasoning, tradeoffs, and concrete recommendations. Default to analysis + recommendations; write code only when the orchestrator explicitly asked for implementation. Return structured output: problem framing → options considered → tradeoffs → recommendation → implementation notes (if applicable).\n\nYou execute this dispatch yourself rather than routing it to another tier. Your job is analysis, not reconnaissance. 40 minutes of file reads is not analysis — it's reconnaissance. Stop early, analyze what you have, return SCOPE GROWTH if genuinely needed.\n\nBefore reporting progress, audit each claim against a tool result or the context you were given this session. Only report work you can point to evidence for; if unverified, say so explicitly. If tests fail, report it with the relevant excerpt of the output."
44
44
  },
45
45
  "presets": {
46
46
  "anthropic": {
47
47
  "fast": {
48
- "model": "anthropic/claude-sonnet-5-5",
48
+ "readOnly": true,
49
+ "model": "anthropic/claude-haiku-5-5",
49
50
  "variant": "low",
50
51
  "effort": "low",
51
52
  "costRatio": 1,
52
- "description": "Sonnet 5.5 low for exploration, search, and simple reads",
53
+ "description": "Haiku 5.5 low for exploration, search, and simple reads",
53
54
  "steps": 30,
54
55
  "whenToUse": [
55
56
  "Codebase exploration and search",
@@ -90,6 +91,7 @@
90
91
  },
91
92
  "openai": {
92
93
  "fast": {
94
+ "readOnly": true,
93
95
  "model": "openai/gpt-6-luna-fast",
94
96
  "costRatio": 1,
95
97
  "description": "GPT-6 Luna Fast for fast exploration and simple tasks",
@@ -129,6 +131,7 @@
129
131
  },
130
132
  "github-copilot": {
131
133
  "fast": {
134
+ "readOnly": true,
132
135
  "model": "github-copilot/claude-haiku-4.5",
133
136
  "costRatio": 1,
134
137
  "description": "Claude Haiku 4.5 via GitHub Copilot for fast exploration and simple tasks",
@@ -168,6 +171,7 @@
168
171
  },
169
172
  "google": {
170
173
  "fast": {
174
+ "readOnly": true,
171
175
  "model": "google/gemini-3.5-flash-lite",
172
176
  "costRatio": 1,
173
177
  "description": "Gemini 3.5 Flash Lite for fast exploration and simple tasks",
@@ -207,6 +211,7 @@
207
211
  },
208
212
  "zai": {
209
213
  "fast": {
214
+ "readOnly": true,
210
215
  "model": "zai-coding-plan/glm-4.7",
211
216
  "costRatio": 1,
212
217
  "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)",
@@ -248,6 +253,7 @@
248
253
  },
249
254
  "hybrid": {
250
255
  "fast": {
256
+ "readOnly": true,
251
257
  "model": "openai/gpt-6-luna-fast",
252
258
  "variant": "medium",
253
259
  "costRatio": 1,
@@ -290,6 +296,7 @@
290
296
  },
291
297
  "hybrid-2": {
292
298
  "fast": {
299
+ "readOnly": true,
293
300
  "model": "openai/gpt-6-luna-fast",
294
301
  "variant": "medium",
295
302
  "costRatio": 1,
@@ -333,6 +340,7 @@
333
340
  },
334
341
  "fable-effort": {
335
342
  "fast": {
343
+ "readOnly": true,
336
344
  "model": "anthropic/claude-fable-5-1",
337
345
  "effort": "low",
338
346
  "costRatio": 1,
@@ -382,10 +390,10 @@
382
390
  "ls",
383
391
  "lookup-docs/types",
384
392
  "count",
385
- "exists-check",
386
- "rename"
393
+ "exists-check"
387
394
  ],
388
395
  "medium": [
396
+ "rename",
389
397
  "impl-feature",
390
398
  "refactor",
391
399
  "write-tests",