init: install hooks + scaffold config; load-context: inline instructions

poc-memory init now:
- Creates the data directory
- Installs the memory-search hook into Claude settings.json
- Scaffolds a starter config.jsonl if none exists

load-context now prints a command reference block at the top so the
AI assistant learns how to use the memory system from the memory
system itself — no CLAUDE.md dependency needed.

Also extract install_hook() as a public function so both init and
daemon install can use it.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-03-05 16:17:49 -05:00
parent 0daf6ffd68
commit 8bb3a554cf
3 changed files with 75 additions and 6 deletions

View file

@ -646,13 +646,18 @@ WantedBy=default.target
eprintln!("Service enabled and started");
// Install memory-search hook into Claude settings
install_hook(&home, &exe)?;
install_hook()?;
Ok(())
}
fn install_hook(home: &str, exe: &Path) -> Result<(), String> {
let settings_path = PathBuf::from(home).join(".claude/settings.json");
/// Install the memory-search hook into Claude Code settings.json.
/// Public so `poc-memory init` can call it too.
pub fn install_hook() -> Result<(), String> {
let home = std::env::var("HOME").map_err(|e| format!("HOME: {}", e))?;
let exe = std::env::current_exe()
.map_err(|e| format!("current_exe: {}", e))?;
let settings_path = PathBuf::from(&home).join(".claude/settings.json");
let hook_binary = exe.with_file_name("memory-search");
if !hook_binary.exists() {