@jun133/kitty 0.0.10 → 0.0.12
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 +95 -90
- package/dist/{App-6FETP3LH.mjs → App-V6SLDWQH.mjs} +39 -5
- package/dist/chunk-4HIVDFN5.mjs +823 -0
- package/dist/{chunk-ELBEXOR7.mjs → chunk-MV5BYUNW.mjs} +293 -1
- package/dist/{chunk-6NJJLOY3.mjs → chunk-TISOA5U6.mjs} +85 -3
- package/dist/{chunk-YSWK3BGL.mjs → chunk-TOBF3KV3.mjs} +1 -1
- package/dist/cli.js +491 -45
- package/dist/cli.js.map +1 -1
- package/dist/{interactive-KLW4JL7R.mjs → interactive-WYSTB4UQ.mjs} +3 -3
- package/dist/{oneShot-YHDMPFQM.mjs → oneShot-INJ27LNB.mjs} +2 -2
- package/dist/tui.mjs +90 -10
- package/package.json +1 -1
- package/dist/chunk-DFDOKON5.mjs +0 -530
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
mirrorProcessOutputToTerminalLog,
|
|
8
8
|
renderKittyBanner,
|
|
9
9
|
ui
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TISOA5U6.mjs";
|
|
11
11
|
import "./chunk-4BN45TQG.mjs";
|
|
12
12
|
import {
|
|
13
13
|
createRuntimeUiAgentCallbacks
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TOBF3KV3.mjs";
|
|
15
15
|
import {
|
|
16
16
|
colorRuntimeUiText,
|
|
17
17
|
loadProjectContext,
|
|
18
18
|
writeStdout
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-MV5BYUNW.mjs";
|
|
20
20
|
import "./chunk-3KMC6H5K.mjs";
|
|
21
21
|
|
|
22
22
|
// src/shell/cli/intro.ts
|
package/dist/tui.mjs
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
mirrorInteractionShellToTerminalLog,
|
|
8
8
|
parseSessionPickerChoice,
|
|
9
9
|
renderKittyBanner
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TISOA5U6.mjs";
|
|
11
11
|
import "./chunk-4BN45TQG.mjs";
|
|
12
12
|
import {
|
|
13
13
|
loadProjectContext
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-MV5BYUNW.mjs";
|
|
15
15
|
import "./chunk-3KMC6H5K.mjs";
|
|
16
16
|
import {
|
|
17
17
|
TUI_COLORS,
|
|
@@ -21,12 +21,13 @@ import {
|
|
|
21
21
|
createInitialTuiState,
|
|
22
22
|
formatContextBudget,
|
|
23
23
|
parseSubmittedInputEcho,
|
|
24
|
+
renderTranscriptEntryLineViews,
|
|
24
25
|
scrollTuiTranscript,
|
|
25
26
|
scrollTuiTranscriptToBottom,
|
|
26
27
|
scrollTuiTranscriptToTop,
|
|
27
28
|
updateComposerState,
|
|
28
29
|
updateRuntimeDock
|
|
29
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-4HIVDFN5.mjs";
|
|
30
31
|
|
|
31
32
|
// src/shell/tui/input/scroll.ts
|
|
32
33
|
var ENABLE_MOUSE_TRACKING = "\x1B[?1000h\x1B[?1002h\x1B[?1006h";
|
|
@@ -116,6 +117,71 @@ function mirrorTtyFacts(source, target) {
|
|
|
116
117
|
};
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
// src/shell/tui/transcriptProjection.ts
|
|
121
|
+
var TuiTranscriptProjection = class {
|
|
122
|
+
cache = /* @__PURE__ */ new Map();
|
|
123
|
+
theme;
|
|
124
|
+
onEntryLayout;
|
|
125
|
+
constructor(options = {}) {
|
|
126
|
+
this.theme = options.theme ?? TUI_COLORS;
|
|
127
|
+
this.onEntryLayout = options.onEntryLayout;
|
|
128
|
+
}
|
|
129
|
+
renderLineViews(entries, width) {
|
|
130
|
+
return entries.flatMap((entry) => this.renderEntry(entry, width));
|
|
131
|
+
}
|
|
132
|
+
renderVisibleLineViews(entries, viewport, offset) {
|
|
133
|
+
const start = Math.max(0, Math.floor(offset));
|
|
134
|
+
const end = start + Math.max(0, Math.floor(viewport.height));
|
|
135
|
+
const rows = [];
|
|
136
|
+
let cursor = 0;
|
|
137
|
+
for (const entry of entries) {
|
|
138
|
+
const entryRows = this.renderEntry(entry, viewport.width);
|
|
139
|
+
const nextCursor = cursor + entryRows.length;
|
|
140
|
+
if (nextCursor <= start) {
|
|
141
|
+
cursor = nextCursor;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (cursor >= end) {
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
const from = Math.max(0, start - cursor);
|
|
148
|
+
const to = Math.min(entryRows.length, end - cursor);
|
|
149
|
+
rows.push(...entryRows.slice(from, to));
|
|
150
|
+
cursor = nextCursor;
|
|
151
|
+
}
|
|
152
|
+
return rows;
|
|
153
|
+
}
|
|
154
|
+
measureRows(entries, width) {
|
|
155
|
+
let rows = 0;
|
|
156
|
+
for (const entry of entries) {
|
|
157
|
+
rows += this.renderEntry(entry, width).length;
|
|
158
|
+
}
|
|
159
|
+
return rows;
|
|
160
|
+
}
|
|
161
|
+
purge(entries) {
|
|
162
|
+
const ids = new Set(entries.map((entry) => entry.id));
|
|
163
|
+
for (const key of this.cache.keys()) {
|
|
164
|
+
const id = key.slice(0, key.indexOf("\0"));
|
|
165
|
+
if (!ids.has(id)) {
|
|
166
|
+
this.cache.delete(key);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
renderEntry(entry, width) {
|
|
171
|
+
const normalizedWidth = Math.max(1, Math.floor(width));
|
|
172
|
+
const key = `${entry.id}\0${normalizedWidth}`;
|
|
173
|
+
const signature = `${entry.role}\0${entry.text}`;
|
|
174
|
+
const cached = this.cache.get(key);
|
|
175
|
+
if (cached?.signature === signature) {
|
|
176
|
+
return cached.rows;
|
|
177
|
+
}
|
|
178
|
+
this.onEntryLayout?.(entry, normalizedWidth);
|
|
179
|
+
const rows = renderTranscriptEntryLineViews(entry, normalizedWidth, this.theme);
|
|
180
|
+
this.cache.set(key, { signature, rows });
|
|
181
|
+
return rows;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
119
185
|
// src/shell/tui/controller.ts
|
|
120
186
|
var DEFAULT_VIEWPORT = {
|
|
121
187
|
width: 80,
|
|
@@ -124,13 +190,14 @@ var DEFAULT_VIEWPORT = {
|
|
|
124
190
|
var TuiController = class {
|
|
125
191
|
state;
|
|
126
192
|
viewport = DEFAULT_VIEWPORT;
|
|
193
|
+
projection = new TuiTranscriptProjection();
|
|
127
194
|
listeners = /* @__PURE__ */ new Set();
|
|
128
195
|
pendingInput = null;
|
|
129
196
|
interruptHandler;
|
|
130
197
|
disposed = false;
|
|
131
198
|
constructor(session) {
|
|
132
199
|
this.state = createInitialTuiState(session);
|
|
133
|
-
this.state = applyViewportResize(this.state, this.viewport);
|
|
200
|
+
this.state = applyViewportResize(this.state, this.viewport, this.projectionOptions());
|
|
134
201
|
}
|
|
135
202
|
getState() {
|
|
136
203
|
return this.state;
|
|
@@ -148,7 +215,7 @@ var TuiController = class {
|
|
|
148
215
|
height: Math.max(1, Math.floor(viewport.height))
|
|
149
216
|
};
|
|
150
217
|
this.viewport = nextViewport;
|
|
151
|
-
this.setState(applyViewportResize(this.state, nextViewport));
|
|
218
|
+
this.setState(applyViewportResize(this.state, nextViewport, this.projectionOptions()));
|
|
152
219
|
}
|
|
153
220
|
readInput(promptLabel = "> ") {
|
|
154
221
|
return this.openInput(promptLabel);
|
|
@@ -186,13 +253,16 @@ var TuiController = class {
|
|
|
186
253
|
if (!text) {
|
|
187
254
|
return;
|
|
188
255
|
}
|
|
189
|
-
this.setState(appendTranscriptEntry(this.state, { role, text }, this.viewport));
|
|
256
|
+
this.setState(appendTranscriptEntry(this.state, { role, text }, this.viewport, this.projectionOptions()));
|
|
190
257
|
}
|
|
191
258
|
appendStreaming(role, text) {
|
|
192
259
|
if (!text) {
|
|
193
260
|
return;
|
|
194
261
|
}
|
|
195
|
-
|
|
262
|
+
if (this.disposed) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.setState(appendTranscriptText(this.state, role, text, this.viewport, this.projectionOptions()));
|
|
196
266
|
}
|
|
197
267
|
appendOutput(text, role = "system") {
|
|
198
268
|
const submitted = parseSubmittedInputEcho(text);
|
|
@@ -220,7 +290,7 @@ var TuiController = class {
|
|
|
220
290
|
}));
|
|
221
291
|
}
|
|
222
292
|
scrollBy(delta) {
|
|
223
|
-
this.setState(scrollTuiTranscript(this.state, this.viewport, delta));
|
|
293
|
+
this.setState(scrollTuiTranscript(this.state, this.viewport, delta, this.projectionOptions()));
|
|
224
294
|
}
|
|
225
295
|
pageUp() {
|
|
226
296
|
this.scrollBy(-Math.max(1, this.viewport.height - 2));
|
|
@@ -232,7 +302,10 @@ var TuiController = class {
|
|
|
232
302
|
this.setState(scrollTuiTranscriptToTop(this.state));
|
|
233
303
|
}
|
|
234
304
|
scrollBottom() {
|
|
235
|
-
this.setState(scrollTuiTranscriptToBottom(this.state, this.viewport));
|
|
305
|
+
this.setState(scrollTuiTranscriptToBottom(this.state, this.viewport, this.projectionOptions()));
|
|
306
|
+
}
|
|
307
|
+
getVisibleTranscriptLineViews(viewport) {
|
|
308
|
+
return this.projection.renderVisibleLineViews(this.state.transcript, viewport, this.state.scroll.offset);
|
|
236
309
|
}
|
|
237
310
|
dispose() {
|
|
238
311
|
this.disposed = true;
|
|
@@ -254,11 +327,18 @@ var TuiController = class {
|
|
|
254
327
|
});
|
|
255
328
|
}
|
|
256
329
|
setState(state) {
|
|
330
|
+
if (this.disposed) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
257
333
|
this.state = state;
|
|
334
|
+
this.projection.purge(this.state.transcript);
|
|
258
335
|
for (const listener of this.listeners) {
|
|
259
336
|
listener(this.state);
|
|
260
337
|
}
|
|
261
338
|
}
|
|
339
|
+
projectionOptions() {
|
|
340
|
+
return { projection: this.projection };
|
|
341
|
+
}
|
|
262
342
|
};
|
|
263
343
|
|
|
264
344
|
// src/shell/tui/turnDisplay.ts
|
|
@@ -659,7 +739,7 @@ async function startTuiChat(options) {
|
|
|
659
739
|
const [{ default: React }, ink, { createTuiAppComponent }] = await Promise.all([
|
|
660
740
|
import("react"),
|
|
661
741
|
import("ink"),
|
|
662
|
-
import("./App-
|
|
742
|
+
import("./App-V6SLDWQH.mjs")
|
|
663
743
|
]);
|
|
664
744
|
const selected = await selectTuiSession({
|
|
665
745
|
cwd: options.cwd,
|