pi-mempalace

Persistent agent memory for pi โ€” raw verbatim storage with semantic search. Never lose context again.

Package details

extensionskill

Install pi-mempalace from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-mempalace
Package
pi-mempalace
Version
0.2.0
Published
Apr 8, 2026
Downloads
456/mo ยท 49/wk
Author
jabbslad
License
MIT
Types
extension, skill
Size
122.3 KB
Dependencies
3 dependencies ยท 4 peers
Pi manifest JSON
{
  "extensions": [
    "./extensions"
  ],
  "skills": [
    "./skills"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

๐Ÿง  pi-mempalace

Your AI forgot everything again. How delightful.

Every conversation you've ever had with an AI โ€” every architectural decision, every late-night debugging eureka, every "let's use Postgres because..." โ€” poof. Gone the moment you close the tab. Your AI has the long-term memory of a goldfish at a rave.

pi-mempalace fixes that. It gives pi agents persistent, cross-session memory. Store everything. Search it later. Never re-explain your life choices to a machine again.


๐Ÿฐ Standing on the Shoulders of a Memory Palace

This project is directly inspired by the wonderful MemPalace โ€” built by Milla Jovovich (yes, that Milla Jovovich โ€” Leeloo from The Fifth Element, Alice from Resident Evil) and developer Ben Sigman.

Milla's origin story is painfully relatable: after thousands of conversations with AI, she realized every new session was a clean slate. All her decisions, reasoning, creative ideas โ€” thrown into the void. Existing memory tools like Mem0 and Zep tried to help, but they had a fatal flaw: they used AI to decide what was worth remembering. The nuance, the "why," the reasoning behind decisions โ€” exactly the stuff that matters โ€” was the first to go.

So Milla and Ben spent months building MemPalace with Claude Code, and landed on a beautifully simple idea:

Don't let AI decide what to forget โ€” store everything, then make it findable.

Their MemPalace scored 96.6% on LongMemEval (the standard benchmark for AI memory) in raw mode โ€” the highest published result requiring zero API calls. The full system hit 100% with hybrid reranking, sparking a glorious internet debate about benchmarks and bragging rights. 7,000+ GitHub stars in 48 hours. Not bad for an actress and a developer with an idea.

pi-mempalace takes that core philosophy โ€” verbatim storage + semantic search โ€” and reimagines it as a native pi extension. No Python. No ChromaDB. No pip install nightmares. Just pure TypeScript running in-process, fast enough to forget that forgetting was ever a problem.


โœจ What It Does

  • ๐Ÿ”„ Auto-capture โ€” Every conversation exchange is stored automatically after each turn. You don't have to remember to remember.
  • ๐ŸŒ… Wake-up context โ€” Each new session starts with a whisper of who you are and what you've been up to (~600-900 tokens of "previously on your life").
  • ๐Ÿ” Semantic search โ€” Find past decisions by meaning, not keywords. "Why did we pick that database?" just works.
  • ๐Ÿ“ Project-aware โ€” Memories are tagged by project (auto-detected from your directory) and topic. Your work stays organized even if you don't.
  • ๐Ÿ  Fully local โ€” Embeddings computed in-process via all-MiniLM-L6-v2. No cloud calls. No API keys. No surveillance capitalism. Just you and your memories.
  • ๐Ÿ“Š Beautiful stats โ€” Sparkline activity charts, bar graphs by project/topic, and a TUI overlay that makes you feel like a hacker in a 90s movie.

๐Ÿš€ Install

# Install from npm
pi install npm:pi-mempalace

# Or from GitHub
pi install https://github.com/Jabbslad/pi-mempalace

# Or from a local checkout
pi install /path/to/pi-mempalace

That's it. pi install runs npm install automatically, which pulls in all three runtime dependencies:

Dependency What It Does Native?
@huggingface/transformers Local embeddings (all-MiniLM-L6-v2, 384 dims) No โ€” pure JS, downloads model on first use (~80MB)
better-sqlite3 SQLite database access Yes โ€” compiles native addon via node-gyp
sqlite-vec Vector similarity search for SQLite Yes โ€” ships prebuilt binary per platform

No Python. No conda. No Docker. No ChromaDB server. No API keys. No sacrificial offerings to the dependency gods.

Prerequisites

  • Node.js (required by pi)
  • C++ toolchain for better-sqlite3's native build:
    • macOS: xcode-select --install
    • Linux: sudo apt install build-essential (or equivalent)
    • Windows: Visual Studio Build Tools

Most dev machines already have this. If pi install fails with gyp errors, that's the fix.


๐ŸŽฎ Quick Start

# Set up your identity and verify everything works
/skill:memory-setup

# Explicitly save something important
memory_save("We chose PostgreSQL for concurrent write support", project: "myapp", topic: "database")

# Search later, when you've inevitably forgotten
memory_search("why did we pick the database?")

# Browse a project's collected wisdom
memory_recall(project: "myapp")

# Check on your growing brain
memory_status()

๐Ÿงฐ Tools

Memory Tools

Tool What It Does
memory_search Semantic search across all stored memories โ€” find things by meaning
memory_save Explicitly save important info โ€” for those "remember this" moments
memory_recall Browse memories by project/topic โ€” like flipping through a journal
memory_status Memory store overview โ€” how big is your brain now?

Palace Graph Tools

Tool What It Does
memory_graph Visualize the palace โ€” projects as wings, shared topics as tunnel connections
memory_tunnel Traverse a tunnel between two projects via a shared topic

Knowledge Graph Tools

Tool What It Does
knowledge_add Add structured facts โ€” "myapp uses PostgreSQL since 2025-01"
knowledge_query Query facts about an entity, with temporal filtering โ€” "what did we use in 2024?"
knowledge_status Knowledge graph stats โ€” entities, facts, predicates

โŒจ๏ธ Commands

Command What It Does
/memory status Quick status overview
/memory stats Full stats overlay with sparklines and bar charts
/memory project <name> Set current project context
/memory search <query> Quick search shortcut
/memory graph Show palace graph with cross-project connections
/memory knowledge <entity> Query knowledge graph for an entity
/memory on / off Enable/disable memory (for those private moments)

๐Ÿ—๏ธ Architecture

Following the MemPalace 4-layer memory stack:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  L0: IDENTITY (~100 tokens)                             โ”‚
โ”‚  Always loaded. ~/.pi/agent/memory/identity.txt         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  L1: ESSENTIAL STORY (~500-800 tokens)                  โ”‚
โ”‚  Top 15 memories by importance + recency.               โ”‚
โ”‚  Grouped by project. Injected at session start.         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  L2: ON-DEMAND PROJECT CONTEXT                          โ”‚
โ”‚  Filtered by project/topic via SQL indexes.             โ”‚
โ”‚  Loaded only when you ask about a specific area.        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  L3: DEEP SEMANTIC SEARCH                               โ”‚
โ”‚  Full vector similarity via sqlite-vec ANN index.       โ”‚
โ”‚  Searches 100K+ memories in milliseconds.               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
pi (TypeScript โ€” everything in-process)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  extensions/pi-mempalace/                        โ”‚
โ”‚                                                  โ”‚
โ”‚  index.ts                memory_store.ts         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ turn_end โ†’        โ”‚    โ”‚ MemoryStore        โ”‚  โ”‚
โ”‚  โ”‚   auto-capture    โ”‚โ”€โ”€โ”€โ”‚                    โ”‚  โ”‚
โ”‚  โ”‚ before_agent โ†’    โ”‚    โ”‚ SQLite + sqlite-vecโ”‚  โ”‚
โ”‚  โ”‚   L0+L1 inject    โ”‚โ†โ”€โ”€โ”‚ ANN vector search  โ”‚  โ”‚
โ”‚  โ”‚ Tools + Commands  โ”‚    โ”‚ Metadata indexes   โ”‚  โ”‚
โ”‚  โ”‚ Stats TUI overlay โ”‚    โ”‚ WAL mode           โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚                    โ”‚  โ”‚
โ”‚                           โ”‚ ~/.pi/agent/       โ”‚  โ”‚
โ”‚                           โ”‚   memory/          โ”‚  โ”‚
โ”‚                           โ”‚     memories.db    โ”‚  โ”‚
โ”‚                           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                  โ”‚
โ”‚  @huggingface/transformers                       โ”‚
โ”‚    all-MiniLM-L6-v2 (384 dimensions)             โ”‚
โ”‚                                                  โ”‚
โ”‚  better-sqlite3 + sqlite-vec                     โ”‚
โ”‚    Indexed storage + vector similarity search    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โšก Performance

Benchmarked on Apple Silicon (M-series). Your mileage may vary, but it'll be fast.

Operation Time Vibes
Model load (first store) ~200ms โ˜• One-time cost per session
Store 1 memory (warm) ~1ms โšก Blink and you'll miss it
Search 100 memories ~1ms ๐Ÿš€ Faster than you can forget
Wakeup L0+L1 <1ms ๐ŸŒ… Instant dawn
Recall L2 (filtered) <1ms ๐ŸŽฏ SQL indexes go brrr
Knowledge graph query <1ms ๐Ÿงฉ Basically free
Palace graph <1ms ๐Ÿฐ All the tunnels, no waiting

๐Ÿ’พ Storage

Memories live in a SQLite database at ~/.pi/agent/memory/memories.db, powered by sqlite-vec for vector similarity search. Metadata is indexed (project, topic, timestamp) for fast pre-filtering before vector search kicks in. Deduplication via SHA-256 hash means you can't accidentally remember the same thing twice โ€” unlike that embarrassing story you keep retelling at parties.

Migrating from v0.1? If you have an existing memories.jsonl file, it's automatically migrated to SQLite on first load. Your old file is renamed to .bak. No data lost, no action needed.


๐Ÿฐ The Full MemPalace Architecture

The original MemPalace uses a gorgeous metaphorical architecture โ€” Wings (top-level containers), Rooms (topics), Halls (corridors by memory type), Closets (compressed summaries), and Drawers (verbatim source files). It runs on Python with ChromaDB and includes AAAK, a custom 30x compression dialect that any LLM can read natively.

pi-mempalace faithfully implements the core MemPalace architecture in TypeScript:

MemPalace Concept pi-mempalace Implementation
Wings (projects/people) project field โ€” auto-detected from git repo
Rooms (topics within wings) topic field โ€” set per memory
Drawers (verbatim chunks) 800-char chunks with 100-char overlap, each with its own embedding
Tunnels (cross-wing connections) memory_graph discovers shared topics across projects
4-Layer Stack L0 Identity โ†’ L1 Essential Story โ†’ L2 On-Demand โ†’ L3 Deep Search
Knowledge Graph Temporal triples with valid_from/valid_to โ€” "what was true when?"
ChromaDB SQLite + sqlite-vec โ€” same HNSW indexing, no Python

The one thing we deliberately skip is AAAK compression โ€” MemPalace's own benchmarks show it drops accuracy from 96.6% to 84.2%. We'll take the storage cost over the precision loss.

The soul is the same: your AI should remember you.

If you want the full palace experience with all its wings and halls and drawers, go check out mempalace.tech. Milla and Ben built something special.


๐Ÿ“Š Benchmark Validation

We reproduce LongMemEval โ€” the standard benchmark for AI memory systems โ€” to validate that our implementation matches MemPalace's retrieval quality. The benchmark stores 500 questions, each with ~50 timestamped conversation sessions, and measures whether the correct session appears in the top-K search results.

Results (Raw Mode โ€” Zero API, Fully Local)

Metric pi-mempalace MemPalace (reference) Delta
Recall@5 95.8% (479/500) 96.6% (483/500) -0.8pp
Recall@10 98.2% (491/500) 98.2% (491/500) identical
NDCG@10 0.884 0.889 -0.005

Per Question Type

Question Type R@5 R@10 Questions
knowledge-update ๐ŸŸข 100% 100% 78
multi-session ๐ŸŸข 97.7% 98.5% 133
temporal-reasoning ๐ŸŸก 94.7% 99.2% 133
single-session-assistant ๐ŸŸก 94.6% 96.4% 56
single-session-user ๐ŸŸก 92.9% 95.7% 70
single-session-preference ๐ŸŸก 90.0% 96.7% 30

The 0.8pp R@5 gap comes from our 800-char chunking (MemPalace stores whole sessions in benchmark mode) and minor differences between sqlite-vec and ChromaDB's HNSW implementations. The weakest categories (temporal, preference) are exactly what MemPalace's hybrid modes address with keyword re-ranking and temporal boosting โ€” features we haven't implemented.

Run It Yourself

# Download the LongMemEval dataset (~277MB)
curl -fsSL -o benchmarks/data/longmemeval_s_cleaned.json \
  https://huggingface.co/datasets/xiaowu0162/longmemeval-cleaned/resolve/main/longmemeval_s_cleaned.json

# Run full benchmark (500 questions, ~4 minutes)
npx tsx benchmarks/longmemeval_bench.mjs

# Quick smoke test (10 questions, ~5 seconds)
npx tsx benchmarks/longmemeval_bench.mjs --limit 10

# Save per-question results
npx tsx benchmarks/longmemeval_bench.mjs --out benchmarks/results/raw_500.jsonl

๐Ÿค” Why Not Just Use MemPalace Directly?

You absolutely could! MemPalace is great. But if you're already living in the pi ecosystem:

  • No Python required โ€” pi-mempalace is pure TypeScript, runs in-process
  • Full MemPalace architecture โ€” 4-layer stack, chunking, palace graph, knowledge graph
  • SQLite instead of ChromaDB โ€” one file, no server, native Node.js via better-sqlite3
  • Palace graph with tunnels โ€” discover cross-project connections via shared topics
  • Temporal knowledge graph โ€” structured facts with time validity ("what was true when?")
  • Auto-chunking โ€” long content split into 800-char chunks with overlap, just like MemPalace
  • Native pi integration โ€” hooks into pi's extension system, session lifecycle, and TUI
  • Auto-capture built in โ€” no manual memory management needed
  • Wake-up context โ€” L0 identity + L1 essential story, injected before you even ask
  • Zero config โ€” install it and go. It just works.

๐Ÿ“œ License

MIT โ€” because memories should be free.