fleetbo-cockpit-cli 1.0.148 → 1.0.149
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 +53 -42
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -639,58 +639,69 @@ if (command === 'alex') {
|
|
|
639
639
|
process.stdout.write('\n\x1b[F');
|
|
640
640
|
rl.prompt();
|
|
641
641
|
|
|
642
|
-
let inputBuffer =
|
|
642
|
+
let inputBuffer = [];
|
|
643
643
|
let isProcessing = false;
|
|
644
|
-
let
|
|
644
|
+
let isPasteMode = false;
|
|
645
645
|
|
|
646
|
-
|
|
647
|
-
if (
|
|
648
|
-
|
|
649
|
-
const trimmedLine = line.trim();
|
|
650
|
-
|
|
651
|
-
if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
|
|
646
|
+
const executePrompt = async (text) => {
|
|
647
|
+
if (['exit', 'quit'].includes(text.toLowerCase())) {
|
|
652
648
|
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
653
649
|
rl.close();
|
|
654
650
|
return;
|
|
655
651
|
}
|
|
652
|
+
if (text !== "") {
|
|
653
|
+
if (text.length > 4000) {
|
|
654
|
+
console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${text.length}/4000 characters).\x1b[0m`);
|
|
655
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
656
|
+
rl.prompt();
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
isProcessing = true;
|
|
660
|
+
rl.setPrompt("");
|
|
661
|
+
await processAlexRequest(text);
|
|
662
|
+
isProcessing = false;
|
|
663
|
+
console.log('');
|
|
664
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
665
|
+
rl.prompt();
|
|
666
|
+
} else {
|
|
667
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
668
|
+
rl.prompt();
|
|
669
|
+
}
|
|
670
|
+
};
|
|
656
671
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
inputBuffer += (inputBuffer ? "\n" : "") + line;
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
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
|
-
}
|
|
680
|
-
|
|
681
|
-
isProcessing = true;
|
|
682
|
-
rl.setPrompt("");
|
|
683
|
-
await processAlexRequest(finalPrompt);
|
|
684
|
-
isProcessing = false;
|
|
672
|
+
rl.on('line', async (line) => {
|
|
673
|
+
if (isProcessing) return;
|
|
685
674
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
675
|
+
// 1. SI LE MODE COLLAGE EST ACTIF
|
|
676
|
+
if (isPasteMode) {
|
|
677
|
+
// Dès que tu tapes EOF, on assemble tout le texte et on l'envoie à Alex
|
|
678
|
+
if (['/s', '/send', 'eof'].includes(line.trim().toLowerCase())) {
|
|
679
|
+
const finalPrompt = inputBuffer.join('\n').trim();
|
|
680
|
+
inputBuffer = [];
|
|
681
|
+
isPasteMode = false;
|
|
682
|
+
await executePrompt(finalPrompt);
|
|
690
683
|
} else {
|
|
691
|
-
|
|
692
|
-
|
|
684
|
+
// On accumule le texte collé silencieusement
|
|
685
|
+
inputBuffer.push(line);
|
|
693
686
|
}
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// 2. ACTIVATION DU MODE COLLAGE
|
|
691
|
+
if (['/paste', '/p'].includes(line.trim().toLowerCase())) {
|
|
692
|
+
isPasteMode = true;
|
|
693
|
+
console.log('\x1b[36m [MULTILINE MODE] Paste your content below. Type /s on a new line to submit.\x1b[0m');
|
|
694
|
+
// On efface le prompt "jojo ❯" pour que ton code collé s'affiche parfaitement !
|
|
695
|
+
rl.setPrompt("");
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// 3. MODE CHAT CLASSIQUE (1 Entrée = 1 Envoi)
|
|
700
|
+
const finalPrompt = line.trim();
|
|
701
|
+
if (finalPrompt === "") {
|
|
702
|
+
rl.prompt(); // Touche Entrée dans le vide
|
|
703
|
+
} else {
|
|
704
|
+
await executePrompt(finalPrompt); // Envoi instantané
|
|
694
705
|
}
|
|
695
706
|
});
|
|
696
707
|
};
|