codex-review-mcp 2.3.5 → 2.3.6
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.
package/dist/mcp-server.test.js
CHANGED
@@ -171,6 +171,34 @@ describe('MCP Server Integration Tests', () => {
|
|
171
171
|
}), expect.any(Function) // onProgress callback
|
172
172
|
);
|
173
173
|
});
|
174
|
+
it('should pass workspaceDir parameter for context gathering', async () => {
|
175
|
+
// CRITICAL TEST: Verifies workspaceDir flows from MCP layer to performCodeReview
|
176
|
+
const testWorkspaceDir = '/Users/test/Projects/learn-webapp';
|
177
|
+
await client.callTool({
|
178
|
+
name: 'perform_code_review',
|
179
|
+
arguments: {
|
180
|
+
content: 'console.log("test");',
|
181
|
+
workspaceDir: testWorkspaceDir
|
182
|
+
}
|
183
|
+
});
|
184
|
+
// Verify workspaceDir is passed to performCodeReview
|
185
|
+
expect(performCodeReview).toHaveBeenCalledWith(expect.objectContaining({
|
186
|
+
workspaceDir: testWorkspaceDir
|
187
|
+
}), expect.any(Function));
|
188
|
+
});
|
189
|
+
it('should handle missing workspaceDir (falls back to cwd)', async () => {
|
190
|
+
await client.callTool({
|
191
|
+
name: 'perform_code_review',
|
192
|
+
arguments: {
|
193
|
+
content: 'console.log("test");'
|
194
|
+
// workspaceDir NOT provided
|
195
|
+
}
|
196
|
+
});
|
197
|
+
// workspaceDir should be undefined, causing gatherContext to use process.cwd()
|
198
|
+
expect(performCodeReview).toHaveBeenCalledWith(expect.objectContaining({
|
199
|
+
workspaceDir: undefined
|
200
|
+
}), expect.any(Function));
|
201
|
+
});
|
174
202
|
it('should return markdown content', async () => {
|
175
203
|
const result = await client.callTool({
|
176
204
|
name: 'perform_code_review',
|
@@ -37,6 +37,16 @@ export async function performCodeReview(input, onProgress) {
|
|
37
37
|
: shouldSkip
|
38
38
|
? ''
|
39
39
|
: await gatherContext(input.workspaceDir);
|
40
|
+
// Debug: Log what context was gathered (to stderr for MCP logs)
|
41
|
+
console.error(`[codex-review-mcp] Context gathered: ${context.length} chars`);
|
42
|
+
const hasCursorRules = context.includes('.cursor/rules');
|
43
|
+
console.error(`[codex-review-mcp] Contains .cursor/rules: ${hasCursorRules}`);
|
44
|
+
if (hasCursorRules) {
|
45
|
+
const cursorFiles = (context.match(/<!-- \.cursor\/rules\/[^>]+ -->/g) || []);
|
46
|
+
console.error(`[codex-review-mcp] Cursor rules files: ${cursorFiles.join(', ')}`);
|
47
|
+
}
|
48
|
+
// Also use debugLog for persistent logging
|
49
|
+
await debugLog(`Context gathered: ${context.length} chars, .cursor/rules: ${hasCursorRules}`);
|
40
50
|
// Build expert prompt
|
41
51
|
await onProgress?.('Building expert prompt…', 50, 100);
|
42
52
|
const isStaticReview = input.contentType === 'code';
|
@@ -112,6 +112,34 @@ describe('performCodeReview', () => {
|
|
112
112
|
});
|
113
113
|
expect(gatherContextModule.gatherContext).toHaveBeenCalledWith(workspaceDir);
|
114
114
|
});
|
115
|
+
it('should use process.cwd() when workspaceDir is not provided', async () => {
|
116
|
+
const gatherSpy = vi.spyOn(gatherContextModule, 'gatherContext').mockResolvedValue('');
|
117
|
+
vi.spyOn(invokeAgentModule, 'invokeAgent').mockResolvedValue('# Review');
|
118
|
+
await performCodeReview({
|
119
|
+
content: mockDiff
|
120
|
+
// workspaceDir NOT provided
|
121
|
+
});
|
122
|
+
// Should be called with undefined, which makes gatherContext use process.cwd()
|
123
|
+
expect(gatherSpy).toHaveBeenCalledWith(undefined);
|
124
|
+
});
|
125
|
+
it('should find .cursor/rules when workspaceDir points to correct directory', async () => {
|
126
|
+
// This tests the critical path: workspaceDir -> gatherContext -> .cursor/rules
|
127
|
+
const workspaceDir = '/project/with/cursor/rules';
|
128
|
+
const gatherSpy = vi.spyOn(gatherContextModule, 'gatherContext')
|
129
|
+
.mockResolvedValue('<!-- .cursor/rules/project.mdc -->\n# Cursor Rules\nUse strict mode');
|
130
|
+
vi.spyOn(invokeAgentModule, 'invokeAgent').mockResolvedValue('# Review');
|
131
|
+
const buildPromptSpy = vi.spyOn(buildPromptModule, 'buildPrompt').mockReturnValue('prompt');
|
132
|
+
await performCodeReview({
|
133
|
+
content: mockDiff,
|
134
|
+
workspaceDir
|
135
|
+
});
|
136
|
+
// Verify gatherContext was called with the workspace dir
|
137
|
+
expect(gatherSpy).toHaveBeenCalledWith(workspaceDir);
|
138
|
+
// Verify the gathered context (with .cursor/rules) is passed to buildPrompt
|
139
|
+
expect(buildPromptSpy).toHaveBeenCalledWith(expect.objectContaining({
|
140
|
+
context: expect.stringContaining('.cursor/rules/project.mdc')
|
141
|
+
}));
|
142
|
+
});
|
115
143
|
});
|
116
144
|
describe('Content Types', () => {
|
117
145
|
it('should handle diff content type', async () => {
|