{"modulePath":"github.com/chainloop-dev/chainloop","version":"v1.138.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cursor\n\n## Constants\n\n```go\nconst Name = \"cursor\"\n```\nName 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.\n\n## Types\n\n```go\ntype Provider struct{}\n```\nProvider implements trace.Provider for Cursor agent sessions.\n\n```go\nfunc New() *Provider\n```\nNew creates a new Cursor provider.\n\n```go\nfunc (p *Provider) AllowToolUse() error\n```\nAllowToolUse 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.\n\n```go\nfunc (p *Provider) AnnouncePromptSubmit(_ string) error\n```\nAnnouncePromptSubmit writes nothing for Cursor, which installs no prompt-submit hook.\n\n```go\nfunc (p *Provider) AnnounceSessionStart(msg trace.SessionStartMessage) error\n```\nAnnounceSessionStart 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.\n\nA message with no instruction writes nothing, so that Cursor's JSON response parser never sees an empty document.\n\n```go\nfunc (p *Provider) AnnounceToUser(_ string) error\n```\nAnnounceToUser 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.\n\n```go\nfunc (p *Provider) CaptureFileSnapshot(_ *state.Store, _ *trace.HookInput) error\n```\nCaptureFileSnapshot is a no-op for Cursor: the afterFileEdit hook delivers old/new strings directly, so no pre-edit snapshot is needed.\n\n```go\nfunc (p *Provider) CleanupAfterEdit(_ *state.Store, _ *trace.HookInput)\n```\nCleanupAfterEdit is a no-op for Cursor: there's no per-edit state to release because no snapshot was taken.\n\n```go\nfunc (p *Provider) CopySessionData(store *state.Store, loc trace.SessionLocation) error\n```\nCopySessionData copies the Cursor transcript for sessionID into the store's raw/\\\u003csessionID\u003e.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.\n\n```go\nfunc (p *Provider) HooksInstalled(repoRoot string) (bool, error)\n```\nHooksInstalled reports whether .cursor/hooks.json holds any Chainloop hook. User-authored hooks are ignored.\n\n```go\nfunc (p *Provider) InstallHooks(repoRoot string) error\n```\nInstallHooks adds Chainloop hooks to .cursor/hooks.json.\n\n```go\nfunc (p *Provider) InstallHooksForTraceRun(repoRoot string) error\n```\nInstallHooksForTraceRun installs every hook except SessionEnd; trace run drives end-of-session itself.\n\n```go\nfunc (p *Provider) IsCommandTool(toolName string) bool\n```\nIsCommandTool returns true for Cursor's shell tool, whose preToolUse and postToolUse hooks snapshot the worktree around each command.\n\n```go\nfunc (p *Provider) IsFileWritingTool(toolName string) bool\n```\nIsFileWritingTool 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.\n\n```go\nfunc (p *Provider) Name() string\n```\nName returns the agent identifier.\n\n```go\nfunc (p *Provider) ParseSession(_ context.Context, opts *trace.ParseOpts) (*aicodingsession.Evidence, error)\n```\nParseSession 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.\n\n```go\nfunc (p *Provider) ReadHookInput(r io.Reader) (*trace.HookInput, error)\n```\nReadHookInput 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.\n\n```go\nfunc (p *Provider) ResolveBeforeContent(_ *state.Store, input *trace.HookInput, after []byte) []byte\n```\nResolveBeforeContent 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.\n\n```go\nfunc (p *Provider) SettingsFile(repoRoot string) string\n```\nSettingsFile returns the absolute path to .cursor/hooks.json for the given repo.\n\n```go\nfunc (p *Provider) SupportsPromptReminder() bool\n```\nSupportsPromptReminder is false for Cursor: it documents no channel that adds context at prompt submit, so it gets the session-start instruction only.\n\n```go\nfunc (p *Provider) SupportsSessionStartBanner() bool\n```\nSupportsSessionStartBanner is false for Cursor: its sessionStart response has no field that reaches the user.\n\n```go\nfunc (p *Provider) SupportsSessionStartInstruction() bool\n```\nSupportsSessionStartInstruction is true for Cursor: additional\\_context in the sessionStart response reaches the model.\n\n```go\nfunc (p *Provider) UninstallHooks(repoRoot string) error\n```\nUninstallHooks removes Chainloop hooks from .cursor/hooks.json. Leaves user-authored hooks intact.\n\n","path":"github.com/chainloop-dev/chainloop/app/cli/internal/trace/cursor","name":"cursor","synopsis":"","isRedistributable":true}
