fleetbo-cockpit-cli 1.0.20 → 1.0.21

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.
Files changed (2) hide show
  1. package/cli.js +13 -4
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -178,19 +178,28 @@ if (command === 'alex') {
178
178
  console.log('');
179
179
  let rawMsg = aiData.message || "I'm ready.";
180
180
 
181
- // 🛡️ FIX: Gemini imbrique parfois le JSON complet dans le champ "message"
182
- // On détecte et on extrait le vrai message texte
181
+ // 🛡️ FIX DÉFINITIF: Gemini imbrique parfois le JSON complet dans "message"
182
+ // Le JSON imbriqué peut être tronqué (4000 tokens), donc JSON.parse échoue.
183
+ // On extrait le vrai message par découpe de string.
183
184
  if (typeof rawMsg === 'string' && rawMsg.trimStart().startsWith('{')) {
185
+ // Tentative 1: Parse complet (JSON non tronqué)
184
186
  try {
185
187
  const nested = JSON.parse(rawMsg);
186
188
  if (nested && nested.message) {
187
189
  rawMsg = nested.message;
188
- // Récupérer aussi moduleData si absent du parent
189
190
  if (!aiData.moduleData && nested.moduleData) {
190
191
  aiData.moduleData = nested.moduleData;
191
192
  }
192
193
  }
193
- } catch (_) {}
194
+ } catch (_) {
195
+ // Tentative 2: Extraction par regex (JSON tronqué)
196
+ const msgMatch = rawMsg.match(/"message"\s*:\s*"((?:[^"\\]|\\.)*)"/);
197
+ if (msgMatch && msgMatch[1]) {
198
+ rawMsg = msgMatch[1].replace(/\\n/g, '\n').replace(/\\"/g, '"');
199
+ } else {
200
+ rawMsg = "Module generated. Check files below.";
201
+ }
202
+ }
194
203
  }
195
204
 
196
205
  // 🛡️ SAFETY: Si le message est un JSON stringifié ou contient du code brut,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",