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 --- tests/prompt.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/prompt.rs (limited to 'tests/prompt.rs') diff --git a/tests/prompt.rs b/tests/prompt.rs new file mode 100644 index 0000000..38fbe40 --- /dev/null +++ b/tests/prompt.rs @@ -0,0 +1,41 @@ +use std::fs; +use std::path::PathBuf; + +use agent686::agent; + +fn temp_dir(tag: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!("agent686-prompt-{tag}-{}", std::process::id())); + let _ = fs::remove_dir_all(&dir); + fs::create_dir_all(&dir).unwrap(); + dir +} + +#[test] +fn project_instructions_stop_at_the_git_root() { + let dir = temp_dir("scope"); + let repo = dir.join("repo"); + fs::create_dir_all(repo.join("src")).unwrap(); + fs::create_dir_all(repo.join(".git")).unwrap(); + fs::write(dir.join("AGENTS.md"), "OUTSIDE THE REPO").unwrap(); + fs::write(repo.join("AGENTS.md"), "INSIDE THE REPO").unwrap(); + + let prompt = agent::system_prompt_for(&repo.join("src")); + let text = prompt["content"].as_str().unwrap(); + + assert!(text.contains("INSIDE THE REPO"), "{text}"); + assert!( + !text.contains("OUTSIDE THE REPO"), + "a parent AGENTS.md above the git root must not be injected" + ); +} + +#[test] +fn outside_a_repository_only_the_current_directory_is_read() { + let dir = temp_dir("norepo"); + fs::create_dir_all(dir.join("work")).unwrap(); + fs::write(dir.join("AGENTS.md"), "PARENT INSTRUCTIONS").unwrap(); + + let prompt = agent::system_prompt_for(&dir.join("work")); + let text = prompt["content"].as_str().unwrap(); + assert!(!text.contains("PARENT INSTRUCTIONS"), "{text}"); +} -- cgit v1.2.3