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: Simplify workflow to avoid shell syntax issues completely

LearningCircuitef55b82f8e9e
diff --git a/.github/workflows/ai-code-reviewer.yml b/.github/workflows/ai-code-reviewer.yml
index 27ff8978b4..c11788f7be 100644
--- a/.github/workflows/ai-code-reviewer.yml
+++ b/.github/workflows/ai-code-reviewer.yml
@@ -27,7 +27,6 @@ jobs:
- 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
@@ -37,9 +36,18 @@ jobs:
- name: Security Review via API
id: review
run: |
- # Create a temporary file for the prompt
- cat > prompt.txt << 'EOF'
- You are a helpful security expert reviewing a pull request. Analyze the following code diff for security opportunities and respond with JSON. Be constructive and educational in your feedback.
+ # 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
@@ -55,42 +63,43 @@ jobs:
Respond with ONLY this JSON format:
{
- "status": "pass|fail|warning",
- "critical_issues": [
+ \"status\": \"pass|fail|warning\",
+ \"critical_issues\": [
{
- "type": "security",
- "file": "path/to/file.py",
- "line": 42,
- "message": "Specific security issue that needs attention"
+ \"type\": \"security\",
+ \"file\": \"path/to/file.py\",
+ \"line\": 42,
+ \"message\": \"Specific security issue that needs attention\"
}
],
- "warnings": [
+ \"warnings\": [
{
- "type": "security",
- "message": "Security opportunity for improvement"
+ \"type\": \"security\",
+ \"message\": \"Security opportunity for improvement\"
}
],
- "suggestions": [
+ \"suggestions\": [
{
- "type": "security",
- "message": "Helpful security recommendation"
+ \"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!
+ - \"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
-
- # Append the diff to the prompt
- cat "${{ steps.diff.outputs.diff }}" >> prompt.txt
-
- # Read the prompt into a variable
- PROMPT=$(cat prompt.txt)
+ )
# Make API call to OpenRouter
RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \
@@ -98,15 +107,20 @@ jobs:
-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
- }")
+ -d "$JSON_PAYLOAD")
+
+ echo "API Response: $RESPONSE"
# Extract the content from response
- CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')
+ 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\": \"security\", \"message\": \"API call failed - check OPENROUTER_API_KEY secret\"}]" >> $GITHUB_OUTPUT
+ echo "warnings=[]" >> $GITHUB_OUTPUT
+ exit 1
+ fi
# Parse the JSON response
STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')
@@ -117,7 +131,6 @@ jobs:
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)"
@@ -156,7 +169,7 @@ jobs:
});
}
- comment += '\n---\n*This review was generated by AI (GLM-4.6) and should be verified by a human reviewer.*';
+ comment += '\n---\n*This review was generated by AI and should be verified by a human reviewer.*';
github.rest.issues.createComment({
issue_number: context.issue.number,
@@ -203,9 +216,18 @@ jobs:
- name: Performance Review via API
id: review
run: |
- # Create a temporary file for the prompt
- cat > prompt.txt << 'EOF'
- You are a helpful performance expert reviewing a pull request. Analyze the code diff for performance opportunities and respond with JSON. Be encouraging and provide actionable optimization suggestions.
+ # 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
@@ -221,56 +243,61 @@ jobs:
Respond with ONLY this JSON format:
{
- "status": "pass|fail|warning",
- "critical_issues": [
+ \"status\": \"pass|fail|warning\",
+ \"critical_issues\": [
{
- "type": "performance",
- "file": "path/to/file.py",
- "line": 42,
- "message": "Specific performance issue description"
+ \"type\": \"performance\",
+ \"file\": \"path/to/file.py\",
+ \"line\": 42,
+ \"message\": \"Specific performance issue description\"
}
],
- "warnings": [
+ \"warnings\": [
{
- "type": "performance",
- "message": "Performance concern that should be addressed"
+ \"type\": \"performance\",
+ \"message\": \"Performance concern that should be addressed\"
}
],
- "suggestions": [
+ \"suggestions\": [
{
- "type": "performance",
- "message": "Recommendation for improving performance"
+ \"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!
+ - \"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
-
- # Append the diff to the prompt
- cat "${{ steps.diff.outputs.diff }}" >> prompt.txt
-
- # Read the prompt into a variable
- PROMPT=$(cat prompt.txt)
+ )
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')
+ -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
+
STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')
ISSUES=$(echo "$CONTENT" | jq -r '.critical_issues // []')
WARNINGS=$(echo "$CONTENT" | jq -r '.warnings // []')
@@ -306,7 +333,7 @@ jobs:
comment += '🌟 **Excellent Performance** - Great optimization practices!\n\n';
}
- comment += '\n---\n*This review was generated by AI (GLM-4.6) and should be verified by a human reviewer.*';
+ comment += '\n---\n*This review was generated by AI and should be verified by a human reviewer.*';
github.rest.issues.createComment({
issue_number: context.issue.number,
@@ -353,9 +380,18 @@ jobs:
- name: Code Quality Review via API
id: review
run: |
- # Create a temporary file for the prompt
- cat > prompt.txt << 'EOF'
- You are a helpful code quality expert reviewing a pull request. Analyze the code diff for quality issues and respond with JSON. Be constructive and encouraging in your feedback.
+ # 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
@@ -371,56 +407,61 @@ jobs:
Respond with ONLY this JSON format:
{
- "status": "pass|fail|warning",
- "critical_issues": [
+ \"status\": \"pass|fail|warning\",
+ \"critical_issues\": [
{
- "type": "quality",
- "file": "path/to/file.py",
- "line": 42,
- "message": "Specific quality issue description"
+ \"type\": \"quality\",
+ \"file\": \"path/to/file.py\",
+ \"line\": 42,
+ \"message\": \"Specific quality issue description\"
}
],
- "warnings": [
+ \"warnings\": [
{
- "type": "quality",
- "message": "Quality concern that should be addressed"
+ \"type\": \"quality\",
+ \"message\": \"Quality concern that should be addressed\"
}
],
- "suggestions": [
+ \"suggestions\": [
{
- "type": "quality",
- "message": "Recommendation for improving code quality"
+ \"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
+ - \"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
-
- # Append the diff to the prompt
- cat "${{ steps.diff.outputs.diff }}" >> prompt.txt
-
- # Read the prompt into a variable
- PROMPT=$(cat prompt.txt)
+ )
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')
+ -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
+
STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')
ISSUES=$(echo "$CONTENT" | jq -r '.critical_issues // []')
WARNINGS=$(echo "$CONTENT" | jq -r '.warnings // []')
@@ -456,7 +497,7 @@ jobs:
comment += '🌟 **Excellent Code Quality** - Great coding practices!\n\n';
}
- comment += '\n---\n*This review was generated by AI (GLM-4.6) and should be verified by a human reviewer.*';
+ comment += '\n---\n*This review was generated by AI and should be verified by a human reviewer.*';
github.rest.issues.createComment({
issue_number: context.issue.number,
@@ -499,9 +540,18 @@ jobs:
- name: Custom Requirements Review via API
id: review
run: |
- # Create a temporary file for the prompt
- cat > prompt.txt << 'EOF'
- You are reviewing a pull request for custom team requirements. Analyze the code diff and respond with JSON. Be helpful and constructive in your feedback.
+ # 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
@@ -517,56 +567,61 @@ jobs:
Respond with ONLY this JSON format:
{
- "status": "pass|fail|warning",
- "critical_issues": [
+ \"status\": \"pass|fail|warning\",
+ \"critical_issues\": [
{
- "type": "custom",
- "file": "path/to/file.py",
- "line": 42,
- "message": "Specific custom requirement issue description"
+ \"type\": \"custom\",
+ \"file\": \"path/to/file.py\",
+ \"line\": 42,
+ \"message\": \"Specific custom requirement issue description\"
}
],
- "warnings": [
+ \"warnings\": [
{
- "type": "custom",
- "message": "Custom requirement concern that should be addressed"
+ \"type\": \"custom\",
+ \"message\": \"Custom requirement concern that should be addressed\"
}
],
- "suggestions": [
+ \"suggestions\": [
{
- "type": "custom",
- "message": "Recommendation for meeting custom requirements"
+ \"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
+ - \"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
-
- # Append the diff to the prompt
- cat "${{ steps.diff.outputs.diff }}" >> prompt.txt
-
- # Read the prompt into a variable
- PROMPT=$(cat prompt.txt)
+ )
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')
+ -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
+
STATUS=$(echo "$CONTENT" | jq -r '.status // "fail"')
ISSUES=$(echo "$CONTENT" | jq -r '.critical_issues // []')
WARNINGS=$(echo "$CONTENT" | jq -r '.warnings // []')
@@ -602,7 +657,7 @@ jobs:
comment += '🌟 **Excellent Requirements Adherence** - 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.*';
+ comment += '\n---\n*This review was generated by AI and should be verified by a human reviewer.*';
github.rest.issues.createComment({
issue_number: context.issue.number,
@@ -639,7 +694,7 @@ jobs:
✅ **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)*`;
+ *Reviews completed by AI via OpenRouter*`;
github.rest.issues.createComment({
issue_number: context.issue.number,