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.

fix: Rewrite AI reviewer to use stdin for robust diff handling

LearningCircuit3098c714f9ed
diff --git a/.github/workflows/ai-code-reviewer.yml b/.github/workflows/ai-code-reviewer.yml
index 46441a61e1..f5492db398 100644
--- a/.github/workflows/ai-code-reviewer.yml
+++ b/.github/workflows/ai-code-reviewer.yml
@@ -22,19 +22,15 @@ jobs:
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
+ git diff origin/main...HEAD --no-color > diff.txt
- name: Comprehensive AI Review
id: review
run: |
# Use the AI reviewer script for comprehensive review
- RESPONSE=$(bash github/scripts/ai-reviewer.sh "${{ steps.diff.outputs.diff }}" "${{ secrets.OPENROUTER_API_KEY }}")
+ RESPONSE=$(cat diff.txt | bash github/scripts/ai-reviewer.sh "${{ secrets.OPENROUTER_API_KEY }}")
echo "AI Response: $RESPONSE"
# Parse response
diff --git a/github/scripts/ai-reviewer.sh b/github/scripts/ai-reviewer.sh
index 34beafda71..c23af14e5e 100755
--- a/github/scripts/ai-reviewer.sh
+++ b/github/scripts/ai-reviewer.sh
@@ -1,20 +1,28 @@
#!/bin/bash
# AI Code Reviewer Script - Comprehensive Review
-# Usage: ./ai-reviewer.sh <DIFF_CONTENT> <API_KEY>
+# Usage: echo "DIFF_CONTENT" | ./ai-reviewer.sh <API_KEY>
set -e
-DIFF_CONTENT="$1"
-API_KEY="$2"
+API_KEY="$1"
-if [ -z "$DIFF_CONTENT" ] || [ -z "$API_KEY" ]; then
- echo '{"status":"fail","security_issues":[],"performance_issues":[],"quality_issues":[],"warnings":[{"type":"input","message":"Missing required parameters"}],"suggestions":[]}'
+if [ -z "$API_KEY" ]; then
+ echo '{"status":"fail","security_issues":[],"performance_issues":[],"quality_issues":[],"warnings":[{"type":"input","message":"Missing API key parameter"}],"suggestions":[]}'
exit 1
fi
-# Create a temporary file with the request - using printf to avoid heredoc issues
-printf '%s\n' '{
+# Read diff content from stdin
+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":[]}'
+ exit 1
+fi
+
+# Create the JSON request using a simpler approach
+cat > request.json << EOF
+{
"model": "z-ai/glm-4.6",
"messages": [
{
@@ -23,12 +31,13 @@ printf '%s\n' '{
},
{
"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 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"
}
],
"temperature": 0.1,
"max_tokens": 2000
-}' > request.json
+}
+EOF
# Make API call to OpenRouter
RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \