From 3b1351018d3184caa5b5ca25cc13e5da1fc02229 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 15:41:46 +0100 Subject: 0.4.5: CLI validation, instruction scope, resume context, prompt hygiene - session ids validated; missing flag values and conflicting flags are usage errors - -- terminator; usage goes to stderr - doctor sends a real session header - sessions record their starting cwd and warn when resumed elsewhere - AGENTS.md stops at the git root; no parent-directory injection - typeahead flush, Ctrl-C during prompts, NO_COLOR/TERM=dumb --- src/session.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/session.rs') diff --git a/src/session.rs b/src/session.rs index f27a188..6e3c1c1 100644 --- a/src/session.rs +++ b/src/session.rs @@ -51,6 +51,8 @@ fn restrict(path: &Path, mode: u32) { pub struct Session { pub id: String, pub model: String, + /// Directory the session was started in; the system prompt is frozen with it. + pub cwd: String, path: PathBuf, file: File, } @@ -83,10 +85,14 @@ impl Session { .map_err(|e| format!("{}: {e}", path.display()))?; restrict(&path, 0o600); + let cwd = std::env::current_dir() + .map(|path| path.display().to_string()) + .unwrap_or_default(); let header = json!({ "t": "header", "session": id, "model": model, + "cwd": cwd, "created": now_ms(), "system": system, }); @@ -96,6 +102,7 @@ impl Session { Ok(Session { id, model: model.to_string(), + cwd, path, file, }) @@ -111,6 +118,7 @@ impl Session { let mut model = String::new(); let mut system = Value::Null; let mut session_id = id.to_string(); + let mut cwd = String::new(); let mut messages = Vec::new(); for line in reader.lines() { @@ -134,6 +142,9 @@ impl Session { if let Some(s) = value.get("session").and_then(|s| s.as_str()) { session_id = s.to_string(); } + if let Some(c) = value.get("cwd").and_then(|c| c.as_str()) { + cwd = c.to_string(); + } } Some("msg") => { let mut message = value.clone(); @@ -158,6 +169,7 @@ impl Session { Session { id: session_id, model, + cwd, path, file, }, -- cgit v1.2.3