@linxiraos/pi-tui 1.4.7 → 1.4.9
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/CHANGELOG.md +28 -109
- package/README.md +7 -1
- package/dist/types/app-keybindings.d.ts +5 -0
- package/dist/types/charts/table-data.d.ts +4 -2
- package/dist/types/chat/bash-execution.d.ts +4 -1
- package/dist/types/chat/eval-execution.d.ts +2 -0
- package/dist/types/chat/execution-shared.d.ts +14 -8
- package/dist/types/chat/figure-markdown.d.ts +2 -0
- package/dist/types/chat/svg-figure.d.ts +5 -0
- package/dist/types/chat/table-chart.d.ts +2 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +11 -3
- package/dist/types/chrome/dynamic-border.d.ts +6 -0
- package/dist/types/chrome/transcript-status.d.ts +2 -2
- package/dist/types/components/editor.d.ts +15 -6
- package/dist/types/components/image.d.ts +6 -0
- package/dist/types/components/loader.d.ts +2 -0
- package/dist/types/keybinding-matchers.d.ts +7 -0
- package/dist/types/native/describe.d.ts +4 -2
- package/dist/types/native/node.d.ts +2 -3
- package/dist/types/native/overlay.d.ts +42 -2
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/btw-history-panel.d.ts +15 -0
- package/dist/types/overlays/btw-history.d.ts +24 -0
- package/dist/types/overlays/btw-inject.d.ts +22 -0
- package/dist/types/overlays/btw-panel.d.ts +7 -0
- package/dist/types/overlays/hook-editor.d.ts +2 -0
- package/dist/types/overlays/jobs-panel.d.ts +4 -0
- package/dist/types/overlays/model-browser.d.ts +1 -1
- package/dist/types/overlays/session-selector.d.ts +11 -2
- package/dist/types/prompt/composer.d.ts +13 -5
- package/dist/types/render/render-utils.d.ts +23 -1
- package/dist/types/status-line/startup.d.ts +0 -15
- package/dist/types/terminal-capabilities.d.ts +1 -1
- package/dist/types/theme/symbols.d.ts +3 -1
- package/dist/types/theme/theme-class.d.ts +1 -0
- package/dist/types/theme/theme.d.ts +1 -1
- package/dist/types/theme/tui-adapters.d.ts +2 -0
- package/dist/types/thinking.d.ts +8 -6
- package/dist/types/tools/ast-grep.d.ts +2 -0
- package/dist/types/tools/eval.d.ts +2 -0
- package/dist/types/tools/find.d.ts +1 -1
- package/dist/types/tools/grouped-file-output.d.ts +100 -19
- package/dist/types/tools/hashline-format.d.ts +5 -0
- package/dist/types/tools/native-view.d.ts +2 -0
- package/dist/types/tools/output-meta.d.ts +27 -0
- package/dist/types/tools/read.d.ts +14 -4
- package/dist/types/tools/task.d.ts +4 -3
- package/dist/types/tools/wait.d.ts +2 -0
- package/dist/types/tui.d.ts +12 -0
- package/dist/types/utils.d.ts +4 -0
- package/package.json +9 -9
- package/src/app-keybindings.d.ts +5 -0
- package/src/app-keybindings.ts +5 -0
- package/src/apps/git/git-tui.ts +10 -17
- package/src/apps/git/sidebar.ts +21 -35
- package/src/apps/ps-top.ts +4 -12
- package/src/charts/chart-plan.ts +0 -29
- package/src/charts/table-data.d.ts +4 -2
- package/src/charts/table-data.ts +55 -6
- package/src/chat/bash-execution.d.ts +4 -1
- package/src/chat/bash-execution.ts +20 -9
- package/src/chat/chat-transcript-builder.ts +5 -2
- package/src/chat/eval-execution.d.ts +2 -0
- package/src/chat/eval-execution.ts +14 -7
- package/src/chat/execution-shared.d.ts +14 -8
- package/src/chat/execution-shared.ts +39 -18
- package/src/chat/figure-markdown.d.ts +2 -0
- package/src/chat/figure-markdown.ts +6 -4
- package/src/chat/read-tool-group.ts +56 -36
- package/src/chat/svg-figure.d.ts +5 -0
- package/src/chat/svg-figure.ts +55 -16
- package/src/chat/table-chart.d.ts +2 -0
- package/src/chat/table-chart.ts +19 -2
- package/src/chat/transcript-render-helpers.d.ts +11 -3
- package/src/chat/transcript-render-helpers.ts +70 -22
- package/src/chrome/dynamic-border.d.ts +6 -0
- package/src/chrome/dynamic-border.ts +28 -2
- package/src/chrome/transcript-status.d.ts +2 -2
- package/src/chrome/transcript-status.ts +5 -3
- package/src/components/editor.d.ts +15 -6
- package/src/components/editor.ts +123 -24
- package/src/components/image.d.ts +6 -0
- package/src/components/image.ts +13 -0
- package/src/components/key-value-list.ts +9 -9
- package/src/components/loader.d.ts +2 -0
- package/src/components/loader.ts +7 -0
- package/src/components/section.ts +1 -9
- package/src/components/table.ts +1 -9
- package/src/keybinding-matchers.d.ts +7 -0
- package/src/keybinding-matchers.ts +13 -0
- package/src/native/backend.ts +7 -3
- package/src/native/describe.d.ts +4 -2
- package/src/native/describe.ts +9 -4
- package/src/native/node.d.ts +2 -3
- package/src/native/node.ts +2 -3
- package/src/native/overlay.d.ts +42 -2
- package/src/native/overlay.ts +124 -16
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +25 -5
- package/src/overlays/btw-history-panel.ts +106 -14
- package/src/overlays/btw-history.ts +65 -0
- package/src/overlays/btw-inject.ts +91 -0
- package/src/overlays/btw-panel.ts +53 -12
- package/src/overlays/extensions/extension-dashboard.ts +7 -8
- package/src/overlays/hook-editor.ts +6 -0
- package/src/overlays/jobs-panel.ts +82 -22
- package/src/overlays/login-dialog.ts +8 -26
- package/src/overlays/model-browser.ts +69 -10
- package/src/overlays/session-selector.ts +25 -5
- package/src/overlays/settings-defs.ts +2 -2
- package/src/overlays/tree-selector.ts +83 -27
- package/src/overlays/usage-dashboard.ts +4 -6
- package/src/prompt/composer.ts +17 -5
- package/src/render/code-cell.ts +1 -1
- package/src/render/file-list.ts +4 -7
- package/src/render/render-utils.d.ts +23 -1
- package/src/render/render-utils.ts +38 -6
- package/src/setup/scenes/glyph.ts +1 -1
- package/src/status-line/startup.ts +36 -70
- package/src/terminal-capabilities.d.ts +1 -1
- package/src/terminal-capabilities.ts +5 -0
- package/src/theme/symbols.d.ts +3 -1
- package/src/theme/symbols.ts +16 -9
- package/src/theme/theme-class.d.ts +1 -0
- package/src/theme/theme-class.ts +15 -3
- package/src/theme/theme.d.ts +1 -1
- package/src/theme/theme.ts +1 -0
- package/src/theme/tui-adapters.d.ts +2 -0
- package/src/theme/tui-adapters.ts +8 -3
- package/src/thinking.d.ts +8 -6
- package/src/thinking.ts +17 -11
- package/src/tmux.ts +1 -0
- package/src/tools/agent-tree.ts +13 -11
- package/src/tools/ask.ts +24 -37
- package/src/tools/ast-edit.ts +48 -93
- package/src/tools/ast-grep.d.ts +2 -0
- package/src/tools/ast-grep.ts +31 -67
- package/src/tools/bash.ts +7 -0
- package/src/tools/default-renderer.ts +1 -1
- package/src/tools/edit.ts +50 -43
- package/src/tools/eval.d.ts +2 -0
- package/src/tools/eval.ts +2 -0
- package/src/tools/fetch.ts +2 -1
- package/src/tools/find.d.ts +1 -1
- package/src/tools/find.ts +13 -5
- package/src/tools/github.ts +14 -46
- package/src/tools/glob.ts +2 -1
- package/src/tools/grep.ts +47 -277
- package/src/tools/grouped-file-output.d.ts +100 -19
- package/src/tools/grouped-file-output.ts +414 -103
- package/src/tools/hashline-format.d.ts +5 -0
- package/src/tools/hashline-format.ts +5 -0
- package/src/tools/json-tree.ts +1 -5
- package/src/tools/lsp.ts +210 -32
- package/src/tools/native-view.d.ts +2 -0
- package/src/tools/native-view.ts +11 -5
- package/src/tools/output-meta.d.ts +27 -0
- package/src/tools/output-meta.ts +68 -4
- package/src/tools/proc-render.ts +3 -3
- package/src/tools/read.d.ts +14 -4
- package/src/tools/read.ts +20 -5
- package/src/tools/task.d.ts +4 -3
- package/src/tools/task.ts +41 -81
- package/src/tools/vibe.ts +4 -4
- package/src/tools/wait.d.ts +2 -0
- package/src/tools/wait.ts +8 -5
- package/src/tools/write.ts +17 -27
- package/src/tools/yield.ts +1 -1
- package/src/tui.d.ts +12 -0
- package/src/tui.ts +91 -9
- package/src/utils.d.ts +4 -0
- package/src/utils.ts +10 -0
package/src/tui.ts
CHANGED
|
@@ -86,6 +86,15 @@ const LINE_FIT_SOURCE_WIDTH_MULTIPLIER = 64;
|
|
|
86
86
|
// Zeta sidebar: the main area never composes narrower than this, even when a
|
|
87
87
|
// gutter reservation is active — narrow terminals ignore the reservation.
|
|
88
88
|
const MIN_MAIN_AREA_COLUMNS = 64;
|
|
89
|
+
// Zeta sidebar snapshot: the gutter column's semantic description travels
|
|
90
|
+
// out-of-band as an APC (`ESC _ zeta;sidebar; <base64 JSON> ESC \`) so a native
|
|
91
|
+
// GUI draws the same column from one frame's data. Unknown APCs are dropped by
|
|
92
|
+
// every terminal emulator, so the ANSI gutter stays the visible fallback.
|
|
93
|
+
const SIDEBAR_APC_PREFIX = "\x1b_zeta;sidebar;";
|
|
94
|
+
const SIDEBAR_APC_SUFFIX = "\x1b\\";
|
|
95
|
+
// Bound the payload per frame: a pathological snapshot falls back to the ANSI
|
|
96
|
+
// gutter instead of stalling the terminal's parser on a huge escape sequence.
|
|
97
|
+
const SIDEBAR_APC_MAX = 64 * 1024;
|
|
89
98
|
// Hide the hardware cursor before each paint/move write. Ghostty-style bar
|
|
90
99
|
// cursors can otherwise leave visual afterimages while the TUI repaints the
|
|
91
100
|
// row under a visible cursor. Paint writes also disable terminal autowrap:
|
|
@@ -357,6 +366,24 @@ export interface Component {
|
|
|
357
366
|
dispose?(): void;
|
|
358
367
|
}
|
|
359
368
|
|
|
369
|
+
/**
|
|
370
|
+
* A gutter component that can hand an external native renderer a semantic
|
|
371
|
+
* snapshot of the column it draws (see {@link TUI.setGutterComponent}). Such a
|
|
372
|
+
* component keeps rendering its ANSI rows — the snapshot only travels
|
|
373
|
+
* out-of-band — and a GUI that receives it draws the same content natively.
|
|
374
|
+
* Deliberately separate from {@link Component}: only a sidebar-shaped
|
|
375
|
+
* component describes itself for a whole external surface.
|
|
376
|
+
*/
|
|
377
|
+
export interface NativeSnapshotSource {
|
|
378
|
+
/** JSON-serializable TSP node for an external native sidebar renderer. */
|
|
379
|
+
describeSnapshot(): NativeNode | null;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** Whether `component` hands an out-of-band snapshot to a native renderer. */
|
|
383
|
+
function isSnapshotSource(component: Component): component is Component & NativeSnapshotSource {
|
|
384
|
+
return typeof (component as Partial<NativeSnapshotSource>).describeSnapshot === "function";
|
|
385
|
+
}
|
|
386
|
+
|
|
360
387
|
/** Lets an overlay root delegate keyboard focus to components it owns. */
|
|
361
388
|
export interface OverlayFocusOwner {
|
|
362
389
|
/** Returns true when `component` is a focus target inside this overlay. */
|
|
@@ -929,6 +956,9 @@ export class TUI extends Container {
|
|
|
929
956
|
// Zeta sidebar: right-hand gutter component and its last painted rows.
|
|
930
957
|
#gutterComponent: Component | null = null;
|
|
931
958
|
#paintedGutterRows: readonly string[] | null = null;
|
|
959
|
+
// Zeta sidebar snapshot: last APC payload written (`null` forces the next
|
|
960
|
+
// paint to write, even when the payload is the empty clear sequence).
|
|
961
|
+
#lastSidebarPayload: string | null = "";
|
|
932
962
|
// Zeta sidebar: columns reserved for the gutter, or null for full width.
|
|
933
963
|
#mainWidthOverride: number | null = null;
|
|
934
964
|
#focusedComponent: Component | null = null;
|
|
@@ -1244,6 +1274,11 @@ export class TUI extends Container {
|
|
|
1244
1274
|
if (this.#gutterComponent === component) return;
|
|
1245
1275
|
this.#gutterComponent = component;
|
|
1246
1276
|
this.#paintedGutterRows = null;
|
|
1277
|
+
// A replacement (or removed) component must never inherit the last column.
|
|
1278
|
+
// Force the next paint to publish its snapshot — or the clear payload — only
|
|
1279
|
+
// when a snapshot was actually published, so an ordinary gutter byte-stream
|
|
1280
|
+
// stays exactly as it was without a native renderer attached.
|
|
1281
|
+
if (this.#lastSidebarPayload !== "") this.#lastSidebarPayload = null;
|
|
1247
1282
|
this.requestRender();
|
|
1248
1283
|
}
|
|
1249
1284
|
|
|
@@ -1283,6 +1318,33 @@ export class TUI extends Container {
|
|
|
1283
1318
|
seq += `\x1b[${restoreRow + 1};1H`;
|
|
1284
1319
|
return seq;
|
|
1285
1320
|
}
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* The APC carrying this frame's sidebar snapshot (see
|
|
1324
|
+
* {@link NativeSnapshotSource}): `ESC _ zeta;sidebar; <base64(UTF-8 JSON)> ESC \`,
|
|
1325
|
+
* with an empty payload when there is no snapshot so a native renderer drops
|
|
1326
|
+
* the column. Returns "" while the payload is unchanged, so frames that only
|
|
1327
|
+
* repaint the same column write no extra bytes.
|
|
1328
|
+
*/
|
|
1329
|
+
#sidebarApc(snapshot: NativeNode | null): string {
|
|
1330
|
+
let payload = "";
|
|
1331
|
+
if (snapshot !== null) {
|
|
1332
|
+
try {
|
|
1333
|
+
const json = JSON.stringify({ v: 1, node: snapshot });
|
|
1334
|
+
const encoded = Buffer.from(json, "utf8").toString("base64");
|
|
1335
|
+
// Oversized snapshots are dropped, not truncated: the ANSI gutter
|
|
1336
|
+
// already shows the same column.
|
|
1337
|
+
if (encoded.length <= SIDEBAR_APC_MAX) payload = encoded;
|
|
1338
|
+
} catch {
|
|
1339
|
+
// A component child or a property cycle cannot cross the snapshot
|
|
1340
|
+
// boundary; the frame falls back to the ANSI gutter.
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
if (payload === this.#lastSidebarPayload) return "";
|
|
1344
|
+
this.#lastSidebarPayload = payload;
|
|
1345
|
+
return `${SIDEBAR_APC_PREFIX}${payload}${SIDEBAR_APC_SUFFIX}`;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1286
1348
|
/** Return how settled resizes refresh native scrollback. */
|
|
1287
1349
|
getResizeScrollback(): ResizeScrollbackMode {
|
|
1288
1350
|
return this.#resizeScrollbackMode;
|
|
@@ -3595,16 +3657,36 @@ export class TUI extends Container {
|
|
|
3595
3657
|
if (gutter) {
|
|
3596
3658
|
const rows = gutter.render(rawWidth - mainWidth);
|
|
3597
3659
|
const seq = this.#gutterPaintSequence(rows, rawWidth - mainWidth, mainWidth, viewportRows, 0);
|
|
3598
|
-
|
|
3660
|
+
// The snapshot rides the same write as the gutter paint, so both describe
|
|
3661
|
+
// this one frame; an APC never moves the cursor.
|
|
3662
|
+
let snapshot: NativeNode | null = null;
|
|
3663
|
+
if (isSnapshotSource(gutter)) {
|
|
3664
|
+
try {
|
|
3665
|
+
snapshot = gutter.describeSnapshot();
|
|
3666
|
+
} catch {
|
|
3667
|
+
// A throwing snapshot source must not take down the frame; the ANSI
|
|
3668
|
+
// gutter below already shows the column.
|
|
3669
|
+
snapshot = null;
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
const apc = this.#sidebarApc(snapshot);
|
|
3673
|
+
if (seq || apc) this.terminal.write(seq + apc);
|
|
3599
3674
|
this.#paintedGutterRows = rows;
|
|
3600
|
-
} else
|
|
3601
|
-
//
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3675
|
+
} else {
|
|
3676
|
+
// Overlay frame, no reservation, or no component: clear the native column
|
|
3677
|
+
// once so a GUI never keeps drawing a snapshot the ANSI frame dropped.
|
|
3678
|
+
const apc = this.#sidebarApc(null);
|
|
3679
|
+
if (this.#paintedGutterRows !== null) {
|
|
3680
|
+
// Gutter removed: clear the margin column once via absolute EL per row.
|
|
3681
|
+
const col = mainWidth + 1;
|
|
3682
|
+
let seq = "";
|
|
3683
|
+
for (let row = 0; row < height; row++) seq += `\x1b[${row + 1};${col}H\x1b[K`;
|
|
3684
|
+
seq += "\x1b[H";
|
|
3685
|
+
this.terminal.write(seq + apc);
|
|
3686
|
+
this.#paintedGutterRows = null;
|
|
3687
|
+
} else if (apc) {
|
|
3688
|
+
this.terminal.write(apc);
|
|
3689
|
+
}
|
|
3608
3690
|
}
|
|
3609
3691
|
}
|
|
3610
3692
|
/**
|
package/src/utils.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ export declare function truncateToWidth(text: string, maxWidth: number, ellipsis
|
|
|
36
36
|
export declare function wrapTextWithAnsi(text: string, width: number): string[];
|
|
37
37
|
export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean): ExtractSegmentsResult;
|
|
38
38
|
export declare function replaceTabs(text: string): string;
|
|
39
|
+
/** Tabs expanded and line breaks collapsed to spaces, for text confined to one rendered row. */
|
|
40
|
+
export declare function singleLine(text: string): string;
|
|
41
|
+
/** A non-negative integer cell width; non-finite input becomes `fallback`. */
|
|
42
|
+
export declare function finiteWidth(width: number, fallback?: number): number;
|
|
39
43
|
/**
|
|
40
44
|
* Returns a string of n spaces. Uses a pre-allocated buffer for efficiency.
|
|
41
45
|
*/
|
package/src/utils.ts
CHANGED
|
@@ -221,6 +221,16 @@ export function replaceTabs(text: string): string {
|
|
|
221
221
|
return text.replaceAll("\t", TAB_SPACES);
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
/** Tabs expanded and line breaks collapsed to spaces, for text confined to one rendered row. */
|
|
225
|
+
export function singleLine(text: string): string {
|
|
226
|
+
return replaceTabs(text).replace(/[\r\n]+/g, " ");
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** A non-negative integer cell width; non-finite input becomes `fallback`. */
|
|
230
|
+
export function finiteWidth(width: number, fallback = 0): number {
|
|
231
|
+
return Number.isFinite(width) ? Math.max(0, Math.trunc(width)) : fallback;
|
|
232
|
+
}
|
|
233
|
+
|
|
224
234
|
/**
|
|
225
235
|
* Returns a string of n spaces. Uses a pre-allocated buffer for efficiency.
|
|
226
236
|
*/
|