diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-15 15:41:46 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-15 15:41:46 +0100 |
| commit | 3b1351018d3184caa5b5ca25cc13e5da1fc02229 (patch) | |
| tree | 99bdc95ba444a5c4d2d3f09c4e5c04ff16108f8f /tests/prompt.rs | |
| parent | 0.4.4: file-tool correctness (diff) | |
| download | agent686-3b1351018d3184caa5b5ca25cc13e5da1fc02229.tar.gz agent686-3b1351018d3184caa5b5ca25cc13e5da1fc02229.zip | |
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
Diffstat (limited to '')
| -rw-r--r-- | tests/prompt.rs | 41 |
1 files changed, 41 insertions, 0 deletions
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 @@ | |||
| 1 | use std::fs; | ||
| 2 | use std::path::PathBuf; | ||
| 3 | |||
| 4 | use agent686::agent; | ||
| 5 | |||
| 6 | fn temp_dir(tag: &str) -> PathBuf { | ||
| 7 | let dir = std::env::temp_dir().join(format!("agent686-prompt-{tag}-{}", std::process::id())); | ||
| 8 | let _ = fs::remove_dir_all(&dir); | ||
| 9 | fs::create_dir_all(&dir).unwrap(); | ||
| 10 | dir | ||
| 11 | } | ||
| 12 | |||
| 13 | #[test] | ||
| 14 | fn project_instructions_stop_at_the_git_root() { | ||
| 15 | let dir = temp_dir("scope"); | ||
| 16 | let repo = dir.join("repo"); | ||
| 17 | fs::create_dir_all(repo.join("src")).unwrap(); | ||
| 18 | fs::create_dir_all(repo.join(".git")).unwrap(); | ||
| 19 | fs::write(dir.join("AGENTS.md"), "OUTSIDE THE REPO").unwrap(); | ||
| 20 | fs::write(repo.join("AGENTS.md"), "INSIDE THE REPO").unwrap(); | ||
| 21 | |||
| 22 | let prompt = agent::system_prompt_for(&repo.join("src")); | ||
| 23 | let text = prompt["content"].as_str().unwrap(); | ||
| 24 | |||
| 25 | assert!(text.contains("INSIDE THE REPO"), "{text}"); | ||
| 26 | assert!( | ||
| 27 | !text.contains("OUTSIDE THE REPO"), | ||
| 28 | "a parent AGENTS.md above the git root must not be injected" | ||
| 29 | ); | ||
| 30 | } | ||
| 31 | |||
| 32 | #[test] | ||
| 33 | fn outside_a_repository_only_the_current_directory_is_read() { | ||
| 34 | let dir = temp_dir("norepo"); | ||
| 35 | fs::create_dir_all(dir.join("work")).unwrap(); | ||
| 36 | fs::write(dir.join("AGENTS.md"), "PARENT INSTRUCTIONS").unwrap(); | ||
| 37 | |||
| 38 | let prompt = agent::system_prompt_for(&dir.join("work")); | ||
| 39 | let text = prompt["content"].as_str().unwrap(); | ||
| 40 | assert!(!text.contains("PARENT INSTRUCTIONS"), "{text}"); | ||
| 41 | } | ||
