cursor

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cursor provides an adapter for Cursor that reads SQLite databases to extract conversation history with workspace-based organization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWatcher

func NewWatcher(workspaceDir string) (<-chan adapter.Event, io.Closer, error)

NewWatcher creates a watcher for Cursor CLI session changes. It watches only the workspace directory - fsnotify on macOS reports events for files in subdirectories when watching the parent (td-0f0e68).

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter implements the adapter.Adapter interface for Cursor CLI sessions.

func New

func New() *Adapter

New creates a new Cursor CLI adapter.

func (*Adapter) Capabilities

func (a *Adapter) Capabilities() adapter.CapabilitySet

Capabilities returns the supported features.

func (*Adapter) Detect

func (a *Adapter) Detect(projectRoot string) (bool, error)

Detect checks if Cursor CLI sessions exist for the given project.

func (*Adapter) ID

func (a *Adapter) ID() string

ID returns the adapter identifier.

func (*Adapter) Icon

func (a *Adapter) Icon() string

Icon returns the adapter icon for badge display.

func (*Adapter) Messages

func (a *Adapter) Messages(sessionID string) ([]adapter.Message, error)

Messages returns all messages for the given session.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the human-readable adapter name.

func (*Adapter) SearchMessages

func (a *Adapter) SearchMessages(sessionID, query string, opts adapter.SearchOptions) ([]adapter.MessageMatch, error)

SearchMessages searches message content within a session. Implements adapter.MessageSearcher interface.

func (*Adapter) Sessions

func (a *Adapter) Sessions(projectRoot string) ([]adapter.Session, error)

Sessions returns all sessions for the given project, sorted by update time.

func (*Adapter) Usage

func (a *Adapter) Usage(sessionID string) (*adapter.UsageStats, error)

Usage returns aggregate usage stats for the given session. Cursor CLI doesn't track detailed token usage, so we return estimates.

func (*Adapter) Watch

func (a *Adapter) Watch(projectRoot string) (<-chan adapter.Event, io.Closer, error)

Watch returns a channel that emits events when session data changes.

type ContentBlock

type ContentBlock struct {
	Type            string          `json:"type"`
	Text            string          `json:"text,omitempty"`
	ToolCallID      string          `json:"toolCallId,omitempty"`
	ToolName        string          `json:"toolName,omitempty"`
	Args            json.RawMessage `json:"args,omitempty"`
	Result          json.RawMessage `json:"result,omitempty"`  // For tool-result blocks
	IsError         bool            `json:"isError,omitempty"` // For tool-result error status
	ProviderOptions *ProviderOpts   `json:"providerOptions,omitempty"`
	Signature       string          `json:"signature,omitempty"`
}

ContentBlock represents a single block in the content array. Content can be a plain string or an array of these blocks.

type CursorOpts

type CursorOpts struct {
	ModelName       string `json:"modelName,omitempty"`
	RawToolCallArgs string `json:"rawToolCallArgs,omitempty"`
}

CursorOpts holds Cursor-specific message metadata.

type MessageBlob

type MessageBlob struct {
	ID      string          `json:"id,omitempty"`
	Role    string          `json:"role"`
	Content json.RawMessage `json:"content"`
}

MessageBlob represents a raw message blob from the SQLite database. Messages are stored as JSON with role and content fields.

type ProviderOpts

type ProviderOpts struct {
	Cursor *CursorOpts `json:"cursor,omitempty"`
}

ProviderOpts holds provider-specific options embedded in content blocks.

type SessionInfo

type SessionInfo struct {
	Path             string    // Path to store.db
	SessionID        string    // UUID of the session
	WorkspaceHash    string    // Hash of the workspace path
	Name             string    // Session name from metadata
	Mode             string    // Agent mode (e.g., "auto-run")
	Model            string    // Last used model
	CreatedAt        time.Time // When the session was created
	UpdatedAt        time.Time // Estimated from file mtime or blob analysis
	MessageCount     int       // Number of user/assistant messages
	TotalTokens      int       // Estimated token count (if available)
	FirstUserMessage string    // Content of the first user message (for title)
}

SessionInfo holds parsed session information for display.

type SessionMeta

type SessionMeta struct {
	AgentID          string `json:"agentId"`
	LatestRootBlobID string `json:"latestRootBlobId"`
	Name             string `json:"name"`
	Mode             string `json:"mode"`
	CreatedAt        int64  `json:"createdAt"` // Unix timestamp in milliseconds
	LastUsedModel    string `json:"lastUsedModel"`
}

SessionMeta holds metadata stored in the meta table at key "0". The value is hex-encoded JSON.

func (SessionMeta) CreatedTime

func (m SessionMeta) CreatedTime() time.Time

CreatedTime returns the createdAt timestamp as time.Time.

Jump to

Keyboard shortcuts

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