~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
major refactor: Simplify workflow to avoid all shell syntax issues
LearningCircuitdf0d54ab1f26
diff --git a/.github/workflows/ai-code-reviewer.yml b/.github/workflows/ai-code-reviewer.ymlindex c11788f7be..9e9d9cf397 100644--- a/.github/workflows/ai-code-reviewer.yml+++ b/.github/workflows/ai-code-reviewer.yml@@ -5,15 +5,12 @@ on:types: [labeled]jobs:- # First check: Security (most critical)security-check:name: 🔒 Security Reviewruns-on: ubuntu-latestif: github.event.action == 'labeled' && github.event.label.name == 'ai_code_review'outputs:status: ${{ steps.review.outputs.status }}- issues: ${{ steps.review.outputs.issues }}- warnings: ${{ steps.review.outputs.warnings }}permissions:contents: readpull-requests: write@@ -36,104 +33,49 @@ jobs:- name: Security Review via APIid: reviewrun: |- # Create JSON payload for API request- JSON_PAYLOAD=$(cat << EOF- {- "model": "z-ai/glm-4.6",- "messages": [- {- "role": "system",- "content": "You are a helpful security expert reviewing pull requests. Respond ONLY with valid JSON. Be constructive and educational in your feedback."- },- {- "role": "user",- "content": "Analyze this 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 that needs attention\"- }- ],- \"warnings\": [- {- \"type\": \"security\",- \"message\": \"Security opportunity for improvement\"- }- ],- \"suggestions\": [- {- \"type\": \"security\",- \"message\": \"Helpful security recommendation\"- }- ]- }-- Status logic:- - \"fail\" = Critical security issues that must be addressed for safety- - \"warning\" = Security opportunities that would strengthen the code- - \"pass\" = Great security practices observed!-- Code diff to review:- ${{ steps.diff.outputs.diff }}"- }- ],- "temperature": 0.1,- "max_tokens": 2000- }- EOF- )-- # Make API call to OpenRouter- RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \+ # Build the request+ 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 "$JSON_PAYLOAD")-- echo "API Response: $RESPONSE"-- # Extract the content from response- CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "error"')-- if [ "$CONTENT" = "error" ]; then- echo "Error: No content in API response"+ -d '{+ "model": "z-ai/glm-4.6",+ "messages": [+ {+ "role": "system",+ "content": "You are a helpful security expert reviewing pull requests. Respond ONLY with valid JSON containing status, issues, warnings, and suggestions arrays."+ },+ {+ "role": "user",+ "content": "Analyze this code diff for security vulnerabilities: ${{ steps.diff.outputs.diff }}\n\nRespond with JSON: {\"status\":\"pass|fail|warning\",\"critical_issues\":[],\"warnings\":[],\"suggestions\":[]}"+ }+ ],+ "temperature": 0.1,+ "max_tokens": 2000+ }' > response.json++ # Parse response+ if [ ! -s response.json ]; thenecho "status=fail" >> $GITHUB_OUTPUT- echo "issues=[{\"type\": \"security\", \"message\": \"API call failed - check OPENROUTER_API_KEY secret\"}]" >> $GITHUB_OUTPUT- echo "warnings=[]" >> $GITHUB_OUTPUT+ echo "No API response - check OPENROUTER_API_KEY secret"exit 1fi- # Parse the JSON response- STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')- ISSUES=$(echo "$CONTENT" | jq -r '.critical_issues // []')- WARNINGS=$(echo "$CONTENT" | jq -r '.warnings // []')+ CONTENT=$(cat response.json | jq -r '.choices[0].message.content // "error"')+ echo "AI Response: $CONTENT"+ STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')echo "status=$STATUS" >> $GITHUB_OUTPUT- echo "issues=$ISSUES" >> $GITHUB_OUTPUT- echo "warnings=$WARNINGS" >> $GITHUB_OUTPUT- echo "Security review status: $STATUS"- echo "Critical issues: $(echo "$ISSUES" | jq length)"- echo "Warnings: $(echo "$WARNINGS" | jq length)"+ # Create comment+ if [ "$STATUS" = "fail" ]; then+ echo "🔒 Security issues found - please review"+ elif [ "$STATUS" = "warning" ]; then+ echo "💡 Security opportunities identified"+ else+ echo "🎉 No security issues found!"+ fi- name: Post Security Review Commentif: always()@@ -141,35 +83,20 @@ jobs: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 += '🔒 **Security Check** - Found some important security items to address:\n\n';- issues.forEach(issue => {- comment += `**${issue.type.toUpperCase()}**: ${issue.message}`;- if (issue.file) comment += ` (${issue.file}:${issue.line || '?'})`;- comment += '\n\n';- });+ 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';} else if (status === 'warning') {- comment += '💡 **Security Opportunities** - Great start! Here are some ways to make it even more secure:\n\n';- warnings.forEach(warning => {- comment += `• ${warning.message}\n`;- });+ 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';} else {comment += '🎉 **Excellent Security Practices** - No security concerns 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 and should be verified by a human reviewer.*';+ 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,@@ -180,11 +107,8 @@ jobs:- name: Fail if Security Issues Foundif: steps.review.outputs.status == 'fail'- run: |- echo "🔒 Security items need attention - please address these important security points"- exit 1+ run: exit 1- # Second check: Performance (only runs if security passes)performance-check:name: ⚡ Performance Reviewruns-on: ubuntu-latest@@ -192,8 +116,6 @@ jobs: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: readpull-requests: write@@ -216,95 +138,30 @@ jobs:- name: Performance Review via APIid: reviewrun: |- # Create JSON payload for API request- JSON_PAYLOAD=$(cat << EOF- {- "model": "z-ai/glm-4.6",- "messages": [- {- "role": "system",- "content": "You are a helpful performance expert reviewing pull requests. Respond ONLY with valid JSON. Be encouraging and provide actionable suggestions."- },- {- "role": "user",- "content": "Analyze this code diff for performance opportunities 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\" = Performance opportunities that need attention for optimal system health- - \"warning\" = Performance improvements that would enhance user experience- - \"pass\" = Excellent performance practices!-- Code diff to review:- ${{ steps.diff.outputs.diff }}"- }- ],- "temperature": 0.1,- "max_tokens": 2000- }- EOF- )-- RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \+ 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 "$JSON_PAYLOAD")-- CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "error"')-- if [ "$CONTENT" = "error" ]; then- echo "Error: No content in API response"- echo "status=fail" >> $GITHUB_OUTPUT- echo "issues=[{\"type\": \"performance\", \"message\": \"API call failed\"}]" >> $GITHUB_OUTPUT- echo "warnings=[]" >> $GITHUB_OUTPUT- exit 1- fi-+ -d '{+ "model": "z-ai/glm-4.6",+ "messages": [+ {+ "role": "system",+ "content": "You are a helpful performance expert reviewing pull requests. Respond ONLY with valid JSON containing status, issues, warnings, and suggestions arrays."+ },+ {+ "role": "user",+ "content": "Analyze this code diff for performance issues: ${{ steps.diff.outputs.diff }}\n\nRespond with JSON: {\"status\":\"pass|fail|warning\",\"critical_issues\":[],\"warnings\":[],\"suggestions\":[]}"+ }+ ],+ "temperature": 0.1,+ "max_tokens": 2000+ }' > response.json++ CONTENT=$(cat response.json | jq -r '.choices[0].message.content // "error"')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 Commentif: always()@@ -312,28 +169,18 @@ jobs: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 += '⚡ **Performance Check** - Found opportunities to boost performance:\n\n';- issues.forEach(issue => {- comment += `**${issue.type.toUpperCase()}**: ${issue.message}`;- if (issue.file) comment += ` (${issue.file}:${issue.line || '?'})`;- comment += '\n\n';- });+ comment += '⚡ **Performance Check** - Performance issues found that need attention.\n\n';} else if (status === 'warning') {- comment += '🚀 **Performance Opportunities** - Good performance! Here are ways to make it even better:\n\n';- warnings.forEach(warning => {- comment += `• ${warning.message}\n`;- });+ comment += '🚀 **Performance Opportunities** - Good performance! Here are ways to optimize further.\n\n';} else {comment += '🌟 **Excellent Performance** - Great optimization practices!\n\n';}- comment += '\n---\n*This review was generated by AI and should be verified by a human reviewer.*';+ 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,@@ -344,11 +191,8 @@ jobs:- name: Fail if Performance Issues Foundif: steps.review.outputs.status == 'fail'- run: |- echo "⚡ Performance opportunities found - please address these optimization points"- exit 1+ run: exit 1- # Third check: Code Quality (only runs if performance passes)code-quality-check:name: 🎨 Code Quality Reviewruns-on: ubuntu-latest@@ -356,8 +200,6 @@ jobs: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: readpull-requests: write@@ -380,95 +222,30 @@ jobs:- name: Code Quality Review via APIid: reviewrun: |- # Create JSON payload for API request- JSON_PAYLOAD=$(cat << EOF- {- "model": "z-ai/glm-4.6",- "messages": [- {- "role": "system",- "content": "You are a helpful code quality expert reviewing pull requests. Respond ONLY with valid JSON. Be constructive and encouraging in your feedback."- },- {- "role": "user",- "content": "Analyze this 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- - \"warning\" = Quality issues that should be improved- - \"pass\" = No significant quality issues found-- Code diff to review:- ${{ steps.diff.outputs.diff }}"- }- ],- "temperature": 0.1,- "max_tokens": 2000- }- EOF- )-- RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \+ 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 "$JSON_PAYLOAD")-- CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "error"')-- if [ "$CONTENT" = "error" ]; then- echo "Error: No content in API response"- echo "status=fail" >> $GITHUB_OUTPUT- echo "issues=[{\"type\": \"quality\", \"message\": \"API call failed\"}]" >> $GITHUB_OUTPUT- echo "warnings=[]" >> $GITHUB_OUTPUT- exit 1- fi-+ -d '{+ "model": "z-ai/glm-4.6",+ "messages": [+ {+ "role": "system",+ "content": "You are a helpful code quality expert reviewing pull requests. Respond ONLY with valid JSON containing status, issues, warnings, and suggestions arrays."+ },+ {+ "role": "user",+ "content": "Analyze this code diff for quality issues: ${{ steps.diff.outputs.diff }}\n\nRespond with JSON: {\"status\":\"pass|fail|warning\",\"critical_issues\":[],\"warnings\":[],\"suggestions\":[]}"+ }+ ],+ "temperature": 0.1,+ "max_tokens": 2000+ }' > response.json++ CONTENT=$(cat response.json | jq -r '.choices[0].message.content // "error"')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 Commentif: always()@@ -476,28 +253,18 @@ jobs: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 += '🎨 **Quality Check** - Found opportunities to improve code quality:\n\n';- issues.forEach(issue => {- comment += `**${issue.type.toUpperCase()}**: ${issue.message}`;- if (issue.file) comment += ` (${issue.file}:${issue.line || '?'})`;- comment += '\n\n';- });+ 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 make it even better:\n\n';- warnings.forEach(warning => {- comment += `• ${warning.message}\n`;- });+ 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---\n*This review was generated by AI and should be verified by a human reviewer.*';+ 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,@@ -508,11 +275,8 @@ jobs:- name: Fail if Quality Issues Foundif: steps.review.outputs.status == 'fail'- run: |- echo "🎨 Code quality opportunities found - please address these quality points"- exit 1+ run: exit 1- # Fourth check: Custom Requirements (only runs if all above pass)custom-checks:name: 🔧 Custom Requirements Reviewruns-on: ubuntu-latest@@ -540,95 +304,30 @@ jobs:- name: Custom Requirements Review via APIid: reviewrun: |- # Create JSON payload for API request- JSON_PAYLOAD=$(cat << EOF- {- "model": "z-ai/glm-4.6",- "messages": [- {- "role": "system",- "content": "You are reviewing pull requests for custom team requirements. Respond ONLY with valid JSON. Be helpful and constructive in your feedback."- },- {- "role": "user",- "content": "Analyze this code diff for custom team requirements 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 }}"- }- ],- "temperature": 0.1,- "max_tokens": 2000- }- EOF- )-- RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \+ 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 "$JSON_PAYLOAD")-- CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "error"')-- if [ "$CONTENT" = "error" ]; then- echo "Error: No content in API response"- echo "status=fail" >> $GITHUB_OUTPUT- echo "issues=[{\"type\": \"custom\", \"message\": \"API call failed\"}]" >> $GITHUB_OUTPUT- echo "warnings=[]" >> $GITHUB_OUTPUT- exit 1- fi-+ -d '{+ "model": "z-ai/glm-4.6",+ "messages": [+ {+ "role": "system",+ "content": "You are reviewing pull requests for custom team requirements. Respond ONLY with valid JSON containing status, issues, warnings, and suggestions arrays."+ },+ {+ "role": "user",+ "content": "Analyze this code diff for team requirements: ${{ steps.diff.outputs.diff }}\n\nRespond with JSON: {\"status\":\"pass|fail|warning\",\"critical_issues\":[],\"warnings\":[],\"suggestions\":[]}"+ }+ ],+ "temperature": 0.1,+ "max_tokens": 2000+ }' > response.json++ CONTENT=$(cat response.json | jq -r '.choices[0].message.content // "error"')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 Commentif: always()@@ -636,28 +335,18 @@ jobs: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 += '🔧 **Requirements Check** - Found items that need attention:\n\n';- issues.forEach(issue => {- comment += `**${issue.type.toUpperCase()}**: ${issue.message}`;- if (issue.file) comment += ` (${issue.file}:${issue.line || '?'})`;- comment += '\n\n';- });+ comment += '🔧 **Requirements Check** - Team requirement issues found that need attention.\n\n';} else if (status === 'warning') {- comment += '💡 **Requirements Opportunities** - Good adherence! Here are some improvements:\n\n';- warnings.forEach(warning => {- comment += `• ${warning.message}\n`;- });+ comment += '💡 **Requirements Opportunities** - Good adherence! Here are improvements.\n\n';} else {- comment += '🌟 **Excellent Requirements Adherence** - All custom requirements met!\n\n';+ comment += '🌟 **Excellent Requirements Adherence** - All team requirements met!\n\n';}- comment += '\n---\n*This review was generated by AI and should be verified by a human reviewer.*';+ 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,@@ -668,11 +357,8 @@ jobs:- name: Fail if Custom Requirements Issues Foundif: steps.review.outputs.status == 'fail'- run: |- echo "🔧 Custom requirements need attention - please address these requirement points"- exit 1+ run: exit 1- # Summary job - runs only if all checks passreview-summary:name: 📋 Review Summaryruns-on: ubuntu-latest