fleetbo-cockpit-cli 1.0.141 → 1.0.142
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 +34 -24
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -643,8 +643,8 @@ if (command === 'alex') {
|
|
|
643
643
|
let isProcessing = false;
|
|
644
644
|
let submitTimeout = null;
|
|
645
645
|
let isPasting = false;
|
|
646
|
+
let lastLineTime = Date.now(); // ⏱️ LE CHRONOMÈTRE MAGIQUE
|
|
646
647
|
|
|
647
|
-
// Fonction d'exécution isolée pour plus de propreté
|
|
648
648
|
const executePrompt = async (text) => {
|
|
649
649
|
if (['exit', 'quit'].includes(text.toLowerCase())) {
|
|
650
650
|
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
@@ -674,46 +674,56 @@ if (command === 'alex') {
|
|
|
674
674
|
rl.on('line', async (line) => {
|
|
675
675
|
if (isProcessing) return;
|
|
676
676
|
|
|
677
|
-
|
|
677
|
+
const now = Date.now();
|
|
678
|
+
const timeSinceLastLine = now - lastLineTime;
|
|
679
|
+
lastLineTime = now;
|
|
680
|
+
|
|
681
|
+
// 1. FIN DU MODE COLLAGE : On vérifie que c'est une ligne vide ET qu'elle vient d'un humain (> 150ms)
|
|
678
682
|
if (isPasting && line.trim() === "") {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
683
|
+
if (timeSinceLastLine > 150) {
|
|
684
|
+
const finalPrompt = inputBuffer.trim();
|
|
685
|
+
inputBuffer = "";
|
|
686
|
+
isPasting = false;
|
|
687
|
+
await executePrompt(finalPrompt);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
// Si c'est < 150ms, c'est juste un paragraphe vide dans le texte copié ! On l'ignore et on accumule.
|
|
684
691
|
}
|
|
685
692
|
|
|
686
693
|
// 2. On accumule la donnée
|
|
687
694
|
inputBuffer += (inputBuffer ? "\n" : "") + line;
|
|
688
695
|
|
|
689
|
-
// 3. Si on est DÉJÀ en mode paste, on
|
|
696
|
+
// 3. Si on est DÉJÀ en mode paste, on s'arrête là (accumulation silencieuse)
|
|
690
697
|
if (isPasting) return;
|
|
691
698
|
|
|
692
|
-
// 4. DÉTECTEUR DE
|
|
693
|
-
if (
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
699
|
+
// 4. DÉTECTEUR DE VITESSE : Si une ligne arrive à la vitesse de la lumière (< 50ms), c'est un copier-coller !
|
|
700
|
+
if (timeSinceLastLine < 50) {
|
|
701
|
+
if (submitTimeout) {
|
|
702
|
+
clearTimeout(submitTimeout);
|
|
703
|
+
submitTimeout = null;
|
|
704
|
+
}
|
|
705
|
+
isPasting = true; // 🚨 Passage en mode manuel !
|
|
697
706
|
return;
|
|
698
707
|
}
|
|
699
708
|
|
|
700
|
-
// 5. FRAPPE NORMALE : On lance le chrono
|
|
709
|
+
// 5. FRAPPE NORMALE : On lance le chrono
|
|
710
|
+
if (submitTimeout) clearTimeout(submitTimeout);
|
|
711
|
+
|
|
701
712
|
submitTimeout = setTimeout(async () => {
|
|
702
713
|
submitTimeout = null;
|
|
703
714
|
|
|
704
|
-
//
|
|
705
|
-
|
|
706
|
-
// L'IA annule l'envoi automatique et passe en mode Paste manuel.
|
|
707
|
-
if (rl.line && rl.line.length > 0) {
|
|
708
|
-
isPasting = true;
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
715
|
+
// Si on a basculé en mode paste entre temps (suite d'un collage), on annule l'envoi auto
|
|
716
|
+
if (isPasting) return;
|
|
711
717
|
|
|
712
|
-
// Envoi direct ! (Car c'est bien une frappe humaine unique)
|
|
713
718
|
const finalPrompt = inputBuffer.trim();
|
|
714
719
|
inputBuffer = "";
|
|
715
|
-
|
|
716
|
-
|
|
720
|
+
|
|
721
|
+
if (finalPrompt === "") {
|
|
722
|
+
rl.prompt(); // L'utilisateur a juste fait Entrée dans le vide
|
|
723
|
+
} else {
|
|
724
|
+
await executePrompt(finalPrompt); // Envoi direct
|
|
725
|
+
}
|
|
726
|
+
}, 50);
|
|
717
727
|
});
|
|
718
728
|
};
|
|
719
729
|
|