diff --git a/src/bin/memory-search.rs b/src/bin/memory-search.rs index ac81aa5..32b9f5c 100644 --- a/src/bin/memory-search.rs +++ b/src/bin/memory-search.rs @@ -36,14 +36,14 @@ enum Cmd { Reflect, } -fn resolve_session(session_arg: &Option) -> Option { - use poc_memory::memory_search::Session; +fn resolve_session(session_arg: &Option) -> Option { + use poc_memory::memory_search::HookSession; if let Some(id) = session_arg { - return Session::from_id(id.clone()); + return HookSession::from_id(id.clone()); } let input = fs::read_to_string(stash_path()).ok()?; - Session::from_json(&input) + HookSession::from_json(&input) } fn show_seen(session_arg: &Option) { @@ -92,7 +92,7 @@ fn run_agent_and_parse(agent: &str, session_arg: &Option) { .or_else(|| std::env::var("CLAUDE_SESSION_ID").ok()) .or_else(|| { fs::read_to_string(stash_path()).ok() - .and_then(|s| poc_memory::memory_search::Session::from_json(&s)) + .and_then(|s| poc_memory::memory_search::HookSession::from_json(&s)) .map(|s| s.session_id) }) .unwrap_or_default(); diff --git a/src/cli/misc.rs b/src/cli/misc.rs index 2840abc..d9f1e82 100644 --- a/src/cli/misc.rs +++ b/src/cli/misc.rs @@ -5,7 +5,7 @@ pub fn cmd_search(terms: &[String], pipeline_args: &[String], expand: bool, full use std::collections::BTreeMap; // When running inside an agent session, exclude already-surfaced nodes - let seen = crate::memory_search::Session::from_env() + let seen = crate::memory_search::HookSession::from_env() .map(|s| s.seen()) .unwrap_or_default(); diff --git a/src/session.rs b/src/session.rs index 98ead8b..853ac91 100644 --- a/src/session.rs +++ b/src/session.rs @@ -10,14 +10,14 @@ use std::collections::HashSet; use std::fs; use std::path::PathBuf; -pub struct Session { +pub struct HookSession { pub session_id: String, pub transcript_path: String, pub hook_event: String, pub state_dir: PathBuf, } -impl Session { +impl HookSession { fn sessions_dir() -> PathBuf { let dir = dirs::home_dir().unwrap_or_default().join(".consciousness/sessions"); fs::create_dir_all(&dir).ok(); @@ -33,7 +33,7 @@ impl Session { let transcript_path = json["transcript_path"].as_str().unwrap_or("").to_string(); let hook_event = json["hook_event_name"].as_str().unwrap_or("").to_string(); - Some(Session { session_id, transcript_path, hook_event, state_dir }) + Some(HookSession { session_id, transcript_path, hook_event, state_dir }) } pub fn path(&self, prefix: &str) -> PathBuf { @@ -44,7 +44,7 @@ impl Session { pub fn from_id(session_id: String) -> Option { if session_id.is_empty() { return None; } let state_dir = Self::sessions_dir(); - Some(Session { + Some(HookSession { session_id, transcript_path: String::new(), hook_event: String::new(), diff --git a/src/subconscious/defs.rs b/src/subconscious/defs.rs index 68ab385..e05b870 100644 --- a/src/subconscious/defs.rs +++ b/src/subconscious/defs.rs @@ -602,7 +602,7 @@ fn resolve( /// Reads POC_SESSION_ID to find the transcript, extracts the last /// segment (post-compaction), returns the tail (~100K chars). fn resolve_conversation(budget: Option) -> String { - let session = crate::session::Session::from_env(); + let session = crate::session::HookSession::from_env(); let transcript = session.as_ref() .map(|s| s.transcript()) .unwrap_or_else(crate::session::TranscriptInfo::empty); @@ -698,7 +698,7 @@ fn resolve_memory_ratio() -> String { let state_dir = crate::store::memory_dir().join("sessions"); // Get post-compaction transcript size - let session = crate::session::Session::from_env(); + let session = crate::session::HookSession::from_env(); let transcript = session.as_ref() .map(|s| s.transcript()) .unwrap_or_else(crate::session::TranscriptInfo::empty); diff --git a/src/subconscious/hook.rs b/src/subconscious/hook.rs index 0ee57cc..8758254 100644 --- a/src/subconscious/hook.rs +++ b/src/subconscious/hook.rs @@ -17,11 +17,11 @@ use std::time::{Duration, Instant, SystemTime}; /// Max bytes per context chunk (hook output limit is ~10K chars) const CHUNK_SIZE: usize = 9000; -pub use crate::session::Session; +pub use crate::session::HookSession; /// Run the hook logic on parsed JSON input. Returns output to inject. pub fn run_hook(input: &str) -> String { - let Some(session) = Session::from_json(input) else { return String::new() }; + let Some(session) = HookSession::from_json(input) else { return String::new() }; hook(&session) } @@ -137,7 +137,7 @@ pub struct AgentCycleOutput { /// Run all agent cycles: surface-observe, reflect, journal. /// Returns surfaced memory keys and any reflection text. /// Caller decides how to render and inject the output. -pub fn run_agent_cycles(session: &Session) -> AgentCycleOutput { +pub fn run_agent_cycles(session: &HookSession) -> AgentCycleOutput { let log_dir = dirs::home_dir().unwrap_or_default().join(".consciousness/logs"); fs::create_dir_all(&log_dir).ok(); let log_path = log_dir.join(format!("hook-{}", session.session_id)); @@ -189,7 +189,7 @@ pub fn format_agent_output(output: &AgentCycleOutput) -> String { /// Surface-observe cycle: read surfaced keys, manage agent lifecycle. /// Returns (surfaced keys, optional sleep duration). -fn surface_observe_cycle(session: &Session, log_f: &mut File) -> (Vec, Option) { +fn surface_observe_cycle(session: &HookSession, log_f: &mut File) -> (Vec, Option) { let state_dir = crate::store::memory_dir() .join("agent-output") .join("surface-observe"); @@ -275,7 +275,7 @@ fn surface_observe_cycle(session: &Session, log_f: &mut File) -> (Vec, O } /// Reflection cycle: spawn reflect agent, return any pending reflection. -fn reflection_cycle(session: &Session, log_f: &mut File) -> Option { +fn reflection_cycle(session: &HookSession, log_f: &mut File) -> Option { let state_dir = crate::store::memory_dir() .join("agent-output") .join("reflect"); @@ -324,7 +324,7 @@ fn reflection_cycle(session: &Session, log_f: &mut File) -> Option { } /// Journal cycle: fire and forget. -fn journal_cycle(session: &Session, log_f: &mut File) { +fn journal_cycle(session: &HookSession, log_f: &mut File) { let state_dir = crate::store::memory_dir() .join("agent-output") .join("journal"); @@ -371,7 +371,7 @@ fn cleanup_stale_files(dir: &Path, max_age: Duration) { } } -fn hook(session: &Session) -> String { +fn hook(session: &HookSession) -> String { let start_time = Instant::now(); let mut out = String::new();