fleetbo-cockpit-cli 1.0.39 → 1.0.41
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 +40 -21
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -459,45 +459,64 @@ if (command === 'alex') {
|
|
|
459
459
|
process.stdout.write('\n\x1b[F');
|
|
460
460
|
rl.prompt();
|
|
461
461
|
|
|
462
|
-
// ---
|
|
462
|
+
// --- MULTI-LINE BUFFER (ANTI-GLITCH VISUEL) ---
|
|
463
463
|
let inputBuffer = "";
|
|
464
|
-
let
|
|
464
|
+
let isProcessing = false;
|
|
465
|
+
let promptTimeout = null; // 🛡️ Le sauveur de l'affichage
|
|
466
|
+
|
|
467
|
+
rl.on('line', async (line) => {
|
|
468
|
+
if (isProcessing) return;
|
|
465
469
|
|
|
466
|
-
rl.on('line', (line) => {
|
|
467
470
|
const trimmedLine = line.trim();
|
|
468
471
|
|
|
469
|
-
//
|
|
472
|
+
// 1. COMMANDES DE SORTIE
|
|
470
473
|
if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
|
|
471
474
|
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
472
475
|
rl.close();
|
|
473
476
|
return;
|
|
474
477
|
}
|
|
475
478
|
|
|
476
|
-
//
|
|
479
|
+
// 2. ACCUMULATION (Si la ligne n'est pas vide)
|
|
477
480
|
if (trimmedLine !== "") {
|
|
478
481
|
inputBuffer += (inputBuffer ? "\n" : "") + line;
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
482
|
+
rl.setPrompt(`\x1b[34m > \x1b[0m`);
|
|
483
|
+
|
|
484
|
+
// 🛡️ ANTI-GLITCH : On laisse le terminal afficher tout le collage d'un coup.
|
|
485
|
+
// On ne redessine le chevron qu'après 50ms de silence.
|
|
486
|
+
clearTimeout(promptTimeout);
|
|
487
|
+
promptTimeout = setTimeout(() => {
|
|
488
|
+
rl.prompt();
|
|
489
|
+
}, 50);
|
|
490
|
+
}
|
|
491
|
+
// 3. VALIDATION (Touche Entrée sur une ligne vide)
|
|
492
|
+
else {
|
|
493
|
+
if (inputBuffer.trim() !== "") {
|
|
487
494
|
const finalPrompt = inputBuffer.trim();
|
|
488
|
-
inputBuffer = "";
|
|
495
|
+
inputBuffer = "";
|
|
489
496
|
|
|
490
497
|
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
498
|
+
clearTimeout(promptTimeout); // On annule tout dessin en cours
|
|
499
|
+
|
|
500
|
+
// 🛑 COUPE-CIRCUIT STRICT (1000 caractères)
|
|
501
|
+
if (finalPrompt.length > 1000) {
|
|
502
|
+
console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejetée : Taille excessive (${finalPrompt.length}/1000 caractères).\x1b[0m`);
|
|
503
|
+
console.log(`\x1b[90m Veuillez être plus concis et vous concentrer sur l'essentiel.\x1b[0m\n`);
|
|
504
|
+
rl.prompt();
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// ✅ ON LANCE LA FORGE
|
|
509
|
+
isProcessing = true;
|
|
491
510
|
await processAlexRequest(finalPrompt);
|
|
511
|
+
isProcessing = false;
|
|
512
|
+
|
|
492
513
|
console.log('');
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
rl.setPrompt(`\x1b[34m
|
|
514
|
+
rl.prompt();
|
|
515
|
+
} else {
|
|
516
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
517
|
+
rl.prompt(); // Entrée dans le vide
|
|
496
518
|
}
|
|
497
|
-
|
|
498
|
-
process.stdout.write('\n\x1b[F');
|
|
499
|
-
rl.prompt();
|
|
500
|
-
}, 50); // 50ms absorbs the fastest "paste" bursts
|
|
519
|
+
}
|
|
501
520
|
});
|
|
502
521
|
};
|
|
503
522
|
|