#!/usr/bin/env bash set -euo pipefail SKILL_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" say() { printf '\n\033[1m▶ %s\033[0m\n' "$*"; } warn() { printf '\033[33m! %s\033[0m\n' "$*"; } install_python_tools() { if ! command -v uv >/dev/null 2>&1; then warn "uv not installed. Install: https://docs.astral.sh/uv/getting-started/installation/" exit 1 fi say "Installing Python dependencies into $SKILL_DIR/.venv/ via uv" uv sync --group tools } # Each plugin version gets its own venv, so the check targets this skill's .venv, not whatever python is on PATH. python_deps_present() { [[ -x "$SKILL_DIR/.venv/bin/python" ]] && "$SKILL_DIR/.venv/bin/python" -c 'import hcl2, bs4, requests' >/dev/null 2>&1 } verify_tools() { say "Verifying tool availability" local tool missing=() if python_deps_present; then printf ' %-15s %s\n' "python deps" "(.venv)" else missing+=("python-hcl2/beautifulsoup4/requests (.venv)") fi # tofu only: the plan runner has no terraform fallback. for tool in trivy tflint tofu terragrunt gh; do if command -v "$tool" >/dev/null 2>&1; then printf ' %-15s %s\n' "$tool" "$(command -v "$tool")" else missing+=("$tool") fi done [[ ${#missing[@]} -eq 0 ]] && return printf ' %-15s \033[31mmissing\033[0m\n' "${missing[@]}" return 1 } main() { case "${1:-}" in "") ;; --check-only) verify_tools; return ;; *) echo "usage: install-tools.sh [--check-only]" >&2; return 2 ;; esac cd "$SKILL_DIR" install_python_tools cat <