Skip to content

Commit 5adc4ef

Browse files
authored
ci: add agent reviewers (#64)
* feat: add claude settings turning off commit attribution * ci: add ChatGPT reviewer * ci: add Claude reviewer * ci: add Kimi reviewer * ci: improve PR review workflows for ethlambda - Extract shared review prompt to .github/prompts/pr_review.md - Update all workflows to use consensus-layer terminology instead of execution-layer - Add @chatgpt trigger to ChatGPT workflow (issue_comment + conditional) - Add @Kimi trigger to Kimi workflow (issue_comment + pull_request_review_comment + conditional) - Pin ChatGPT action to specific commit (6fdbaeafc6f9e0eaebb844f8cfafff67cb2947f0) - Replace ethrex references with ethlambda across all workflows - Update Ethereum-specific considerations to focus on: * Fork choice (LMD GHOST / 3SF-mini) correctness * Attestation processing and validation * Justification and finalization logic * State transition functions (process_slots, process_block) * XMSS signature verification and aggregation * SSZ encoding/decoding correctness * ci: fix chatgpt code review action parameters The actual action doesn't receive parameters normally, it fetches everything from its env * ci: bump checkout version and remove fetch-depth 0 * ci: bump claude-code-action to v1 * docs: add CLAUDE.md * ci: use official codex action * ci: pre-fetch base and head refs * chore: remove chatgpt workflow * ci: use claude-code for kimi code review * Revert "ci: use claude-code for kimi code review" This reverts commit 448ecf8. * Revert "chore: remove chatgpt workflow" This reverts commit 2c9a41f. * Revert "ci: pre-fetch base and head refs" This reverts commit ba4dd5a. * Revert "ci: use official codex action" This reverts commit 34c5f2f. * ci: put Kimi review in collapsible section * ci: limit ChatGPT review pr diff to 100k chars
1 parent 866ade1 commit 5adc4ef

File tree

8 files changed

+428
-3
lines changed

8 files changed

+428
-3
lines changed

.claude/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"attribution": {
3+
"commit": "",
4+
"pr": ""
5+
}
6+
}

.github/prompts/pr_review.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
You are a senior code reviewer for ethlambda, a minimalist Lean Ethereum consensus client written in Rust.
2+
3+
Review this PR focusing on:
4+
- Code correctness and potential bugs
5+
- Security vulnerabilities (critical for blockchain code)
6+
- Performance implications
7+
- Rust best practices and idiomatic patterns
8+
- Memory safety and proper error handling
9+
- Code readability and maintainability
10+
11+
Consensus-layer considerations:
12+
- Fork choice (LMD GHOST / 3SF-mini) correctness
13+
- Attestation processing and validation
14+
- Justification and finalization logic
15+
- State transition functions (process_slots, process_block)
16+
- XMSS signature verification and aggregation
17+
- SSZ encoding/decoding correctness
18+
19+
Be concise and specific. Provide line references when suggesting changes.
20+
If the code looks good, acknowledge it briefly.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Lint
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v6
2525

2626
- name: Setup Rust
2727
uses: dtolnay/rust-toolchain@master
@@ -45,7 +45,7 @@ jobs:
4545
name: Test
4646
runs-on: ubuntu-latest
4747
steps:
48-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v6
4949

5050
- name: Download test fixtures
5151
env:

.github/workflows/docker_publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v4
33+
uses: actions/checkout@v6
3434

