factor instructions out of code into default files

Instructions and starter identity are now files in defaults/ that
get installed to data_dir by `poc-memory init`. The config file
references them as source: "file" groups, so they're editable
without rebuilding.

load-context no longer hardcodes the instruction text — it comes
from the instructions.md file in data_dir, which is just another
context group.

New user setup path:
  cargo install --path .
  poc-memory init
  # edit ~/.config/poc-memory/config.jsonl
  # start a Claude session

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-03-05 16:21:13 -05:00
parent 8bb3a554cf
commit 9bca1f94e3
4 changed files with 80 additions and 22 deletions

View file

@ -371,6 +371,12 @@ fn cmd_init() -> Result<(), String> {
std::fs::create_dir_all(&cfg.data_dir)
.map_err(|e| format!("create data_dir: {}", e))?;
// Install default files (instructions, starter identity) if missing
install_default_file(&cfg.data_dir, "instructions.md",
include_str!("../defaults/instructions.md"))?;
install_default_file(&cfg.data_dir, "identity.md",
include_str!("../defaults/identity.md"))?;
// Initialize store
let mut store = store::Store::load()?;
let count = store.init_from_markdown()?;
@ -380,7 +386,7 @@ fn cmd_init() -> Result<(), String> {
// Install hooks
daemon::install_hook()?;
// Create example config if none exists
// Create config if none exists
let config_path = std::env::var("POC_MEMORY_CONFIG")
.map(std::path::PathBuf::from)
.unwrap_or_else(|_| {
@ -402,6 +408,16 @@ fn cmd_init() -> Result<(), String> {
Ok(())
}
fn install_default_file(data_dir: &std::path::Path, name: &str, content: &str) -> Result<(), String> {
let path = data_dir.join(name);
if !path.exists() {
std::fs::write(&path, content)
.map_err(|e| format!("write {}: {}", name, e))?;
println!("Created {}", path.display());
}
Ok(())
}
fn cmd_migrate() -> Result<(), String> {
migrate::migrate()
}
@ -1507,24 +1523,7 @@ fn cmd_load_context(args: &[String]) -> Result<(), String> {
return Ok(());
}
let name = &cfg.assistant_name;
println!("=== MEMORY SYSTEM ({name}) ===");
println!("Your persistent memory, loaded from the capnp store.");
println!("Read to reconstruct yourself — identity first, then context.");
println!();
println!("--- memory commands (reference) ---");
println!("poc-memory search QUERY — search (1-3 words, AND logic)");
println!("poc-memory used KEY — mark a recalled memory as useful (boosts weight)");
println!("poc-memory wrong KEY [CTX] — mark a memory as wrong (reduces weight)");
println!("poc-memory gap DESCRIPTION — record a knowledge gap");
println!("poc-memory journal-write TEXT — write a journal entry");
println!("poc-memory render KEY — view a node's content");
println!("poc-memory write KEY < TEXT — upsert a node from stdin");
println!();
println!("When recalled memories shaped your response, call `poc-memory used KEY`.");
println!("When a memory was wrong, call `poc-memory wrong KEY`.");
println!("This closes the feedback loop — the weight system learns from use.");
println!("=== MEMORY SYSTEM ({}) ===", cfg.assistant_name);
println!();
for group in &cfg.context_groups {