From 93b859f5084772202497ae2cd044869f57426a35 Mon Sep 17 00:00:00 2001 From: moilanik Date: Wed, 4 Mar 2026 10:00:11 +0200 Subject: [PATCH] feat: add --update flag to refresh instructions without full setup curl ... | bash -s -- --update pulls the latest .ai/ files and exits without scanning projects or touching docs templates. Bootstrap captures the pre-pull commit hash and forwards it to local mode; local mode compares with HEAD and either reports "already up to date" or prints new commit messages with git log --oneline. FR-1.5 added to apply-requirements.md. README and apply.md updated. --- README.md | 4 ++++ apply.md | 12 ++++++++++-- apply.sh | 35 +++++++++++++++++++++++++++-------- docs/apply-requirements.md | 1 + 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1f7d713..01865cd 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,11 @@ Good instructions are what make that possible — they allow AI to produce outpu Run this from your dev root — the folder where all your projects live: ```bash +# Full setup: clone/pull + scan all projects + create/refresh docs templates curl -fsSL https://gitea.nikos-dev.keskikuja.site/niko/ai-superpower/raw/branch/main/apply.sh | bash + +# Update instructions only: pull latest .ai/ files, skip all project setup +curl -fsSL https://gitea.nikos-dev.keskikuja.site/niko/ai-superpower/raw/branch/main/apply.sh | bash -s -- --update ``` This script **must be run via `curl | bash`** from your dev root. Running it directly will fail with instructions to use the curl command. diff --git a/apply.md b/apply.md index affc2aa..9edaea3 100644 --- a/apply.md +++ b/apply.md @@ -14,9 +14,17 @@ How `apply.sh` sets up and maintains AI instructions across all projects. See [R curl -fsSL https://gitea.nikos-dev.keskikuja.site/niko/ai-superpower/raw/branch/main/apply.sh | bash ``` -**Bootstrap phase** — when piped through bash, `BASH_SOURCE[0]` is empty. The script uses this to detect the bootstrap context, then clones (or pulls) the repo and re-execs the local `apply.sh --bootstrapped DEV_ROOT`. +**Bootstrap phase** — when piped through bash, `BASH_SOURCE[0]` is empty. The script uses this to detect the bootstrap context, then clones (or pulls) the repo and re-execs the local `apply.sh --bootstrapped DEV_ROOT`, forwarding any flags. -**Local phase** — runs with `--bootstrapped` flag. Scans dev root recursively for `.git` directories and runs per-project setup for each one found. +**`--update` flag** — pass `--update` to skip all project setup and only pull the latest instructions: + +```bash +curl -fsSL .../apply.sh | bash -s -- --update +``` + +The git pull still runs in bootstrap; local mode detects the flag at `$3`, prints the commit hash, and exits immediately. No projects are scanned, no docs touched. + +**Local phase** — runs with `--bootstrapped` flag (without `--update`). Scans dev root recursively for `.git` directories and runs per-project setup for each one found. ## Project detection diff --git a/apply.sh b/apply.sh index 6d7ff4d..f013ed5 100755 --- a/apply.sh +++ b/apply.sh @@ -10,15 +10,18 @@ RAW_URL="https://gitea.nikos-dev.keskikuja.site/niko/ai-superpower/raw/branch/ma if [[ -z "${BASH_SOURCE[0]:-}" ]]; then DEV_ROOT="$PWD" # capture before exec replaces the process TARGET="$DEV_ROOT/$REPO_NAME" + EXTRA_FLAGS="${1:-}" # pass through --update if provided if [[ -d "$TARGET" ]]; then - echo "→ updating $REPO_NAME ..." - git -C "$TARGET" pull || { echo "✗ git pull failed"; exit 1; } + 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 - echo "→ cloning $REPO_NAME into $TARGET ..." - git clone "$REPO_URL" "$TARGET" || { echo "✗ git clone failed"; exit 1; } + PREV_COMMIT="" + echo "\u2192 cloning $REPO_NAME into $TARGET ..." + git clone "$REPO_URL" "$TARGET" || { echo "\u2717 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" + # Pass DEV_ROOT and PREV_COMMIT explicitly + exec bash "$TARGET/apply.sh" --bootstrapped "$DEV_ROOT" ${EXTRA_FLAGS:+"$EXTRA_FLAGS"} "$PREV_COMMIT" fi # ── Guard — block direct invocation ────────────────────────────────────────── @@ -26,7 +29,8 @@ 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 " curl -fsSL $RAW_URL | bash # full setup" + echo " curl -fsSL $RAW_URL | bash -s -- --update # update instructions only" echo "" exit 1 fi @@ -36,7 +40,22 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DEV_ROOT="${2:?DEV_ROOT not passed — re-run via curl}" AI_TARGET="$SCRIPT_DIR/.ai" TEMPLATE_MARKER="