From 5cd72d2df3d39810e30964c95808cc697890f99c Mon Sep 17 00:00:00 2001 From: Godopu Date: Sun, 25 Oct 2026 17:00:17 +0000 Subject: [PATCH] fix(lib.sh): the herdr name of a non-ASCII or option-like name equals Python's (Issue #71) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tr/sed lowercase differently from str.lower() outside ASCII, so a name like "İstanbul-creator-claude" was started as x--stanbul-... while the row's attach_command named i-stanbul-.... A non-ASCII name is now lowercased and replaced by python3 (fail closed without it), and the name is read with printf, not echo ("-n" no longer vanishes). Refs #71 Co-Authored-By: Claude Opus 5.5 --- .agents/skills/lib.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.agents/skills/lib.sh b/.agents/skills/lib.sh index 775147e..7217137 100644 --- a/.agents/skills/lib.sh +++ b/.agents/skills/lib.sh @@ -37,15 +37,25 @@ AGENT_SESSIONS_YAML="${AGENT_SESSIONS_YAML:-$WORKSPACE_ROOT/.mam/agent-sessions. # (Issue #71). The herdr shim gets this same definition: _init_herdr_isolation # writes it in with `declare -f`. A long name needs its SHA-1 suffix; with no # shasum, sha1sum, openssl or python3 to make it, this fails (stderr, nonzero) -# rather than return a name herdr never registered. +# rather than return a name herdr never registered. A name that is not ASCII +# is lowercased and replaced by python3 (tr/sed differ from str.lower() there), +# and fails the same way without it. _sanitize_herdr_agent_name() { local n="$1" if [ -z "$n" ]; then printf 'agent\n' return 0 fi - local s - s=$(echo "$n" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9_-]/-/g') + local s="" + if [ -z "$(printf '%s' "$n" | LC_ALL=C tr -d '\000-\177')" ]; then + s=$(printf '%s' "$n" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9_-]/-/g') + elif command -v python3 >/dev/null 2>&1; then + s=$(python3 -c 'import re,sys; sys.stdout.write(re.sub(r"[^a-z0-9_-]", "-", sys.argv[1].lower()))' "$n") || s="" + fi + if [ -z "$s" ]; then + echo "ERROR: cannot make the herdr name of '$n': it is not ASCII and there is no python3 to convert it" >&2 + return 1 + fi if [[ ! "$s" =~ ^[a-z] ]]; then s="x-$s"; fi if [ "${#s}" -gt 32 ]; then local h=""