Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds OpenCode as a third supported AI coding agent alongside Claude Code and Gemini CLI. The implementation follows the established agent abstraction pattern and includes comprehensive testing and documentation.
Changes:
- New OpenCode agent package with TypeScript plugin, hook handlers, transcript parsing, and token usage calculation
- Hook lifecycle handlers for session-start, stop, task-start, and task-complete events
- Refactored agent hook management from hardcoded checks to registry-based iteration in
setup.go
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/agent/opencode/*.go | OpenCode agent implementation (hooks, transcript parsing, types) |
| cmd/entire/cli/agent/opencode/entire.ts | Embedded TypeScript plugin for OpenCode's plugin system |
| cmd/entire/cli/hooks_opencode_handlers.go | Hook lifecycle event handlers for OpenCode sessions |
| cmd/entire/cli/hook_registry.go | Hook registration for OpenCode events |
| cmd/entire/cli/state.go | Pre-prompt state capture for OpenCode JSONL transcripts |
| cmd/entire/cli/strategy/manual_commit_condensation.go | OpenCode-specific prompt extraction and token usage |
| cmd/entire/cli/setup.go | Refactored agent hook management to use registry pattern |
| cmd/entire/cli/summarize/summarize.go | OpenCode condensed transcript placeholder (not yet implemented) |
| cmd/entire/cli/integration_test/*.go | Comprehensive integration tests for OpenCode workflows |
| README.md | Documentation updates for OpenCode support |
| // Resolve the entire binary path once at load time. | ||
| // Supports ENTIRE_BIN env var override for development/testing. | ||
| function resolveBinary(): string { | ||
| const envBin = process.env.ENTIRE_BIN; | ||
| if (envBin) return envBin; | ||
| try { | ||
| return execSync("which entire", { encoding: "utf-8" }).trim(); | ||
| } catch { | ||
| return "entire"; | ||
| } | ||
| } | ||
|
|
||
| const entireBin = resolveBinary(); |
There was a problem hiding this comment.
The PR description states that the ENTIRE_BIN environment variable is "set by hook handlers", but there's no code in hooks_opencode_handlers.go or the hook execution path that actually sets this variable. The resolveBinary function will fall back to using 'which entire' or PATH lookup, which works fine, but the PR description is misleading. Either the description should be corrected to say ENTIRE_BIN is optional (with fallback to PATH), or the hook handlers should actually set this variable for consistency.
Summary
Adds OpenCode as a third supported coding agent alongside Claude Code and Gemini CLI.
opencodeagent package with embedded TypeScript plugin, hook install/uninstall, JSONL transcript parsing, and token usage calculationremoveAgentHooks()from hardcoded agent list to registry-based iterationCleanShot.2026-02-15.at.00.45.16.mp4
How it works
Users enable OpenCode support with:
entire enable --agent opencodeThis installs
.opencode/plugins/entire.ts— a TypeScript plugin that hooks into OpenCode's plugin API and callsentire hooks opencode <event>for each lifecycle event. The plugin exports the session transcript as JSONL to a temp directory for checkpoint metadata extraction.Key design decisions
go:embed'd into the Go binary and written to.opencode/plugins/entire.tsduringInstallHooksos.tmpdir()/entire-opencode/<sessionId>.jsonlusing OpenCode's SDK export APIhandleAfterAgentpattern (notcommitWithMetadata)entire enabledefault unchanged — still defaults to Claude Code. OpenCode requires--agent opencodeentirebinary viaENTIRE_BINenv var (set by hook handlers) with fallback to PATH lookupFiles
cmd/entire/cli/agent/opencode/(8 files)hooks_opencode_handlers.go,hook_registry.gostate.go(CaptureOpencodePrePromptState)strategy/manual_commit_condensation.gointegration_test/(4 files)setup.go,hooks_cmd.go,registry.goTesting
-raceflag