Skip to content

feat: add OpenCode integration for decision-record pipeline#6

Merged
mabry1985 merged 3 commits into
mainfrom
open-code-adapter
May 19, 2026
Merged

feat: add OpenCode integration for decision-record pipeline#6
mabry1985 merged 3 commits into
mainfrom
open-code-adapter

Conversation

@gnostichumor
Copy link
Copy Markdown
Collaborator

@gnostichumor gnostichumor commented May 18, 2026

Summary

Adds full OpenCode support to the decision-record planning pipeline. All changes are additive — existing Claude Code configs remain untouched.

Files Added

File Purpose
opencode.json Main config: MCP server registration, 3 agents, /plan command, default agent
.opencode/agents/dr-wizard.md Primary orchestrator agent (intake → handoff)
.opencode/agents/dr-skeptic.md Subagent for decision review (read-only, edit: deny)
.opencode/agents/dr-decomposer.md Subagent for task graph decomposition
.opencode/commands/plan.md /plan command adapted for OpenCode
setup-opencode.sh Installer script for adding the pipeline to any existing project

Key Adaptations from Claude Code

  • MCP format: type: "local" with command array instead of .mcpServers
  • Agent permissions: permission: system with allow/deny instead of tools: list
  • Model names: Full anthropic/claude-sonnet-4-20250514 instead of sonnet
  • Subagent invocation: @dr-skeptic syntax instead of Task(subagent_type: ...)
  • Color values: Hex codes instead of color names (required by OpenCode schema)

Setup Script

setup-opencode.sh automates adding the pipeline to any existing project:

./setup-opencode.sh /path/to/your/project

Runs 6 steps: prerequisite check → copy configs → copy server → build → validate → smoke test.

Testing

  • 20/20 integration tests pass (config, agents, MCP server, pipeline tools, gate evaluation)
  • Verified with opencode run --model opencode-go/kimi-k2.5 — dr-wizard loads, MCP connects, intake starts
  • Setup script tested on fresh directories, idempotent re-runs, and no-argument mode

Summary by CodeRabbit

  • New Features

    • Introduced a decision-record planning pipeline with specialized AI agents for orchestration, review, and task decomposition.
    • Added /plan command for idea-to-MVP workflows with five gated phases.
  • Documentation

    • Added pipeline specifications and workflow guidelines.
  • Chores

    • Added automated setup script for project provisioning.

Review Change Stack

- Add opencode.json with MCP server registration, agent definitions, and /plan command
- Add .opencode/agents/dr-wizard.md (primary orchestrator agent)
- Add .opencode/agents/dr-skeptic.md (subagent for decision review)
- Add .opencode/agents/dr-decomposer.md (subagent for task decomposition)
- Add .opencode/commands/plan.md (pipeline command adapted for opencode)

All changes are additive and maintain compatibility with existing Claude Code configs.
Automates adding the decision-record pipeline to an existing project:
1. Validates prerequisites (node >= 20, npm, opencode)
2. Copies opencode.json and .opencode/ (agents + commands)
3. Copies MCP server source into target/server/
4. Installs dependencies and builds the MCP server
5. Validates opencode configuration
6. Runs smoke test against MCP server (init + tool listing)

Usage:
  ./setup-opencode.sh [target-dir]

Idempotent: warns and confirms before overwriting existing files,
skips server/ copy if already present.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@gnostichumor has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 43cc86b2-4d00-45b4-92e0-7316b3d0ee87

📥 Commits

Reviewing files that changed from the base of the PR and between 08de21b and 13fdf3d.

⛔ Files ignored due to path filters (2)
  • CONTRIBUTING.md is excluded by !*.md
  • README.md is excluded by !*.md
📒 Files selected for processing (3)
  • docs/README.md
  • docs/how-to/install.md
  • docs/tutorials/your-first-plan.md

Walkthrough

This PR introduces a complete infrastructure for an OpenCode-based decision-record planning pipeline. It adds three orchestrated agents (dr-wizard, dr-skeptic, dr-decomposer) that drive an idea-to-MVP planning workflow, configuration files that wire these agents and MCP tools together, and a setup script that provisions projects with the full pipeline and validates the installation.

Changes

Decision-Record Planning Pipeline

