recall

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package recall is a tiny full-text index over saved sessions. It powers the /recall slash command — search across every conversation you've had with yottacode, ranked by FTS5 relevance.

The index lives at ~/.yottacode/index.sqlite and is rebuilt incrementally whenever a session is saved. At startup the TUI re-indexes every session in a background goroutine so historical sessions become searchable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backfill

func Backfill(idx *Index) error

Backfill walks every saved session via session.List + session.Load and re-indexes them. Cheap when the corpus is small (a few dozen sessions); expected to run as a background goroutine at TUI startup.

Types

type Hit

type Hit struct {
	SessionID   string
	SessionName string
	Model       string
	Created     time.Time
	Role        adapter.Role
	MsgIndex    int
	Snippet     string
}

Hit is one search result: the message that matched plus the surrounding session metadata. Snippet contains FTS5-highlighted match context with `[…]` brackets around the matched terms.

type Index

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

Index is the writable handle on the FTS5 database. Safe to share across goroutines because database/sql serializes operations.

func MustOpenForTest

func MustOpenForTest(t interface {
	TempDir() string
	Fatalf(string, ...any)
}) *Index

MustOpenForTest opens a fresh in-temp-dir index for use from another package's tests. Panics on failure (which would mean the test fixture itself is broken). Lives in the production file so it's exported, but is only intended to be called from *_test.go.

func Open

func Open() (*Index, error)

Open returns the index living at ~/.yottacode/index.sqlite, creating the directory and schema as needed.

func (*Index) Close

func (idx *Index) Close() error

Close releases the underlying database handle. It's fine to ignore the error during shutdown.

func (*Index) IndexSession

func (idx *Index) IndexSession(s *session.Session) error

IndexSession upserts every user/assistant message body for the given session. Replaces any prior FTS rows for that session id, so re-indexing after a turn is correct (and cheap — sessions are at most a few KB).

func (*Index) Search

func (idx *Index) Search(query string, limit int) ([]Hit, error)

Search runs an FTS5 MATCH query and returns up to `limit` hits sorted by rank (most relevant first). limit defaults to 10 when ≤ 0.

The first attempt uses the raw query so power users can still write FTS5-native expressions ("auth OR jwt", "\"exact phrase\"", etc.). On a syntax failure we retry with a sanitized version so naive inputs like "nothing-matches-this" — which FTS5 reads as a NOT operator — still produce a clean empty result instead of a SQL error.

Jump to

Keyboard shortcuts

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