sessions

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompositeKey

func CompositeKey(workstationID, projectID, sessionID string) string

CompositeKey builds the isolation key: workstation_id:project_id:session_id.

func GitRemoteProjectID added in v0.4.0

func GitRemoteProjectID(cwdPath string) (string, error)

GitRemoteProjectID computes a stable 8-char project ID from the git remote origin URL and the repository-relative path of cwdPath (via git rev-parse --show-prefix). Returns "", error if cwdPath is not inside a git repo or has no remote configured.

func ProjectID

func ProjectID(cwdPath string) string

ProjectID computes a deterministic project ID with directory name prefix. Tries git remote origin URL first (stable across machines and OS path layouts), falls back to SHA-256 of the absolute path if not a git repo or has no remote. Format: "dirname_xxxxxxxx" (name + 8-char hex hash)

func WorkstationID

func WorkstationID() string

WorkstationID computes a deterministic 8-char hexadecimal ID from hostname + machine_id.

Types

type Exchange

type Exchange struct {
	UserText      string
	AssistantText string
	ToolsUsed     []string
	Timestamp     time.Time
}

Exchange represents a user-assistant message pair.

type ListOptions

type ListOptions struct {
	WorkstationID string
	ProjectID     string
	Limit         int
	Offset        int
}

type SessionMeta

type SessionMeta struct {
	SessionID     string
	ProjectPath   string
	GitBranch     string
	FirstMsgAt    time.Time
	LastMsgAt     time.Time
	Exchanges     []Exchange
	ToolCounts    map[string]int
	ExchangeCount int
}

SessionMeta holds metadata extracted from a parsed session.

func ParseSession

func ParseSession(path string) (*SessionMeta, error)

ParseSession reads a Claude JSONL session file and returns parsed session metadata.

func ParseSessionReader

func ParseSessionReader(r io.Reader) (*SessionMeta, error)

ParseSessionReader reads Claude JSONL session data from an io.Reader.

type SessionSearchResult

type SessionSearchResult struct {
	Session gormdb.IndexedSession
	Rank    float64
}

type Store

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

func NewStore

func NewStore(store *gormdb.Store) *Store

func (*Store) CheckSessionsExist added in v0.4.0

func (s *Store) CheckSessionsExist(ctx context.Context, ids []string) ([]string, error)

CheckSessionsExist returns the subset of provided IDs that already exist in the database.

func (*Store) GetSession

func (s *Store) GetSession(ctx context.Context, id string) (*gormdb.IndexedSession, error)

GetSession retrieves by ID.

func (*Store) GetSessionMtime

func (s *Store) GetSessionMtime(ctx context.Context, id string) (time.Time, bool, error)

GetSessionMtime returns (mtime, found, error) for skip check.

func (*Store) ListSessions

func (s *Store) ListSessions(ctx context.Context, opts ListOptions) ([]gormdb.IndexedSession, error)

ListSessions lists with optional WorkstationID/ProjectID filters + Limit/Offset.

func (*Store) SearchSessions

func (s *Store) SearchSessions(ctx context.Context, query string, limit int) ([]SessionSearchResult, error)

SearchSessions FTS via ts_rank + websearch_to_tsquery.

func (*Store) UpsertSession

func (s *Store) UpsertSession(ctx context.Context, session *gormdb.IndexedSession) error

UpsertSession upserts via raw SQL ON CONFLICT(id) DO UPDATE.

Jump to

Keyboard shortcuts

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