#!/usr/bin/env bash # Installe CrazyClaude dans le projet courant. # À lancer depuis la racine du projet après git subtree add. # # Usage : bash .claude/install.sh set -euo pipefail CLAUDE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Bootstrap : si on lance install.sh depuis le repo CrazyClaude lui-même # (et non depuis .claude/ d'un autre projet), on s'installe en tant que .claude/ if [[ "$(basename "$CLAUDE_DIR")" != ".claude" ]]; then TARGET="${1:-$(pwd)/.claude}" echo "==> Bootstrap : installation de CrazyClaude dans $TARGET" git clone "$CLAUDE_DIR" "$TARGET" exec bash "$TARGET/install.sh" fi PROJECT_DIR="$(dirname "$CLAUDE_DIR")" require() { command -v "$1" &>/dev/null || { echo "ERREUR : '$1' introuvable dans le PATH" >&2; exit 1; } } require python3 require argc require jq require aichat require claude echo "=== Virtualenv Python ===" python3 -m venv "$CLAUDE_DIR/venv" "$CLAUDE_DIR/venv/bin/pip" install -q -r "$CLAUDE_DIR/mcp/qwen3-mcp/requirements.txt" echo "OK" echo "" echo "=== Installation de llm-functions ===" if [[ ! -f "$CLAUDE_DIR/llm-functions/Argcfile.sh" ]]; then git clone https://github.com/sigoden/llm-functions.git "$CLAUDE_DIR/llm-functions" else echo "déjà présent" fi if [[ ! -f "$CLAUDE_DIR/llm-functions/tools.txt" ]]; then echo "Génération de tools.txt..." find "$CLAUDE_DIR/llm-functions/tools" -maxdepth 1 -type f \ ! -name 'demo_*' \ | sed 's|.*/||' \ | sort > "$CLAUDE_DIR/llm-functions/tools.txt" echo " $(wc -l < "$CLAUDE_DIR/llm-functions/tools.txt") outils activés" fi (cd "$CLAUDE_DIR/llm-functions" && argc build) LOCAL_TOOLS_DIR="$CLAUDE_DIR/tools-local" if [[ -d "$LOCAL_TOOLS_DIR" ]]; then for src in "$LOCAL_TOOLS_DIR"/*; do [[ -f "$src" && -x "$src" ]] || continue name="$(basename "$src")" cp "$src" "$CLAUDE_DIR/llm-functions/bin/$name" chmod +x "$CLAUDE_DIR/llm-functions/bin/$name" done echo " overrides locaux appliqués" fi echo "OK" echo "" echo "=== Mise à jour du .gitignore projet ===" GITIGNORE="$PROJECT_DIR/.gitignore" entries=( ".claude/" ) for entry in "${entries[@]}"; do if ! grep -qxF "$entry" "$GITIGNORE" 2>/dev/null; then echo "$entry" >> "$GITIGNORE" echo " ajouté : $entry" fi done echo "OK" echo "" echo "=== Hooks exécutables ===" chmod +x "$CLAUDE_DIR/hooks/"*.sh echo "OK" echo "" echo "=== Enregistrement du serveur MCP ===" PYTHON="$CLAUDE_DIR/venv/bin/python3" SERVER="$CLAUDE_DIR/mcp/qwen3-mcp/server.py" if claude mcp list 2>/dev/null | grep -q "^qwen3:"; then echo "MCP qwen3 déjà enregistré — mise à jour" claude mcp remove qwen3 2>/dev/null || true fi claude mcp add --transport stdio qwen3 -- "$PYTHON" "$SERVER" echo "OK" echo "" echo "=== Vérification ===" claude mcp list | grep qwen3 echo "" echo "Installation terminée. Éditez .claude/CLAUDE.md pour adapter au projet."