#!/usr/bin/env bash # Usage: scripts/bootstrap-project.sh "" [owner=peppa-bot] # Creates a Gitea repo, fills it from the Gitea template repo, runs `openspec init`, pushes, and # leaves a working clone in $PEPPA_WORKSPACES/. The web platform will call the # same steps (stage 5); this script is the manual path until then. set -euo pipefail cd "$(dirname "$0")/.." ROOT="$PWD" [ -f .env ] && set -a && . ./.env && set +a . scripts/gitea-lib.sh SLUG="${1:?slug}"; KEY="$(echo "${2:?KEY}" | tr a-z A-Z)"; NAME="${3:?name}"; OWNER="${4:-$GITEA_BOT_USER}" WS="${PEPPA_WORKSPACES:-$HOME/peppa/workspaces}"; WS="${WS/#\~/$HOME}" DEST="$WS/$SLUG" [ -e "$DEST" ] && { echo "already exists: $DEST" >&2; exit 1; } gitea_create_repo "$OWNER" "$SLUG" "$NAME" # Start from the shared template in Gitea (RULES.md stays there: sessions load it live). TPL="$(mktemp -d)"; trap 'rm -rf "$TPL"' EXIT git -c credential.helper=peppa clone -q --depth 1 "$GITEA_URL/${GITEA_TEMPLATE_REPO:-peppa-bot/template}.git" "$TPL" rm -rf "$TPL/.git" "$TPL/RULES.md" "$TPL/README.md" mkdir -p "$DEST" cp -R "$TPL/." "$DEST/" cd "$DEST" printf '# %s\n\nПроект Пеппы. Ключ задач: `%s`. Правила — в [AGENTS.md](AGENTS.md).\n' "$NAME" "$KEY" > README.md mkdir -p .peppa cat > .peppa/project.json </dev/null git init -q -b main gitea_git_setup git add -A git commit -qm "Bootstrap $NAME from Peppa template" git remote add origin "$GITEA_URL/$OWNER/$SLUG.git" git push -q -u origin main "$ROOT/packages/cli/bin/peppa" project add "$SLUG" "$KEY" "$NAME" --owner "$OWNER" --path "$DEST" echo "ready: $DEST ($GITEA_URL/$OWNER/$SLUG)"