feat(identity): add migration script for Ollama/Python config
- Auto-detects Python command, platform, architecture - Probes Ollama (local vs remote) - Sets prose_model based on machine (qwen3:8b for GURU-5070, else qwen3:14b) - Tested on Mikes-MacBook-Air: all fields populated correctly Ready for coord rollout to all machines.
This commit is contained in:
117
.claude/scripts/migrate-identity.sh
Executable file
117
.claude/scripts/migrate-identity.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/bin/bash
|
||||
# migrate-identity.sh - Auto-detect and populate identity.json with Ollama/Python config
|
||||
# Run this on each machine to complete the identity.json migration
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
IDENTITY_PATH="$SCRIPT_DIR/../identity.json"
|
||||
|
||||
if [ ! -f "$IDENTITY_PATH" ]; then
|
||||
echo "[ERROR] identity.json not found at $IDENTITY_PATH"
|
||||
echo " Run onboarding first to create it."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Detecting machine configuration..."
|
||||
|
||||
# Detect Python
|
||||
PYTHON_CMD=""
|
||||
for cmd in py python3 python; do
|
||||
if command -v "$cmd" >/dev/null 2>&1; then
|
||||
if "$cmd" -c "import sys; sys.exit(0)" >/dev/null 2>&1; then
|
||||
PYTHON_CMD="$cmd"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[ -z "$PYTHON_CMD" ] && PYTHON_CMD="python3"
|
||||
echo " Python: $PYTHON_CMD"
|
||||
|
||||
# Detect platform
|
||||
PLATFORM=""
|
||||
case "$(uname -s)" in
|
||||
Darwin) PLATFORM="macos" ;;
|
||||
Linux) PLATFORM="linux" ;;
|
||||
CYGWIN*|MINGW*|MSYS*) PLATFORM="windows" ;;
|
||||
*) PLATFORM="unknown" ;;
|
||||
esac
|
||||
echo " Platform: $PLATFORM"
|
||||
|
||||
# Detect architecture
|
||||
ARCH=""
|
||||
case "$(uname -m)" in
|
||||
x86_64|amd64) ARCH="amd64" ;;
|
||||
arm64|aarch64) ARCH="arm64" ;;
|
||||
*) ARCH="unknown" ;;
|
||||
esac
|
||||
echo " Architecture: $ARCH"
|
||||
|
||||
# Detect Ollama endpoint
|
||||
OLLAMA_ENDPOINT=""
|
||||
OLLAMA_FALLBACK="http://100.101.122.4:11434" # Beast via Tailscale
|
||||
PROSE_MODEL="qwen3:14b" # default
|
||||
|
||||
if curl -s -m 2 http://localhost:11434/api/tags >/dev/null 2>&1; then
|
||||
OLLAMA_ENDPOINT="http://localhost:11434"
|
||||
echo " Ollama: local (localhost:11434)"
|
||||
|
||||
# Check if this is GURU-5070 with 12GB VRAM - use qwen3:8b
|
||||
HOSTNAME=$(hostname)
|
||||
if [[ "$HOSTNAME" == "GURU-5070" ]] || [[ "$HOSTNAME" == "DESKTOP-0O8A1RL" ]]; then
|
||||
PROSE_MODEL="qwen3:8b"
|
||||
echo " Prose model: qwen3:8b (12GB VRAM machine)"
|
||||
else
|
||||
echo " Prose model: qwen3:14b (default)"
|
||||
fi
|
||||
else
|
||||
OLLAMA_ENDPOINT="$OLLAMA_FALLBACK"
|
||||
echo " Ollama: remote (Beast via Tailscale)"
|
||||
echo " Prose model: qwen3:14b (default)"
|
||||
fi
|
||||
|
||||
# Build updated identity.json
|
||||
echo ""
|
||||
echo "[INFO] Updating identity.json..."
|
||||
|
||||
# Read existing, add new fields, write back
|
||||
python3 -c "
|
||||
import json, sys
|
||||
with open('$IDENTITY_PATH', 'r') as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Add new fields if not present
|
||||
if 'python' not in data:
|
||||
data['python'] = {}
|
||||
data['python']['command'] = '$PYTHON_CMD'
|
||||
|
||||
if 'ollama' not in data:
|
||||
data['ollama'] = {}
|
||||
data['ollama']['endpoint'] = '$OLLAMA_ENDPOINT'
|
||||
data['ollama']['fallback'] = '$OLLAMA_FALLBACK'
|
||||
data['ollama']['prose_model'] = '$PROSE_MODEL'
|
||||
|
||||
if 'platform' not in data:
|
||||
data['platform'] = '$PLATFORM'
|
||||
if 'architecture' not in data:
|
||||
data['architecture'] = '$ARCH'
|
||||
|
||||
data['last_updated'] = '$(date -u +"%Y-%m-%dT%H:%M:%SZ")'
|
||||
|
||||
with open('$IDENTITY_PATH', 'w') as f:
|
||||
json.dump(data, f, indent=2)
|
||||
f.write('\n')
|
||||
|
||||
print('[OK] identity.json updated')
|
||||
"
|
||||
|
||||
echo ""
|
||||
echo "[SUCCESS] Migration complete. New fields added:"
|
||||
echo " python.command: $PYTHON_CMD"
|
||||
echo " ollama.endpoint: $OLLAMA_ENDPOINT"
|
||||
echo " ollama.fallback: $OLLAMA_FALLBACK"
|
||||
echo " ollama.prose_model: $PROSE_MODEL"
|
||||
echo " platform: $PLATFORM"
|
||||
echo " architecture: $ARCH"
|
||||
echo ""
|
||||
echo "Review: cat $IDENTITY_PATH"
|
||||
Reference in New Issue
Block a user