#!/usr/bin/env bash set -euo pipefail REPO_URL="https://gitea.nikos-dev.keskikuja.site/niko/ai-superpower.git" REPO_NAME="ai-superpower" RAW_URL="https://gitea.nikos-dev.keskikuja.site/niko/ai-superpower/raw/branch/main/apply.sh" # ── Bootstrap mode (curl | bash) ───────────────────────────────────────────── # BASH_SOURCE[0] is empty when piped through bash if [[ -z "${BASH_SOURCE[0]:-}" ]]; then DEV_ROOT="$PWD" # capture before exec replaces the process TARGET="$DEV_ROOT/$REPO_NAME" if [[ -d "$TARGET" ]]; then echo "→ updating $REPO_NAME ..." git -C "$TARGET" pull || { echo "✗ git pull failed"; exit 1; } else echo "→ cloning $REPO_NAME into $TARGET ..." git clone "$REPO_URL" "$TARGET" || { echo "✗ git clone failed"; exit 1; } fi # Pass DEV_ROOT explicitly — local mode must not guess it from script location exec bash "$TARGET/apply.sh" --bootstrapped "$DEV_ROOT" fi # ── Guard — block direct invocation ────────────────────────────────────────── if [[ "${1:-}" != "--bootstrapped" ]]; then echo "✗ do not run this script directly." echo " run from your dev root folder:" echo "" echo " curl -fsSL $RAW_URL | bash" echo "" exit 1 fi # ── Local mode ──────────────────────────────────────────────────────────────── SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DEV_ROOT="${2:?DEV_ROOT not passed — re-run via curl}" AI_TARGET="$DEV_ROOT/.ai" TEMPLATE_MARKER="