[agent:surfer] init template AI-ready : WORKFLOW, AGENTS, AI_CONTEXT, Sphinx, scripts
Some checks failed
Build Sphinx docs / build (push) Has been cancelled
Some checks failed
Build Sphinx docs / build (push) Has been cancelled
This commit is contained in:
81
scripts/new-project.sh
Executable file
81
scripts/new-project.sh
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
# new-project.sh — Scaffold un nouveau projet AI-ready
|
||||
# Usage: ./new-project.sh <nom-projet> "<description>" [channel-discord]
|
||||
# Ex: ./new-project.sh cosma-dashboard "Dashboard C2 COSMA temps réel" cosma
|
||||
|
||||
set -e
|
||||
REPO_NAME="${1:?Usage: $0 <nom-projet> <description> [discord-channel]}"
|
||||
DESCRIPTION="${2:?Usage: $0 <nom-projet> <description> [discord-channel]}"
|
||||
DISCORD_CHANNEL="${3:-master-plan}"
|
||||
BASE_URL="${GITEA_BASE_URL:-http://192.168.0.82:3000}"
|
||||
TEMPLATE_REPO="floppyrj45/lab-project-template"
|
||||
NEXTCLOUD_BASE="/mnt/nas-nextcloud"
|
||||
|
||||
if [[ -f "$HOME/.agent-gitea-tokens" ]]; then source "$HOME/.agent-gitea-tokens"; fi
|
||||
ADMIN_TOKEN="${GITEA_ADMIN_TOKEN:-${GITEA_TOKEN_SURFER:-}}"
|
||||
if [[ -z "$ADMIN_TOKEN" ]]; then
|
||||
echo "ERROR: Aucun token Gitea trouvé dans ~/.agent-gitea-tokens"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Création projet : $REPO_NAME ==="
|
||||
|
||||
# 1. Create Gitea repo from template
|
||||
echo "[1/4] Création repo Gitea..."
|
||||
REPO=$(curl -sf -X POST "$BASE_URL/api/v1/repos/$TEMPLATE_REPO/generate" \
|
||||
-H "Authorization: token $ADMIN_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"owner\": \"floppyrj45\",
|
||||
\"name\": \"$REPO_NAME\",
|
||||
\"description\": \"$DESCRIPTION\",
|
||||
\"private\": true,
|
||||
\"default_branch\": \"main\"
|
||||
}" | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d.get("html_url","ERR"))' 2>/dev/null)
|
||||
echo " Repo: $REPO"
|
||||
|
||||
# 2. Create Nextcloud folder
|
||||
echo "[2/4] Création dossier Nextcloud..."
|
||||
mkdir -p "$NEXTCLOUD_BASE/$REPO_NAME" 2>/dev/null || echo " (Nextcloud mount non disponible, à créer manuellement)"
|
||||
|
||||
# 3. Clone and customize AI_CONTEXT.md
|
||||
echo "[3/4] Personnalisation du template..."
|
||||
WORK_DIR=$(mktemp -d)
|
||||
git clone "http://floppyrj45@192.168.0.82:3000/floppyrj45/$REPO_NAME" "$WORK_DIR/$REPO_NAME" 2>/dev/null
|
||||
cd "$WORK_DIR/$REPO_NAME"
|
||||
|
||||
sed -i "s/PROJECT_NAME/$REPO_NAME/g" AI_CONTEXT.md README.md CLAUDE.md docs/conf.py docs/index.rst
|
||||
sed -i "s/PROJECT_DESCRIPTION/$DESCRIPTION/g" AI_CONTEXT.md README.md
|
||||
sed -i "s/PROJECT_CHANNEL/$DISCORD_CHANNEL/g" AI_CONTEXT.md README.md
|
||||
|
||||
git config user.name "agent-surfer"
|
||||
git config user.email "agent-surfer@labo.local"
|
||||
git add -A
|
||||
git commit -m "[agent:surfer] init scaffold $REPO_NAME"
|
||||
git push origin main
|
||||
cd / && rm -rf "$WORK_DIR"
|
||||
|
||||
# 4. Setup branch protection
|
||||
echo "[4/4] Protection de branches..."
|
||||
for branch in main develop; do
|
||||
curl -sf -X POST "$BASE_URL/api/v1/repos/floppyrj45/$REPO_NAME/branch_protections" \
|
||||
-H "Authorization: token $ADMIN_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"branch_name\": \"$branch\",
|
||||
\"enable_push\": false,
|
||||
\"enable_push_whitelist\": true,
|
||||
\"push_whitelist_usernames\": [\"floppyrj45\"],
|
||||
\"require_signed_commits\": false,
|
||||
\"enable_status_check\": false
|
||||
}" > /dev/null 2>&1 || true
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=== Projet $REPO_NAME prêt ==="
|
||||
echo " Gitea : $BASE_URL/floppyrj45/$REPO_NAME"
|
||||
echo " Docs : http://192.168.0.82/$REPO_NAME-docs/"
|
||||
echo " NC : $NEXTCLOUD_BASE/$REPO_NAME/"
|
||||
echo ""
|
||||
echo "Pour un agent Claude CLI :"
|
||||
echo " git clone http://192.168.0.82:3000/floppyrj45/$REPO_NAME && cd $REPO_NAME && claude"
|
||||
Reference in New Issue
Block a user