coderev-cli 1.0.5 → 1.0.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/package.json +1 -1
- package/src/reviewer.js +11 -1
package/package.json
CHANGED
package/src/reviewer.js
CHANGED
|
@@ -446,13 +446,23 @@ async function callAI(apiKey, messages, config) {
|
|
|
446
446
|
messages,
|
|
447
447
|
});
|
|
448
448
|
|
|
449
|
-
return response.choices[0]?.message?.content || '';
|
|
449
|
+
return response.choices?.[0]?.message?.content || '';
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
/**
|
|
453
453
|
* Parse AI response into structured review result.
|
|
454
454
|
*/
|
|
455
455
|
function parseReviewResponse(text) {
|
|
456
|
+
if (!text || typeof text !== 'string') {
|
|
457
|
+
return {
|
|
458
|
+
summary: 'Empty response from AI',
|
|
459
|
+
score: 0,
|
|
460
|
+
issues: [{ type: 'error', severity: 'high', message: 'AI returned empty response', suggestion: 'Check API key and provider configuration' }],
|
|
461
|
+
suggestions: [],
|
|
462
|
+
praise: [],
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
|
|
456
466
|
try {
|
|
457
467
|
// Try direct parse first
|
|
458
468
|
return JSON.parse(text);
|