opencode-resolve 0.1.2 → 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)
60
+
61
+ ---
62
+
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
95
+
96
+ No manual config editing required. Works on macOS, Linux, and Windows.
97
+
98
+ > For manual setup, see [Prerequisites](#prerequisites) and [Quick Start](#quick-start) below.
30
99
 
31
100
  ---
32
101
 
33
- ## Roles at a glance
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
+ ```
34
113
 
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. |
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
+ ```
40
140
 
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`.
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,46 +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
- **Step 1install the plugin:**
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).
202
+
203
+ ### Step 1 — Install and prime the cache
81
204
 
82
205
  ```sh
83
- npm install -g opencode-resolve
206
+ opencode plugin opencode-resolve --global --force
84
207
  ```
85
208
 
86
- **Step 2 — `~/.config/opencode/opencode.json`** (the only required keys; merge into an existing file rather than replacing if one exists):
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.
87
214
 
88
215
  ```json
89
216
  {
90
217
  "$schema": "https://opencode.ai/config.json",
91
- "model": "<your-default-model-id>",
218
+ "model": "<user-default-model-id>",
92
219
  "plugin": ["opencode-resolve"]
93
220
  }
94
221
  ```
95
222
 
96
- **Step 3 `~/.config/opencode/resolve.json`** (created automatically by `postinstall`; the file below is the canonical default):
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:
97
279
 
98
280
  ```json
99
281
  {
100
- "enabled": ["coder", "reviewer", "resolver"],
282
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
101
283
  "preserveNative": true,
102
284
  "context7": true,
103
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
+ },
104
305
  "autoApprove": true,
105
- "maxParallelSubagents": 1
306
+ "maxParallelSubagents": 2
106
307
  }
107
308
  ```
108
309
 
109
- **Step 4 restart OpenCode.**
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,
318
+ "models": {
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"
326
+ },
327
+ "agents": {
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
340
+ }
341
+ ```
342
+
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:
110
358
 
111
- That is the entire setup. `context7` is the only MCP server the plugin needs (auto-registered when the key above is `true`) — no other MCP entries are required for `opencode-resolve` itself. Models are inherited from your top-level OpenCode `model` unless you pin per-role models under `models` (see [Model Setup](#model-setup)).
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.
112
366
 
113
- If you want stricter behavior, flip `autoApprove` to `false` (every action prompts for approval) and/or raise `maxParallelSubagents` to let the resolver fan out independent subtasks.
367
+ ### Why this template
368
+
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-only — never 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.
114
390
 
115
391
  ---
116
392
 
@@ -118,14 +394,16 @@ If you want stricter behavior, flip `autoApprove` to `false` (every action promp
118
394
 
119
395
  | Item | Default |
120
396
  |---|---|
121
- | 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) |
122
400
  | Primary agent for new tasks | `resolver` (`mode: "all"`) |
123
401
  | Agent model | Inherits top-level OpenCode `model` |
124
402
  | Native `plan` / `build` | Preserved untouched |
125
- | Context7 MCP preset | Added if absent |
403
+ | Context7 MCP preset | Added automatically when `context7: true` |
126
404
  | Optional commands | Disabled |
127
405
  | `autoApprove` | `true` (no per-action prompts on coder/resolver) |
128
- | Reviewer modification | Denied (cannot be auto-approved) |
406
+ | Max retries per checkpoint | 3 (via resolver prompt) |
129
407
 
130
408
  ---
131
409
 
@@ -145,14 +423,14 @@ Inline plugin options in `opencode.json` override file config.
145
423
  Config precedence:
146
424
 
147
425
  ```text
148
- built-in defaults -> first config file found -> inline plugin options
426
+ built-in defaults first config file found inline plugin options
149
427
  ```
150
428
 
151
429
  Minimal config (matches defaults):
152
430
 
153
431
  ```json
154
432
  {
155
- "enabled": ["coder", "reviewer", "resolver"],
433
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
156
434
  "autoApprove": true,
157
435
  "context7": true,
158
436
  "commands": false
@@ -167,7 +445,7 @@ Inline form inside `opencode.json`:
167
445
  [
168
446
  "opencode-resolve",
169
447
  {
170
- "enabled": ["coder", "reviewer", "resolver"],
448
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
171
449
  "autoApprove": true,
172
450
  "context7": true,
173
451
  "commands": false
@@ -187,13 +465,13 @@ Every accepted top-level option:
187
465
 
188
466
  | Key | Type | Default | Purpose |
189
467
  |---|---|---|---|
190
- | `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. |
191
469
  | `preserveNative` | `boolean` | `true` | Native `plan`/`build` are always preserved. Accepted for readability. |
192
470
  | `context7` | `boolean` | `true` | When true, registers the Context7 MCP server unless already configured. |
193
471
  | `commands` | `boolean` | `false` | When true, adds `resolve`, `resolve-code`, `resolve-review` commands. |
194
472
  | `autoApprove` | `boolean` | `true` | Flips default `"ask"` permissions to `"allow"` on enabled agents. Never touches `"deny"` or user-set keys. |
195
- | `maxParallelSubagents` | `positive integer` | `1` | Cap on simultaneous subagents the resolver dispatches across coder, reviewer, etc. |
196
- | `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. |
197
475
  | `agents` | `object` | `{}` | Per-agent overrides (see below). |
198
476
  | `config` | `string` | _none_ | Custom path to a config file (relative to the project or absolute). |
199
477
 
@@ -225,9 +503,7 @@ Permission keys (each takes `"ask"`, `"allow"`, or `"deny"`):
225
503
  }
226
504
  ```
227
505
 
228
- A fully-annotated reference config ships with the package as
229
- [`opencode-resolve.reference.jsonc`](./opencode-resolve.reference.jsonc) — copy
230
- 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).
231
507
 
232
508
  ---
233
509
 
@@ -243,7 +519,7 @@ the keys you need into your `resolve.json` (without the comments).
243
519
  | User explicit `"allow"` | stays `"allow"` | stays `"allow"` |
244
520
  | User explicit `"deny"` | stays `"deny"` | stays `"deny"` |
245
521
 
246
- 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.
247
523
 
248
524
  Turn it off when you want the conservative ask-every-time behavior:
249
525
 
@@ -253,23 +529,31 @@ Turn it off when you want the conservative ask-every-time behavior:
253
529
  }
