Documentation
¶
Overview ¶
Package memory provides cross-session memory persistence as a set of typed, single-fact files with a lightweight frontmatter header.
Facts live in two scopes:
- global (~/.config/moa/global/memory/<slug>.md) — user, feedback
- project (~/.config/moa/projects/<hash>/memory/<slug>.md) — project, reference
where <hash> is SHA256(CanonicalizePath(workspaceRoot))[:16]. Only the index (one line per fact) is injected into the prompt; full bodies are read on demand. The index is derived from the files at load — moa never writes a MEMORY.md of its own.
Index ¶
- Constants
- func ValidName(name string) bool
- func ValidType(t Type) bool
- type Memory
- type Scope
- type Store
- func (s *Store) Delete(id string) error
- func (s *Store) FormatIndex(mems []Memory) string
- func (s *Store) GlobalDir() string
- func (s *Store) List() []Memory
- func (s *Store) MigrateV1IfNeeded() error
- func (s *Store) ProjectDir() string
- func (s *Store) Read(id string) (Memory, bool, error)
- func (s *Store) Write(m Memory) error
- type Type
Constants ¶
const (
// MaxFactSize is the hard per-fact limit (16KB).
MaxFactSize = 16 * 1024
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Memory ¶
type Memory struct {
Name string
Description string
Type Type
Body string
Scope Scope
Path string // absolute path to the file (set on read/list)
}
Memory is a single fact.
type Scope ¶
type Scope int
Scope is where a fact lives.
func ScopeForType ¶
ScopeForType routes a type to its scope (D2): user/feedback are global, everything else is project-local.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the global and project memory directories for one workspace.
func New ¶
New builds a Store. configDir is the moa config root (~/.config/moa); workspaceRoot selects the project scope.
func (*Store) FormatIndex ¶
FormatIndex renders the index as one bullet per fact (no framing — the caller adds it). Empty if no facts. Bounded by maxIndexBytes with a truncation note.
func (*Store) List ¶
List scans both scopes and returns all facts, project scope first, then by name. Global and project facts with the same name coexist as distinct IDs.
func (*Store) MigrateV1IfNeeded ¶
MigrateV1IfNeeded wraps a flat v1 MEMORY.md into a single legacy fact, then retires the flat file. Idempotent even across partial failures: the flat file is only renamed after the fact is safely written, so an interrupted run simply retries next time (D6).
func (*Store) ProjectDir ¶
ProjectDir returns this workspace's project memory directory.