@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.
Files changed (172) hide show
  1. package/CHANGELOG.md +28 -109
  2. package/README.md +7 -1
  3. package/dist/types/app-keybindings.d.ts +5 -0
  4. package/dist/types/charts/table-data.d.ts +4 -2
  5. package/dist/types/chat/bash-execution.d.ts +4 -1
  6. package/dist/types/chat/eval-execution.d.ts +2 -0
  7. package/dist/types/chat/execution-shared.d.ts +14 -8
  8. package/dist/types/chat/figure-markdown.d.ts +2 -0
  9. package/dist/types/chat/svg-figure.d.ts +5 -0
  10. package/dist/types/chat/table-chart.d.ts +2 -0
  11. package/dist/types/chat/transcript-render-helpers.d.ts +11 -3
  12. package/dist/types/chrome/dynamic-border.d.ts +6 -0
  13. package/dist/types/chrome/transcript-status.d.ts +2 -2
  14. package/dist/types/components/editor.d.ts +15 -6
  15. package/dist/types/components/image.d.ts +6 -0
  16. package/dist/types/components/loader.d.ts +2 -0
  17. package/dist/types/keybinding-matchers.d.ts +7 -0
  18. package/dist/types/native/describe.d.ts +4 -2
  19. package/dist/types/native/node.d.ts +2 -3
  20. package/dist/types/native/overlay.d.ts +42 -2
  21. package/dist/types/native/state.d.ts +4 -0
  22. package/dist/types/overlays/btw-history-panel.d.ts +15 -0
  23. package/dist/types/overlays/btw-history.d.ts +24 -0
  24. package/dist/types/overlays/btw-inject.d.ts +22 -0
  25. package/dist/types/overlays/btw-panel.d.ts +7 -0
  26. package/dist/types/overlays/hook-editor.d.ts +2 -0
  27. package/dist/types/overlays/jobs-panel.d.ts +4 -0
  28. package/dist/types/overlays/model-browser.d.ts +1 -1
  29. package/dist/types/overlays/session-selector.d.ts +11 -2
  30. package/dist/types/prompt/composer.d.ts +13 -5
  31. package/dist/types/render/render-utils.d.ts +23 -1
  32. package/dist/types/status-line/startup.d.ts +0 -15
  33. package/dist/types/terminal-capabilities.d.ts +1 -1
  34. package/dist/types/theme/symbols.d.ts +3 -1
  35. package/dist/types/theme/theme-class.d.ts +1 -0
  36. package/dist/types/theme/theme.d.ts +1 -1
  37. package/dist/types/theme/tui-adapters.d.ts +2 -0
  38. package/dist/types/thinking.d.ts +8 -6
  39. package/dist/types/tools/ast-grep.d.ts +2 -0
  40. package/dist/types/tools/eval.d.ts +2 -0
  41. package/dist/types/tools/find.d.ts +1 -1
  42. package/dist/types/tools/grouped-file-output.d.ts +100 -19
  43. package/dist/types/tools/hashline-format.d.ts +5 -0
  44. package/dist/types/tools/native-view.d.ts +2 -0
  45. package/dist/types/tools/output-meta.d.ts +27 -0
  46. package/dist/types/tools/read.d.ts +14 -4
  47. package/dist/types/tools/task.d.ts +4 -3
  48. package/dist/types/tools/wait.d.ts +2 -0
  49. package/dist/types/tui.d.ts +12 -0
  50. package/dist/types/utils.d.ts +4 -0
  51. package/package.json +9 -9
  52. package/src/app-keybindings.d.ts +5 -0
  53. package/src/app-keybindings.ts +5 -0
  54. package/src/apps/git/git-tui.ts +10 -17
  55. package/src/apps/git/sidebar.ts +21 -35
  56. package/src/apps/ps-top.ts +4 -12
  57. package/src/charts/chart-plan.ts +0 -29
  58. package/src/charts/table-data.d.ts +4 -2
  59. package/src/charts/table-data.ts +55 -6
  60. package/src/chat/bash-execution.d.ts +4 -1
  61. package/src/chat/bash-execution.ts +20 -9
  62. package/src/chat/chat-transcript-builder.ts +5 -2
  63. package/src/chat/eval-execution.d.ts +2 -0
  64. package/src/chat/eval-execution.ts +14 -7
  65. package/src/chat/execution-shared.d.ts +14 -8
  66. package/src/chat/execution-shared.ts +39 -18
  67. package/src/chat/figure-markdown.d.ts +2 -0
  68. package/src/chat/figure-markdown.ts +6 -4
  69. package/src/chat/read-tool-group.ts +56 -36
  70. package/src/chat/svg-figure.d.ts +5 -0
  71. package/src/chat/svg-figure.ts +55 -16
  72. package/src/chat/table-chart.d.ts +2 -0
  73. package/src/chat/table-chart.ts +19 -2
  74. package/src/chat/transcript-render-helpers.d.ts +11 -3
  75. package/src/chat/transcript-render-helpers.ts +70 -22
  76. package/src/chrome/dynamic-border.d.ts +6 -0
  77. package/src/chrome/dynamic-border.ts +28 -2
  78. package/src/chrome/transcript-status.d.ts +2 -2
  79. package/src/chrome/transcript-status.ts +5 -3
  80. package/src/components/editor.d.ts +15 -6
  81. package/src/components/editor.ts +123 -24
  82. package/src/components/image.d.ts +6 -0
  83. package/src/components/image.ts +13 -0
  84. package/src/components/key-value-list.ts +9 -9
  85. package/src/components/loader.d.ts +2 -0
  86. package/src/components/loader.ts +7 -0
  87. package/src/components/section.ts +1 -9
  88. package/src/components/table.ts +1 -9
  89. package/src/keybinding-matchers.d.ts +7 -0
  90. package/src/keybinding-matchers.ts +13 -0
  91. package/src/native/backend.ts +7 -3
  92. package/src/native/describe.d.ts +4 -2
  93. package/src/native/describe.ts +9 -4
  94. package/src/native/node.d.ts +2 -3
  95. package/src/native/node.ts +2 -3
  96. package/src/native/overlay.d.ts +42 -2
  97. package/src/native/overlay.ts +124 -16
  98. package/src/native/state.d.ts +4 -0
  99. package/src/native/state.ts +25 -5
  100. package/src/overlays/btw-history-panel.ts +106 -14
  101. package/src/overlays/btw-history.ts +65 -0
  102. package/src/overlays/btw-inject.ts +91 -0
  103. package/src/overlays/btw-panel.ts +53 -12
  104. package/src/overlays/extensions/extension-dashboard.ts +7 -8
  105. package/src/overlays/hook-editor.ts +6 -0
  106. package/src/overlays/jobs-panel.ts +82 -22
  107. package/src/overlays/login-dialog.ts +8 -26
  108. package/src/overlays/model-browser.ts +69 -10
  109. package/src/overlays/session-selector.ts +25 -5
  110. package/src/overlays/settings-defs.ts +2 -2
  111. package/src/overlays/tree-selector.ts +83 -27
  112. package/src/overlays/usage-dashboard.ts +4 -6
  113. package/src/prompt/composer.ts +17 -5
  114. package/src/render/code-cell.ts +1 -1
  115. package/src/render/file-list.ts +4 -7
  116. package/src/render/render-utils.d.ts +23 -1
  117. package/src/render/render-utils.ts +38 -6
  118. package/src/setup/scenes/glyph.ts +1 -1
  119. package/src/status-line/startup.ts +36 -70
  120. package/src/terminal-capabilities.d.ts +1 -1
  121. package/src/terminal-capabilities.ts +5 -0
  122. package/src/theme/symbols.d.ts +3 -1
  123. package/src/theme/symbols.ts +16 -9
  124. package/src/theme/theme-class.d.ts +1 -0
  125. package/src/theme/theme-class.ts +15 -3
  126. package/src/theme/theme.d.ts +1 -1
  127. package/src/theme/theme.ts +1 -0
  128. package/src/theme/tui-adapters.d.ts +2 -0
  129. package/src/theme/tui-adapters.ts +8 -3
  130. package/src/thinking.d.ts +8 -6
  131. package/src/thinking.ts +17 -11
  132. package/src/tmux.ts +1 -0
  133. package/src/tools/agent-tree.ts +13 -11
  134. package/src/tools/ask.ts +24 -37
  135. package/src/tools/ast-edit.ts +48 -93
  136. package/src/tools/ast-grep.d.ts +2 -0
  137. package/src/tools/ast-grep.ts +31 -67
  138. package/src/tools/bash.ts +7 -0
  139. package/src/tools/default-renderer.ts +1 -1
  140. package/src/tools/edit.ts +50 -43
  141. package/src/tools/eval.d.ts +2 -0
  142. package/src/tools/eval.ts +2 -0
  143. package/src/tools/fetch.ts +2 -1
  144. package/src/tools/find.d.ts +1 -1
  145. package/src/tools/find.ts +13 -5
  146. package/src/tools/github.ts +14 -46
  147. package/src/tools/glob.ts +2 -1
  148. package/src/tools/grep.ts +47 -277
  149. package/src/tools/grouped-file-output.d.ts +100 -19
  150. package/src/tools/grouped-file-output.ts +414 -103
  151. package/src/tools/hashline-format.d.ts +5 -0
  152. package/src/tools/hashline-format.ts +5 -0
  153. package/src/tools/json-tree.ts +1 -5
  154. package/src/tools/lsp.ts +210 -32
  155. package/src/tools/native-view.d.ts +2 -0
  156. package/src/tools/native-view.ts +11 -5
  157. package/src/tools/output-meta.d.ts +27 -0
  158. package/src/tools/output-meta.ts +68 -4
  159. package/src/tools/proc-render.ts +3 -3
  160. package/src/tools/read.d.ts +14 -4
  161. package/src/tools/read.ts +20 -5
  162. package/src/tools/task.d.ts +4 -3
  163. package/src/tools/task.ts +41 -81
  164. package/src/tools/vibe.ts +4 -4
  165. package/src/tools/wait.d.ts +2 -0
  166. package/src/tools/wait.ts +8 -5
  167. package/src/tools/write.ts +17 -27
  168. package/src/tools/yield.ts +1 -1
  169. package/src/tui.d.ts +12 -0
  170. package/src/tui.ts +91 -9
  171. package/src/utils.d.ts +4 -0
  172. package/src/utils.ts +10 -0
