-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-review.genai.js
More file actions
43 lines (32 loc) · 1003 Bytes
/
code-review.genai.js
File metadata and controls
43 lines (32 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { execSync } from 'child_process';
const token = process.env.GITHUB_TOKEN;
if (!token) {
console.error("❌ GITHUB_TOKEN is not set.");
process.exit(1);
}
// 1. Get staged changes
const changes = execSync('git diff --cached', { encoding: 'utf-8' });
// 2. Define diff for LLM
function defDiff(label, content) {
global[label] = content;
}
// 3. Inject into global scope
defDiff("CODE_CHANGES", changes);
// 4. Prompt for LLM (template only — hook up your LLM agent)
const prompt = `
## Role
You are a senior developer. Your job is to review code changes and provide meaningful feedback.
## Input
<CODE_CHANGES>
## Instructions
- Identify bugs, anti-patterns, or issues
- Suggest improvements
- Use best practices (Clean Code, OWASP, etc.)
- Keep it concise and example-driven
## Format
📌 Issue: ...
❌ Why: ...
✅ Suggestion: ...
`;
console.log("Generated Prompt:\n", prompt.replace("<CODE_CHANGES>", global["CODE_CHANGES"]));
// You would send the prompt to your LLM here.