Expand description
Native memory RPCs — read/write the agent’s ~/.claude/projects/<sanitized>/memory/
folder that Claude Code uses for autonomous, cross-session fact storage.
Three commands: agent:memory:list — list *.md files in the memory dir agent:memory:read_file — read one file by filename (no path traversal) agent:memory:write_file — write/create one file atomically (tmp→rename)
Spec: docs/specs/SPEC_AGENT_PANE_MEMORY_IDENTITY_MODALS_2026_06_19.md §7
Functions§
- djb2_
hash 🔒 - Hash matching Claude Code’s sessionStoragePortable.ts implementation.
JS
charCodeAt()iterates UTF-16 code units (two surrogates per non-BMP char); Rustchars()iterates Unicode scalar values — they diverge for emoji/non-BMP.encode_utf16()produces the same UTF-16 unit stream as JS, so the hashes match. - memory_
dir_ 🔒for_ cwd - Compute
~/.claude/projects/<sanitized>/memory/for the given working directory. - parse_
frontmatter_ 🔒type - Extract
metadata.typefrom YAML frontmatter. Claude Code memory files nest the type undermetadata:: metadata: type: user A top-leveltype:key is NOT the correct field. - radix_
36 🔒 - Convert a u32 to a base-36 string (lowercase, same as Number.toString(36) in JS).
- register_
native_ memory_ handlers - validate_
filename 🔒 - Validate a filename: alphanumeric +
-_, must end with.md, no path separators.