fleetbo-cockpit-cli 1.0.12 → 1.0.14
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/cli.js +19 -2
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -162,7 +162,10 @@ if (command === 'alex') {
|
|
|
162
162
|
const result = await axios.post(ALEX_ENGINE_URL, { prompt, projectType: 'android' }, {
|
|
163
163
|
headers: { 'x-project-id': projectId }
|
|
164
164
|
});
|
|
165
|
-
|
|
165
|
+
let aiData = result.data;
|
|
166
|
+
if (typeof aiData === 'string') {
|
|
167
|
+
try { aiData = JSON.parse(aiData); } catch (_) {}
|
|
168
|
+
}
|
|
166
169
|
process.stdout.write('\r' + ' '.repeat(50) + '\r');
|
|
167
170
|
|
|
168
171
|
if (aiData.status === 'quota_exceeded') {
|
|
@@ -172,7 +175,21 @@ if (command === 'alex') {
|
|
|
172
175
|
|
|
173
176
|
if (aiData.status === 'success' || aiData.status === 'message' || aiData.status === 'complex_refusal') {
|
|
174
177
|
console.log('');
|
|
175
|
-
|
|
178
|
+
let rawMsg = aiData.message || "I'm ready.";
|
|
179
|
+
|
|
180
|
+
// 🛡️ SAFETY: Si le message est un JSON stringifié ou contient du code brut,
|
|
181
|
+
// on extrait uniquement la partie lisible pour le terminal.
|
|
182
|
+
if (typeof rawMsg === 'object') {
|
|
183
|
+
rawMsg = rawMsg.message || rawMsg.text || "Module generated.";
|
|
184
|
+
}
|
|
185
|
+
// Détection d'un JSON brut accidentellement injecté dans le message
|
|
186
|
+
try {
|
|
187
|
+
const testParse = JSON.parse(rawMsg);
|
|
188
|
+
if (testParse && typeof testParse === 'object' && testParse.status) {
|
|
189
|
+
rawMsg = testParse.message || "Module generated.";
|
|
190
|
+
}
|
|
191
|
+
} catch (_) { /* Not JSON, continue normally */ }
|
|
192
|
+
|
|
176
193
|
const formattedMsg = wrapText(rawMsg, 85);
|
|
177
194
|
console.log('\x1b[32mAlex ❯\x1b[0m ' + formattedMsg);
|
|
178
195
|
|