Layer / File(s) Summary
Planning workflow agent specifications and command definition
.opencode/agents/dr-wizard.md, .opencode/agents/dr-skeptic.md, .opencode/agents/dr-decomposer.md, .opencode/commands/plan.md
dr-wizard orchestrates the five-phase planning pipeline with per-turn control flow and delegates to dr-skeptic for antagonistic decision review and to dr-decomposer for task graph decomposition. The /plan command document specifies phases, gates, tool sequences, and artifact locations.
OpenCode configuration and MCP server setup
opencode.json
Defines the MCP decision-record server runner, registers the three subagents with shared model and distinct permission sets, and configures the /plan command with dr-wizard as the driver.
Installation and validation script
setup-opencode.sh
Validates prerequisites (Node.js ≥ 20, npm, opencode CLI), copies configuration files and agent/command definitions, builds the MCP server, and runs smoke tests via JSON-RPC initialize and tools/list calls; prints completion status and next steps.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the primary change: adding OpenCode integration (config, agents, commands, and setup script) for a decision-record planning pipeline.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch open-code-adapter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.opencode/agents/dr-skeptic.md:
- Line 2: The prompt contains a contradiction between the description saying
“one or more lenses” and the later rule that requires a single lens per
invocation; make them consistent by choosing the single‑lens model: update the
description text so it states that the agent evaluates a single specified lens
(operational, strategic, security, cost, or user‑impact) and revise any wording
that permits multiple lenses (e.g., the phrase “one or more lenses” and any
related sentence) to require exactly one lens per call so orchestration is
deterministic; ensure references to “verdict” and “concerns” remain tied to that
single lens.

In `@opencode.json`:
- Around line 19-29: The permission block in opencode.json grants overly-broad
rights (e.g., "bash", "edit", "glob", "grep", "task", "todowrite",
"decision-record_*")—restrict these to least privilege for the DR pipeline by
removing any tool scopes not required by the documented workflow and only
keeping minimal entries like "read" and the specific capability names the
pipeline actually needs; update every similar permission object (the other
blocks mentioned) to mirror the tightened set and validate that callers of the
permissioned features (check code referencing the "permission" object) still
function with the reduced rights.

In `@setup-opencode.sh`:
- Around line 134-136: The success message "opencode.json syntax validated
(JSON)" is misleading when opencode is missing; change the behavior in the block
that currently calls warn "opencode not installed — skipping config validation"
and ok "opencode.json syntax validated (JSON)" so that either (A) perform a real
JSON parse (e.g., run python3 -m json.tool or jq to validate opencode.json
before emitting ok) or (B) replace the ok message with a clear skip message like
"opencode.json validation skipped (opencode not installed)"; update the branch
that uses warn and ok to implement one of these fixes and ensure the strings
"opencode.json syntax validated (JSON)" and "opencode not installed — skipping
config validation" are adjusted accordingly.
- Around line 128-132: The script currently masks failures by appending "||
true" to the opencode models call; instead run opencode models capturing
stdout/stderr into VALIDATION_OUTPUT and capture its exit code ($?), then if the
exit code is non‑zero call fail with a message that includes VALIDATION_OUTPUT
(use the same fail function) and only if the exit code is zero proceed to
inspect VALIDATION_OUTPUT with grep for "error|invalid" and call fail or ok
accordingly; update references to VALIDATION_OUTPUT, the opencode models
invocation, and the fail/ok calls to implement this exit‑code first logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 75a11a6a-0406-479b-b789-ac628ad9cdfe

📥 Commits

Reviewing files that changed from the base of the PR and between 1687b08 and 08de21b.

📒 Files selected for processing (6)
  • .opencode/agents/dr-decomposer.md
  • .opencode/agents/dr-skeptic.md
  • .opencode/agents/dr-wizard.md
  • .opencode/commands/plan.md
  • opencode.json
  • setup-opencode.sh

@@ -0,0 +1,65 @@
---
description: Antagonistic reviewer for decision records. Given a DR with a selected position and argument, returns a verdict (pass/block) and concerns from one or more lenses (operational, strategic, security, cost, user-impact).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Resolve lens-scope contradiction in the prompt.

Line 2 allows “one or more lenses,” but Line 59 requires one lens per invocation. Please make these consistent so orchestration behavior is deterministic.

Also applies to: 59-59

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.opencode/agents/dr-skeptic.md at line 2, The prompt contains a
contradiction between the description saying “one or more lenses” and the later
rule that requires a single lens per invocation; make them consistent by
choosing the single‑lens model: update the description text so it states that
the agent evaluates a single specified lens (operational, strategic, security,
cost, or user‑impact) and revise any wording that permits multiple lenses (e.g.,
the phrase “one or more lenses” and any related sentence) to require exactly one
lens per call so orchestration is deterministic; ensure references to “verdict”
and “concerns” remain tied to that single lens.

