This is a Pi extension that gives agents durable working memory through plain markdown files. Instead of losing task context when Pi compacts conversation history, or watching two sessions overwrite the same progress.md, it splits memory into session-owned files plus an audit trail of immutable events.
Everything lives under ~/.pi/agent/memory/. No database, no server. Just markdown.
The main idea: confirmed owner sessions get their own progress.md and todo.md under sessions/<session-id>/, while a shared progress.md at the project root becomes a generated dashboard. Multiple owner sessions in the same repo cannot clobber each other's resume state because they write to different session folders. Subagents and unidentified sessions are read-only: they report anything durable back to a parent or owner session, which decides what to checkpoint. Shared history is append-only: every owner checkpoint, compaction, and todo update becomes a uniquely named event file in events/; dream runs write audit artifacts under dreams/. When the event stream gets large, /memory-digest run can add a deterministic summary under event-digests/; it never edits, deletes, moves, or marks raw events.
memory.md is curated long-term project knowledge. Dreams maintain a schema-v1 markdown file with stable sections, source citations, and conservative deferrals. Instead of copying every task note, an owner-session dream pass periodically reviews recent owner session progress, events, todos, and any existing event digests, then distills only low-risk durable facts into memory.md. Dreams fire silently after owner compaction when they have not run in the last 24 hours, or you can run them manually from an owner session with /dream-run.
For a project called my-repo, the layout looks like this:
~/.pi/agent/memory/
global.md # cross-project preferences (not auto-edited)
my-repo/
progress.md # generated dashboard, not the source of truth
memory.md # curated durable knowledge (created by dreams)
sessions/
019e.../
progress.md # this session's Resume Here
todo.md # this session's active todo
019f.../
progress.md # another session's Resume Here
todo.md # another session's active todo
events/
20260523T185519Z-019e...-checkpoint-a1b2c3.md
20260523T185700Z-019e...-compaction-d4e5f6.md
20260523T185730Z-019e...-migration-9a8b7c.md
event-digests/
20260523T185730Z-019e...-migration-9a8b7c-digest-200-a1b2c3d4e5f6.md
dreams/
last-run.md
20260523T190000Z-019e...-dream-123abc.md
The shared progress.md starts with a layout marker and explicitly says it is non-authoritative. Owner sessions should read their own session progress and todo for source-of-truth continuity. The dashboard is just a convenience view that lists active sessions and recent events. If you open a second Pi window in the same repo, you will see two owner session folders under sessions/, each with its own Resume Here. Subagents and unidentified sessions do not maintain durable session progress/todo; a parent or owner session captures whatever matters from their result.
memory.md does not exist until the first dream runs. Dreams create it automatically with stable schema-v1 sections. After a few days of work it might look like:
# Project Memory
<!-- pi-memory-workbench-memory: v1 -->
Durable project knowledge distilled automatically by pi-memory-workbench dreams.
## Conventions
- [id: conv-a1b2c3d4] Shared `progress.md` is dashboard-only; session progress is authoritative. (source: events/20260523T185519Z-...md; seen: 2026-05-23)
## Decisions
## Verified Commands
- [id: cmd-d4e5f6a7] `for f in index.ts memory.ts paths.ts todo.ts todo-widget.ts memory-events.ts memory-schema.ts; do node --check "$f" || exit $?; done` passed. (source: sessions/019e.../progress.md; seen: 2026-05-23)
## Gotchas
## Avoid
## Deferred
- [id: def-9a8b7c6d] Candidate involving `AGENTS.md` policy changes. (deferred: AGENTS.md policy change requires manual review; source: events/20260523T190000Z-...md; seen: 2026-05-23)If an older freeform memory.md exists, the first schema-v1 dream preserves the original content under ## Legacy Memory instead of deleting it.
Session todos are normal markdown with checkbox markers:
# Review memory workflow
Session ID: 019e...
Session progress: ~/.pi/agent/memory/my-repo/sessions/019e.../progress.md
## Objective
Review the memory workflow.
## Items
- [>] Smoke /reload
- [ ] Try /memory
- [x] Create README
- [!] Fix edge case in todo status update[ ] means TODO, [>] means DOING, [x] means DONE, [!] means BLOCKED. Legacy todos/current.md is kept as a migration source only; new commands write to the session todo.
Install the GitHub package:
pi install git:github.com/nicobailon/pi-memory-workbenchFor a project-local installation, add -l:
pi install -l git:github.com/nicobailon/pi-memory-workbenchTo develop from a local clone instead:
git clone https://github.com/nicobailon/pi-memory-workbench.git
pi install ./pi-memory-workbenchThen reload Pi:
/reload
Create a session todo and checkpoint before you stop working:
/todo-new Review memory workflow
/todo-add Verify compaction checkpoint behavior
/memory-checkpoint
Check what the extension sees:
/memory
After Pi compacts context, the extension writes a focused checkpoint to your session files. If auto-continue is enabled, it sends a hidden follow-up that points you back to your session progress, session todo, and latest event. It never treats the shared dashboard as the resume source.
Auto-continue is on by default. Turn it off if hidden follow-ups annoy you:
/memory-autocontinue off
Editor chrome is off by default. Turn it on if you want the todo widget and footer status:
/memory-footer on
Dreams run silently after compaction when they have not run in 24 hours. You will not see a notification or follow-up; they just create an artifact under dreams/ and possibly append to memory.md. If you want to force one now:
/dream-status
/dream-run
Slash commands:
/memory — Show the session memory packet, recent events, and file paths.
/memory-refresh — Reload memory files from disk and update the editor chrome. This is read-only: it does not migrate, regenerate the dashboard, or trigger dreams.
/memory-migrate — Run legacy migration and regenerate the dashboard.
/memory-lint — Run read-only health checks for layout, session files, schema-v1 memory, recent events, dreams, and digest eligibility.
/memory-digest status|run — Show event digest status or create one non-destructive digest when enough old undigested events are eligible.
/memory-autocontinue status|on|off — Control hidden follow-ups after compaction.
/memory-footer status|on|off — Control editor chrome.
/memory-checkpoint — Edit this session's Resume Here. This also writes a checkpoint event under events/.
/todo — Open this session's todo overlay.
/todo-new <title> — Create this session's todo.
/todo-add <text> — Add a TODO item.
/todo-doing <index> <exact current item text> — Mark an item DOING.
/todo-done <index> <exact current item text> — Mark an item DONE.
/todo-blocked <index> <exact current item text> — Mark an item BLOCKED.
/dream-status — Show dream freshness.
/dream-run — Run dream curation now.
Agent tools:
memory_read — Read the session memory packet.
memory_recall — Search durable workbench artifacts with bounded ranked snippets, scope/kind/session filters, or expand an exact returned source path.
memory_checkpoint — Update this session's Resume Here.
memory_todo — Create, list, add, or update this session's todo.
memory_dream — Check dream status or run curation.
memory_lint — Run the same read-only health checks as /memory-lint.
memory_digest — Run digest status or run.
Status updates require the exact current item text. This prevents a stale index from updating the wrong task after items are added or reordered. If you type /todo-done 1 without the text, the command will tell you the correct usage.
When Pi compacts an owner-session conversation, the extension snapshots the current session state before compaction, then generates a focused checkpoint from Pi's native summary, notable tool calls, read files, edits, and retained context. Subagents and unidentified sessions skip durable compaction writes and report outcomes through a parent or owner session instead.
A successful owner compaction writes an immutable event, updates this session's progress, appends to this session's todo if one exists, and regenerates the shared dashboard as best effort. It never updates another session's files.
If checkpoint generation fails because the model is unavailable or the XML is malformed, a deterministic fallback reconstructs Resume Here from explicit native-summary sections, existing session state, and observed file activity. It writes a distinct fallback event and never invents verification outcomes. If the compaction is aborted, it writes nothing. If boomerang just collapsed a branch, it skips checkpointing entirely because boomerang already handles its own handoff.
After compaction, if the last dream is more than 24 hours old, it silently runs dream curation before the compaction handler finishes. That may append durable notes to memory.md and writes an audit artifact under dreams/. If dream generation fails, the error is logged but compaction and auto-continue proceed normally.
If you have the old single-session layout (progress.md, memory.md, todos/current.md), the extension automatically migrates from owner sessions on session start or /memory-migrate. It archives the full legacy progress.md in an immutable migration event, seeds your current session's progress from the old Resume Here, imports the legacy todo into your session todo if present, and replaces the shared progress.md with the new dashboard format. Read-only sessions do not run migration. If another owner session changed the legacy file while migrating, /memory-migrate may report that dashboard repair needs another run. It never runs migration from ordinary read or refresh paths, so multiple owner sessions racing to migrate do not write-storm each other.
Event digests are additive summaries for old raw event files. Status is read-only and uses sortable event filenames for ordering and high-water. File mtimes are used only to decide whether an event is old enough to digest. The newest event tail stays raw-only so recent work remains directly inspectable.
A digest records the last source event as Complete through event: events/<file>, and the digest filename starts with that complete-through event stem. That means status can find the latest high-water by lexicographic digest filename and only read the latest few digest files.
The format is plain markdown:
# Memory Event Digest
Event metadata: v1
Kind: event-digest
Created: 2026-05-23T19:00:00.000Z
Session ID: 019e...
Project: my-repo
Previous digest: event-digests/<file> | None.
Complete through event: events/<last-source-event>
Covers events before: 2026-05-22T19:00:00.000Z
Excludes newest event tail: 50
Source event count: 200
Source hash: sha256:...
## Source events
- events/<file> — sha256:...
## Summary
- Digest covers immutable raw event files, ordered by sortable event filename.
## Sessions
- 019e...: 42
## Kinds
- checkpoint: 12
## Durable candidates
- None.
## Audit note
Raw events are immutable and remain authoritative. This digest is an additive summary only.
## Memory refs
- None./memory-digest run refuses to run if the session/events layout marker is missing. It writes at most one digest with exclusive creation and does not migrate layouts.
/memory-lint is the read-only health dashboard. It uses the current memory state only and does not migrate, refresh the dashboard, run dreams, create digests, or call any write helper. It checks dashboard markers and wording, owner-session progress/todo shape when writable, legacy todo presence, memory.md schema-v1 headings and duplicates, deferred memory entries, dream freshness, recent event metadata and related links, and digest eligibility.
Recommendations are scoped: /memory-migrate is only for layout marker issues, /dream-run is for missing/stale schema memory or stale dreams, /memory-digest run is for old undigested events above threshold, and manual review is used for ambiguous schema/deferred issues. In read-only sessions, lint still reports the same project/layout health issues; writable session progress and todo checks become informational, and write recommendations are directed to a parent or owner session.
Dreams are the consolidation pass. Raw session progress, todos, and events are great for resuming work, but they are too noisy to become long-term project memory directly. A dream reviews recent sources and distills durable facts into memory.md automatically.
Dreams run:
- Silently after owner-session compaction, at most once per 24 hours.
- Manually when you run
/dream-run, which forces curation even if the last automatic dream is fresh.
Each run writes an audit artifact showing sources reviewed, digest sources reviewed, raw event sources reviewed, applied entries, superseded entries, skipped duplicates, deferred entries, and the auto-apply policy. Dreams do not automatically edit AGENTS.md, global memory, source files, event files, or digest files. Higher-risk candidates stay under ## Deferred for manual review.
Dream extraction reads semantic sections instead of scanning event metadata. Explicit ## Conventions, ## Decisions, ## Verified Commands, ## Gotchas, and ## Avoid sections determine the destination memory section. ## Durable Facts, ## Summary, and progress ## Updates use conservative classification. Existing memory.md content, source hashes, bare paths, and event metadata are not re-ingested as candidates.
Supersession is explicit and preserves history. A candidate such as - [supersedes: dec-a1b2c3d4] Use the new decision. may replace an existing non-deferred memory ID. The old bullet remains in place with status: superseded, superseded-by, and date metadata, while the replacement gets its own stable ID. Unknown targets, self-replacements, conflicting replacements, and high-risk candidates are deferred. Dreams never infer resolution from a file edit.
memory_read is the fast continuity packet; memory_recall is the deeper read-only retrieval path. When schema memory exists, the packet includes a bounded hot view with at most two recent active entries per durable section, stable memory IDs, and counts for omitted, superseded, and deferred entries. Recall searches plain markdown on demand and never changes memory files.
Use a natural-language query with one of these scopes: project, session, memory, events, dreams, or digests. Results are bounded, ranked, and include exact project-relative paths. To inspect authoritative content, call memory_recall again with one returned path instead of query. Optional kind and sessionId filters narrow the source set.
Recall intentionally does not support arbitrary regex. Multi-term searches require at least two matching terms to reduce false positives from common workbench words such as "memory", "session", and "event".
The extension has a zero-install Bun test harness. It mocks only Pi's file-mutation queue boundary while exercising real filesystem behavior for memory schema updates, repeated Dream idempotence, recall, event metadata, digest high-water, and raw-event immutability.
cd ~/.pi/agent/extensions/pi-memory-workbench
npm test
npm run checkNo todo widget? Turn on chrome and create a todo:
/memory-footer on
/todo-new <title>
Old todos/current.md not updating? It is legacy. New commands write to sessions/<session-id>/todo.md.
Stale dashboard? Use /memory-migrate to regenerate it. The dashboard is best effort; read session files and events for source-of-truth state.
Not sure what is wrong? Run /memory-lint. It is read-only and will suggest /memory-migrate, /dream-run, /memory-digest run, or manual review depending on the issue. In read-only sessions, those write suggestions are parent- or owner-directed.
Digest status says below threshold? That is normal. Digests are for older event backlogs and keep the newest 50 events undigested.
/memory-checkpoint fails in non-UI mode? Use the memory_checkpoint tool instead.
/todo-done 1 fails with a usage error? You need the exact current item text, like /todo-done 1 "Verify compaction checkpoint behavior". Copy it from /todo or memory_read.
Dream status says never run? Run /dream-run. Or just keep working; the next compaction will trigger it if stale.
- Plain markdown is the source of truth.
- Owner sessions own mutable progress and todo.
- Subagents and unidentified sessions use memory read-only; parent or owner sessions capture durable outcomes.
- Shared
progress.mdis a generated dashboard, not continuity state. - Events are immutable audit records, never modified after creation.
- Event digests are additive and deterministic; raw events remain authoritative.
- Durable memory is curated by dreams, not copied from every task note.
- Dashboard freshness is convenient, not correctness-critical.
- Migration preserves legacy content before replacing anything.
There is no npm release yet; install from GitHub or a local clone. Interactive smoke testing still needs a live Pi session. Only confirmed owner sessions write durable progress and todo state. Subagents and unidentified sessions run in read-only memory mode and should report durable outcomes to a parent or owner session. Lint and digest status are local read-only checks, but digest creation still needs enough old event files to be useful. This does not replace reading source files; it just gives agents a memory boost.
See CHANGELOG.md for release history.
MIT © 2026 Nico Bailon.