Skip to content

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

Rust

test(install): cover repo-root baking in TS generators

João Matheusa8cc5e3be205
diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rs
index 199d8bf3..e393f3b1 100644
--- a/crates/ai-memory-cli/src/commands/install_hooks.rs
+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs
@@ -2748,6 +2748,33 @@ model = "gpt-5"
);
}
+ #[test]
+ fn opencode_plugin_bakes_repo_root_default() {
+ let plugin =
+ build_opencode_plugin("http://127.0.0.1:49374", Some("tok"), Some("repo-root"));
+ assert!(
+ plugin.contains("const DEFAULT_PROJECT_STRATEGY = \"repo-root\";"),
+ "repo-root install default must bake the const: {plugin}"
+ );
+ assert!(
+ plugin.contains("if (!projectStrategy) projectStrategy = DEFAULT_PROJECT_STRATEGY;"),
+ "must apply the default when a marker pins no strategy: {plugin}"
+ );
+ assert!(
+ plugin.contains("if (repoProject) project = repoProject;"),
+ "{plugin}"
+ );
+ }
+
+ #[test]
+ fn opencode_plugin_default_omits_baked_strategy() {
+ let plugin = build_opencode_plugin("http://127.0.0.1:49374", Some("tok"), None);
+ assert!(
+ !plugin.contains("DEFAULT_PROJECT_STRATEGY"),
+ "basename default must bake no strategy: {plugin}"
+ );
+ }
+
// ----------------------------------------------------------------
// OMP tests
// ----------------------------------------------------------------
@@ -2790,6 +2817,29 @@ model = "gpt-5"
assert!(extension.contains("url.searchParams.set(\"project\", repoProject)"));
}
+ #[test]
+ fn omp_extension_bakes_repo_root_default() {
+ let extension =
+ build_omp_extension("http://127.0.0.1:49374", Some("tok"), Some("repo-root"));
+ assert!(
+ extension.contains("const DEFAULT_PROJECT_STRATEGY = \"repo-root\";"),
+ "repo-root install default must bake the const: {extension}"
+ );
+ assert!(
+ extension.contains("if (!projectStrategy) projectStrategy = DEFAULT_PROJECT_STRATEGY;"),
+ "{extension}"
+ );
+ }
+
+ #[test]
+ fn omp_extension_default_omits_baked_strategy() {
+ let extension = build_omp_extension("http://127.0.0.1:49374", Some("tok"), None);
+ assert!(
+ !extension.contains("DEFAULT_PROJECT_STRATEGY"),
+ "{extension}"
+ );
+ }
+
#[test]
fn omp_extension_is_directly_discoverable_by_omp() {
let tmp = TempDir::new().unwrap();
diff --git a/crates/ai-memory-cli/src/commands/openclaw_plugin.rs b/crates/ai-memory-cli/src/commands/openclaw_plugin.rs
index 3e69064a..edfb65ee 100644
--- a/crates/ai-memory-cli/src/commands/openclaw_plugin.rs
+++ b/crates/ai-memory-cli/src/commands/openclaw_plugin.rs
@@ -540,6 +540,28 @@ mod tests {
assert!(plugin.contains("tok"));
}
+ #[test]
+ fn openclaw_plugin_bakes_repo_root_default() {
+ let plugin = build_plugin("http://127.0.0.1:49374", Some("tok"), Some("repo-root"));
+ assert!(
+ plugin.contains("const DEFAULT_PROJECT_STRATEGY = \"repo-root\";"),
+ "repo-root install default must bake the const: {plugin}"
+ );
+ assert!(
+ plugin.contains("if (!projectStrategy) projectStrategy = DEFAULT_PROJECT_STRATEGY;"),
+ "must apply the default when a marker pins no strategy: {plugin}"
+ );
+ }
+
+ #[test]
+ fn openclaw_plugin_default_omits_baked_strategy() {
+ let plugin = build_plugin("http://127.0.0.1:49374", Some("tok"), None);
+ assert!(
+ !plugin.contains("DEFAULT_PROJECT_STRATEGY"),
+ "basename default must bake no strategy: {plugin}"
+ );
+ }
+
#[test]
fn package_writes_all_required_files() {
let tmp = TempDir::new().unwrap();