@snapcommit/cli 3.9.2 → 3.9.3
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.
|
@@ -1326,15 +1326,29 @@ async function getAIInterpretation(userInput, token) {
|
|
|
1326
1326
|
console.error(chalk_1.default.red(`\n❌ AI API Error (${response.status}):`), errorData);
|
|
1327
1327
|
return null;
|
|
1328
1328
|
}
|
|
1329
|
-
|
|
1329
|
+
let data;
|
|
1330
|
+
try {
|
|
1331
|
+
data = await response.json();
|
|
1332
|
+
}
|
|
1333
|
+
catch (parseError) {
|
|
1334
|
+
console.error(chalk_1.default.red('\n❌ JSON Parse Error:'), parseError.message);
|
|
1335
|
+
console.error(chalk_1.default.gray('Response was not valid JSON'));
|
|
1336
|
+
return null;
|
|
1337
|
+
}
|
|
1330
1338
|
// Debug: Show what AI returned
|
|
1331
1339
|
if (process.env.DEBUG === 'true') {
|
|
1332
1340
|
console.log(chalk_1.default.gray('[DEBUG] AI Response:'), JSON.stringify(data, null, 2));
|
|
1333
1341
|
}
|
|
1342
|
+
if (!data || !data.intent) {
|
|
1343
|
+
console.error(chalk_1.default.red('\n❌ Invalid AI response structure'));
|
|
1344
|
+
console.error(chalk_1.default.gray('Expected: {intent: {...}}'));
|
|
1345
|
+
console.error(chalk_1.default.gray('Got:'), JSON.stringify(data).substring(0, 200));
|
|
1346
|
+
return null;
|
|
1347
|
+
}
|
|
1334
1348
|
return data.intent;
|
|
1335
1349
|
}
|
|
1336
1350
|
catch (error) {
|
|
1337
|
-
console.error(chalk_1.default.red('\n❌ Network
|
|
1351
|
+
console.error(chalk_1.default.red('\n❌ Network Error:'), error.message);
|
|
1338
1352
|
return null;
|
|
1339
1353
|
}
|
|
1340
1354
|
}
|