fleetbo-cockpit-cli 1.0.38 → 1.0.39
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 +16 -27
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -213,8 +213,8 @@ if (command === 'alex') {
|
|
|
213
213
|
const initialPrompt = args.slice(1).join(' ');
|
|
214
214
|
|
|
215
215
|
const processAlexRequest = async (prompt) => {
|
|
216
|
-
if (prompt.length >
|
|
217
|
-
console.log('\n\x1b[31m⛔ [Alex Safety] Request too long (' + prompt.length + '/
|
|
216
|
+
if (prompt.length > 1000) {
|
|
217
|
+
console.log('\n\x1b[31m⛔ [Alex Safety] Request too long (' + prompt.length + '/1000 chars).\x1b[0m');
|
|
218
218
|
console.log('\x1b[90mAlex prefers concise instructions. Please summarize.\x1b[0m');
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
@@ -460,55 +460,44 @@ if (command === 'alex') {
|
|
|
460
460
|
rl.prompt();
|
|
461
461
|
|
|
462
462
|
// --- LOGIQUE DE BUFFER MULTILIGNE ---
|
|
463
|
-
let inputBuffer = "";
|
|
464
|
-
|
|
465
|
-
let isProcessing = false;
|
|
466
|
-
let pasteDebounceTimer = null;
|
|
467
|
-
|
|
468
|
-
rl.on('line', async (line) => {
|
|
469
|
-
if (isProcessing) return; // Blocage de sécurité pendant qu'Alex forge
|
|
463
|
+
let inputBuffer = "";
|
|
464
|
+
let pasteTimer = null; // Debouncer for fast input streams
|
|
470
465
|
|
|
466
|
+
rl.on('line', (line) => {
|
|
471
467
|
const trimmedLine = line.trim();
|
|
472
468
|
|
|
473
|
-
//
|
|
469
|
+
// Exit commands
|
|
474
470
|
if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
|
|
475
471
|
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
476
472
|
rl.close();
|
|
477
473
|
return;
|
|
478
474
|
}
|
|
479
475
|
|
|
480
|
-
//
|
|
476
|
+
// Accumulate all non-empty lines
|
|
481
477
|
if (trimmedLine !== "") {
|
|
482
478
|
inputBuffer += (inputBuffer ? "\n" : "") + line;
|
|
483
|
-
rl.setPrompt(`\x1b[34m > \x1b[0m`);
|
|
484
479
|
}
|
|
485
480
|
|
|
486
|
-
//
|
|
487
|
-
|
|
488
|
-
if (pasteDebounceTimer) clearTimeout(pasteDebounceTimer);
|
|
481
|
+
// DEBOUNCE LOGIC : Wait 50ms of silence before checking validation
|
|
482
|
+
if (pasteTimer) clearTimeout(pasteTimer);
|
|
489
483
|
|
|
490
|
-
|
|
491
|
-
//
|
|
492
|
-
// - La dernière touche pressée était "Entrée" sur une ligne VIDE
|
|
493
|
-
// - ET que le buffer n'est pas vide
|
|
484
|
+
pasteTimer = setTimeout(async () => {
|
|
485
|
+
// Trigger forge ONLY on an intentional EMPTY line + content in buffer
|
|
494
486
|
if (trimmedLine === "" && inputBuffer.trim() !== "") {
|
|
495
487
|
const finalPrompt = inputBuffer.trim();
|
|
496
|
-
inputBuffer = ""; //
|
|
488
|
+
inputBuffer = ""; // Flush immediately
|
|
497
489
|
|
|
498
490
|
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
499
|
-
|
|
500
|
-
isProcessing = true; // Verrouille l'entrée
|
|
501
491
|
await processAlexRequest(finalPrompt);
|
|
502
|
-
isProcessing = false; // Libère l'entrée
|
|
503
|
-
|
|
504
492
|
console.log('');
|
|
493
|
+
} else if (inputBuffer !== "") {
|
|
494
|
+
// Show we are still listening for the next line
|
|
495
|
+
rl.setPrompt(`\x1b[34m > \x1b[0m`);
|
|
505
496
|
}
|
|
506
497
|
|
|
507
|
-
// Rafraîchissement visuel du prompt
|
|
508
498
|
process.stdout.write('\n\x1b[F');
|
|
509
499
|
rl.prompt();
|
|
510
|
-
|
|
511
|
-
}, 50); // Pause de 50ms pour absorber les "Coller" massifs
|
|
500
|
+
}, 50); // 50ms absorbs the fastest "paste" bursts
|
|
512
501
|
});
|
|
513
502
|
};
|
|
514
503
|
|