Skip to content

[Spec 178] Support OpenCode as an alternative agent shell - #663

Merged
waleedkadous merged 10 commits into
mainfrom
builder/spir-178-support-opencode-as-an-alterna
Apr 12, 2026
Merged

waleedkadous merged 10 commits into
mainfrom
builder/spir-178-support-opencode-as-an-alterna

Conversation

@waleedkadous

Copy link
Copy Markdown
Contributor

Summary

Add first-class OpenCode support as an alternative agent shell in Codev's agent farm. OpenCode supports 75+ LLM providers, giving users flexibility beyond Claude Code.

Changes

  • Harness provider (harness.ts): New OPENCODE_HARNESS built-in provider with getWorktreeFiles() for file-based role injection via opencode.json. buildRoleInjection() throws for architect use (builder-only). Auto-detection recognizes opencode basename. Optional getWorktreeFiles?() method added to HarnessProvider interface (backward-compatible).
  • Spawn integration (spawn-worktree.ts): Both startBuilderSession() and buildWorktreeLaunchScript() call getWorktreeFiles() when available. JSON merge strategy preserves existing opencode.json config (e.g., permissions) while adding instructions.
  • Doctor validation (doctor.ts): OpenCode added to AI_DEPENDENCIES and VERIFY_CONFIGS. Warns if OpenCode configured as architect shell.
  • Documentation (README.md): New "Alternative Agent Shells" section with configuration examples, permission setup, and known differences.

Testing

  • 51 harness unit tests (12 new for OpenCode)
  • 64 spawn-worktree unit tests (4 new for OpenCode merge/script behavior)
  • All 2331 tests passing, 0 regressions
  • 3-way consultation (Gemini, Codex, Claude) approved all 3 phases

Spec

Link: codev/specs/178-support-opencode-as-an-alterna.md

Review

Link: codev/reviews/178-support-opencode-as-an-alterna.md

@waleedkadous

Copy link
Copy Markdown
Contributor Author

Architect Integration Review

Excellent implementation — all three reviewers confirm existing harnesses (Claude, Codex, Gemini) are completely unaffected. The getWorktreeFiles?() pattern is clean and backward-compatible. Well done.

Three changes needed before merge:

1. Repository pollution via opencode.json (Gemini — HIGH)

The injected opencode.json (with its ephemeral .builder-role.md reference) will get committed back to main when the builder runs git add. This is the same problem the spec explicitly avoided for AGENTS.md but missed for opencode.json.

Fix options:

  • git update-index --skip-worktree opencode.json for tracked files
  • Add to .git/info/exclude for untracked files
  • Or investigate if OpenCode supports a custom config path via env var

2. JSONC parse safety (Codex — HIGH)

writeWorktreeFiles uses JSON.parse() on existing opencode.json, but OpenCode's config supports JSONC (comments, trailing commas). Parse failure currently falls through to overwrite — which destroys the user's config. Fix by failing safely: warn and don't overwrite when parse fails.

3. Field name inconsistency (Claude — MEDIUM)

README uses permission (singular), spec/plan/tests use permissions (plural). One is wrong for OpenCode's actual schema. The wrong one causes silent builder failures (hung on permission prompts). Please verify against OpenCode's docs and make it consistent everywhere.

@waleedkadous
waleedkadous merged commit 7f0ae11 into main Apr 12, 2026
6 checks passed
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.

1 participant