Skip to content

Commit 24aca72

Browse files
nawi-25claude
andcommitted
fix: rename job to Claude, add env validation and diff size limit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d1adcf1 commit 24aca72

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎.github/workflows/ai-review.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
review:
9-
name: Gemini Code Review
9+
name: Claude Code Review
1010
runs-on: ubuntu-latest
1111
# Skip if the PR was opened by the bot itself
1212
if: github.actor != 'github-actions[bot]'

‎scripts/ai-review.mjs‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@ import { Octokit } from "@octokit/rest";
33

44
const prNumber = parseInt(process.env.PR_NUMBER);
55
const githubToken = process.env.GITHUB_TOKEN;
6-
const [repoOwner, repoName] = (process.env.GITHUB_REPOSITORY || "").split("/");
6+
const repo = process.env.GITHUB_REPOSITORY || "";
7+
const [repoOwner, repoName] = repo.split("/");
78

9+
if (!prNumber || !githubToken || !repoOwner || !repoName || !process.env.ANTHROPIC_API_KEY) {
10+
console.error("Missing required environment variables.");
11+
process.exit(1);
12+
}
13+
14+
const MAX_DIFF_CHARS = 20000;
815
const octokit = new Octokit({ auth: githubToken });
916

1017
async function runReview() {
@@ -22,6 +29,10 @@ async function runReview() {
2229
return;
2330
}
2431

32+
const truncatedDiff = prDiff.length > MAX_DIFF_CHARS
33+
? prDiff.slice(0, MAX_DIFF_CHARS) + "\n\n... [diff truncated]"
34+
: prDiff;
35+
2536
const prompt = `You are a senior Python engineer reviewing a pull request for the Node9 Python SDK.
2637
Node9 is an execution security library — a @protect decorator that intercepts AI agent tool calls and asks for human approval before running them.
2738
@@ -37,7 +48,7 @@ Do NOT rewrite the code. Just review it.
3748
Keep your review under 400 words.
3849
3950
## Git Diff:
40-
${prDiff}`;
51+
${truncatedDiff}`;
4152

4253
console.log("Sending diff to Claude for review...");
4354
const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });

0 commit comments

Comments
 (0)