Expand description
Local-first memory for AI assistants.
palace-rs stores verbatim text as drawers in one SQLite file, embeds it
locally with ONNX Runtime, and retrieves it with hybrid (vector + BM25)
search. A temporal knowledge graph keeps facts with validity windows.
The same crate powers the palace CLI and MCP server.
§Using it as a library
Turn off the default cli feature to leave out the CLI dependencies:
[dependencies]
palace-rs = { version = "0.19", default-features = false }The library is imported as palace:
use palace::{db, knowledge_graph, store};
let conn = db::open_in_memory()?;
store::add_drawer(
&conn,
"wing_code",
"backend",
"We use SQLite with WAL mode for concurrent reads.",
None,
"architecture.md",
0,
"example",
4.0,
)?;
knowledge_graph::add_triple(
&conn,
"Palace",
"stores_data_in",
"SQLite",
Some("2026-04-01"),
None,
1.0,
None,
None,
)?;
assert_eq!(store::count_drawers(&conn)?, 1);Starting points:
dbopens a palace (db::openfor a file,db::open_in_memoryfor tests).storeadds, updates, and lists drawers.palace::Palacewraps a palace for search, includingpalace::Palace::search_with_provenancefor scored, cited results.knowledge_graphadds and queries facts.embedderembeds text with the active local model.
Modules§
- backend
- Backend contracts for storage implementations.
- backends
- cli
- CLI entry point using clap.
- closet
- Closet layer: compact topical pointers to verbatim drawers.
- config
- Configuration system for Palace.
- convo_
miner - Conversation file ingestor.
- db
- Database layer: SQLite with WAL mode and schema migrations.
- dialect
- AAAK dialect — compressed memory format for Palace.
- embedder
- Text embedding using ONNX Runtime and the models in
crate::embedding_models. - embedding_
eval - Known-item retrieval probes for comparing embedding models on a palace.
- embedding_
migration - Switching a palace to another embedding model without losing search.
- embedding_
models - Registry of embedding models Palace can run.
- entity_
detector - Lightweight entity detection for drawer metadata.
- export
- Palace export / import — portable JSON snapshots of all drawers.
- feedback
- Feedback through public GitHub Discussions.
- gain
- Aggregation and rendering for
palace gain. - general_
extractor - Extract typed memories from text using regex heuristics.
- hall_
router - Route drawer content into broad palace halls.
- hook_
sessions - Per-session activity recorded by the agent hooks.
- hooks
- Cursor hook response builders for automatic, model-independent memory use.
- i18n
- Locale metadata for entity detection.
- install
- knowledge_
graph - Temporal Entity-Relationship Knowledge Graph.
- layers
- 4-Layer Memory Stack.
- manifest_
entities - Detect project entities from common package manifests.
- mcp_
server - MCP Server — stdio JSON-RPC tool loop for AI coding assistants.
- migrate
- SQLite-to-SQLite migration helpers for older palace files.
- miner
- Project file ingestor.
- normalize
- Conversation format normalizer.
- onboarding
- Interactive first-run wizard.
- origin
- Corpus-origin detection for project and conversation mining.
- palace
- High-level facade for embedding the memory palace as a library.
- palace_
graph - Palace graph traversal.
- preference
- Preference sentence detection for improved agent memory recall.
- query_
intent - Lightweight query intent classification for adaptive retrieval.
- query_
rewriter - Query rewriting — normalises raw agent queries before embedding/BM25 lookup.
- query_
sanitizer - Query cleanup for agent-originated memory searches.
- ranker
- Hybrid retrieval: BM25 keyword scoring plus optional vector similarity.
- remote
- Remote MCP proxy transport.
- reranker
- Optional local reranking for top hybrid candidates.
- room_
detector - Room detection from folder structure and filename patterns. Writes and reads palace.yaml for a project. Port of room_detector_local.py.
- searcher
- Semantic search over the palace.
- split
- Split concatenated Claude Code mega-transcript files into per-session files.
- store
- Drawer CRUD and vector search.
- sweep
- Message-level transcript sweeper.
- time_
query - Relative time in queries: “two weeks ago”, “last Tuesday”, “in March”.
- usage
- Local usage telemetry for Palace MCP calls.
- watcher
- Incremental file watcher — re-mines changed files into the palace.
- wings
- Wing names: which wing a write lands in, and renaming or merging a wing.