~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat: Replace code review with AI PR gatekeeper system
LearningCircuitd25b44eb4c14
diff --git a/.github/workflows/ai-pr-gatekeeper.yml b/.github/workflows/ai-pr-gatekeeper.ymlnew file mode 100644index 0000000000..64cdd8bcdf--- /dev/null+++ b/.github/workflows/ai-pr-gatekeeper.yml@@ -0,0 +1,618 @@+name: AI PR Gatekeeper++on:+ pull_request:+ types: [labeled]++jobs:+ # First check: Security (most critical)+ security-check:+ name: 🔒 Security Review+ runs-on: ubuntu-latest+ if: contains(github.event.label.name, 'ai_code_review') && github.event.action == 'added'+ outputs:+ status: ${{ steps.review.outputs.status }}+ issues: ${{ steps.review.outputs.issues }}+ warnings: ${{ steps.review.outputs.warnings }}+ permissions:+ contents: read+ pull-requests: write+ issues: read+ steps:+ - name: Checkout repository+ uses: actions/checkout@v5+ with:+ fetch-depth: 0++ - name: Get PR diff+ id: diff+ run: |+ # Get the diff for this PR+ git fetch origin main+ DIFF=$(git diff origin/main...HEAD --no-color)+ echo "diff<<EOF" >> $GITHUB_OUTPUT+ echo "$DIFF" >> $GITHUB_OUTPUT+ echo "EOF" >> $GITHUB_OUTPUT++ - name: Security Review via API+ id: review+ run: |+ # Prepare the security-focused prompt+ PROMPT='You are a security expert reviewing a pull request. Analyze the following code diff for security vulnerabilities and respond with JSON:++ Focus on:+ - Hardcoded secrets, passwords, API keys, tokens+ - SQL injection vulnerabilities+ - Cross-site scripting (XSS) risks+ - Authentication and authorization issues+ - Input validation problems+ - Insecure direct object references+ - Path traversal vulnerabilities+ - Insecure dependencies+ - Sensitive data exposure+ - Cryptographic issues++ Respond with ONLY this JSON format:+ {+ "status": "pass|fail|warning",+ "critical_issues": [+ {+ "type": "security",+ "file": "path/to/file.py",+ "line": 42,+ "message": "Specific security issue description"+ }+ ],+ "warnings": [+ {+ "type": "security",+ "message": "Security concern that should be addressed"+ }+ ],+ "suggestions": [+ {+ "type": "security",+ "message": "Recommendation for improving security"+ }+ ]+ }++ Status logic:+ - "fail" = Any critical security issues found+ - "warning" = Only security warnings, no critical issues+ - "pass" = No security issues found++ Code diff to review:+ ${{ steps.diff.outputs.diff }}'++ # Make API call to OpenRouter+ RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \+ -H "Content-Type: application/json" \+ -H "Authorization: Bearer ${{ secrets.OPENROUTER_API_KEY }}" \+ -H "HTTP-Referer: https://github.com/${{ github.repository }}" \+ -H "X-Title: AI Security Review" \+ -d "{+ \"model\": \"z-ai/glm-4.6\",+ \"messages\": [{\"role\": \"user\", \"content\": \"$PROMPT\"}],+ \"temperature\": 0.1,+ \"max_tokens\": 2000+ }")++ # Extract the content from response+ CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')++ # Parse the JSON response+ STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')+ ISSUES=$(echo "$CONTENT" | jq -r '.critical_issues // []')+ WARNINGS=$(echo "$CONTENT" | jq -r '.warnings // []')++ echo "status=$STATUS" >> $GITHUB_OUTPUT+ echo "issues=$ISSUES" >> $GITHUB_OUTPUT+ echo "warnings=$WARNINGS" >> $GITHUB_OUTPUT++ # Log results+ echo "Security review status: $STATUS"+ echo "Critical issues: $(echo "$ISSUES" | jq length)"+ echo "Warnings: $(echo "$WARNINGS" | jq length)"++ - name: Post Security Review Comment+ if: always()+ uses: actions/github-script@v7+ with:+ script: |+ const status = '${{ steps.review.outputs.status }}';+ const issues = JSON.parse('${{ steps.review.outputs.issues }}' || '[]');+ const warnings = JSON.parse('${{ steps.review.outputs.warnings }}' || '[]');++ let comment = '## 🔒 Security Review\n\n';++ if (status === 'fail') {+ comment += '❌ **FAILED** - Critical security issues found that must be addressed:\n\n';+ issues.forEach(issue => {+ comment += `**${issue.type.toUpperCase()}**: ${issue.message}`;+ if (issue.file) comment += ` (${issue.file}:${issue.line || '?'})`;+ comment += '\n\n';+ });+ } else if (status === 'warning') {+ comment += '⚠️ **WARNING** - Security concerns found:\n\n';+ warnings.forEach(warning => {+ comment += `• ${warning.message}\n`;+ });+ } else {+ comment += '✅ **PASSED** - No critical security issues found\n\n';+ }++ if (warnings.length > 0) {+ comment += '\n**Security Recommendations:**\n';+ warnings.forEach(warning => {+ comment += `• ${warning.message}\n`;+ });+ }++ comment += '\n---\n*This review was generated by AI (GLM-4.6) and should be verified by a human reviewer.*';++ github.rest.issues.createComment({+ issue_number: context.issue.number,+ owner: context.repo.owner,+ repo: context.repo.repo,+ body: comment+ });++ - name: Fail if Security Issues Found+ if: steps.review.outputs.status == 'fail'+ run: |+ echo "❌ Security check failed - PR cannot proceed"+ exit 1++ # Second check: Performance (only runs if security passes)+ performance-check:+ name: ⚡ Performance Review+ runs-on: ubuntu-latest+ needs: security-check+ if: needs.security-check.outputs.status == 'success'+ outputs:+ status: ${{ steps.review.outputs.status }}+ issues: ${{ steps.review.outputs.issues }}+ warnings: ${{ steps.review.outputs.warnings }}+ permissions:+ contents: read+ pull-requests: write+ issues: read+ steps:+ - name: Checkout repository+ uses: actions/checkout@v5+ with:+ fetch-depth: 0++ - name: Get PR diff+ id: diff+ run: |+ git fetch origin main+ DIFF=$(git diff origin/main...HEAD --no-color)+ echo "diff<<EOF" >> $GITHUB_OUTPUT+ echo "$DIFF" >> $GITHUB_OUTPUT+ echo "EOF" >> $GITHUB_OUTPUT++ - name: Performance Review via API+ id: review+ run: |+ PROMPT='You are a performance expert reviewing a pull request. Analyze the code diff for performance issues and respond with JSON:++ Focus on:+ - Inefficient algorithms or data structures+ - N+1 query problems+ - Missing database indexes+ - Large memory allocations+ - Blocking I/O operations+ - Unnecessary computations in loops+ - Cache issues+ - Slow database queries+ - Network request optimization+ - Resource cleanup++ Respond with ONLY this JSON format:+ {+ "status": "pass|fail|warning",+ "critical_issues": [+ {+ "type": "performance",+ "file": "path/to/file.py",+ "line": 42,+ "message": "Specific performance issue description"+ }+ ],+ "warnings": [+ {+ "type": "performance",+ "message": "Performance concern that should be addressed"+ }+ ],+ "suggestions": [+ {+ "type": "performance",+ "message": "Recommendation for improving performance"+ }+ ]+ }++ Status logic:+ - "fail" = Critical performance issues that will significantly impact system performance+ - "warning" = Performance concerns that should be optimized but are not critical+ - "pass" = No performance issues found++ Code diff to review:+ ${{ steps.diff.outputs.diff }}'++ RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \+ -H "Content-Type: application/json" \+ -H "Authorization: Bearer ${{ secrets.OPENROUTER_API_KEY }}" \+ -H "HTTP-Referer: https://github.com/${{ github.repository }}" \+ -H "X-Title: AI Performance Review" \+ -d "{+ \"model\": \"z-ai/glm-4.6\",+ \"messages\": [{\"role\": \"user\", \"content\": \"$PROMPT\"}],+ \"temperature\": 0.1,+ \"max_tokens\": 2000+ }")++ CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')+ STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')+ ISSUES=$(echo "$CONTENT" | jq -r '.critical_issues // []')+ WARNINGS=$(echo "$CONTENT" | jq -r '.warnings // []')++ echo "status=$STATUS" >> $GITHUB_OUTPUT+ echo "issues=$ISSUES" >> $GITHUB_OUTPUT+ echo "warnings=$WARNINGS" >> $GITHUB_OUTPUT++ - name: Post Performance Review Comment+ if: always()+ uses: actions/github-script@v7+ with:+ script: |+ const status = '${{ steps.review.outputs.status }}';+ const issues = JSON.parse('${{ steps.review.outputs.issues }}' || '[]');+ const warnings = JSON.parse('${{ steps.review.outputs.warnings }}' || '[]');++ let comment = '## ⚡ Performance Review\n\n';++ if (status === 'fail') {+ comment += '❌ **FAILED** - Critical performance issues found:\n\n';+ issues.forEach(issue => {+ comment += `**${issue.type.toUpperCase()}**: ${issue.message}`;+ if (issue.file) comment += ` (${issue.file}:${issue.line || '?'})`;+ comment += '\n\n';+ });+ } else if (status === 'warning') {+ comment += '⚠️ **WARNING** - Performance concerns found:\n\n';+ warnings.forEach(warning => {+ comment += `• ${warning.message}\n`;+ });+ } else {+ comment += '✅ **PASSED** - No performance issues found\n\n';+ }++ comment += '\n---\n*This review was generated by AI (GLM-4.6) and should be verified by a human reviewer.*';++ github.rest.issues.createComment({+ issue_number: context.issue.number,+ owner: context.repo.owner,+ repo: context.repo.repo,+ body: comment+ });++ - name: Fail if Performance Issues Found+ if: steps.review.outputs.status == 'fail'+ run: |+ echo "❌ Performance check failed - PR cannot proceed"+ exit 1++ # Third check: Code Quality (only runs if performance passes)+ code-quality-check:+ name: 🎨 Code Quality Review+ runs-on: ubuntu-latest+ needs: performance-check+ if: needs.performance-check.outputs.status == 'success'+ outputs:+ status: ${{ steps.review.outputs.status }}+ issues: ${{ steps.review.outputs.issues }}+ warnings: ${{ steps.review.outputs.warnings }}+ permissions:+ contents: read+ pull-requests: write+ issues: read+ steps:+ - name: Checkout repository+ uses: actions/checkout@v5+ with:+ fetch-depth: 0++ - name: Get PR diff+ id: diff+ run: |+ git fetch origin main+ DIFF=$(git diff origin/main...HEAD --no-color)+ echo "diff<<EOF" >> $GITHUB_OUTPUT+ echo "$DIFF" >> $GITHUB_OUTPUT+ echo "EOF" >> $GITHUB_OUTPUT++ - name: Code Quality Review via API+ id: review+ run: |+ PROMPT='You are a code quality expert reviewing a pull request. Analyze the code diff for quality issues and respond with JSON:++ Focus on:+ - Code readability and maintainability+ - Proper error handling+ - Code duplication+ - Naming conventions+ - Documentation and comments+ - Function and class design+ - Code organization and structure+ - Best practices and patterns+ - Type safety+ - Dead code or unused variables++ Respond with ONLY this JSON format:+ {+ "status": "pass|fail|warning",+ "critical_issues": [+ {+ "type": "quality",+ "file": "path/to/file.py",+ "line": 42,+ "message": "Specific quality issue description"+ }+ ],+ "warnings": [+ {+ "type": "quality",+ "message": "Quality concern that should be addressed"+ }+ ],+ "suggestions": [+ {+ "type": "quality",+ "message": "Recommendation for improving code quality"+ }+ ]+ }++ Status logic:+ - "fail" = Critical quality issues that impact maintainability (use fail sparingly)+ - "warning" = Quality issues that should be improved+ - "pass" = No significant quality issues found++ Code diff to review:+ ${{ steps.diff.outputs.diff }}'++ RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \+ -H "Content-Type: application/json" \+ -H "Authorization: Bearer ${{ secrets.OPENROUTER_API_KEY }}" \+ -H "HTTP-Referer: https://github.com/${{ github.repository }}" \+ -H "X-Title: AI Code Quality Review" \+ -d "{+ \"model\": \"z-ai/glm-4.6\",+ \"messages\": [{\"role\": \"user\", \"content\": \"$PROMPT\"}],+ \"temperature\": 0.1,+ \"max_tokens\": 2000+ }")++ CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')+ STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')+ ISSUES=$(echo "$CONTENT" | jq -r '.critical_issues // []')+ WARNINGS=$(echo "$CONTENT" | jq -r '.warnings // []')++ echo "status=$STATUS" >> $GITHUB_OUTPUT+ echo "issues=$ISSUES" >> $GITHUB_OUTPUT+ echo "warnings=$WARNINGS" >> $GITHUB_OUTPUT++ - name: Post Code Quality Review Comment+ if: always()+ uses: actions/github-script@v7+ with:+ script: |+ const status = '${{ steps.review.outputs.status }}';+ const issues = JSON.parse('${{ steps.review.outputs.issues }}' || '[]');+ const warnings = JSON.parse('${{ steps.review.outputs.warnings }}' || '[]');++ let comment = '## 🎨 Code Quality Review\n\n';++ if (status === 'fail') {+ comment += '❌ **FAILED** - Critical code quality issues found:\n\n';+ issues.forEach(issue => {+ comment += `**${issue.type.toUpperCase()}**: ${issue.message}`;+ if (issue.file) comment += ` (${issue.file}:${issue.line || '?'})`;+ comment += '\n\n';+ });+ } else if (status === 'warning') {+ comment += '⚠️ **WARNING** - Code quality concerns found:\n\n';+ warnings.forEach(warning => {+ comment += `• ${warning.message}\n`;+ });+ } else {+ comment += '✅ **PASSED** - No significant quality issues found\n\n';+ }++ comment += '\n---\n*This review was generated by AI (GLM-4.6) and should be verified by a human reviewer.*';++ github.rest.issues.createComment({+ issue_number: context.issue.number,+ owner: context.repo.owner,+ repo: context.repo.repo,+ body: comment+ });++ - name: Fail if Quality Issues Found+ if: steps.review.outputs.status == 'fail'+ run: |+ echo "❌ Code quality check failed - PR cannot proceed"+ exit 1++ # Fourth check: Custom Requirements (only runs if all above pass)+ custom-checks:+ name: 🔧 Custom Requirements Review+ runs-on: ubuntu-latest+ needs: code-quality-check+ if: needs.code-quality-check.outputs.status == 'success'+ permissions:+ contents: read+ pull-requests: write+ issues: read+ steps:+ - name: Checkout repository+ uses: actions/checkout@v5+ with:+ fetch-depth: 0++ - name: Get PR diff+ id: diff+ run: |+ git fetch origin main+ DIFF=$(git diff origin/main...HEAD --no-color)+ echo "diff<<EOF" >> $GITHUB_OUTPUT+ echo "$DIFF" >> $GITHUB_OUTPUT+ echo "EOF" >> $GITHUB_OUTPUT++ - name: Custom Requirements Review via API+ id: review+ run: |+ PROMPT='You are reviewing a pull request for custom team requirements. Analyze the code diff and respond with JSON:++ Focus on:+ - Adherence to project coding standards+ - Database migration safety+ - API contract compatibility+ - Testing requirements+ - Documentation completeness+ - Configuration management+ - Logging and monitoring requirements+ - Dependency management+ - Build and deployment considerations+ - Any team-specific conventions found in the code++ Respond with ONLY this JSON format:+ {+ "status": "pass|fail|warning",+ "critical_issues": [+ {+ "type": "custom",+ "file": "path/to/file.py",+ "line": 42,+ "message": "Specific custom requirement issue description"+ }+ ],+ "warnings": [+ {+ "type": "custom",+ "message": "Custom requirement concern that should be addressed"+ }+ ],+ "suggestions": [+ {+ "type": "custom",+ "message": "Recommendation for meeting custom requirements"+ }+ ]+ }++ Status logic:+ - "fail" = Critical violations of team requirements+ - "warning" = Minor deviations from team standards+ - "pass" - All custom requirements met++ Code diff to review:+ ${{ steps.diff.outputs.diff }}'++ RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \+ -H "Content-Type: application/json" \+ -H "Authorization: Bearer ${{ secrets.OPENROUTER_API_KEY }}" \+ -H "HTTP-Referer: https://github.com/${{ github.repository }}" \+ -H "X-Title: AI Custom Requirements Review" \+ -d "{+ \"model\": \"z-ai/glm-4.6\",+ \"messages\": [{\"role\": \"user\", \"content\": \"$PROMPT\"}],+ \"temperature\": 0.1,+ \"max_tokens\": 2000+ }")++ CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')+ STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')+ ISSUES=$(echo "$CONTENT" | jq -r '.critical_issues // []')+ WARNINGS=$(echo "$CONTENT" | jq -r '.warnings // []')++ echo "status=$STATUS" >> $GITHUB_OUTPUT+ echo "issues=$ISSUES" >> $GITHUB_OUTPUT+ echo "warnings=$WARNINGS" >> $GITHUB_OUTPUT++ - name: Post Custom Requirements Review Comment+ if: always()+ uses: actions/github-script@v7+ with:+ script: |+ const status = '${{ steps.review.outputs.status }}';+ const issues = JSON.parse('${{ steps.review.outputs.issues }}' || '[]');+ const warnings = JSON.parse('${{ steps.review.outputs.warnings }}' || '[]');++ let comment = '## 🔧 Custom Requirements Review\n\n';++ if (status === 'fail') {+ comment += '❌ **FAILED** - Custom requirement issues found:\n\n';+ issues.forEach(issue => {+ comment += `**${issue.type.toUpperCase()}**: ${issue.message}`;+ if (issue.file) comment += ` (${issue.file}:${issue.line || '?'})`;+ comment += '\n\n';+ });+ } else if (status === 'warning') {+ comment += '⚠️ **WARNING** - Custom requirement concerns found:\n\n';+ warnings.forEach(warning => {+ comment += `• ${warning.message}\n`;+ });+ } else {+ comment += '✅ **PASSED** - All custom requirements met\n\n';+ }++ comment += '\n---\n*This review was generated by AI (GLM-4.6) and should be verified by a human reviewer.*';++ github.rest.issues.createComment({+ issue_number: context.issue.number,+ owner: context.repo.owner,+ repo: context.repo.repo,+ body: comment+ });++ - name: Fail if Custom Requirements Issues Found+ if: steps.review.outputs.status == 'fail'+ run: |+ echo "❌ Custom requirements check failed - PR cannot proceed"+ exit 1++ # Summary job - runs only if all checks pass+ review-summary:+ name: 📋 Review Summary+ runs-on: ubuntu-latest+ needs: [security-check, performance-check, code-quality-check, custom-checks]+ if: always() && needs.security-check.result == 'success' && needs.performance-check.result == 'success' && needs.code-quality-check.result == 'success' && needs.custom-checks.result == 'success'+ permissions:+ contents: read+ pull-requests: write+ issues: read+ steps:+ - name: Post Success Summary+ uses: actions/github-script@v7+ with:+ script: |+ const comment = `## 🎉 AI Review Complete - All Checks Passed!\n\n+ ✅ **Security Review** - Passed\n+ ✅ **Performance Review** - Passed\n+ ✅ **Code Quality Review** - Passed\n+ ✅ **Custom Requirements Review** - Passed\n\n+ This PR has passed all automated AI checks and is ready for human review.\n\n+ ---\n+ *Reviews completed by AI (GLM-4.6 via OpenRouter)*`;++ github.rest.issues.createComment({+ issue_number: context.issue.number,+ owner: context.repo.owner,+ repo: context.repo.repo,+ body: comment+ });\ No newline at end of filediff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.ymldeleted file mode 100644index 9b0fe8248a..0000000000--- a/.github/workflows/claude-code-review.yml+++ /dev/null@@ -1,71 +0,0 @@-name: Claude Code Review--on:- pull_request:- types: [opened, labeled]- # Optional: Only run on specific file changes- # paths:- # - "src/**/*.ts"- # - "src/**/*.tsx"- # - "src/**/*.js"- # - "src/**/*.jsx"--jobs:- claude-review:- # Only run when:- # - PR is opened (initial review)- # - 'claude-review' label is added- if: |- github.event.action == 'opened' ||- (github.event.action == 'labeled' && contains(github.event.label.name, 'claude-review'))- runs-on: ubuntu-latest- permissions:- contents: read- pull-requests: read- issues: read- id-token: write- steps:- - name: Checkout repository- uses: actions/checkout@v5- with:- fetch-depth: 1-- - name: Run Claude Code Review- id: claude-review- uses: anthropics/claude-code-action@beta- with:- claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}-- # Use Claude Opus 4.1 for more thorough reviews- #model: "claude-opus-4-1-20250805"-- # Direct prompt for automated review (no @claude mention needed)- direct_prompt: |- Please review this pull request and provide feedback on:- - Code quality and best practices- - Potential bugs or issues- - Performance considerations- - Security concerns- - Test coverage- Be constructive and helpful in your feedback.-- # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR- # use_sticky_comment: true- # Optional: Customize review based on file types- # direct_prompt: |- # Review this PR focusing on:- # - For TypeScript files: Type safety and proper interface usage- # - For API endpoints: Security, input validation, and error handling- # - For React components: Performance, accessibility, and best practices- # - For tests: Coverage, edge cases, and test quality- # Optional: Different prompts for different authors- # direct_prompt: |- # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&- # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||- # 'Please provide a thorough code review focusing on our coding standards and best practices.' }}- # Optional: Add specific tools for running tests or linting- # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"- # Optional: Skip review for certain conditions- # if: |- # !contains(github.event.pull_request.title, '[skip-review]') &&- # !contains(github.event.pull_request.title, '[WIP]')diff --git a/docs/AI_PR_Gatekeeper_Setup.md b/docs/AI_PR_Gatekeeper_Setup.mdnew file mode 100644index 0000000000..87b5d0bf3b--- /dev/null+++ b/docs/AI_PR_Gatekeeper_Setup.md@@ -0,0 +1,146 @@+# AI PR Gatekeeper Setup Guide++This guide explains how to set up the automated AI PR review system that uses GLM-4.6 via OpenRouter to review pull requests.++## Overview++The AI PR Gatekeeper provides automated, chained code reviews with four check types:+1. **Security Review** 🔒 - Most critical, runs first+2. **Performance Review** ⚡ - Runs only if security passes+3. **Code Quality Review** 🎨 - Runs only if performance passes+4. **Custom Requirements Review** 🔧 - Runs only if all above pass++Each check can pass, warn, or fail. Failed checks prevent the PR from being merged.++## Setup Instructions++### 1. Get OpenRouter API Key++1. Go to [OpenRouter.ai](https://openrouter.ai/)+2. Sign up or log in+3. Navigate to API Keys section+4. Create a new API key+5. Copy the key (it starts with `sk-or-v1-...`)++### 2. Add API Key to GitHub Secrets++1. Go to your GitHub repository+2. Navigate to **Settings** → **Secrets and variables** → **Actions**+3. Click **New repository secret**+4. Name it: `OPENROUTER_API_KEY`+5. Paste your OpenRouter API key+6. Click **Add secret**++### 3. Configure Branch Protection (Recommended)++To make the AI checks mandatory for merging:++1. Go to **Settings** → **Branches** → **Branch protection rules**+2. Click **Add rule**+3. Under "Branch name pattern", enter `main`+4. Check **Require status checks to pass before merging**+5. Select the following required checks:+ - 🔒 Security Review+ - ⚡ Performance Review+ - 🎨 Code Quality Review+ - 🔧 Custom Requirements Review+6. Click **Create**++## Usage++### Triggering AI Reviews++To trigger an AI review on a PR:++1. Go to the PR page+2. Click **Labels**+3. Add the label: `ai_code_review`++The review will automatically start with the security check. If it passes, it will continue through the chain.++### Re-running Reviews++To re-run the AI reviews after making changes:++1. Remove the `ai_code_review` label+2. Add the `ai_code_review` label again++This will restart the entire review chain.++## Review Results++Each review type posts a separate comment with:+- ✅ **PASSED** - No issues found+- ⚠️ **WARNING** - Minor issues found (doesn't block merge)+- ❌ **FAILED** - Critical issues found (blocks merge)++If all checks pass, a final summary comment indicates the PR is ready for human review.++## Cost Estimation++Based on GLM-4.6 pricing ($0.50/M input tokens, $1.75/M output tokens):++- Security check: ~$0.002+- Performance check: ~$0.002+- Code quality check: ~$0.002+- Custom requirements check: ~$0.002+- **Total per PR: ~$0.008** (less than 1 cent)++Failed checks are cheaper since the chain stops early.++## Customization++### Changing the Model++To use a different model (e.g., GLM-4.5-Air for cost savings):++In `.github/workflows/ai-pr-gatekeeper.yml`, change:+```yaml+"model": "z-ai/glm-4.6"+```+to:+```yaml+"model": "z-ai/glm-4.5-air"+```++### Adding Custom Review Types++You can add new review types by copying one of the existing jobs and:+1. Updating the job name and description+2. Modifying the prompt to focus on your specific requirements+3. Adding it to the job dependency chain+4. Including it in the required status checks++## Troubleshooting++### Reviews Not Running++- Ensure the `ai_code_review` label is added (not just present)+- Check that `OPENROUTER_API_KEY` secret is correctly configured+- Verify GitHub Actions permissions are properly set++### API Errors++- Check OpenRouter API key validity+- Verify OpenRouter account has sufficient credits+- Review GitHub Actions logs for specific error messages++### Reviews Failing Unexpectedly++- Review the AI comments for specific issues+- Check if the model is being too strict+- Consider adjusting prompts to be more lenient if needed++## Security Considerations++- API keys are stored securely in GitHub Secrets+- Reviews only run on your repository's PRs, not forks+- All API calls are made through secure HTTPS connections+- No code or data is stored by the AI service after analysis++## Support++For issues with:+- **OpenRouter API**: Check [OpenRouter documentation](https://openrouter.ai/docs)+- **GitHub Actions**: Check [GitHub Actions documentation](https://docs.github.com/en/actions)+- **Workflow issues**: Review the GitHub Actions logs for specific error details\ No newline at end of file