Skip to content

Comments

OpenCode transcript refactor#445

Open
Soph wants to merge 10 commits intomainfrom
soph/opencode-refactor
Open

OpenCode transcript refactor#445
Soph wants to merge 10 commits intomainfrom
soph/opencode-refactor

Conversation

@Soph
Copy link
Collaborator

@Soph Soph commented Feb 20, 2026

This refactor changes how OpenCode transcript handling works. Previously, the TypeScript plugin wrote JSON/JSONL transcripts to temp files and passed the file paths to hooks.

Now, the plugin only sends the session ID, and the Go hook handler calls opencode export directly to get the native JSON format. This eliminates race conditions between plugin shutdown and the hook reading the transcript, and ensures full data fidelity by using OpenCode's own export format.

This means we are not creating an artificial JSONL that is not compatible to our rendering for Claude Code JSONL anyway, and we are not generating our own OpenCode style JSON file with the risk of breaking imports in the future.

Also the old approach had an issue that we want the full log on each checkpoint, so if you resume/rewind we can restore the context before the last prompt too. The initial implementation only capture the log from the start of the last prompt.

Main things:

  • using opencode export to get the full logs so we can store them
  • removed the export.json logic completely and only use the logs from ☝️
  • there was a bug with file_path being used and not filePath that broken checkpointing when only existing files were edited by tooling. New files worked (need to look at e2e test later if we need to make sure we have that...)

@Soph Soph requested a review from a team as a code owner February 20, 2026 13:38
Copilot AI review requested due to automatic review settings February 20, 2026 13:38
@cursor
Copy link

cursor bot commented Feb 20, 2026

PR Summary

Medium Risk
Changes the transcript source-of-truth and parsing/chunking logic for OpenCode, plus introduces dependency on the opencode CLI at runtime; failures could break checkpoint creation, resume/rewind, or modified-file detection.

Overview
Refactors OpenCode transcript capture to rely on OpenCode’s native opencode export JSON rather than plugin-written JSONL/temp transcript files. The TS plugin now sends only session_id (and prompt on turn start), and the Go hook handler exports/caches the full session transcript into .entire/tmp/<session>.json on turn-end for checkpointing, chunking/reassembly, summarization, and file-change extraction.

Updates the OpenCode agent’s parsing/analysis pipeline to operate on export JSON (ExportSession/parts-based text extraction, camelCase filePath tool inputs) and adjusts condensation/summarize paths to slice/count OpenCode transcripts by message index. Adds integration-test support via ENTIRE_TEST_OPENCODE_MOCK_EXPORT plus a new resumed-session-after-commit test, and extends entire clean to list/delete .entire/tmp cached files.

Written by Cursor Bugbot for commit ec397ef. 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 refactors OpenCode transcript handling to use OpenCode's native export JSON format instead of plugin-generated JSONL. The TypeScript plugin now only sends the session ID to hooks, and the Go handler calls opencode export directly to obtain the full transcript. This architectural change eliminates race conditions between plugin shutdown and hook execution, ensures full data fidelity, and captures complete context on each checkpoint (not just from the last prompt).

Changes:

  • TypeScript plugin simplified to remove transcript generation logic and only send session_id
  • Go lifecycle handler now calls opencode export and caches results in .entire/tmp/
  • All OpenCode transcript parsing changed from JSONL line-by-line format to export JSON structure
  • Added temp file cleanup to entire clean command
  • Updated all tests to use export JSON format instead of JSONL

Reviewed changes

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

Show a summary per file
File Description
cmd/entire/cli/agent/opencode/entire_plugin.ts Removed transcript generation logic; plugin now only sends session_id
cmd/entire/cli/agent/opencode/lifecycle.go Added fetchAndCacheExport to call opencode export and cache results
cmd/entire/cli/agent/opencode/types.go Changed from JSONL Message type to export JSON ExportSession/ExportMessage types
cmd/entire/cli/agent/opencode/transcript.go Replaced ParseMessages with ParseExportSession; added SliceFromMessage helper
cmd/entire/cli/agent/opencode/opencode.go Implemented JSON-based ChunkTranscript/ReassembleTranscript
cmd/entire/cli/agent/opencode/cli_commands.go Added runOpenCodeExport function
cmd/entire/cli/agent/opencode/*_test.go Updated all tests to use export JSON format
cmd/entire/cli/lifecycle.go Removed export JSON copy logic (no longer needed)
cmd/entire/cli/clean.go Added temp file listing and deletion for .entire/tmp/
cmd/entire/cli/clean_test.go Updated test expectations and signatures
cmd/entire/cli/summarize/summarize.go Updated buildCondensedTranscriptFromOpenCode for export JSON
cmd/entire/cli/strategy/manual_commit_condensation.go Added OpenCode case for transcript scoping
cmd/entire/cli/integration_test/*.go Updated all integration tests for export JSON format

@Soph
Copy link
Collaborator Author

Soph commented Feb 20, 2026

@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 6 potential issues.

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

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

Copilot reviewed 30 out of 30 changed files in this pull request and generated 7 comments.

@Soph Soph force-pushed the soph/opencode-refactor branch from 4ab2ee9 to 8addb6e Compare February 20, 2026 17:28
Soph added 4 commits February 20, 2026 18:29
Entire-Checkpoint: 938d1244c4c6
…sn't written

Entire-Checkpoint: 1b33ad469161
Entire-Checkpoint: 8606b4e2a007
Entire-Checkpoint: 03bc551af447
@Soph Soph force-pushed the soph/opencode-refactor branch from 8addb6e to c38639a Compare February 20, 2026 17:29
@entireio entireio deleted a comment from Copilot AI Feb 20, 2026
@entireio entireio deleted a comment from Copilot AI Feb 20, 2026
Soph added 3 commits February 20, 2026 18:54
Entire-Checkpoint: 5e0994673a26
# Conflicts:
#	cmd/entire/cli/rewind.go
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.

1 participant