opencode-resolve 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -1,17 +1,44 @@
1
- # opencode-resolve
1
+ # opencode-resolve — Lightweight Resolver Plugin for OpenCode
2
+
3
+ **[English](./README.md) | [한국어](./README.ko.md)**
2
4
 
3
5
  [![npm version](https://img.shields.io/npm/v/opencode-resolve.svg)](https://www.npmjs.com/package/opencode-resolve)
6
+ [![CI](https://github.com/jshsakura/opencode-resolve/actions/workflows/publish.yml/badge.svg)](https://github.com/jshsakura/opencode-resolve/actions/workflows/publish.yml)
4
7
  [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
5
8
 
6
- Small OpenCode plugin that turns a single instruction into a finished, verified change.
9
+ > **opencode-resolve** is a **lightweight resolver plugin for [OpenCode](https://opencode.ai)**. It lives _inside_ your OpenCode session and turns a single instruction into a finished, verified change — that is what _resolving_ means here.
10
+ >
11
+ > It is **not** a standalone application, not a model provider, not a separate CLI you run daily, and not a replacement for your `opencode.json` configuration. It is an OpenCode plugin and nothing more.
12
+
13
+ It exposes a **fixed-role verified resolve loop** — **resolver** (context-efficient planner/judge) and **coder** (focused implementer) — running with auto-approved permissions so a task drives to completion without prompting at every step. The resolver inspects only relevant files, plans the smallest patch, dispatches coder with exact instructions, verifies, and iterates through verified checkpoints. Each checkpoint is retried up to 3 times on failure, then the resolver moves forward. Internal specialist subagents (**explorer**, **reviewer**, **deep-reviewer**) are injected by default as OpenCode-native subagents — available when the resolver judges them justified — but they are not part of the core path and are never user-facing primary roles. It defines roles, not model providers: agents inherit your OpenCode default model unless you pin them.
7
14
 
8
- `opencode-resolve` ships three roles by default — **resolver** (orchestrator), **coder** (implementer), and **reviewer** (read-only auditor) — and runs them with auto-approved permissions so a task drives to completion without prompting at every step. It defines roles, not model providers: agents inherit your OpenCode default model unless you pin them.
15
+ ```
16
+ # Paste this into any AI coding assistant for fully guided setup
17
+ Install and configure opencode-resolve by following the instructions here:
18
+ https://github.com/jshsakura/opencode-resolve#drop-in-setup-give-to-an-llm
19
+ ```
20
+
21
+ ---
22
+
23
+ ## What this is — and isn't
24
+
25
+ | ✅ What it is | ❌ What it isn't |
26
+ |---|---|
27
+ | A **lightweight resolver plugin for OpenCode** installed via `opencode plugin opencode-resolve` | A standalone app or separate CLI |
28
+ | A fixed-role verified loop (resolver + coder) injected into OpenCode | A model provider or API key manager |
29
+ | A Context7 MCP auto-registration hook | A replacement for your `opencode.json` config |
30
+ | A config file (`resolve.json`) that lives alongside OpenCode config | Something you invoke manually every time you code |
31
+ | Installed once, then runs automatically inside OpenCode | An alternative to OpenCode itself |
32
+
33
+ If OpenCode is not installed or not running, opencode-resolve does nothing.
9
34
 
10
35
  ---
11
36
 
12
37
  ## Table of Contents
13
38
 
14
- - [Roles at a glance](#roles-at-a-glance)
39
+ - [Features](#features)
40
+ - [AI-Powered Setup](#ai-powered-setup)
41
+ - [Prerequisites](#prerequisites)
15
42
  - [Quick Start](#quick-start)
16
43
  - [Drop-in setup (give to an LLM)](#drop-in-setup-give-to-an-llm)
17
44
  - [Default Behavior](#default-behavior)
@@ -23,39 +50,115 @@ Small OpenCode plugin that turns a single instruction into a finished, verified
23
50
  - [Model Setup](#model-setup)
24
51
  - [Agent Reference](#agent-reference)
25
52
  - [Optional Commands](#optional-commands)
53
+ - [Context7 Integration](#context7-integration)
54
+ - [Keeping Up to Date](#keeping-up-to-date)
26
55
  - [Local Development](#local-development)
27
56
  - [Verification](#verification)
28
57
  - [Release](#release)
29
58
  - [Design Rules](#design-rules)
59
+ - [License](#license)
30
60
 
31
61
  ---
32
62
 
33
- ## Roles at a glance
63
+ ## Features
64
+
65
+ - **Fixed-role verified resolve loop** — `resolver` (context-efficient planner/judge) + `coder` (focused implementer)
66
+ - **Context-efficient by default** — minimal file reads, smallest patch, targeted verification, checkpointed execution with max 3 retries per failing checkpoint
67
+ - **OpenCode-native internal specialist subagents** — `reviewer` (verification-gap audit), `explorer` (codebase scout), `deep-reviewer` (risky/security review) — injected as subagents by default but not part of the core path; resolver dispatches them only when justified
68
+ - **Auto-approved permissions** — coder and resolver work without per-action prompts
69
+ - **Context7 MCP** — auto-registers [Context7](https://context7.com) documentation lookup when `context7: true`
70
+ - **Model pinning** — pin different models per role when you have measured a benefit; by default all roles inherit your OpenCode default model
71
+ - **Soft parallel cap** — `maxParallelSubagents` controls how many coders the resolver fans out
72
+ - **Strict validation** — unknown keys, typos, invalid modes, and wrong types all fail fast at load time
73
+ - **Additive migration** — upgrades never overwrite your existing config
74
+ - **Zero dependencies beyond `@opencode-ai/plugin`** — nothing extra to install
75
+
76
+ ---
77
+
78
+ ## AI-Powered Setup
79
+
80
+ > **One line. Any AI coding assistant. Everything configured automatically.**
81
+
82
+ Paste this into Claude Code, Cursor, Codex, OpenCode, Windsurf, VS Code Copilot, or Gemini CLI:
83
+
84
+ ```
85
+ Install and configure opencode-resolve by following the instructions here:
86
+ https://github.com/jshsakura/opencode-resolve#drop-in-setup-give-to-an-llm
87
+ ```
88
+
89
+ Your AI will:
90
+
91
+ 1. Install the plugin via `opencode plugin opencode-resolve --global --force`
92
+ 2. Merge `opencode-resolve` into your `opencode.json` plugin array
93
+ 3. Create `resolve.json` with a working configuration
94
+ 4. Tell you to restart OpenCode
34
95
 
35
- | Role | Default | Can edit? | Can run shell? | Purpose |
36
- |---|:---:|:---:|:---:|---|
37
- | `resolver` | Yes | Yes (auto) | Yes (auto) | Primary orchestrator. Plans, dispatches `coder` (one at a time), verifies, iterates. |
38
- | `coder` | Yes | Yes (auto) | Yes (auto) | Focused implementer. Makes the smallest correct change and verifies. |
39
- | `reviewer` | Yes | **Never** | **Never** | Read-only auditor. Inspects only — recommends fixes for `coder` or `resolver` to apply. |
96
+ No manual config editing required. Works on macOS, Linux, and Windows.
40
97
 
41
- Hard rule: **the reviewer cannot modify the project by any means.** Both `edit` and `bash` are denied for the reviewer regardless of `autoApprove`. Any required fix is routed back through `coder` or `resolver`.
98
+ > For manual setup, see [Prerequisites](#prerequisites) and [Quick Start](#quick-start) below.
99
+
100
+ ---
101
+
102
+ ## Prerequisites
103
+
104
+ ### 1. OpenCode
105
+
106
+ opencode-resolve is an OpenCode plugin. You need [OpenCode](https://opencode.ai) installed and running.
107
+
108
+ Verify:
109
+
110
+ ```sh
111
+ opencode --version
112
+ ```
113
+
114
+ ### 2. Node.js ≥ 20
115
+
116
+ The plugin and OpenCode itself require Node.js 20 or later.
117
+
118
+ Verify:
119
+
120
+ ```sh
121
+ node --version # should be v20.x or later
122
+ ```
123
+
124
+ ### 3. A configured model provider
125
+
126
+ OpenCode needs at least one model provider configured in `~/.config/opencode/opencode.json` with a valid API key. opencode-resolve agents inherit your default model unless you pin them.
127
+
128
+ Example minimal provider setup:
129
+
130
+ ```json
131
+ {
132
+ "model": "openai/gpt-4o",
133
+ "provider": {
134
+ "openai": {
135
+ "name": "OpenAI"
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ > No additional API keys or MCP servers are required. Context7 is auto-registered by the plugin.
42
142
 
43
143
  ---
44
144
 
45
145
  ## Quick Start
46
146
 
47
- Install from npm:
147
+ ### Install from npm
48
148
 
49
149
  ```sh
50
150
  npm install -g opencode-resolve
51
151
  ```
52
152
 
53
- The package `postinstall` step:
153
+ The `postinstall` script automatically:
54
154
 
55
- 1. Adds `opencode-resolve` to `~/.config/opencode/opencode.json` `plugin` array.
56
- 2. Creates `~/.config/opencode/resolve.json` from [`opencode-resolve.example.json`](./opencode-resolve.example.json) when missing.
155
+ 1. Adds `opencode-resolve` to `~/.config/opencode/opencode.json` `plugin` array (if not already present).
156
+ 2. Creates `~/.config/opencode/resolve.json` adapted to your current model provider when the file does not exist:
157
+ - **GLM/ZAI model detected** → mixed GLM + GPT alias preset (`coder` → GLM, `resolver` → GPT).
158
+ - **OpenAI/GPT model detected** → single-provider GPT preset using your current model for all roles.
159
+ - **Other or no model** → model-neutral `models: {}` (all roles inherit OpenCode default).
57
160
 
58
- Restart OpenCode after installation.
161
+ Existing `resolve.json` files are **never overwritten** — the adaptive preset only applies to first-time creation. To regenerate, delete `resolve.json` and reinstall.
59
162
 
60
163
  To skip automatic registration:
61
164
 
@@ -63,7 +166,17 @@ To skip automatic registration:
63
166
  OPENCODE_RESOLVE_SKIP_POSTINSTALL=1 npm install -g opencode-resolve
64
167
  ```
65
168
 
66
- Manual fallback: add the plugin to `~/.config/opencode/opencode.json` yourself:
169
+ ### Refresh the plugin cache
170
+
171
+ > **Important — OpenCode caches plugins itself.** OpenCode does NOT use globally-installed npm packages directly. It maintains its own cache at `~/.cache/opencode/packages/`. After the very first install (or any future upgrade), refresh the cache:
172
+
173
+ ```sh
174
+ opencode plugin opencode-resolve --global --force
175
+ ```
176
+
177
+ ### Manual fallback
178
+
179
+ If `postinstall` didn't register the plugin, add it to `~/.config/opencode/opencode.json` yourself:
67
180
 
68
181
  ```json
69
182
  {
@@ -71,81 +184,209 @@ Manual fallback: add the plugin to `~/.config/opencode/opencode.json` yourself:
71
184
  }
72
185
  ```
73
186
 
187
+ ### Restart OpenCode
188
+
189
+ ```sh
190
+ opencode
191
+ ```
192
+
193
+ You should now see `resolver` and `coder` agents available.
194
+
74
195
  ---
75
196
 
76
197
  ## Drop-in setup (give to an LLM)
77
198
 
78
- Hand the block below to any reasonably capable LLM along with the instruction _"set up opencode-resolve on this machine"_ and it can finish the install end-to-end. Everything below is the entire required configuration no other MCP servers, environment variables, or files are needed.
199
+ Hand the block below to any reasonably capable LLM along with the instruction _"set up opencode-resolve on this machine"_ and it will finish the install end-to-end. The LLM **must run this interactively**it discovers what providers and models are already configured, then asks the user which to pin per role. No guessing, no invented model IDs.
79
200
 
80
- > **Important OpenCode caches plugins itself.** OpenCode does NOT use globally-installed npm packages. It maintains its own cache at `~/.cache/opencode/packages/`. After the very first install (or any future upgrade), refresh the cache with `opencode plugin opencode-resolve --global --force` and restart OpenCode. `npm install -g` alone is not enough.
201
+ > **For LLMs reading this:** treat every "Ask the user" prompt below as a real question wait for the user's answer before continuing. Never proceed with a default if the user hasn't responded. Never invent model IDs that aren't in the user's `opencode.json` (or in their declared `provider.*` registry).
81
202
 
82
- **Step 1 — install via OpenCode (also primes the cache):**
203
+ ### Step 1 — Install and prime the cache
83
204
 
84
205
  ```sh
85
206
  opencode plugin opencode-resolve --global --force
86
207
  ```
87
208
 
88
- **Step 2 `~/.config/opencode/opencode.json`** (merge into the existing file; do not replace it):
209
+ This downloads the plugin, installs it into OpenCode's package cache (`~/.cache/opencode/packages/`), and makes it available.
210
+
211
+ ### Step 2 — Register the plugin in `~/.config/opencode/opencode.json`
212
+
213
+ Add the string `"opencode-resolve"` to the `plugin` array. **Do not use the inline tuple form here** — keep the entry as a bare string so all role/model config lives in `resolve.json` (Step 3). This avoids split-brain configuration.
89
214
 
90
215
  ```json
91
216
  {
92
217
  "$schema": "https://opencode.ai/config.json",
93
- "model": "<your-default-model-id>",
218
+ "model": "<user-default-model-id>",
94
219
  "plugin": ["opencode-resolve"]
95
220
  }
96
221
  ```
97
222
 
98
- **Step 3 `~/.config/opencode/resolve.json`** (auto-created by `postinstall`; the block below is the recommended canonical setup copy it verbatim then edit `models` to match your provider):
223
+ > If the user already has other plugins, append `"opencode-resolve"` to the existing array. **Never overwrite** their existing config.
224
+
225
+ ### Step 3 — Pick models interactively, then write `~/.config/opencode/resolve.json`
226
+
227
+ The LLM **drives a short Q&A** here. Goal: end with `resolve.json` containing model IDs the user explicitly chose from their own configuration.
228
+
229
+ #### 3a. Discover the user's installed providers and models
230
+
231
+ Read `~/.config/opencode/opencode.json` and build a candidate map:
232
+
233
+ | Source | What to collect |
234
+ |---|---|
235
+ | `provider.*` keys | Each configured provider (e.g. `zai`, `openai`, `anthropic`). |
236
+ | `provider.<key>.models.*` keys | The model keys the user has declared under that provider. |
237
+ | Top-level `model` | If the prefix before `/` is not already in `provider.*`, add it as an implicit candidate (e.g. `zai-coding-plan` from `zai-coding-plan/glm-5.1`). |
238
+ | `agent.*.model` | Any per-agent overrides — add their provider/model pairs as candidates. |
239
+
240
+ If the user has **no providers configured at all**, stop and tell them to add at least one provider with a valid API key to `opencode.json` first — opencode-resolve cannot pick a model that does not exist.
241
+
242
+ #### 3b. Ask the user: which provider?
243
+
244
+ Print the candidate list and ask. Example wording the LLM should use:
245
+
246
+ > _I found these providers in your OpenCode config. Which one should opencode-resolve roles use?_
247
+ >
248
+ > 1. `zai-coding-plan` — models: `glm-5.1`, `glm-4.7-flash`
249
+ > 2. `openai` — models: `gpt-4o`, `gpt-4o-mini`, `o1`, `o1-mini`, `o3-mini`, `gpt-5.5`
250
+ > 3. _Other (provide an explicit `provider/model` ID)_
251
+
252
+ If exactly one provider candidate exists, skip the question and use it.
253
+
254
+ #### 3c. Ask the user: single-tier or split?
255
+
256
+ > _Do you want a single model for every role, or split — a fast model for `coder`/`explorer` and a stronger model for `resolver`/`reviewer`/`deep-reviewer`?_
257
+ >
258
+ > A. Single model for all roles (simplest, recommended for one-provider setups)
259
+ > B. Split — fast + strong (recommended when you have both a cheap and a strong model)
260
+
261
+ #### 3d. Ask the user: which model(s)?
262
+
263
+ Show only the models under the provider picked in 3b.
264
+
265
+ - For **single-tier (A)** — ask one question:
266
+ > _Which model should every role use?_ → list models from the chosen provider.
267
+ - For **split (B)** — ask two questions, in order:
268
+ > _Pick the **fast** model for `coder` and `explorer`:_ → list models.
269
+ >
270
+ > _Pick the **strong** model for `resolver`, `reviewer`, `deep-reviewer`:_ → list models.
271
+
272
+ Confirm each pick back to the user before writing the file. Example:
273
+
274
+ > _I'll pin `coder` and `explorer` to `zai-coding-plan/glm-5.1`, and `resolver`/`reviewer`/`deep-reviewer` to `openai/gpt-5.5`. Proceed?_
275
+
276
+ #### 3e. Write `~/.config/opencode/resolve.json`
277
+
278
+ If the user picked **A (single-tier)**, write:
99
279
 
100
280
  ```json
101
281
  {
102
- "enabled": ["coder", "reviewer", "resolver"],
282
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
103
283
  "preserveNative": true,
104
284
  "context7": true,
105
285
  "commands": false,
286
+ "models": {
287
+ "primary": "<chosen-provider>/<chosen-model>",
288
+ "coder": "primary",
289
+ "explorer": "primary",
290
+ "resolver": "primary",
291
+ "reviewer": "primary",
292
+ "deep-reviewer": "primary"
293
+ },
294
+ "agents": {
295
+ "coder": { "enabled": true, "mode": "all" },
296
+ "resolver": { "enabled": true },
297
+ "explorer": { "enabled": true, "mode": "subagent" },
298
+ "reviewer": { "enabled": true, "mode": "subagent" },
299
+ "deep-reviewer": { "enabled": true, "mode": "subagent" },
300
+ "architect": { "enabled": false },
301
+ "gpt-coder": { "enabled": false },
302
+ "debugger": { "enabled": false },
303
+ "researcher": { "enabled": false }
304
+ },
106
305
  "autoApprove": true,
107
- "maxParallelSubagents": 2,
306
+ "maxParallelSubagents": 2
307
+ }
308
+ ```
309
+
310
+ If the user picked **B (split)**, write:
311
+
312
+ ```json
313
+ {
314
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
315
+ "preserveNative": true,
316
+ "context7": true,
317
+ "commands": false,
108
318
  "models": {
109
- "glm": "zai-coding-plan/glm-5",
110
- "gpt": "openai/gpt-5.5",
111
- "coder": "glm",
112
- "reviewer": "openai/gpt-4o-mini",
113
- "resolver": "gpt"
319
+ "fast": "<provider>/<fast-model>",
320
+ "strong": "<provider>/<strong-model>",
321
+ "coder": "fast",
322
+ "explorer": "fast",
323
+ "resolver": "strong",
324
+ "reviewer": "strong",
325
+ "deep-reviewer": "strong"
114
326
  },
115
327
  "agents": {
116
- "coder": { "mode": "all" },
117
- "reviewer": { "mode": "all" },
118
- "resolver": { "enabled": true },
119
- "architect": { "enabled": false },
120
- "gpt-coder": { "enabled": false },
121
- "debugger": { "enabled": false },
122
- "researcher": { "enabled": false }
123
- }
328
+ "coder": { "enabled": true, "mode": "all" },
329
+ "resolver": { "enabled": true },
330
+ "explorer": { "enabled": true, "mode": "subagent" },
331
+ "reviewer": { "enabled": true, "mode": "subagent" },
332
+ "deep-reviewer": { "enabled": true, "mode": "subagent" },
333
+ "architect": { "enabled": false },
334
+ "gpt-coder": { "enabled": false },
335
+ "debugger": { "enabled": false },
336
+ "researcher": { "enabled": false }
337
+ },
338
+ "autoApprove": true,
339
+ "maxParallelSubagents": 2
124
340
  }
125
341
  ```
126
342
 
127
- **Step 4restart OpenCode.**
343
+ Replace every `<provider>/<model>` placeholder with the **exact** ID strings the user picked in 3b/3d no inventing, no autocompletion, no version drift. If you cannot map the picked model to a `provider/model` string, ask the user to clarify rather than guessing.
344
+
345
+ > Each enabled agent carries an explicit `enabled: true` so the file is self-documenting. The `enabled` array remains authoritative; the per-agent flag just removes ambiguity for humans reading the file.
346
+
347
+ > If `resolve.json` already exists, **do not overwrite it silently**. Show the user the existing content first, summarize what would change, and ask whether to overwrite, merge, or abort.
348
+
349
+ ### Step 4 — Restart OpenCode and verify
350
+
351
+ Close and reopen OpenCode, then confirm the install worked:
352
+
353
+ ```sh
354
+ opencode run "list available agents"
355
+ ```
356
+
357
+ The output **must** include `resolver` and `coder` (and `reviewer` if enabled). Two failure modes to check explicitly:
358
+
359
+ | Symptom | Cause | Fix |
360
+ |---|---|---|
361
+ | Only OpenCode's built-in `explore` / `general` appear | Plugin didn't load | Re-run `opencode plugin opencode-resolve --global --force`; verify `"opencode-resolve"` is in `opencode.json` `plugin` array as a string. |
362
+ | Agents appear but fail when invoked with "model not found" | A pinned model ID in `models` doesn't exist | Re-open `resolve.json`, replace the offending ID with one the user actually has, restart. |
363
+ | The user said split but only one tier shows up | `models` block missing `fast` or `strong` | Re-run Step 3 from 3d. |
364
+
365
+ Internal specialist subagents (`explorer`, `reviewer`, `deep-reviewer`) are subagent-only and won't appear in the primary picker — only `resolver` (and `coder` since it has `mode: "all"`) show up there.
128
366
 
129
367
  ### Why this template
130
368
 
131
- - **`enabled`** activates the three default roles: `coder` implements, `reviewer` audits read-only, `resolver` orchestrates.
132
- - **`autoApprove: true`** lets `coder` and `resolver` work without per-action approval prompts. `reviewer` stays locked to deny — it cannot modify by any means.
133
- - **`maxParallelSubagents: 2`** is a per-role cap: up to two coders and up to two reviewers may run concurrently when working on genuinely independent things. Drop to `1` for strict per-role serialization, raise above `2` for more aggressive fan-out.
134
- - **`agents.coder.mode = "all"` and `agents.reviewer.mode = "all"`** make both visible in the primary agent picker, not just as subagents the resolver dispatches. You can still call them directly when you don't need orchestration.
135
- - **`agents.resolver.enabled: true`** is explicit (default is also true); ships with `mode: "all"` so it appears as both a primary agent and a subagent.
136
- - **`models`** uses two aliases (`glm` for fast/cheap implementation, `gpt` for stronger orchestration) and pins reviewer to `gpt-4o-mini` for cheap reads. Replace these with model IDs your provider actually exposes.
137
- - **`context7`** is the only MCP this plugin auto-registersno other MCP servers are required.
138
- - All other resolve agents (`architect`, `gpt-coder`, `debugger`, `researcher`) ship disabled. Flip `enabled: true` only if you want to use them.
139
-
140
- ### Resolver workflow (what happens when you call it)
141
-
142
- 1. Resolver reads the request, inspects relevant files.
143
- 2. Plans the smallest correct change.
144
- 3. Dispatches `coder` to implement (one at a time).
145
- 4. Verifies (tests, type checks, targeted checks).
146
- 5. If issues remain, dispatches `coder` again with a focused fix.
147
- 6. For risky changes, optionally consults `reviewer` for a read-only audit; routes any required fixes back through `coder`.
148
- 7. Repeats until the task is resolved or clearly blocked, then returns a concise summary.
369
+ | Setting | Why |
370
+ |---|---|
371
+ | `enabled: ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"]` | Fixed core path (resolver→coder) plus OpenCode-native internal specialist subagents injected by default |
372
+ | `autoApprove: true` | Coder and resolver work without per-action prompts |
373
+ | `maxParallelSubagents: 2` | Up to two coders may run in parallel for independent work |
374
+ | `agents.coder.mode = "all"` | Coder appears in the agent picker, not just as a subagent |
375
+ | `agents.{explorer,reviewer,deep-reviewer}.mode = "subagent"` | Internal specialists are subagent-onlynever user-facing primary roles |
376
+ | `context7: true` | Plugin auto-registers Context7 MCP no manual MCP config needed |
377
+ | `models` aliases | Empty by default — all roles inherit the OpenCode default model. Pin role-specific models only when you have measured a benefit |
378
+ | Other agents disabled | `architect`, `gpt-coder`, `debugger`, `researcher` off by default. Enable when needed |
379
+
380
+ ### What happens when you call the resolver
381
+
382
+ 1. **Classify** Resolver classifies the work as quick, normal, deep, or risky.
383
+ 2. **Inspect** Reads only relevant files using local tools. No broad exploration.
384
+ 3. **For trivial work** Resolver applies the small edit directly. No subagent needed.
385
+ 4. **Implement** Dispatches `coder` with exact file paths and focused instructions.
386
+ 5. **Verify** Runs the cheapest meaningful check first (targeted test, type check, or lint).
387
+ 6. **Retry** — If issues remain, dispatches `coder` again with a focused fix. Max 3 attempts per failing checkpoint. When verified, proceed to the next checkpoint.
388
+ 7. **Report** — Returns a concise evidence summary: what changed, verification results, and any remaining blockers.
389
+ 8. **Internal specialists** — When justified: dispatch `explorer` (scope genuinely unknown), `reviewer` (verification gap on non-trivial changes), or `deep-reviewer` (risky/security/high-impact only). These are available by default as subagents but are not the core path.
149
390
 
150
391
  ---
151
392
 
@@ -153,14 +394,16 @@ opencode plugin opencode-resolve --global --force
153
394
 
154
395
  | Item | Default |
155
396
  |---|---|
156
- | Enabled agents | `coder`, `reviewer`, `resolver` |
397
+ | Enabled agents | `coder`, `resolver`, `explorer`, `reviewer`, `deep-reviewer` |
398
+ | Core path | `resolver` → `coder` (fixed-role verified loop) |
399
+ | Internal subagents | `explorer`, `reviewer`, `deep-reviewer` (subagent-only, dispatched when justified) |
157
400
  | Primary agent for new tasks | `resolver` (`mode: "all"`) |
158
401
  | Agent model | Inherits top-level OpenCode `model` |
159
402
  | Native `plan` / `build` | Preserved untouched |
160
- | Context7 MCP preset | Added if absent |
403
+ | Context7 MCP preset | Added automatically when `context7: true` |
161
404
  | Optional commands | Disabled |
162
405
  | `autoApprove` | `true` (no per-action prompts on coder/resolver) |
163
- | Reviewer modification | Denied (cannot be auto-approved) |
406
+ | Max retries per checkpoint | 3 (via resolver prompt) |
164
407
 
165
408
  ---
166
409
 
@@ -180,14 +423,14 @@ Inline plugin options in `opencode.json` override file config.
180
423
  Config precedence:
181
424
 
182
425
  ```text
183
- built-in defaults -> first config file found -> inline plugin options
426
+ built-in defaults first config file found inline plugin options
184
427
  ```
185
428
 
186
429
  Minimal config (matches defaults):
187
430
 
188
431
  ```json
189
432
  {
190
- "enabled": ["coder", "reviewer", "resolver"],
433
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
191
434
  "autoApprove": true,
192
435
  "context7": true,
193
436
  "commands": false
@@ -202,7 +445,7 @@ Inline form inside `opencode.json`:
202
445
  [
203
446
  "opencode-resolve",
204
447
  {
205
- "enabled": ["coder", "reviewer", "resolver"],
448
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
206
449
  "autoApprove": true,
207
450
  "context7": true,
208
451
  "commands": false
@@ -222,13 +465,13 @@ Every accepted top-level option:
222
465
 
223
466
  | Key | Type | Default | Purpose |
224
467
  |---|---|---|---|
225
- | `enabled` | `string[]` | `["coder", "reviewer", "resolver"]` | Which resolve agents to inject. Per-agent `agents.<name>.enabled` overrides this. |
468
+ | `enabled` | `string[]` | `["coder", "resolver", "explorer", "reviewer", "deep-reviewer"]` | Which resolve agents to inject. Core path: resolver→coder. Internal specialists (explorer, reviewer, deep-reviewer) are subagent-only. Per-agent `agents.<name>.enabled` overrides this. |
226
469
  | `preserveNative` | `boolean` | `true` | Native `plan`/`build` are always preserved. Accepted for readability. |
227
470
  | `context7` | `boolean` | `true` | When true, registers the Context7 MCP server unless already configured. |
228
471
  | `commands` | `boolean` | `false` | When true, adds `resolve`, `resolve-code`, `resolve-review` commands. |
229
472
  | `autoApprove` | `boolean` | `true` | Flips default `"ask"` permissions to `"allow"` on enabled agents. Never touches `"deny"` or user-set keys. |
230
- | `maxParallelSubagents` | `positive integer` | `1` | Cap on simultaneous subagents the resolver dispatches across coder, reviewer, etc. |
231
- | `models` | `object` | `{}` | Alias map. Keys are agent names or `glm`/`gpt`. Values are model ids or other aliases. |
473
+ | `maxParallelSubagents` | `positive integer` | `2` | Cap on simultaneous subagents the resolver dispatches per role. |
474
+ | `models` | `object` | `{}` | Alias map. Keys are agent names or `fast`/`strong`/`mini`/`codex`/`quick`/`deep`/`glm`/`gpt`. Values are model ids or other aliases. Empty by default — all roles inherit the OpenCode default model. |
232
475
  | `agents` | `object` | `{}` | Per-agent overrides (see below). |
233
476
  | `config` | `string` | _none_ | Custom path to a config file (relative to the project or absolute). |
234
477
 
@@ -260,9 +503,7 @@ Permission keys (each takes `"ask"`, `"allow"`, or `"deny"`):
260
503
  }
261
504
  ```
262
505
 
263
- A fully-annotated reference config ships with the package as
264
- [`opencode-resolve.reference.jsonc`](./opencode-resolve.reference.jsonc) — copy
265
- the keys you need into your `resolve.json` (without the comments).
506
+ A fully-annotated reference config ships with the package as [`opencode-resolve.reference.jsonc`](./opencode-resolve.reference.jsonc) — copy the keys you need into your `resolve.json` (without the comments).
266
507
 
267
508
  ---
268
509
 
@@ -278,7 +519,7 @@ the keys you need into your `resolve.json` (without the comments).
278
519
  | User explicit `"allow"` | stays `"allow"` | stays `"allow"` |
279
520
  | User explicit `"deny"` | stays `"deny"` | stays `"deny"` |
280
521
 
281
- Reviewer permissions for `edit` and `bash` are `"deny"` in the defaults, so `autoApprove` cannot grant the reviewer modification rights.
522
+ Agents with `"deny"` defaults (e.g. reviewer's `edit` and `bash`) keep those denials even with `autoApprove: true`. Reviewer is enabled by default as an internal subagent — its deny permissions ensure it stays read-only.
282
523
 
283
524
  Turn it off when you want the conservative ask-every-time behavior:
284
525
 
@@ -288,29 +529,29 @@ Turn it off when you want the conservative ask-every-time behavior:
288
529
  }
289
530
  ```
290
531
 
291
- Trust note: `autoApprove: true` assumes you trust the workspace and the model you have configured. Use a sandbox or VM for untrusted code, and keep `autoApprove: false` if you want to inspect every action.
532
+ > **Trust note:** `autoApprove: true` assumes you trust the workspace and the model you have configured. Use a sandbox or VM for untrusted code, and keep `autoApprove: false` if you want to inspect every action.
292
533
 
293
534
  ---
294
535
 
295
536
  ## Parallel Subagent Limit
296
537
 
297
- `maxParallelSubagents` (default `2`) caps how many subagents the **resolver** may dispatch concurrently **per role**. The default of `2` lets up to two coders run in parallel AND up to two reviewers run in parallel — total up to four subagents in flight when both roles are active. Subagents of different roles may always run concurrently (e.g. coder implementing while reviewer audits the previous step).
538
+ `maxParallelSubagents` (default `2`) caps how many subagents the **resolver** may dispatch concurrently **per role** for context efficiency. The default of `2` lets up to two coders run in parallel for genuinely independent work.
298
539
 
299
540
  | Value | Behavior |
300
541
  |---|---|
301
- | `1` | Strictly one of each role at a time. Coder may run while reviewer runs, but never two coders or two reviewers in parallel. |
302
- | `2` (default) | Up to two of each role concurrently. Total in flight up to (per-role limit × number of active roles). |
303
- | `N > 2` | Up to N of each role concurrently. Useful when fanning out genuinely independent work. |
542
+ | `1` | Strictly one coder at a time. |
543
+ | `2` (default) | Up to two coders concurrently. Useful when fanning out genuinely independent work. |
544
+ | `N > 2` | Up to N coders concurrently. Use sparingly to avoid context waste. |
304
545
 
305
546
  Override per project or per user:
306
547
 
307
548
  ```json
308
- { "maxParallelSubagents": 1 } // strictest
309
- { "maxParallelSubagents": 2 } // default
310
- { "maxParallelSubagents": 4 } // aggressive parallelism
549
+ { "maxParallelSubagents": 1 }
550
+ { "maxParallelSubagents": 2 }
551
+ { "maxParallelSubagents": 4 }
311
552
  ```
312
553
 
313
- > **Important — soft limit, not a hard cap.** The limit is woven into the resolver's system prompt only. There is no runtime interceptor that blocks excess dispatches. Modern models (GPT-5.x, GLM-5, Claude 4.x) generally respect the directive, but if a model misbehaves, dispatches above the limit will go through. Pair this with `maxSteps` to bound total iterations if you want a stricter ceiling.
554
+ > **Important — soft limit, not a hard cap.** The limit is woven into the resolver's system prompt only. There is no runtime interceptor that blocks excess dispatches. Capable instruction-following coding models generally respect the directive, but if a model misbehaves, dispatches above the limit will go through. Pair this with `maxSteps` to bound total iterations if you want a stricter ceiling.
314
555
 
315
556
  The limit is templated into the prompt at config-load time, so restart OpenCode to pick up the new value. If you provide a custom `agents.resolver.prompt`, the templated rule is skipped and your prompt wins entirely.
316
557
 
@@ -325,6 +566,18 @@ When you upgrade to a newer version of `opencode-resolve`, the `postinstall` scr
325
566
  - **Never** rewrites your `enabled` list, `models` map, or `agents` overrides.
326
567
  - If `enabled` is set and does not include `"resolver"`, prints a one-line tip suggesting you add it. Your file is left untouched.
327
568
 
569
+ ### Adaptive first-install preset
570
+
571
+ When `resolve.json` does **not** exist, postinstall inspects your OpenCode model configuration and writes a provider-adapted `models` block:
572
+
573
+ | Detected provider | Preset |
574
+ |---|---|
575
+ | GLM / ZAI | Mixed GLM + GPT: coder/explorer → GLM, resolver/reviewer/deep-reviewer → GPT |
576
+ | OpenAI / GPT | Single-provider: all roles use your current OpenAI model |
577
+ | Other or none | Model-neutral: `models: {}` (all roles inherit OpenCode default) |
578
+
579
+ To change presets at any time, edit `models` in `resolve.json` directly or delete the file and reinstall.
580
+
328
581
  Skip the migration entirely with:
329
582
 
330
583
  ```sh
@@ -335,7 +588,7 @@ OPENCODE_RESOLVE_SKIP_POSTINSTALL=1 npm install -g opencode-resolve
335
588
 
336
589
  ## Model Setup
337
590
 
338
- `opencode-resolve` does not ship a provider-specific role default.
591
+ `opencode-resolve` does not pin any provider-specific model by default. All resolve agents inherit your top-level OpenCode `model` — use a single efficient model if it gives the best token-per-result efficiency. Only pin role-specific models when you have measured a benefit.
339
592
 
340
593
  Model resolution order for each resolve agent:
341
594
 
@@ -344,68 +597,80 @@ Model resolution order for each resolve agent:
344
597
  3. top-level OpenCode `model`
345
598
  4. OpenCode's own fallback when no model is configured
346
599
 
347
- Use the default config when all resolve roles should follow your current OpenCode model.
600
+ ### Use default model for everything (recommended)
348
601
 
349
- Pin models only when you intentionally want fixed role behavior, such as fast coding on one model and deeper review on another.
602
+ ```json
603
+ {
604
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
605
+ "models": {}
606
+ }
607
+ ```
350
608
 
351
- Role-specific aliases:
609
+ ### Role-specific aliases (when measured benefit exists)
352
610
 
353
611
  ```json
354
612
  {
355
- "enabled": ["coder", "reviewer", "resolver"],
613
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
356
614
  "models": {
357
- "glm": "zai-coding-plan/glm-5.1",
358
- "gpt": "openai/gpt-5.5",
359
- "coder": "glm",
360
- "resolver": "gpt",
361
- "reviewer": "gpt"
615
+ "fast": "openai/gpt-5-mini",
616
+ "strong": "openai/gpt-5.3-codex",
617
+ "coder": "fast",
618
+ "resolver": "strong"
362
619
  }
363
620
  }
364
621
  ```
365
622
 
366
- Pin one role directly:
623
+ ### Pin one role directly
367
624
 
368
625
  ```json
369
626
  {
370
627
  "agents": {
371
- "reviewer": {
372
- "model": "openai/gpt-5.5"
628
+ "resolver": {
629
+ "model": "openai/gpt-5.3-codex"
373
630
  }
374
631
  }
375
632
  }
376
633
  ```
377
634
 
378
- Native OpenCode agents such as `plan` and `build` are configured through the top-level OpenCode `agent`, not through `opencode-resolve`.
635
+ ### Mixed setup (OpenCode config + resolve models)
379
636
 
380
- Mixed setup example:
637
+ Native OpenCode agents such as `plan` and `build` are configured through the top-level OpenCode `agent`, not through `opencode-resolve`.
381
638
 
382
639
  ```json
383
640
  {
384
- "model": "zai-coding-plan/glm-5.1",
641
+ "model": "openai/gpt-5-mini",
385
642
  "agent": {
386
643
  "plan": {
387
- "model": "openai/gpt-5.5"
644
+ "model": "openai/gpt-5.3-codex"
388
645
  }
389
646
  },
390
647
  "plugin": [
391
648
  [
392
649
  "opencode-resolve",
393
650
  {
394
- "enabled": ["coder", "reviewer", "resolver"],
395
- "models": {
396
- "glm": "zai-coding-plan/glm-5.1",
397
- "gpt": "openai/gpt-5.5",
398
- "coder": "glm",
399
- "resolver": "gpt",
400
- "reviewer": "gpt"
401
- }
651
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"]
402
652
  }
403
653
  ]
404
654
  ]
405
655
  }
406
656
  ```
407
657
 
408
- In this setup, `plan`, `resolver`, and `reviewer` use `openai/gpt-5.5`; native `build` and resolve `coder` use `zai-coding-plan/glm-5.1`.
658
+ In this setup, `plan` uses `openai/gpt-5.3-codex`; native `build`, resolve `coder`, and resolve `resolver` all use `openai/gpt-5-mini`.
659
+
660
+ ### Supported model alias keys
661
+
662
+ | Alias | Purpose |
663
+ |---|---|
664
+ | `fast` | Provider-neutral alias for a fast/cheap model |
665
+ | `strong` | Provider-neutral alias for a strong/expensive model |
666
+ | `mini` | Provider-neutral alias for a mini/efficient model |
667
+ | `codex` | Provider-neutral alias for a codex-style coding model |
668
+ | `quick` | Legacy alias (equivalent to `fast`) |
669
+ | `deep` | Legacy alias (equivalent to `strong`) |
670
+ | `glm` | Legacy alias (backward compatibility) |
671
+ | `gpt` | Legacy alias (backward compatibility) |
672
+
673
+ Aliases only resolve when defined in `models`. Agent names (`coder`, `resolver`, etc.) are also valid alias keys.
409
674
 
410
675
  ---
411
676
 
@@ -413,9 +678,11 @@ In this setup, `plan`, `resolver`, and `reviewer` use `openai/gpt-5.5`; native `
413
678
 
414
679
  | Agent | Default | Mode | Edit | Bash | WebFetch | Purpose |
415
680
  |---|:---:|---|---|---|---|---|
416
- | `resolver` | Yes | `all` | ask → allow | ask → allow | ask → allow | Primary orchestrator. Plans, dispatches `coder` (one at a time), verifies, iterates to completion. |
417
- | `coder` | Yes | `subagent` | ask → allow | ask → allow | ask → allow | Focused implementer. Smallest correct change. |
418
- | `reviewer` | Yes | `subagent` | **deny** | **deny** | ask → allow | Read-only auditor. Cannot modify by any means. |
681
+ | `resolver` | Yes (core) | `all` | ask → allow | ask → allow | ask → allow | Context-efficient orchestrator. Decomposes work into verified checkpoints, dispatches coder, verifies each, carries forward. Max 3 retries per failing checkpoint. |
682
+ | `coder` | Yes (core) | `subagent` | ask → allow | ask → allow | ask → allow | Focused implementer. Smallest correct patch. Reads only needed files. |
683
+ | `explorer` | Yes (subagent) | `subagent` | **deny** | ask → allow | ask → allow | Internal fast codebase scout. Resolver dispatches when scope is genuinely unknown; prefers local read/grep/glob for narrow scope. |
684
+ | `reviewer` | Yes (subagent) | `subagent` | **deny** | **deny** | ask → allow | Internal verification-gap auditor. Resolver dispatches for post-change verification gaps on non-trivial changes. |
685
+ | `deep-reviewer` | Yes (subagent) | `subagent` | **deny** | **deny** | ask → allow | Internal thorough review for risky/security/architecture changes. Resolver dispatches ONLY for high-impact work. |
419
686
  | `architect` | No | `subagent` | deny | ask → allow | ask → allow | Design and task decomposition. |
420
687
  | `gpt-coder` | No | `subagent` | ask → allow | ask → allow | ask → allow | Stronger-reasoning implementation fallback. |
421
688
  | `debugger` | No | `subagent` | ask → allow | ask → allow | ask → allow | Reproduction and root-cause analysis. |
@@ -433,19 +700,25 @@ Supported modes:
433
700
 
434
701
  Supported permission values: `ask`, `allow`, `deny`.
435
702
 
436
- Supported model alias keys: `glm`, `gpt`, and every supported agent name. Aliases only resolve when defined in `models`.
703
+ Supported model alias keys: `fast`, `strong`, `mini`, `codex`, `quick`, `deep`, `glm`, `gpt`, and every supported agent name. Aliases only resolve when defined in `models`.
437
704
 
438
705
  `preserveNative` is accepted for readability, but native `plan` and `build` are always preserved. The plugin never rewrites built-in OpenCode agents.
439
706
 
440
707
  ### Resolver orchestration rules
441
708
 
442
- The resolver's prompt enforces the following behavior:
709
+ The resolver uses a context-efficient approach with checkpointed execution (max 3 retries per failing checkpoint):
443
710
 
444
- - Plan the smallest correct change before dispatching.
445
- - Dispatch **only one `coder` subagent at a time**. Never call coders in parallel.
446
- - After each coder run, verify (tests, type checks, targeted checks) when practical.
447
- - Optionally consult `reviewer` for an independent read-only audit on risky changes; route any required fixes back through `coder`.
448
- - Iterate until the task is resolved or clearly blocked, then return a concise summary.
711
+ - **Classify** the work as quick, normal, deep, or risky before planning.
712
+ - **Inspect only relevant files** using local tools avoid broad exploration.
713
+ - For trivial work, apply edits directly no subagent needed.
714
+ - Dispatch **coder** with focused file/behavior instructions.
715
+ - Run the **cheapest meaningful verification** first.
716
+ - Retry from verification logs if issues remain. Max 3 attempts per failing checkpoint; then move forward or report the blocker.
717
+ - Use **explorer** only when scope is genuinely unknown and local read/grep/glob are insufficient (internal subagent, not core path).
718
+ - Use **reviewer** only when a verification gap exists on non-trivial changes (internal subagent, not core path).
719
+ - Use **deep-reviewer** only for risky, security-sensitive, architectural, or high-impact changes (internal subagent, not core path).
720
+ - Return a concise evidence summary when resolved or blocked.
721
+ - Honor the `maxParallelSubagents` per-role limit for context efficiency.
449
722
 
450
723
  ---
451
724
 
@@ -461,6 +734,56 @@ Set `commands: true` to add helper subtask commands:
461
734
 
462
735
  ---
463
736
 
737
+ ## Context7 Integration
738
+
739
+ When `context7: true` (the default), the plugin automatically registers the [Context7](https://context7.com) MCP server at startup:
740
+
741
+ ```json
742
+ {
743
+ "type": "remote",
744
+ "url": "https://mcp.context7.com/mcp"
745
+ }
746
+ ```
747
+
748
+ This gives all resolve agents access to up-to-date library and framework documentation through the `resolve-library-id` and `query-docs` tools — no manual MCP configuration needed.
749
+
750
+ To disable Context7 registration (e.g. you already have it configured, or you don't want it):
751
+
752
+ ```json
753
+ {
754
+ "context7": false
755
+ }
756
+ ```
757
+
758
+ If `mcp.context7` is already present in your OpenCode config, the plugin does not overwrite it.
759
+
760
+ ---
761
+
762
+ ## Keeping Up to Date
763
+
764
+ > **OpenCode caches the last version it downloaded.** To get a new release you must explicitly refresh.
765
+
766
+ ```sh
767
+ # Upgrade via npm
768
+ npm install -g opencode-resolve@latest
769
+
770
+ # Refresh the OpenCode cache
771
+ opencode plugin opencode-resolve --global --force
772
+
773
+ # Restart OpenCode
774
+ ```
775
+
776
+ After upgrading, `postinstall` runs additive migration on your `resolve.json` — new keys are added, existing keys are never modified.
777
+
778
+ ### Pinning a specific version
779
+
780
+ ```sh
781
+ npm install -g opencode-resolve@0.1.3
782
+ opencode plugin opencode-resolve --global --force
783
+ ```
784
+
785
+ ---
786
+
464
787
  ## Local Development
465
788
 
466
789
  From this repository:
@@ -536,7 +859,19 @@ The release workflow runs `npm ci`, `npm run typecheck`, `npm test`, and `npm pu
536
859
  ## Design Rules
537
860
 
538
861
  - Do not overwrite native `plan` or `build` agents.
539
- - Keep the default agent set small and role-clear: `resolver` orchestrates, `coder` modifies, `reviewer` only reads.
540
- - The reviewer never modifies anythingfixes always go through `coder` or `resolver`.
541
- - The resolver dispatches at most one coder at a time.
862
+ - Core path is fixed: `resolver` (context-efficient planner/judge) `coder` (implementer).
863
+ - Internal specialist subagents (`explorer`, `reviewer`, `deep-reviewer`) are injected by default as OpenCode-native subagents they inherit OpenCode's composition philosophy but are not the default execution path and are never user-facing primary roles.
864
+ - Resolver prefers local read/grep/glob for narrow scope; dispatches `explorer` only when scope is genuinely unknown.
865
+ - Resolver dispatches `reviewer` only for verification gaps on non-trivial changes.
866
+ - Resolver dispatches `deep-reviewer` only for risky, security-sensitive, architectural, or high-impact changes.
867
+ - Reviewer and deep-reviewer are read-only — fixes always go through `coder` or `resolver`.
868
+ - Max 3 retries per failing checkpoint to avoid wasted context. Large tasks are decomposed into verified checkpoints.
869
+ - The resolver honors `maxParallelSubagents` for context efficiency.
542
870
  - Search and inspect before editing. Make the smallest correct change. Verify when practical.
871
+ - Read only needed files. Avoid broad exploration. Targeted verification, not full suites.
872
+
873
+ ---
874
+
875
+ ## License
876
+
877
+ [MIT](./LICENSE)