#!/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" # BASH_SOURCE[0] is empty when piped through bash — this is the bootstrap entry point if [[ -z "${BASH_SOURCE[0]:-}" ]]; then DEV_ROOT="$PWD" # capture before exec replaces the process TARGET="$DEV_ROOT/$REPO_NAME" EXTRA_FLAGS="${1:-}" if [[ -d "$TARGET" ]]; then PREV_COMMIT="$(git -C "$TARGET" rev-parse --short HEAD 2>/dev/null || echo "")" echo "\u2192 updating $REPO_NAME ..." git -C "$TARGET" pull || { echo "\u2717 git pull failed"; exit 1; } else PREV_COMMIT="" echo "\u2192 cloning $REPO_NAME into $TARGET ..." git clone "$REPO_URL" "$TARGET" || { echo "\u2717 git clone failed"; exit 1; } fi exec bash "$TARGET/apply.sh" --bootstrapped "$DEV_ROOT" ${EXTRA_FLAGS:+"$EXTRA_FLAGS"} "$PREV_COMMIT" fi 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 # full setup" echo " curl -fsSL $RAW_URL | bash -s -- --update # update instructions only" echo "" exit 1 fi SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" AI_TARGET="$SCRIPT_DIR/.ai" TEMPLATE_MARKER="