Comment thread opencode.json
Comment on lines +19 to +29
"permission": {
"read": "allow",
"edit": "allow",
"bash": "allow",
"glob": "allow",
"grep": "allow",
"list": "allow",
"task": "allow",
"todowrite": "allow",
"decision-record_*": "allow"
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Tighten agent permissions to least privilege before release.

Current permissions grant broad capabilities (bash, edit, webfetch) that are not required by the documented pipeline flow. This increases blast radius if an agent is prompt-injected or misused. Restrict each agent to only the tools it must use for the DR workflow.

Also applies to: 36-44, 51-60

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@opencode.json` around lines 19 - 29, The permission block in opencode.json
grants overly-broad rights (e.g., "bash", "edit", "glob", "grep", "task",
"todowrite", "decision-record_*")—restrict these to least privilege for the DR
pipeline by removing any tool scopes not required by the documented workflow and
only keeping minimal entries like "read" and the specific capability names the
pipeline actually needs; update every similar permission object (the other
blocks mentioned) to mirror the tightened set and validate that callers of the
permissioned features (check code referencing the "permission" object) still
function with the reduced rights.

Comment thread setup-opencode.sh
Comment on lines +128 to +132
VALIDATION_OUTPUT=$(opencode models 2>&1 || true)
if echo "$VALIDATION_OUTPUT" | grep -qi "error\|invalid"; then
fail "opencode config validation failed:\n$VALIDATION_OUTPUT"
fi
ok "opencode configuration is valid"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
# Verify whether this repo currently ignores opencode validation exit codes.
# Expected: find the `|| true` usage in setup-opencode.sh at validation step.
rg -n -C2 'opencode models|\\|\\| true|VALIDATION_OUTPUT' setup-opencode.sh

Repository: protoLabsAI/protoLedger

Length of output: 639


Do not ignore opencode models exit status.

The || true on line 128 suppresses command failures, allowing validation to pass even when CLI validation fails without matching the grep pattern. Check the exit code first, then inspect output if needed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@setup-opencode.sh` around lines 128 - 132, The script currently masks
failures by appending "|| true" to the opencode models call; instead run
opencode models capturing stdout/stderr into VALIDATION_OUTPUT and capture its
exit code ($?), then if the exit code is non‑zero call fail with a message that
includes VALIDATION_OUTPUT (use the same fail function) and only if the exit
code is zero proceed to inspect VALIDATION_OUTPUT with grep for "error|invalid"
and call fail or ok accordingly; update references to VALIDATION_OUTPUT, the
opencode models invocation, and the fail/ok calls to implement this exit‑code
first logic.

Comment thread setup-opencode.sh
Comment on lines +134 to +136
warn "opencode not installed — skipping config validation"
ok "opencode.json syntax validated (JSON)"
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove the false “JSON validated” success message.

When opencode is missing, no JSON parse is performed, but Line 135 reports successful syntax validation. Either run an actual parser check (e.g., python3 -m json.tool) or change the message to “validation skipped.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@setup-opencode.sh` around lines 134 - 136, The success message "opencode.json
syntax validated (JSON)" is misleading when opencode is missing; change the
behavior in the block that currently calls warn "opencode not installed —
skipping config validation" and ok "opencode.json syntax validated (JSON)" so
that either (A) perform a real JSON parse (e.g., run python3 -m json.tool or jq
to validate opencode.json before emitting ok) or (B) replace the ok message with
a clear skip message like "opencode.json validation skipped (opencode not
installed)"; update the branch that uses warn and ok to implement one of these
fixes and ensure the strings "opencode.json syntax validated (JSON)" and
"opencode not installed — skipping config validation" are adjusted accordingly.

- README.md: Add OpenCode as third interface option, update directory structure
- docs/how-to/install.md: Add full OpenCode installation section with quick install, script steps, after-install usage, and manual install instructions
- docs/README.md: Add OpenCode install link to how-to index
- CONTRIBUTING.md: Mention OpenCode in project description and add as contribution area
- docs/tutorials/your-first-plan.md: Add OpenCode as alternative to CLI in prerequisites and next steps
@mabry1985 mabry1985 merged commit 54053a8 into main May 19, 2026
3 checks passed
@mabry1985 mabry1985 deleted the open-code-adapter branch May 19, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants