groundcrew-cli 0.14.1 → 0.15.0
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/dist/index.js +13 -19
- package/package.json +1 -1
- package/src/index.ts +16 -23
package/dist/index.js
CHANGED
|
@@ -415,35 +415,29 @@ function chatCompleter(line) {
|
|
|
415
415
|
return [[], line];
|
|
416
416
|
}
|
|
417
417
|
function setupInlineSuggestions(rl) {
|
|
418
|
-
let
|
|
418
|
+
let hasGhost = false;
|
|
419
419
|
const clearGhost = () => {
|
|
420
|
-
if (
|
|
421
|
-
process.stdout.write("\x1B["
|
|
422
|
-
|
|
423
|
-
lastGhostLen = 0;
|
|
420
|
+
if (hasGhost) {
|
|
421
|
+
process.stdout.write("\x1B[u\x1B[K");
|
|
422
|
+
hasGhost = false;
|
|
424
423
|
}
|
|
425
424
|
};
|
|
426
425
|
const showGhost = () => {
|
|
427
426
|
const line = rl.line;
|
|
428
427
|
if (!line || !line.startsWith("/") || line.includes(" ")) {
|
|
429
|
-
clearGhost();
|
|
430
428
|
return;
|
|
431
429
|
}
|
|
432
430
|
const matches = CHAT_COMMANDS.filter((c) => c.cmd.startsWith(line));
|
|
433
|
-
if (matches.length === 0)
|
|
434
|
-
clearGhost();
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
431
|
+
if (matches.length === 0) return;
|
|
437
432
|
const best = matches[0];
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
433
|
+
const remainder = best.cmd.slice(line.length);
|
|
434
|
+
if (!remainder && matches.length === 1) return;
|
|
435
|
+
const ghost = `${remainder} \u2014 ${best.desc}`;
|
|
436
|
+
process.stdout.write("\x1B[s");
|
|
437
|
+
process.stdout.write("\x1B[K");
|
|
438
|
+
process.stdout.write(`\x1B[2m${ghost}\x1B[0m`);
|
|
439
|
+
process.stdout.write("\x1B[u");
|
|
440
|
+
hasGhost = true;
|
|
447
441
|
};
|
|
448
442
|
process.stdin.on("keypress", (_ch, key) => {
|
|
449
443
|
if (!key) return;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -544,44 +544,37 @@ function chatCompleter(line: string): [string[], string] {
|
|
|
544
544
|
* Renders dimmed text after cursor, erased on next keystroke.
|
|
545
545
|
*/
|
|
546
546
|
function setupInlineSuggestions(rl: readline.Interface): void {
|
|
547
|
-
let
|
|
547
|
+
let hasGhost = false;
|
|
548
548
|
|
|
549
549
|
const clearGhost = () => {
|
|
550
|
-
if (
|
|
551
|
-
//
|
|
552
|
-
process.stdout.write("\x1b["
|
|
553
|
-
|
|
554
|
-
lastGhostLen = 0;
|
|
550
|
+
if (hasGhost) {
|
|
551
|
+
// Restore cursor to where user was typing, clear everything after
|
|
552
|
+
process.stdout.write("\x1b[u\x1b[K");
|
|
553
|
+
hasGhost = false;
|
|
555
554
|
}
|
|
556
555
|
};
|
|
557
556
|
|
|
558
557
|
const showGhost = () => {
|
|
559
558
|
const line = (rl as any).line as string;
|
|
560
559
|
if (!line || !line.startsWith("/") || line.includes(" ")) {
|
|
561
|
-
clearGhost();
|
|
562
560
|
return;
|
|
563
561
|
}
|
|
564
562
|
|
|
565
563
|
const matches = CHAT_COMMANDS.filter((c) => c.cmd.startsWith(line));
|
|
566
|
-
if (matches.length === 0)
|
|
567
|
-
clearGhost();
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
564
|
+
if (matches.length === 0) return;
|
|
570
565
|
|
|
571
|
-
// Show best match as ghost
|
|
572
566
|
const best = matches[0];
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
const rawLen = ghost.length + ` — ${best.desc}`.length;
|
|
567
|
+
const remainder = best.cmd.slice(line.length);
|
|
568
|
+
if (!remainder && matches.length === 1) return;
|
|
576
569
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
570
|
+
const ghost = `${remainder} \u2014 ${best.desc}`;
|
|
571
|
+
|
|
572
|
+
// Save cursor, write dimmed ghost, restore cursor
|
|
573
|
+
process.stdout.write("\x1b[s"); // save cursor position
|
|
574
|
+
process.stdout.write("\x1b[K"); // clear to end of line (remove old ghost)
|
|
575
|
+
process.stdout.write(`\x1b[2m${ghost}\x1b[0m`); // write dimmed ghost
|
|
576
|
+
process.stdout.write("\x1b[u"); // restore cursor to typing position
|
|
577
|
+
hasGhost = true;
|
|
585
578
|
};
|
|
586
579
|
|
|
587
580
|
// Listen to keypresses
|