Memnest: Local-First Memory Management for AI Coding Assistants
Open source solution to persist AI assistant memory across sessions on your machine.
1Core Functionality
Memnest preserves AI coding assistants' (like pi, Claude Code, Codex) memory between sessions by storing decisions, preferences, and corrections locally. Unlike chat logs, it intentionally saves only user-designated information in an SQLite database. Conversation history remains verbatim and searchable through both keyword and semantic search without LLM summarization.
2Technical Architecture
Built with Rust, the service uses SQLite as single source of truth with Tantivy (BM25) and HNSW vector indexing for hybrid search capabilities. Local intfloat/multilingual-e5-base model enables semantic searches without internet. AES-256-GCM encryption secures sensitive data, with credentials stored separately from searchable content in a dedicated vault.
3Write and Read Paths
Write operations first persist data securely to SQLite, then update both keyword and vector indexes. Read operations combine results from both search methods using RRF fusion and MMR reranking algorithms (λ=0.5). This dual-path approach ensures accuracy by considering exact matches and semantic similarities simultaneously, returning top 60 results (k=60).
4Installation Options
Linux x86_64/aarch64 users install via single bash script, creating either system-wide or user-level systemd services. Windows/WSL setups use PowerShell scripts. Source compilation requires Rust toolchain (2024 edition). Post-installation, service exposes HTTP API and MCP endpoint at 127.0.0.1:3111. The npm package pi-memnest provides pi-specific integration after core service installation.
5Integration Methods
Any MCP-compatible client (pi, Claude Code, Codex etc.) integrates via JSON configuration specifying either HTTP endpoint (recommended) or direct binary path. Streamable HTTP allows multiple clients to share single server/data directory. Stdio mode is reserved for exclusive store access - secondary writers get rejected to prevent index corruption.
6Data Governance
Project isolation maintains separate workspaces while playbook rules apply globally. Credentials never appear in search results due to dedicated encrypted vault. Backup/restore procedures and retention policies are documented in docs/operations.md. CJK language support and reranker experiments are benchmarked in docs/retrieval-benchmarks.md.
7Performance Features
First write/search incurs embedding model download latency (≈500MB). Preload with memnest --warmup-embedding. Index jobs ensure write durability before searchability. BM25 excels at literal matches (port numbers, crate names) while HNSW handles paraphrases - maintaining both indexes covers complementary failure modes only discernible at query time.
8Fault Tolerance
Atomic SQLite transactions protect against data loss. Index jobs written with records enable interrupted writes to replay at startup. Dual indexes (BM25+HNSW) provide redundancy - each fails differently to queries. Workspace isolation prevents cross-project contamination while allowing shared playbook rules for consistent behavior.
9Use Cases
Developers can persist coding preferences (e.g., specific API usage patterns) across assistant sessions. Bug fixes and code refinements become permanent. Project-specific memory spaces enable multi-team usage on single machines without data leakage. Hybrid search retrieves precise information from historical interactions, combining exact string matches with conceptual similarity.
10Open Source Ecosystem
Hosted on GitHub with 141 commits, Memnest operates under MIT license. CONTRIBUTING.md outlines development practices while CODE_OF_CONDUCT.md sets community standards. The architecture enables extensions through adapters/core separation - current implementations support pi, Claude Code, and Codex via standardized MCP protocol, with room for additional client integrations.