← Catalog

@yylan/pi-memory

High-performance long-term memory system for pi coding agent — SQLite FTS5 + local ONNX embeddings

Package

Install

Install with PiG

pig install npm:@yylan/pi-memory

Install with Pi

pi install npm:@yylan/pi-memory
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 1.0.1 (README.md). PiG does not review it.

🧠 @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 VariableDefaultDescription
PI_MEMORY_DIR~/.pi-memoryDatabase storage directory
PI_MEMORY_TOKEN_BUDGET2000Max tokens for memory injection
PI_MEMORY_AUTO_CAPTUREtrueEnable automatic tool capture
PI_MEMORY_EMBEDDINGStrueEnable local ONNX embeddings

📋 Tools

ToolDescription
memory_searchSearch long-term memory with hybrid BM25+vector
memory_saveSave durable facts, conventions, preferences
memory_consolidateRun consolidation pipeline manually
memory_statusCheck 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)