session: --session flag, journal agent cycle, conversation bytes config
- memory-search: add --session flag for multi-session support - config: add surface_conversation_bytes option - journal_agent_cycle: trigger journal agent every 10KB of conversation - Session::from_id() constructor Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
parent
7c0c376e0f
commit
84c78f7ae1
4 changed files with 91 additions and 18 deletions
|
|
@ -18,6 +18,10 @@ struct Args {
|
|||
#[arg(long)]
|
||||
hook: bool,
|
||||
|
||||
/// Session ID (overrides stash file; for multiple concurrent sessions)
|
||||
#[arg(long)]
|
||||
session: Option<String>,
|
||||
|
||||
#[command(subcommand)]
|
||||
command: Option<Cmd>,
|
||||
}
|
||||
|
|
@ -30,13 +34,19 @@ enum Cmd {
|
|||
Reflect,
|
||||
}
|
||||
|
||||
fn show_seen() {
|
||||
let input = match fs::read_to_string(STASH_PATH) {
|
||||
Ok(s) => s,
|
||||
Err(_) => { eprintln!("No session state available"); return; }
|
||||
};
|
||||
let Some(session) = poc_memory::memory_search::Session::from_json(&input) else {
|
||||
eprintln!("No session state available");
|
||||
fn resolve_session(session_arg: &Option<String>) -> Option<poc_memory::memory_search::Session> {
|
||||
use poc_memory::memory_search::Session;
|
||||
|
||||
if let Some(id) = session_arg {
|
||||
return Session::from_id(id.clone());
|
||||
}
|
||||
let input = fs::read_to_string(STASH_PATH).ok()?;
|
||||
Session::from_json(&input)
|
||||
}
|
||||
|
||||
fn show_seen(session_arg: &Option<String>) {
|
||||
let Some(session) = resolve_session(session_arg) else {
|
||||
eprintln!("No session state available (use --session ID)");
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -75,18 +85,18 @@ fn show_seen() {
|
|||
}
|
||||
}
|
||||
|
||||
fn run_agent_and_parse(agent: &str) {
|
||||
let session_id = std::env::var("CLAUDE_SESSION_ID")
|
||||
.or_else(|_| {
|
||||
fn run_agent_and_parse(agent: &str, session_arg: &Option<String>) {
|
||||
let session_id = session_arg.clone()
|
||||
.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))
|
||||
.map(|s| s.session_id)
|
||||
.ok_or(std::env::VarError::NotPresent)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
if session_id.is_empty() {
|
||||
eprintln!("No session ID available (set CLAUDE_SESSION_ID or run --hook first)");
|
||||
eprintln!("No session ID available (use --session ID, set CLAUDE_SESSION_ID, or run --hook first)");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -180,8 +190,8 @@ fn main() {
|
|||
|
||||
if let Some(cmd) = args.command {
|
||||
match cmd {
|
||||
Cmd::Surface => run_agent_and_parse("surface"),
|
||||
Cmd::Reflect => run_agent_and_parse("reflect"),
|
||||
Cmd::Surface => run_agent_and_parse("surface", &args.session),
|
||||
Cmd::Reflect => run_agent_and_parse("reflect", &args.session),
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -203,6 +213,6 @@ fn main() {
|
|||
let output = poc_memory::memory_search::run_hook(&input);
|
||||
print!("{}", output);
|
||||
} else {
|
||||
show_seen()
|
||||
show_seen(&args.session)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue