Expand description
Per-project auto-memory loader (PMAT-CODE-MEMORY-AUTO-001).
Mirrors Claude Code’s auto-memory mechanism: every project has an
associated directory under ~/.config/apr/projects/<slug>/memory/
containing freely-named markdown files. When apr code starts
against a given working directory, every *.md in that directory
is concatenated into the system prompt under a ## Auto-memory
section. This lets the user (or apr itself) accumulate
per-project notes — facts about the user, project state,
feedback, references — without ever editing a single CLAUDE.md.
§Path slug
Claude Code uses a hyphenated path slug like
-home-noah-src-aprender (leading dash + every / → -). We
keep the same slug for cross-tool compatibility: a user moving
from Claude Code to apr keeps their auto-memory by symlinking
~/.claude/projects/ ↔ ~/.config/apr/projects/.
§File ordering
Files are loaded in lexicographic order so MEMORY.md lands first
(uppercase M < lowercase f/p/r/u ASCII) and the rest
sort by name. A file named MEMORY.md is therefore the canonical
“top-of-memory index” matching Claude’s convention.
§Pure-function design
No terminal I/O; warnings are returned via &mut Vec<String> for
the caller to route. No filesystem mutation — read-only loader.
Functions§
- auto_
memory_ root - Auto-memory root directory:
$APR_CONFIG/projectsif the env var is set (override; exclusive — same Poka-Yoke as the settings ladder), otherwise~/.config/apr/projects. - load_
auto_ memory - Load every
*.mdfile in the project’s memory directory in lexicographic order. ReturnsNonewhen the directory doesn’t exist or has no markdown files (so the caller can omit the## Auto-memoryheading entirely instead of emitting an empty section). - project_
memory_ dir - Per-project memory directory:
<root>/<slug>/memory/. - project_
slug - Path-slug Claude Code uses for the project directory under
~/.config/apr/projects/. Format: leading-, then every path separator replaced with-. Non-absolute paths get prefixed with the host’s HOME (Claude’s behavior) so a relativecwdstill produces a stable slug.