@@ -1,4 +1,5 @@
1
1
  import type { NativeNode } from "../native/node.js";
2
+ import { type Theme, type ThemeColor } from "../theme/theme.js";
2
3
  /**
3
4
  * One file's contribution to a grouped file output. The header itself is generated
4
5
  * by `formatGroupedFiles` (one `#` per nesting level); use `headerSuffix` to tack
@@ -51,22 +52,35 @@ export interface FileMatchSection {
51
52
  * Files with no model lines are omitted.
52
53
  */
53
54
  export declare function formatFileMatches(files: string[], grouped: boolean, renderFile: (filePath: string) => FileMatchSection): GroupedFilesOutput;
54
- /** Per-line classification of grouped output, used by renderers for hyperlinks. */
55
+ /** Whether a row of grouped output is a code-frame row the search matched (`*12│…`). */
56
+ export declare function isMatchRow(line: string): boolean;
57
+ /** Per-line classification of grouped output, used by renderers for file rows and hyperlinks. */
55
58
  export interface GroupedLineContext {
56
59
  /** Directory header, file header, or any non-header body/content line. */
57
60
  kind: "dir" | "file" | "content";
58
61
  /** Number of leading `#` for headers; 0 for content lines. */
59
62
  depth: number;
60
- /** Resolved absolute path of the dir/file a header points at (when resolvable). */
63
+ /** Resolved absolute path of the file a header points at (when resolvable). */
61
64
  headerPath?: string;
65
+ /**
66
+ * For file headers, the full display path: the folded directory chain joined
67
+ * with the name, without `#` markers or the hashline tag.
68
+ */
69
+ displayPath?: string;
70
+ /** For file headers, a trailing parenthesized note such as `(2 replacements)`. */
71
+ suffix?: string;
62
72
  /** For content lines, the absolute path of the owning file (line hyperlinks). */
63
73
  filePath?: string;
64
- /** Header is an internal/url-like target the caller resolves itself. */
65
- isUrl?: boolean;
74
+ /**
75
+ * The internal or url-like target, as written, that a header names or a
76
+ * content line belongs to; the caller resolves it (no filesystem path).
77
+ */
78
+ url?: string;
66
79
  }
