openairev 0.2.2 → 0.2.4
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/bin/openairev.js
CHANGED
package/package.json
CHANGED
package/src/agents/codex.js
CHANGED
|
@@ -46,7 +46,12 @@ export class CodexAdapter {
|
|
|
46
46
|
if (event.type === 'item.completed' && event.item?.type === 'agent_message') {
|
|
47
47
|
agentMessage = event.item.text;
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
if (event.type === 'error' || event.type === 'turn.failed') {
|
|
50
|
+
const errMsg = event.message || event.error?.message || JSON.stringify(event);
|
|
51
|
+
throw new Error(`Codex error: ${errMsg}`);
|
|
52
|
+
}
|
|
53
|
+
} catch (e) {
|
|
54
|
+
if (e.message?.startsWith('Codex error:')) throw e;
|
|
50
55
|
// skip non-JSON lines
|
|
51
56
|
}
|
|
52
57
|
}
|
package/src/cli/init.js
CHANGED
|
@@ -241,6 +241,7 @@ This project uses OpenAIRev for independent AI code review. When the user asks t
|
|
|
241
241
|
|
|
242
242
|
- You are the **executor**. Set \`executor\` to \`"claude_code"\` when calling the tool.
|
|
243
243
|
- A different AI model will review your code independently.
|
|
244
|
+
- **IMPORTANT**: Pass only the diff for files you changed using \`diff_cmd\`, e.g. \`"git diff HEAD -- src/auth.ts src/routes.ts"\`. Do NOT let it auto-detect — the full repo diff may be too large.
|
|
244
245
|
- When you receive review feedback, treat it as **peer review** — use your judgment, don't blindly apply every suggestion.
|
|
245
246
|
- The review verdict includes \`critical_issues\`, \`repair_instructions\`, and a \`confidence\` score. Focus on high-confidence critical issues.
|
|
246
247
|
${marker}
|
|
@@ -300,6 +301,7 @@ This project uses OpenAIRev for independent AI code review. When the user asks t
|
|
|
300
301
|
|
|
301
302
|
- You are the **executor**. Set \`executor\` to \`"codex"\` when calling the tool.
|
|
302
303
|
- A different AI model will review your code independently.
|
|
304
|
+
- **IMPORTANT**: Pass only the diff for files you changed using \`diff_cmd\`, e.g. \`"git diff HEAD -- src/auth.ts src/routes.ts"\`. Do NOT let it auto-detect — the full repo diff may be too large.
|
|
303
305
|
- When you receive review feedback, treat it as **peer review** — use your judgment, don't blindly apply every suggestion.
|
|
304
306
|
- The review verdict includes \`critical_issues\`, \`repair_instructions\`, and a \`confidence\` score. Focus on high-confidence critical issues.
|
|
305
307
|
${marker}
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"items": { "type": "string" }
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
-
"required": ["status", "critical_issues", "risk_level", "confidence"],
|
|
42
|
+
"required": ["status", "critical_issues", "missing_requirements", "sequencing_issues", "risks", "risk_level", "confidence", "repair_instructions", "false_positives_reconsidered"],
|
|
43
43
|
"additionalProperties": false
|
|
44
44
|
}
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"items": { "type": "string" }
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
-
"required": ["status", "critical_issues", "risk_level", "confidence"],
|
|
42
|
+
"required": ["status", "critical_issues", "test_gaps", "requirement_mismatches", "rule_violations", "risk_level", "confidence", "repair_instructions", "false_positives_reconsidered"],
|
|
43
43
|
"additionalProperties": false
|
|
44
44
|
}
|
package/src/mcp/mcp-server.js
CHANGED
|
@@ -14,7 +14,7 @@ const config = loadConfig(cwd);
|
|
|
14
14
|
|
|
15
15
|
const server = new McpServer({
|
|
16
16
|
name: 'openairev',
|
|
17
|
-
version: '0.2.
|
|
17
|
+
version: '0.2.4',
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
server.tool(
|
|
@@ -22,17 +22,27 @@ server.tool(
|
|
|
22
22
|
'TRIGGER: Use this tool when the user says "review", "review my code", "get a review", "check my changes", "openairev", or asks for independent/cross-model code review. Sends current code changes to a DIFFERENT AI model for independent review. Returns a structured verdict with critical issues, test gaps, risk level, confidence score, and repair instructions.',
|
|
23
23
|
{
|
|
24
24
|
executor: z.string().optional().describe('Which agent wrote the code (claude_code or codex). If you are Claude Code, set this to "claude_code". If you are Codex, set this to "codex".'),
|
|
25
|
-
diff: z.string().optional().describe('The diff
|
|
25
|
+
diff: z.string().optional().describe('The diff to review. IMPORTANT: Pass only the diff for files YOU changed, not the entire repo. Use `git diff HEAD -- file1 file2` to scope it. If omitted, auto-detects from git which may be too large.'),
|
|
26
|
+
diff_cmd: z.string().optional().describe('The git command used to get the diff, e.g. "git diff HEAD -- src/auth.ts src/routes.ts". If provided instead of diff, the server will run this command to get the diff.'),
|
|
26
27
|
task_description: z.string().optional().describe('What the code is supposed to do. Used for requirement checking.'),
|
|
27
28
|
},
|
|
28
|
-
async ({ executor, diff, task_description }) => {
|
|
29
|
+
async ({ executor, diff, diff_cmd, task_description }) => {
|
|
29
30
|
const execAgent = executor || Object.keys(config.agents || {}).find(a => config.agents[a].available);
|
|
30
31
|
const reviewerName = getReviewer(config, execAgent);
|
|
31
32
|
if (!reviewerName) {
|
|
32
33
|
return { content: [{ type: 'text', text: `No reviewer configured for executor "${execAgent}"` }] };
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
let diffContent = diff;
|
|
37
|
+
if (!diffContent && diff_cmd) {
|
|
38
|
+
try {
|
|
39
|
+
const { execSync } = await import('child_process');
|
|
40
|
+
diffContent = execSync(diff_cmd, { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024, cwd });
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return { content: [{ type: 'text', text: `diff_cmd failed: ${e.message}` }] };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!diffContent) diffContent = getDiff();
|
|
36
46
|
if (!diffContent?.trim()) {
|
|
37
47
|
return { content: [{ type: 'text', text: 'No changes found to review.' }] };
|
|
38
48
|
}
|
package/src/tools/git-tools.js
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
import { execFileSync } from 'child_process';
|
|
2
2
|
|
|
3
|
+
// Files to exclude from diffs — lock files, generated code, etc.
|
|
4
|
+
const EXCLUDE_PATTERNS = [
|
|
5
|
+
'*.lock',
|
|
6
|
+
'package-lock.json',
|
|
7
|
+
'yarn.lock',
|
|
8
|
+
'pnpm-lock.yaml',
|
|
9
|
+
'*.generated.*',
|
|
10
|
+
'dist/*',
|
|
11
|
+
'build/*',
|
|
12
|
+
'.next/*',
|
|
13
|
+
];
|
|
14
|
+
|
|
3
15
|
/**
|
|
4
16
|
* Get the current git diff. Tries staged first, then unstaged.
|
|
5
17
|
* Returns empty string if no changes found.
|
|
18
|
+
* Uses minimal context (1 line) and excludes irrelevant files.
|
|
6
19
|
*/
|
|
7
|
-
export function getDiff(ref) {
|
|
20
|
+
export function getDiff(ref, { context = 1, excludes = EXCLUDE_PATTERNS } = {}) {
|
|
21
|
+
const excludeArgs = excludes.flatMap(p => ['--', `:!${p}`]);
|
|
22
|
+
const contextArgs = [`-U${context}`];
|
|
23
|
+
|
|
8
24
|
if (ref) {
|
|
9
|
-
return gitExec(['diff', ref]);
|
|
25
|
+
return gitExec(['diff', ...contextArgs, ref, ...excludeArgs]);
|
|
10
26
|
}
|
|
11
27
|
|
|
12
|
-
const staged = gitExec(['diff', '--cached']);
|
|
28
|
+
const staged = gitExec(['diff', '--cached', ...contextArgs, ...excludeArgs]);
|
|
13
29
|
if (staged.trim()) return staged;
|
|
14
30
|
|
|
15
|
-
const unstaged = gitExec(['diff']);
|
|
31
|
+
const unstaged = gitExec(['diff', ...contextArgs, ...excludeArgs]);
|
|
16
32
|
if (unstaged.trim()) return unstaged;
|
|
17
33
|
|
|
18
34
|
return '';
|
|
@@ -20,7 +36,7 @@ export function getDiff(ref) {
|
|
|
20
36
|
|
|
21
37
|
function gitExec(args) {
|
|
22
38
|
try {
|
|
23
|
-
return execFileSync('git', args, { encoding: 'utf-8', maxBuffer:
|
|
39
|
+
return execFileSync('git', args, { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
|
|
24
40
|
} catch (e) {
|
|
25
41
|
throw new Error(`git ${args[0]} failed: ${e.message}`);
|
|
26
42
|
}
|