cache

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureCacheReady

func EnsureCacheReady(pmPath string) error

EnsureCacheReady ensures the SQLite cache database exists and has the latest schema. This function is idempotent and safe to call before any cache operation.

It will: - Create the database and run migrations if .cache.db doesn't exist - Run any pending migrations if the schema is outdated - Return nil if the database is already up-to-date (fast path)

func RunMigrations

func RunMigrations(dbPath string) error

func ShouldSync

func ShouldSync(pmPath string) (bool, error)

ShouldSync checks if the cache needs to be synchronized with the filesystem by comparing the last sync timestamp with the modification times of ticket files

func SyncCache

func SyncCache(pmPath string) error

SyncCache synchronizes the SQLite cache with the filesystem by scanning all ticket files and updating the database

func SyncMilestones

func SyncMilestones(pmPath string) error

SyncMilestones reads all milestone files from .pm/milestones/ and upserts them into the milestones cache table.

Types

type CachedTicket

type CachedTicket struct {
	ID          string
	Title       string
	Type        string
	Status      string
	HasChildren int
}

CachedTicket is a row from the tickets cache table, used by ListTickets.

func ListTickets

func ListTickets(db *sql.DB, opts ListOptions) ([]CachedTicket, error)

ListTickets queries the SQLite cache and returns tickets matching opts, ordered by updated_at descending.

type ListOptions

type ListOptions struct {
	// ParentFilter limits results to children of this ticket ID.
	// Combined with Subtree=true it returns all descendants; otherwise direct children only.
	ParentFilter string
	// Subtree, when true with ParentFilter, returns all descendants via materialized-path LIKE.
	// When true without ParentFilter, all tickets are returned (no parent filter at all).
	Subtree bool
	// IncludeStates is a whitelist of statuses. Mutually exclusive with ExcludeStates.
	IncludeStates []string
	// ExcludeStates is a blacklist of statuses. Mutually exclusive with IncludeStates.
	ExcludeStates []string
	// MilestoneFilter limits results to tickets belonging to this milestone ID.
	MilestoneFilter string
	// DependsOn limits results to tickets whose depends_on includes this ticket ID.
	DependsOn string
	// Blocks limits results to tickets that block (are depended upon by) this ticket ID.
	Blocks string
	// Related limits results to tickets with any relationship to this ticket ID.
	Related string
}

ListOptions controls filtering in ListTickets.

type SearchOptions

type SearchOptions struct {
	// IncludeStates is a whitelist of statuses. Mutually exclusive with ExcludeStates.
	IncludeStates []string
	// ExcludeStates is a blacklist of statuses. Mutually exclusive with IncludeStates.
	ExcludeStates []string
}

SearchOptions controls filtering for SearchTickets.

type SearchResult

type SearchResult struct {
	ID      string
	Title   string
	Type    string
	Status  string
	Snippet string // short excerpt from body around the first match; empty for id/title matches
}

SearchResult is a ticket row returned by SearchTickets, including a body snippet.

func SearchTickets

func SearchTickets(db *sql.DB, query string, opts SearchOptions) ([]SearchResult, error)

SearchTickets searches the tickets cache for query across id, title, and body. Results are ordered by relevance: id match first, then title, then body.

Jump to

Keyboard shortcuts

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