Skip to main content

palace/
lib.rs

1//! Local-first memory for AI assistants.
2//!
3//! `palace-rs` stores verbatim text as *drawers* in one SQLite file, embeds it
4//! locally with ONNX Runtime, and retrieves it with hybrid (vector + BM25)
5//! search. A temporal knowledge graph keeps facts with validity windows.
6//! The same crate powers the `palace` CLI and MCP server.
7//!
8//! # Using it as a library
9//!
10//! Turn off the default `cli` feature to leave out the CLI dependencies:
11//!
12//! ```toml
13//! [dependencies]
14//! palace-rs = { version = "0.19", default-features = false }
15//! ```
16//!
17//! The library is imported as `palace`:
18//!
19//! ```
20//! use palace::{db, knowledge_graph, store};
21//!
22//! # fn main() -> anyhow::Result<()> {
23//! let conn = db::open_in_memory()?;
24//! store::add_drawer(
25//!     &conn,
26//!     "wing_code",
27//!     "backend",
28//!     "We use SQLite with WAL mode for concurrent reads.",
29//!     None,
30//!     "architecture.md",
31//!     0,
32//!     "example",
33//!     4.0,
34//! )?;
35//! knowledge_graph::add_triple(
36//!     &conn,
37//!     "Palace",
38//!     "stores_data_in",
39//!     "SQLite",
40//!     Some("2026-04-01"),
41//!     None,
42//!     1.0,
43//!     None,
44//!     None,
45//! )?;
46//! assert_eq!(store::count_drawers(&conn)?, 1);
47//! # Ok(())
48//! # }
49//! ```
50//!
51//! Starting points:
52//!
53//! - [`db`] opens a palace (`db::open` for a file, `db::open_in_memory` for tests).
54//! - [`store`] adds, updates, and lists drawers.
55//! - [`palace::Palace`] wraps a palace for search, including
56//!   [`palace::Palace::search_with_provenance`] for scored, cited results.
57//! - [`knowledge_graph`] adds and queries facts.
58//! - [`embedder`] embeds text with the active local model.
59
60#![recursion_limit = "256"]
61
62pub mod backend;
63pub mod backends;
64pub mod closet;
65pub mod config;
66pub mod convo_miner;
67pub mod db;
68pub mod dialect;
69pub mod embedder;
70pub mod embedding_eval;
71pub mod embedding_migration;
72pub mod embedding_models;
73pub mod entity_detector;
74pub mod export;
75pub mod feedback;
76pub mod gain;
77pub mod general_extractor;
78pub mod hall_router;
79pub mod hook_sessions;
80pub mod hooks;
81pub mod i18n;
82pub mod install;
83pub mod knowledge_graph;
84pub mod layers;
85pub mod manifest_entities;
86pub mod mcp_server;
87pub mod migrate;
88pub mod miner;
89pub mod normalize;
90pub mod onboarding;
91pub mod origin;
92pub mod palace;
93pub mod palace_graph;
94pub mod preference;
95pub mod query_intent;
96pub mod query_rewriter;
97pub mod query_sanitizer;
98pub mod ranker;
99pub mod remote;
100pub mod reranker;
101pub mod room_detector;
102pub mod searcher;
103pub mod split;
104pub mod store;
105pub mod sweep;
106pub mod time_query;
107pub mod usage;
108pub mod watcher;
109pub mod wings;
110
111#[cfg(feature = "cli")]
112pub mod cli;