codex-review-mcp 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,52 +1,14 @@
1
- import { Agent, run, tool } from '@openai/agents';
1
+ import { Agent, run } from '@openai/agents';
2
2
  import { debugLog } from '../util/debug.js';
3
- import { promises as fs } from 'node:fs';
4
- import { join } from 'node:path';
5
- import { z } from 'zod';
6
3
  export async function invokeAgent({ prompt, maxTokens, workspaceDir }) {
7
4
  const model = process.env.CODEX_MODEL || 'gpt-5-codex';
8
- const cwd = workspaceDir || process.cwd();
9
- // Tool: Read file from the codebase
10
- const readFileTool = tool({
11
- name: 'read_file',
12
- description: 'Read the contents of a file from the codebase to examine existing patterns, utilities, or configuration. Use this to check for existing code before suggesting changes.',
13
- parameters: z.object({
14
- path: z.string().describe('Relative path to the file from the repository root'),
15
- }),
16
- execute: async (params) => {
17
- try {
18
- // Basic path sandboxing to keep reads under cwd
19
- const requested = params.path.replace(/\\/g, '/');
20
- if (requested.includes('..')) {
21
- return 'Access denied: parent directory traversal is not allowed.';
22
- }
23
- const fullPath = join(cwd, requested);
24
- if (!fullPath.startsWith(cwd)) {
25
- return 'Access denied: path escapes workspace boundary.';
26
- }
27
- const content = await fs.readFile(fullPath, 'utf8');
28
- const MAX_RETURN = 50_000; // cap very large files
29
- const body = content.length > MAX_RETURN ? content.slice(0, MAX_RETURN) + '\n... [truncated]' : content;
30
- await debugLog(`Agent read file: ${params.path} (${content.length} chars)`);
31
- return `File: ${params.path}\n\n${body}`;
32
- }
33
- catch (error) {
34
- const errorMsg = `Unable to read ${params.path}: ${error.message}`;
35
- await debugLog(`Agent file read error: ${errorMsg}`);
36
- return errorMsg;
37
- }
38
- },
39
- });
40
5
  const agent = new Agent({
41
6
  name: 'Code Reviewer',
42
- instructions: 'You are a precise code-review agent. Follow the output contract exactly. Use minimal verbosity. When you need to examine existing code patterns, utilities, or configurations to provide accurate recommendations, use the read_file tool.',
7
+ instructions: 'You are a precise code-review agent. Follow the output contract exactly. Use minimal verbosity.',
43
8
  model,
44
- tools: [readFileTool],
45
9
  });
46
10
  try {
47
- const result = await run(agent, prompt, {
48
- maxTurns: 25, // Allow more turns for file reading (default is 10)
49
- });
11
+ const result = await run(agent, prompt);
50
12
  const out = result.finalOutput ?? '';
51
13
  await debugLog(`Agent model=${model} outputLen=${out.length}`);
52
14
  return out;
@@ -5,7 +5,6 @@ import { run } from '@openai/agents';
5
5
  vi.mock('@openai/agents', () => ({
6
6
  Agent: vi.fn().mockImplementation((config) => config),
7
7
  run: vi.fn(),
8
- tool: vi.fn().mockImplementation((config) => config),
9
8
  }));
10
9
  vi.mock('../util/debug', () => ({
11
10
  debugLog: vi.fn(),
@@ -75,26 +74,7 @@ describe('invokeAgent', () => {
75
74
  process.env.CODEX_MODEL = originalEnv;
76
75
  }
77
76
  });
78
- it('should create agent with read_file tool for examining codebase', async () => {
79
- vi.mocked(run).mockResolvedValue({
80
- finalOutput: '# Review',
81
- });
82
- await invokeAgent({
83
- prompt: 'Review this code',
84
- workspaceDir: '/test/workspace'
85
- });
86
- const { Agent, tool } = await import('@openai/agents');
87
- // Verify tool was created
88
- expect(tool).toHaveBeenCalledWith(expect.objectContaining({
89
- name: 'read_file',
90
- description: expect.stringContaining('examine existing patterns'),
91
- }));
92
- // Verify agent was created with tools
93
- expect(Agent).toHaveBeenCalledWith(expect.objectContaining({
94
- tools: expect.arrayContaining([expect.anything()]),
95
- }));
96
- });
97
- it('should pass workspaceDir to control file reading scope', async () => {
77
+ it('should pass workspaceDir parameter (for future use)', async () => {
98
78
  vi.mocked(run).mockResolvedValue({
99
79
  finalOutput: '# Review',
100
80
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-review-mcp",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build": "tsc",