Skip to main content

Module memdir

Module memdir 

Source
Expand description

Memory directory: persistent file-based memory system.

Scans .md files with YAML frontmatter, sorts by recency, caps at 200 files.

Structs§

MemoryFile
A memory file with its full content.
MemoryFileMeta
Metadata for a memory file (without loading full content).
MemoryIndex
Result of loading MEMORY.md with truncation info.

Enums§

MemoryType
Memory types for categorized memory entries.

Functions§

auto_memory_path
Resolve the memory directory for a project. Default: ~/.claude/projects/<sanitized-root>/memory/
build_memory_prompt_content
Build the complete memory prompt content for the system prompt.
ensure_memory_dir_exists
Create the memory directory if it doesn’t exist.
load_memory_file
Load a memory file with its full content, stripping frontmatter.
load_memory_index
Load the MEMORY.md index file with truncation. Returns None if the file doesn’t exist or is empty.
memory_age_days
How many days ago a memory was modified.
memory_age_text
Human-readable age string.
memory_freshness_text
Freshness warning for stale memories (>1 day old).
sanitize_path_component
Sanitize a path component for use as a directory name. Keeps alphanumeric, -, _, .. Replaces everything else with _.
scan_memory_dir
Scan a memory directory for .md files. Returns metadata sorted newest-first, capped at 200 files. Excludes MEMORY.md (the index file).