67
80
  /**
68
81
  * Walk grouped output lines, tracking a directory stack keyed by header depth, so
69
- * each header and body line can be linked back to its absolute filesystem path.
82
+ * each header and body line can be linked back to its absolute filesystem path
83
+ * and each file header to its full display path.
70
84
  * Reconstruction is stack-based (not per-blank-group) so nested directory headers
71
85
  * resolve correctly across the whole output.
72
86
  *
@@ -75,9 +89,64 @@ export interface GroupedLineContext {
75
89
  * formatted relative to cwd regardless of the (sub)directory the search was
76
90
  * scoped to. `fileScope` is the initial owning file for body lines that appear
77
91
  * before any header (single-file scopes have no `#` headers); it defaults to
78
- * `headerBase` and should be passed the scoped file's absolute path.
92
+ * `headerBase` and should be passed the scoped file's absolute path. A URL base
93
+ * or scope (`local://…`) is no filesystem path: headerless lines belong to the
94
+ * URL, and headers under a URL base get no path.
79
95
  */
80
96
  export declare function classifyGroupedLines(lines: readonly string[], headerBase: string | undefined, fileScope?: string | undefined): GroupedLineContext[];
97
+ /**
98
+ * Line groups with one file per group, for terminal tree lists: `# dir/`
99
+ * header rows are dropped (each file row carries its full path), and every
100
+ * file row starts a group of its own, so each file gets its own branch instead
101
+ * of hanging under the previous file of its directory. Rows before a group's
102
+ * first file row (notes, a single-file scope's matches) keep their group.
103
+ */
104
+ export declare function groupsByFile(groups: readonly (readonly number[])[], contexts: readonly GroupedLineContext[]): number[][];
105
+ /** Details fields a grouped-output tool records for links: the display base paths and resolved URL targets. */
106
+ export interface GroupedLinkDetails {
107
+ cwd?: string;
108
+ searchPath?: string;
109
+ displayTargets?: Record<string, string>;
110
+ }
111
+ /**
112
+ * Link targets for the rows of sanitized grouped output: a file row's file, a
113
+ * body row's owning file, and for an internal URL the file `displayTargets`
114
+ * resolves it to. Destinations keep the original path bytes: while the raw
115
+ * `displayContent` still aligns line-for-line with the sanitized `displayText`,
116
+ * a row takes its raw classification's target. Raw text never links a row the
117
+ * sanitized output leaves unlinked.
118
+ */
119
+ export declare function groupedLinkTargets(contexts: readonly GroupedLineContext[], displayText: string, details: GroupedLinkDetails | undefined, rawDetails: unknown): (index: number) => string | undefined;
120
+ /**
121
+ * A memoized styler for the rows of grouped output, so a collapsed preview
122
+ * styles only the rows it shows. A file row is its full path (dim directory,
123
+ * name in {@link FILE_NAME_COLOR}; a URL whole in that color) and any dim
124
+ * suffix, linked to `linkTarget`'s file or, for an unresolved URL, the URL.
125
+ * Body rows come from `styleBody`, tabs expanded; with `linkLines` a numbered
126
+ * code-frame row links to its line in the owning file.
127
+ */
128
+ export declare function createGroupedRowStyler(lines: readonly string[], contexts: readonly GroupedLineContext[], theme: Theme, options: {
129
+ linkTarget: (index: number) => string | undefined;
130
+ styleBody: (index: number) => string;
131
+ linkLines?: boolean;
132
+ }): (index: number) => string;
133
+ /**
134
+ * Fit line groups (one file each) into `budget` rows, the `… N more` summary row
135
+ * included: whole groups first, then the next group cut short when it can still
136
+ * show a row under its file row (the first group always shows its head). The
137
+ * summary counts the `unit`s left out, the rows `isUnit` accepts, out of `total`
138
+ * when the caller knows it; with none left out it counts hidden lines. `gap`
139
+ * rows separate shown groups (framed lists put a blank line between files).
140
+ */
141
+ export declare function fitGroupsToBudget(groups: readonly (readonly number[])[], budget: number, options: {
142
+ isUnit: (index: number) => boolean;
143
+ unit: string;
144
+ total?: number;
145
+ gap?: number;
146
+ }): {
147
+ shown: (readonly number[])[];
148
+ summary: string;
149
+ };
81
150
  /**
82
151
  * Split line indices into blank-line-separated groups, mirroring
83
152
  * `splitGroupsByBlankLine`: when any blank line is present, break on runs of
@@ -85,6 +154,15 @@ export declare function classifyGroupedLines(lines: readonly string[], headerBas
85
154
  * indices lets callers slice parallel arrays (raw lines, styled lines, contexts).
86
155
  */
