opencode-model-router 1.0.1 → 1.0.3

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 (3) hide show
  1. package/README.md +2 -0
  2. package/package.json +1 -1
  3. package/src/index.ts +16 -29
package/README.md CHANGED
@@ -14,6 +14,8 @@ The plugin injects a **delegation protocol** into the system prompt that teaches
14
14
 
15
15
  The agent automatically delegates via the Task tool when it recognizes the task complexity, or when plan steps are annotated with `[tier:fast]`, `[tier:medium]`, or `[tier:heavy]` tags.
16
16
 
17
+ This applies both to plan-driven execution and direct ad-hoc requests. For every new user message, the orchestrator performs an intent gate, splits multi-task requests into atomic units, and routes each unit to `@fast`, `@medium`, or `@heavy`.
18
+
17
19
  ## Installation
18
20
 
19
21
  ### Option A: npm package (recommended)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-model-router",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
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",
package/src/index.ts CHANGED
@@ -98,43 +98,30 @@ function buildAgentOptions(tier: TierConfig): Record<string, unknown> {
98
98
  function buildDelegationProtocol(cfg: RouterConfig): string {
99
99
  const tiers = getActiveTiers(cfg);
100
100
 
101
- const tierRows = Object.entries(tiers)
101
+ const tierSummary = Object.entries(tiers)
102
102
  .map(([name, t]) => {
103
103
  const shortModel = t.model.split("/").pop() ?? t.model;
104
- const thinkingInfo = t.variant ? ` (${t.variant})` : "";
105
- return `| @${name} | \`${shortModel}\`${thinkingInfo} | ${t.description} |`;
104
+ const variant = t.variant ? ` (${t.variant})` : "";
105
+ return `@${name}=${shortModel}${variant}`;
106
106
  })
107
- .join("\n");
108
-
109
- const whenToUse = Object.entries(tiers)
110
- .map(([name, t]) => `- **@${name}**: ${t.whenToUse.join(", ")}`)
111
- .join("\n");
112
-
113
- const rules = cfg.rules.map((r, i) => `${i + 1}. ${r}`).join("\n");
107
+ .join(" | ");
114
108
 
115
109
  return [
116
110
  "## Model Delegation Protocol",
111
+ `Preset: ${cfg.activePreset}. Tiers: ${tierSummary}.`,
117
112
  "",
118
- `Active preset: **${cfg.activePreset}** (switch with \`/preset <name>\`)`,
119
- `Available presets: ${Object.keys(cfg.presets).join(", ")}`,
120
- "",
121
- "| Agent | Model | Purpose |",
122
- "|-------|-------|---------|",
123
- tierRows,
124
- "",
125
- "### When to use each tier:",
126
- whenToUse,
127
- "",
128
- "### Rules:",
129
- rules,
130
- "",
131
- "### How to delegate:",
132
- "Use the Task tool with the tier name as `subagent_type`:",
133
- '- `Task(subagent_type="fast", prompt="Find all files importing AuthContext")`',
134
- '- `Task(subagent_type="medium", prompt="Implement the UserService class per the spec")`',
135
- '- `Task(subagent_type="heavy", prompt="Review this auth flow for security vulnerabilities")`',
113
+ "Apply to every user message (plan and ad-hoc):",
114
+ "1. Split multi-part requests into atomic tasks.",
115
+ "2. Respect explicit tier instructions and [tier:fast|medium|heavy] tags.",
116
+ "3. Route read-only search/exploration tasks to @fast.",
117
+ "4. Route implementation/edit/refactor/test/bugfix tasks to @medium.",
118
+ "5. Route architecture/security/performance/complex debugging to @heavy.",
119
+ "6. For mixed requests, delegate each subtask to the matching tier, then synthesize one final response.",
120
+ "7. For trivial single read/grep tasks, execute directly.",
121
+ `8. If uncertain, default to @${cfg.defaultTier}.`,
136
122
  "",
137
- `Default tier when unspecified: **@${cfg.defaultTier}**`,
123
+ "Delegate with Task(subagent_type=\"fast|medium|heavy\", prompt=\"...\").",
124
+ "Keep orchestration and final synthesis in the primary agent.",
138
125
  ].join("\n");
139
126
  }
140
127