Skip to content

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

Rust

fix(hooks): install the shared helper with the curl hook installer

Vinícius DS Andrade3c677e64863a
diff --git a/crates/ai-memory-cli/tests/suite/packaging.rs b/crates/ai-memory-cli/tests/suite/packaging.rs
index 5fd728be..0b4d5909 100644
--- a/crates/ai-memory-cli/tests/suite/packaging.rs
+++ b/crates/ai-memory-cli/tests/suite/packaging.rs
@@ -868,6 +868,11 @@ fn installed_hook_names(agent_arg: &str, canonical_agent: &str, hooks: &[&str])
)
.unwrap();
}
+ std::fs::write(
+ tmp.path().join("bundle/hooks/_lib.sh"),
+ "# shared helper sourced by every event script\n",
+ )
+ .unwrap();
let archive = tmp.path().join("ai-memory-hooks.tar.gz");
let status = Command::new("tar")
.arg("-czf")
@@ -926,6 +931,10 @@ fn installed_hook_names(agent_arg: &str, canonical_agent: &str, hooks: &[&str])
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
+ assert!(
+ destination.join("_lib.sh").is_file(),
+ "the shared helper must land beside the agent directories"
+ );
let installed = destination.join(canonical_agent);
let mut names = std::fs::read_dir(&installed)
.unwrap()
diff --git a/scripts/install-hooks.sh b/scripts/install-hooks.sh
index 994edc89..9ff03374 100755
--- a/scripts/install-hooks.sh
+++ b/scripts/install-hooks.sh
@@ -172,6 +172,18 @@ if [[ -z "$expected_sum" || "$actual_sum" != "$expected_sum" ]]; then
exit 1
fi
echo "Installing ai-memory hooks for $AGENT into $DEST"
+# Every event script sources _lib.sh from its own directory or the one above
+# it, so the helper goes beside the agent directories, where `install-hooks`
+# also looks when it stages a bundle. A script installed without it stops at
+# the line that sources it.
+source="$TMP/_lib.sh"
+if tar -xOf "$TMP/$ARCHIVE" "hooks/_lib.sh" > "$source" && [[ -s "$source" ]]; then
+ install -m 0644 "$source" "$TO/_lib.sh"
+ echo " ✓ _lib"
+else
+ echo " ✗ _lib (missing from verified release bundle)" >&2
+ exit 1
+fi
for name in "${SCRIPTS[@]}"; do
member="hooks/$AGENT/${name}.sh"
source="$TMP/${name}.sh"