@mumbrane/arrakis 0.8.1 → 0.8.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/package.json +1 -1
- package/src/cli.js +3 -0
- package/src/markdown.js +1 -1
- package/src/theme.js +21 -19
- package/src/tui.js +26 -5
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/markdown.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Streaming Markdown renderer for the terminal, in the
|
|
1
|
+
// Streaming Markdown renderer for the terminal, in the Spice style. Text
|
|
2
2
|
// arrives in chunks; each complete line is rendered as soon as its newline
|
|
3
3
|
// arrives. Tables are held until they end so their columns can be aligned.
|
|
4
4
|
|
package/src/theme.js
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
// "
|
|
1
|
+
// "Spice": arrakis's design language.
|
|
2
2
|
//
|
|
3
|
-
// A
|
|
4
|
-
// accents,
|
|
5
|
-
// carry meaning (success, caution, error) and are used sparingly.
|
|
3
|
+
// A desert palette: spice gold as the primary, burnt orange and ember as
|
|
4
|
+
// accents, sand for soft text, dark umber panels behind code. Sage, saffron
|
|
5
|
+
// and rose carry meaning (success, caution, error) and are used sparingly.
|
|
6
|
+
// (The keys below name roles, kept from earlier themes: `violet` is the
|
|
7
|
+
// primary color, `orchid` the hot accent, `lilac` the soft text, and so on.)
|
|
6
8
|
//
|
|
7
9
|
// Colors render in 24-bit where the terminal supports it and fall back to the
|
|
8
10
|
// nearest 256-color value elsewhere (e.g. macOS Terminal.app). NO_COLOR turns
|
|
9
11
|
// everything off.
|
|
10
12
|
|
|
11
13
|
export const PALETTE = {
|
|
12
|
-
violet: [
|
|
13
|
-
iris: [
|
|
14
|
-
orchid: [
|
|
15
|
-
lilac: [
|
|
16
|
-
mist: [
|
|
17
|
-
dusk: [
|
|
18
|
-
mint: [
|
|
19
|
-
amber: [
|
|
20
|
-
rose: [
|
|
21
|
-
sky: [
|
|
22
|
-
ink: [
|
|
23
|
-
panel: [
|
|
24
|
-
raise: [
|
|
25
|
-
addBg: [
|
|
26
|
-
delBg: [
|
|
14
|
+
violet: [232, 166, 64], // primary: spice gold
|
|
15
|
+
iris: [196, 104, 38], // deep accent: burnt orange
|
|
16
|
+
orchid: [244, 128, 52], // hot accent: ember
|
|
17
|
+
lilac: [240, 226, 196], // soft text: sand
|
|
18
|
+
mist: [156, 144, 124], // muted text: dune
|
|
19
|
+
dusk: [96, 86, 70], // faint lines
|
|
20
|
+
mint: [150, 208, 130], // success: sage
|
|
21
|
+
amber: [242, 206, 108], // caution / numbers: saffron
|
|
22
|
+
rose: [238, 110, 110],
|
|
23
|
+
sky: [124, 196, 210], // functions, links: oasis teal
|
|
24
|
+
ink: [26, 19, 11], // text on gold chips
|
|
25
|
+
panel: [40, 32, 22], // code panels: umber
|
|
26
|
+
raise: [58, 45, 28], // selected rows, your messages
|
|
27
|
+
addBg: [28, 50, 30],
|
|
28
|
+
delBg: [64, 28, 26],
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
const env = process.env;
|
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);
|
|
@@ -185,7 +189,7 @@ export class FancyUI extends UI {
|
|
|
185
189
|
}
|
|
186
190
|
}
|
|
187
191
|
|
|
188
|
-
// Your message: a raised
|
|
192
|
+
// Your message: a raised gold-edged panel across the full width, so it stands
|
|
189
193
|
// apart from both the terminal and arrakis's replies.
|
|
190
194
|
echoUser(text) {
|
|
191
195
|
const c = this.c;
|
|
@@ -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();
|