history

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FrecentEntry

type FrecentEntry struct {
	Text     string    `json:"text"`
	Score    float64   `json:"score"`
	LastUsed time.Time `json:"last_used"`
	UseCount int       `json:"use_count"`
}

FrecentEntry is a single history entry with scoring metadata.

type FrecentHistory

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

FrecentHistory tracks prompt history by frecency (frequency + recency). Entries are persisted as JSON in the user's session directory.

func NewFrecentHistory

func NewFrecentHistory(filePath string) *FrecentHistory

NewFrecentHistory creates a FrecentHistory backed by the given file path. If the file exists it is loaded immediately; otherwise an empty history is created.

func (*FrecentHistory) Save

func (fh *FrecentHistory) Save() error

Save persists the history to disk. The caller must hold fh.mu (either RLock or Lock).

func (*FrecentHistory) Search

func (fh *FrecentHistory) Search(query string, limit int) []FrecentEntry

Search returns entries matching the query, sorted by most recently used first.

func (*FrecentHistory) Upsert

func (fh *FrecentHistory) Upsert(text string)

Upsert adds or updates an entry in the history and persists to disk.

Jump to

Keyboard shortcuts

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