Documentation
¶
Overview ¶
Package storage manages persisted conversation metadata.
Index ¶
- Constants
- Variables
- func NewConversationID() string
- type Conversation
- type DB
- func (c *DB) Close() error
- func (c *DB) Completions(in string) []string
- func (c *DB) Delete(id string) error
- func (c *DB) Find(in string) (*Conversation, error)
- func (c *DB) FindHEAD() (*Conversation, error)
- func (c *DB) List() []Conversation
- func (c *DB) ListOlderThan(t time.Duration) []Conversation
- func (c *DB) Save(id, title, api, model string) error
Constants ¶
const ( // SHA1Short is the short display length used in CLI output. SHA1Short = 7 // SHA1MinLen is the minimum prefix length considered for ID matching. SHA1MinLen = 4 // SHA1ReadBlockSize is the size of random bytes mixed into ID generation. SHA1ReadBlockSize = 4096 )
Variables ¶
var ( // ErrNoMatches is returned when no conversations match the query. ErrNoMatches = errors.New("no conversations found") // ErrManyMatches is returned when multiple conversations match the query. ErrManyMatches = errors.New("multiple conversations matched the input") )
var SHA1Regexp = regexp.MustCompile(`\b[0-9a-f]{40}\b`)
SHA1Regexp matches a full 40-char SHA-1 hex string.
Functions ¶
func NewConversationID ¶
func NewConversationID() string
NewConversationID generates a stable-looking ID for conversation records.
This is not used for cryptographic security; it is used as an identifier.
Types ¶
type Conversation ¶
type Conversation struct {
ID string `db:"id"`
Title string `db:"title"`
UpdatedAt time.Time `db:"updated_at"`
API *string `db:"api"`
Model *string `db:"model"`
}
Conversation in the database.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is an append-only JSONL-backed conversation metadata index.
func Open ¶
Open loads the conversation metadata store from the given datasource.
The datasource is usually a directory path. The special value ":memory:" creates a temporary store (primarily used for tests).
func (*DB) Completions ¶
Completions returns shell completion candidates for IDs and titles.
func (*DB) Find ¶
func (c *DB) Find(in string) (*Conversation, error)
Find resolves a conversation by ID prefix or exact title.
func (*DB) FindHEAD ¶
func (c *DB) FindHEAD() (*Conversation, error)
FindHEAD returns the most recently updated conversation.
func (*DB) List ¶
func (c *DB) List() []Conversation
List returns conversations sorted by most recently updated.
func (*DB) ListOlderThan ¶
func (c *DB) ListOlderThan(t time.Duration) []Conversation
ListOlderThan returns conversations older than the given duration.