254
530
  ```
255
531
 
256
- 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.
257
533
 
258
534
  ---
259
535
 
260
536
  ## Parallel Subagent Limit
261
537
 
262
- `maxParallelSubagents` (default `1`) caps how many subagents the **resolver** may dispatch in parallel across `coder`, `reviewer`, or any other subagent. The default of `1` enforces strictly serial dispatch: resolver waits for each subagent to finish before launching the next.
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.
539
+
540
+ | Value | Behavior |
541
+ |---|---|
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. |
263
545
 
264
- Raise it when you want resolver to fan out independent subtasks:
546
+ Override per project or per user:
265
547
 
266
548
  ```json
267
- {
268
- "maxParallelSubagents": 3
269
- }
549
+ { "maxParallelSubagents": 1 }
550
+ { "maxParallelSubagents": 2 }
551
+ { "maxParallelSubagents": 4 }
270
552
  ```
271
553
 
272
- The limit is woven into the resolver's prompt at config-load time, so changing it does not require any code changes restart OpenCode to pick up the new limit. If you provide a custom `agents.resolver.prompt`, the templated rule is skipped and your prompt wins.
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.
555
+
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.
273
557
 
274
558
  ---
275
559
 
@@ -282,6 +566,18 @@ When you upgrade to a newer version of `opencode-resolve`, the `postinstall` scr
282
566
  - **Never** rewrites your `enabled` list, `models` map, or `agents` overrides.
283
567
  - If `enabled` is set and does not include `"resolver"`, prints a one-line tip suggesting you add it. Your file is left untouched.
284
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
+
285
581
  Skip the migration entirely with:
286
582
 
287
583
  ```sh
@@ -292,7 +588,7 @@ OPENCODE_RESOLVE_SKIP_POSTINSTALL=1 npm install -g opencode-resolve
292
588
 
293
589
  ## Model Setup
294
590
 
295
- `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.
296
592
 
297
593
  Model resolution order for each resolve agent:
298
594
 
@@ -301,68 +597,80 @@ Model resolution order for each resolve agent:
301
597
  3. top-level OpenCode `model`
302
598
  4. OpenCode's own fallback when no model is configured
303
599
 
304
- Use the default config when all resolve roles should follow your current OpenCode model.
600
+ ### Use default model for everything (recommended)
305
601
 
306
- 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
+ ```
307
608
 
308
- Role-specific aliases:
609
+ ### Role-specific aliases (when measured benefit exists)
309
610
 
310
611
  ```json
311
612
  {
312
- "enabled": ["coder", "reviewer", "resolver"],
613
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"],
313
614
  "models": {
314
- "glm": "zai-coding-plan/glm-5.1",
315
- "gpt": "openai/gpt-5.5",
316
- "coder": "glm",
317
- "resolver": "gpt",
318
- "reviewer": "gpt"
615
+ "fast": "openai/gpt-5-mini",
616
+ "strong": "openai/gpt-5.3-codex",
617
+ "coder": "fast",
618
+ "resolver": "strong"
319
619
  }
320
620
  }
321
621
  ```
