Skip to content

Commit 6fb961f

Browse files
authored
Merge pull request #2 from node9-ai/dev
fix: merge latest dev updates into main
2 parents d1adcf1 + 12771d8 commit 6fb961f

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

.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: 18 additions & 6 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,11 @@ async function runReview() {
2229
return;
2330
}
2431

32+
const wasTruncated = prDiff.length > MAX_DIFF_CHARS;
33+
const truncatedDiff = wasTruncated
34+
? prDiff.slice(0, MAX_DIFF_CHARS) + "\n\n... [diff truncated]"
35+
: prDiff;
36+
2537
const prompt = `You are a senior Python engineer reviewing a pull request for the Node9 Python SDK.
2638
Node9 is an execution security library — a @protect decorator that intercepts AI agent tool calls and asks for human approval before running them.
2739
@@ -34,16 +46,16 @@ Review the following git diff and provide concise, actionable feedback. Focus on
3446
3547
If the changes look good with no issues, say so briefly.
3648
Do NOT rewrite the code. Just review it.
37-
Keep your review under 400 words.
49+
Keep your review under 800 words.
3850
3951
## Git Diff:
40-
${prDiff}`;
52+
${truncatedDiff}`;
4153

4254
console.log("Sending diff to Claude for review...");
4355
const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
4456
const message = await client.messages.create({
45-
model: "claude-sonnet-4-5",
46-
max_tokens: 1024,
57+
model: "claude-sonnet-4-6",
58+
max_tokens: 2048,
4759
messages: [{ role: "user", content: prompt }],
4860
});
4961

@@ -54,7 +66,7 @@ ${prDiff}`;
5466
owner: repoOwner,
5567
repo: repoName,
5668
issue_number: prNumber,
57-
body: `## 🤖 Claude Code Review\n\n${review}\n\n---\n*Automated review by Claude Sonnet*`,
69+
body: `## 🤖 Claude Code Review\n\n${review}${wasTruncated ? "\n\n> ⚠️ **Note:** This diff exceeded 20,000 characters and was truncated. The review above covers only the first portion of the changes." : ""}\n\n---\n*Automated review by Claude Sonnet*`,
5870
});
5971

6072
console.log("Review posted successfully.");

0 commit comments

Comments
 (0)