Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer handles indexing and searching memory files.
func NewIndexer ¶
func NewIndexer(embedder embeddings.Embedder, store Store, logger *slog.Logger, maxChunkChars int) *Indexer
NewIndexer creates a new memory indexer. maxChunkChars controls the maximum chunk size for embeddings; 0 uses the default (6000).
func (*Indexer) Index ¶
func (idx *Indexer) Index(ctx context.Context, memoryPath, dirPath string, excludePaths []string) (int, error)
Index scans the memory path (directory tree or single .md file), embeds whole files, and stores any stale or new entries. Returns the number of files indexed. dirPath scopes the indexed files; empty string means global scope. excludePaths are absolute paths to skip during indexing (prefix match with separator check).
func (*Indexer) Search ¶
func (idx *Indexer) Search(ctx context.Context, dirPath, query string, topK int) ([]SearchResult, error)
Search embeds the query and returns the top-K results ranked by cosine similarity. Results are scoped to the given dirPath (project-scoped) plus global files (dir_path = ”).
type SearchResult ¶
type SearchResult struct {
FilePath string `json:"file_path"`
Content string `json:"content,omitempty"`
Score float32 `json:"score"`
ChunkIndex int `json:"chunk_index"`
}
SearchResult holds a single search result with its similarity score.
type Store ¶
type Store interface {
UpsertMemoryFile(ctx context.Context, file *db.MemoryFile) error
GetMemoryFilesByDirPath(ctx context.Context, dirPath string) ([]*db.MemoryFile, error)
GetMemoryFileHash(ctx context.Context, filePath, dirPath string) (string, error)
DeleteMemoryFile(ctx context.Context, filePath, dirPath string) error
}
Store is the memory file storage interface (subset of db.Store).