@mumbrane/arrakis 0.8.0 → 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/README.md +1 -1
- package/package.json +1 -1
- package/src/cli.js +24 -13
- package/src/tui.js +43 -4
- package/src/ui.js +7 -0
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ In a session:
|
|
|
69
69
|
| `/compact` | Summarize history to free up context |
|
|
70
70
|
| `/model [name]` | Pick a model from your provider |
|
|
71
71
|
| `/provider` | Switch provider or update your API key |
|
|
72
|
-
| `/clear` |
|
|
72
|
+
| `/clear` | Clear the screen and start a fresh session (the old one stays saved) |
|
|
73
73
|
| `/yolo` | Toggle running tool calls without asking |
|
|
74
74
|
| `/exit` | Quit (or Ctrl-D) |
|
|
75
75
|
|
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 = () => [
|
|
@@ -313,17 +316,19 @@ async function interactive({ agent, ui, prompts, config, cwd, firstPrompt, mcpSe
|
|
|
313
316
|
return parts.join(' · ');
|
|
314
317
|
};
|
|
315
318
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
319
|
+
state.showBanner = () =>
|
|
320
|
+
ui.banner({
|
|
321
|
+
version: VERSION,
|
|
322
|
+
model: config.model,
|
|
323
|
+
provider: config.providerName || config.baseUrl,
|
|
324
|
+
cwd,
|
|
325
|
+
instructions: loadProjectInstructions(cwd).filter((i) => i.text.trim()).map((i) => i.file),
|
|
326
|
+
resumed: agent.session.messages.length ? `resumed ${agent.session.id} (${agent.session.messages.length} messages)` : '',
|
|
327
|
+
mcp: mcpServers,
|
|
328
|
+
hooks,
|
|
329
|
+
update,
|
|
330
|
+
});
|
|
331
|
+
state.showBanner();
|
|
327
332
|
|
|
328
333
|
const send = async (text) => {
|
|
329
334
|
const { content, attached, errors } = buildMessage(text, cwd, state.pastedImages.splice(0));
|
|
@@ -541,12 +546,18 @@ async function slashCommand(text, { agent, ui, prompts, config, cwd, state }) {
|
|
|
541
546
|
case 'exit':
|
|
542
547
|
case 'quit':
|
|
543
548
|
return 'exit';
|
|
544
|
-
case 'clear':
|
|
549
|
+
case 'clear': {
|
|
550
|
+
const previous = agent.session.messages.length ? agent.session.id : null;
|
|
545
551
|
agent.session = Session.create({ cwd, model: config.model });
|
|
546
552
|
agent.checkpoints = new Checkpoints(agent.session.file);
|
|
547
553
|
agent.systemPrompt = null;
|
|
548
|
-
|
|
554
|
+
agent.todos = [];
|
|
555
|
+
agent.notes = [];
|
|
556
|
+
ui.clearScreen();
|
|
557
|
+
state.showBanner?.();
|
|
558
|
+
if (previous) ui.info(` Fresh start. The previous conversation is saved: /resume or arrakis -r ${previous}`);
|
|
549
559
|
break;
|
|
560
|
+
}
|
|
550
561
|
case 'compact': {
|
|
551
562
|
const ac = new AbortController();
|
|
552
563
|
agent.abort = ac;
|
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);
|
|
@@ -333,8 +337,8 @@ export class FancyUI extends UI {
|
|
|
333
337
|
const nl = this.buffer.indexOf('\n', this.cursor);
|
|
334
338
|
this.buffer = this.buffer.slice(0, this.cursor) + (nl < 0 ? '' : this.buffer.slice(nl));
|
|
335
339
|
} else if (key.ctrl && name === 'l') {
|
|
336
|
-
this.
|
|
337
|
-
this.
|
|
340
|
+
this.clearScreen();
|
|
341
|
+
return this.render();
|
|
338
342
|
} else if (str === '?' && !this.buffer) {
|
|
339
343
|
this.showHelp = !this.showHelp;
|
|
340
344
|
return this.render();
|
|
@@ -539,15 +543,45 @@ 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
|
+
|
|
558
|
+
// Clear the screen and scrollback, and forget what was printed, so a resize
|
|
559
|
+
// doesn't bring it back. The input area is redrawn by the next render.
|
|
560
|
+
clearScreen({ keepScrollback = false } = {}) {
|
|
561
|
+
this.thinkBuf = '';
|
|
562
|
+
this.md = null;
|
|
563
|
+
this.mode = null;
|
|
564
|
+
this.partial = '';
|
|
565
|
+
this.transcript = [];
|
|
566
|
+
this.transcriptSize = 0;
|
|
567
|
+
this.out.write(keepScrollback ? '\x1b[2J\x1b[H' : '\x1b[2J\x1b[3J\x1b[H');
|
|
568
|
+
this.regionRows = 0;
|
|
569
|
+
this.regionCursorRow = 0;
|
|
570
|
+
this.regionCursorCol = 0;
|
|
571
|
+
this.regionWidths = [];
|
|
572
|
+
this.contentRows = 0;
|
|
573
|
+
this.lastBlank = true;
|
|
574
|
+
this.atLineStart = true;
|
|
575
|
+
}
|
|
576
|
+
|
|
545
577
|
handleResize() {
|
|
546
578
|
const cols = this.out.columns;
|
|
547
579
|
if (cols === this.lastCols || !this.active) return this.render();
|
|
548
580
|
this.lastCols = cols;
|
|
549
581
|
// Clear screen and scrollback, reprint the conversation at the new width.
|
|
550
|
-
|
|
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));
|
|
551
585
|
this.regionRows = 0;
|
|
552
586
|
this.drawRegion();
|
|
553
587
|
}
|
|
@@ -713,7 +747,12 @@ export class FancyUI extends UI {
|
|
|
713
747
|
|
|
714
748
|
render() {
|
|
715
749
|
if (!this.active) return;
|
|
716
|
-
|
|
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
|
+
}
|
|
717
756
|
let s = '\x1b[?25l';
|
|
718
757
|
if (this.regionRows) {
|
|
719
758
|
const up = this.rowsAboveCursor();
|
package/src/ui.js
CHANGED
|
@@ -377,6 +377,13 @@ export class UI {
|
|
|
377
377
|
this.write(this.out, t.mist(' /help for commands · Ctrl-C to interrupt · Ctrl-D to quit\n\n'));
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
+
// Clear the screen and the scrollback.
|
|
381
|
+
clearScreen() {
|
|
382
|
+
this.endText();
|
|
383
|
+
if (this.out.isTTY) this.out.write('\x1b[2J\x1b[3J\x1b[H');
|
|
384
|
+
this.atLineStart = true;
|
|
385
|
+
}
|
|
386
|
+
|
|
380
387
|
info(msg) {
|
|
381
388
|
this.endText();
|
|
382
389
|
this.write(this.log, this.lc.mist(msg) + '\n');
|