3535
- name: Set up Docker Buildx
3636
uses: docker/setup-buildx-action@v3
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: PR Review - ChatGPT
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
pull_request_review_comment:
7+
types: [created]
8+
issue_comment:
9+
types: [created]
10+
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
chatgpt-review:
21+
name: ChatGPT Code Review
22+
if: |
23+
github.event_name == 'pull_request' ||
24+
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@chatgpt')) ||
25+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@chatgpt'))
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v6
30+
31+
- name: Read review prompt
32+
id: prompt
33+
run: |
34+
PROMPT=$(cat .github/prompts/pr_review.md)
35+
echo "content<<EOF" >> $GITHUB_OUTPUT
36+
echo "$PROMPT" >> $GITHUB_OUTPUT
37+
echo "EOF" >> $GITHUB_OUTPUT
38+
39+
- name: ChatGPT Code Review
40+
uses: anc95/ChatGPT-CodeReview@6fdbaeafc6f9e0eaebb844f8cfafff67cb2947f0
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
44+
MODEL: gpt-4o
45+
LANGUAGE: English
46+
MAX_PATCH_LENGTH: 100000
47+
max_tokens: 4096
48+
PROMPT: ${{ steps.prompt.outputs.content }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: PR Review - Claude
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
pull_request_review_comment:
7+
types: [created]
8+
issue_comment:
9+
types: [created]
10+
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
issues: write
15+
id-token: write
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
claude-review:
23+
name: Claude Code Review
24+
if: |
25+
github.event_name == 'pull_request' ||
26+
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@claude')) ||
27+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude'))
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v6
32+
33+
- name: Read review prompt
34+
id: prompt
35+
run: |
36+
PROMPT=$(cat .github/prompts/pr_review.md)
37+
echo "content<<EOF" >> $GITHUB_OUTPUT
38+
echo "$PROMPT" >> $GITHUB_OUTPUT
39+
echo "EOF" >> $GITHUB_OUTPUT
40+
41+
- name: Claude Code Review
42+
uses: anthropics/claude-code-action@v1
43+
with:
44+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
45+
claude_args: |
46+
--max-turns 5
47+
--model claude-sonnet-4-20250514
48+
trigger_phrase: "@claude"
49+
prompt: ${{ steps.prompt.outputs.content }}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: PR Review - Kimi
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
pull_request_review_comment:
7+
types: [created]
8+
issue_comment:
9+
types: [created]
10+
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
kimi-review:
21+
name: Kimi Code Review
22+
if: |
23+
github.event_name == 'pull_request' ||
24+
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@kimi')) ||
25+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@kimi'))
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v6
30+
31+
- name: Read review prompt
32+
id: prompt
33+
run: |
34+
PROMPT=$(cat .github/prompts/pr_review.md)
35+
echo "content<<EOF" >> $GITHUB_OUTPUT
36+
echo "$PROMPT" >> $GITHUB_OUTPUT
37+
echo "EOF" >> $GITHUB_OUTPUT
38+
39+
- name: Get PR diff
40+
id: diff
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
gh pr diff ${{ github.event.pull_request.number }} > pr_diff.txt
45+
# Truncate if too large (Kimi has context limits)
46+
head -c 100000 pr_diff.txt > pr_diff_truncated.txt
47+
48+
- name: Kimi Code Review
49+
id: kimi_review
50+
env:
51+
KIMI_API_KEY: ${{ secrets.KIMI_API_KEY }}
52+
PR_TITLE: ${{ github.event.pull_request.title }}
53+
REVIEW_PROMPT: ${{ steps.prompt.outputs.content }}
54+
run: |
55+
if [ -z "$KIMI_API_KEY" ]; then
56+
echo "Error: KIMI_API_KEY secret is not set" > kimi_review.txt
57+
exit 0
58+
fi
59+
60+
DIFF_CONTENT=$(cat pr_diff_truncated.txt)
61+
62+
# Build the request body
63+
REQUEST_BODY=$(jq -n \
64+
--arg diff "$DIFF_CONTENT" \
65+
--arg title "$PR_TITLE" \
66+
--arg prompt "$REVIEW_PROMPT" \
67+
'{
68+
"model": "moonshot-v1-128k",
69+
"messages": [
70+
{
71+
"role": "system",
72+
"content": $prompt
73+
},
74+
{
75+
"role": "user",
76+
"content": ("PR Title: " + $title + "\n\nDiff:\n" + $diff)
77+
}
78+
],
79+
"temperature": 0.3,
80+
"max_tokens": 4096
81+
}')
82+
83+
# Try the API call
84+
HTTP_RESPONSE=$(curl -s -w "\n%{http_code}" https://api.moonshot.ai/v1/chat/completions \
85+
-H "Content-Type: application/json" \
86+
-H "Authorization: Bearer $KIMI_API_KEY" \
87+
-d "$REQUEST_BODY")
88+
89+
HTTP_CODE=$(echo "$HTTP_RESPONSE" | tail -n1)
90+
RESPONSE=$(echo "$HTTP_RESPONSE" | sed '$d')
91+
92+
if [ "$HTTP_CODE" != "200" ]; then
93+
echo "API Error (HTTP $HTTP_CODE): $RESPONSE" > kimi_review.txt
94+
else
95+
# Check for API errors in response
96+
ERROR=$(echo "$RESPONSE" | jq -r '.error.message // empty')
97+
if [ -n "$ERROR" ]; then
98+
echo "API Error: $ERROR" > kimi_review.txt
99+
else
100+
REVIEW=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "Error: Unexpected API response"')
101+
echo "$REVIEW" > kimi_review.txt
102+
fi
103+
fi
104+
105+
- name: Post review comment
106+
env:
107+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
run: |
109+
echo "<details><summary><h2>Kimi AI Code Review</h2></summary>" > body.md
110+
cat kimi_review.txt >> body.md
111+
echo -e "\n---\n*Automated review by Kimi (Moonshot AI)*\n</details>" >> body.md
112+
113+
gh pr comment ${{ github.event.pull_request.number }} --body-file body.md

0 commit comments

Comments
 (0)