87
156
  export declare function groupLineIndicesByBlank(rawLines: readonly string[]): number[][];
157
+ /**
158
+ * Styled code-frame rows of grouped search output, highlighted in each owning
159
+ * file's language (`lang` overrides it when the highlighter knows it). A run of
160
+ * consecutive line numbers in one file highlights together on its first
161
+ * request; a gap row, a jump in line numbers or another file starts a new run.
162
+ * Rows without a numbered code frame (headers, gap rows, notes) return
163
+ * undefined, for the caller to style.
164
+ */
165
+ export declare function createCodeFrameStyler(lines: readonly string[], contexts: readonly GroupedLineContext[], color: ThemeColor, theme: Theme, lang?: string): (index: number) => string | undefined;
88
166
  /** One event of {@link walkGroupedOutput}: a directory header, a file header, or a non-blank body line. */
89
167
  export type GroupedOutputEvent = {
90
168
  readonly kind: "dir";
@@ -98,35 +176,38 @@ export type GroupedOutputEvent = {
98
176
  };
99
177
  /**
100
178
  * Walk grouped output (`# dir/`, `## file.ts (suffix)`, body lines), resolving
101
- * each file header to its full display path (the folded directory chain
102
- * joined with the name) and dropping blank separator lines.
179
+ * each file header to its full display path (see {@link classifyGroupedLines})
180
+ * and dropping blank separator lines.
103
181
  */
104
182
  export declare function walkGroupedOutput(lines: readonly string[]): Generator<GroupedOutputEvent>;
105
- /** One source line for {@link numberedCode}: its number (`null` for an elision marker), text and match mark. */
183
+ /** One source line for {@link numberedCode}: its number (`null` for an elision marker, which adds no line), text and match mark. */
106
184
  export interface NumberedLine {
107
185
  n: number | null;
108
186
  text: string;
109
187
  mark?: boolean;
110
188
  }
111
189
  /**
112
- * Numbered `code` for possibly non-contiguous source lines: one block per run
113
- * of consecutive line numbers (`start` = the run's first line, match lines
114
- * `mark`ed), with a `…` row wherever the numbers jump or an elision marker
115
- * (`n: null`) sits. `path` is the file the lines come from: Tern picks their
116
- * grammar from it and draws no header (the row or head above names the file).
117
- * `wrap` soft-wraps long lines instead of scrolling the block sideways.
190
+ * One numbered `code` block for possibly non-contiguous source lines (match
191
+ * lines `mark`ed by their line number): `start` when the numbers run on
192
+ * consecutively, else `nums` (each line's number), from whose jumps Tern draws
193
+ * the `…` gap rows in the gutter. Elision markers (`n: null`) add no line; the
194
+ * numbers jump around them. `path` is the file the lines come from: Tern picks
195
+ * their grammar from it and draws no header (the row or head above names the
196
+ * file). `wrap` soft-wraps long lines instead of scrolling the block sideways.
197
+ * `undefined` when no line is numbered.
118
198
  */
119
199
  export declare function numberedCode(lines: readonly NumberedLine[], opts?: {
120
200
  path?: string;
121
201
  wrap?: boolean;
122
- }): NativeNode[];
202
+ }): NativeNode | undefined;
123
203
  /**
124
204
  * Describe grouped search output (grep / ast-grep / ast-edit display content)
125
205
  * by file (§7.3 grep): per file a 22px path row (dim dir, strong name, the
126
206
  * header's suffix or the match count as a chip), then its lines as
127
- * {@link numberedCode} with match lines marked and `…` between non-adjacent
128
- * runs. Unnumbered body lines stay plain `code`. `maxFiles` keeps only the
129
- * first files (the caller says how many were left out). `file` owns the lines
207
+ * one {@link numberedCode} block with match lines marked (gaps between
208
+ * non-adjacent runs drawn in its gutter). Unnumbered body lines stay plain
209
+ * `code`. `maxFiles` keeps only the first files (the caller says how many
210
+ * were left out). `file` owns the lines
130
211
  * before any header: a single-file search prints none, yet its lines get the
131
212
  * same file row as a directory search's.
132
213
  */
@@ -6,6 +6,11 @@ export declare const HL_FILE_SUFFIX = "]";
6
6
  export declare const HL_FILE_HASH_SEP = "#";
7
7
  /** Number of characters in a displayed file hash. */
8
8
  export declare const HL_FILE_HASH_LENGTH = 4;
9
+ /**
10
+ * A trailing `#TAG` file hash exactly as the hashline store writes it (uppercase
11
+ * hex), so a name's own `#dead` or `#v2` ending survives stripping.
12
+ */
13
+ export declare const HASHLINE_TAG_SUFFIX_RE: RegExp;
9
14
  /** Keyword identifying a file move operation. */
