fleetbo-cockpit-cli 1.0.148 → 1.0.150
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 +76 -41
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -639,59 +639,94 @@ if (command === 'alex') {
|
|
|
639
639
|
process.stdout.write('\n\x1b[F');
|
|
640
640
|
rl.prompt();
|
|
641
641
|
|
|
642
|
-
let
|
|
642
|
+
let standardBuffer = [];
|
|
643
643
|
let isProcessing = false;
|
|
644
|
-
let
|
|
644
|
+
let isPasteMode = false;
|
|
645
|
+
let pasteBlockerTimer = null;
|
|
645
646
|
|
|
647
|
+
const executePrompt = async (text) => {
|
|
648
|
+
if (['exit', 'quit'].includes(text.toLowerCase())) {
|
|
649
|
+
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
650
|
+
rl.close();
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
if (text !== "") {
|
|
654
|
+
if (text.length > 4000) {
|
|
655
|
+
console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${text.length}/4000 characters).\x1b[0m`);
|
|
656
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
657
|
+
rl.prompt();
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
isProcessing = true;
|
|
661
|
+
rl.setPrompt("");
|
|
662
|
+
|
|
663
|
+
// ✨ LE FAMEUX MESSAGE EXECUTING POUR TOUS LES ENVOIS ✨
|
|
664
|
+
console.log('\x1b[90mExecuting...\x1b[0m');
|
|
665
|
+
|
|
666
|
+
await processAlexRequest(text);
|
|
667
|
+
|
|
668
|
+
isProcessing = false;
|
|
669
|
+
console.log('');
|
|
670
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
671
|
+
rl.prompt();
|
|
672
|
+
} else {
|
|
673
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
674
|
+
rl.prompt();
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
// L'ÉCOUTEUR DE TOUCHES BLINDÉ
|
|
646
679
|
rl.on('line', async (line) => {
|
|
647
680
|
if (isProcessing) return;
|
|
648
681
|
|
|
649
|
-
|
|
682
|
+
// 1. SI LE MODE COLLAGE EST ACTIF
|
|
683
|
+
if (isPasteMode) {
|
|
684
|
+
if (['/s', '/send', 'eof'].includes(line.trim().toLowerCase())) {
|
|
685
|
+
const finalPrompt = standardBuffer.join('\n').trim();
|
|
686
|
+
standardBuffer = [];
|
|
687
|
+
isPasteMode = false;
|
|
688
|
+
await executePrompt(finalPrompt);
|
|
689
|
+
} else {
|
|
690
|
+
standardBuffer.push(line);
|
|
691
|
+
}
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
650
694
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
695
|
+
// 2. ACTIVATION DU MODE COLLAGE (/p)
|
|
696
|
+
if (['/paste', '/p'].includes(line.trim().toLowerCase())) {
|
|
697
|
+
isPasteMode = true;
|
|
698
|
+
standardBuffer = []; // Sécurité : on vide tout
|
|
699
|
+
console.log('\x1b[36m [MULTILINE MODE] Paste your content below. Type /s on a new line to submit.\x1b[0m');
|
|
700
|
+
rl.setPrompt("");
|
|
701
|
+
return;
|
|
655
702
|
}
|
|
656
703
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
if (inputBuffer.trim() !== "") {
|
|
663
|
-
if (!hintShown) {
|
|
664
|
-
// 1ère ligne vide → affiche le hint, attend la 2ème
|
|
665
|
-
hintShown = true;
|
|
666
|
-
rl.setPrompt("\x1b[90m ↵ again to send\x1b[0m");
|
|
667
|
-
rl.prompt();
|
|
668
|
-
} else {
|
|
669
|
-
// 2ème ligne vide → soumet
|
|
670
|
-
hintShown = false;
|
|
671
|
-
const finalPrompt = inputBuffer.trim();
|
|
672
|
-
inputBuffer = "";
|
|
673
|
-
|
|
674
|
-
if (finalPrompt.length > 4000) {
|
|
675
|
-
console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${finalPrompt.length}/4000 characters).\x1b[0m`);
|
|
676
|
-
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
677
|
-
rl.prompt();
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
704
|
+
// 3. LE BOUCLIER ANTI-COLLAGE SAUVAGE (Mode Chat Classique)
|
|
705
|
+
standardBuffer.push(line);
|
|
706
|
+
|
|
707
|
+
// On annule et relance le chrono de 15ms à chaque ligne ultra-rapide
|
|
708
|
+
if (pasteBlockerTimer) clearTimeout(pasteBlockerTimer);
|
|
680
709
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
await processAlexRequest(finalPrompt);
|
|
684
|
-
isProcessing = false;
|
|
710
|
+
pasteBlockerTimer = setTimeout(async () => {
|
|
711
|
+
pasteBlockerTimer = null;
|
|
685
712
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
713
|
+
if (standardBuffer.length > 1) {
|
|
714
|
+
// 🚨 ALERTE : Plus d'une ligne reçue en 15ms = Copier-coller illégal !
|
|
715
|
+
console.log('\n\x1b[31m⚠️ Illegal paste detected! You must type /p before pasting multiple lines of code.\x1b[0m');
|
|
716
|
+
standardBuffer = []; // On détruit la tentative de collage
|
|
717
|
+
rl.prompt();
|
|
690
718
|
} else {
|
|
691
|
-
|
|
692
|
-
|
|
719
|
+
// ✅ CAS NORMAL : 1 seule touche Entrée humaine
|
|
720
|
+
const finalPrompt = standardBuffer[0].trim();
|
|
721
|
+
standardBuffer = [];
|
|
722
|
+
|
|
723
|
+
if (finalPrompt === "") {
|
|
724
|
+
rl.prompt();
|
|
725
|
+
} else {
|
|
726
|
+
await executePrompt(finalPrompt);
|
|
727
|
+
}
|
|
693
728
|
}
|
|
694
|
-
}
|
|
729
|
+
}, 15); // 15 millisecondes d'analyse
|
|
695
730
|
});
|
|
696
731
|
};
|
|
697
732
|
|