Documentation
¶
Index ¶
- type Index
- func (idx *Index) Close() error
- func (idx *Index) List(scope string, topic string) ([]MemoryEntry, error)
- func (idx *Index) Rebuild(projectDir, globalDir string) error
- func (idx *Index) Remove(name string) error
- func (idx *Index) Search(query string, scope string) ([]MemoryEntry, error)
- func (idx *Index) Upsert(name, filePath, scope, content string) error
- type MemoryEntry
- type MemoryStore
- func (s *MemoryStore) Close() error
- func (s *MemoryStore) Delete(name string) error
- func (s *MemoryStore) Edit(name string, editFn func(content string) string) error
- func (s *MemoryStore) Index() *Index
- func (s *MemoryStore) List(scope string, topic string) ([]MemoryEntry, error)
- func (s *MemoryStore) Read(name string) (string, error)
- func (s *MemoryStore) Rename(oldName, newName string) error
- func (s *MemoryStore) Search(query string, scope string) ([]MemoryEntry, error)
- func (s *MemoryStore) Write(name, content string) error
- type Scope
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index manages the SQLite FTS5 index for memory search.
func NewIndex ¶
NewIndex opens (or creates) the SQLite database at dbPath, initializes the schema, and configures WAL mode with a busy timeout.
func (*Index) List ¶
func (idx *Index) List(scope string, topic string) ([]MemoryEntry, error)
List returns all memories, optionally filtered by scope and/or topic.
type MemoryEntry ¶
type MemoryEntry struct {
Name string
FilePath string
Scope string // "project" or "global"
Topic string
Title string
Summary string
Rank float64 // FTS5 rank (populated for search results)
}
MemoryEntry represents a single memory record with its metadata.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore provides CRUD operations for markdown-based memories with SQLite FTS5 indexing. It manages two directories: project-local and global.
func NewMemoryStore ¶
func NewMemoryStore(projectDir, globalDir, indexDBPath string, logger *slog.Logger) (*MemoryStore, error)
NewMemoryStore creates a MemoryStore with the given directories and index DB path. Both projectDir and globalDir are created if they do not exist.
func (*MemoryStore) Delete ¶
func (s *MemoryStore) Delete(name string) error
Delete removes a memory file and its index entry.
func (*MemoryStore) Edit ¶
func (s *MemoryStore) Edit(name string, editFn func(content string) string) error
Edit reads a memory, applies editFn to its content, and writes the result back.
func (*MemoryStore) Index ¶
func (s *MemoryStore) Index() *Index
Index returns the underlying Index for direct access (e.g., by the watcher).
func (*MemoryStore) List ¶
func (s *MemoryStore) List(scope string, topic string) ([]MemoryEntry, error)
List returns all memories, optionally filtered by scope and topic.
func (*MemoryStore) Read ¶
func (s *MemoryStore) Read(name string) (string, error)
Read returns the content of a memory by name.
func (*MemoryStore) Rename ¶
func (s *MemoryStore) Rename(oldName, newName string) error
Rename moves a memory from oldName to newName. This supports cross-scope moves.
func (*MemoryStore) Search ¶
func (s *MemoryStore) Search(query string, scope string) ([]MemoryEntry, error)
Search performs a full-text search over all memories.
func (*MemoryStore) Write ¶
func (s *MemoryStore) Write(name, content string) error
Write creates or overwrites a memory. The name determines scope and path:
- "global/foo" -> globalDir/foo.md (scope=global)
- "foo" -> projectDir/foo.md (scope=project)
- "topic/sub/name" -> projectDir/topic/sub/name.md (scope=project)
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors memory directories for file changes and auto-updates the SQLite FTS5 index. It debounces events to avoid redundant rebuilds.
func NewWatcher ¶
NewWatcher creates a Watcher that monitors projectDir and globalDir for markdown file changes. The default debounce window is 300ms.