@kodrunhq/opencode-autopilot 0.1.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,303 @@
1
- # @kodrunhq/opencode-autopilot
1
+ <p align="center">
2
+ <img src="https://img.shields.io/npm/v/@kodrunhq/opencode-autopilot?color=blue&label=npm" alt="npm version" />
3
+ <img src="https://img.shields.io/github/actions/workflow/status/kodrunhq/opencode-autopilot/ci.yml?branch=main&label=CI" alt="CI" />
4
+ <img src="https://img.shields.io/github/license/kodrunhq/opencode-autopilot" alt="license" />
5
+ <img src="https://img.shields.io/badge/TypeScript-strict-blue?logo=typescript&logoColor=white" alt="TypeScript" />
6
+ <img src="https://img.shields.io/badge/runtime-Bun-f9f1e1?logo=bun&logoColor=black" alt="Bun" />
7
+ </p>
8
+
9
+ <p align="center">
10
+ <img src="assets/logo.svg" alt="opencode-autopilot logo" width="120" height="120" />
11
+ </p>
12
+
13
+ <h1 align="center">opencode-autopilot</h1>
14
+
15
+ <p align="center">
16
+ <strong>Autonomous AI coding pipeline for OpenCode.</strong><br/>
17
+ Idea to shipped code &bull; 21-agent code review &bull; Adversarial model diversity &bull; Guided setup
18
+ </p>
19
+
20
+ ---
21
+
22
+ A plugin for the [OpenCode](https://github.com/opencode-ai/opencode) AI coding CLI that turns it into a fully autonomous software development system. Give it an idea — it researches, designs architecture, plans tasks, implements code, runs multi-agent code review, writes documentation, and extracts lessons for next time.
23
+
24
+ The core insight: **adversarial model diversity**. Agents that review each other's work use different model families. Your architect designs in Claude, your critic challenges in GPT, your red team attacks from Gemini — three different reasoning patterns catching three different classes of bugs.
25
+
26
+ ## Quick Start
27
+
28
+ ### Option A: AI-guided setup (recommended)
29
+
30
+ Paste this into your AI session:
31
+
32
+ ```
33
+ Install and configure opencode-autopilot by following the instructions here:
34
+ https://raw.githubusercontent.com/kodrunhq/opencode-autopilot/main/docs/guide/installation.md
35
+ ```
36
+
37
+ The AI walks you through installation, model assignment for each agent group, and verification.
38
+
39
+ ### Option B: CLI installer
40
+
41
+ ```bash
42
+ bunx @kodrunhq/opencode-autopilot install
43
+ ```
44
+
45
+ This registers the plugin in `opencode.json` and creates a starter config. Then launch OpenCode and run `/oc-configure` to set up your model assignments.
46
+
47
+ ### Option C: Manual setup
48
+
49
+ **Install:**
50
+
51
+ ```bash
52
+ npm install -g @kodrunhq/opencode-autopilot
53
+ ```
54
+
55
+ **Add to your OpenCode config** (`opencode.json`):
56
+
57
+ ```json
58
+ {
59
+ "plugin": ["@kodrunhq/opencode-autopilot"]
60
+ }
61
+ ```
62
+
63
+ Launch OpenCode. The plugin auto-installs agents, skills, and commands on first load and shows a welcome toast directing you to `/oc-configure`.
64
+
65
+ ### Verify your setup
66
+
67
+ ```bash
68
+ bunx @kodrunhq/opencode-autopilot doctor
69
+ ```
70
+
71
+ This checks config health, model assignments, and adversarial diversity between agent groups.
72
+
73
+ ## Model Groups
74
+
75
+ Agents are organized into 8 groups by the type of thinking they do. Each group gets a primary model and fallback chain. The `/oc-configure` command walks you through assigning models interactively.
76
+
77
+ | Group | Agents | What they do | Model recommendation |
78
+ |-------|--------|-------------|---------------------|
79
+ | **Architects** | oc-architect, oc-planner, autopilot | System design, planning, orchestration | Most powerful available |
80
+ | **Challengers** | oc-critic, oc-challenger | Challenge architecture, find design flaws | Strong model, **different family from Architects** |
81
+ | **Builders** | oc-implementer | Write production code | Strong coding model |
82
+ | **Reviewers** | oc-reviewer + 19 review agents | Find bugs, security issues, logic errors | Strong model, **different family from Builders** |
83
+ | **Red Team** | red-team, product-thinker | Final adversarial pass, hunt exploits | **Different family from both Builders and Reviewers** |
84
+ | **Researchers** | oc-researcher, researcher | Domain research, feasibility analysis | Good comprehension, any family |
85
+ | **Communicators** | oc-shipper, documenter, oc-retrospector | Docs, changelogs, lesson extraction | Mid-tier model |
86
+ | **Utilities** | oc-explorer, metaprompter, pr-reviewer | Fast lookups, prompt tuning, PR scanning | Fastest/cheapest available |
87
+
88
+ ### Adversarial diversity
89
+
90
+ The installer warns when adversarial pairs share a model family:
91
+
92
+ | Pair | Relationship | Why diversity matters |
93
+ |------|-------------|---------------------|
94
+ | Architects / Challengers | Challengers critique architect output | Same model = confirmation bias |
95
+ | Builders / Reviewers | Reviewers find bugs in builder code | Same model = shared blind spots |
96
+ | Red Team / Builders+Reviewers | Final adversarial perspective | Most effective as a third family |
97
+
98
+ ### Example config
99
+
100
+ ```json
101
+ {
102
+ "version": 4,
103
+ "configured": true,
104
+ "groups": {
105
+ "architects": { "primary": "anthropic/claude-opus-4-6", "fallbacks": ["openai/gpt-5.4"] },
106
+ "challengers": { "primary": "openai/gpt-5.4", "fallbacks": ["google/gemini-3.1-pro"] },
107
+ "builders": { "primary": "anthropic/claude-opus-4-6", "fallbacks": ["anthropic/claude-sonnet-4-6"] },
108
+ "reviewers": { "primary": "openai/gpt-5.4", "fallbacks": ["google/gemini-3.1-pro"] },
109
+ "red-team": { "primary": "google/gemini-3.1-pro", "fallbacks": ["openai/gpt-5.4"] },
110
+ "researchers": { "primary": "anthropic/claude-sonnet-4-6", "fallbacks": ["openai/gpt-5.4"] },
111
+ "communicators": { "primary": "anthropic/claude-sonnet-4-6", "fallbacks": ["anthropic/claude-haiku-4-5"] },
112
+ "utilities": { "primary": "anthropic/claude-haiku-4-5", "fallbacks": ["google/gemini-3-flash"] }
113
+ },
114
+ "overrides": {}
115
+ }
116
+ ```
117
+
118
+ Per-agent overrides are supported for fine-grained control:
119
+
120
+ ```json
121
+ {
122
+ "overrides": {
123
+ "oc-planner": { "primary": "openai/gpt-5.4", "fallbacks": ["anthropic/claude-opus-4-6"] }
124
+ }
125
+ }
126
+ ```
127
+
128
+ ## The Pipeline
129
+
130
+ opencode-autopilot runs an 8-phase autonomous pipeline, each driven by a specialized agent:
131
+
132
+ ```
133
+ IDEA --> RECON --> CHALLENGE --> ARCHITECT --> EXPLORE --> PLAN --> BUILD --> SHIP --> RETROSPECTIVE
134
+ | | | | | | |
135
+ Research Enhance Multi-proposal Task plan Code + Docs & Extract
136
+ & assess the idea design arena with waves review changelog lessons
137
+ ```
138
+
139
+ | Phase | Agent | What happens |
140
+ |-------|-------|-------------|
141
+ | **RECON** | oc-researcher | Domain research, feasibility assessment, technology landscape |
142
+ | **CHALLENGE** | oc-challenger | Proposes ambitious enhancements to the original idea |
143
+ | **ARCHITECT** | oc-architect x N | Multiple design proposals debated by oc-critic; depth scales with confidence |
144
+ | **EXPLORE** | -- | Reserved for speculative analysis (future) |
145
+ | **PLAN** | oc-planner | Decomposes architecture into wave-scheduled tasks (max 300-line diffs each) |
146
+ | **BUILD** | oc-implementer | Implements code with inline review; 3-strike limit on CRITICAL findings |
147
+ | **SHIP** | oc-shipper | Generates walkthrough, architectural decisions, and changelog |
148
+ | **RETROSPECTIVE** | oc-retrospector | Extracts lessons, injected into future runs |
149
+
150
+ ### Confidence-driven architecture
151
+
152
+ The ARCHITECT phase uses a **multi-proposal arena**. Based on confidence signals from RECON:
153
+
154
+ - **High confidence** -> 1 architecture proposal
155
+ - **Medium confidence** -> 2 competing proposals (simplicity vs. extensibility)
156
+ - **Low confidence** -> 3 competing proposals + critic evaluation
157
+
158
+ ### Strike-limited builds
159
+
160
+ BUILD tracks implementation quality with a strike system:
161
+
162
+ - Each CRITICAL review finding = 1 strike
163
+ - 3 strikes -> pipeline stops (prevents infinite retry loops)
164
+ - Non-critical findings generate fix instructions without strikes
165
+ - Waves execute in order; a wave advances only after passing review
166
+
167
+ ## Code Review
168
+
169
+ The `oc_review` tool provides a 4-stage multi-agent review pipeline:
170
+
171
+ **Stage 1 -- Specialist dispatch:** Auto-detects your stack from changed files and dispatches relevant agents in parallel.
172
+
173
+ **Stage 2 -- Cross-verification:** Each agent reviews other agents' findings to filter noise and catch missed issues.
174
+
175
+ **Stage 3 -- Adversarial review:** Red-team agent hunts for exploits; product-thinker checks for UX gaps.
176
+
177
+ **Stage 4 -- Report or fix cycle:** CRITICAL findings with actionable fixes trigger an automatic fix cycle; everything else lands in the final report.
178
+
179
+ ### 21 Review Agents
180
+
181
+ | Category | Agents | When selected |
182
+ |----------|--------|--------------|
183
+ | **Universal** (always run) | logic-auditor, security-auditor, code-quality-auditor, test-interrogator, silent-failure-hunter, contract-verifier | Every review |
184
+ | **Stack-aware** (auto-selected) | type-soundness, react-patterns-auditor, go-idioms-auditor, python-django-auditor, rust-safety-auditor, database-auditor, auth-flow-verifier, state-mgmt-auditor, concurrency-checker, scope-intent-verifier, wiring-inspector, dead-code-scanner, spec-checker | Based on changed file types |
185
+ | **Sequenced** (run last) | red-team, product-thinker | After all findings collected |
186
+
187
+ Review memory persists per project -- false positives are tracked and suppressed in future reviews (auto-pruned after 30 days).
188
+
189
+ ## Model Fallback
190
+
191
+ When a model is rate-limited, unavailable, or returns an error, the fallback system automatically:
192
+
193
+ 1. Classifies the error (rate limit, auth, quota, service unavailable, etc.)
194
+ 2. Selects the next model from the group's fallback chain
195
+ 3. Replays the conversation on the new model
196
+ 4. Shows a toast notification (configurable)
197
+ 5. Recovers to the primary model after a cooldown period
198
+
199
+ ## Bundled Assets
200
+
201
+ The plugin ships with production-ready assets that auto-install to `~/.config/opencode/`:
202
+
203
+ | Type | Assets | Purpose |
204
+ |------|--------|---------|
205
+ | **Agents** | researcher, metaprompter, documenter, pr-reviewer, autopilot + 10 pipeline agents | Research, docs, PR review, full autonomous pipeline |
206
+ | **Commands** | `/oc-configure`, `/new-agent`, `/new-skill`, `/new-command`, `/review-pr` | Model setup, extend the plugin in-session, PR reviews |
207
+ | **Skills** | coding-standards | Universal best practices (naming, error handling, immutability, validation) |
208
+
209
+ ### In-session creation
210
+
211
+ Extend the plugin without leaving OpenCode:
212
+
213
+ - **`/new-agent`** -- Create a custom agent with YAML frontmatter + system prompt
214
+ - **`/new-skill`** -- Create a skill directory with domain knowledge
215
+ - **`/new-command`** -- Create a slash command (validates against built-in names)
216
+
217
+ All created assets write to `~/.config/opencode/` and are available immediately.
218
+
219
+ ## Configuration
220
+
221
+ Config lives at `~/.config/opencode/opencode-autopilot.json`. Run `/oc-configure` for interactive setup, or edit manually.
222
+
223
+ | Setting | Options | Default |
224
+ |---------|---------|---------|
225
+ | `orchestrator.autonomy` | `full`, `supervised`, `manual` | `full` |
226
+ | `orchestrator.strictness` | `strict`, `normal`, `lenient` | `normal` |
227
+ | `orchestrator.phases.*` | `true` / `false` | all `true` |
228
+ | `confidence.thresholds.proceed` | `HIGH`, `MEDIUM`, `LOW` | `MEDIUM` |
229
+ | `confidence.thresholds.abort` | `HIGH`, `MEDIUM`, `LOW` | `LOW` |
230
+ | `fallback.enabled` | `true` / `false` | `true` |
231
+
232
+ Config auto-migrates across schema versions (v1 -> v2 -> v3 -> v4).
233
+
234
+ ## Tools
235
+
236
+ The plugin registers 11 tools, all prefixed with `oc_` to avoid conflicts with OpenCode built-ins:
237
+
238
+ | Tool | Purpose |
239
+ |------|---------|
240
+ | `oc_orchestrate` | Core pipeline state machine -- start a run or advance phases |
241
+ | `oc_review` | Multi-agent code review (4-stage pipeline) |
242
+ | `oc_configure` | Interactive model group assignment (start/assign/commit/doctor/reset) |
243
+ | `oc_state` | Query and patch pipeline state |
244
+ | `oc_phase` | Phase transitions and validation |
245
+ | `oc_confidence` | Confidence ledger management |
246
+ | `oc_plan` | Query task waves and status counts |
247
+ | `oc_forensics` | Diagnose pipeline failures (recoverable vs. terminal) |
248
+ | `oc_create_agent` | Create custom agents in-session |
249
+ | `oc_create_skill` | Create custom skills in-session |
250
+ | `oc_create_command` | Create custom commands in-session |
251
+
252
+ ## Architecture
253
+
254
+ ```
255
+ src/
256
+ +-- index.ts Plugin entry -- registers tools, hooks, fallback handlers
257
+ +-- config.ts Zod-validated config with v1->v2->v3->v4 migration
258
+ +-- installer.ts Self-healing asset copier (COPYFILE_EXCL, never overwrites)
259
+ +-- registry/
260
+ | +-- types.ts GroupId, AgentEntry, GroupDefinition, DiversityRule, ...
261
+ | +-- model-groups.ts AGENT_REGISTRY, GROUP_DEFINITIONS, DIVERSITY_RULES
262
+ | +-- resolver.ts Model resolution: override > group > default
263
+ | +-- diversity.ts Adversarial diversity checker
264
+ | +-- doctor.ts Shared diagnosis logic (CLI + tool)
265
+ +-- tools/ Tool definitions (thin wrappers calling *Core functions)
266
+ +-- templates/ Pure functions: input -> markdown string
267
+ +-- review/ 21-agent review engine, stack gate, memory, severity
268
+ +-- orchestrator/
269
+ | +-- handlers/ Per-phase state machine handlers
270
+ | +-- fallback/ Model fallback: classifier, manager, state, chain resolver
271
+ | +-- artifacts.ts Phase artifact path management
272
+ | +-- lesson-memory.ts Cross-run lesson persistence
273
+ | +-- schemas.ts Pipeline state Zod schemas
274
+ +-- utils/ Validators, paths, fs-helpers, gitignore management
275
+
276
+ bin/
277
+ +-- cli.ts CLI: install + doctor subcommands
278
+ ```
279
+
280
+ **Dependency flow** (strictly top-down, no cycles):
281
+ `index.ts` -> `tools/*` -> `registry/*` + `templates/*` + `utils/*` -> Node built-ins + `yaml`
282
+
283
+ **Key patterns:**
284
+ - **Declarative registry** -- adding an agent = one line in AGENT_REGISTRY, everything derives from it
285
+ - **Atomic writes** -- all file operations use tmp + rename with crypto-random suffixes
286
+ - **Immutable state** -- deep-frozen data, spread operators, readonly arrays
287
+ - **Bidirectional validation** -- Zod parse on read AND write
288
+ - **Self-healing assets** -- bundled files copy on load, never overwrite user customizations
289
+
290
+ ## Contributing
291
+
292
+ ```bash
293
+ git clone https://github.com/kodrunhq/opencode-autopilot.git
294
+ cd opencode-autopilot
295
+ bun install
296
+ bun test && bun run lint
297
+ ```
298
+
299
+ 834 tests across 64 files. No build step -- Bun runs TypeScript natively.
300
+
301
+ ## License
302
+
303
+ [MIT](LICENSE)
@@ -0,0 +1,45 @@
1
+ ---
2
+ description: Configure opencode-autopilot model assignments for each agent group
3
+ agent: autopilot
4
+ ---
5
+ Help the user configure opencode-autopilot by walking through the model
6
+ assignment process interactively.
7
+
8
+ Start by calling the oc_configure tool with subcommand "start". This returns:
9
+ - Available models grouped by provider (from the user's OpenCode config)
10
+ - The 8 agent groups with descriptions and recommendations
11
+ - Current assignments if reconfiguring
12
+ - Adversarial diversity rules
13
+
14
+ Then walk through each of the 8 agent groups in order (architects first,
15
+ utilities last), explaining for each:
16
+
17
+ 1. What the group does and which agents belong to it
18
+ 2. The model tier recommendation
19
+ 3. For adversarial groups (challengers, reviewers, red-team): explain WHY
20
+ model diversity matters and which group they're adversarial to
21
+ 4. List available models from the user's providers
22
+
23
+ For each group, present the available models as a numbered list:
24
+
25
+ Example format:
26
+ Primary model for Architects:
27
+ 1. anthropic/claude-opus-4-6
28
+ 2. openai/gpt-5.4
29
+ 3. google/gemini-3.1-pro
30
+
31
+ Pick a number (or type a model ID):
32
+
33
+ If the user sends just a number, map it to the corresponding model.
34
+ Then ask for optional fallbacks the same way (1-3 fallback models).
35
+ Call oc_configure with subcommand "assign" for each group.
36
+
37
+ If the assign response contains diversityWarnings, explain them
38
+ conversationally. Strong warnings should be highlighted — the user can
39
+ still proceed, but make the quality trade-off clear.
40
+
41
+ After all 8 groups are assigned, call oc_configure with subcommand "commit"
42
+ to persist the configuration.
43
+
44
+ End by showing the final summary table and running the "doctor" subcommand
45
+ to verify everything is healthy.
@@ -0,0 +1,35 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="120" height="120">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
4
+ <stop offset="0%" stop-color="#6366f1"/>
5
+ <stop offset="100%" stop-color="#8b5cf6"/>
6
+ </linearGradient>
7
+ <linearGradient id="ring" x1="0%" y1="0%" x2="100%" y2="100%">
8
+ <stop offset="0%" stop-color="#c4b5fd"/>
9
+ <stop offset="100%" stop-color="#a78bfa"/>
10
+ </linearGradient>
11
+ </defs>
12
+ <!-- Background circle -->
13
+ <circle cx="60" cy="60" r="56" fill="url(#bg)"/>
14
+ <!-- Outer ring -->
15
+ <circle cx="60" cy="60" r="48" fill="none" stroke="url(#ring)" stroke-width="2.5" opacity="0.6"/>
16
+ <!-- Compass/autopilot crosshair -->
17
+ <line x1="60" y1="20" x2="60" y2="38" stroke="#e0e7ff" stroke-width="2.5" stroke-linecap="round"/>
18
+ <line x1="60" y1="82" x2="60" y2="100" stroke="#e0e7ff" stroke-width="2.5" stroke-linecap="round"/>
19
+ <line x1="20" y1="60" x2="38" y2="60" stroke="#e0e7ff" stroke-width="2.5" stroke-linecap="round"/>
20
+ <line x1="82" y1="60" x2="100" y2="60" stroke="#e0e7ff" stroke-width="2.5" stroke-linecap="round"/>
21
+ <!-- Center diamond (autopilot indicator) -->
22
+ <polygon points="60,42 72,60 60,78 48,60" fill="none" stroke="#fff" stroke-width="2.5" stroke-linejoin="round"/>
23
+ <!-- Inner direction arrow (north pointer) -->
24
+ <polygon points="60,42 54,58 60,54 66,58" fill="#fff" opacity="0.95"/>
25
+ <!-- Code brackets -->
26
+ <text x="34" y="64" font-family="monospace" font-size="18" font-weight="bold" fill="#c4b5fd" opacity="0.7">&lt;</text>
27
+ <text x="78" y="64" font-family="monospace" font-size="18" font-weight="bold" fill="#c4b5fd" opacity="0.7">/&gt;</text>
28
+ <!-- Orbital dots (agent indicators) -->
29
+ <circle cx="60" cy="14" r="3" fill="#a78bfa"/>
30
+ <circle cx="100" cy="40" r="2.5" fill="#c4b5fd"/>
31
+ <circle cx="100" cy="80" r="2.5" fill="#c4b5fd"/>
32
+ <circle cx="60" cy="106" r="3" fill="#a78bfa"/>
33
+ <circle cx="20" cy="80" r="2.5" fill="#c4b5fd"/>
34
+ <circle cx="20" cy="40" r="2.5" fill="#c4b5fd"/>
35
+ </svg>