fleetbo-cockpit-cli 1.0.202 → 1.0.203
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 +11 -32
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -753,88 +753,67 @@ if (command === 'alex') {
|
|
|
753
753
|
|
|
754
754
|
// READY
|
|
755
755
|
console.log('');
|
|
756
|
-
console.log('\x1b[32mAlex ❯\x1b[0m
|
|
756
|
+
console.log('\x1b[32mAlex ❯\x1b[0m Secure channel established. Awaiting instructions...');
|
|
757
757
|
console.log('');
|
|
758
758
|
|
|
759
|
+
// 1. ON SUPPRIME LE PROMPT VISUEL (Plus de "Pilot ❯")
|
|
759
760
|
const rl = readline.createInterface({
|
|
760
761
|
input: process.stdin,
|
|
761
|
-
output: process.stdout
|
|
762
|
-
prompt: `\x1b[34m${dynamicUsername} ❯ \x1b[0m`
|
|
762
|
+
output: process.stdout
|
|
763
763
|
});
|
|
764
|
-
|
|
765
|
-
process.stdout.write('\n\x1b[F');
|
|
766
|
-
rl.prompt();
|
|
767
764
|
|
|
768
765
|
// LE BOUCLIER ANTI CTRL+C (SIGINT)
|
|
769
766
|
rl.on('SIGINT', () => {
|
|
770
767
|
console.log('\n\x1b[90m Alex session aborted (Ctrl+C).\x1b[0m');
|
|
771
768
|
process.stdout.write('[ALEX_OFFLINE]\n'); // Prévient React !
|
|
772
769
|
rl.close();
|
|
773
|
-
process.exit(0);
|
|
770
|
+
process.exit(0);
|
|
774
771
|
});
|
|
775
772
|
|
|
776
773
|
let standardBuffer = [];
|
|
777
774
|
let isProcessing = false;
|
|
778
|
-
let isPasteMode = false;
|
|
779
|
-
let pasteBlockerTimer = null;
|
|
780
775
|
|
|
781
776
|
const executePrompt = async (text) => {
|
|
782
777
|
if (['exit', 'quit'].includes(text.toLowerCase())) {
|
|
783
778
|
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
784
|
-
process.stdout.write('[ALEX_OFFLINE]\n');
|
|
779
|
+
process.stdout.write('[ALEX_OFFLINE]\n');
|
|
785
780
|
rl.close();
|
|
786
781
|
return;
|
|
787
782
|
}
|
|
783
|
+
|
|
788
784
|
if (text !== "") {
|
|
789
785
|
if (text.length > 4000) {
|
|
790
786
|
console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${text.length}/4000 characters).\x1b[0m`);
|
|
791
|
-
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
792
|
-
rl.prompt();
|
|
793
787
|
return;
|
|
794
788
|
}
|
|
795
|
-
isProcessing = true;
|
|
796
|
-
rl.setPrompt("");
|
|
797
789
|
|
|
798
|
-
|
|
799
|
-
//process.stdout.write('[START_LOAD]\n');
|
|
790
|
+
isProcessing = true;
|
|
800
791
|
|
|
792
|
+
// 2. On exécute la requête sans faire de "rl.setPrompt()"
|
|
801
793
|
await processAlexRequest(text);
|
|
802
794
|
|
|
803
|
-
// 🛑 FIN DU PROCESSUS : On éteint l'overlay
|
|
804
|
-
//process.stdout.write('[END_LOAD]\n');
|
|
805
|
-
|
|
806
795
|
isProcessing = false;
|
|
807
|
-
console.log('');
|
|
808
|
-
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
809
|
-
rl.prompt();
|
|
810
|
-
} else {
|
|
811
|
-
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
812
|
-
rl.prompt();
|
|
796
|
+
console.log(''); // Petit saut de ligne esthétique quand Alex a fini
|
|
813
797
|
}
|
|
814
798
|
};
|
|
815
799
|
|
|
816
|
-
//
|
|
800
|
+
// 3. RÉCEPTEUR SILENCIEUX (Plus de "rl.prompt()" qui pollue l'écran)
|
|
817
801
|
let pasteTimer = null;
|
|
818
802
|
|
|
819
803
|
rl.on('line', async (line) => {
|
|
820
804
|
if (isProcessing) return;
|
|
821
805
|
|
|
822
|
-
// On empile toutes les lignes reçues (qu'elles viennent du clavier ou de React)
|
|
823
806
|
standardBuffer.push(line);
|
|
824
807
|
|
|
825
808
|
if (pasteTimer) clearTimeout(pasteTimer);
|
|
826
809
|
|
|
827
|
-
// Si plusieurs lignes arrivent en moins de 30ms (vitesse d'envoi de React),
|
|
828
|
-
// on les fusionne silencieusement en un seul gros prompt !
|
|
829
810
|
pasteTimer = setTimeout(async () => {
|
|
830
811
|
pasteTimer = null;
|
|
831
812
|
|
|
832
813
|
const finalPrompt = standardBuffer.join('\n').trim();
|
|
833
814
|
standardBuffer = [];
|
|
834
815
|
|
|
835
|
-
if (finalPrompt
|
|
836
|
-
rl.prompt();
|
|
837
|
-
} else {
|
|
816
|
+
if (finalPrompt !== "") {
|
|
838
817
|
await executePrompt(finalPrompt);
|
|
839
818
|
}
|
|
840
819
|
}, 30);
|