Skip to content

Commit 225fce2

Browse files
committed
chore: add github-reviewer-agent
1 parent 0f03944 commit 225fce2

File tree

4 files changed

+96
-2
lines changed

4 files changed

+96
-2
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
import { join } from 'path';
6+
import { MCPAgent } from '../src';
7+
import { getModel } from './model';
8+
9+
const model = getModel('gpt-4o-2024-11-20');
10+
11+
async function main() {
12+
const agent = new MCPAgent({
13+
model,
14+
instructions:
15+
'You are GitHub Reviewer, a specialized assistant designed to help with code review tasks. ' +
16+
'You excel at analyzing pull requests, identifying potential bugs, security issues, and suggesting code improvements. ' +
17+
'You should focus on code quality, maintainability, performance, and adherence to best practices. ' +
18+
'When reviewing code, consider readability, potential edge cases, error handling, and test coverage. ' +
19+
'Provide constructive feedback and suggest specific improvements when possible.\n\n' +
20+
'IMPORTANT WORKFLOW REQUIREMENTS:\n' +
21+
'1. You MUST browse through ALL code changes in the pull request before providing feedback. Do not skip any files or changes.\n' +
22+
'2. After reviewing all changes, create a comprehensive review report with the following sections:\n' +
23+
' - Summary of changes\n' +
24+
' - Potential issues and bugs\n' +
25+
' - Code quality considerations\n' +
26+
' - Suggested improvements\n' +
27+
' - Overall assessment\n' +
28+
'3. ALWAYS include relevant code snippets in your report to illustrate your points. For each important issue or suggestion, ' +
29+
'include the corresponding code before and after the change (if applicable) in markdown code blocks with proper syntax highlighting.\n' +
30+
'4. When highlighting significant changes, use the format:\n' +
31+
' ```diff\n' +
32+
' - removed code\n' +
33+
' + added code\n' +
34+
' ```\n' +
35+
'5. Use the filesystem tool to save your final review report to a file named "REVIEW_RESULT.md" in the current directory.\n\n' +
36+
'Make extensive use of the playwright browsing tool to navigate GitHub repositories, ' +
37+
'examine code changes in PRs, understand context by exploring related files, and analyze commit histories. ' +
38+
'Take screenshots of specific code sections when they help illustrate complex issues or changes. ' +
39+
'Your reviews should be thorough yet easy to understand, with code examples making your feedback concrete and actionable. ' +
40+
"Remember that including actual code snippets makes your reports more vivid and helps the developer understand exactly what you're referring to.",
41+
mcpServers: {
42+
playwright: {
43+
command: 'npx',
44+
args: ['@playwright/mcp@latest'],
45+
},
46+
filesystem: {
47+
command: 'npx',
48+
args: [
49+
'-y',
50+
'@modelcontextprotocol/server-filesystem',
51+
join(__dirname, 'result'),
52+
],
53+
},
54+
},
55+
});
56+
57+
try {
58+
await agent.initialize();
59+
const tools = agent.getTools();
60+
console.log(`\nAvailable tools (${tools.length}):`);
61+
for (const tool of tools) {
62+
console.log(`- ${tool.name}: ${tool.description}`);
63+
}
64+
65+
// GitHub PR review related queries
66+
const queries = [
67+
'Review https://github.com/bytedance/UI-TARS-desktop/pull/534',
68+
];
69+
70+
for (const query of queries) {
71+
console.log('\n==================================================');
72+
console.log(`👤 Review request: ${query}`);
73+
console.log('==================================================');
74+
75+
const reviewFeedback = await agent.run(query);
76+
77+
console.log('--------------------------------------------------');
78+
console.log(`🔍 Review feedback: ${reviewFeedback}`);
79+
console.log('==================================================\n');
80+
}
81+
} catch (error) {
82+
console.error('Error during code review:', error);
83+
} finally {
84+
await agent.cleanup();
85+
}
86+
}
87+
88+
if (require.main === module) {
89+
main().catch(console.error);
90+
}

packages/agent-infra/agent/core/src/mcp/mcp-agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import { Agent } from '../agent';
77
import { AgentOptions, ToolDefinition } from '../types';
8-
import { MCPClient, MCPServerConfig, MCPServerRegistry } from './mcp-client';
8+
import { MCPClient, MCPServerRegistry } from './mcp-client';
99
import { MCPToolAdapter } from './mcp-tool-adapter';
1010

1111
export interface MCPAgentOptions extends AgentOptions {

packages/agent-infra/agent/core/src/mcp/mcp-client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5+
6+
/**
7+
* FIXME: migrate to `packages/agent-infra/mcp-client`.
8+
*/
59
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
610
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
711
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
@@ -16,7 +20,6 @@ export interface MCPServerConfig {
1620
command?: string;
1721
args?: string[];
1822
env?: Record<string, string>;
19-
2023
// SSE based server config
2124
url?: string;
2225
}

packages/agent-infra/agent/core/src/mcp/mcp-tool-adapter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
/*
23
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
34
* SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)