Pi package + native memory engine for the Pi coding agent. Install Pi first, then install Pi-Memory.
Pi-Memory gives Pi agents a durable local memory layer built from three small pieces:
- a native C CLI for persistence and queries
- a Pi extension for compaction/session lifecycle automation
- a
MEMORY.mdbridge for human-readable project continuity
Repository: https://github.com/SiliconState/Pi-Memory
Pi session JSONL files are excellent for forensics, but they are not optimized for fast recall. Pi-Memory adds a second layer:
- raw session JSONL for full history
- structured memory for durable decisions, findings, lessons, entities, and project state
That makes long-running work easier to resume after compaction, handoff, or reboot.
| Layer | Responsibility | Location |
|---|---|---|
| Native core | Structured persistence + query/search/export/sync | ~/.pi/memory/pi-memory / %USERPROFILE%\.pi\memory\pi-memory.exe |
| SQLite store | Durable source of truth | ~/.pi/memory/memory.db / %USERPROFILE%\.pi\memory\memory.db |
| Project bridge | Human-readable context projection | MEMORY.md in your project |
Pi-Memory has native source support for:
- macOS
- Linux
- Windows
| Platform | Native support | In-repo prebuilt |
|---|---|---|
| macOS arm64 | ✅ | ✅ |
| macOS x64 | ✅ | ✅ |
| Linux x64 | ✅ | release/CI artifact or compile fallback |
| Linux arm64 | ✅ | release/CI artifact or compile fallback |
| Windows x64 | ✅ | compile fallback today; prebuilt can be shipped by release workflow |
If a matching prebuilt is absent, scripts/setup.mjs automatically falls back to compiling from source.
pi install git:github.com/SiliconState/Pi-MemoryThis is the primary install path because Pi reads the package metadata and installs:
- the extension
- the skill
- the prompts
- the native binary via
postinstall
Verify:
~/.pi/memory/pi-memory --versionOn Windows:
$env:USERPROFILE\.pi\memory\pi-memory.exe --versionThe package structure is ready for npm and bun installs from git or a packed tarball.
Examples:
npm install github:SiliconState/Pi-Memory
bun add github:SiliconState/Pi-MemoryNotes:
postinstallrunsscripts/setup.mjs- prebuilt binaries are used when present
- otherwise the package compiles from source
- Pi users should still prefer
pi install git:...so Pi registers the extension/skill/prompt metadata - npm publish is not live yet
curl -fsSL https://raw.githubusercontent.com/SiliconState/Pi-Memory/main/scripts/install.sh | bashThis helper is Unix-only.
If pi-memory is not on your PATH, use one of these:
- macOS / Linux:
~/.pi/memory/pi-memory - Windows:
%USERPROFILE%\.pi\memory\pi-memory.exe
BIN="${PI_MEMORY_BIN:-$HOME/.pi/memory/pi-memory}"
# initialize project memory markers
"$BIN" init
# write memory
"$BIN" log decision "Use SQLite for agent memory" \
--choice "Single local database" \
--rationale "Simple, durable, low operational overhead"
"$BIN" log finding "Extension syncs MEMORY.md before compaction" \
--category architecture \
--confidence verified
"$BIN" log lesson "Wrong project attribution caused noisy sync output" \
--fix "Pass --project explicitly when needed"
"$BIN" log entity "SessionManager" --type concept --description "Pi session tree manager"
# inspect memory
"$BIN" query --limit 20
"$BIN" search "compaction"
"$BIN" state <project>
# project bridge
"$BIN" sync MEMORY.md --limit 15For PowerShell, use the Windows binary path directly or set PI_MEMORY_BIN.
Primary record types:
- decisions — what was chosen and why
- findings — facts, discoveries, compaction summaries
- lessons — failures and fixes
- entities — named tools, services, concepts, contracts
- sessions — ingested Pi session metadata and stats
- project_state — current phase, summary, next actions, rollups
Session ingest and shutdown automation also carry:
session_idlinks across records- token/cost rollups
- compaction summaries
- auto-extracted decisions/lessons/entities from session JSONL
| Dimension | Pi session JSONL | Pi-Memory |
|---|---|---|
| Purpose | Complete transcript | Curated durable memory |
| Noise level | High | Low / intentional |
| Scope | One session | Cross-session / cross-project |
| Best use | Replay, auditing, debugging | Recall, continuity, handoff |
Think of it as:
- JSONL = camera footage
- Pi-Memory = engineering notebook
You want both.
The extension automates continuity around compaction and shutdown:
- syncs
MEMORY.mdbefore compaction - stores compaction summaries as findings
- captures the latest user intent for auto-resume after auto-compactions
- ingests the current session JSONL on shutdown
- updates
project_state - syncs
MEMORY.mdagain at shutdown - performs provider/model failover for compaction-related resilience
Inside Pi you can also use:
/compact-threshold
/compact-threshold 75%
/compact-threshold reset
/compact
npm run setup
npm run doctor
npm run test:smoke
npm pack --dry-runmacOS / Linux
cd native && makeWindows (MSVC Developer Command Prompt)
cd native
nmake /F Makefile.winMIT