Skip to content

~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.

major refactor: Simplify to single comprehensive AI review

LearningCircuitcc18d9d1b16e
diff --git a/.github/workflows/ai-code-reviewer.yml b/.github/workflows/ai-code-reviewer.yml
index b958ac4e0d..16e4386d9a 100644
--- a/.github/workflows/ai-code-reviewer.yml
+++ b/.github/workflows/ai-code-reviewer.yml
@@ -5,8 +5,8 @@ on:
types: [labeled]
jobs:
- security-check:
- name: 🔒 Security Review
+ comprehensive-review:
+ name: 🤖 AI Code Review
runs-on: ubuntu-latest
if: github.event.action == 'labeled' && github.event.label.name == 'ai_code_review'
outputs:
@@ -30,11 +30,11 @@ jobs:
echo "$DIFF" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- - name: Security Review via API
+ - name: Comprehensive AI Review
id: review
run: |
- # Use the AI reviewer script
- RESPONSE=$(./github/scripts/ai-reviewer.sh "security" "${{ steps.diff.outputs.diff }}" "${{ secrets.OPENROUTER_API_KEY }}")
+ # Use the AI reviewer script for comprehensive review
+ RESPONSE=$(./github/scripts/ai-reviewer.sh "${{ steps.diff.outputs.diff }}" "${{ secrets.OPENROUTER_API_KEY }}")
echo "AI Response: $RESPONSE"
# Parse response
@@ -43,30 +43,31 @@ jobs:
# Log result
if [ "$STATUS" = "fail" ]; then
- echo "🔒 Security issues found - please review"
+ echo "❌ Critical issues found - please review and fix"
elif [ "$STATUS" = "warning" ]; then
- echo "💡 Security opportunities identified"
+ echo "⚠️ Important issues found - should be addressed"
else
- echo "🎉 No security issues found!"
+ echo "✅ No critical issues found!"
fi
- - name: Post Security Review Comment
+ - name: Post Comprehensive Review Comment
if: always()
uses: actions/github-script@v7
with:
script: |
const status = '${{ steps.review.outputs.status }}';
- let comment = '## 🔒 Security Review\n\n';
+ let comment = '## 🤖 AI Code Review\n\n';
if (status === 'fail') {
- comment += '🔒 **Security Check** - Important security items found that need attention.\n\n';
- comment += 'Please review the AI response above for specific security concerns.\n\n';
+ comment += '❌ **Critical Issues Found** - This PR has important issues that must be addressed before merge:\n\n';
+ comment += 'Please review the detailed AI analysis below and fix the critical security, performance, or quality issues.\n\n';
} else if (status === 'warning') {
- comment += '💡 **Security Opportunities** - Good security practices! Here are ways to make it even stronger.\n\n';
- comment += 'Consider the security suggestions in the AI response above.\n\n';
+ comment += '⚠️ **Issues Found** - This PR has some issues that should be addressed:\n\n';
+ comment += 'Consider the suggestions and warnings in the AI analysis below for improvements.\n\n';
} else {
- comment += '🎉 **Excellent Security Practices** - No security concerns found!\n\n';
+ comment += '✅ **Great Work!** - No critical issues found\n\n';
+ comment += 'The code looks good! Check the AI analysis below for any minor suggestions.\n\n';
}
comment += '---\n*This review was generated by AI and should be verified by a human reviewer.*';
@@ -78,235 +79,8 @@ jobs:
body: comment
});
- - name: Fail if Security Issues Found
+ - name: Fail if Critical Issues Found
if: steps.review.outputs.status == 'fail'
- run: exit 1
-
- 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 }}
- 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: |
- # Use the AI reviewer script
- RESPONSE=$(./github/scripts/ai-reviewer.sh "performance" "${{ steps.diff.outputs.diff }}" "${{ secrets.OPENROUTER_API_KEY }}")
- echo "AI Response: $RESPONSE"
-
- # Parse response
- STATUS=$(echo "$RESPONSE" | jq -r '.status // "fail"')
- echo "status=$STATUS" >> $GITHUB_OUTPUT
-
- - name: Post Performance Review Comment
- if: always()
- uses: actions/github-script@v7
- with:
- script: |
- const status = '${{ steps.review.outputs.status }}';
-
- let comment = '## ⚡ Performance Review\n\n';
-
- if (status === 'fail') {
- comment += '⚡ **Performance Check** - Performance issues found that need attention.\n\n';
- } else if (status === 'warning') {
- comment += '🚀 **Performance Opportunities** - Good performance! Here are ways to optimize further.\n\n';
- } else {
- comment += '🌟 **Excellent Performance** - Great optimization practices!\n\n';
- }
-
- comment += '---\n*This review was generated by AI 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: exit 1
-
- 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 }}
- 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: |
- # Use the AI reviewer script
- RESPONSE=$(./github/scripts/ai-reviewer.sh "quality" "${{ steps.diff.outputs.diff }}" "${{ secrets.OPENROUTER_API_KEY }}")
- echo "AI Response: $RESPONSE"
-
- # Parse response
- STATUS=$(echo "$RESPONSE" | jq -r '.status // "fail"')
- echo "status=$STATUS" >> $GITHUB_OUTPUT
-
- - name: Post Code Quality Review Comment
- if: always()
- uses: actions/github-script@v7
- with:
- script: |
- const status = '${{ steps.review.outputs.status }}';
-
- let comment = '## 🎨 Code Quality Review\n\n';
-
- if (status === 'fail') {
- comment += '🎨 **Quality Check** - Code quality issues found that need attention.\n\n';
- } else if (status === 'warning') {
- comment += '💡 **Quality Opportunities** - Good code quality! Here are ways to improve further.\n\n';
- } else {
- comment += '🌟 **Excellent Code Quality** - Great coding practices!\n\n';
- }
-
- comment += '---\n*This review was generated by AI 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: exit 1
-
- 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: |
- # Use the AI reviewer script
- RESPONSE=$(./github/scripts/ai-reviewer.sh "custom" "${{ steps.diff.outputs.diff }}" "${{ secrets.OPENROUTER_API_KEY }}")
- echo "AI Response: $RESPONSE"
-
- # Parse response
- STATUS=$(echo "$RESPONSE" | jq -r '.status // "fail"')
- echo "status=$STATUS" >> $GITHUB_OUTPUT
-
- - name: Post Custom Requirements Review Comment
- if: always()
- uses: actions/github-script@v7
- with:
- script: |
- const status = '${{ steps.review.outputs.status }}';
-
- let comment = '## 🔧 Custom Requirements Review\n\n';
-
- if (status === 'fail') {
- comment += '🔧 **Requirements Check** - Team requirement issues found that need attention.\n\n';
- } else if (status === 'warning') {
- comment += '💡 **Requirements Opportunities** - Good adherence! Here are improvements.\n\n';
- } else {
- comment += '🌟 **Excellent Requirements Adherence** - All team requirements met!\n\n';
- }
-
- comment += '---\n*This review was generated by AI 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: exit 1
-
- 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 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 file
+ echo "❌ Critical issues found - please address these before merging"
+ exit 1
\ No newline at end of file
diff --git a/github/scripts/ai-reviewer.sh b/github/scripts/ai-reviewer.sh
index bead4a2ef6..08d3baf81e 100755
--- a/github/scripts/ai-reviewer.sh
+++ b/github/scripts/ai-reviewer.sh
@@ -1,53 +1,66 @@
#!/bin/bash
-# AI Code Reviewer Script
-# Usage: ./ai-reviewer.sh <REVIEW_TYPE> <DIFF_CONTENT> <API_KEY>
-# REVIEW_TYPE: security, performance, quality, custom
+# AI Code Reviewer Script - Comprehensive Review
+# Usage: ./ai-reviewer.sh <DIFF_CONTENT> <API_KEY>
# DIFF_CONTENT: The git diff content
# API_KEY: OpenRouter API key
set -e
-REVIEW_TYPE="$1"
-DIFF_CONTENT="$2"
-API_KEY="$3"
+DIFF_CONTENT="$1"
+API_KEY="$2"
-if [ -z "$REVIEW_TYPE" ] || [ -z "$DIFF_CONTENT" ] || [ -z "$API_KEY" ]; then
- echo "Usage: $0 <REVIEW_TYPE> <DIFF_CONTENT> <API_KEY>"
+if [ -z "$DIFF_CONTENT" ] || [ -z "$API_KEY" ]; then
+ echo "Usage: $0 <DIFF_CONTENT> <API_KEY>"
exit 1
fi
-# Set prompts based on review type
-case "$REVIEW_TYPE" in
- "security")
- SYSTEM_PROMPT="You are a helpful security expert reviewing pull requests. Respond ONLY with valid JSON containing status, issues, warnings, and suggestions arrays."
- USER_PROMPT="Analyze this code diff for security vulnerabilities and respond with JSON: {\"status\":\"pass|fail|warning\",\"critical_issues\":[],\"warnings\":[],\"suggestions\":[]}"
- ;;
- "performance")
- SYSTEM_PROMPT="You are a helpful performance expert reviewing pull requests. Respond ONLY with valid JSON containing status, issues, warnings, and suggestions arrays."
- USER_PROMPT="Analyze this code diff for performance issues and respond with JSON: {\"status\":\"pass|fail|warning\",\"critical_issues\":[],\"warnings\":[],\"suggestions\":[]}"
- ;;
- "quality")
- SYSTEM_PROMPT="You are a helpful code quality expert reviewing pull requests. Respond ONLY with valid JSON containing status, issues, warnings, and suggestions arrays."
- USER_PROMPT="Analyze this code diff for quality issues and respond with JSON: {\"status\":\"pass|fail|warning\",\"critical_issues\":[],\"warnings\":[],\"suggestions\":[]}"
- ;;
- "custom")
- SYSTEM_PROMPT="You are reviewing pull requests for custom team requirements. Respond ONLY with valid JSON containing status, issues, warnings, and suggestions arrays."
- USER_PROMPT="Analyze this code diff for team requirements and respond with JSON: {\"status\":\"pass|fail|warning\",\"critical_issues\":[],\"warnings\":[],\"suggestions\":[]}"
- ;;
- *)
- echo "Error: Unknown review type '$REVIEW_TYPE'. Use: security, performance, quality, or custom"
- exit 1
- ;;
-esac
-
-# Prepare the full user message with the diff
-FULL_USER_PROMPT="$USER_PROMPT\n\nCode diff to analyze:\n$DIFF_CONTENT"
+# Comprehensive review prompt covering all aspects
+SYSTEM_PROMPT="You are a helpful code reviewer analyzing pull requests. Provide a comprehensive review covering security, performance, code quality, and best practices. Respond ONLY with valid JSON containing status, issues, warnings, and suggestions arrays."
+
+USER_PROMPT="Please analyze this code diff comprehensively and respond with JSON:
+
+Review Focus Areas:
+- Security: Look for hardcoded secrets, SQL injection, XSS, authentication issues, input validation problems
+- Performance: Check for inefficient algorithms, N+1 queries, missing indexes, memory issues, blocking operations
+- Code Quality: Evaluate readability, maintainability, proper error handling, naming conventions, documentation
+- Best Practices: Ensure adherence to coding standards, proper patterns, type safety, dead code removal
+
+Respond with this JSON format:
+{
+ \"status\": \"pass|fail|warning\",
+ \"security_issues\": [
+ {\"type\": \"security\", \"file\": \"path\", \"line\": 42, \"message\": \"Security issue description\"}
+ ],
+ \"performance_issues\": [
+ {\"type\": \"performance\", \"file\": \"path\", \"line\": 42, \"message\": \"Performance issue description\"}
+ ],
+ \"quality_issues\": [
+ {\"type\": \"quality\", \"file\": \"path\", \"line\": 42, \"message\": \"Quality issue description\"}
+ ],
+ \"warnings\": [
+ {\"type\": \"general\", \"message\": \"General suggestion for improvement\"}
+ ],
+ \"suggestions\": [
+ {\"type\": \"enhancement\", \"message\": \"Positive recommendation\"}
+ ]
+}
+
+Status logic:
+- \"fail\" = Critical security or performance issues that must be addressed
+- \"warning\" = Important issues that should be addressed but don't block merge
+- \"pass\" = No critical issues found (only suggestions and minor improvements)
+
+Code diff to analyze:
+$DIFF_CONTENT"
+
+FULL_USER_PROMPT="$USER_PROMPT"
# 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 $API_KEY" \
+ -H "HTTP-Referer: https://github.com/LearningCircuit/local-deep-research" \
-d "{
\"model\": \"z-ai/glm-4.6\",
\"messages\": [
@@ -66,7 +79,7 @@ RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \
# Check if API call was successful
if [ -z "$RESPONSE" ]; then
- echo '{"status":"fail","critical_issues":[{"type":"api","message":"API call failed - no response"}],"warnings":[],"suggestions":[]}'
+ echo '{"status":"fail","security_issues":[],"performance_issues":[],"quality_issues":[],"warnings":[{"type":"api","message":"API call failed - no response"}],"suggestions":[]}'
exit 1
fi
@@ -74,15 +87,14 @@ fi
CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "error"')
if [ "$CONTENT" = "error" ]; then
- echo '{"status":"fail","critical_issues":[{"type":"api","message":"Invalid API response format"}],"warnings":[],"suggestions":[]}'
+ echo '{"status":"fail","security_issues":[],"performance_issues":[],"quality_issues":[],"warnings":[{"type":"api","message":"Invalid API response format"}],"suggestions":[]}'
exit 1
fi
# Validate that the response is valid JSON
if ! echo "$CONTENT" | jq . >/dev/null 2>&1; then
# If AI response is not valid JSON, create a fallback response
- STATUS=$(echo "$CONTENT" | grep -o '"status":"[^"]*"' | head -1 | cut -d'"' -f4 || echo "fail")
- echo "{\"status\":\"$STATUS\",\"critical_issues\":[{\"type\":\"parsing\",\"message\":\"AI response could not be parsed as JSON. Raw response: $CONTENT\"}],\"warnings\":[],\"suggestions\":[]}"
+ echo '{"status":"fail","security_issues":[],"performance_issues":[],"quality_issues":[],"warnings":[{"type":"parsing","message":"AI response could not be parsed as JSON"}],"suggestions":[]}'
else
# Return the valid JSON response
echo "$CONTENT"