fleetbo-cockpit-cli 1.0.129 → 1.0.131
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 +57 -31
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -250,8 +250,8 @@ if (command === 'alex') {
|
|
|
250
250
|
const initialPrompt = args.slice(1).join(' ');
|
|
251
251
|
|
|
252
252
|
const processAlexRequest = async (prompt) => {
|
|
253
|
-
if (prompt.length >
|
|
254
|
-
console.log('\n\x1b[31m⛔ [Alex Safety] Request too long (' + prompt.length + '/
|
|
253
|
+
if (prompt.length > 4000) {
|
|
254
|
+
console.log('\n\x1b[31m⛔ [Alex Safety] Request too long (' + prompt.length + '/4000 chars).\x1b[0m');
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
257
|
|
|
@@ -639,48 +639,74 @@ if (command === 'alex') {
|
|
|
639
639
|
process.stdout.write('\n\x1b[F');
|
|
640
640
|
rl.prompt();
|
|
641
641
|
|
|
642
|
-
let inputBuffer = "";
|
|
643
|
-
let isProcessing = false;
|
|
642
|
+
let inputBuffer = "";
|
|
643
|
+
let isProcessing = false;
|
|
644
|
+
let hintTimer = null;
|
|
645
|
+
let submitTimer = null;
|
|
646
|
+
|
|
647
|
+
const showHint = () => {
|
|
648
|
+
if (hintTimer) clearTimeout(hintTimer);
|
|
649
|
+
hintTimer = setTimeout(() => {
|
|
650
|
+
hintTimer = null;
|
|
651
|
+
if (inputBuffer.trim() !== "" && !isProcessing) {
|
|
652
|
+
rl.setPrompt("\x1b[90m ↵ again to send\x1b[0m");
|
|
653
|
+
rl.prompt();
|
|
654
|
+
}
|
|
655
|
+
}, 400);
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
const doSubmit = async () => {
|
|
659
|
+
if (hintTimer) { clearTimeout(hintTimer); hintTimer = null; }
|
|
660
|
+
if (submitTimer) { clearTimeout(submitTimer); submitTimer = null; }
|
|
661
|
+
if (isProcessing || inputBuffer.trim() === "") return;
|
|
662
|
+
|
|
663
|
+
const finalPrompt = inputBuffer.trim();
|
|
664
|
+
inputBuffer = "";
|
|
665
|
+
|
|
666
|
+
if (finalPrompt.length > 4000) {
|
|
667
|
+
console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${finalPrompt.length}/4000 characters).\x1b[0m`);
|
|
668
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
669
|
+
rl.prompt();
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
isProcessing = true;
|
|
674
|
+
rl.setPrompt("");
|
|
675
|
+
await processAlexRequest(finalPrompt);
|
|
676
|
+
isProcessing = false;
|
|
677
|
+
|
|
678
|
+
console.log('');
|
|
679
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
680
|
+
rl.prompt();
|
|
681
|
+
};
|
|
644
682
|
|
|
645
683
|
rl.on('line', async (line) => {
|
|
646
|
-
if (isProcessing) return;
|
|
684
|
+
if (isProcessing) return;
|
|
647
685
|
|
|
648
686
|
const trimmedLine = line.trim();
|
|
649
687
|
|
|
650
|
-
if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
|
|
688
|
+
if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
|
|
651
689
|
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
652
|
-
rl.close();
|
|
653
|
-
return;
|
|
690
|
+
rl.close();
|
|
691
|
+
return;
|
|
654
692
|
}
|
|
655
693
|
|
|
656
694
|
if (trimmedLine !== "") {
|
|
695
|
+
// Ligne non-vide : annule submit en attente (paste avec ligne vide interne)
|
|
696
|
+
if (submitTimer) { clearTimeout(submitTimer); submitTimer = null; }
|
|
657
697
|
inputBuffer += (inputBuffer ? "\n" : "") + line;
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
698
|
+
// Hint affiché 400ms après la dernière ligne — jamais pendant un paste
|
|
699
|
+
showHint();
|
|
700
|
+
} else {
|
|
662
701
|
if (inputBuffer.trim() !== "") {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
if (
|
|
667
|
-
|
|
668
|
-
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
669
|
-
rl.prompt();
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
isProcessing = true;
|
|
674
|
-
rl.setPrompt("");
|
|
675
|
-
await processAlexRequest(finalPrompt);
|
|
676
|
-
isProcessing = false;
|
|
677
|
-
|
|
678
|
-
console.log('');
|
|
679
|
-
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
680
|
-
rl.prompt();
|
|
702
|
+
// Ligne vide : annule le hint, attend 400ms pour soumettre
|
|
703
|
+
// Si une ligne non-vide arrive → submitTimer annulé (paste continue)
|
|
704
|
+
if (hintTimer) { clearTimeout(hintTimer); hintTimer = null; }
|
|
705
|
+
if (submitTimer) clearTimeout(submitTimer);
|
|
706
|
+
submitTimer = setTimeout(() => doSubmit(), 400);
|
|
681
707
|
} else {
|
|
682
708
|
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
683
|
-
rl.prompt();
|
|
709
|
+
rl.prompt();
|
|
684
710
|
}
|
|
685
711
|
}
|
|
686
712
|
});
|