Skip to content

Support OpenCode #9

Description

@hugogu

https://opencode.ai/

Good to support this popular open source coding agent.

Activity

  1. kushagrchitkar commented on May 16, 2026

    @kushagrchitkar
    Collaborator

    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.

  2. d180 commented on Jul 8, 2026

    @d180

    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 on 127.0.0.1 with 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.

  3. kushagrchitkar commented on Jul 8, 2026

    @kushagrchitkar
    Collaborator

    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!!

  4. d180 commented on Jul 8, 2026

    @d180

    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 the opencode CLI 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 plus session.created / session.updated events. There was a brief gap where the session.status event did not include it, but that is fixed upstream now. So parent/child sub-agent runs should map straight onto CodeAlmanac’s existing HarnessAgentTrace fields without extra plumbing.

    I’ll get a draft PR up soon.

  5. kushagrchitkar commented on Jul 8, 2026

    @kushagrchitkar
    Collaborator

    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.

  6. d180 commented on Jul 8, 2026

    @d180

    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.md if 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 ran setup --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?

  7. kushagrchitkar commented on Jul 8, 2026

    @kushagrchitkar
    Collaborator

    Since this does touch the onboarding wizard, would be great if you could make it part of this PR itself.

  8. d180 commented on Jul 8, 2026

    @d180

    Sure, I will implement it accordingly.

  9. d180 commented on Jul 9, 2026

    @d180

    Hi @kushagrchitkar , implemented the Opencode harness. Please review and test it and let me know if anything needs attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions