feat: add interactive setup wizard with API validation and mismatch detection
Major improvements to plugin setup experience: Setup Commands: - Redesign /initial-setup as interactive wizard (MCP + system + project config) - Add /project-init for quick project-only setup - Add /project-sync for handling repository moves/renames - Add Gitea API validation to auto-fill org/repo when verified Configuration Changes: - Move GITEA_ORG from system to project level (supports multi-org users) - System config now only contains GITEA_URL and GITEA_TOKEN - Project .env now contains GITEA_ORG and GITEA_REPO Automation: - Add SessionStart hook for projman and pr-review - Automatically detects git remote vs .env mismatch - Warns user to run /project-sync when mismatch found Documentation: - Unify configuration docs (remove duplicate in plugins/projman) - Add flow diagrams to CONFIGURATION.md - Add setup script review guidance to UPDATING.md - Update COMMANDS-CHEATSHEET.md with new commands and hooks Files added: - plugins/projman/commands/project-init.md - plugins/projman/commands/project-sync.md - plugins/projman/hooks/hooks.json - plugins/pr-review/commands/initial-setup.md - plugins/pr-review/commands/project-init.md - plugins/pr-review/commands/project-sync.md - plugins/pr-review/hooks/hooks.json - plugins/cmdb-assistant/commands/initial-setup.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
273
plugins/pr-review/commands/initial-setup.md
Normal file
273
plugins/pr-review/commands/initial-setup.md
Normal file
@@ -0,0 +1,273 @@
|
||||
---
|
||||
description: Interactive setup wizard for pr-review plugin - configures Gitea MCP and project settings
|
||||
---
|
||||
|
||||
# PR Review Setup Wizard
|
||||
|
||||
This command sets up the pr-review plugin. It shares the Gitea MCP server with projman, so if you've already run `/initial-setup` for projman, most of the work is done.
|
||||
|
||||
## Important Context
|
||||
|
||||
- **This command uses Bash, Read, Write, and AskUserQuestion tools** - NOT MCP tools
|
||||
- **MCP tools won't work until after setup + session restart**
|
||||
- **Shares Gitea MCP server with projman plugin**
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Check Existing Setup
|
||||
|
||||
### Step 1.1: Check if Gitea MCP is Already Configured
|
||||
|
||||
First, check if the system configuration already exists (from projman or previous setup):
|
||||
|
||||
```bash
|
||||
cat ~/.config/claude/gitea.env 2>/dev/null || echo "FILE_NOT_FOUND"
|
||||
```
|
||||
|
||||
**If file exists with valid values (no placeholders):**
|
||||
- Skip to Phase 3 (Project Configuration)
|
||||
- Inform user: "Gitea configuration found. Skipping system setup."
|
||||
|
||||
**If file doesn't exist or has placeholders:**
|
||||
- Continue to Phase 2
|
||||
|
||||
### Step 1.2: Check if projman is Installed
|
||||
|
||||
Check if projman plugin exists (they share MCP server):
|
||||
|
||||
```bash
|
||||
find ~/.claude ~/.config/claude -name "projman" -type d 2>/dev/null | head -1
|
||||
```
|
||||
|
||||
**If projman exists:**
|
||||
- Suggest: "The projman plugin is installed and shares the same Gitea MCP server. Consider running `/initial-setup` from projman for the full setup wizard."
|
||||
|
||||
Use AskUserQuestion:
|
||||
- Question: "How would you like to proceed with setup?"
|
||||
- Header: "Setup"
|
||||
- Options:
|
||||
- "Continue with pr-review setup (Recommended if not using projman)"
|
||||
- "I'll use projman's /initial-setup instead"
|
||||
|
||||
**If user chooses projman setup:** End here with instructions to run projman's setup.
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: System Setup (if needed)
|
||||
|
||||
This is a condensed version focusing on what pr-review needs.
|
||||
|
||||
### Step 2.1: Python and MCP Server
|
||||
|
||||
Check Python version:
|
||||
```bash
|
||||
python3 --version
|
||||
```
|
||||
|
||||
If below 3.10, stop and inform user.
|
||||
|
||||
Locate and set up the MCP server:
|
||||
```bash
|
||||
find ~/.claude ~/.config/claude -name "mcp_server" -path "*gitea*" 2>/dev/null | head -5
|
||||
```
|
||||
|
||||
If venv doesn't exist, create it:
|
||||
```bash
|
||||
cd /path/to/mcp-servers/gitea && python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip && pip install -r requirements.txt && deactivate
|
||||
```
|
||||
|
||||
### Step 2.2: Gitea Configuration
|
||||
|
||||
Create config directory:
|
||||
```bash
|
||||
mkdir -p ~/.config/claude
|
||||
```
|
||||
|
||||
Use AskUserQuestion:
|
||||
- Question: "What is your Gitea server URL?"
|
||||
- Header: "Gitea URL"
|
||||
- Options:
|
||||
- "https://gitea.hotserv.cloud"
|
||||
- "Other (I'll provide the URL)"
|
||||
|
||||
Create configuration file (credentials only, org is per-project):
|
||||
```bash
|
||||
cat > ~/.config/claude/gitea.env << 'EOF'
|
||||
# Gitea API Configuration
|
||||
# Generated by pr-review /initial-setup
|
||||
# Note: GITEA_ORG is configured per-project in .env
|
||||
|
||||
GITEA_URL=<USER_PROVIDED_URL>
|
||||
GITEA_TOKEN=PASTE_YOUR_TOKEN_HERE
|
||||
EOF
|
||||
chmod 600 ~/.config/claude/gitea.env
|
||||
```
|
||||
|
||||
### Step 2.3: Token Instructions
|
||||
|
||||
Display these instructions:
|
||||
|
||||
---
|
||||
|
||||
**Action Required: Add Your Gitea API Token**
|
||||
|
||||
I've created `~/.config/claude/gitea.env` but you need to add your API token manually.
|
||||
|
||||
**Steps:**
|
||||
1. Open: `nano ~/.config/claude/gitea.env`
|
||||
2. Generate token in Gitea: Settings → Applications → Generate New Token
|
||||
- Permissions needed: `repo`, `read:org`, `read:user`
|
||||
3. Replace `PASTE_YOUR_TOKEN_HERE` with your token
|
||||
4. Save the file
|
||||
|
||||
---
|
||||
|
||||
Use AskUserQuestion:
|
||||
- Question: "Have you added your Gitea token?"
|
||||
- Header: "Token"
|
||||
- Options:
|
||||
- "Yes, I've added the token"
|
||||
- "Skip for now"
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Project Configuration
|
||||
|
||||
### Step 3.1: Check Current Directory
|
||||
|
||||
```bash
|
||||
pwd && git rev-parse --show-toplevel 2>/dev/null || echo "NOT_A_GIT_REPO"
|
||||
```
|
||||
|
||||
### Step 3.2: Check Existing Project Config
|
||||
|
||||
```bash
|
||||
cat .env 2>/dev/null | grep GITEA_REPO || echo "NOT_FOUND"
|
||||
```
|
||||
|
||||
If `GITEA_REPO` is already set, skip to Phase 4.
|
||||
|
||||
### Step 3.3: Detect Organization and Repository
|
||||
|
||||
Extract organization:
|
||||
```bash
|
||||
git remote get-url origin 2>/dev/null | sed 's/.*[:/]\([^/]*\)\/[^/]*$/\1/'
|
||||
```
|
||||
|
||||
Extract repository:
|
||||
```bash
|
||||
git remote get-url origin 2>/dev/null | sed 's/.*[:/]\([^/]*\)\.git$/\1/' | sed 's/.*\/\([^/]*\)$/\1/'
|
||||
```
|
||||
|
||||
### Step 3.4: Validate Repository via Gitea API
|
||||
|
||||
```bash
|
||||
source ~/.config/claude/gitea.env
|
||||
curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITEA_TOKEN" "$GITEA_URL/api/v1/repos/<detected-org>/<detected-repo>"
|
||||
```
|
||||
|
||||
| HTTP Code | Action |
|
||||
|-----------|--------|
|
||||
| **200** | Auto-fill - "Verified: <org>/<repo> exists" - skip to Step 3.7 |
|
||||
| **404** | Not found - proceed to Step 3.5 |
|
||||
| **401/403** | Permission issue - warn, proceed to Step 3.5 |
|
||||
|
||||
### Step 3.5: Confirm Organization (only if validation failed)
|
||||
|
||||
Use AskUserQuestion:
|
||||
- Question: "Repository not found. Is '<detected-org>' the correct organization?"
|
||||
- Header: "Organization"
|
||||
- Options:
|
||||
- "Yes, that's correct"
|
||||
- "No, let me specify"
|
||||
|
||||
### Step 3.6: Confirm Repository (only if validation failed)
|
||||
|
||||
Use AskUserQuestion:
|
||||
- Question: "Is '<detected-repo-name>' the correct repository?"
|
||||
- Header: "Repository"
|
||||
- Options:
|
||||
- "Yes, that's correct"
|
||||
- "No, let me specify"
|
||||
|
||||
**After corrections, re-validate via API (Step 3.4).**
|
||||
|
||||
### Step 3.7: Create/Update Project Config
|
||||
|
||||
If `.env` exists, append:
|
||||
```bash
|
||||
echo "GITEA_ORG=<ORG_NAME>" >> .env
|
||||
echo "GITEA_REPO=<REPO_NAME>" >> .env
|
||||
```
|
||||
|
||||
If `.env` doesn't exist:
|
||||
```bash
|
||||
cat > .env << 'EOF'
|
||||
# Project Configuration
|
||||
GITEA_ORG=<ORG_NAME>
|
||||
GITEA_REPO=<REPO_NAME>
|
||||
EOF
|
||||
```
|
||||
|
||||
### Step 3.5: PR Review Settings (Optional)
|
||||
|
||||
Use AskUserQuestion:
|
||||
- Question: "Do you want to configure PR review settings?"
|
||||
- Header: "Settings"
|
||||
- Options:
|
||||
- "Use defaults (Recommended)"
|
||||
- "Let me customize"
|
||||
|
||||
If customize, ask about:
|
||||
- `PR_REVIEW_CONFIDENCE_THRESHOLD` (default: 0.5)
|
||||
- `PR_REVIEW_AUTO_SUBMIT` (default: false)
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Validation and Next Steps
|
||||
|
||||
### Step 4.1: Test Configuration (if token was added)
|
||||
|
||||
```bash
|
||||
source ~/.config/claude/gitea.env && curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITEA_TOKEN" "$GITEA_URL/api/v1/user"
|
||||
```
|
||||
|
||||
Report result:
|
||||
- 200: Success
|
||||
- 401: Invalid token
|
||||
- Other: Connection issue
|
||||
|
||||
### Step 4.2: Summary
|
||||
|
||||
```
|
||||
╔════════════════════════════════════════════════════════════╗
|
||||
║ PR-REVIEW SETUP COMPLETE ║
|
||||
╠════════════════════════════════════════════════════════════╣
|
||||
║ MCP Server (Gitea): ✓ Ready ║
|
||||
║ System Config: ✓ ~/.config/claude/gitea.env ║
|
||||
║ Project Config: ✓ ./.env ║
|
||||
╚════════════════════════════════════════════════════════════╝
|
||||
```
|
||||
|
||||
### Step 4.3: Session Restart Notice
|
||||
|
||||
---
|
||||
|
||||
**⚠️ Session Restart Required**
|
||||
|
||||
Restart your Claude Code session for MCP tools to become available.
|
||||
|
||||
**After restart, you can:**
|
||||
- Run `/pr-review <PR_NUMBER>` to review a pull request
|
||||
- Run `/pr-summary <PR_NUMBER>` for a quick summary
|
||||
- Run `/pr-findings <PR_NUMBER>` to list actionable findings
|
||||
|
||||
---
|
||||
|
||||
## Available Commands After Setup
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/pr-review <number>` | Full multi-agent PR review with confidence scoring |
|
||||
| `/pr-summary <number>` | Quick PR summary |
|
||||
| `/pr-findings <number>` | List findings with severity and line numbers |
|
||||
Reference in New Issue
Block a user