local

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package local implements Leros built-in file-backed memory.

Index

Constants

View Source
const (
	// TargetMemory stores worker facts, environment notes, and durable lessons.
	TargetMemory = "memory"
	// TargetUser stores user preferences and profile facts.
	TargetUser = "user"
	// TargetProjectMemory stores project-level persistent memory.
	TargetProjectMemory = "project_memory"
)
View Source
const (
	// EntryDelimiter separates individual memory entries within a file.
	EntryDelimiter = "\n§\n"
)

Variables

This section is empty.

Functions

func DefaultMemoryRoot

func DefaultMemoryRoot() (string, error)

DefaultMemoryRoot returns the workspace memory directory.

func ReadEntries

func ReadEntries(path string) ([]string, error)

ReadEntries reads and parses memory entries from a file.

Types

type EntrySet

type EntrySet struct {
	Target     string   `json:"target"`
	Entries    []string `json:"entries"`
	Usage      string   `json:"usage"`
	EntryCount int      `json:"entry_count"`
}

EntrySet is the live memory state for one target.

type Options

type Options struct {
	RootDir         string
	MemoryCharLimit int
	UserCharLimit   int
}

Options configures a Store.

type Result

type Result struct {
	Success    bool     `json:"success"`
	Message    string   `json:"message,omitempty"`
	Target     string   `json:"target,omitempty"`
	Entries    []string `json:"entries,omitempty"`
	Usage      string   `json:"usage,omitempty"`
	EntryCount int      `json:"entry_count,omitempty"`
	Error      string   `json:"error,omitempty"`
	Matches    []string `json:"matches,omitempty"`
	MemoryRoot string   `json:"memory_root,omitempty"`
	MemoryFile string   `json:"memory_file,omitempty"`
}

Result is returned from mutating memory operations.

type Store

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

Store persists compact curated memories to USER.md and MEMORY.md.

func MustDefaultStore

func MustDefaultStore() *Store

MustDefaultStore creates the default store and panics only on impossible path resolution.

func NewStore

func NewStore(opts Options) (*Store, error)

NewStore creates a file-backed memory store.

func (*Store) Add

func (s *Store) Add(ctx context.Context, target string, content string) (*Result, error)

Add appends a compact memory entry.

func (*Store) BuildPromptBlock

func (s *Store) BuildPromptBlock(ctx context.Context) (string, error)

BuildPromptBlock renders the current memory snapshot for system prompt injection.

func (*Store) Load

func (s *Store) Load(ctx context.Context, target string) (*EntrySet, error)

Load reads one target without mutating it.

func (*Store) Remove

func (s *Store) Remove(ctx context.Context, target string, oldText string) (*Result, error)

Remove deletes the entry containing oldText.

func (*Store) Replace

func (s *Store) Replace(ctx context.Context, target string, oldText string, newContent string) (*Result, error)

Replace replaces the entry containing oldText with newContent.

func (*Store) RootDir

func (s *Store) RootDir() string

RootDir returns the memory directory containing USER.md and MEMORY.md.

Jump to

Keyboard shortcuts

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