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.

simplify: AI reviewer now outputs direct markdown comments

LearningCircuit390f8fe9a7c3
diff --git a/.github/workflows/ai-code-reviewer.yml b/.github/workflows/ai-code-reviewer.yml
index f5492db398..363905d9c5 100644
--- a/.github/workflows/ai-code-reviewer.yml
+++ b/.github/workflows/ai-code-reviewer.yml
@@ -9,8 +9,6 @@ jobs:
name: 🤖 AI Code Review
runs-on: ubuntu-latest
if: github.event.action == 'labeled' && github.event.label.name == 'ai_code_review'
- outputs:
- status: ${{ steps.review.outputs.status }}
permissions:
contents: read
pull-requests: write
@@ -26,57 +24,15 @@ jobs:
git fetch origin main
git diff origin/main...HEAD --no-color > diff.txt
- - name: Comprehensive AI Review
- id: review
+ - name: AI Code Review
run: |
- # Use the AI reviewer script for comprehensive review
- RESPONSE=$(cat diff.txt | bash github/scripts/ai-reviewer.sh "${{ secrets.OPENROUTER_API_KEY }}")
- echo "AI Response: $RESPONSE"
+ # Run the AI reviewer and capture the comment
+ COMMENT=$(cat diff.txt | bash github/scripts/ai-reviewer.sh "${{ secrets.OPENROUTER_API_KEY }}")
- # Parse response
- STATUS=$(echo "$RESPONSE" | jq -r '.status // "fail"')
- echo "status=$STATUS" >> $GITHUB_OUTPUT
+ # Post the comment directly using GitHub CLI
+ echo "$COMMENT" | gh issue comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }}
- # Log result
- if [ "$STATUS" = "fail" ]; then
- echo "❌ Critical issues found - please review and fix"
- elif [ "$STATUS" = "warning" ]; then
- echo "⚠️ Important issues found - should be addressed"
- else
- echo "✅ No critical issues found!"
- fi
-
- - name: Post Comprehensive Review Comment
+ - name: Cleanup
if: always()
- uses: actions/github-script@v7
- with:
- script: |
- const status = '${{ steps.review.outputs.status }}';
-
- let comment = '## 🤖 AI Code Review\n\n';
-
- if (status === 'fail') {
- 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 += '⚠️ **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 += '✅ **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.*';
-
- github.rest.issues.createComment({
- issue_number: context.issue.number,
- owner: context.repo.owner,
- repo: context.repo.repo,
- body: comment
- });
-
- - name: Fail if Critical Issues Found
- if: steps.review.outputs.status == 'fail'
run: |
- echo "❌ Critical issues found - please address these before merging"
- exit 1
\ No newline at end of file
+ rm -f diff.txt
\ No newline at end of file
diff --git a/github/scripts/ai-reviewer.sh b/github/scripts/ai-reviewer.sh
index c23af14e5e..70c02d5c2e 100755
--- a/github/scripts/ai-reviewer.sh
+++ b/github/scripts/ai-reviewer.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# AI Code Reviewer Script - Comprehensive Review
+# AI Code Reviewer Script - Simple Comment Version
# Usage: echo "DIFF_CONTENT" | ./ai-reviewer.sh <API_KEY>
set -e
@@ -8,7 +8,9 @@ set -e
API_KEY="$1"
if [ -z "$API_KEY" ]; then
- echo '{"status":"fail","security_issues":[],"performance_issues":[],"quality_issues":[],"warnings":[{"type":"input","message":"Missing API key parameter"}],"suggestions":[]}'
+ echo "## 🤖 AI Code Review
+
+❌ **Error**: Missing API key parameter"
exit 1
fi
@@ -16,22 +18,24 @@ fi
DIFF_CONTENT=$(cat)
if [ -z "$DIFF_CONTENT" ]; then
- echo '{"status":"fail","security_issues":[],"performance_issues":[],"quality_issues":[],"warnings":[{"type":"input","message":"Missing diff content from stdin"}],"suggestions":[]}'
+ echo "## 🤖 AI Code Review
+
+❌ **Error**: No diff content to analyze"
exit 1
fi
-# Create the JSON request using a simpler approach
+# Create the JSON request
cat > request.json << EOF
{
"model": "z-ai/glm-4.6",
"messages": [
{
"role": "system",
- "content": "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."
+ "content": "You are a helpful code reviewer analyzing pull requests. Provide a comprehensive review covering security, performance, code quality, and best practices. Respond with a clear, human-readable comment in markdown format."
},
{
"role": "user",
- "content": "Please analyze this code diff comprehensively and respond with JSON:\n\nReview Focus Areas:\n- Security: Look for hardcoded secrets, SQL injection, XSS, authentication issues, input validation problems\n- Performance: Check for inefficient algorithms, N+1 queries, missing indexes, memory issues, blocking operations\n- Code Quality: Evaluate readability, maintainability, proper error handling, naming conventions, documentation\n- Best Practices: Ensure adherence to coding standards, proper patterns, type safety, dead code removal\n\nRespond with this JSON format:\n{\n \"status\": \"pass|fail|warning\",\n \"security_issues\": [\n {\"type\": \"security\", \"file\": \"path\", \"line\": 42, \"message\": \"Security issue description\"}\n ],\n \"performance_issues\": [\n {\"type\": \"performance\", \"file\": \"path\", \"line\": 42, \"message\": \"Performance issue description\"}\n ],\n \"quality_issues\": [\n {\"type\": \"quality\", \"file\": \"path\", \"line\": 42, \"message\": \"Quality issue description\"}\n ],\n \"warnings\": [\n {\"type\": \"general\", \"message\": \"General suggestion for improvement\"}\n ],\n \"suggestions\": [\n {\"type\": \"enhancement\", \"message\": \"Positive recommendation\"}\n ]\n}\n\nStatus logic:\n- \"fail\" = Critical security or performance issues that must be addressed\n- \"warning\" = Important issues that should be addressed but do not block merge\n- \"pass\" = No critical issues found (only suggestions and minor improvements)\n\nCode diff to analyze:\n$DIFF_CONTENT"
+ "content": "Please analyze this code diff and provide a comprehensive review in markdown format:\n\nFocus Areas:\n- Security: Look for hardcoded secrets, SQL injection, XSS, authentication issues, input validation problems\n- Performance: Check for inefficient algorithms, N+1 queries, missing indexes, memory issues, blocking operations\n- Code Quality: Evaluate readability, maintainability, proper error handling, naming conventions, documentation\n- Best Practices: Ensure adherence to coding standards, proper patterns, type safety, dead code removal\n\nCode diff to analyze:\n\n$DIFF_CONTENT"
}
],
"temperature": 0.1,
@@ -51,23 +55,26 @@ rm -f request.json
# Check if API call was successful
if [ -z "$RESPONSE" ]; then
- echo '{"status":"fail","security_issues":[],"performance_issues":[],"quality_issues":[],"warnings":[{"type":"api","message":"API call failed - no response"}],"suggestions":[]}'
+ echo "## 🤖 AI Code Review
+
+❌ **Error**: API call failed - no response received"
exit 1
fi
-# Extract and validate the content
+# Extract the content
CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "error"')
if [ "$CONTENT" = "error" ]; then
- echo '{"status":"fail","security_issues":[],"performance_issues":[],"quality_issues":[],"warnings":[{"type":"api","message":"Invalid API response format"}],"suggestions":[]}'
+ echo "## 🤖 AI Code Review
+
+❌ **Error**: Invalid API response format"
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
- 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"
-fi
\ No newline at end of file
+# Output the review directly as a comment
+echo "## 🤖 AI Code Review
+
+$CONTENT
+
+---
+*This review was generated by AI and should be verified by a human reviewer.*"
\ No newline at end of file