Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new entire attach <session-id> command to retroactively capture an agent session (from an existing transcript) and turn it into an Entire checkpoint + tracked session.
Changes:
- Registers a new
attachCobra command and implements session attachment + checkpoint creation/condensation flow. - Adds transcript-path fallback logic to search Claude project directories when sessions were started from subdirectories.
- Adds unit tests covering several
attachscenarios (missing args, transcript missing, success path, duplicate session, output includes trailer).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| cmd/entire/cli/transcript.go | Adds helper functions to locate session transcripts (including subdirectory search). |
| cmd/entire/cli/root.go | Registers the new attach command on the root CLI. |
| cmd/entire/cli/attach.go | Implements attach end-to-end: resolve transcript, extract files/prompt, save checkpoint, condense, optionally amend commit. |
| cmd/entire/cli/attach_test.go | Introduces unit tests for attach behaviors and outputs. |
Comments suppressed due to low confidence (1)
cmd/entire/cli/transcript.go:96
- sanitizePathForSearch does not match Claude Code's SanitizePathForClaude behavior for non-ASCII paths (this implementation replaces each UTF-8 byte with '-', while SanitizePathForClaude replaces each non-alphanumeric rune once via regex). This can cause searchTranscriptInSubdirs to compute the wrong repoPrefix and fail to find transcripts for repos under paths containing non-ASCII characters. Prefer reusing the existing sanitizer (e.g., paths.SanitizePathForClaude / claudecode.SanitizePathForClaude) instead of duplicating the logic here.
}
// FindCheckpointUUID finds the UUID of the message containing the tool_result
// for the given tool_use_id. This is used to find the checkpoint point for
// transcript truncation when rewinding to a task.
// Returns the UUID and true if found, empty string and false otherwise.
func FindCheckpointUUID(transcript []transcriptLine, toolUseID string) (string, bool) {
for _, line := range transcript {
if line.Type != transcriptTypeUser {
continue
}
var msg userMessageWithToolResults
8 tasks
524be76 to
aa41eb3
Compare
Add searchTranscriptInProjectDirs to search for session transcripts across an agent's project directories when the primary lookup fails. This handles cases where sessions were started from subdirectories (different CWD hash). Also fix parameter shadowing of the transcript package by renaming transcript params to lines, and remove the now-unnecessary local type alias. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 750296d02171
When a session's UserPromptSubmit hook doesn't fire (e.g. Factory AI Droid exec mode), the TurnEnd handler now backfills prompt.txt by extracting the first user prompt from the transcript. This ensures checkpoint metadata includes the prompt even for agents that skip hook invocations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 031fc80a52d1
Implement the `entire attach` command that imports an existing agent session transcript into the Entire tracking system. Features include: - Resolve transcripts across agent types (Claude Code, Gemini CLI, OpenCode, Cursor, Copilot CLI, Factory AI Droid) - Auto-detect agent from transcript when --agent flag is wrong - Normalize Gemini transcripts (convert content arrays to strings) while preserving all other fields - Single-pass transcript metadata extraction (prompt, turns, model) - Create checkpoint with file change detection - Offer to amend the last commit with Entire-Checkpoint trailer - Support --force flag for non-interactive use - Depth-limited directory walking for transcript search fallback Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 97c75100bbac
- Fix appendCheckpointTrailer false positive on body text containing ": " by using a strict git trailer regex (^[A-Za-z][A-Za-z0-9-]*: ) instead of a loose strings.Contains check - Return error explicitly when OpenRepository fails instead of silently continuing past the empty-repo guard - Add debug logging in detectAgentByTranscript for failed agent attempts to aid troubleshooting - Refactor runAttach into smaller helpers to resolve maintidx lint (validateAttachPreconditions, resolveAgentAndTranscript, collectFileChanges, storeTranscript, printAttachConfirmation) - Wrap json.MarshalIndent return to resolve wrapcheck lint - Remove unnecessary tt := tt loop variable capture (Go 1.22+) - Add test case for body text with ": " not being treated as trailer Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 23d9d11d11e7
a110eeb to
678c636
Compare
Address PR #688 review feedback by breaking up attach.go (669→459 lines) and relocating misplaced concerns to their proper packages: - Move trailer manipulation (AppendCheckpointTrailer, IsTrailerLine) to trailers package where other trailer operations live - Move normalizeGeminiTranscript to geminicli.NormalizeTranscript since it's Gemini-specific transcript logic - Extract transcript utilities (extractTranscriptMetadata, estimateSessionDuration) to attach_transcript.go - Replace hardcoded agentSessionBaseDirs map with SessionBaseDirProvider optional interface on Agent, implemented by Claude Code, Gemini CLI, Cursor, and Factory AI Droid - Fix storeTranscript parameter ordering: ctx first per Go convention - Distinguish "detection failed" from "no changes found" in attach output - Switch estimateSessionDuration from bytes.Split to bufio.Scanner - Simplify resolveAndValidateTranscript by removing redundant agentName parameter Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 475f14207459
…ogic - Revert estimateSessionDuration from bufio.Scanner back to bytes.Split: Scanner has a 64KB default line limit that silently truncates large JSONL lines (tool results can easily exceed this). Since data is already in memory, bytes.Split has no memory overhead and no limit. - Remove dual-context (ctx, logCtx) from collectFileChanges, matching the fix already applied to storeTranscript. No other function in the codebase takes two context parameters. - Replace addCheckpointTrailer in manual_commit_hooks.go with a one-line delegation to trailers.AppendCheckpointTrailer, eliminating 55 lines of duplicated trailer-appending logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 874d71c3e4a0
Entire-Checkpoint: 7e8f69399bbe
Cursor and Factory AI Droid both use JSONL transcripts and support GetSessionBaseDir for fallback transcript search, but had no attach test coverage. Add tests verifying: - Cursor flat layout attach (CLI-style <id>.jsonl) - Cursor nested layout attach (IDE-style <id>/<id>.jsonl) - Factory AI Droid flat layout attach Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 5d90be021b38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
attachcommand accessible viaentire attach <session-id>. Enables users to retroactively capture an agent session that wasn't tracked (ie if the agent was created outside of the project's root directory).The attach command allows for an optional
-aor--agentflag to set the agent. It can auto-detect the agent type for sessions from Gemini and Claude. It also allows for a-for--forceflag that will append the agent session to the user's last commit message. Otherwise, the user has the option to either append or copy the checkpoint ID themselves via the dialog prompts.Notes/known issues
session_turn_countdefaults to 0 if we can't find it in the metadata. I don't believe we display the session turns in the UI (we display steps) so I don't believe this is presented to the user. That data is not always captured - not sure how big of a deal this is for the first pass through/version for this command.attachcommand works for Opencode sessions that weren't tracked in the project folder (say, if Entire was enabled after Opencode was installed), but it won't detect Opencode sessions from folders outside the project. (attachdoesn't care about folder location for other agents: this is isolated to Opencode atm)Test plan
entire attach <real-session-id>with Claude sessionsentire attach --force <session-id>amends the latest commit without promptingentire attach --agent gemini <session-id>with Gemini sessionsentire attach --agent factoryai-droid <session-id>with Droid sessionsentire attach --agent cursor <session-id>with Cursor sessionsentire attach <gemini-session-id>with Gemini sessionsentire rewindworks on attach-created checkpoints