Documentation
¶
Index ¶
- Constants
- func GetDBPath() (string, error)
- func GetDataDir() (string, error)
- func ResolveDBPath(pathOverride string) (string, error)
- type Config
- type Fragment
- type ListOptions
- type MiningState
- type SearchResult
- type Store
- func (s *Store) Close() error
- func (s *Store) CreateFragment(ctx context.Context, f *Fragment) error
- func (s *Store) DeleteFragment(ctx context.Context, agent, path string) (deleted bool, err error)
- func (s *Store) FindFragmentsByPath(ctx context.Context, path string) ([]Fragment, error)
- func (s *Store) FragmentCountsByAgent(ctx context.Context) (map[string]int, error)
- func (s *Store) GetFragment(ctx context.Context, agent, path string) (*Fragment, error)
- func (s *Store) GetState(ctx context.Context, sessionID string) (*MiningState, error)
- func (s *Store) LastMinedByAgent(ctx context.Context) (map[string]time.Time, error)
- func (s *Store) ListFragments(ctx context.Context, opts ListOptions) ([]Fragment, error)
- func (s *Store) SearchFragments(ctx context.Context, query string, limit int, agent string) ([]SearchResult, error)
- func (s *Store) UpdateFragment(ctx context.Context, agent, path, content string) (updated bool, err error)
- func (s *Store) UpsertState(ctx context.Context, st *MiningState) error
Constants ¶
const (
DefaultSourceMine = "mine"
)
Variables ¶
This section is empty.
Functions ¶
func GetDataDir ¶
GetDataDir returns the XDG data directory for term-llm.
func ResolveDBPath ¶
ResolveDBPath resolves an optional DB path override.
Types ¶
type Config ¶
type Config struct {
Path string // Optional DB path override (supports :memory:)
}
Config controls memory store initialization.
type Fragment ¶
type Fragment struct {
ID string
Agent string
Path string
Content string
Source string
CreatedAt time.Time
UpdatedAt time.Time
AccessedAt *time.Time
AccessCount int
DecayScore float64
Pinned bool
}
Fragment is a durable memory item extracted from sessions.
type ListOptions ¶
ListOptions configures fragment listing.
type MiningState ¶
MiningState tracks per-session mining progress.
type SearchResult ¶
type SearchResult struct {
Agent string `json:"agent"`
Path string `json:"path"`
Snippet string `json:"snippet"`
Score float64 `json:"score"`
}
SearchResult is a BM25 result from FTS.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists memory fragments and mining state.
func (*Store) CreateFragment ¶
CreateFragment inserts a new fragment and syncs FTS explicitly.
func (*Store) DeleteFragment ¶
DeleteFragment removes a fragment and syncs FTS. Returns deleted=false when no matching fragment exists.
func (*Store) FindFragmentsByPath ¶
FindFragmentsByPath fetches fragments for a path across all agents.
func (*Store) FragmentCountsByAgent ¶
FragmentCountsByAgent returns count(fragment) grouped by agent.
func (*Store) GetFragment ¶
GetFragment fetches a fragment by (agent,path).
func (*Store) LastMinedByAgent ¶
LastMinedByAgent returns MAX(mined_at) grouped by agent.
func (*Store) ListFragments ¶
ListFragments returns fragments sorted by updated_at descending.
func (*Store) SearchFragments ¶
func (s *Store) SearchFragments(ctx context.Context, query string, limit int, agent string) ([]SearchResult, error)
SearchFragments performs BM25 search over FTS5.
func (*Store) UpdateFragment ¶
func (s *Store) UpdateFragment(ctx context.Context, agent, path, content string) (updated bool, err error)
UpdateFragment updates content for an existing (agent,path) fragment and syncs FTS. Returns updated=false when no matching fragment exists.
func (*Store) UpsertState ¶
func (s *Store) UpsertState(ctx context.Context, st *MiningState) error
UpsertState inserts or updates mining state.