@yandy0725/pi-memory4.4.1
File-system driven persistent memory layer for pi coding agent
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-memory
English | 中文
Persistent memory for the pi coding agent: project knowledge (facts, preferences, debugging history) kept as plain Markdown files, available across sessions and across harnesses. Memory lives on disk, not in the conversation.
Install
pi install npm:@yandy0725/pi-memory
Requires pi 1.5.0 or newer (@earendil-works/pi-coding-agent peer range is >=1.5.0).
Or add it to ~/.pi/agent/settings.json:
{ "packages": ["npm:@yandy0725/pi-memory"] }
Configure a model first
// ~/.pi/agent/memory.json
{ "defaults": { "model": "provider/model-id" } }
There is no bundled default model, and it does not fall back to the parent session's model:
defaults.model must resolve in your registry. dream always needs it; autoSurfacing /
extractMemories need it when enabled. A missing model makes session_start report a config error and
initialise nothing.
What it does
- One
memorytool —add/replace/remove/list/search. One memory per file,nameis the lookup key, andaddwith an existing name overwrites it. MEMORY.mdin the system prompt — thememory_indexsection is frozen for the whole session, so pi's section diff appends nothing per turn and the provider prefix cache keeps hitting.- Auto-surfacing — one lightweight side query per turn picks relevant memories and injects their
bodies inside
<relevant_memories>. - Automatic extraction (off by default) — after each turn a sub-session picks out what is worth remembering and writes it through the same tool.
/dream— a headless tidy-up: merge duplicates, resolve contradictions, rebuild the index./deep-dream— manual cross-project pass: reads the memory of every project (full entry bodies go to the configured model), never modifies the sources, and writes a candidate report you copy into your globalAGENTS.mdyourself. See the reference.- Cross-device sync (on by default) — push this project's memory to a git remote and share it with another machine working on the same repository (see below).
- Runs natively on Windows; no WSL needed.
Cross-device sync (enabled by default)
Set sync.remote to push this project's memory entries to a git remote so another machine working on
the same repository shares them:
// ~/.pi/agent/memory.json
{ "sync": { "remote": "git@github.com:you/project-memory.git" } }
- No configured or initialized remote: in a git project startup reports a non-fatal sync configuration
error and does not contact a remote; local memory keeps working. A non-git project only gets the
unsupported-environment notice. To disable sync, set
{ "sync": { "enabled": false } }inmemory.json. - There is no init command: the next session start with this config clones into
<memoryDir>/.sync/repoand records a baseline. - Prepare the remote yourself (an empty repository is fine) and make sure
gitcan clone/push it non-interactively — pi-memory stores no credentials. - Only entry
*.mdfiles sync:MEMORY.md,.lock,.backups/andsessions/stay local. - If both sides rewrite the same memory, both are kept: the other becomes a deterministic conflict
copy that
/dreammerges later. - On the first sync of a project that already has local entries, expect one info notice
(
pi-memory sync notice: …) that same-named entries may land as conflict copies. It is not a failure and it does not repeat for that baseline. - Manual convergence:
/memory sync pull/push/status(strict dry-run) /remote <url>.
Full semantics: cross-device sync.
Commands
| Command | What it does |
|---|---|
/memory |
Memory dir, index capacity, entry count, module status, lock holder |
/memory unlock |
Clear a .lock left behind by a crash |
/memory sync [status|pull|push|remote <url>|unlock] |
Sync status and manual convergence |
/dream |
Tidy the memory (confirms first, then snapshots the whole directory) |
/deep-dream |
Analyze every project's memory into a candidate report (confirms first; sources stay read-only) |
Full tool and argument reference: tool reference.
Where memory lives
<memoryDir>/<git|local>/<project>/
The default root is $XDG_DATA_HOME/simple-memory on Linux and macOS (~/.local/share/simple-memory when
XDG_DATA_HOME is unset or relative) and %LOCALAPPDATA%\simple-memory on Windows. The disk format (entry
frontmatter, MEMORY.md, .lock, .backups/) is defined by
memory-core; memoryDir overrides the root, but
it is per-harness configuration — with dsh, override it to the same value on that side too.
The index is frozen for the whole session: memories written this session appear in the system prompt only after a compaction or in the next session. The tool's return value is the confirmation that the write happened.
Docs
- Reference (in Chinese): full configuration, cross-device sync, internals, tool and command reference
- Repository:
memory-core/dsh-memoryand how to develop
MIT