brito-cli 0.7.3 → 0.7.4
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 +26 -3
- package/package.json +1 -1
package/dist/ui/dock.js
CHANGED
|
@@ -43,6 +43,8 @@ export class Dock {
|
|
|
43
43
|
started = false;
|
|
44
44
|
onData = (d) => this.feed(d);
|
|
45
45
|
resizeTimer;
|
|
46
|
+
reflowing = false;
|
|
47
|
+
reflowAgain = false;
|
|
46
48
|
onResize = () => {
|
|
47
49
|
this.rows = process.stdout.rows || 24;
|
|
48
50
|
this.cols = process.stdout.columns || 80;
|
|
@@ -58,9 +60,30 @@ export class Dock {
|
|
|
58
60
|
async reflow() {
|
|
59
61
|
if (!this.started)
|
|
60
62
|
return;
|
|
61
|
-
|
|
63
|
+
if (this.reflowing) {
|
|
64
|
+
this.reflowAgain = true;
|
|
65
|
+
return;
|
|
66
|
+
} // um DSR por vez; refaz ao terminar
|
|
67
|
+
this.reflowing = true;
|
|
68
|
+
try {
|
|
69
|
+
do {
|
|
70
|
+
this.reflowAgain = false;
|
|
71
|
+
await this.reflowOnce();
|
|
72
|
+
} while (this.reflowAgain && this.started);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
this.reflowing = false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async reflowOnce() {
|
|
79
|
+
const pos = await this.getCursor(true);
|
|
62
80
|
if (!this.started)
|
|
63
81
|
return;
|
|
82
|
+
if (!pos) {
|
|
83
|
+
process.stdout.write(this.paintSeq(false));
|
|
84
|
+
return;
|
|
85
|
+
} // sem resposta do terminal: não chuta posição
|
|
86
|
+
const [r] = pos;
|
|
64
87
|
const wrap = (w) => Math.max(1, Math.ceil(w / this.cols));
|
|
65
88
|
const above = this.lastWidths.slice(0, this.lastCursor.line).reduce((n, w) => n + wrap(w), 0)
|
|
66
89
|
+ Math.floor(Math.max(0, this.lastCursor.col - 1) / this.cols);
|
|
@@ -119,9 +142,9 @@ export class Dock {
|
|
|
119
142
|
}
|
|
120
143
|
catch { /* já fechado */ }
|
|
121
144
|
}
|
|
122
|
-
getCursor() {
|
|
145
|
+
getCursor(strict = false) {
|
|
123
146
|
return new Promise((resolve) => {
|
|
124
|
-
const t = setTimeout(() => { this.dsr = undefined; resolve([this.rows, 1]); }, 400);
|
|
147
|
+
const t = setTimeout(() => { this.dsr = undefined; resolve(strict ? null : [this.rows, 1]); }, 400);
|
|
125
148
|
this.dsr = (r, col) => { clearTimeout(t); this.dsr = undefined; resolve([r, col]); };
|
|
126
149
|
process.stdout.write("\x1b[6n");
|
|
127
150
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brito-cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
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": {
|