feat(project-bootstrap): add greenfield-full mode with remote create
Three modes now: greenfield-full (new + remote), add-remote, upgrade. Step 0: detect git/remote/empty state for mode selection. Step 1.5: Gitea API repo create + push. Step 8: projects-meta sync for visibility. Version 1.7.0 → 1.8.0 (MINOR). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
---
|
||||
name: project-bootstrap
|
||||
version: 1.7.0
|
||||
version: 1.8.0
|
||||
description: >
|
||||
Initializes or upgrades a project in the current folder: git, .gitignore, README.md,
|
||||
.wiki/ using Karpathy's method, .tasks/ for task tracking, CLAUDE.md with skill triggers.
|
||||
Creates remote Gitea repo and syncs projects-meta cache for greenfield projects.
|
||||
Use this skill when the user says "initialize project", "bootstrap", "setup project",
|
||||
"upgrade project", "add wiki", "add tasks", "start project", "set everything up",
|
||||
or launches the agent in a new or existing folder and wants to configure the workspace.
|
||||
"create new project", or launches the agent in a new folder and wants a full setup.
|
||||
Trigger even if the user just says "let's start a project" or "set it all up".
|
||||
---
|
||||
|
||||
# Project Bootstrap
|
||||
|
||||
Sets up a complete working environment for a monorepo project in one pass.
|
||||
Operates in two modes: **init** (new project) and **upgrade** (existing project).
|
||||
Operates in three modes: **greenfield-full** (new project + remote create), **add-remote**
|
||||
(existing git without remote), and **upgrade** (existing project).
|
||||
|
||||
---
|
||||
|
||||
@@ -24,18 +26,26 @@ Check what already exists in the current directory:
|
||||
```bash
|
||||
ls -la
|
||||
git rev-parse --git-dir 2>/dev/null && echo "git:yes" || echo "git:no"
|
||||
git remote get-url origin 2>/dev/null && echo "remote:yes" || echo "remote:no"
|
||||
ls -A 2>/dev/null | grep -q . && echo "empty:no" || echo "empty:yes"
|
||||
[ -d .wiki ] && echo "wiki:yes" || echo "wiki:no"
|
||||
[ -d .tasks ] && echo "tasks:yes" || echo "tasks:no"
|
||||
[ -f CLAUDE.md ] && echo "claude:yes" || echo "claude:no"
|
||||
[ -f README.md ] && echo "readme:yes" || echo "readme:no"
|
||||
```
|
||||
|
||||
Determine mode:
|
||||
- **greenfield-full**: `git:no` + `empty:yes` — new project, will create remote
|
||||
- **add-remote**: `git:yes` + `remote:no` — existing git, offer to create remote
|
||||
- **upgrade**: otherwise — existing project, upgrade only
|
||||
|
||||
Show the user a summary in one block — what was found, what will be created:
|
||||
|
||||
```
|
||||
Found: ✅ git ❌ .wiki ✅ .tasks ❌ CLAUDE.md ✅ README.md
|
||||
Create: .wiki CLAUDE.md
|
||||
Skip: git (exists) .tasks (exists) README.md (exists)
|
||||
Mode: greenfield-full (new project + remote create)
|
||||
|
||||
Found: (empty directory)
|
||||
Create: git .wiki .tasks CLAUDE.md .gitignore README.md remote
|
||||
```
|
||||
|
||||
Ask one question: "Looks right? Shall we proceed?" — and wait for confirmation.
|
||||
@@ -56,6 +66,69 @@ If it exists — leave it untouched.
|
||||
|
||||
---
|
||||
|
||||
## Step 1.5 — Remote create (greenfield-full / add-remote modes)
|
||||
|
||||
Only in **greenfield-full** or **add-remote** mode. Skip for upgrade mode.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Read `~/.config/projects-mcp/auth.toml` to get Gitea credentials:
|
||||
|
||||
```bash
|
||||
# POSIX (Linux/macOS/git-bash):
|
||||
source ~/.config/projects-mcp/auth.toml 2>/dev/null || true
|
||||
# Windows PowerShell:
|
||||
Get-Content ~/.config/projects-mcp/auth.toml | Select-String "base_url|token"
|
||||
```
|
||||
|
||||
If auth file missing → stop and tell user: run `/setup-projects-meta` first.
|
||||
|
||||
### Validate project name
|
||||
|
||||
Current folder name becomes the repo name. Must be:
|
||||
- **Latin only** — a-z, 0-9, hyphens
|
||||
- **kebab-case** — lowercase, hyphens between words
|
||||
- **Not a duplicate** — check via Gitea API
|
||||
|
||||
```bash
|
||||
PROJECT_NAME=$(basename "$PWD")
|
||||
# Validate: only latin alnum + hyphen, no leading/trailing hyphen
|
||||
echo "$PROJECT_NAME" | grep -qE '^[a-z0-9]+(-[a-z0-9]+)*$' || {
|
||||
echo "❌ Invalid project name: '$PROJECT_NAME'. Use latin kebab-case (e.g. 'my-project')."
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
### Create repo via Gitea API
|
||||
|
||||
```bash
|
||||
# Extract base_url and token from auth.toml (POSIX):
|
||||
BASE_URL=$(grep "^base_url" ~/.config/projects-mcp/auth.toml | cut -d'"' -f2)
|
||||
TOKEN=$(grep "^token" ~/.config/projects-mcp/auth.toml | cut -d'"' -f2)
|
||||
|
||||
# Create repo:
|
||||
curl -X POST "$BASE_URL/api/v1/user/repos?token=$TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"name\":\"$PROJECT_NAME\",\"private\":false,\"auto_init\":false}"
|
||||
```
|
||||
|
||||
On failure → stop and show error. Duplicate name = suggest rename or delete existing.
|
||||
|
||||
### Add remote and push
|
||||
|
||||
```bash
|
||||
git remote add origin "$BASE_URL/$USER/$PROJECT_NAME.git"
|
||||
git branch -M master
|
||||
git push -u origin master
|
||||
```
|
||||
|
||||
For **add-remote** mode (git exists, push local commits after adding remote):
|
||||
```bash
|
||||
git push -u origin master # or main if that's the current branch
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 2 — README.md
|
||||
|
||||
If it does not exist — create a minimal one:
|
||||
@@ -462,6 +535,7 @@ Print a final report:
|
||||
CLAUDE.md — skill triggers
|
||||
.gitignore — standard template
|
||||
README.md — starter file
|
||||
remote — Gitea repo created and pushed
|
||||
|
||||
Skipped (already existed):
|
||||
git — left untouched
|
||||
@@ -470,6 +544,41 @@ Next step: describe the project in README.md and start your first task —
|
||||
say "use task management system".
|
||||
```
|
||||
|
||||
For **greenfield-full** mode, append to summary:
|
||||
```
|
||||
Remote: <Gitea URL>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 8 — projects-meta sync (greenfield-full mode)
|
||||
|
||||
Only in **greenfield-full** mode. Re-sync the projects-meta cache so the new
|
||||
project becomes visible to `mcp__projects-meta__*` tools.
|
||||
|
||||
```bash
|
||||
# POSIX:
|
||||
node ~/projects/.common/lib/projects-meta-mcp/dist/sync.js
|
||||
|
||||
# Windows PowerShell:
|
||||
node ~/projects/.common/lib/projects-meta-mcp/dist/sync.js
|
||||
```
|
||||
|
||||
Verify the project is now visible:
|
||||
```bash
|
||||
# Via MCP (if available in current session):
|
||||
# mcp__projects-meta__meta_status
|
||||
|
||||
# Or manually check the cache file exists:
|
||||
ls -la ~/projects/.common/lib/projects-meta-mcp/cache/projects.json
|
||||
```
|
||||
|
||||
If the sync script doesn't exist → skip with informational message:
|
||||
```
|
||||
ℹ️ projects-meta sync script not found at ~/projects/.common/lib/projects-meta-mcp/dist/sync.js
|
||||
Run /setup-projects-meta to install it. The new repo is already created in Gitea.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Rules
|
||||
|
||||
Reference in New Issue
Block a user