@yylan/pi-memory
High-performance long-term memory system for pi coding agent — SQLite FTS5 + local ONNX embeddings
Package details
Install @yylan/pi-memory from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@yylan/pi-memory- Package
@yylan/pi-memory- Version
1.0.1- Published
- May 22, 2026
- Downloads
- not available
- Author
- yylan
- License
- MIT
- Types
- extension
- Size
- 50 KB
- Dependencies
- 2 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./extensions/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
🧠 @yylan/pi-memory
High-performance long-term memory system for pi coding agent.
Built with dual-process architecture for maximum performance — SQLite FTS5 for BM25 search + local ONNX embeddings for vector search.
Features
- 4-Tier Memory: Working → Episodic → Semantic → Procedural
- Hybrid Search: BM25 (FTS5) + Vector embeddings (384-dim) with RRF fusion
- Auto-Capture: Automatically records tool calls and results
- Smart Injection: Relevant memories are injected into system prompt before each turn
- Privacy: API keys, tokens, and secrets are automatically redacted
- Fast: <1ms BM25 search, ~5ms vector search, <20ms total memory injection
🔧 Installation
pi install npm:@yylan/pi-memory
Then reload pi (/reload) or restart.
Note: On first load, pi will automatically install dependencies (
better-sqlite3,@xenova/transformers). This may take a moment.
🔑 Configuration
| Env Variable | Default | Description |
|---|---|---|
PI_MEMORY_DIR |
~/.pi-memory |
Database storage directory |
PI_MEMORY_TOKEN_BUDGET |
2000 |
Max tokens for memory injection |
PI_MEMORY_AUTO_CAPTURE |
true |
Enable automatic tool capture |
PI_MEMORY_EMBEDDINGS |
true |
Enable local ONNX embeddings |
📋 Tools
| Tool | Description |
|---|---|
memory_search |
Search long-term memory with hybrid BM25+vector |
memory_save |
Save durable facts, conventions, preferences |
memory_consolidate |
Run consolidation pipeline manually |
memory_status |
Check health, stats, embedding availability |
📋 Commands
/memory status — Show memory system stats
/memory search <q> — Search memories
/memory consolidate — Run consolidation now
🏗️ Architecture
┌─────────────────────────────────────────────┐
│ pi Extension (jiti runtime) │
│ - Event handlers, Custom tools, IPC client │
└──────────────────┬──────────────────────────┘
│ IPC (<0.1ms)
┌──────────────────▼──────────────────────────┐
│ Memory Server (standalone Node.js process) │
│ - better-sqlite3 + FTS5 (BM25 full-text) │
│ - @xenova/transformers (local embeddings) │
│ - RRF hybrid search (BM25 + Vector) │
│ - 4-tier memory pipeline │
└─────────────────────────────────────────────┘
🔄 Memory Lifecycle
Working (raw observations)
→ Episodic (session summaries)
→ Semantic (extracted facts, patterns)
→ Procedural (workflows, conventions)