Skip to content

feat(middleware): implement OpenCodeCliRuntime concrete class (#16)#17

Merged
alexey-pelykh merged 1 commit intomainfrom
feat/opencode-cli-runtime
Feb 25, 2026
Merged

feat(middleware): implement OpenCodeCliRuntime concrete class (#16)#17
alexey-pelykh merged 1 commit intomainfrom
feat/opencode-cli-runtime

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

  • Implement OpenCodeCliRuntime extending CLIRuntimeBase — spawns opencode run --format json and maps per-line envelope NDJSON output to AgentEvent instances
  • Implement OpenCodeMcpConfigManager with merge-restore pattern on .opencode/config.json (same approach as Gemini/Codex)
  • Add comprehensive test suite with 33 tests covering all specified categories (buildArgs, extractEvent, buildEnv, done enrichment, MCP config)

Key design decisions:

  • Text events are complete parts (no delta tracking needed, simpler than Codex)
  • Tool events combine use + result in a single NDJSON line; uses pending events buffer drain in execute() override
  • Usage, cost, and stop reason captured from step_finish events
  • supportsStdinPrompt defaults to true (not overridden)
  • Prompt included on session resume (unlike Codex)

Test plan

  • All 33 unit tests pass (npx vitest run src/middleware/runtimes/opencode.test.ts)
  • Format check passes (pnpm format:check)
  • Type check passes (pnpm tsgo)
  • Lint passes (pnpm lint)
  • CI build + test jobs pass

Closes #16

🤖 Generated with Claude Code

Fourth CLIRuntimeBase subclass — spawns `opencode run --format json`
and maps per-line envelope NDJSON output to AgentEvent instances.

Key features:
- Complete text parts (no delta tracking needed)
- Combined tool_use + tool_result via pending events buffer drain
- Usage/cost/stopReason from step_finish events
- OpenCodeMcpConfigManager with merge-restore on .opencode/config.json
- 33 tests covering all specified categories

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-pelykh alexey-pelykh enabled auto-merge (squash) February 25, 2026 15:22
@alexey-pelykh alexey-pelykh merged commit 187c616 into main Feb 25, 2026
5 of 8 checks passed
@alexey-pelykh alexey-pelykh deleted the feat/opencode-cli-runtime branch February 25, 2026 15:43
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.

Implement OpenCodeCliRuntime concrete class

1 participant