Pi
@db0-ai/pi is an extension that gives the Pi coding agent persistent, cross-session memory. Preferences, project patterns, and solutions survive compaction and session resets.
Install
npx @db0-ai/pi init
This creates the extension at ~/.pi/agent/extensions/db0/, installs dependencies, and writes the entry point. No other configuration needed.
What it does
The extension registers tools and lifecycle hooks with Pi's extension API:
Tools
The agent gets three memory tools:
| Tool | Description |
|---|---|
db0_memory_write |
Store a fact with scope and optional tags |
db0_memory_search |
Search memories by query |
db0_memory_list |
List memories, optionally filtered by scope |
Lifecycle hooks
| Hook | Behavior |
|---|---|
before_agent_start |
Packs relevant memories into context |
turn_end |
Extracts facts from the assistant's response |
session_start |
Creates a fresh harness (memories carry over) |
session_shutdown |
Runs reconciliation and closes cleanly |
Memory extraction happens automatically after every turn. The agent doesn't need to be told to remember — it just does.
What gets remembered
With the coding-assistant profile (default), the extension captures:
- Tool and language preferences ("use bun", "single quotes", "functional style")
- Project patterns and architecture decisions
- Solutions to problems encountered across sessions
- User corrections and feedback
Facts are scoped: user-scope memories persist forever, session-scope ones expire with the session.
Storage
Default: ~/.pi/agent/db0.sqlite
Override with the DB0_STORAGE environment variable or pass dbPath in the extension config:
export DB0_STORAGE=postgresql://user:pass@host:5432/db
Uninstall
# Remove extension and database
npx @db0-ai/pi uninstall
# Remove extension, keep memories
npx @db0-ai/pi uninstall --keep-data
Configuration
The extension accepts these options:
| Option | Default | Description |
|---|---|---|
dbPath |
~/.pi/agent/db0.sqlite |
Storage path or PostgreSQL URL |
profile |
coding-assistant |
Memory profile |
tokenBudget |
1500 |
Tokens for context injection |