fleetbo-cockpit-cli 1.0.139 → 1.0.141

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.
Files changed (2) hide show
  1. package/cli.js +63 -37
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -641,53 +641,79 @@ if (command === 'alex') {
641
641
 
642
642
  let inputBuffer = "";
643
643
  let isProcessing = false;
644
- let pasteTimeout = null;
644
+ let submitTimeout = null;
645
+ let isPasting = false;
646
+
647
+ // Fonction d'exécution isolée pour plus de propreté
648
+ const executePrompt = async (text) => {
649
+ if (['exit', 'quit'].includes(text.toLowerCase())) {
650
+ console.log('\n\x1b[90m Alex session closed.\x1b[0m');
651
+ rl.close();
652
+ return;
653
+ }
654
+ if (text !== "") {
655
+ if (text.length > 4000) {
656
+ console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${text.length}/4000 characters).\x1b[0m`);
657
+ rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
658
+ rl.prompt();
659
+ return;
660
+ }
661
+ isProcessing = true;
662
+ rl.setPrompt("");
663
+ await processAlexRequest(text);
664
+ isProcessing = false;
665
+ console.log('');
666
+ rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
667
+ rl.prompt();
668
+ } else {
669
+ rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
670
+ rl.prompt();
671
+ }
672
+ };
645
673
 
646
674
  rl.on('line', async (line) => {
647
675
  if (isProcessing) return;
648
676
 
649
- // 1. On accumule les lignes (utile pour le copier-coller rapide)
677
+ // 1. FIN DU MODE COPIER-COLLER : L'utilisateur appuie manuellement sur Entrée (ligne vide)
678
+ if (isPasting && line.trim() === "") {
679
+ const finalPrompt = inputBuffer.trim();
680
+ inputBuffer = "";
681
+ isPasting = false; // Désactivation du mode
682
+ await executePrompt(finalPrompt);
683
+ return;
684
+ }
685
+
686
+ // 2. On accumule la donnée
650
687
  inputBuffer += (inputBuffer ? "\n" : "") + line;
651
688
 
652
- // 2. On annule le timer précédent si une nouvelle ligne arrive
653
- if (pasteTimeout) clearTimeout(pasteTimeout);
689
+ // 3. Si on est DÉJÀ en mode paste, on accumule silencieusement et on attend ton feu vert
690
+ if (isPasting) return;
654
691
 
655
- // 3. On lance un micro-timer de 30ms
656
- pasteTimeout = setTimeout(async () => {
657
- const finalPrompt = inputBuffer.trim();
658
- inputBuffer = ""; // On vide le buffer pour la prochaine fois
692
+ // 4. DÉTECTEUR DE COPIER-COLLER : Si un timer est déjà en cours, c'est la 2ème ligne instantanée !
693
+ if (submitTimeout) {
694
+ clearTimeout(submitTimeout);
695
+ submitTimeout = null;
696
+ isPasting = true; // 🚨 L'IA comprend que tu colles et passe en mode Manuel
697
+ return;
698
+ }
659
699
 
660
- // Gestion de la sortie
661
- if (['exit', 'quit'].includes(finalPrompt.toLowerCase())) {
662
- console.log('\n\x1b[90m Alex session closed.\x1b[0m');
663
- rl.close();
664
- return;
700
+ // 5. FRAPPE NORMALE : On lance le chrono de 30ms
701
+ submitTimeout = setTimeout(async () => {
702
+ submitTimeout = null;
703
+
704
+ // 🛡️ SÉCURITÉ MAGIQUE : Si le terminal a encore des caractères non validés en mémoire (rl.line),
705
+ // c'est que tu as collé un texte sans saut de ligne final.
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;
665
710
  }
666
711
 
667
- // Envoi si le texte final n'est pas vide
668
- if (finalPrompt !== "") {
669
- if (finalPrompt.length > 4000) {
670
- console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${finalPrompt.length}/4000 characters).\x1b[0m`);
671
- rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
672
- rl.prompt();
673
- return;
674
- }
675
-
676
- // On verrouille et on envoie
677
- isProcessing = true;
678
- rl.setPrompt("");
679
-
680
- await processAlexRequest(finalPrompt);
681
-
682
- // On libère
683
- isProcessing = false;
684
- console.log('');
685
- rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
686
- rl.prompt();
687
- } else {
688
- rl.prompt();
689
- }
690
- }, 30); // ⏱️ 30 millisecondes d'attente
712
+ // Envoi direct ! (Car c'est bien une frappe humaine unique)
713
+ const finalPrompt = inputBuffer.trim();
714
+ inputBuffer = "";
715
+ await executePrompt(finalPrompt);
716
+ }, 30);
691
717
  });
692
718
  };
693
719
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.139",
3
+ "version": "1.0.141",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",