Skip to content

feat: implement TranscriptAnalyzer for Cursor agent#537

Open
gtrrz-victor wants to merge 5 commits intomainfrom
gtrrz-victor/fix-commit-message-cursor-shadow-branch
Open

feat: implement TranscriptAnalyzer for Cursor agent#537
gtrrz-victor wants to merge 5 commits intomainfrom
gtrrz-victor/fix-commit-message-cursor-shadow-branch

Conversation

@gtrrz-victor
Copy link
Contributor

@gtrrz-victor gtrrz-victor commented Feb 27, 2026

Summary

  • Implement TranscriptAnalyzer interface for Cursor agent — enables prompt extraction (for shadow branch commit messages), summary extraction, and transcript position tracking. Cursor uses the same JSONL format as Claude Code, so the shared transcript package handles parsing and normalization.
  • ExtractModifiedFilesFromOffset returns ErrNoToolUseBlocks — Cursor transcripts don't contain tool_use blocks, so file detection continues to rely on git status. The sentinel error makes the intent explicit ("can't extract" vs "found nothing").
  • Fix shadow branch fallback commit message — use agent type instead of agent name for the fallback commit message when no prompts are available.

This is how the commits at the shadow branch were looking before:
image
vs now:
image

🤖 Generated with Claude Code

gtrrz-victor and others added 2 commits February 27, 2026 14:25
generateCommitMessage() hardcoded "Claude Code session updates" as the
fallback when no prompt was available. This affected agents like Cursor
that don't implement TranscriptAnalyzer. Now accepts an agentType param
and uses it in the fallback (e.g. "Cursor session updates").

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 749feac02cb6
Cursor uses the same JSONL transcript format as Claude Code. Implement
the TranscriptAnalyzer interface to enable prompt extraction (for shadow
branch commit messages), summary extraction, and transcript position
tracking. ExtractModifiedFilesFromOffset returns ErrNoToolUseBlocks
since Cursor transcripts lack tool_use blocks — file detection continues
to rely on git status.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: b25d9722e24d
Copilot AI review requested due to automatic review settings February 27, 2026 04:02
@gtrrz-victor gtrrz-victor requested a review from a team as a code owner February 27, 2026 04:02
@cursor
Copy link

cursor bot commented Feb 27, 2026

PR Summary

Medium Risk
Moderate risk because it changes how Cursor sessions are parsed for prompts/summaries and alters autogenerated commit-message defaults, which can affect checkpoint metadata and automation behavior (while still relying on git status for file detection).

Overview
Cursor sessions now implement agent.TranscriptAnalyzer, adding transcript position tracking plus extraction of user prompts (for commit messages) and a summary from the last assistant text in the JSONL transcript.

Because Cursor transcripts don’t include tool_use blocks, ExtractModifiedFilesFromOffset explicitly returns a new sentinel ErrNoToolUseBlocks and the system continues to fall back to git-status-based file detection.

Shadow-branch commit message generation now falls back to "<agentType> session updates" (e.g., Cursor/Gemini/OpenCode) instead of a fixed Claude Code string, and tests were updated accordingly.

Written by Cursor Bugbot for commit 44a7bae. 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 implements the TranscriptAnalyzer interface for the Cursor agent, enabling richer checkpoint metadata extraction (prompts, summaries, transcript position tracking). The implementation leverages the shared transcript package that handles the common JSONL format used by both Cursor and Claude Code. Additionally, it fixes the fallback commit message to use agent type instead of agent name.

Changes:

  • Implements TranscriptAnalyzer interface for Cursor agent with methods for extracting prompts, summaries, and tracking transcript position using the shared transcript package
  • Introduces ErrNoToolUseBlocks sentinel error to explicitly signal that Cursor transcripts don't support file extraction (file detection continues via git status)
  • Updates generateCommitMessage to accept and use AgentType parameter for agent-specific fallback messages instead of hardcoded "Claude Code session updates"

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cmd/entire/cli/agent/cursor/transcript.go New file implementing TranscriptAnalyzer interface with GetTranscriptPosition, ExtractPrompts, ExtractSummary, and ExtractModifiedFilesFromOffset methods
cmd/entire/cli/agent/cursor/transcript_test.go Comprehensive test coverage for all TranscriptAnalyzer methods including edge cases
cmd/entire/cli/agent/cursor/lifecycle.go Removed outdated comment about not implementing TranscriptAnalyzer
cmd/entire/cli/agent/cursor/cursor.go Updated comment to reflect TranscriptAnalyzer implementation
cmd/entire/cli/commit_message.go Added agentType parameter to generateCommitMessage for dynamic fallback messages
cmd/entire/cli/commit_message_test.go Extended tests to cover all agent types in fallback scenarios
cmd/entire/cli/lifecycle.go Updated generateCommitMessage call to pass agent type

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

The implementation returns position 0 (not the line count) since it
doesn't read the file. Update the test expectation to match.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: a8c66992dc1b
Copy link
Contributor

@khaong khaong left a comment

Choose a reason for hiding this comment

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

ExtractModifiedFilesFromOffset returning ErrNoToolUseBlocks will cause a user-visible warning on every Cursor stop hook invocation.

Since Cursor now implements TranscriptAnalyzer but not SubagentAwareExtractor, the stop hook takes the fallback branch at lifecycle.go:245:

if files, _, fileErr := analyzer.ExtractModifiedFilesFromOffset(...); fileErr != nil {
    fmt.Fprintf(os.Stderr, "Warning: failed to extract modified files: %v\n", fileErr)

This prints to stderr every time:

Warning: failed to extract modified files: cursor transcripts do not contain tool_use blocks; file detection uses git status

Same issue at lifecycle.go:511 for task checkpoints.

The manual_commit_hooks.go:1341 call site is fine (uses logging.Debug), but the lifecycle.go paths print directly to the user.

Simplest fix: return nil, 0, nil instead of the sentinel error. The practical effect is the same — no files, fall through to git status. The sentinel error is well-intentioned for explicitness but causes noise at the call sites that treat any error as a warning.

…commit-message-cursor-shadow-branch

# Conflicts:
#	cmd/entire/cli/lifecycle.go

Entire-Checkpoint: 718968f12b5f
Entire-Checkpoint: 8c2d20b5258d
@squishykid
Copy link
Member

Simplest fix: return nil, 0, nil instead of the sentinel error. The practical effect is the same — no files, fall through to git status. The sentinel error is well-intentioned for explicitness but causes noise at the call sites that treat any error as a warning.

In e7ce443 I implemented this, along with an integration test to ensure this remains the case.

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.

4 participants