322
622
 
323
- Pin one role directly:
623
+ ### Pin one role directly
324
624
 
325
625
  ```json
326
626
  {
327
627
  "agents": {
328
- "reviewer": {
329
- "model": "openai/gpt-5.5"
628
+ "resolver": {
629
+ "model": "openai/gpt-5.3-codex"
330
630
  }
331
631
  }
332
632
  }
333
633
  ```
334
634
 
335
- 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)
336
636
 
337
- Mixed setup example:
637
+ Native OpenCode agents such as `plan` and `build` are configured through the top-level OpenCode `agent`, not through `opencode-resolve`.
338
638
 
339
639
  ```json
340
640
  {
341
- "model": "zai-coding-plan/glm-5.1",
641
+ "model": "openai/gpt-5-mini",
342
642
  "agent": {
343
643
  "plan": {
344
- "model": "openai/gpt-5.5"
644
+ "model": "openai/gpt-5.3-codex"
345
645
  }
346
646
  },
347
647
  "plugin": [
348
648
  [
349
649
  "opencode-resolve",
350
650
  {
351
- "enabled": ["coder", "reviewer", "resolver"],
352
- "models": {
353
- "glm": "zai-coding-plan/glm-5.1",
354
- "gpt": "openai/gpt-5.5",
355
- "coder": "glm",
356
- "resolver": "gpt",
357
- "reviewer": "gpt"
358
- }
651
+ "enabled": ["coder", "resolver", "explorer", "reviewer", "deep-reviewer"]
359
652
  }
360
653
  ]
361
654
  ]
362
655
  }
363
656
  ```
364
657
 
365
- 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.
366
674
 
367
675
  ---
368
676
 
@@ -370,9 +678,11 @@ In this setup, `plan`, `resolver`, and `reviewer` use `openai/gpt-5.5`; native `
370
678
 
371
679
  | Agent | Default | Mode | Edit | Bash | WebFetch | Purpose |
372
680
  |---|:---:|---|---|---|---|---|
373
- | `resolver` | Yes | `all` | ask → allow | ask → allow | ask → allow | Primary orchestrator. Plans, dispatches `coder` (one at a time), verifies, iterates to completion. |
374
- | `coder` | Yes | `subagent` | ask → allow | ask → allow | ask → allow | Focused implementer. Smallest correct change. |
375
- | `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. |
376
686
  | `architect` | No | `subagent` | deny | ask → allow | ask → allow | Design and task decomposition. |
377
687
  | `gpt-coder` | No | `subagent` | ask → allow | ask → allow | ask → allow | Stronger-reasoning implementation fallback. |
378
688
  | `debugger` | No | `subagent` | ask → allow | ask → allow | ask → allow | Reproduction and root-cause analysis. |
@@ -390,19 +700,25 @@ Supported modes:
390
700
 
391
701
  Supported permission values: `ask`, `allow`, `deny`.
392
702
 
393
- 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`.
394
704
 
395
705
  `preserveNative` is accepted for readability, but native `plan` and `build` are always preserved. The plugin never rewrites built-in OpenCode agents.
396
706
 
397
707
  ### Resolver orchestration rules
398
708
 
399
- 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):
400
710
 
401
- - Plan the smallest correct change before dispatching.
402
- - Dispatch **only one `coder` subagent at a time**. Never call coders in parallel.
403
- - After each coder run, verify (tests, type checks, targeted checks) when practical.
404
- - Optionally consult `reviewer` for an independent read-only audit on risky changes; route any required fixes back through `coder`.
405
- - 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.
406
722
 
407
723
  ---
408
724
 
@@ -418,6 +734,56 @@ Set `commands: true` to add helper subtask commands:
418
734
 
419
735
  ---
420
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
+
421
787
  ## Local Development
422
788
 
423
789
  From this repository:
@@ -493,7 +859,19 @@ The release workflow runs `npm ci`, `npm run typecheck`, `npm test`, and `npm pu
493
859
  ## Design Rules
494
860
 
495
861
  - Do not overwrite native `plan` or `build` agents.
496
- - Keep the default agent set small and role-clear: `resolver` orchestrates, `coder` modifies, `reviewer` only reads.
497
- - The reviewer never modifies anythingfixes always go through `coder` or `resolver`.
498
- - 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.
499
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)