10
15
  export declare const HL_MOVE_KEYWORD = "MV";
11
16
  /** Keyword identifying a file removal operation. */
@@ -8,6 +8,8 @@ import type { NativeToolHead, NativeToolView, ToolRenderResult } from "./rendere
8
8
  export declare function displayPath(filePath: string): string;
9
9
  /** Configured file link for a head's path target, when the path is absolute. */
10
10
  export declare function fileHref(filePath: string | undefined): string | undefined;
11
+ /** Link for a head target that is a web URL (`www.` gains `https://`), else undefined. */
12
+ export declare function urlHref(target: string | undefined): string | undefined;
11
13
  /** Diff stats as one head `meta` string, `+8 −1` (U+2212 minus), or undefined when nothing changed. */
12
14
  export declare function diffStatsMeta(added: number, removed: number): string | undefined;
13
15
  /**
@@ -100,8 +100,21 @@ export interface LimitsMeta {
100
100
  last: number;
101
101
  };
102
102
  selectorBase?: string;
103
+ /** The first cut line exceeds what one `:raw` read returns; that read stops at this many bytes. */
104
+ rawByteCap?: number;
103
105
  };
104
106
  }
107
+ /**
108
+ * The bash minimizer rewrote this output: `filter` is the native filter label
109
+ * (`chain` for a minimized `&&`/`;` chain), the byte counts are the raw capture
110
+ * and the minimized text, and `artifactId` holds the raw capture.
111
+ */
112
+ export interface MinimizedMeta {
113
+ filter: string;
114
+ inputBytes: number;
115
+ outputBytes: number;
116
+ artifactId: string;
117
+ }
105
118
  /**
106
119
  * Structured metadata for tool outputs.
107
120
  */
@@ -114,6 +127,7 @@ export interface OutputMeta {
114
127
  pagedSource?: true;
115
128
  diagnostics?: DiagnosticMeta;
116
129
  limits?: LimitsMeta;
130
+ minimized?: MinimizedMeta;
117
131
  }
118
132
  /**
119
133
  * Reformat pre-formatted diagnostic messages into a multi-level, prefix-folded
@@ -136,6 +150,13 @@ export declare function stripRawOutputArtifactNotice(text: string): {
136
150
  text: string;
137
151
  artifactId?: string;
138
152
  };
153
+ /** Whether `line` is the column-cap notice {@link formatOutputNotice} emits (`[Some lines truncated to 768 chars…]`). */
154
+ export declare function isColumnTruncationNotice(line: string): boolean;
155
+ /**
156
+ * Whether the bracketed notice `line` carries the column-cap clause: alone, or after the parts
157
+ * {@link formatOutputNotice} joins before it (`[Showing lines 1-4 of 5. … Some lines truncated to 768 chars…]`).
158
+ */
159
+ export declare function hasColumnTruncationClause(line: string): boolean;
139
160
  /** Remove a trailing generated output notice when metadata is unavailable. */
140
161
  export declare function stripGeneratedOutputNotice(text: string): string;
141
162
  /** Format truncation ranges and recovery hints. */
