openairev 0.2.0 → 0.2.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.
- package/bin/openairev.js +1 -1
- package/package.json +1 -1
- package/src/cli/init.js +100 -3
- package/src/mcp/mcp-server.js +1 -1
package/bin/openairev.js
CHANGED
package/package.json
CHANGED
package/src/cli/init.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { writeFileSync, mkdirSync, copyFileSync, existsSync } from 'fs';
|
|
2
|
-
import { join, dirname } from 'path';
|
|
1
|
+
import { writeFileSync, readFileSync, mkdirSync, copyFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join, dirname, resolve } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
5
|
import YAML from 'yaml';
|
|
@@ -8,7 +8,9 @@ import { getConfigDir, getConfigPath, configExists } from '../config/config-load
|
|
|
8
8
|
import { detectAgent } from '../agents/detect.js';
|
|
9
9
|
|
|
10
10
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
const
|
|
11
|
+
const PACKAGE_ROOT = resolve(__dirname, '../..');
|
|
12
|
+
const PROMPTS_SRC = join(PACKAGE_ROOT, 'prompts');
|
|
13
|
+
const MCP_SERVER_PATH = join(PACKAGE_ROOT, 'src/mcp/mcp-server.js');
|
|
12
14
|
|
|
13
15
|
export async function initCommand() {
|
|
14
16
|
const cwd = process.cwd();
|
|
@@ -187,6 +189,15 @@ export async function initCommand() {
|
|
|
187
189
|
|
|
188
190
|
console.log(`\n${chalk.green('✓')} Config written to .openairev/config.yaml`);
|
|
189
191
|
console.log(`${chalk.green('✓')} Prompt templates written to .openairev/prompts/`);
|
|
192
|
+
|
|
193
|
+
// Configure agent integrations
|
|
194
|
+
if (answers.agents.includes('claude_code')) {
|
|
195
|
+
setupClaudeCode(cwd);
|
|
196
|
+
}
|
|
197
|
+
if (answers.agents.includes('codex')) {
|
|
198
|
+
setupCodex(cwd);
|
|
199
|
+
}
|
|
200
|
+
|
|
190
201
|
console.log(`\nRun ${chalk.cyan('openairev review')} to trigger a review.\n`);
|
|
191
202
|
}
|
|
192
203
|
|
|
@@ -209,3 +220,89 @@ function copyIfMissing(src, dest) {
|
|
|
209
220
|
copyFileSync(src, dest);
|
|
210
221
|
}
|
|
211
222
|
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Set up Claude Code integration:
|
|
226
|
+
* - Add MCP server to .claude/settings.json
|
|
227
|
+
* - Append instructions to CLAUDE.md
|
|
228
|
+
*/
|
|
229
|
+
function setupClaudeCode(cwd) {
|
|
230
|
+
// MCP server config
|
|
231
|
+
const claudeDir = join(cwd, '.claude');
|
|
232
|
+
const settingsPath = join(claudeDir, 'settings.json');
|
|
233
|
+
|
|
234
|
+
mkdirSync(claudeDir, { recursive: true });
|
|
235
|
+
|
|
236
|
+
let settings = {};
|
|
237
|
+
if (existsSync(settingsPath)) {
|
|
238
|
+
try { settings = JSON.parse(readFileSync(settingsPath, 'utf-8')); } catch { /* start fresh */ }
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (!settings.mcpServers) settings.mcpServers = {};
|
|
242
|
+
settings.mcpServers.openairev = {
|
|
243
|
+
command: 'node',
|
|
244
|
+
args: [MCP_SERVER_PATH],
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
248
|
+
console.log(`${chalk.green('✓')} MCP server added to .claude/settings.json`);
|
|
249
|
+
|
|
250
|
+
// CLAUDE.md instructions
|
|
251
|
+
const claudeMdPath = join(cwd, 'CLAUDE.md');
|
|
252
|
+
const marker = '<!-- openairev -->';
|
|
253
|
+
const instructions = `
|
|
254
|
+
${marker}
|
|
255
|
+
## OpenAIRev — Cross-Model Code Review
|
|
256
|
+
|
|
257
|
+
This project uses OpenAIRev for independent AI code review. When the user asks to "review", "get a review", or "check my changes", use the \`openairev_review\` MCP tool.
|
|
258
|
+
|
|
259
|
+
- You are the **executor**. Set \`executor\` to \`"claude_code"\` when calling the tool.
|
|
260
|
+
- A different AI model will review your code independently.
|
|
261
|
+
- When you receive review feedback, treat it as **peer review** — use your judgment, don't blindly apply every suggestion.
|
|
262
|
+
- The review verdict includes \`critical_issues\`, \`repair_instructions\`, and a \`confidence\` score. Focus on high-confidence critical issues.
|
|
263
|
+
${marker}
|
|
264
|
+
`;
|
|
265
|
+
|
|
266
|
+
if (existsSync(claudeMdPath)) {
|
|
267
|
+
const existing = readFileSync(claudeMdPath, 'utf-8');
|
|
268
|
+
if (!existing.includes(marker)) {
|
|
269
|
+
writeFileSync(claudeMdPath, existing + '\n' + instructions.trim() + '\n');
|
|
270
|
+
console.log(`${chalk.green('✓')} OpenAIRev instructions appended to CLAUDE.md`);
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
writeFileSync(claudeMdPath, instructions.trim() + '\n');
|
|
274
|
+
console.log(`${chalk.green('✓')} CLAUDE.md created with OpenAIRev instructions`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Set up Codex CLI integration:
|
|
280
|
+
* - Add instructions to AGENTS.md
|
|
281
|
+
*/
|
|
282
|
+
function setupCodex(cwd) {
|
|
283
|
+
const agentsMdPath = join(cwd, 'AGENTS.md');
|
|
284
|
+
const marker = '<!-- openairev -->';
|
|
285
|
+
const instructions = `
|
|
286
|
+
${marker}
|
|
287
|
+
## OpenAIRev — Cross-Model Code Review
|
|
288
|
+
|
|
289
|
+
This project uses OpenAIRev for independent AI code review. When the user asks to "review", "get a review", or "check my changes", use the \`openairev_review\` MCP tool.
|
|
290
|
+
|
|
291
|
+
- You are the **executor**. Set \`executor\` to \`"codex"\` when calling the tool.
|
|
292
|
+
- A different AI model will review your code independently.
|
|
293
|
+
- When you receive review feedback, treat it as **peer review** — use your judgment, don't blindly apply every suggestion.
|
|
294
|
+
- The review verdict includes \`critical_issues\`, \`repair_instructions\`, and a \`confidence\` score. Focus on high-confidence critical issues.
|
|
295
|
+
${marker}
|
|
296
|
+
`;
|
|
297
|
+
|
|
298
|
+
if (existsSync(agentsMdPath)) {
|
|
299
|
+
const existing = readFileSync(agentsMdPath, 'utf-8');
|
|
300
|
+
if (!existing.includes(marker)) {
|
|
301
|
+
writeFileSync(agentsMdPath, existing + '\n' + instructions.trim() + '\n');
|
|
302
|
+
console.log(`${chalk.green('✓')} OpenAIRev instructions appended to AGENTS.md`);
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
writeFileSync(agentsMdPath, instructions.trim() + '\n');
|
|
306
|
+
console.log(`${chalk.green('✓')} AGENTS.md created with OpenAIRev instructions`);
|
|
307
|
+
}
|
|
308
|
+
}
|
package/src/mcp/mcp-server.js
CHANGED
|
@@ -94,7 +94,7 @@ async function handleRequest(request, config, cwd) {
|
|
|
94
94
|
result: {
|
|
95
95
|
protocolVersion: '2024-11-05',
|
|
96
96
|
capabilities: { tools: {} },
|
|
97
|
-
serverInfo: { name: 'openairev', version: '0.2.
|
|
97
|
+
serverInfo: { name: 'openairev', version: '0.2.1' },
|
|
98
98
|
},
|
|
99
99
|
id,
|
|
100
100
|
};
|