fix(migrate-identity): Windows compatibility (two bugs)

The script auto-detected PYTHON_CMD but then hardcoded `python3` for the
JSON write (exit 127 on Windows where only `py` exists), and passed a Git
Bash POSIX path (/d/...) to native Python (FileNotFoundError). Fixes:
- use "$PYTHON_CMD" instead of hardcoded python3
- convert IDENTITY_PATH via `cygpath -m` for the interpreter (no-op elsewhere)

Verified on GURU-5070: identity.json migrated correctly (py, windows/amd64,
localhost Ollama, qwen3:8b).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-26 20:07:46 -07:00
parent 6c4c17a8be
commit 251bb3546b

View File

@@ -74,10 +74,13 @@ fi
echo ""
echo "[INFO] Updating identity.json..."
# Read existing, add new fields, write back
python3 -c "
# Read existing, add new fields, write back.
# On Windows, native Python can't open Git Bash POSIX paths (/d/...); convert to a
# drive-letter/forward-slash path for the interpreter. No-op (falls back) elsewhere.
IDENTITY_PATH_PY=$(cygpath -m "$IDENTITY_PATH" 2>/dev/null || echo "$IDENTITY_PATH")
"$PYTHON_CMD" -c "
import json, sys
with open('$IDENTITY_PATH', 'r') as f:
with open('$IDENTITY_PATH_PY', 'r') as f:
data = json.load(f)
# Add new fields if not present
@@ -98,7 +101,7 @@ if 'architecture' not in data:
data['last_updated'] = '$(date -u +"%Y-%m-%dT%H:%M:%SZ")'
with open('$IDENTITY_PATH', 'w') as f:
with open('$IDENTITY_PATH_PY', 'w') as f:
json.dump(data, f, indent=2)
f.write('\n')