Repository navigation
Support OpenCode #9
Description
Activity
Thanks for opening the issue. We've been gauging demand for which coding agents to support next, and opening an issue is probably the clearest signal that demand exists.
We'll start work on integrating OpenCode ASAP.
Hey @kushagrchitkar, saw this is assigned to you already. Let me know if you're mid-flight on it, otherwise happy to take it.
Plan is to shell out to OpenCode's local server,
opencode serve, which runs on127.0.0.1with no login needed, instead of scraping CLI stdout. It already streams structured SSE events for text, tool calls, tool results, and file edits, which maps pretty directly onto what CodeAlmanac's harness events already look like. Basically the same shape as the Claude adapter, just talking to a different local process instead of an SDK.New harness lives next to the Codex and Claude ones, with the same
check()/run()interface both already implement, so nothing about how the rest of the app calls into harnesses changes.One thing I haven't nailed down: not sure yet if OpenCode's sessions support sub-agent spawning the way CodeAlmanac tracks parent/child runs. Won't block a first PR either way. I'll just note it if it's not there yet.
Hey @d180, this is not on my priority list right now, so you can definitely take this one. One thing I would like for you to keep in mind is that we have recently ported over to python. Apart from that, would be happy to review the PR you land. Thanks!!
Awesome, thanks @kushagrchitkar!
Yeah, I saw the Python port. This will be a plain Python adapter under
integrations/harnesses/opencode/, same as the Codex and Claude ones, so there should be no extra runtime or language added here. The only external dependency is theopencodeCLI itself, which we’ll just shell out to and talk to over HTTP like a subprocess, same as the other harnesses already do.Also closed the loop on the sub-agent question from before. OpenCode already tracks this natively: sessions carry a
parentID, and it is available on the session object plussession.created/session.updatedevents. There was a brief gap where thesession.statusevent did not include it, but that is fixed upstream now. So parent/child sub-agent runs should map straight onto CodeAlmanac’s existingHarnessAgentTracefields without extra plumbing.I’ll get a draft PR up soon.
One thing I'd encourage is also to test if you can access the transcripts for opencode sessions, and how their agents.md injections work.
Transcripts are accessible, but OpenCode stores them differently than Claude and Codex.
Claude and Codex write JSONL logs that we scan line by line. OpenCode instead writes per-session and per-message JSON files under
~/.local/share/opencode/storage/session/{projectHash}/{sessionID}.json. So this is doable as its own discovery adapter, just not as a drop-in reuse of the existing JSONL scanner.For
AGENTS.md, OpenCode reads from a global~/.config/opencode/AGENTS.md, and falls back to~/.claude/CLAUDE.mdif that is missing. That is exactly the file our Claude setup already writes to, so there is a chance OpenCode is already picking up our instructions indirectly for anyone who ransetup --runner claude.I’d rather not rely on that, especially since there is an open OpenCode bug around that precedence being flaky. Plan is to write our own explicit managed block in
~/.config/opencode/AGENTS.md, same shape as the Codex adapter.Separately, one scoping question from before that I forgot to ask: the interactive setup wizard picks Codex vs Claude with hardcoded if/else logic, not by looping over harness kinds. So adding OpenCode as a third interactive choice is not a clean one-liner there.
Do you want me to generalize that as part of this PR, or should I ship OpenCode via
setup --runner opencode/ config only and leave the interactive wizard untouched for now?Since this does touch the onboarding wizard, would be great if you could make it part of this PR itself.
Sure, I will implement it accordingly.
Hi @kushagrchitkar , implemented the Opencode harness. Please review and test it and let me know if anything needs attention.
https://opencode.ai/
Good to support this popular open source coding agent.