Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

test(cli): skip no-note controls when a Claude file sits above the temp dir (#1346)

Victor Alencar0d3d112d4dc6
diff --git a/crates/ai-memory-cli/tests/suite/routing_instructions.rs b/crates/ai-memory-cli/tests/suite/routing_instructions.rs
index 397ed16d..e34da86f 100644
--- a/crates/ai-memory-cli/tests/suite/routing_instructions.rs
+++ b/crates/ai-memory-cli/tests/suite/routing_instructions.rs
@@ -1,7 +1,7 @@
//! Integration tests for ai-memory routing instructions.
use std::fs;
-use std::path::Path;
+use std::path::{Path, PathBuf};
use std::process::{Command, Output};
use ai_memory_core::routing_skills::MANAGED_MARKER;
@@ -478,6 +478,19 @@ fn devin_install_instructions_writes_project_devin_skills() {
assert!(!project.path().join(".agents/skills").exists());
}
+/// The first Claude Code instruction file above where `tempfile` puts a
+/// project. Probing a real temp dir follows `TMPDIR` the way the tests do.
+fn claude_file_above_temp_dir() -> Option<PathBuf> {
+ let probe = tempfile::tempdir().ok()?;
+ let probe = fs::canonicalize(probe.path()).ok()?;
+ probe.parent()?.ancestors().find_map(|dir| {
+ ["CLAUDE.md", "CLAUDE.local.md", ".claude/CLAUDE.md"]
+ .iter()
+ .map(|name| dir.join(name))
+ .find(|path| path.is_file())
+ })
+}
+
/// #1297: with only `AGENTS.md` written, a `CLAUDE.local.md` or
/// `.claude/CLAUDE.md` makes Claude Code read that instead, so the install
/// says so. Controls: `AGENTS.md` alone, a `CLAUDE.md` target alongside, and a
@@ -512,6 +525,16 @@ fn install_instructions_warns_when_claude_code_will_skip_agents_md() {
"{shadow}: {stderr}"
);
}
+ // #1346: the binary checks every ancestor of the cwd, so a Claude file
+ // above the OS temp dir prints the note for any temp project. On Windows
+ // %TEMP% sits inside the real home, next to a user's ~/.claude/CLAUDE.md.
+ if let Some(path) = claude_file_above_temp_dir() {
+ eprintln!(
+ "skipping no-note controls: {} sits above the temp dir",
+ path.display()
+ );
+ return;
+ }
assert!(!run(&[]).contains(note));
assert!(!run(&[("CLAUDE.local.md", "@AGENTS.md\n")]).contains(note));
// A CLAUDE.md alongside becomes a target too, so Claude Code sees the block.