poc-hook: call memory-search internally on UserPromptSubmit

Spawn memory-search --hook as a subprocess, piping the hook input
JSON through stdin and printing its stdout. This ensures memory
context injection goes through the same hook whose output Claude
Code reliably persists, fixing the issue where memory-search as a
separate hook had its output silently dropped.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-03-09 17:07:16 -04:00
parent c2f245740c
commit 6dc300fcf8

View file

@ -151,6 +151,28 @@ fn main() {
"UserPromptSubmit" => { "UserPromptSubmit" => {
signal_user(); signal_user();
check_notifications(); check_notifications();
// Run memory-search, passing through the hook input it needs
if let Ok(output) = Command::new("memory-search")
.arg("--hook")
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::null())
.spawn()
.and_then(|mut child| {
if let Some(ref mut stdin) = child.stdin {
use std::io::Write;
let _ = stdin.write_all(input.as_bytes());
}
child.wait_with_output()
})
{
let text = String::from_utf8_lossy(&output.stdout);
if !text.is_empty() {
print!("{text}");
}
}
if let Some(ref t) = transcript { if let Some(ref t) = transcript {
check_context(t, false); check_context(t, false);
} }