memories

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package memories implements a persistent memory system for project context. Memories are stored as markdown files with YAML frontmatter under ~/.celeste/projects/<hash>/memories/.

Index

Constants

This section is empty.

Variables

View Source
var ValidTypes = []string{"user", "feedback", "project", "reference"}

ValidTypes lists the allowed memory types.

Functions

func CheckStaleness

func CheckStaleness(memory *Memory) (int, string)

CheckStaleness returns how many days old a memory is and a warning string. If the memory is fresh (< 7 days), the warning is empty.

func IsValidType

func IsValidType(t string) bool

IsValidType checks if a type string is a valid memory type.

func ShouldVerify

func ShouldVerify(memory *Memory) bool

ShouldVerify returns true if a memory is older than 7 days.

Types

type Index

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

Index manages the MEMORY.md file that summarizes all memories for system prompt injection.

func LoadIndex

func LoadIndex(path string) (*Index, error)

LoadIndex loads or creates an Index from a MEMORY.md file path.

func (*Index) Add

func (idx *Index) Add(entry IndexEntry) error

Add adds an entry to the index. If an entry with the same name exists, it is replaced.

func (*Index) Entries

func (idx *Index) Entries() []IndexEntry

Entries returns a copy of the index entries.

func (*Index) Remove

func (idx *Index) Remove(name string) error

Remove removes an entry by name.

func (*Index) Render

func (idx *Index) Render() string

Render renders the index as markdown for system prompt injection. Caps output at 200 lines.

func (*Index) Save

func (idx *Index) Save() error

Save writes the index to disk as MEMORY.md.

type IndexEntry

type IndexEntry struct {
	Name        string
	File        string
	Description string
}

IndexEntry represents a single entry in the MEMORY.md index.

type Memory

type Memory struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Type        string `yaml:"type"` // user, feedback, project, reference
	Created     string `yaml:"created"`
	Project     string `yaml:"project"`
	Content     string `yaml:"-"` // everything after frontmatter
}

Memory represents a single memory entry with frontmatter metadata and content.

func NewMemory

func NewMemory(name, description, memType, project, content string) *Memory

NewMemory creates a Memory with the current timestamp.

func ParseMemory

func ParseMemory(data []byte) (*Memory, error)

ParseMemory parses a markdown file with YAML frontmatter into a Memory. Frontmatter is delimited by "---" lines.

func (*Memory) Serialize

func (m *Memory) Serialize() []byte

Serialize renders the memory back to markdown with YAML frontmatter.

type MemoryCandidate

type MemoryCandidate struct {
	Type    string `json:"type"`    // feedback, project, user, reference
	Content string `json:"content"` // the extracted content
	Reason  string `json:"reason"`  // why this was flagged
}

MemoryCandidate represents a potential memory extracted from conversation.

func ExtractCandidates

func ExtractCandidates(userMsg, assistantMsg string) []MemoryCandidate

ExtractCandidates analyzes a user message and assistant response for potential memories to save.

type Store

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

Store manages memory files on disk under a project-specific directory.

func NewStore

func NewStore(projectDir string) *Store

NewStore creates a Store for the given project directory. It derives a hash-based path under ~/.celeste/projects/<hash>/memories/.

func NewStoreWithBase

func NewStoreWithBase(baseDir string) *Store

NewStoreWithBase creates a Store with an explicit base directory (useful for testing).

func (*Store) BaseDir

func (s *Store) BaseDir() string

BaseDir returns the store's base directory.

func (*Store) Delete

func (s *Store) Delete(name string) error

Delete removes a memory file by name.

func (*Store) List

func (s *Store) List() ([]*Memory, error)

List returns all memories in the store.

func (*Store) ListByType

func (s *Store) ListByType(memType string) ([]*Memory, error)

ListByType returns all memories of a given type.

func (*Store) Load

func (s *Store) Load(name string) (*Memory, error)

Load reads a memory by name from disk.

func (*Store) Save

func (s *Store) Save(memory *Memory) error

Save writes a memory to disk as a markdown file.

Jump to

Keyboard shortcuts

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