fleetbo-cockpit-cli 1.0.39 → 1.0.40
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 +31 -21
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -459,45 +459,55 @@ if (command === 'alex') {
|
|
|
459
459
|
process.stdout.write('\n\x1b[F');
|
|
460
460
|
rl.prompt();
|
|
461
461
|
|
|
462
|
-
// ---
|
|
462
|
+
// --- MULTI-LINE BUFFER (SYNCHRONE & STRICT) ---
|
|
463
463
|
let inputBuffer = "";
|
|
464
|
-
let
|
|
464
|
+
let isProcessing = false; // Verrou de sécurité
|
|
465
|
+
|
|
466
|
+
rl.on('line', async (line) => {
|
|
467
|
+
if (isProcessing) return; // Ignore les frappes si le moteur tourne
|
|
465
468
|
|
|
466
|
-
rl.on('line', (line) => {
|
|
467
469
|
const trimmedLine = line.trim();
|
|
468
470
|
|
|
469
|
-
//
|
|
471
|
+
// 1. COMMANDES DE SORTIE
|
|
470
472
|
if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
|
|
471
473
|
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
472
474
|
rl.close();
|
|
473
475
|
return;
|
|
474
476
|
}
|
|
475
477
|
|
|
476
|
-
//
|
|
478
|
+
// 2. ACCUMULATION (Si la ligne n'est pas vide)
|
|
477
479
|
if (trimmedLine !== "") {
|
|
478
480
|
inputBuffer += (inputBuffer ? "\n" : "") + line;
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
// Trigger forge ONLY on an intentional EMPTY line + content in buffer
|
|
486
|
-
if (trimmedLine === "" && inputBuffer.trim() !== "") {
|
|
481
|
+
rl.setPrompt(`\x1b[34m > \x1b[0m`);
|
|
482
|
+
rl.prompt();
|
|
483
|
+
}
|
|
484
|
+
// 3. VALIDATION (Touche Entrée sur une ligne vide)
|
|
485
|
+
else {
|
|
486
|
+
if (inputBuffer.trim() !== "") {
|
|
487
487
|
const finalPrompt = inputBuffer.trim();
|
|
488
|
-
inputBuffer = ""; //
|
|
488
|
+
inputBuffer = ""; // On vide la RAM immédiatement
|
|
489
489
|
|
|
490
490
|
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
491
|
+
|
|
492
|
+
// 🛑 COUPE-CIRCUIT STRICT (Limite 1000 caractères)
|
|
493
|
+
if (finalPrompt.length > 1000) {
|
|
494
|
+
console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejetée : Taille excessive (${finalPrompt.length}/1000 caractères).\x1b[0m`);
|
|
495
|
+
console.log(`\x1b[90m Veuillez être plus concis et vous concentrer sur l'essentiel.\x1b[0m\n`);
|
|
496
|
+
rl.prompt(); // On redonne la main au pilote sans rien bloquer
|
|
497
|
+
return; // ⛔ ON BLOQUE TOUT ICI
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// ✅ SI TOUT EST VERT -> ON LANCE LA FORGE
|
|
501
|
+
isProcessing = true;
|
|
491
502
|
await processAlexRequest(finalPrompt);
|
|
503
|
+
isProcessing = false;
|
|
504
|
+
|
|
492
505
|
console.log('');
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
rl.
|
|
506
|
+
rl.prompt();
|
|
507
|
+
} else {
|
|
508
|
+
rl.prompt(); // Entrée dans le vide -> on affiche juste le prompt
|
|
496
509
|
}
|
|
497
|
-
|
|
498
|
-
process.stdout.write('\n\x1b[F');
|
|
499
|
-
rl.prompt();
|
|
500
|
-
}, 50); // 50ms absorbs the fastest "paste" bursts
|
|
510
|
+
}
|
|
501
511
|
});
|
|
502
512
|
};
|
|
503
513
|
|