Add automated setup system for easy installation
All checks were successful
AI Codebase Quality Review / ai-codebase-review (push) Successful in 36s

- Add setup.sh interactive wizard for 5-minute setup
- Add INSTALL.md comprehensive installation guide
- Add templates/workflows/ directory with parameterized workflow templates
- Update README.md with prominent Installation section
- Update docs/README.md with installation links

The setup wizard automates:
- Platform selection (Gitea/GitHub)
- Bot configuration
- LLM provider setup
- Workflow file generation
- Configuration file creation

Users can now add OpenRabbit to any repository in under 5 minutes.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-16 11:33:05 +00:00
parent b24ae0dcda
commit 95937c4738
9 changed files with 964 additions and 5 deletions

318
INSTALL.md Normal file
View File

@@ -0,0 +1,318 @@
# Installation
Add OpenRabbit AI code review to your Gitea or GitHub repository in under 5 minutes.
---
## Quick Start (Recommended)
### Automated Setup
Run the interactive setup wizard:
```bash
# Clone OpenRabbit (or download setup.sh)
git clone https://github.com/YourOrg/openrabbit.git
cd openrabbit
# Run setup wizard
./setup.sh
```
The wizard will:
- ✅ Ask for your platform (Gitea/GitHub)
- ✅ Configure bot name and LLM provider
- ✅ Generate workflow files for your platform
- ✅ Create basic configuration file
- ✅ Provide step-by-step next actions
**That's it!** Follow the wizard's output to complete setup.
---
## Prerequisites
Before you start, ensure you have:
- [ ] **Gitea or GitHub repository** with Actions enabled
- [ ] **Python 3.11+** (for the AI review tools)
- [ ] **LLM API access** - Choose one:
- OpenAI API key (recommended for getting started)
- Anthropic Claude API key
- Azure OpenAI Service access
- Google Gemini API key
- Self-hosted Ollama instance
- [ ] **Bot account** (for Gitea) or use built-in GITHUB_TOKEN (for GitHub)
---
## Manual Setup
Prefer to set up manually? Follow these platform-specific instructions.
### For Gitea
#### 1. Create Bot Account
1. Create a new Gitea user (e.g., `codebot`, `ai-reviewer`)
2. Generate an access token:
- Go to User Settings → Applications → Generate New Token
- Enable scopes: `repo` (Full repository access), `issue` (Issue read/write)
3. Save the token securely
#### 2. Add Organization/Repository Secrets
Go to Settings → Secrets and add:
| Secret Name | Description | Required |
|-------------|-------------|----------|
| `AI_REVIEW_TOKEN` | Bot's Gitea access token | ✅ Yes |
| `OPENAI_API_KEY` | OpenAI API key (or your LLM provider's key) | ✅ Yes |
| `OPENROUTER_API_KEY` | OpenRouter API key | Only if using OpenRouter |
| `OLLAMA_HOST` | Ollama server URL (e.g., `http://localhost:11434`) | Only if using Ollama |
| `SEARXNG_URL` | SearXNG instance URL for web search | Optional |
#### 3. Add Workflow Files
Copy workflow files to your repository:
```bash
# In your project repository
mkdir -p .gitea/workflows
# Copy from OpenRabbit (adjust path as needed)
cp /path/to/openrabbit/templates/workflows/*.yml .gitea/workflows/
# Edit each workflow file and replace:
# - {{OPENRABBIT_REPO}} → Your OpenRabbit fork (e.g., YourOrg/openrabbit)
# - {{API_URL}} → Your Gitea API URL (e.g., https://gitea.example.com/api/v1)
# - {{BOT_NAME}} → Your bot mention name (e.g., codebot)
# - {{BOT_USERNAME}} → Your bot account username
# - {{PLATFORM}} → gitea
```
Or use the setup wizard to generate them automatically: `./setup.sh`
#### 4. Commit and Push
```bash
git add .gitea/workflows/
git commit -m "Add OpenRabbit AI code review"
git push
```
#### 5. Set Up Labels
Create an issue and comment:
```
@codebot setup-labels
```
The bot will automatically create required labels.
---
### For GitHub
#### 1. Add Repository/Organization Secrets
Go to Settings → Secrets and variables → Actions:
| Secret Name | Description | Required |
|-------------|-------------|----------|
| `OPENAI_API_KEY` | OpenAI API key (or your LLM provider's key) | ✅ Yes |
| `AI_REVIEW_TOKEN` | Only if OpenRabbit repo is private | Optional |
| `OPENROUTER_API_KEY` | OpenRouter API key | Only if using OpenRouter |
| `OLLAMA_HOST` | Ollama server URL | Only if using Ollama |
| `SEARXNG_URL` | SearXNG instance URL | Optional |
**Note:** GitHub's built-in `GITHUB_TOKEN` is used automatically for API access.
#### 2. Add Workflow Files
Copy workflow files to your repository:
```bash
# In your project repository
mkdir -p .github/workflows
# Copy from OpenRabbit
cp /path/to/openrabbit/templates/workflows/*.yml .github/workflows/
# Edit each workflow file and replace:
# - {{OPENRABBIT_REPO}} → OpenRabbit repository (e.g., anthropics/openrabbit)
# - {{API_URL}} → https://api.github.com
# - {{BOT_NAME}} → Your bot mention name (e.g., codebot)
# - {{BOT_USERNAME}} → Your bot username (or 'github-actions[bot]')
# - {{PLATFORM}} → github
```
Or use the setup wizard: `./setup.sh`
#### 3. Commit and Push
```bash
git add .github/workflows/
git commit -m "Add OpenRabbit AI code review"
git push
```
#### 4. Set Up Labels
Create an issue and comment:
```
@codebot setup-labels
```
---
## Configuration
### Basic Configuration
If you used the setup wizard, a basic `tools/ai-review/config.yml` was created.
### Advanced Configuration
For advanced settings, see:
- **[Configuration Reference](docs/configuration.md)** - All config options
- **[Agent Documentation](docs/agents.md)** - Agent-specific settings
- **[LLM Providers](docs/configuration.md#llm-providers)** - Provider setup
### Per-Repository Overrides
Create `.ai-review.yml` in your project root to override settings:
```yaml
# .ai-review.yml
review:
fail_on_severity: MEDIUM # Override: fail on MEDIUM instead of HIGH
agents:
pr:
auto_summary:
enabled: false # Disable auto-summary for this repo
```
---
## Testing Your Setup
### Test PR Review
1. Create a new pull request
2. Wait 30-60 seconds for the workflow to run
3. Check for the AI review comment with inline suggestions
### Test Issue Triage
1. Create a new issue
2. Comment: `@codebot triage`
3. The bot should analyze and label the issue
### Test Chat
1. On any issue, comment: `@codebot How does authentication work?`
2. The bot should search the codebase and respond
### Test Commands
Try these commands in issue comments:
- `@codebot help` - Show all available commands
- `@codebot explain` - Explain the issue in detail
- `@codebot summarize` - Generate a summary
- `@codebot suggest` - Get solution suggestions
---
## Troubleshooting
### Workflow Not Triggering
**Problem:** No AI review appears after creating a PR.
**Solutions:**
- ✅ Verify Actions/Workflows are enabled in repository settings
- ✅ Check workflow files are in correct directory (`.gitea/workflows/` or `.github/workflows/`)
- ✅ Review workflow syntax: `cat .gitea/workflows/enterprise-ai-review.yml`
- ✅ Check Actions tab for error logs
### "Missing Token" Error
**Problem:** Workflow fails with authentication error.
**Solutions:**
- ✅ Verify `AI_REVIEW_TOKEN` secret is set (Gitea)
- ✅ Verify token has correct permissions: `repo`, `issue`
- ✅ For private OpenRabbit repos on GitHub, set `AI_REVIEW_TOKEN`
### "LLM Call Failed" Error
**Problem:** Workflow fails when calling the LLM.
**Solutions:**
- ✅ Verify API key secret is set (`OPENAI_API_KEY`, etc.)
- ✅ Check API key is valid and has credits/quota remaining
- ✅ Verify `provider` in `config.yml` matches your secret
- ✅ For Ollama: verify `OLLAMA_HOST` is accessible from runner
### Bot Not Responding to Commands
**Problem:** Commenting `@codebot help` does nothing.
**Solutions:**
- ✅ Verify bot name matches `mention_prefix` in `config.yml`
- ✅ Check bot username in workflow `if:` conditions matches actual bot account
- ✅ Verify `github.event.comment.user.login != 'BotUsername'` in workflows (prevents infinite loops)
- ✅ Check Actions tab to see if workflow ran
### Labels Not Applied
**Problem:** Bot reviews the code but doesn't add labels.
**Solutions:**
- ✅ Run `@codebot setup-labels` to create required labels
- ✅ Verify bot account has permission to manage labels
- ✅ Check label names in `config.yml` match repository labels
### Need More Help?
- **[Troubleshooting Guide](docs/troubleshooting.md)** - Comprehensive troubleshooting
- **[Getting Started](docs/getting-started.md)** - Detailed setup walkthrough
- **[GitHub Issues](https://github.com/YourOrg/openrabbit/issues)** - Report bugs or ask questions
---
## Next Steps
Once OpenRabbit is working:
### Customize Behavior
- **[Configuration Guide](docs/configuration.md)** - Adjust review settings, severity thresholds
- **[Agent Reference](docs/agents.md)** - Enable/disable agents, configure features
- **[Security Scanning](docs/SECURITY.md)** - Understand security rules, add custom rules
### Enterprise Features
- **[Notifications](docs/enterprise.md#notifications)** - Slack/Discord alerts
- **[Metrics](docs/enterprise.md#metrics)** - Prometheus monitoring
- **[Audit Logging](docs/enterprise.md#audit-trail)** - Compliance and audit trails
- **[CODEOWNERS](docs/enterprise.md#codeowners)** - Enforce code ownership
### Advanced Usage
- **[Workflow Reference](docs/workflows.md)** - Understand workflow routing
- **[CLI Usage](docs/getting-started.md#helper-cli-usage)** - Run reviews locally
- **[API Reference](docs/api-reference.md)** - Integrate with custom tools
---
## Support
- **Documentation:** [docs/](docs/)
- **Issues:** [GitHub Issues](https://github.com/YourOrg/openrabbit/issues)
- **Discussions:** [GitHub Discussions](https://github.com/YourOrg/openrabbit/discussions)
---
**🎉 Enjoy automated code reviews with OpenRabbit!**

View File

@@ -26,6 +26,29 @@ Enterprise-grade AI code review system for **Gitea** and **GitHub** with automat
--- ---
## 📦 Installation
**Quick Setup (5 minutes):**
```bash
# Clone OpenRabbit
git clone https://github.com/YourOrg/openrabbit.git
cd openrabbit
# Run interactive setup wizard
./setup.sh
```
The wizard will generate workflow files, create configuration, and guide you through the remaining steps.
**📖 See [INSTALL.md](INSTALL.md) for:**
- Detailed installation instructions
- Manual setup guide
- Platform-specific differences (Gitea vs GitHub)
- Troubleshooting common issues
---
## Quick Start ## Quick Start
### 1. Set Repository/Organization Secrets ### 1. Set Repository/Organization Secrets

View File

@@ -6,19 +6,23 @@ Enterprise-grade AI code review system for Gitea with automated issue triage, PR
| Document | Description | | Document | Description |
|----------|-------------| |----------|-------------|
| [Getting Started](getting-started.md) | Quick setup guide | | [**Installation**](../INSTALL.md) | **Automated setup wizard & installation guide** |
| [Getting Started](getting-started.md) | Detailed setup walkthrough |
| [Configuration](configuration.md) | All configuration options | | [Configuration](configuration.md) | All configuration options |
| [Agents](agents.md) | Detailed agent documentation | | [Agents](agents.md) | Detailed agent documentation |
| [Security](security.md) | Security scanning features | | [SECURITY](SECURITY.md) | Security best practices & scanning |
| [API Reference](api-reference.md) | Client and agent APIs | | [API Reference](api-reference.md) | Client and agent APIs |
| [Workflows](workflows.md) | Gitea workflow examples | | [Workflows](workflows.md) | Gitea workflow examples |
| [Troubleshooting](troubleshooting.md) | Common issues and solutions | | [Troubleshooting](troubleshooting.md) | Common issues and solutions |
| [Enterprise](enterprise.md) | Enterprise features & compliance |
| [CLAUDE](CLAUDE.md) | Claude Code integration guide |
## Quick Links ## Quick Links
- **Setup**: See [Getting Started](getting-started.md) - **🚀 Installation**: See [../INSTALL.md](../INSTALL.md) - Automated setup wizard
- **Configuration**: See [Configuration](configuration.md) - **⚙️ Configuration**: See [Configuration](configuration.md)
- **Enterprise Features**: See [Enterprise](enterprise.md) - **🏢 Enterprise Features**: See [Enterprise](enterprise.md)
- **🔧 Troubleshooting**: See [Troubleshooting](troubleshooting.md)
## Architecture Overview ## Architecture Overview

300
setup.sh Executable file
View File

@@ -0,0 +1,300 @@
#!/bin/bash
# OpenRabbit Setup Wizard
# This script helps you set up OpenRabbit AI code review for your Gitea or GitHub repository
set -e # Exit on error
echo "🐰 OpenRabbit Setup Wizard"
echo "==========================="
echo ""
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEMPLATE_DIR="$SCRIPT_DIR/templates/workflows"
# Check if templates directory exists
if [ ! -d "$TEMPLATE_DIR" ]; then
echo "❌ Error: Template directory not found at $TEMPLATE_DIR"
echo "Please run this script from the OpenRabbit repository root."
exit 1
fi
# 1. Detect platform
echo "Step 1: Platform Configuration"
echo "------------------------------"
read -p "Platform? [gitea/github] (default: gitea): " PLATFORM
PLATFORM=${PLATFORM:-gitea}
# Validate platform
if [ "$PLATFORM" != "gitea" ] && [ "$PLATFORM" != "github" ]; then
echo "❌ Error: Invalid platform. Please choose 'gitea' or 'github'"
exit 1
fi
echo "✅ Platform: $PLATFORM"
echo ""
# 2. Bot configuration
echo "Step 2: Bot Configuration"
echo "-------------------------"
read -p "Bot mention name (e.g., codebot): " BOT_NAME
while [ -z "$BOT_NAME" ]; do
echo "❌ Bot name cannot be empty"
read -p "Bot mention name (e.g., codebot): " BOT_NAME
done
# Validate bot name (alphanumeric, dash, underscore only)
if ! echo "$BOT_NAME" | grep -qE '^[a-zA-Z0-9_-]+$'; then
echo "❌ Error: Bot name must contain only letters, numbers, dashes, and underscores"
exit 1
fi
read -p "Bot account username (default: same as mention name): " BOT_USERNAME
BOT_USERNAME=${BOT_USERNAME:-$BOT_NAME}
echo "✅ Bot: @$BOT_NAME (account: $BOT_USERNAME)"
echo ""
# 3. LLM Provider
echo "Step 3: LLM Provider"
echo "--------------------"
echo "Available providers:"
echo " 1) openai - OpenAI GPT models (default)"
echo " 2) anthropic - Anthropic Claude models"
echo " 3) azure - Azure OpenAI Service"
echo " 4) gemini - Google Gemini API"
echo " 5) ollama - Self-hosted Ollama"
read -p "Choose provider [1-5] (default: 1): " PROVIDER_CHOICE
PROVIDER_CHOICE=${PROVIDER_CHOICE:-1}
case "$PROVIDER_CHOICE" in
1) PROVIDER="openai" ;;
2) PROVIDER="anthropic" ;;
3) PROVIDER="azure" ;;
4) PROVIDER="gemini" ;;
5) PROVIDER="ollama" ;;
*)
echo "❌ Invalid choice. Using openai."
PROVIDER="openai"
;;
esac
echo "✅ Provider: $PROVIDER"
echo ""
# 4. Platform-specific settings
if [ "$PLATFORM" = "gitea" ]; then
echo "Step 4: Gitea Configuration"
echo "---------------------------"
read -p "Gitea API URL (e.g., https://gitea.example.com/api/v1): " API_URL
while [ -z "$API_URL" ]; do
echo "❌ API URL cannot be empty"
read -p "Gitea API URL: " API_URL
done
# Validate URL format
if ! echo "$API_URL" | grep -qE '^https?://'; then
echo "❌ Error: API URL must start with http:// or https://"
exit 1
fi
echo "✅ API URL: $API_URL"
else
echo "Step 4: GitHub Configuration"
echo "----------------------------"
API_URL="https://api.github.com"
echo "✅ Using GitHub API: $API_URL"
fi
echo ""
# 5. OpenRabbit repository location
echo "Step 5: OpenRabbit Repository"
echo "-----------------------------"
read -p "OpenRabbit repo location (e.g., YourOrg/openrabbit): " OPENRABBIT_REPO
while [ -z "$OPENRABBIT_REPO" ]; do
echo "❌ Repository cannot be empty"
read -p "OpenRabbit repo location: " OPENRABBIT_REPO
done
# Validate repo format
if ! echo "$OPENRABBIT_REPO" | grep -qE '^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$'; then
echo "❌ Error: Repository must be in format 'owner/repo'"
exit 1
fi
echo "✅ OpenRabbit: $OPENRABBIT_REPO"
echo ""
# 6. Create workflow directory
echo "Step 6: Creating Workflow Files"
echo "--------------------------------"
WORKFLOW_DIR=".${PLATFORM}/workflows"
mkdir -p "$WORKFLOW_DIR"
# Replace template variables in workflow files
for template in "$TEMPLATE_DIR"/*.yml; do
filename=$(basename "$template")
output="$WORKFLOW_DIR/$filename"
echo "Creating $output..."
# Use sed to replace template variables
sed -e "s|{{OPENRABBIT_REPO}}|$OPENRABBIT_REPO|g" \
-e "s|{{API_URL}}|$API_URL|g" \
-e "s|{{BOT_NAME}}|$BOT_NAME|g" \
-e "s|{{BOT_USERNAME}}|$BOT_USERNAME|g" \
-e "s|{{PLATFORM}}|$PLATFORM|g" \
"$template" > "$output"
done
echo "✅ Created 5 workflow files in $WORKFLOW_DIR/"
echo ""
# 7. Create basic config.yml if it doesn't exist
CONFIG_FILE="tools/ai-review/config.yml"
if [ ! -f "$CONFIG_FILE" ]; then
echo "Step 7: Creating Configuration File"
echo "------------------------------------"
mkdir -p "$(dirname "$CONFIG_FILE")"
cat > "$CONFIG_FILE" <<EOF
# OpenRabbit Configuration
# This is a basic configuration - see docs/configuration.md for full options
provider: $PROVIDER
model:
openai: gpt-4.1-mini
anthropic: claude-3.5-sonnet
azure: gpt-4
gemini: gemini-1.5-pro
ollama: codellama:13b
interaction:
mention_prefix: "@$BOT_NAME"
commands:
- help
- explain
- suggest
- security
- summarize
- triage
- changelog
- explain-diff
- review-again
- setup-labels
review:
fail_on_severity: HIGH
max_diff_lines: 800
security_scan: true
agents:
issue:
enabled: true
pr:
enabled: true
security_scan: true
auto_summary:
enabled: true
post_as_comment: true
codebase:
enabled: true
chat:
enabled: true
max_iterations: 5
labels:
priority:
critical: "priority: critical"
high: "priority: high"
medium: "priority: medium"
low: "priority: low"
type:
bug: "type: bug"
feature: "type: feature"
question: "type: question"
documentation: "type: documentation"
security: "type: security"
status:
approved: "ai-approved"
changes_required: "ai-changes-required"
reviewed: "ai-reviewed"
EOF
echo "✅ Created $CONFIG_FILE"
echo ""
else
echo "Step 7: Configuration File"
echo "--------------------------"
echo " $CONFIG_FILE already exists (not overwriting)"
echo ""
fi
# 8. Display next steps
echo "✅ Setup Complete!"
echo "=================="
echo ""
echo "📋 Next Steps:"
echo ""
echo "1⃣ Create Bot Account"
echo " - Create a new $PLATFORM user account: '$BOT_USERNAME'"
if [ "$PLATFORM" = "gitea" ]; then
echo " - Generate an access token with 'repo' and 'issue' permissions"
else
echo " - The built-in GITHUB_TOKEN will be used automatically"
fi
echo ""
echo "2⃣ Add Repository/Organization Secrets"
if [ "$PLATFORM" = "gitea" ]; then
echo " Required secrets:"
echo " • AI_REVIEW_TOKEN = <bot access token>"
echo " • OPENAI_API_KEY = <your LLM API key>"
echo ""
echo " Optional secrets:"
echo " • OPENROUTER_API_KEY = <if using OpenRouter>"
echo " • OLLAMA_HOST = <if using Ollama>"
echo " • SEARXNG_URL = <if using web search>"
else
echo " Required secrets:"
echo " • OPENAI_API_KEY = <your LLM API key>"
echo ""
echo " Optional secrets:"
echo " • AI_REVIEW_TOKEN = <if using private OpenRabbit repo>"
echo " • OPENROUTER_API_KEY = <if using OpenRouter>"
echo " • OLLAMA_HOST = <if using Ollama>"
echo " • SEARXNG_URL = <if using web search>"
fi
echo ""
echo "3⃣ Commit and Push Workflow Files"
echo " git add $WORKFLOW_DIR/"
if [ ! -f "$CONFIG_FILE.orig" ]; then
echo " git add $CONFIG_FILE"
fi
echo " git commit -m \"Add OpenRabbit AI code review workflows\""
echo " git push"
echo ""
echo "4⃣ Set Up Labels (Automatic)"
echo " Create an issue in your repository and comment:"
echo " @$BOT_NAME setup-labels"
echo ""
echo " The bot will automatically detect your label schema and create missing labels."
echo ""
echo "5⃣ Test the Setup"
echo " • Create a pull request to test PR review"
echo " • Comment '@$BOT_NAME help' on any issue to see available commands"
echo " • Comment '@$BOT_NAME How does authentication work?' for chat"
echo ""
echo "📚 Documentation:"
echo " • Installation Guide: INSTALL.md"
echo " • Configuration: docs/configuration.md"
echo " • Agent Reference: docs/agents.md"
echo " • Troubleshooting: docs/troubleshooting.md"
echo ""
echo "🎉 Happy reviewing with OpenRabbit!"

View File

@@ -0,0 +1,61 @@
name: AI Chat ({{BOT_USERNAME}})
# WORKFLOW ROUTING:
# This workflow handles FREE-FORM questions/chat (no specific command)
# Other workflows: ai-issue-triage.yml (@{{BOT_NAME}} triage), ai-comment-reply.yml (specific commands)
# This is the FALLBACK for any @{{BOT_NAME}} mention that isn't a known command
on:
issue_comment:
types: [created]
# CUSTOMIZE YOUR BOT NAME:
# Change '@{{BOT_NAME}}' in all conditions below to match your config.yml mention_prefix
# Examples: '@bartender', '@uni', '@joey', '@codebot'
jobs:
ai-chat:
# Only run if comment mentions the bot but NOT a specific command
# This prevents duplicate runs with ai-comment-reply.yml and ai-issue-triage.yml
# CRITICAL: Ignore bot's own comments to prevent infinite loops (bot username: {{BOT_USERNAME}})
if: |
{{PLATFORM}}.event.comment.user.login != '{{BOT_USERNAME}}' &&
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}}') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} triage') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} help') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} explain') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} suggest') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} security') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} summarize') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} changelog') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} explain-diff') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} review-again') &&
!contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} setup-labels')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: {{OPENRABBIT_REPO}}
path: .ai-review
token: ${{ secrets.AI_REVIEW_TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install requests pyyaml
- name: Run AI Chat
env:
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
AI_REVIEW_REPO: ${{ {{PLATFORM}}.repository }}
AI_REVIEW_API_URL: {{API_URL}}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
SEARXNG_URL: ${{ secrets.SEARXNG_URL }}
run: |
cd .ai-review/tools/ai-review
python main.py comment ${{ {{PLATFORM}}.repository }} ${{ {{PLATFORM}}.event.issue.number }} "${{ {{PLATFORM}}.event.comment.body }}"

View File

@@ -0,0 +1,58 @@
name: AI Codebase Quality Review
on:
# Weekly scheduled run
schedule:
- cron: "0 0 * * 0" # Every Sunday at midnight
# Manual trigger
workflow_dispatch:
inputs:
report_type:
description: "Type of report to generate"
required: false
default: "full"
type: choice
options:
- full
- security
- quick
jobs:
ai-codebase-review:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for analysis
# Checkout central AI tooling
- uses: actions/checkout@v4
with:
repository: {{OPENRABBIT_REPO}}
path: .ai-review
token: ${{ secrets.AI_REVIEW_TOKEN }}
# Setup Python
- uses: actions/setup-python@v5
with:
python-version: "3.11"
# Install dependencies
- run: pip install requests pyyaml
# Run AI codebase analysis
- name: Run AI Codebase Analysis
env:
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
AI_REVIEW_REPO: ${{ {{PLATFORM}}.repository }}
AI_REVIEW_API_URL: {{API_URL}}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
run: |
cd .ai-review/tools/ai-review
python main.py codebase ${{ {{PLATFORM}}.repository }}

View File

@@ -0,0 +1,98 @@
name: AI Comment Reply
# WORKFLOW ROUTING:
# This workflow handles SPECIFIC commands: help, explain, suggest, security, summarize, changelog, explain-diff, review-again, setup-labels
# Other workflows: ai-issue-triage.yml (@{{BOT_NAME}} triage), ai-chat.yml (free-form questions)
on:
issue_comment:
types: [created]
# CUSTOMIZE YOUR BOT NAME:
# Change '@{{BOT_NAME}}' in the 'if' condition below to match your config.yml mention_prefix
# Examples: '@bartender', '@uni', '@joey', '@codebot'
jobs:
ai-reply:
runs-on: ubuntu-latest
# Only run for specific commands (not free-form chat or triage)
# This prevents duplicate runs with ai-chat.yml and ai-issue-triage.yml
# CRITICAL: Ignore bot's own comments to prevent infinite loops (bot username: {{BOT_USERNAME}})
if: |
{{PLATFORM}}.event.comment.user.login != '{{BOT_USERNAME}}' &&
(contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} help') ||
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} explain') ||
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} suggest') ||
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} security') ||
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} summarize') ||
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} changelog') ||
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} explain-diff') ||
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} review-again') ||
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} setup-labels'))
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: {{OPENRABBIT_REPO}}
path: .ai-review
token: ${{ secrets.AI_REVIEW_TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install requests pyyaml
- name: Run AI Comment Response
env:
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
AI_REVIEW_API_URL: {{API_URL}}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
run: |
cd .ai-review/tools/ai-review
# Determine if this is a PR or issue comment
IS_PR="${{ {{PLATFORM}}.event.issue.pull_request != null }}"
REPO="${{ {{PLATFORM}}.repository }}"
ISSUE_NUMBER="${{ {{PLATFORM}}.event.issue.number }}"
# Validate inputs
if [ -z "$REPO" ] || [ -z "$ISSUE_NUMBER" ]; then
echo "Error: Missing required parameters"
exit 1
fi
# Validate repository format (owner/repo)
if ! echo "$REPO" | grep -qE '^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$'; then
echo "Error: Invalid repository format: $REPO"
exit 1
fi
if [ "$IS_PR" = "true" ]; then
# This is a PR comment - use safe dispatch with minimal event data
# Build minimal event payload (does not include sensitive user data)
EVENT_DATA=$(cat <<EOF
{
"action": "created",
"issue": {
"number": ${{ {{PLATFORM}}.event.issue.number }},
"pull_request": {}
},
"comment": {
"id": ${{ {{PLATFORM}}.event.comment.id }},
"body": $(echo '${{ {{PLATFORM}}.event.comment.body }}' | jq -Rs .)
}
}
EOF
)
# Use safe dispatch utility
python utils/safe_dispatch.py issue_comment "$REPO" "$EVENT_DATA"
else
# This is an issue comment - use the comment command
COMMENT_BODY='${{ {{PLATFORM}}.event.comment.body }}'
python main.py comment "$REPO" "$ISSUE_NUMBER" "$COMMENT_BODY"
fi

View File

@@ -0,0 +1,44 @@
name: AI Issue Triage
# WORKFLOW ROUTING:
# This workflow handles ONLY the 'triage' command
# Other workflows: ai-comment-reply.yml (specific commands), ai-chat.yml (free-form questions)
on:
issue_comment:
types: [created]
jobs:
ai-triage:
runs-on: ubuntu-latest
# Only run if comment contains @{{BOT_NAME}} triage
# CRITICAL: Ignore bot's own comments to prevent infinite loops (bot username: {{BOT_USERNAME}})
if: |
{{PLATFORM}}.event.comment.user.login != '{{BOT_USERNAME}}' &&
contains({{PLATFORM}}.event.comment.body, '@{{BOT_NAME}} triage')
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: {{OPENRABBIT_REPO}}
path: .ai-review
token: ${{ secrets.AI_REVIEW_TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install requests pyyaml
- name: Run AI Issue Triage
env:
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
AI_REVIEW_REPO: ${{ {{PLATFORM}}.repository }}
AI_REVIEW_API_URL: {{API_URL}}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
run: |
cd .ai-review/tools/ai-review
python main.py issue ${{ {{PLATFORM}}.repository }} ${{ {{PLATFORM}}.event.issue.number }}

View File

@@ -0,0 +1,53 @@
name: Enterprise AI Code Review
on:
pull_request:
types: [opened, synchronize]
jobs:
ai-review:
runs-on: ubuntu-latest
steps:
# Checkout the PR repository
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Checkout the CENTRAL AI tooling repo
- uses: actions/checkout@v4
with:
repository: {{OPENRABBIT_REPO}}
path: .ai-review
token: ${{ secrets.AI_REVIEW_TOKEN }}
# Setup Python
- uses: actions/setup-python@v5
with:
python-version: "3.11"
# Install dependencies
- run: pip install requests pyyaml
# Run the AI review
- name: Run Enterprise AI Review
env:
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
AI_REVIEW_REPO: ${{ {{PLATFORM}}.repository }}
AI_REVIEW_API_URL: {{API_URL}}
AI_REVIEW_PR_NUMBER: ${{ {{PLATFORM}}.event.pull_request.number }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
run: |
cd .ai-review/tools/ai-review
python main.py pr ${{ {{PLATFORM}}.repository }} ${{ {{PLATFORM}}.event.pull_request.number }} \
--title "${{ {{PLATFORM}}.event.pull_request.title }}"
# Fail CI on HIGH severity (optional)
- name: Check Review Result
if: failure()
run: |
echo "AI Review found HIGH severity issues. Please address them before merging."
exit 1