db

package
v0.0.0-...-b28ec5d Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

internal/db/links.go

internal/db/notes.go

internal/db/nulltime.go

internal/db/projects.go

internal/db/sessions.go

internal/db/tags.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CosineSimilarity

func CosineSimilarity(a, b []float64) float64

Types

type DB

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

func Open

func Open(path string) (*DB, error)

func (*DB) AddSessionTag

func (d *DB) AddSessionTag(sessionID int64, tag string) error

func (*DB) ArchiveProject

func (d *DB) ArchiveProject(id int64) error

func (*DB) BumpPreferenceAccess

func (d *DB) BumpPreferenceAccess(id int64) error

func (*DB) Close

func (d *DB) Close() error

func (*DB) Conn

func (d *DB) Conn() *sql.DB

func (*DB) DecayPreferences

func (d *DB) DecayPreferences() error

func (*DB) DeleteContradictingInferredPreferences

func (d *DB) DeleteContradictingInferredPreferences() (int64, error)

func (*DB) DeleteLowConfidencePreferences

func (d *DB) DeleteLowConfidencePreferences(threshold float64) (int64, error)

func (*DB) DeletePreference

func (d *DB) DeletePreference(id int64) error

func (*DB) DeleteProject

func (d *DB) DeleteProject(name string) (int, error)

func (*DB) DeleteSupersededPreferences

func (d *DB) DeleteSupersededPreferences(olderThanDays int) (int64, error)

func (*DB) GetConversationDigest

func (d *DB) GetConversationDigest(sessionID int64) (string, error)

func (*DB) GetDistinctSessionDates

func (d *DB) GetDistinctSessionDates() ([]string, error)

func (*DB) GetLatestSession

func (d *DB) GetLatestSession(projectID int64) (*Session, error)

func (*DB) GetLinkedProjects

func (d *DB) GetLinkedProjects(projectID int64) ([]Project, error)

func (*DB) GetPreference

func (d *DB) GetPreference(id int64) (*Preference, error)

func (*DB) GetProjectByName

func (d *DB) GetProjectByName(name string) (*Project, error)

func (*DB) GetProjectByPath

func (d *DB) GetProjectByPath(path string) (*Project, error)

func (*DB) GetSessionsInRange

func (d *DB) GetSessionsInRange(projectID int64, since, until time.Time) ([]Session, error)

func (*DB) HasOverlappingSession

func (d *DB) HasOverlappingSession(projectID int64, start, end time.Time) (bool, error)

func (*DB) InsertConversationDigest

func (d *DB) InsertConversationDigest(sessionID int64, digestJSON string) error

func (*DB) InsertNote

func (d *DB) InsertNote(n Note) (int64, error)

func (*DB) InsertPreference

func (d *DB) InsertPreference(p Preference) (int64, error)

func (*DB) InsertSession

func (d *DB) InsertSession(s Session) (int64, error)

func (*DB) LinkProjects

func (d *DB) LinkProjects(projectID, linkedProjectID int64) error

func (*DB) ListDirtyProjects

func (d *DB) ListDirtyProjects() ([]Project, error)

func (*DB) ListNotes

func (d *DB) ListNotes(projectID int64, limit, offset int) ([]Note, int, error)

func (*DB) ListPreferencesByProject

func (d *DB) ListPreferencesByProject(projectID *int64, limit, offset int) ([]Preference, int, error)

func (*DB) ListProjects

func (d *DB) ListProjects(status string) ([]Project, error)

func (*DB) ListSessionTags

func (d *DB) ListSessionTags(sessionID int64) ([]string, error)

func (*DB) ListSessions

func (d *DB) ListSessions(f SessionFilter) ([]Session, int, error)

func (*DB) ListSessionsByTag

func (d *DB) ListSessionsByTag(tag string) ([]Session, error)

func (*DB) PruneNotes

func (d *DB) PruneNotes(before time.Time) (int64, error)

func (*DB) PrunePreferences

func (d *DB) PrunePreferences(before time.Time) (int64, error)

func (*DB) PruneSessions

func (d *DB) PruneSessions(before time.Time) (int64, error)

func (*DB) RemoveSessionTag

func (d *DB) RemoveSessionTag(sessionID int64, tag string) error

func (*DB) SearchNotes

func (d *DB) SearchNotes(query string) ([]Note, error)

func (*DB) SearchPreferences

func (d *DB) SearchPreferences(query string) ([]Preference, error)

func (*DB) SearchSessions

func (d *DB) SearchSessions(query string) ([]Session, error)

func (*DB) SearchSimilar

func (d *DB) SearchSimilar(queryVec []float64, sourceType string, limit int, minScore float64) ([]EmbeddingResult, error)

func (*DB) SessionExists

func (d *DB) SessionExists(claudeSessionID string) (bool, error)

func (*DB) StoreEmbedding

func (d *DB) StoreEmbedding(sourceType string, sourceID int64, content string, vec []float64, model string, truncated bool) error

func (*DB) SupersedePreference

func (d *DB) SupersedePreference(oldID, newID int64) error

func (*DB) UnlinkProjects

func (d *DB) UnlinkProjects(projectID, linkedProjectID int64) error

func (*DB) UpdatePreference

func (d *DB) UpdatePreference(id int64, category, content, source string, confidence float64) error

func (*DB) UpsertProject

func (d *DB) UpsertProject(p Project) (int64, error)

type EmbeddingResult

type EmbeddingResult struct {
	ID         int64
	SourceType string
	SourceID   int64
	Score      float64
	Content    string
}

type Note

type Note struct {
	ID        int64
	ProjectID *int64
	SessionID *int64
	Content   string
	CreatedAt time.Time
}

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool
}

NullTime is a time.Time that is stored as a Unix timestamp in SQLite rather than the Go default string format. This allows proper round-tripping through the modernc.org/sqlite driver.

func ToNullTime

func ToNullTime(t *time.Time) NullTime

ToNullTime converts a *time.Time to NullTime

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements sql.Scanner.

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements driver.Valuer.

type Preference

type Preference struct {
	ID               int64
	ProjectID        *int64
	Category         string
	Content          string
	Source           string
	Confidence       float64
	CreatedAt        time.Time
	UpdatedAt        time.Time
	LastReferencedAt *time.Time
	AccessCount      int
	SupersededBy     *int64
	SupersededAt     *time.Time
}

type Project

type Project struct {
	ID            int64
	Name          string
	Path          string
	Languages     string
	Branch        string
	Dirty         bool
	DirtyFiles    int
	LastCommitAt  NullTime
	LastCommitMsg string
	Ahead         int
	Behind        int
	Status        string
	DiscoveredAt  NullTime
	LastScannedAt NullTime
}

type Session

type Session struct {
	ID              int64
	ProjectID       int64
	ClaudeSessionID string
	StartedAt       *time.Time
	EndedAt         *time.Time
	DurationSecs    int
	Summary         string
	FilesChanged    string
	CommitsMade     string
	Tags            string
	Source          string
	CreatedAt       time.Time
	// Joined fields
	ProjectName string
}

type SessionFilter

type SessionFilter struct {
	ProjectID int64
	Since     *time.Time
	Limit     int
	Offset    int
}

Jump to

Keyboard shortcuts

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