Skip to content

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

Rust

fix(hooks): parse BOM-prefixed marker aliases

AkitaOnRails5bdaa3f5b178
diff --git a/hooks/_lib.sh b/hooks/_lib.sh
index 0e28e5a8..4ddd6709 100644
--- a/hooks/_lib.sh
+++ b/hooks/_lib.sh
@@ -558,7 +558,7 @@ ai_memory_aliases_json_value() {
ai_memory_aliases_json() {
[ -f "$1" ] || return 0
- _ai_alias_body=$(LC_ALL=C awk '
+ _ai_alias_body=$(ai_memory_strip_utf8_bom <"$1" | LC_ALL=C awk '
BEGIN { table = 0; count = 0; bad = 0 }
{
line = $0
@@ -581,7 +581,7 @@ ai_memory_aliases_json() {
if (bad) print "invalid"
else if (count == 1) print body
}
- ' "$1")
+ ')
[ "$_ai_alias_body" = "invalid" ] && { printf 'invalid'; return 0; }
[ -n "$_ai_alias_body" ] || return 0
_ai_alias_trimmed=$(printf '%s' "$_ai_alias_body" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
diff --git a/tests/hooks/test_lib.sh b/tests/hooks/test_lib.sh
index 4b45365b..91eb5447 100755
--- a/tests/hooks/test_lib.sh
+++ b/tests/hooks/test_lib.sh
@@ -73,6 +73,8 @@ printf '\357\273\277aliases = ["former-name"]\n' >"$TMP/bom-aliases.toml"
bom_aliases_declared=no
ai_memory_marker_declares_settings "$TMP/bom-aliases.toml" && bom_aliases_declared=yes
assert_eq "BOM does not hide first-line aliases boundary" "yes" "$bom_aliases_declared"
+assert_eq "BOM does not hide first-line aliases value" '["former-name"]' \
+ "$(ai_memory_aliases_json "$TMP/bom-aliases.toml")"
# --- find_marker ------------------------------------------------------
mkdir -p "$TMP/a/b/c/d"