fleetbo-cockpit-cli 1.0.38 → 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 +29 -30
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -213,8 +213,8 @@ if (command === 'alex') {
|
|
|
213
213
|
const initialPrompt = args.slice(1).join(' ');
|
|
214
214
|
|
|
215
215
|
const processAlexRequest = async (prompt) => {
|
|
216
|
-
if (prompt.length >
|
|
217
|
-
console.log('\n\x1b[31m⛔ [Alex Safety] Request too long (' + prompt.length + '/
|
|
216
|
+
if (prompt.length > 1000) {
|
|
217
|
+
console.log('\n\x1b[31m⛔ [Alex Safety] Request too long (' + prompt.length + '/1000 chars).\x1b[0m');
|
|
218
218
|
console.log('\x1b[90mAlex prefers concise instructions. Please summarize.\x1b[0m');
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
@@ -459,56 +459,55 @@ if (command === 'alex') {
|
|
|
459
459
|
process.stdout.write('\n\x1b[F');
|
|
460
460
|
rl.prompt();
|
|
461
461
|
|
|
462
|
-
// ---
|
|
463
|
-
let inputBuffer = "";
|
|
464
|
-
|
|
465
|
-
let isProcessing = false;
|
|
466
|
-
let pasteDebounceTimer = null;
|
|
462
|
+
// --- MULTI-LINE BUFFER (SYNCHRONE & STRICT) ---
|
|
463
|
+
let inputBuffer = "";
|
|
464
|
+
let isProcessing = false; // Verrou de sécurité
|
|
467
465
|
|
|
468
466
|
rl.on('line', async (line) => {
|
|
469
|
-
if (isProcessing) return; //
|
|
467
|
+
if (isProcessing) return; // Ignore les frappes si le moteur tourne
|
|
470
468
|
|
|
471
469
|
const trimmedLine = line.trim();
|
|
472
470
|
|
|
473
|
-
// 1.
|
|
471
|
+
// 1. COMMANDES DE SORTIE
|
|
474
472
|
if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
|
|
475
473
|
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
476
474
|
rl.close();
|
|
477
475
|
return;
|
|
478
476
|
}
|
|
479
477
|
|
|
480
|
-
// 2. ACCUMULATION
|
|
478
|
+
// 2. ACCUMULATION (Si la ligne n'est pas vide)
|
|
481
479
|
if (trimmedLine !== "") {
|
|
482
480
|
inputBuffer += (inputBuffer ? "\n" : "") + line;
|
|
483
481
|
rl.setPrompt(`\x1b[34m > \x1b[0m`);
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
// 3.
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
pasteDebounceTimer = setTimeout(async () => {
|
|
491
|
-
// On ne déclenche la forge QUE si :
|
|
492
|
-
// - La dernière touche pressée était "Entrée" sur une ligne VIDE
|
|
493
|
-
// - ET que le buffer n'est pas vide
|
|
494
|
-
if (trimmedLine === "" && inputBuffer.trim() !== "") {
|
|
482
|
+
rl.prompt();
|
|
483
|
+
}
|
|
484
|
+
// 3. VALIDATION (Touche Entrée sur une ligne vide)
|
|
485
|
+
else {
|
|
486
|
+
if (inputBuffer.trim() !== "") {
|
|
495
487
|
const finalPrompt = inputBuffer.trim();
|
|
496
|
-
inputBuffer = ""; //
|
|
488
|
+
inputBuffer = ""; // On vide la RAM immédiatement
|
|
497
489
|
|
|
498
490
|
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
499
491
|
|
|
500
|
-
|
|
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;
|
|
501
502
|
await processAlexRequest(finalPrompt);
|
|
502
|
-
isProcessing = false;
|
|
503
|
+
isProcessing = false;
|
|
503
504
|
|
|
504
505
|
console.log('');
|
|
506
|
+
rl.prompt();
|
|
507
|
+
} else {
|
|
508
|
+
rl.prompt(); // Entrée dans le vide -> on affiche juste le prompt
|
|
505
509
|
}
|
|
506
|
-
|
|
507
|
-
// Rafraîchissement visuel du prompt
|
|
508
|
-
process.stdout.write('\n\x1b[F');
|
|
509
|
-
rl.prompt();
|
|
510
|
-
|
|
511
|
-
}, 50); // Pause de 50ms pour absorber les "Coller" massifs
|
|
510
|
+
}
|
|
512
511
|
});
|
|
513
512
|
};
|
|
514
513
|
|