brito-cli 0.7.2 → 0.7.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/dist/ui/dock.js +30 -1
- package/package.json +1 -1
package/dist/ui/dock.js
CHANGED
|
@@ -23,6 +23,8 @@ export class Dock {
|
|
|
23
23
|
skipNL = false;
|
|
24
24
|
top = 1;
|
|
25
25
|
height = 0;
|
|
26
|
+
lastWidths = [];
|
|
27
|
+
lastCursor = { line: 0, col: 1 };
|
|
26
28
|
spinner = null;
|
|
27
29
|
busy = false;
|
|
28
30
|
promptOverride = null;
|
|
@@ -40,12 +42,36 @@ export class Dock {
|
|
|
40
42
|
dsr;
|
|
41
43
|
started = false;
|
|
42
44
|
onData = (d) => this.feed(d);
|
|
45
|
+
resizeTimer;
|
|
43
46
|
onResize = () => {
|
|
44
47
|
this.rows = process.stdout.rows || 24;
|
|
45
48
|
this.cols = process.stdout.columns || 80;
|
|
46
49
|
this.outRow = Math.min(this.outRow, this.rows);
|
|
47
|
-
|
|
50
|
+
clearTimeout(this.resizeTimer);
|
|
51
|
+
this.resizeTimer = setTimeout(() => void this.reflow(), 40);
|
|
48
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* O terminal re-quebra (reflow) o que já está na tela ao redimensionar: réguas largas viram 2 linhas
|
|
55
|
+
* e as posições guardadas ficam inválidas. Perguntamos onde o cursor foi parar, deduzimos onde o dock
|
|
56
|
+
* começa agora, apagamos dali para baixo e repintamos.
|
|
57
|
+
*/
|
|
58
|
+
async reflow() {
|
|
59
|
+
if (!this.started)
|
|
60
|
+
return;
|
|
61
|
+
const [r] = await this.getCursor();
|
|
62
|
+
if (!this.started)
|
|
63
|
+
return;
|
|
64
|
+
const wrap = (w) => Math.max(1, Math.ceil(w / this.cols));
|
|
65
|
+
const above = this.lastWidths.slice(0, this.lastCursor.line).reduce((n, w) => n + wrap(w), 0)
|
|
66
|
+
+ Math.floor(Math.max(0, this.lastCursor.col - 1) / this.cols);
|
|
67
|
+
const top = Math.max(1, Math.min(this.rows, r - above));
|
|
68
|
+
this.outRow = top;
|
|
69
|
+
this.outCol = 1;
|
|
70
|
+
this.skipNL = false;
|
|
71
|
+
this.top = top;
|
|
72
|
+
this.height = 0;
|
|
73
|
+
process.stdout.write(`\x1b[${top};1H\x1b[J` + this.paintSeq(true));
|
|
74
|
+
}
|
|
49
75
|
constructor(opts) {
|
|
50
76
|
this.opts = opts;
|
|
51
77
|
if (opts.historyFile) {
|
|
@@ -83,6 +109,7 @@ export class Dock {
|
|
|
83
109
|
this.restoreTerminal();
|
|
84
110
|
process.stdin.off("data", this.onData);
|
|
85
111
|
process.stdout.off("resize", this.onResize);
|
|
112
|
+
clearTimeout(this.resizeTimer);
|
|
86
113
|
process.stdin.pause();
|
|
87
114
|
}
|
|
88
115
|
restoreTerminal() {
|
|
@@ -316,6 +343,8 @@ export class Dock {
|
|
|
316
343
|
}
|
|
317
344
|
this.top = base;
|
|
318
345
|
this.height = h;
|
|
346
|
+
this.lastWidths = visibleLines.map((l) => Math.min(stringWidth(stripAnsi(l)), this.cols));
|
|
347
|
+
this.lastCursor = { line: Math.max(0, Math.min(h - 1, cursor.row - (out.length - h) - 1)), col: Math.min(cursor.col, this.cols) };
|
|
319
348
|
const row = base + cursor.row - (out.length - h);
|
|
320
349
|
s += `\x1b[${Math.min(row, this.rows)};${Math.min(cursor.col, this.cols)}H`;
|
|
321
350
|
return s;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brito-cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Coding-agent CLI with a code knowledge graph, memory and reviewable skills / CLI de agente de código com grafo de conhecimento, memória e skills revisáveis",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|