cursor

package
v1.108.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "cursor"

Name is the provider identifier emitted to evidence and used as the key in SessionRecord.Provider. Kept as an exported constant so CLI wiring can refer to it without instantiating the provider.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct{}

Provider implements trace.Provider for Cursor agent sessions.

func New

func New() *Provider

New creates a new Cursor provider.

func (*Provider) CaptureFileSnapshot

func (p *Provider) CaptureFileSnapshot(_ *state.Store, _ *trace.HookInput) error

CaptureFileSnapshot is a no-op for Cursor: the afterFileEdit hook delivers old/new strings directly, so no pre-edit snapshot is needed.

func (*Provider) CleanupAfterEdit

func (p *Provider) CleanupAfterEdit(_ *state.Store, _ *trace.HookInput)

CleanupAfterEdit is a no-op for Cursor: there's no per-edit state to release because no snapshot was taken.

func (*Provider) CopySessionData

func (p *Provider) CopySessionData(store *state.Store, repoRoot, sessionID string) error

CopySessionData copies the Cursor transcript for sessionID into the store's raw/<sessionID>.jsonl. Handles both flat and nested source layouts; the destination is always flat so downstream consumers (parse, pre-push) don't need to re-resolve.

func (*Provider) DiscoverSession

func (p *Provider) DiscoverSession(repoRoot string) (*trace.DiscoveredSession, error)

DiscoverSession finds the most recent Cursor session for the given repo root.

func (*Provider) InstallHooks

func (p *Provider) InstallHooks(repoRoot string) error

InstallHooks adds Chainloop hooks to .cursor/hooks.json.

func (*Provider) InstallHooksForTraceRun

func (p *Provider) InstallHooksForTraceRun(repoRoot string) error

InstallHooksForTraceRun installs every hook except SessionEnd; trace run drives end-of-session itself.

func (*Provider) IsCommandTool

func (p *Provider) IsCommandTool(_ string) bool

IsCommandTool always returns false for Cursor: shell-execution hooks are not yet wired (Cursor installs only sessionStart/sessionEnd/afterFileEdit), so shell-driven file changes are not captured for this provider.

func (*Provider) IsFileWritingTool

func (p *Provider) IsFileWritingTool(toolName string) bool

IsFileWritingTool returns true for the synthetic "edit" tool name we set on afterFileEdit hook inputs. Cursor has no tool-name concept for generic preToolUse/postToolUse events in our flow, so "edit" is the sole signal.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the agent identifier.

func (*Provider) ParseSession

func (p *Provider) ParseSession(_ context.Context, opts *trace.ParseOpts) (*aicodingsession.Evidence, error)

ParseSession reads the copied transcript JSONL for sessionID and returns a best-effort Evidence. Cursor's transcript format does not include token usage, so Usage stays empty and the result carries a warning.

func (*Provider) ReadHookInput

func (p *Provider) ReadHookInput(r io.Reader) (*trace.HookInput, error)

ReadHookInput parses a Cursor hook JSON payload from the given reader. ConversationID is preferred as the session identifier; session_id is used as a fallback for forward-compatibility.

func (*Provider) ResolveBeforeContent

func (p *Provider) ResolveBeforeContent(_ *state.Store, input *trace.HookInput, after []byte) []byte

ResolveBeforeContent reverses the edits reported by Cursor's afterFileEdit hook against the file's current content to reconstruct the pre-edit state. Returns nil when no edits were reported.

func (*Provider) SessionDirForRepo

func (p *Provider) SessionDirForRepo(repoRoot string) string

SessionDirForRepo returns the Cursor agent-transcripts directory for the repo.

func (*Provider) SettingsFile

func (p *Provider) SettingsFile(repoRoot string) string

SettingsFile returns the absolute path to .cursor/hooks.json for the given repo.

func (*Provider) SystemMessage

func (p *Provider) SystemMessage(_ string) error

SystemMessage is a no-op for Cursor: the documented hook response channel does not include a "systemMessage"-style announcement path comparable to Claude Code's SessionStart output. We log nothing to stdout to avoid confusing Cursor's JSON response parser.

func (*Provider) UninstallHooks

func (p *Provider) UninstallHooks(repoRoot string) error

UninstallHooks removes Chainloop hooks from .cursor/hooks.json. Leaves user-authored hooks intact.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL