Skip to content

Commit 68b9041

Browse files
committed
Changes reviewer
1 parent 7e69225 commit 68b9041

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.agents/changes-reviewer.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { AgentConfig, AgentStepContext } from './types/agent-config'
2+
3+
const config: AgentConfig = {
4+
id: 'changes-reviewer',
5+
version: '0.0.1',
6+
displayName: 'Changes Reviewer',
7+
model: 'x-ai/grok-4',
8+
9+
parentPrompt: 'Spawn when you need to review code changes',
10+
11+
systemPrompt:
12+
'You are an expert software developer. Your job is to review code changes and provide helpful feedback.',
13+
14+
instructionsPrompt: `
15+
Use the following guidelines to review the changes and suggest improvements:
16+
1. Find ways to simplify the code
17+
2. Reuse existing code as much as possible instead of writing new code
18+
3. Preserve as much behavior as possible in the existing code
19+
4. Prefer to change as few lines of code as possible
20+
5. Look for logical errors in the code
21+
6. Look for missed cases in the code
22+
7. Look for any other bugs
23+
8. Look for opportunities to improve the code's readability
24+
`.trim(),
25+
26+
includeMessageHistory: true,
27+
outputMode: 'last_message',
28+
29+
toolNames: ['read_files', 'run_terminal_command', 'end_turn'],
30+
31+
handleSteps: function* ({ agentState, prompt, params }: AgentStepContext) {
32+
// Step 1: Get list of changed files from git diff
33+
const { toolResult: gitDiffResult } = yield {
34+
toolName: 'run_terminal_command',
35+
args: {
36+
command: 'git diff HEAD --name-only',
37+
process_type: 'SYNC',
38+
timeout_seconds: 30,
39+
},
40+
}
41+
42+
// Step 2: Get untracked files from git status
43+
const { toolResult: gitStatusResult } = yield {
44+
toolName: 'run_terminal_command',
45+
args: {
46+
command: 'git status --porcelain',
47+
process_type: 'SYNC',
48+
timeout_seconds: 30,
49+
},
50+
}
51+
52+
// Step 3: Run full git diff to see the actual changes
53+
yield {
54+
toolName: 'run_terminal_command',
55+
args: {
56+
command: 'git diff HEAD',
57+
process_type: 'SYNC',
58+
timeout_seconds: 30,
59+
},
60+
}
61+
62+
// Step 4: Extract file paths from git diff output
63+
const gitDiffOutput = gitDiffResult?.result || ''
64+
const changedFiles = gitDiffOutput
65+
.split('\n')
66+
.map((line) => line.trim())
67+
.filter((line) => line && !line.startsWith('??') && !line.includes('OSC'))
68+
69+
// Step 5: Extract untracked files from git status output
70+
const gitStatusOutput = gitStatusResult?.result || ''
71+
const untrackedFiles = gitStatusOutput
72+
.split('\n')
73+
.map((line) => line.trim())
74+
.filter((line) => line.startsWith('??'))
75+
.map((line) => line.substring(3).trim()) // Remove '?? ' prefix
76+
.filter((file) => file)
77+
78+
// Step 6: Combine all files to read
79+
const allFilesToRead = [...changedFiles, ...untrackedFiles].filter(
80+
(file) => file,
81+
)
82+
83+
if (allFilesToRead.length > 0) {
84+
yield {
85+
toolName: 'read_files',
86+
args: {
87+
paths: allFilesToRead,
88+
},
89+
}
90+
}
91+
92+
// Step 7: Let AI review the changes
93+
yield 'STEP_ALL'
94+
},
95+
}
96+
97+
export default config

0 commit comments

Comments
 (0)