peppa/scripts/bootstrap-project.sh
Асель 4168e8c867 Bootstrap Peppa monorepo, DB schema, OpenSpec and project template
- pnpm workspace: apps/web (Next.js), apps/bot, packages/{db,shared,mcp,runner}
- Drizzle schema: projects, goals, tasks, sessions, questions, events
- Postgres via infra/docker-compose.yml
- template/: AGENTS.md workflow on OpenSpec, Claude hooks, peppa MCP config
- scripts to push template and bootstrap projects in Gitea

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 19:13:16 +05:00

39 lines
1.8 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Usage: scripts/bootstrap-project.sh <slug> <KEY> "<Name>" [owner]
# Creates a Gitea repo, fills it from the template, runs `openspec init`, pushes, and
# leaves a working clone in $PEPPA_WORKSPACES/<slug>. 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
: "${GITEA_URL:?}" "${GITEA_TOKEN:?set GITEA_TOKEN in .env}"
SLUG="${1:?slug}"; KEY="$(echo "${2:?KEY}" | tr a-z A-Z)"; NAME="${3:?name}"; OWNER="${4:-peppa}"
WS="${PEPPA_WORKSPACES:-$HOME/peppa/workspaces}"; WS="${WS/#\~/$HOME}"
DEST="$WS/$SLUG"
HOST="${GITEA_URL#*://}"
REMOTE="https://peppa:${GITEA_TOKEN}@${HOST}/${OWNER}/${SLUG}.git"
api() { curl -fsS -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" "$@"; }
[ -e "$DEST" ] && { echo "already exists: $DEST" >&2; exit 1; }
api -X POST "$GITEA_URL/api/v1/orgs/$OWNER/repos" \
-d "{\"name\":\"$SLUG\",\"description\":\"$NAME\",\"default_branch\":\"main\",\"private\":true}" >/dev/null
mkdir -p "$DEST"
cp -R "$ROOT/template/." "$DEST/"
rm -f "$DEST/README.md"
cd "$DEST"
printf '# %s\n\nПроект Пеппы. Ключ задач: `%s`. Правила — в [AGENTS.md](AGENTS.md).\n' "$NAME" "$KEY" > README.md
mkdir -p .peppa
cat > .peppa/project.json <<JSON
{ "slug": "$SLUG", "key": "$KEY", "name": "$NAME", "peppaUrl": "${PEPPA_WEB_URL:-http://localhost:3100}" }
JSON
openspec init --tools claude,agents --no-animation . >/dev/null
git init -q -b main
git add -A
git -c user.name="Peppa" -c user.email="peppa@localhost" commit -qm "Bootstrap $NAME from Peppa template"
git remote add origin "$REMOTE"
git push -q -u origin main
git remote set-url origin "$GITEA_URL/$OWNER/$SLUG.git"
echo "ready: $DEST ($GITEA_URL/$OWNER/$SLUG)"