Documentation
¶
Index ¶
- Constants
- type Provider
- func (p *Provider) AnnounceSessionStart(msg trace.SessionStartMessage) error
- func (p *Provider) AnnounceToUser(_ string) error
- func (p *Provider) CaptureFileSnapshot(_ *state.Store, _ *trace.HookInput) error
- func (p *Provider) CleanupAfterEdit(_ *state.Store, _ *trace.HookInput)
- func (p *Provider) CopySessionData(store *state.Store, loc trace.SessionLocation) error
- func (p *Provider) DiscoverSession(repoRoot string) (*trace.DiscoveredSession, error)
- func (p *Provider) InstallHooks(repoRoot string) error
- func (p *Provider) InstallHooksForTraceRun(repoRoot string) error
- func (p *Provider) IsCommandTool(_ string) bool
- func (p *Provider) IsFileWritingTool(toolName string) bool
- func (p *Provider) Name() string
- func (p *Provider) ParseSession(_ context.Context, opts *trace.ParseOpts) (*aicodingsession.Evidence, error)
- func (p *Provider) ReadHookInput(r io.Reader) (*trace.HookInput, error)
- func (p *Provider) ResolveBeforeContent(_ *state.Store, input *trace.HookInput, after []byte) []byte
- func (p *Provider) SessionDirForRepo(repoRoot string) string
- func (p *Provider) SettingsFile(repoRoot string) string
- func (p *Provider) SupportsSessionStartBanner() bool
- func (p *Provider) SupportsSessionStartInstruction() bool
- func (p *Provider) UninstallHooks(repoRoot string) error
Constants ¶
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 (*Provider) AnnounceSessionStart ¶ added in v1.114.0
func (p *Provider) AnnounceSessionStart(msg trace.SessionStartMessage) error
AnnounceSessionStart writes Cursor's sessionStart hook response. Cursor adds its additional_context field to the conversation's initial system context, which is how the model receives the instruction. The response has no field that Cursor shows to the user, so the banner is dropped.
A message with no instruction writes nothing, so that Cursor's JSON response parser never sees an empty document.
func (*Provider) AnnounceToUser ¶ added in v1.109.1
AnnounceToUser is unsupported for Cursor: it installs only sessionStart, sessionEnd and afterFileEdit, so no hook fires after a shell command and there is nowhere to deliver the message.
func (*Provider) CaptureFileSnapshot ¶
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 ¶
CleanupAfterEdit is a no-op for Cursor: there's no per-edit state to release because no snapshot was taken.
func (*Provider) CopySessionData ¶
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 ¶
InstallHooks adds Chainloop hooks to .cursor/hooks.json.
func (*Provider) InstallHooksForTraceRun ¶
InstallHooksForTraceRun installs every hook except SessionEnd; trace run drives end-of-session itself.
func (*Provider) IsCommandTool ¶
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 ¶
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) 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 ¶
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 ¶
SessionDirForRepo returns the Cursor agent-transcripts directory for the repo.
func (*Provider) SettingsFile ¶
SettingsFile returns the absolute path to .cursor/hooks.json for the given repo.
func (*Provider) SupportsSessionStartBanner ¶ added in v1.114.0
SupportsSessionStartBanner is false for Cursor: its sessionStart response has no field that reaches the user.
func (*Provider) SupportsSessionStartInstruction ¶ added in v1.114.0
SupportsSessionStartInstruction is true for Cursor: additional_context in the sessionStart response reaches the model.
func (*Provider) UninstallHooks ¶
UninstallHooks removes Chainloop hooks from .cursor/hooks.json. Leaves user-authored hooks intact.