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: Resolve AI code reviewer workflow issues and restore Claude Code review

LearningCircuit387aed7b2dd4
diff --git a/.github/workflows/ai-code-reviewer.yml b/.github/workflows/ai-code-reviewer.yml
index 363905d9c5..a792f52476 100644
--- a/.github/workflows/ai-code-reviewer.yml
+++ b/.github/workflows/ai-code-reviewer.yml
@@ -12,19 +12,26 @@ jobs:
permissions:
contents: read
pull-requests: write
- issues: read
+ issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y jq
+
- name: Get PR diff
run: |
git fetch origin main
git diff origin/main...HEAD --no-color > diff.txt
- name: AI Code Review
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Run the AI reviewer and capture the comment
COMMENT=$(cat diff.txt | bash github/scripts/ai-reviewer.sh "${{ secrets.OPENROUTER_API_KEY }}")
@@ -35,4 +42,4 @@ jobs:
- name: Cleanup
if: always()
run: |
- rm -f diff.txt
\ No newline at end of file
+ rm -f diff.txt
diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml
new file mode 100644
index 0000000000..9b0fe8248a
--- /dev/null
+++ b/.github/workflows/claude-code-review.yml
@@ -0,0 +1,71 @@
+name: Claude Code Review
+
+on:
+ pull_request:
+ types: [opened, labeled]
+ # Optional: Only run on specific file changes
+ # paths:
+ # - "src/**/*.ts"
+ # - "src/**/*.tsx"
+ # - "src/**/*.js"
+ # - "src/**/*.jsx"
+
+jobs:
+ claude-review:
+ # Only run when:
+ # - PR is opened (initial review)
+ # - 'claude-review' label is added
+ if: |
+ github.event.action == 'opened' ||
+ (github.event.action == 'labeled' && contains(github.event.label.name, 'claude-review'))
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: read
+ issues: read
+ id-token: write
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v5
+ with:
+ fetch-depth: 1
+
+ - name: Run Claude Code Review
+ id: claude-review
+ uses: anthropics/claude-code-action@beta
+ with:
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
+
+ # Use Claude Opus 4.1 for more thorough reviews
+ #model: "claude-opus-4-1-20250805"
+
+ # Direct prompt for automated review (no @claude mention needed)
+ direct_prompt: |
+ Please review this pull request and provide feedback on:
+ - Code quality and best practices
+ - Potential bugs or issues
+ - Performance considerations
+ - Security concerns
+ - Test coverage
+ Be constructive and helpful in your feedback.
+
+ # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
+ # use_sticky_comment: true
+ # Optional: Customize review based on file types
+ # direct_prompt: |
+ # Review this PR focusing on:
+ # - For TypeScript files: Type safety and proper interface usage
+ # - For API endpoints: Security, input validation, and error handling
+ # - For React components: Performance, accessibility, and best practices
+ # - For tests: Coverage, edge cases, and test quality
+ # Optional: Different prompts for different authors
+ # direct_prompt: |
+ # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
+ # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
+ # 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
+ # Optional: Add specific tools for running tests or linting
+ # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"
+ # Optional: Skip review for certain conditions
+ # if: |
+ # !contains(github.event.pull_request.title, '[skip-review]') &&
+ # !contains(github.event.pull_request.title, '[WIP]')
diff --git a/github/scripts/ai-reviewer.sh b/github/scripts/ai-reviewer.sh
index 70c02d5c2e..bc7479758c 100755
--- a/github/scripts/ai-reviewer.sh
+++ b/github/scripts/ai-reviewer.sh
@@ -24,24 +24,37 @@ if [ -z "$DIFF_CONTENT" ]; then
exit 1
fi
-# 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 with a clear, human-readable comment in markdown format."
- },
- {
- "role": "user",
- "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,
- "max_tokens": 2000
-}
-EOF
+# Create the JSON request with proper escaping using jq
+USER_PROMPT="Please analyze this code diff and provide a comprehensive review in markdown format:
+
+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
+
+Code diff to analyze:
+
+$DIFF_CONTENT"
+
+jq -n \
+ --arg system_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." \
+ --arg user_content "$USER_PROMPT" \
+ '{
+ "model": "z-ai/glm-4.6",
+ "messages": [
+ {
+ "role": "system",
+ "content": $system_content
+ },
+ {
+ "role": "user",
+ "content": $user_content
+ }
+ ],
+ "temperature": 0.1,
+ "max_tokens": 2000
+ }' > request.json
# Make API call to OpenRouter
RESPONSE=$(curl -s -X POST "https://openrouter.ai/api/v1/chat/completions" \
@@ -77,4 +90,4 @@ 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
+*This review was generated by AI and should be verified by a human reviewer.*"