Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix: make detect-project.sh locale-independent and handle Windows backslash paths

suusuu0927797692d70fc3
diff --git a/skills/continuous-learning-v2/scripts/detect-project.sh b/skills/continuous-learning-v2/scripts/detect-project.sh
index 47b1e3634..8cf1be2dd 100755
--- a/skills/continuous-learning-v2/scripts/detect-project.sh
+++ b/skills/continuous-learning-v2/scripts/detect-project.sh
@@ -79,7 +79,11 @@ _clv2_detect_project() {
fi
# Derive project name from directory basename
- project_name=$(basename "$project_root")
+ # Normalize Windows backslashes so basename works when CLAUDE_PROJECT_DIR
+ # is passed as e.g. C:\Users\...\project.
+ local _norm_root
+ _norm_root=$(printf '%s' "$project_root" | sed 's|\\|/|g')
+ project_name=$(basename "$_norm_root")
# Derive project ID: prefer git remote URL hash (portable across machines),
# fall back to path hash (machine-specific but still useful)
@@ -100,8 +104,15 @@ _clv2_detect_project() {
local hash_input="${remote_url:-$project_root}"
# Prefer Python for consistent SHA256 behavior across shells/platforms.
+ # Pass the value via env var and encode as UTF-8 inside Python so the hash
+ # is locale-independent (shells vary between UTF-8 / CP932 / CP1252, which
+ # would otherwise produce different hashes for the same non-ASCII path).
if [ -n "$_CLV2_PYTHON_CMD" ]; then
- project_id=$(printf '%s' "$hash_input" | "$_CLV2_PYTHON_CMD" -c "import sys,hashlib; print(hashlib.sha256(sys.stdin.buffer.read()).hexdigest()[:12])" 2>/dev/null)
+ project_id=$(_CLV2_HASH_INPUT="$hash_input" "$_CLV2_PYTHON_CMD" -c '
+import os, hashlib
+s = os.environ["_CLV2_HASH_INPUT"]
+print(hashlib.sha256(s.encode("utf-8")).hexdigest()[:12])
+' 2>/dev/null)
fi
# Fallback if Python is unavailable or hash generation failed.
@@ -115,7 +126,11 @@ _clv2_detect_project() {
# check if a project dir exists under the legacy hash and reuse it
if [ "$legacy_hash_input" != "$hash_input" ] && [ -n "$_CLV2_PYTHON_CMD" ]; then
local legacy_id=""
- legacy_id=$(printf '%s' "$legacy_hash_input" | "$_CLV2_PYTHON_CMD" -c "import sys,hashlib; print(hashlib.sha256(sys.stdin.buffer.read()).hexdigest()[:12])" 2>/dev/null)
+ legacy_id=$(_CLV2_HASH_INPUT="$legacy_hash_input" "$_CLV2_PYTHON_CMD" -c '
+import os, hashlib
+s = os.environ["_CLV2_HASH_INPUT"]
+print(hashlib.sha256(s.encode("utf-8")).hexdigest()[:12])
+' 2>/dev/null)
if [ -n "$legacy_id" ] && [ -d "${_CLV2_PROJECTS_DIR}/${legacy_id}" ] && [ ! -d "${_CLV2_PROJECTS_DIR}/${project_id}" ]; then
# Migrate legacy directory to new hash
mv "${_CLV2_PROJECTS_DIR}/${legacy_id}" "${_CLV2_PROJECTS_DIR}/${project_id}" 2>/dev/null || project_id="$legacy_id"