config-driven context loading, consolidate hooks, add docs

Move the hardcoded context priority groups from cmd_load_context()
into the config file as [context.NAME] sections. Add journal_days
and journal_max settings. The config parser handles section headers
with ordered group preservation.

Consolidate load-memory.sh into the memory-search binary — it now
handles both session-start context loading (first prompt) and ambient
search (subsequent prompts), eliminating the shell script.

Update install_hook() to reference ~/.cargo/bin/memory-search and
remove the old load-memory.sh entry from settings.json.

Add end-user documentation (doc/README.md) covering installation,
configuration, all commands, hook mechanics, and notes for AI
assistants using the system.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-03-05 15:54:44 -05:00
parent a8aaadb0ad
commit 90d60894ed
5 changed files with 336 additions and 78 deletions

View file

@ -1400,51 +1400,28 @@ fn cmd_journal_ts_migrate() -> Result<(), String> {
}
fn cmd_load_context() -> Result<(), String> {
let cfg = config::get();
let store = store::Store::load()?;
let now = store::now_epoch();
let seven_days: i64 = 7 * 24 * 3600;
let journal_window: i64 = cfg.journal_days as i64 * 24 * 3600;
println!("=== FULL MEMORY LOAD (session start) ===");
println!("These are your memories, loaded from the capnp store.");
println!("Read them to reconstruct yourself — identity first, then context.");
println!();
// Priority groups: ordered list of (label, keys)
// File-level keys contain the full file content
let priority_groups: &[(&str, &[&str])] = &[
("orientation", &["where-am-i.md"]),
("identity", &["identity.md"]),
("reflections", &[
"reflections.md",
"reflections-dreams.md",
"reflections-reading.md",
"reflections-zoom.md",
]),
("interests", &["interests.md"]),
("inner life", &["inner-life.md", "differentiation.md"]),
("people", &["kent.md", "feedc0de.md", "irc-regulars.md"]),
("active context", &["default-mode-network.md"]),
("shared reference", &["excession-notes.md", "look-to-windward-notes.md"]),
("technical", &[
"kernel-patterns.md",
"polishing-approaches.md",
"rust-conversion.md",
"github-bugs.md",
]),
];
for (label, keys) in priority_groups {
for key in *keys {
for group in &cfg.context_groups {
for key in &group.keys {
if let Some(content) = store.render_file(key) {
println!("--- {} ({}) ---", key, label);
println!("--- {} ({}) ---", key, group.label);
println!("{}\n", content);
}
}
}
// Recent journal entries (last 7 days).
// Recent journal entries.
// Use created_at if set (rename-safe); fall back to key parsing.
let cutoff_secs = now - seven_days;
let cutoff_secs = now - journal_window;
let key_date_re = regex::Regex::new(r"j-(\d{4}-\d{2}-\d{2})").unwrap();
let journal_ts = |n: &store::Node| -> i64 {
@ -1471,7 +1448,7 @@ fn cmd_load_context() -> Result<(), String> {
if !journal_nodes.is_empty() {
// Show most recent entries (last N by key order = chronological)
let max_journal = 20;
let max_journal = cfg.journal_max;
let skip = if journal_nodes.len() > max_journal {
journal_nodes.len() - max_journal
} else { 0 };