#!/usr/bin/env bash set -euo pipefail # Détection de langages et outillages par conventions de fichiers. # À sourcer depuis les agents. Utilise le répertoire courant comme racine projet. has_file() { [[ -f "$1" ]]; } has_dir() { [[ -d "$1" ]]; } has_bin() { command -v "$1" >/dev/null 2>&1; } export HAS_NODE=0 HAS_TYPESCRIPT=0 HAS_GO=0 HAS_RUST=0 HAS_PYTHON=0 HAS_SHELL_BASH=0 HAS_SHELL_PWSH=0 # Node / TypeScript if has_file package.json; then HAS_NODE=1; fi if has_file tsconfig.json || git ls-files '*.ts' | grep -q . 2>/dev/null; then HAS_TYPESCRIPT=1; fi # Go if has_file go.mod || has_file go.work; then HAS_GO=1; fi # Rust if has_file Cargo.toml; then HAS_RUST=1; fi # Python if has_file pyproject.toml || has_file requirements.txt || git ls-files '*.py' | grep -q . 2>/dev/null; then HAS_PYTHON=1; fi # Shell (bash) if git ls-files '*.sh' | grep -q . 2>/dev/null; then HAS_SHELL_BASH=1; fi # PowerShell (pwsh) if git ls-files '*.ps1' | grep -q . 2>/dev/null; then HAS_SHELL_PWSH=1; fi # Exposer aussi l'état des outils lorsqu’ils existent export HAS_NPM=0 HAS_NPX=0 HAS_GO_BIN=0 HAS_CARGO=0 HAS_PYTHON_BIN=0 HAS_PIP=0 HAS_SHELLCHECK=0 HAS_PWSH=0 has_bin npm && HAS_NPM=1 has_bin npx && HAS_NPX=1 has_bin go && HAS_GO_BIN=1 has_bin cargo && HAS_CARGO=1 has_bin python && HAS_PYTHON_BIN=1 || true has_bin pip && HAS_PIP=1 || true has_bin shellcheck && HAS_SHELLCHECK=1 || true has_bin pwsh && HAS_PWSH=1 || true