npm install -g @anthropic-ai/claude-code ist deprecated. Neuer Installer: curl -fsSL https://claude.ai/install.sh | bash Binary landet in ~/.local/bin (kein npm-global-PATH-Setup mehr noetig).
172 lines
7.4 KiB
Bash
Executable file
172 lines
7.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# diagnose-claude-profiles.sh
|
|
# Prueft ob die Claude Code Multi-Profile-Einrichtung korrekt ist
|
|
# Verwendung: bash diagnose-claude-profiles.sh
|
|
|
|
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
|
|
ok() { echo -e "${GREEN}[OK] $*${NC}"; }
|
|
warn() { echo -e "${YELLOW}[WARN] $*${NC}"; }
|
|
fail() { echo -e "${RED}[FAIL] $*${NC}"; }
|
|
info() { echo -e "${BLUE}[INFO] $*${NC}"; }
|
|
|
|
ISSUES=0
|
|
issue() { fail "$*"; ((ISSUES++)); }
|
|
|
|
echo ""
|
|
echo "============================================"
|
|
echo " Claude Code Profile - Diagnose"
|
|
echo "============================================"
|
|
|
|
# ── 1. Binary ──────────────────────────────────────────────────────────
|
|
echo -e "\n=== 1. claude Binary ==="
|
|
CLAUDE_BIN=$(command -v claude 2>/dev/null || true)
|
|
if [[ -n "$CLAUDE_BIN" ]]; then
|
|
ok "claude gefunden: $CLAUDE_BIN"
|
|
CLAUDE_VERSION=$(claude --version 2>/dev/null || echo "Version nicht lesbar")
|
|
info "Version: $CLAUDE_VERSION"
|
|
else
|
|
issue "claude Binary nicht gefunden"
|
|
info "PATH: $PATH"
|
|
# Neue Installationsorte pruefen (~/.local/bin, /usr/local/bin)
|
|
for loc in "$HOME/.local/bin/claude" "/usr/local/bin/claude"; do
|
|
if [[ -f "$loc" ]]; then
|
|
warn "claude liegt in $loc aber ist nicht im PATH"
|
|
fi
|
|
done
|
|
info "Fix: curl -fsSL https://claude.ai/install.sh | bash"
|
|
fi
|
|
|
|
# ── 2. Installation ────────────────────────────────────────────────────
|
|
echo -e "\n=== 2. Installation ==="
|
|
if [[ -n "$CLAUDE_BIN" ]]; then
|
|
ok "Binary vorhanden: $CLAUDE_BIN"
|
|
elif npm list -g @anthropic-ai/claude-code --depth=0 2>/dev/null | grep -q claude-code; then
|
|
PKG=$(npm list -g @anthropic-ai/claude-code --depth=0 2>/dev/null | grep claude-code)
|
|
warn "Veraltete npm-Installation gefunden: $PKG"
|
|
info "Migration: curl -fsSL https://claude.ai/install.sh | bash"
|
|
else
|
|
issue "claude nicht installiert"
|
|
info "Fix: curl -fsSL https://claude.ai/install.sh | bash"
|
|
fi
|
|
|
|
# ── 3. Config-Verzeichnisse ────────────────────────────────────────────
|
|
echo -e "\n=== 3. Config-Verzeichnisse ==="
|
|
for dir in ~/.claude-priv ~/.claude-work; do
|
|
expanded="${dir/#\~/$HOME}"
|
|
if [[ -d "$expanded" ]]; then
|
|
COUNT=$(ls -A "$expanded" 2>/dev/null | wc -l)
|
|
ok "$dir existiert ($COUNT Eintraege)"
|
|
else
|
|
issue "$dir fehlt"
|
|
info "Fix: bash setup-claude-profiles.sh"
|
|
fi
|
|
done
|
|
|
|
if [[ -d "$HOME/.claude" && ! -L "$HOME/.claude" ]]; then
|
|
warn "~/.claude existiert noch als echtes Verzeichnis (sollte nicht mehr da sein)"
|
|
info "Eventuell wurde setup-claude-profiles.sh nicht vollstaendig ausgefuehrt"
|
|
fi
|
|
|
|
# ── 4. Symlinks in ~/.claude-work ─────────────────────────────────────
|
|
echo -e "\n=== 4. Symlinks ==="
|
|
for item in projects settings.json; do
|
|
link="$HOME/.claude-work/$item"
|
|
expected_target="$HOME/.claude-priv/$item"
|
|
if [[ -L "$link" ]]; then
|
|
actual=$(readlink "$link")
|
|
resolved=$(readlink -f "$link" 2>/dev/null || echo "BROKEN")
|
|
if [[ "$resolved" == "BROKEN" || ! -e "$resolved" ]]; then
|
|
issue "$link -> $actual (BROKEN - Ziel existiert nicht)"
|
|
info "Fix: rm $link && ln -s $expected_target $link"
|
|
else
|
|
ok "$link -> $actual"
|
|
fi
|
|
elif [[ -e "$link" ]]; then
|
|
warn "$link existiert, ist aber kein Symlink (echte Datei/Verzeichnis)"
|
|
else
|
|
issue "$link fehlt (kein Symlink)"
|
|
info "Fix: ln -s $expected_target $link"
|
|
fi
|
|
done
|
|
|
|
# ── 5. Auth-Token ──────────────────────────────────────────────────────
|
|
echo -e "\n=== 5. Auth-Token ==="
|
|
for profile in priv work; do
|
|
dir="$HOME/.claude-${profile}"
|
|
# Claude speichert Credentials in verschiedenen Dateien je nach Version
|
|
found_token=0
|
|
for credfile in ".credentials.json" "auth.json" ".auth"; do
|
|
if [[ -f "$dir/$credfile" ]]; then
|
|
SIZE=$(wc -c < "$dir/$credfile")
|
|
if [[ "$SIZE" -gt 10 ]]; then
|
|
ok "~/.claude-${profile}/$credfile vorhanden (${SIZE} Bytes)"
|
|
found_token=1
|
|
break
|
|
fi
|
|
fi
|
|
done
|
|
if [[ "$found_token" -eq 0 ]]; then
|
|
# Alle JSON-Dateien anzeigen die Token enthalten koennten
|
|
JSON_FILES=$(find "$dir" -maxdepth 2 -name "*.json" 2>/dev/null | head -5)
|
|
if [[ -n "$JSON_FILES" ]]; then
|
|
warn "~/.claude-${profile}: kein bekanntes Credential-File, vorhandene JSON-Dateien:"
|
|
echo "$JSON_FILES" | while read -r f; do info " $f ($(wc -c < "$f") Bytes)"; done
|
|
else
|
|
issue "~/.claude-${profile}: KEIN Credential-File gefunden - Login noetig"
|
|
info "Fix: CLAUDE_CONFIG_DIR=~/.claude-${profile} command claude /login"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# ── 6. .zshrc Aliases ─────────────────────────────────────────────────
|
|
echo -e "\n=== 6. .zshrc Aliases ==="
|
|
ZSHRC="$HOME/.zshrc"
|
|
if [[ ! -f "$ZSHRC" ]]; then
|
|
issue "$ZSHRC fehlt"
|
|
else
|
|
if grep -q "claude-profiles-start" "$ZSHRC"; then
|
|
ok ".zshrc: claude-profiles Block vorhanden"
|
|
# Aliases einzeln pruefen
|
|
for alias_name in claude-priv claude-work claude-account; do
|
|
if grep -q "$alias_name" "$ZSHRC"; then
|
|
ok " $alias_name definiert"
|
|
else
|
|
issue " $alias_name fehlt in .zshrc"
|
|
fi
|
|
done
|
|
else
|
|
issue ".zshrc: claude-profiles Block fehlt komplett"
|
|
info "Fix: bash setup-claude-profiles.sh"
|
|
fi
|
|
fi
|
|
|
|
# Aktuelle Shell-Aliases pruefen (falls .zshrc geladen ist)
|
|
echo ""
|
|
info "Aktive Aliases in dieser Shell:"
|
|
alias claude-priv 2>/dev/null && true || warn " claude-priv: nicht aktiv (source ~/.zshrc noetig?)"
|
|
alias claude-work 2>/dev/null && true || warn " claude-work: nicht aktiv (source ~/.zshrc noetig?)"
|
|
|
|
# ── 7. Verzeichnis-Inhalt (Info) ───────────────────────────────────────
|
|
echo -e "\n=== 7. Inhalt ~/.claude-priv ==="
|
|
if [[ -d "$HOME/.claude-priv" ]]; then
|
|
ls -la "$HOME/.claude-priv/" 2>/dev/null
|
|
fi
|
|
|
|
# ── Zusammenfassung ────────────────────────────────────────────────────
|
|
echo ""
|
|
echo "============================================"
|
|
if [[ "$ISSUES" -eq 0 ]]; then
|
|
ok "Keine Probleme gefunden"
|
|
echo -e "${GREEN} Alles sieht gut aus.${NC}"
|
|
echo " Wenn claude trotzdem nicht funktioniert: Login erneuern mit"
|
|
echo " CLAUDE_CONFIG_DIR=~/.claude-priv command claude /login"
|
|
else
|
|
fail "$ISSUES Problem(e) gefunden - siehe [FAIL] Zeilen oben"
|
|
echo " Haeufigstes Fix-All:"
|
|
echo " bash setup-claude-profiles.sh # Verzeichnisse + Aliases reparieren"
|
|
echo " source ~/.zshrc # Aliases neu laden"
|
|
echo " claude-account priv # Neu anmelden"
|
|
fi
|
|
echo "============================================"
|
|
echo ""
|