Documentation
¶
Index ¶
- Constants
- type Provider
- func (p *Provider) AllowToolUse() error
- func (p *Provider) AnnouncePromptSubmit(_ string) error
- 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) HooksInstalled(repoRoot string) (bool, error)
- func (p *Provider) InstallHooks(repoRoot string) error
- func (p *Provider) InstallHooksForTraceRun(repoRoot string) error
- func (p *Provider) IsCommandTool(toolName 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) SettingsFile(repoRoot string) string
- func (p *Provider) SupportsPromptReminder() bool
- 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) AllowToolUse ¶ added in v1.124.0
AllowToolUse writes the preToolUse hook response that lets the tool call proceed. Cursor blocks the call when a preToolUse hook writes a response that is not valid JSON or does not match the schema, so the pre hook writes this response whatever the trace does.
func (*Provider) AnnouncePromptSubmit ¶ added in v1.116.0
AnnouncePromptSubmit writes nothing for Cursor, which installs no prompt-submit hook.
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: the postToolUse response that runs after a shell command has no field that Cursor shows to the user, so 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) HooksInstalled ¶ added in v1.118.0
HooksInstalled reports whether .cursor/hooks.json holds any Chainloop hook. User-authored hooks are ignored.
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 returns true for Cursor's shell tool, whose preToolUse and postToolUse hooks snapshot the worktree around each command.
func (*Provider) IsFileWritingTool ¶
IsFileWritingTool returns true for the synthetic "edit" tool name we set on afterFileEdit hook inputs. The preToolUse/postToolUse hooks are installed for the shell tool only, so "edit" is the sole file-writing 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) SettingsFile ¶
SettingsFile returns the absolute path to .cursor/hooks.json for the given repo.
func (*Provider) SupportsPromptReminder ¶ added in v1.116.0
SupportsPromptReminder is false for Cursor: it documents no channel that adds context at prompt submit, so it gets the session-start instruction only.
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.