@@ -147,6 +168,12 @@ export declare function formatTruncationMetaNotice(truncation: TruncationMeta, s
147
168
  export declare function formatStyledArtifactReference(artifactId: string, theme: Theme): string;
148
169
  /** Describe an incomplete artifact capture. */
149
170
  export declare function formatArtifactErrorNotice(error: OutputArtifactError): string;
171
+ /**
172
+ * `git 120.4KB → 3.2KB`: the minimizer filter that ran and the bytes it took the output from and to.
173
+ * Native labels are short words; a rehydrated session or extension may carry any text, so the label
174
+ * is sanitized to one plain line, its home paths shortened to `~`, and width-bounded.
175
+ */
176
+ export declare function formatMinimizedMeta(minimized: MinimizedMeta): string;
150
177
  /**
151
178
  * Format notices from OutputMeta for LLM consumption.
152
179
  * Returns empty string if no notices needed.
@@ -111,6 +111,16 @@ export declare function splitInternalUrlSel(rawPath: string, specOf?: (scheme: s
111
111
  path: string;
112
112
  sel?: string;
113
113
  };
114
+ /**
115
+ * Split a filesystem read target from its query (`data.json?q=.items` →
116
+ * `data.json`, `?q=.items`), the display twin of the read tool's JSON, SQLite
117
+ * and image-question parsers. URLs own their query string and stay whole, as
118
+ * does a `?` inside a file name.
119
+ */
120
+ export declare function splitReadQuery(readPath: string): {
121
+ path: string;
122
+ query?: string;
123
+ };
114
124
  /** Recognize HTTP URLs and www-prefixed external read targets. */
115
125
  export declare function isReadableUrlPath(value: string): boolean;
116
126
  /** Return the first selected line when every range has valid one-based bounds. */
@@ -139,11 +149,11 @@ export declare function readSourceFsPath(details: unknown): string | undefined;
139
149
  */
140
150
  export declare function readResultIsMarkdown(details: ReadToolDetails | undefined, args: ReadRenderArgs | undefined): boolean;
141
151
  /**
142
- * Read content as numbered, wrapped `code` (no path header: the head names
143
- * the file), matching the ANSI preview's hanging wrap. Numbers come from
152
+ * Read content as one numbered, wrapped `code` block (no path header: the head
153
+ * names the file), matching the ANSI preview's hanging wrap. Numbers come from
144
154
  * `lineNumbers` (`displayContent`'s per-line numbers, `null` for an elided
145
- * block; runs split with `…` between) when they cover every line, else count
146
- * up from `start`.
155
+ * block, which Tern shows as a `…` gap row where the numbers jump) when they
156
+ * cover every line, else count up from `start`.
147
157
  */
148
158
  export declare function readContentCode(content: string, start: number, numbers: readonly (number | null)[] | undefined, path: string | undefined): NativeNode[];
149
159
  /** Render file, image, and URL reads in the transcript. */
@@ -1,9 +1,10 @@
1
1
  import type { Usage } from "@linxiraos/pi-ai";
2
2
  import type { ThemeColor } from "../theme/theme.js";
3
3
  import type { ConfiguredThinkingLevel } from "../render/render-utils.js";
4
- import type { RenderResultOptions, NativeToolView, ToolRenderResult } from "./renderer.js";
5
4
  import { type Component } from "../tui.js";
5
+ import type { RenderResultOptions } from "./renderer.js";
6
6
  import { type Theme } from "../theme/theme.js";
7
+ import type { NativeToolView, ToolRenderResult } from "./renderer.js";
7
8
  /** Render context threaded in from `ToolExecutionComponent.#buildRenderContext`. */
8
9
  interface TaskRenderContext {
9
10
  hasResult?: boolean;
@@ -103,7 +104,7 @@ export interface TaskItem {
103
104
  agent?: string;
104
105
  /** Historical source session selected by the bundled consult agent. */
105
106
  sourceSession?: string;
106
- /** Optional model selector override for the historical source session. */
107
+ /** Bundled seance: override for the source session's saved model. Any other agent: one exact per-call model, gated by `task.perCallModel`. */
107
108
  model?: string | string[];
108
109
  /** Inline instructions; exactly one of task or taskFile is required. */
109
110
  task?: string;
@@ -134,7 +135,7 @@ export interface TaskParams {
134
135
  agent?: string;
135
136
  /** Historical source session selected by the bundled consult agent. */
136
137
  sourceSession?: string;
137
- /** Optional model selector override for the historical source session. */
138
+ /** See {@link TaskItem.model}. */
138
139
  model?: string | string[];
139
140
  /** The work (flat form). */
140
141
  task?: string;
@@ -17,6 +17,8 @@ export interface JobSnapshot {
17
17
  type: "bash" | "task" | "eval";
18
18
  status: "running" | "completed" | "failed" | "cancelled";
19
19
  label: string;
20
+ /** What the job is for, in the model's words (a process job's `label` is its command line). */
21
+ intent?: string;
20
22
  durationMs: number;
21
23
  /** Process exit status when the job reports one. */
22
24
  exitCode?: number;
@@ -194,6 +194,18 @@ export interface Component {
194
194
  */
195
195
  dispose?(): void;
196
196
  }
197
+ /**
198
+ * A gutter component that can hand an external native renderer a semantic
199
+ * snapshot of the column it draws (see {@link TUI.setGutterComponent}). Such a
200
+ * component keeps rendering its ANSI rows — the snapshot only travels
201
+ * out-of-band — and a GUI that receives it draws the same content natively.
202
+ * Deliberately separate from {@link Component}: only a sidebar-shaped
203
+ * component describes itself for a whole external surface.
204
+ */
205
+ export interface NativeSnapshotSource {
206
+ /** JSON-serializable TSP node for an external native sidebar renderer. */
207
+ describeSnapshot(): NativeNode | null;
208
+ }
197
209
  /** Lets an overlay root delegate keyboard focus to components it owns. */
198
210
  export interface OverlayFocusOwner {
199
211
  /** Returns true when `component` is a focus target inside this overlay. */
@@ -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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@linxiraos/pi-tui",
4
- "version": "1.4.7",
4
+ "version": "1.4.9",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "homepage": "https://linxira-os.github.io/zeta/",
7
7
  "author": "Linxira-OS",
@@ -38,14 +38,14 @@
38
38
  "gen:glyphs": "bun scripts/gen-glyphs.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@linxiraos/pi-omptype": "1.4.7",
42
- "@linxiraos/pi-agent-core": "1.4.7",
43
- "@linxiraos/pi-ai": "1.4.7",
44
- "@linxiraos/pi-catalog": "1.4.7",
45
- "@linxiraos/pi-natives": "1.4.7",
46
- "@linxiraos/pi-utils": "1.4.7",
47
- "@linxiraos/pi-wire": "1.4.7",
48
- "@linxiraos/pi-snapcompact": "1.4.7"
41
+ "@linxiraos/pi-omptype": "1.4.9",
42
+ "@linxiraos/pi-agent-core": "1.4.9",
43
+ "@linxiraos/pi-ai": "1.4.9",
44
+ "@linxiraos/pi-catalog": "1.4.9",
45
+ "@linxiraos/pi-natives": "1.4.9",
46
+ "@linxiraos/pi-utils": "1.4.9",
47
+ "@linxiraos/pi-wire": "1.4.9",
48
+ "@linxiraos/pi-snapcompact": "1.4.9"
49
49
  },
50
50
  "devDependencies": {
51
51
  "kitty-vt-wasm": "^0.2.0"
@@ -24,6 +24,7 @@ interface AppKeybindings {
24
24
  "app.message.followUp": true;
25
25
  "app.retry": true;
26
26
  "app.message.dequeue": true;
27
+ "app.btw.inject": true;
27
28
  "app.clipboard.pasteImage": true;
28
29
  "app.clipboard.pasteTextRaw": true;
29
30
  "app.clipboard.copyLine": true;
@@ -272,6 +273,10 @@ export declare const KEYBINDINGS: {
272
273
  readonly defaultKeys: ["alt+up", "shift+up"];
273
274
  readonly description: "Dequeue message";
274
275
  };
276
+ readonly "app.btw.inject": {
277
+ readonly defaultKeys: "alt+i";
278
+ readonly description: "Send a /btw answer's steering prompt to the main session";
279
+ };
275
280
  readonly "app.clipboard.pasteImage": {
276
281
  readonly defaultKeys: KeyId[];
277
282
  readonly description: "Paste image or text from clipboard";
@@ -44,6 +44,7 @@ interface AppKeybindings {
44
44
  "app.message.followUp": true;
45
45
  "app.retry": true;
46
46
  "app.message.dequeue": true;
47
+ "app.btw.inject": true;
47
48
  "app.clipboard.pasteImage": true;
48
49
  "app.clipboard.pasteTextRaw": true;
49
50
  "app.clipboard.copyLine": true;
@@ -182,6 +183,10 @@ export const KEYBINDINGS = {
182
183
  defaultKeys: ["alt+up", "shift+up"],
183
184
  description: "Dequeue message",
184
185
  },
186
+ "app.btw.inject": {
187
+ defaultKeys: "alt+i",
188
+ description: "Send a /btw answer's steering prompt to the main session",
189
+ },
185
190
  "app.clipboard.pasteImage": {
186
191
  defaultKeys: getDefaultPasteImageKeys(),
187
192
  description: "Paste image or text from clipboard",
@@ -37,7 +37,7 @@ import { routeSgrMouseInput } from "../../mouse";
37
37
  import { col, compact, keyed, node, row, span, stableKey, text } from "../../native/describe";
38
38
  import { Memo } from "../../native/memo";
39
39
  import type { DescribeContext, NativeNode, NativeUiEvent } from "../../native/node";
40
- import { actionButton } from "../../native/overlay";
40
+ import { actionButton, iconButton, segmentedTabs } from "../../native/overlay";
41
41
  import { type Component, type OverlayHandle, TUI } from "../../tui";
42
42
  import { truncateToWidth, visibleWidth } from "../../utils";
43
43
  import { theme, warmHighlighter } from "../../theme/theme";
@@ -1039,35 +1039,28 @@ class GitTuiComponent implements Component {
1039
1039
  } else {
1040
1040
  left.push(text([span(this.#model.branch ?? "detached", "muted")], { role: "zeta.app.git.path" }));
1041
1041
  }
1042
- const iconButton = (name: string, act: string, title: string, on?: boolean): NativeNode =>
1043
- node(
1044
- "icon",
1045
- { name, title, aria: title, role: on ? "zeta.app.ibtn.set" : "zeta.app.ibtn", actions: { click: act } },
1046
- undefined,
1047
- act,
1048
- );
1042
+ const tool = (name: string, act: string, title: string, on?: boolean): NativeNode =>
1043
+ iconButton(name, act, title, { key: act, on });
1049
1044
  const right: NativeNode[] = [
1050
1045
  row(
1051
1046
  [
1052
- iconButton("chev-up", "prev-hunk", `Previous change (${formatTooltipKey("alt+up")})`),
1053
- iconButton("chev", "next-hunk", `Next change (${formatTooltipKey("alt+down")})`),
1047
+ tool("chev-up", "prev-hunk", `Previous change (${formatTooltipKey("alt+up")})`),
1048
+ tool("chev", "next-hunk", `Next change (${formatTooltipKey("alt+down")})`),
1054
1049
  ],
1055
1050
  { gap: "none", align: "center" },
1056
1051
  ),
1057
- node(
1058
- "tabs",
1052
+ segmentedTabs(
1059
1053
  {
1060
1054
  items: VIEW_TABS.map(tab => ({ id: tab.id, label: tab.label })),
1061
1055
  active: this.#pane.mode,
1062
1056
  role: "zeta.app.seg",
1063
1057
  },
1064
- undefined,
1065
1058
  "views",
1066
1059
  ),
1067
1060
  ];
1068
1061
  if (!narrow) {
1069
1062
  right.push(
1070
- iconButton(
1063
+ tool(
1071
1064
  "type",
1072
1065
  "whitespace",
1073
1066
  this.#whitespace === "off"
@@ -1077,7 +1070,7 @@ class GitTuiComponent implements Component {
1077
1070
  : `Ignoring formatting and imports; show all (${formatTooltipKey("b")})`,
1078
1071
  this.#whitespace !== "off",
1079
1072
  ),
1080
- iconButton("corner-down-right", "wrap", `Wrap lines (${formatTooltipKey("w")})`, this.#pane.wrap),
1073
+ tool("corner-down-right", "wrap", `Wrap lines (${formatTooltipKey("w")})`, this.#pane.wrap),
1081
1074
  );
1082
1075
  }
1083
1076
  if (file?.area === "unstaged" || file?.area === "staged") {
@@ -1089,8 +1082,8 @@ class GitTuiComponent implements Component {
1089
1082
  );
1090
1083
  }
1091
1084
  right.push(
1092
- iconButton("keyboard", "help", `Keyboard shortcuts (${formatTooltipKey("?")})`),
1093
- iconButton("x", "close", `Close (${formatTooltipKey("q")})`),
1085
+ tool("keyboard", "help", `Keyboard shortcuts (${formatTooltipKey("?")})`),
1086
+ tool("x", "close", `Close (${formatTooltipKey("q")})`),
1094
1087
  );
1095
1088
  return keyed(
1096
1089
  row(
@@ -20,6 +20,7 @@ import { matchesKey } from "../../keys";
20
20
  import { col, compact, item, keyed, list, node, row, span, stableKey, text } from "../../native/describe";
21
21
  import { Memo } from "../../native/memo";
22
22
  import type { DescribeContext, NativeChild, NativeNode, NativeUiEvent } from "../../native/node";
23
+ import { actionButton, iconButton, quietButton, segmentedTabs } from "../../native/overlay";
23
24
  import type { TspProps, TspSpan } from "@linxiraos/pi-wire";
24
25
  import { TERMINAL } from "../../terminal-capabilities";
25
26
  import { truncateToWidth, visibleWidth } from "../../utils";
@@ -237,11 +238,6 @@ class GitFileTree {
237
238
  }
238
239
  }
239
240
 
240
- /** A quiet text button (`Stage all`): a clickable row the role sheet draws as `.btn.quiet`. */
241
- function quietButton(label: string, act: string, title: string): NativeNode {
242
- return node("row", { role: "zeta.app.qbtn", actions: { click: act }, title }, [text(label)], act);
243
- }
244
-
245
241
  /** A text field at rest: its value (or placeholder) as text; a click starts editing it. */
246
242
  function fieldText(
247
243
  value: string,
@@ -1099,8 +1095,7 @@ export class Sidebar {
1099
1095
  }
1100
1096
 
1101
1097
  #describeStyleToggle(): NativeNode {
1102
- return node(
1103
- "tabs",
1098
+ return segmentedTabs(
1104
1099
  {
1105
1100
  items: [
1106
1101
  { id: "path", label: "Path" },
@@ -1109,7 +1104,6 @@ export class Sidebar {
1109
1104
  active: this.viewStyle,
1110
1105
  role: "zeta.app.seg",
1111
1106
  },
1112
- undefined,
1113
1107
  "style",
1114
1108
  );
1115
1109
  }
@@ -1128,18 +1122,10 @@ export class Sidebar {
1128
1122
  area === "unstaged"
1129
1123
  ? [
1130
1124
  quietButton("Stage all", "stage-all", "Stage every change (space on the head)"),
1131
- node(
1132
- "icon",
1133
- {
1134
- name: "wand",
1135
- role: "zeta.app.ibtn",
1136
- title: "Stage by description…",
1137
- aria: "Stage by description",
1138
- actions: { click: "stage-ai" },
1139
- },
1140
- undefined,
1141
- "ai",
1142
- ),
1125
+ iconButton("wand", "stage-ai", "Stage by description…", {
1126
+ key: "ai",
1127
+ aria: "Stage by description",
1128
+ }),
1143
1129
  ]
1144
1130
  : [quietButton("Unstage all", "unstage-all", "Unstage every change (space on the head)")];
1145
1131
  const head = row(
@@ -1264,8 +1250,13 @@ export class Sidebar {
1264
1250
  "zeta.app.git.body",
1265
1251
  );
1266
1252
  const hasChanges = this.#model.staged.length > 0 || this.#model.unstaged.length > 0 || this.amend;
1267
- const canCommit =
1268
- hasChanges && !this.generating && (summary.trim().length > 0 || description.trim().length === 0);
1253
+ const blocked = !hasChanges
1254
+ ? "Nothing to commit"
1255
+ : this.generating
1256
+ ? "Generating the commit message…"
1257
+ : summary.trim().length === 0 && description.trim().length > 0
1258
+ ? "Write a summary line first"
1259
+ : undefined;
1269
1260
  const label = this.generating
1270
1261
  ? "Generating message…"
1271
1262
  : summary.trim().length === 0 && description.trim().length === 0
@@ -1273,8 +1264,13 @@ export class Sidebar {
1273
1264
  : this.#model.staged.length > 0
1274
1265
  ? "Commit"
1275
1266
  : "Stage all & commit";
1276
- // The panels' button (zeta-panels.css `zeta.btn`): accent while the keyboard is on it, muted when it can't run.
1277
- const commitTone = !canCommit ? "muted" : on({ kind: "commit-button" }) ? "accent" : undefined;
1267
+ // The panels' button: the primary while the keyboard is on it, disabled (saying why) when it can't run.
1268
+ const commit = actionButton(label, "commit", {
1269
+ title: this.#model.staged.length > 0 ? "Commit the staged changes" : "Stage everything, then commit",
1270
+ busy: this.generating,
1271
+ disabled: blocked,
1272
+ tone: on({ kind: "commit-button" }) ? "accent" : undefined,
1273
+ });
1278
1274
  return col(
1279
1275
  [
1280
1276
  keyed(summaryField, "summary"),
@@ -1289,17 +1285,7 @@ export class Sidebar {
1289
1285
  actions: { click: "amend" },
1290
1286
  title: "Amend the previous commit",
1291
1287
  }),
1292
- row(compact([this.generating && node("spinner", { style: "dots" }), text(label)]), {
1293
- gap: "xs",
1294
- align: "center",
1295
- role: "zeta.btn",
1296
- tone: commitTone,
1297
- actions: canCommit ? { click: "commit" } : undefined,
1298
- title:
1299
- this.#model.staged.length > 0
1300
- ? "Commit the staged changes"
1301
- : "Stage everything, then commit",
1302
- }),
1288
+ commit,
1303
1289
  ],
1304
1290
  { justify: "between", align: "center", role: "zeta.app.git.foot" },
1305
1291
  ),