codex-review-mcp 2.2.1 โ 2.3.1
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.
@@ -5,44 +5,26 @@ export function buildPrompt({ diffText, context, focus, version, isStaticReview
|
|
5
5
|
return [
|
6
6
|
versionLine,
|
7
7
|
'',
|
8
|
-
'You are an expert
|
9
|
-
'Prefer minimal diffs and direct fixes.',
|
8
|
+
'You are an expert React and GraphQL code reviewer. Be concise, specific, and actionable.',
|
10
9
|
'',
|
11
|
-
'
|
10
|
+
'PRIORITY HIERARCHY:',
|
11
|
+
'1. Project documentation (.cursor/rules/*, CODE_REVIEW.md, CONTRIBUTING.md)',
|
12
|
+
'2. Config files (tsconfig.json, .eslintrc, prettier)',
|
13
|
+
'3. Existing patterns in the same directory/module',
|
14
|
+
'4. General best practices (only when not conflicting above)',
|
12
15
|
'',
|
13
|
-
'
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'',
|
19
|
-
'MANDATORY REVIEW REQUIREMENTS:',
|
20
|
-
'- ๐ EXAMINE existing code patterns in the same directory/module before suggesting changes',
|
21
|
-
'- ๐ CHECK for existing utility functions, abstractions, and helpers before creating new ones',
|
22
|
-
'- ๐ฏ FOLLOW the exact naming conventions, file structure, and import patterns used in this repo',
|
23
|
-
'- ๐งช MATCH existing test patterns and testing approaches when reviewing test files',
|
24
|
-
'- โ๏ธ VALIDATE against linting and formatting rules defined in the project config',
|
25
|
-
'- ๐ซ NEVER suggest patterns that are inconsistent with the existing codebase',
|
26
|
-
'- ๐ซ NEVER introduce external libraries/patterns not already in use',
|
27
|
-
'- โ
PREFER reusing existing abstractions over creating new ones',
|
28
|
-
'',
|
29
|
-
'SPECIFIC TECHNICAL GUIDELINES:',
|
30
|
-
'- Follow ALL guidelines, conventions, and architectural patterns defined in the project documentation below',
|
31
|
-
'- Maintain consistency with the existing codebase styling, naming conventions, and structural themes',
|
32
|
-
'- Base your recommendations on the internal documentation, .cursor/rules files, and configuration files provided',
|
33
|
-
'- Do NOT suggest changes that deviate from the project\'s established patterns or introduce external patterns',
|
34
|
-
'- When project guidelines conflict with general best practices, prioritize the project guidelines',
|
35
|
-
'- For accessibility audits: apply axe-core best practices and WCAG 2.1 Level AA guidelines',
|
36
|
-
'- When reviewing accessibility audit results or configs: VERIFY the audit tool is configured for WCAG 2.1 Level AA only. FLAG if audits are misconfigured (using WCAG 2.2, Level AAA, or only Level A tags) as these will report violations that don\'t match the Axe browser extension defaults or project compliance requirements. Correct axe-core tags should be: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"].',
|
37
|
-
'- CRITICAL Z-INDEX WARNING: Be extremely cautious with z-index changes on modals, overlays, or components. Analyze the entire z-index hierarchy before suggesting changes. Flag any z-index modifications as HIGH RISK and verify they won\'t break stacking context upstream or downstream. Always check for existing z-index patterns in the codebase first.',
|
38
|
-
'- MATERIAL-UI/MUI SPACING: Use theme.spacing() for all margin, padding, and gap values instead of hardcoded px/rem/em values to avoid magic numbers (e.g., gap: theme.spacing(3) for 24px). Flag any hardcoded spacing values.',
|
16
|
+
'CORE PRINCIPLES:',
|
17
|
+
'- Match existing patterns, naming, structure, and imports in this codebase',
|
18
|
+
'- Reuse existing utilities and abstractions; never introduce new ones unnecessarily',
|
19
|
+
'- Never suggest external libraries or patterns not already in use',
|
20
|
+
'- Validate against project linting and formatting rules',
|
21
|
+
'- When project guidelines conflict with best practices, follow the project',
|
39
22
|
focusLine,
|
40
23
|
'',
|
41
|
-
'
|
42
|
-
'1.
|
43
|
-
'
|
44
|
-
'
|
45
|
-
'4. Would this change maintain consistency with the surrounding code?',
|
24
|
+
'TECHNICAL REQUIREMENTS:',
|
25
|
+
'- Accessibility: WCAG 2.1 Level AA with tags ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"]. Flag misconfigured audits using WCAG 2.2, AAA, or only Level A.',
|
26
|
+
'- Z-index: Flag as HIGH RISK. Check entire stacking context before suggesting changes.',
|
27
|
+
'- MUI spacing: Use theme.spacing() for margins/padding/gaps. Flag hardcoded px/rem/em values.',
|
46
28
|
'',
|
47
29
|
`\n---\n${reviewType}${isStaticReview ? ' - Code Files' : ' (unified=0)'}:\n`,
|
48
30
|
diffText,
|
@@ -61,10 +61,10 @@ describe('buildPrompt', () => {
|
|
61
61
|
diffText: mockDiff,
|
62
62
|
});
|
63
63
|
// Verify key sections are present
|
64
|
-
expect(prompt).toContain('You are an expert
|
65
|
-
expect(prompt).toContain('
|
66
|
-
expect(prompt).toContain('
|
67
|
-
expect(prompt).toContain('
|
64
|
+
expect(prompt).toContain('You are an expert React and GraphQL code reviewer');
|
65
|
+
expect(prompt).toContain('PRIORITY HIERARCHY');
|
66
|
+
expect(prompt).toContain('CORE PRINCIPLES');
|
67
|
+
expect(prompt).toContain('TECHNICAL REQUIREMENTS');
|
68
68
|
expect(prompt).toContain('Output strictly as Markdown with the following sections');
|
69
69
|
});
|
70
70
|
it('should include the diff text', () => {
|
@@ -87,27 +87,20 @@ describe('buildPrompt', () => {
|
|
87
87
|
expect(prompt).toContain('TypeScript best practices');
|
88
88
|
expect(prompt).toContain(mockDiff);
|
89
89
|
});
|
90
|
-
it('should include POSIX environment assumption', () => {
|
91
|
-
const prompt = buildPrompt({
|
92
|
-
diffText: mockDiff,
|
93
|
-
});
|
94
|
-
expect(prompt).toContain('ENVIRONMENT ASSUMPTION: The runtime and tooling are POSIX (macOS/Linux)');
|
95
|
-
expect(prompt).toContain('Do NOT suggest Windows/PowerShell/cmd-specific commands');
|
96
|
-
});
|
97
90
|
it('should include z-index warning', () => {
|
98
91
|
const prompt = buildPrompt({
|
99
92
|
diffText: mockDiff,
|
100
93
|
});
|
101
|
-
expect(prompt).toContain('
|
102
|
-
expect(prompt).toContain('
|
94
|
+
expect(prompt).toContain('Z-index: Flag as HIGH RISK');
|
95
|
+
expect(prompt).toContain('Check entire stacking context');
|
103
96
|
});
|
104
97
|
it('should include guidance hierarchy with proper priorities', () => {
|
105
98
|
const prompt = buildPrompt({
|
106
99
|
diffText: mockDiff,
|
107
100
|
});
|
108
|
-
expect(prompt).toContain('1.
|
109
|
-
expect(prompt).toContain('2.
|
110
|
-
expect(prompt).toContain('3. Existing patterns in
|
101
|
+
expect(prompt).toContain('1. Project documentation');
|
102
|
+
expect(prompt).toContain('2. Config files');
|
103
|
+
expect(prompt).toContain('3. Existing patterns in the same directory/module');
|
111
104
|
expect(prompt).toContain('4. General best practices');
|
112
105
|
});
|
113
106
|
});
|
@@ -1,10 +1,13 @@
|
|
1
|
-
export function formatOutput(agentMarkdown) {
|
1
|
+
export function formatOutput(agentMarkdown, version) {
|
2
2
|
// For MVP, trust agent output if non-empty; otherwise return a minimal stub.
|
3
|
-
|
4
|
-
|
3
|
+
const versionFooter = version ? `\n\n---\n*Generated by codex-review-mcp v${version}*` : '';
|
4
|
+
if (agentMarkdown && agentMarkdown.trim().length > 0) {
|
5
|
+
return agentMarkdown + versionFooter;
|
6
|
+
}
|
5
7
|
return [
|
6
8
|
'# Code Review',
|
7
9
|
'',
|
8
10
|
'No issues detected or empty output from agent.',
|
11
|
+
versionFooter,
|
9
12
|
].join('\n');
|
10
13
|
}
|
@@ -2,10 +2,18 @@ import { describe, it, expect } from 'vitest';
|
|
2
2
|
import { formatOutput } from './formatOutput.js';
|
3
3
|
describe('formatOutput', () => {
|
4
4
|
describe('Valid Agent Output', () => {
|
5
|
-
it('should return agent markdown
|
5
|
+
it('should return agent markdown without version when version not provided', () => {
|
6
6
|
const agentOutput = '# Code Review\n\n## Issues\n\n- Issue 1\n- Issue 2';
|
7
7
|
const result = formatOutput(agentOutput);
|
8
8
|
expect(result).toBe(agentOutput);
|
9
|
+
expect(result).not.toContain('Generated by codex-review-mcp');
|
10
|
+
});
|
11
|
+
it('should append version footer when version is provided', () => {
|
12
|
+
const agentOutput = '# Code Review\n\n## Issues\n\n- Issue 1';
|
13
|
+
const result = formatOutput(agentOutput, '2.3.0');
|
14
|
+
expect(result).toContain(agentOutput);
|
15
|
+
expect(result).toContain('---');
|
16
|
+
expect(result).toContain('*Generated by codex-review-mcp v2.3.0*');
|
9
17
|
});
|
10
18
|
it('should preserve formatting and special characters', () => {
|
11
19
|
const agentOutput = `# Review
|
@@ -58,6 +66,12 @@ function fix() {
|
|
58
66
|
expect(result).toContain('# Code Review');
|
59
67
|
expect(result).toContain('No issues detected or empty output from agent');
|
60
68
|
});
|
69
|
+
it('should include version in fallback message when provided', () => {
|
70
|
+
const result = formatOutput('', '2.3.0');
|
71
|
+
expect(result).toContain('# Code Review');
|
72
|
+
expect(result).toContain('No issues detected or empty output from agent');
|
73
|
+
expect(result).toContain('*Generated by codex-review-mcp v2.3.0*');
|
74
|
+
});
|
61
75
|
it('should return fallback message when output is only whitespace', () => {
|
62
76
|
const result = formatOutput(' \n\n \t ');
|
63
77
|
expect(result).toContain('# Code Review');
|
@@ -59,7 +59,7 @@ export async function performCodeReview(input, onProgress) {
|
|
59
59
|
await debugLog(`Review produced ${agentMd.length} chars`);
|
60
60
|
// Format output
|
61
61
|
await onProgress?.('Formatting outputโฆ', 90, 100);
|
62
|
-
const out = formatOutput(agentMd);
|
62
|
+
const out = formatOutput(agentMd, VERSION);
|
63
63
|
await onProgress?.('Done', 100, 100);
|
64
64
|
return out;
|
65
65
|
}
|