prior-cli 1.2.1 → 1.2.3
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/bin/prior.js +16 -27
- package/package.json +1 -1
package/bin/prior.js
CHANGED
|
@@ -401,35 +401,24 @@ function renderToolSkip(name) {
|
|
|
401
401
|
process.stdout.write(` ${c.warn('⊘')} ${c.muted(name)} ${c.dim('skipped')}\n`);
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
// ──
|
|
404
|
+
// ── Confirm prompt (Enter-based, no raw mode) ─────────────────
|
|
405
405
|
function askConfirmKey(promptText, rl) {
|
|
406
406
|
return new Promise(resolve => {
|
|
407
|
-
process.stdout.
|
|
408
|
-
|
|
409
|
-
if (!process.stdout.isTTY || !process.stdin.isTTY) {
|
|
410
|
-
process.stdout.write(c.ok('y') + '\n');
|
|
407
|
+
if (!process.stdout.isTTY || !process.stdin.isTTY || !rl) {
|
|
408
|
+
process.stdout.write(` ${c.muted('┤')} ${promptText} ${c.muted('[Y/n]')} ${c.ok('y')}\n\n`);
|
|
411
409
|
return resolve(true);
|
|
412
410
|
}
|
|
413
411
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const key = ch.toLowerCase();
|
|
426
|
-
if (key === '\u0003') { process.stdout.write('\n'); process.exit(0); }
|
|
427
|
-
if (key === 'n') { process.stdout.write(c.err('n') + '\n\n'); return resolve(false); }
|
|
428
|
-
process.stdout.write(c.ok('y') + '\n\n');
|
|
429
|
-
resolve(true);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
process.stdin.on('data', handler);
|
|
412
|
+
rl.question(` ${c.muted('┤')} ${promptText} ${c.muted('[Y/n]')} `, ans => {
|
|
413
|
+
const key = (ans || '').trim().toLowerCase();
|
|
414
|
+
if (key === 'n' || key === 'no') {
|
|
415
|
+
process.stdout.write('\n');
|
|
416
|
+
resolve(false);
|
|
417
|
+
} else {
|
|
418
|
+
process.stdout.write('\n');
|
|
419
|
+
resolve(true);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
433
422
|
});
|
|
434
423
|
}
|
|
435
424
|
|
|
@@ -592,14 +581,14 @@ async function startChat(opts = {}) {
|
|
|
592
581
|
clearSuggestions();
|
|
593
582
|
if (!matches.length) return;
|
|
594
583
|
_suggCount = matches.length;
|
|
584
|
+
process.stdout.write('\x1b[s'); // save cursor first (at end of typed input)
|
|
595
585
|
// Print newlines to scroll terminal and guarantee room below the prompt
|
|
596
586
|
process.stdout.write('\n'.repeat(matches.length));
|
|
597
|
-
process.stdout.write(`\x1b[${matches.length}A`); // move cursor back up
|
|
598
|
-
process.stdout.write('\x1b[s'); // save cursor (now at prompt line)
|
|
587
|
+
process.stdout.write(`\x1b[${matches.length}A`); // move cursor back up to prompt line
|
|
599
588
|
for (const { cmd, desc } of matches) {
|
|
600
589
|
process.stdout.write(`\x1b[B\r\x1b[2K${c.brand(' ' + cmd.padEnd(14))}${c.dim(desc)}`);
|
|
601
590
|
}
|
|
602
|
-
process.stdout.write('\x1b[u');
|
|
591
|
+
process.stdout.write('\x1b[u'); // restore cursor to end of typed input
|
|
603
592
|
}
|
|
604
593
|
|
|
605
594
|
process.stdin.on('keypress', (ch, key) => {
|