Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(hooks): source-tree dev path resolves _lib.sh one dir up
Pablo Wintera9a309e5507a
diff --git a/hooks/claude-code/post-tool-use.sh b/hooks/claude-code/post-tool-use.shindex 84718824..d5d483a1 100755--- a/hooks/claude-code/post-tool-use.sh+++ b/hooks/claude-code/post-tool-use.sh@@ -5,7 +5,11 @@# if found, appends `&workspace=X&project=Y` to the URL so the server# routes the event to the declared workspace/project pair instead of# bucketing by basename(cwd) under the default workspace.-. "$(dirname "$0")/_lib.sh"+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged+# alongside this script. From the source tree it lives one dir up.+_lib_dir="$(dirname "$0")"+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."+. "$_lib_dir/_lib.sh"SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"PAYLOAD=$(cat)diff --git a/hooks/claude-code/pre-compact.sh b/hooks/claude-code/pre-compact.shindex 5a0a39cb..1fe049e3 100755--- a/hooks/claude-code/pre-compact.sh+++ b/hooks/claude-code/pre-compact.sh@@ -5,7 +5,11 @@# if found, appends `&workspace=X&project=Y` to the URL so the server# routes the event to the declared workspace/project pair instead of# bucketing by basename(cwd) under the default workspace.-. "$(dirname "$0")/_lib.sh"+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged+# alongside this script. From the source tree it lives one dir up.+_lib_dir="$(dirname "$0")"+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."+. "$_lib_dir/_lib.sh"SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"PAYLOAD=$(cat)diff --git a/hooks/claude-code/pre-tool-use.sh b/hooks/claude-code/pre-tool-use.shindex 1d4c27b1..8ab1a366 100755--- a/hooks/claude-code/pre-tool-use.sh+++ b/hooks/claude-code/pre-tool-use.sh@@ -5,7 +5,11 @@# if found, appends `&workspace=X&project=Y` to the URL so the server# routes the event to the declared workspace/project pair instead of# bucketing by basename(cwd) under the default workspace.-. "$(dirname "$0")/_lib.sh"+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged+# alongside this script. From the source tree it lives one dir up.+_lib_dir="$(dirname "$0")"+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."+. "$_lib_dir/_lib.sh"SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"PAYLOAD=$(cat)diff --git a/hooks/claude-code/session-end.sh b/hooks/claude-code/session-end.shindex ba73dea9..2f40461c 100755--- a/hooks/claude-code/session-end.sh+++ b/hooks/claude-code/session-end.sh@@ -5,7 +5,11 @@# if found, appends `&workspace=X&project=Y` to the URL so the server# routes the event to the declared workspace/project pair instead of# bucketing by basename(cwd) under the default workspace.-. "$(dirname "$0")/_lib.sh"+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged+# alongside this script. From the source tree it lives one dir up.+_lib_dir="$(dirname "$0")"+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."+. "$_lib_dir/_lib.sh"SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"PAYLOAD=$(cat)diff --git a/hooks/claude-code/session-start.sh b/hooks/claude-code/session-start.shindex 673983da..29286f90 100755--- a/hooks/claude-code/session-start.sh+++ b/hooks/claude-code/session-start.sh@@ -10,7 +10,11 @@# and appends `&workspace=X&project=Y` to both URLs when found — so a# session resuming under a marker-declared workspace doesn't query the# `default` bucket and miss its own handoff.-. "$(dirname "$0")/_lib.sh"+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged+# alongside this script. From the source tree it lives one dir up.+_lib_dir="$(dirname "$0")"+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."+. "$_lib_dir/_lib.sh"SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"PAYLOAD=$(cat)diff --git a/hooks/claude-code/stop.sh b/hooks/claude-code/stop.shindex 0b799ccc..c52bd2e0 100755--- a/hooks/claude-code/stop.sh+++ b/hooks/claude-code/stop.sh@@ -5,7 +5,11 @@# if found, appends `&workspace=X&project=Y` to the URL so the server# routes the event to the declared workspace/project pair instead of# bucketing by basename(cwd) under the default workspace.-. "$(dirname "$0")/_lib.sh"+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged+# alongside this script. From the source tree it lives one dir up.+_lib_dir="$(dirname "$0")"+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."+. "$_lib_dir/_lib.sh"SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"PAYLOAD=$(cat)diff --git a/hooks/claude-code/user-prompt-submit.sh b/hooks/claude-code/user-prompt-submit.shindex 243679bb..f8994466 100755--- a/hooks/claude-code/user-prompt-submit.sh+++ b/hooks/claude-code/user-prompt-submit.sh@@ -5,7 +5,11 @@# if found, appends `&workspace=X&project=Y` to the URL so the server# routes the event to the declared workspace/project pair instead of# bucketing by basename(cwd) under the default workspace.-. "$(dirname "$0")/_lib.sh"+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged+# alongside this script. From the source tree it lives one dir up.+_lib_dir="$(dirname "$0")"+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."+. "$_lib_dir/_lib.sh"SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"PAYLOAD=$(cat)