Skip to content

Add OpenCode agent support#415

Open
peyton-alt wants to merge 4 commits intomainfrom
feat/add-opencode
Open

Add OpenCode agent support#415
peyton-alt wants to merge 4 commits intomainfrom
feat/add-opencode

Conversation

@peyton-alt
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 19, 2026 02:44
@cursor
Copy link

cursor bot commented Feb 19, 2026

PR Summary

Medium Risk
Adds a new agent and touches shared transcript scoping/condensation paths used by explain and summarization. Risk is mostly integration/format-parsing correctness and hook execution reliability rather than security-critical logic.

Overview
Adds a new OpenCode agent integration with a Bun-loaded OpenCode plugin that emits lifecycle hooks (session/turn start/end, compaction) and writes .opencode/sessions/entire/<session>.json transcripts with an API-to-in-memory fallback for shutdown safety.

Introduces cmd/entire/cli/agent/opencode implementing hook install/uninstall/idempotency, hook event parsing into normalized agent.Events, and JSON transcript parsing for prompt extraction, modified-file detection from tool parts, token usage calculation, and transcript chunk/reassembly.

Wires OpenCode into existing CLI flows by registering the agent, enabling transcript scoping/counting in explain, adding OpenCode-aware condensation in summarize, detecting agent type from .opencode, and including OpenCode hook cleanup in disable --uninstall.

Written by Cursor Bugbot for commit 64e61d8. Configure here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds first-class OpenCode agent support to Entire CLI, integrating OpenCode lifecycle hooks and transcript parsing so sessions can be captured, condensed, and explained similarly to existing Claude Code and Gemini CLI flows.

Changes:

  • Registers a new opencode agent and implements hook installation/uninstallation via an embedded OpenCode plugin template.
  • Adds OpenCode transcript parsing/slicing plus token and prompt extraction, and wires OpenCode support into summarize/explain and manual-commit condensation paths.
  • Extends uninstall/status-related messaging and detection to include OpenCode agent hooks.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
cmd/entire/cli/summarize/summarize.go Adds OpenCode transcript condensation logic for summarize/explain prompt extraction.
cmd/entire/cli/strategy/manual_commit_condensation.go Adds OpenCode parsing for transcript item counting, prompt extraction, and token usage calculation.
cmd/entire/cli/strategy/common.go Detects OpenCode agent type from git trees for shadow-branch scenarios.
cmd/entire/cli/setup.go Includes OpenCode in uninstall detection and hook removal output.
cmd/entire/cli/hooks_cmd.go Ensures the OpenCode agent package is imported/registered for hook command registration.
cmd/entire/cli/explain.go Scopes OpenCode transcripts by message index (JSON) rather than line index (JSONL).
cmd/entire/cli/agent/registry.go Adds AgentNameOpenCode / AgentTypeOpenCode identifiers.
cmd/entire/cli/agent/opencode/opencode.go Implements the OpenCode agent (identity, transcript storage/chunking, legacy session methods).
cmd/entire/cli/agent/opencode/transcript.go Implements OpenCode transcript parsing, slicing, prompt/file extraction, and token usage aggregation.
cmd/entire/cli/agent/opencode/types.go Defines OpenCode transcript and hook payload types.
cmd/entire/cli/agent/opencode/lifecycle.go Maps OpenCode hook verbs into normalized lifecycle events.
cmd/entire/cli/agent/opencode/hooks.go Implements hook support by installing/removing the OpenCode plugin file.
cmd/entire/cli/agent/opencode/plugin.go Embeds the OpenCode plugin template into the Go binary.
cmd/entire/cli/agent/opencode/entire_plugin.ts OpenCode plugin implementation that writes transcripts and calls entire hooks opencode ....
cmd/entire/cli/agent/opencode/*_test.go Adds unit tests for transcript parsing, lifecycle parsing, and hook install/uninstall behaviors.

Comment on lines 487 to 490
// Check for OpenCode config
if _, err := tree.Tree(".opencode"); err == nil {
return agent.AgentTypeOpenCode
}
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadAgentTypeFromTree detects OpenCode only via the presence of a .opencode tree entry, but OpenCodeAgent.DetectPresence also treats a repo-root opencode.json as a presence signal. If opencode.json is the only committed config (and .opencode is gitignored), shadow-branch detection will incorrectly fall back to Unknown. Consider also checking for tree.File("opencode.json") here to keep agent detection consistent.

Suggested change
// Check for OpenCode config
if _, err := tree.Tree(".opencode"); err == nil {
return agent.AgentTypeOpenCode
}
// Check for OpenCode config (either .opencode directory or repo-root opencode.json)
if _, err := tree.Tree(".opencode"); err == nil {
return agent.AgentTypeOpenCode
}
if _, err := tree.File("opencode.json"); err == nil {
return agent.AgentTypeOpenCode
}

Copilot uses AI. Check for mistakes.
@peyton-alt
Copy link
Contributor Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

@peyton-alt peyton-alt marked this pull request as ready for review February 19, 2026 03:49
@peyton-alt peyton-alt requested a review from a team as a code owner February 19, 2026 03:49
* use tmpDir for generated OpenCode session logs, we don't need them to stay around

Entire-Checkpoint: 5c2efb4784e9

* use JSONL instead of JSON, some test fixes

Entire-Checkpoint: 61dc94e5a51e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments