@mumbrane/arrakis 0.8.1 → 0.8.2
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/package.json +1 -1
- package/src/cli.js +3 -0
- package/src/tui.js +25 -4
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -262,6 +262,9 @@ async function interactive({ agent, ui, prompts, config, cwd, firstPrompt, mcpSe
|
|
|
262
262
|
ui.completer = (line) => completer(line, cwd, [...BUILTIN_COMMANDS, ...[...loadCustomCommands(cwd).keys()].map((k) => `/${k}`)]);
|
|
263
263
|
// Recreate the line reader so it picks up completion and history.
|
|
264
264
|
if (ui instanceof FancyUI) {
|
|
265
|
+
// Take over the whole terminal: clear the visible screen (scrollback is
|
|
266
|
+
// kept) so the welcome sits at the top and the composer at the bottom.
|
|
267
|
+
ui.clearScreen({ keepScrollback: true });
|
|
265
268
|
ui.cwd = cwd;
|
|
266
269
|
const descriptions = Object.fromEntries(SLASH_HELP.split('\n').filter((l) => l.startsWith('/')).map((l) => [l.slice(1).split(/\s/)[0], l.replace(/^\/\S+(\s+\[[^\]]*\]|\s+<[^>]*>)?\s+/, '')]));
|
|
267
270
|
ui.commandList = () => [
|
package/src/tui.js
CHANGED
|
@@ -51,6 +51,10 @@ export class FancyUI extends UI {
|
|
|
51
51
|
this.transcript = [];
|
|
52
52
|
this.transcriptSize = 0;
|
|
53
53
|
this.lastCols = this.out.columns;
|
|
54
|
+
// Rows of the screen filled by printed output since the last clear. Until
|
|
55
|
+
// the screen is full, blank rows pad the gap so the composer sits at the
|
|
56
|
+
// bottom; after that the conversation scrolls normally.
|
|
57
|
+
this.contentRows = 0;
|
|
54
58
|
this.onResize = () => {
|
|
55
59
|
clearTimeout(this.resizeTimer);
|
|
56
60
|
this.resizeTimer = setTimeout(() => this.handleResize(), 60);
|
|
@@ -539,23 +543,33 @@ export class FancyUI extends UI {
|
|
|
539
543
|
}
|
|
540
544
|
this.eraseRegion();
|
|
541
545
|
this.out.write(s);
|
|
546
|
+
this.contentRows = Math.min(this.out.rows || 24, this.contentRows + this.countRows(s));
|
|
542
547
|
this.drawRegion();
|
|
543
548
|
}
|
|
544
549
|
|
|
550
|
+
// Screen rows a chunk of output takes, counting wrapped lines.
|
|
551
|
+
countRows(s) {
|
|
552
|
+
const cols = Math.max(1, this.out.columns || 100);
|
|
553
|
+
const lines = s.split('\n');
|
|
554
|
+
if (lines.at(-1) === '') lines.pop();
|
|
555
|
+
return lines.reduce((n, l) => n + Math.max(1, Math.ceil(visibleLength(l) / cols)), 0);
|
|
556
|
+
}
|
|
557
|
+
|
|
545
558
|
// Clear the screen and scrollback, and forget what was printed, so a resize
|
|
546
559
|
// doesn't bring it back. The input area is redrawn by the next render.
|
|
547
|
-
clearScreen() {
|
|
560
|
+
clearScreen({ keepScrollback = false } = {}) {
|
|
548
561
|
this.thinkBuf = '';
|
|
549
562
|
this.md = null;
|
|
550
563
|
this.mode = null;
|
|
551
564
|
this.partial = '';
|
|
552
565
|
this.transcript = [];
|
|
553
566
|
this.transcriptSize = 0;
|
|
554
|
-
this.out.write('\x1b[2J\x1b[3J\x1b[H');
|
|
567
|
+
this.out.write(keepScrollback ? '\x1b[2J\x1b[H' : '\x1b[2J\x1b[3J\x1b[H');
|
|
555
568
|
this.regionRows = 0;
|
|
556
569
|
this.regionCursorRow = 0;
|
|
557
570
|
this.regionCursorCol = 0;
|
|
558
571
|
this.regionWidths = [];
|
|
572
|
+
this.contentRows = 0;
|
|
559
573
|
this.lastBlank = true;
|
|
560
574
|
this.atLineStart = true;
|
|
561
575
|
}
|
|
@@ -565,7 +579,9 @@ export class FancyUI extends UI {
|
|
|
565
579
|
if (cols === this.lastCols || !this.active) return this.render();
|
|
566
580
|
this.lastCols = cols;
|
|
567
581
|
// Clear screen and scrollback, reprint the conversation at the new width.
|
|
568
|
-
|
|
582
|
+
const all = this.transcript.join('');
|
|
583
|
+
this.out.write('\x1b[?25l\x1b[2J\x1b[3J\x1b[H' + all);
|
|
584
|
+
this.contentRows = Math.min(this.out.rows || 24, this.countRows(all));
|
|
569
585
|
this.regionRows = 0;
|
|
570
586
|
this.drawRegion();
|
|
571
587
|
}
|
|
@@ -731,7 +747,12 @@ export class FancyUI extends UI {
|
|
|
731
747
|
|
|
732
748
|
render() {
|
|
733
749
|
if (!this.active) return;
|
|
734
|
-
|
|
750
|
+
let { lines, cursorRow, cursorCol } = this.layout();
|
|
751
|
+
const gap = Math.max(0, (this.out.rows || 24) - this.contentRows - lines.length);
|
|
752
|
+
if (gap) {
|
|
753
|
+
lines = [...Array(gap).fill(''), ...lines];
|
|
754
|
+
cursorRow = cursorRow === null ? null : cursorRow + gap;
|
|
755
|
+
}
|
|
735
756
|
let s = '\x1b[?25l';
|
|
736
757
|
if (this.regionRows) {
|
|
737
758
|
const up = this.rowsAboveCursor();
|