Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/bunkerlab-net/mempalace
/ functions
Functions
2,248 in github.com/bunkerlab-net/mempalace
⨍
Functions
2,248
◇
Types & classes
117
↓ 214 callers
Function
test_db
Create an in-memory turso database with the full schema applied. Returns (Database, Connection) tuple to keep the Database alive for the test lifetime
src/test_helpers.rs:8
↓ 120 callers
Function
query_all
Collect all rows from a query into a Vec.
src/db.rs:62
↓ 92 callers
Function
with_isolated_env
Wraps the three-line test setup (tempdir, `async_with_vars`, `test_conn`) so callers only express what is under test. The connection is passed by val
src/mcp/tools.rs:2031
↓ 59 callers
Function
str_arg
Extract a string argument from the tool args JSON object. Returns an empty string when the key is absent or the value is not a string.
src/mcp/tools.rs:81
↓ 47 callers
Function
add_drawer
Add a drawer and index its words. Returns `true` when the drawer was inserted, `false` when a drawer with the same `id` already exists (idempotent —
src/palace/drawer.rs:562
↓ 44 callers
Function
seed_drawer
(connection: &Connection, wing: &str, room: &str, content: &str)
src/mcp/tools.rs:2019
↓ 38 callers
Function
run
(cli: Cli)
src/app.rs:34
↓ 36 callers
Function
test_registry
Create a fresh registry backed by a temporary directory.
src/palace/entity_registry.rs:1366
↓ 34 callers
Method
find
Return the canonical root for `x`, inserting `x` as its own root on first access. Path compression is applied so repeated calls are nearly O(1).
src/palace/project_scanner.rs:213
↓ 27 callers
Function
get_entity_patterns
Return merged entity detection patterns for the requested language codes. Language codes are matched case-insensitively (e.g., `"PT-BR"` or `"pt-br"`
src/i18n/mod.rs:117
↓ 24 callers
Function
dispatch
Dispatch a tool call by name and return the JSON result.
src/mcp/tools.rs:32
↓ 24 callers
Function
sanitize_name
Validate a wing/room/entity name. Returns `Some(error_json)` if invalid. Validates and trims `value`. Returns `Ok(trimmed)` on success, or `Err(err
src/mcp/tools.rs:139
↓ 21 callers
Function
add_to_known_entities
Merge `entities_by_category` into the global known-entities registry. - List-format categories: union case-insensitively, original order preserved. -
src/palace/known_entities.rs:57
↓ 21 callers
Function
hook_log
Append a timestamped line to `hook.log` in `state_dir`.
src/cli/hook.rs:1094
↓ 21 callers
Method
seed
Seed the registry from onboarding data and persist to disk. Clears existing `people` and `projects`; ambiguous flags are rebuilt from the new people
src/palace/entity_registry.rs:360
↓ 21 callers
Function
with_temp_registry
(f: F)
src/palace/known_entities.rs:399
↓ 18 callers
Function
handle_request
Validate request shape and dispatch to `handle_request_dispatch`. Returns `None` for notifications (no response required per JSON-RPC 2.0).
src/mcp/mod.rs:247
↓ 18 callers
Function
strip_noise
Remove system tags, hook output, and Claude Code UI chrome from a message. Applied per message (never across boundaries) so a dangling open tag in on
src/normalize/claude_code.rs:128
↓ 17 callers
Function
search_memories
Search the palace using BM25-ranked inverted-index search. Two-pass approach: the first pass selects up to `n_results × BM25_OVERFETCH` candidates by
src/palace/search.rs:59
↓ 16 callers
Function
config_dir
Returns the mempalace data directory. Resolution order: 1. `MEMPALACE_DIR` env var — explicit user, container, or test override. 2. `MEMPAL_DIR` env
src/config.rs:65
↓ 16 callers
Function
sanitize_opt_name
Validate an optional name filter. Returns `Ok(None)` if the value is empty/whitespace-only, `Ok(Some(trimmed))` if valid, or `Err(error_json)` if the
src/mcp/tools.rs:242
↓ 16 callers
Function
tool_diary_write
Append a diary entry for an agent in its personal wing. When `wing` is supplied it is used directly (after sanitization); otherwise the wing is deriv
src/mcp/tools.rs:1520
↓ 16 callers
Function
try_parse
Try to parse Claude.ai JSON export into transcript text. Accepts three formats: - JSON array of message objects (`[{"role":…,"content":…}]`) - Object
src/normalize/claude_ai.rs:21
↓ 15 callers
Function
add_triple
Add a relationship triple. Auto-creates entities if they don't exist. Returns the triple ID.
src/kg/mod.rs:747
↓ 15 callers
Function
open_palace
Open the palace DB, ensuring schema exists. Returns `(db, connection, path)`. `palace_override` takes priority over `MEMPALACE_PALACE_PATH` and the c
src/app.rs:12
↓ 14 callers
Method
compress
Compress plain text into AAAK Dialect format.
src/dialect/mod.rs:315
↓ 14 callers
Function
mine
Mine a project directory into the palace.
src/palace/miner.rs:906
↓ 14 callers
Function
normalize
Normalize a file to transcript format. Detects format automatically and converts to `> user\nresponse\n\n` format.
src/normalize/mod.rs:19
↓ 14 callers
Function
sanitize_iso_temporal
Validate an ISO-8601 date or canonical UTC datetime string for KG temporal fields. Accepts `None` and the empty string as pass-through values so call
src/config.rs:210
↓ 13 callers
Function
expand_tilde
Expand a leading `~` to the user's home directory. Resolves the home directory by trying `HOME`, then `USERPROFILE`, then `HOMEDRIVE` + `HOMEPATH` (W
src/config.rs:138
↓ 13 callers
Function
hook_parse_message_line
Extract user-message text from a single JSONL line; return `None` to skip. Handles both Claude Code (`message.role == "user"`) and Codex CLI (`type =
src/cli/hook.rs:497
↓ 13 callers
Function
onboarding_readline
Print a prompt to stdout and read one trimmed line from `reader`. When `default` is `Some("")` the prompt shows nothing extra; when `default` is `Som
src/cli/onboarding.rs:804
↓ 13 callers
Function
run_read_line_impl
Generic core of `run_read_line` — accepts any `AsyncBufRead` so tests can drive the algorithm with a `Cursor` rather than a real stdin handle.
src/mcp/mod.rs:138
↓ 13 callers
Function
serve_once
Bind a random port, accept exactly one connection, and respond with `body` as JSON. Returns the port so callers can build an endpoint URL. The spawne
src/llm/client.rs:922
↓ 13 callers
Function
text_samples
(texts: &[&str])
src/palace/corpus_origin.rs:568
↓ 12 callers
Function
extract_memories
Extract memories from text, classifying into 5 types: decision, preference, milestone, problem, emotional.
src/extract/mod.rs:35
↓ 12 callers
Function
make_dict
(people: Vec<&str>, projects: Vec<&str>, uncertain: Vec<&str>)
src/llm/refine.rs:628
↓ 12 callers
Function
messages_to_transcript
Convert [(role, text), ...] to transcript format with > markers.
src/normalize/mod.rs:110
↓ 12 callers
Function
mine_convos
Mine all conversation files in `directory`, filing chunks as drawers in the palace. Resolves the wing name, walks for eligible files, and delegates p
src/palace/convo_miner.rs:693
↓ 12 callers
Function
mine_load_config
Load project config from `project_dir`, trying config file names in precedence order: `mempalace.yaml`, `mempalace.yml`, `mempal.yaml`, `mempal.yml`.
src/palace/miner.rs:659
↓ 12 callers
Function
regenerate_closets
Regenerate `compressed` entries for drawers using a configured LLM. Optionally filters to a single `wing`. When `sample > 0`, only the first `sample`
src/palace/closet_llm.rs:89
↓ 12 callers
Function
tool_add_drawer
Insert a new drawer into the palace, computing a deterministic SHA256-based ID.
src/mcp/tools.rs:600
↓ 11 callers
Function
create_tunnel
Create (or update) an explicit tunnel between two palace locations. Tunnels are symmetric: calling with (A, B) and (B, A) both resolve to the same ca
src/palace/graph.rs:463
↓ 11 callers
Function
detect_origin_heuristic
(samples: &[String])
src/palace/corpus_origin.rs:455
↓ 11 callers
Function
list_tunnels
List explicit tunnels, optionally filtered to those involving a given wing.
src/palace/graph.rs:619
↓ 11 callers
Method
lookup
Look up a word and return its entity classification. Checks people registry first, then projects, then the wiki cache. Context is used to disambiguat
src/palace/entity_registry.rs:402
↓ 11 callers
Function
make_mega_file
Build a test file containing `n_sessions` Claude Code session blocks, each with at least 12 content lines so the 10-line minimum is satisfied.
src/cli/split.rs:691
↓ 11 callers
Method
palace_db_path
Resolve the palace database path, checking env vars in priority order. Resolution order: 1. `MEMPALACE_PALACE_PATH` — primary override. 2. `MEMPAL_PA
src/config.rs:399
↓ 11 callers
Function
tool_kg_add
Add a subject–predicate–object triple to the knowledge graph.
src/mcp/tools.rs:1188
↓ 10 callers
Function
acquire_mine_lock
Acquire an exclusive mine lock in `lock_dir`. Creates `lock_dir/mine.lock` atomically via `O_CREAT|O_EXCL` semantics. Returns `Err` immediately if th
src/palace/miner.rs:1012
↓ 10 callers
Method
classify
(&self, system: &str, user: &str, json_mode: bool)
src/llm/client.rs:176
↓ 10 callers
Function
confirm_entities
Accept or interactively confirm detected entities. - `yes=true`: all entities with `confidence >= CONFIDENCE_THRESHOLD` are accepted without promptin
src/palace/entity_confirm.rs:41
↓ 10 callers
Function
layer2
Layer 2: On-demand retrieval filtered by wing and/or room. Returns the most recent `results` drawers matching the given filters, formatted as a compa
src/palace/layers.rs:252
↓ 10 callers
Function
maybe_migrate
Migrate from `~/.mempalace` to `$XDG_DATA_HOME/mempalace` if needed. Idempotent: returns immediately if already migrated, legacy dir absent, or eithe
src/config.rs:454
↓ 10 callers
Function
normalize_wing_name
Normalize a directory name into a wing slug. Lowercases the name and replaces spaces and hyphens with underscores. This is the single canonical rule
src/config.rs:185
↓ 10 callers
Function
sanitize_kg_value
Validate a knowledge-graph entity value (subject or object). More permissive than `sanitize_name` — allows punctuation such as commas, colons, and pa
src/mcp/tools.rs:204
↓ 10 callers
Function
scan_project_with_opts
Scan a project directory for all readable files.
src/palace/miner.rs:96
↓ 10 callers
Function
upsert_closet_lines
Insert or replace closet content for a single drawer in the `compressed` table. Called after LLM-driven or regex-driven closet generation for a drawe
src/palace/closets.rs:53
↓ 10 callers
Function
write_jsonl
Write `lines` to a temp file named `name` in `dir` and return the path.
src/palace/sweeper.rs:533
↓ 9 callers
Function
add_triple_validate_params
Validate confidence and ISO temporal fields on a `TripleParams`. Both `valid_from` and `valid_to` are validated via [`crate::config::sanitize_iso_tem
src/kg/mod.rs:661
↓ 9 callers
Method
check_available
(&self)
src/llm/client.rs:141
↓ 9 callers
Function
check_text_flatten_names
Called by `check_text` to flatten the registry JSON into a set of entity names. Supports list-format (`["Alice", "Bob"]`) and dict-format (`{"Alice":
src/palace/fact_checker.rs:105
↓ 9 callers
Function
detect_entities
Scan files and detect entity candidates using the specified locale languages. Language codes are BCP 47 tags (e.g., `"en"`, `"de"`, `"pt-br"`). Stopw
src/palace/entity_detect.rs:51
↓ 9 callers
Function
extract_candidates
Extract capitalized-word candidates from `text`, filtered by stop words and a minimum frequency of 3 occurrences. Returns a map of candidate name to
src/palace/entity_detect.rs:290
↓ 9 callers
Function
hook_output
(data: &Value)
src/cli/hook.rs:1125
↓ 9 callers
Function
ingest_diaries
Ingest all diary files from `diary_dir` into the palace. Only files named `YYYY-MM-DD*.md` are processed. New sections discovered since the last run
src/palace/diary_ingest.rs:81
↓ 9 callers
Function
make_dict
(people: Vec<DetectedEntity>, projects: Vec<DetectedEntity>)
src/palace/entity_confirm.rs:184
↓ 9 callers
Function
merge_detected
Merge two [`DetectedDict`] values. Primary entries win on name conflict (case-insensitive). When `drop_uncertain` is `true`, the secondary's uncertai
src/palace/project_scanner.rs:991
↓ 9 callers
Function
query_entity
Query all relationships for an entity.
src/kg/query.rs:125
↓ 9 callers
Function
sanitize_query
(raw: &str)
src/palace/query_sanitizer.rs:50
↓ 9 callers
Function
score_entity_person_locale_signals
Called by `score_entity_person` to apply locale-specific verb, dialogue, and direct-address signals. Each template substitutes `{name}` with `escaped
src/palace/entity_detect.rs:520
↓ 9 callers
Function
tool_update_drawer
Update an existing drawer's content and/or location (wing/room). Recomputes the deterministic SHA256 ID after any change to keep it consistent with `
src/mcp/tools.rs:1075
↓ 9 callers
Function
user_record
Build a minimal valid Claude Code user record as a JSON string.
src/palace/sweeper.rs:540
↓ 8 callers
Function
check_text_check_claim
Called by `check_text_kg_contradictions` to evaluate one claim against retrieved KG facts. Fires `relationship_mismatch` when the KG records a differ
src/palace/fact_checker.rs:268
↓ 8 callers
Function
chunk_by_exchange
One user turn (>) + the full AI response that follows = one or more chunks. Each line is whitespace-trimmed and empty lines are dropped; the remainin
src/palace/convo_miner.rs:291
↓ 8 callers
Function
compile_regexes
(patterns: &[&str])
src/extract/mod.rs:216
↓ 8 callers
Method
confidence
Confidence that this is a real project. - `0.99` — user has commits (`is_mine`) - `0.7` — git repo with at least one commit by anyone (`has_git && t
src/palace/project_scanner.rs:101
↓ 8 callers
Method
confirm_research
Mark a researched word as confirmed and optionally promote it to the people registry. If `entity_type` is `"person"`, the word is added to `people` w
src/palace/entity_registry.rs:486
↓ 8 callers
Function
diary_ingest_change_decision
Compare the current diary file against its cursor entry and decide how much work to do. Strict mode (preferred): if a `content_hash` was recorded, on
src/palace/diary_ingest.rs:357
↓ 8 callers
Function
diary_ingest_drawer_id
Generate a stable, unique drawer ID for a diary section. Format: `diary-{wing_prefix}-{identity_hash}-{date}-{index}`. The 20-char sanitized prefix k
src/palace/diary_ingest.rs:613
↓ 8 callers
Function
entity_id
Normalize an entity name to an ID: lowercase, spaces→underscores, strip apostrophes.
src/kg/mod.rs:12
↓ 8 callers
Function
entity_registry_wikipedia_classify
Classify a Wikipedia REST API JSON response into a `WikiCacheEntry`. Checks `page_type` for disambiguation pages, then `extract` text for name and pl
src/palace/entity_registry.rs:1234
↓ 8 callers
Function
flatten_content_block
Render one assistant message content block as a plain string. Called by `flatten_content` for each element of an array-typed message. All block types
src/palace/sweeper.rs:79
↓ 8 callers
Function
hook_get_mine_targets
Collect `mempalace mine` project targets from `MEMPAL_DIR`. `MEMPAL_DIR` (when set, valid, and free of `..` traversal segments) contributes a `Projec
src/cli/hook.rs:661
↓ 8 callers
Function
json
Parse a JSON string literal into a `serde_json::Value`. Reduces boilerplate across tests that build JSON fixtures inline.
src/normalize/claude_ai.rs:159
↓ 8 callers
Function
run
Split mega-files in a directory into per-session files.
src/cli/split.rs:459
↓ 8 callers
Function
seed_alice_knows_bob
Seed a single "Alice knows Bob" triple for reuse across tests.
src/kg/query.rs:389
↓ 8 callers
Function
seed_drawers
(connection: &Connection)
src/palace/search.rs:977
↓ 8 callers
Function
tool_diary_read
Read the most recent diary entries for an agent, newest first. When `wing` is supplied the query is scoped to that wing AND to the requesting agent (
src/mcp/tools.rs:1607
↓ 8 callers
Function
tool_search
Full-text search the palace, returning ranked drawer results.
src/mcp/tools.rs:504
↓ 8 callers
Function
try_parse
Try to parse Claude Code JSONL format into transcript text. Each line is a JSON object with `"type"` (`"human"` or `"user"` for the human turn, `"ass
src/normalize/claude_code.rs:177
↓ 8 callers
Function
wal_log
Append a write-operation entry to `config_dir()/wal/write_log.jsonl`. The data directory is `$XDG_DATA_HOME/mempalace` by default, or the value of `M
src/mcp/tools.rs:312
↓ 7 callers
Function
apply_classifications
Apply LLM `decisions` to `detected`, routing each entity to its new category. Returns `(refined_dict, reclassified_count, dropped_count)`. Entities w
src/llm/refine.rs:441
↓ 7 callers
Function
chunk_text
Split content into drawer-sized chunks, breaking at paragraph/line boundaries.
src/palace/chunker.rs:60
↓ 7 callers
Function
classify_drawer
Classify one drawer by inspecting its source-file metadata. When `project_roots` is empty the caller is scoping the run via `--wing` alone (the `run`
src/cli/sync.rs:96
↓ 7 callers
Function
collect_corpus_text
Walk `dir` for prose files (`.md`, `.txt`, `.rst`) and return concatenated text. Caps output at [`MAX_CORPUS_BYTES`] and limits recursion via [`CORPU
src/llm/refine.rs:196
↓ 7 callers
Function
get_provider
Build an [`LlmProvider`] by name. Valid provider names: `"ollama"`, `"openai-compat"`, `"anthropic"`. Returns `Err(Error::Llm)` for unknown names.
src/llm/client.rs:524
↓ 7 callers
Function
index_words
Index the words in a drawer's content into the `drawer_words` table.
src/palace/drawer.rs:9
↓ 7 callers
Function
onboarding_generate_entity_codes
Generate AAAK entity codes for each person: first 3 letters uppercase. Collision is resolved by extending to 4 characters.
src/cli/onboarding.rs:575
↓ 7 callers
Function
regenerate_closets_format_content
Called by `regenerate_closets_process_drawer` to format `ClosetOutput` into stored text. Produces pipe-joined topics on one line, one quote per line,
src/palace/closet_llm.rs:330
next →
1–100 of 2,248, ranked by callers