@linxiraos/pi-tui 1.4.7 → 1.4.10

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 (181) hide show
  1. package/CHANGELOG.md +154 -231
  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/setup/scenes/language.d.ts +3 -0
  33. package/dist/types/setup/scenes/types.d.ts +5 -0
  34. package/dist/types/setup/setup-version.d.ts +1 -1
  35. package/dist/types/setup/wizard.d.ts +1 -1
  36. package/dist/types/status-line/startup.d.ts +0 -15
  37. package/dist/types/terminal-capabilities.d.ts +1 -1
  38. package/dist/types/theme/symbols.d.ts +3 -1
  39. package/dist/types/theme/theme-class.d.ts +1 -0
  40. package/dist/types/theme/theme.d.ts +1 -1
  41. package/dist/types/theme/tui-adapters.d.ts +2 -0
  42. package/dist/types/thinking.d.ts +8 -6
  43. package/dist/types/tools/ast-grep.d.ts +2 -0
  44. package/dist/types/tools/eval.d.ts +2 -0
  45. package/dist/types/tools/find.d.ts +1 -1
  46. package/dist/types/tools/grouped-file-output.d.ts +100 -19
  47. package/dist/types/tools/hashline-format.d.ts +5 -0
  48. package/dist/types/tools/native-view.d.ts +2 -0
  49. package/dist/types/tools/output-meta.d.ts +27 -0
  50. package/dist/types/tools/read.d.ts +14 -4
  51. package/dist/types/tools/task.d.ts +4 -3
  52. package/dist/types/tools/wait.d.ts +2 -0
  53. package/dist/types/tui.d.ts +12 -0
  54. package/dist/types/utils.d.ts +4 -0
  55. package/package.json +9 -9
  56. package/src/app-keybindings.d.ts +5 -0
  57. package/src/app-keybindings.ts +5 -0
  58. package/src/apps/git/git-tui.ts +10 -17
  59. package/src/apps/git/sidebar.ts +21 -35
  60. package/src/apps/ps-top.ts +4 -12
  61. package/src/charts/chart-plan.ts +0 -29
  62. package/src/charts/table-data.d.ts +4 -2
  63. package/src/charts/table-data.ts +55 -6
  64. package/src/chat/bash-execution.d.ts +4 -1
  65. package/src/chat/bash-execution.ts +20 -9
  66. package/src/chat/chat-transcript-builder.ts +5 -2
  67. package/src/chat/eval-execution.d.ts +2 -0
  68. package/src/chat/eval-execution.ts +14 -7
  69. package/src/chat/execution-shared.d.ts +14 -8
  70. package/src/chat/execution-shared.ts +39 -18
  71. package/src/chat/figure-markdown.d.ts +2 -0
  72. package/src/chat/figure-markdown.ts +6 -4
  73. package/src/chat/read-tool-group.ts +56 -36
  74. package/src/chat/svg-figure.d.ts +5 -0
  75. package/src/chat/svg-figure.ts +55 -16
  76. package/src/chat/table-chart.d.ts +2 -0
  77. package/src/chat/table-chart.ts +19 -2
  78. package/src/chat/transcript-render-helpers.d.ts +11 -3
  79. package/src/chat/transcript-render-helpers.ts +70 -22
  80. package/src/chrome/dynamic-border.d.ts +6 -0
  81. package/src/chrome/dynamic-border.ts +28 -2
  82. package/src/chrome/transcript-status.d.ts +2 -2
  83. package/src/chrome/transcript-status.ts +5 -3
  84. package/src/components/editor.d.ts +15 -6
  85. package/src/components/editor.ts +123 -24
  86. package/src/components/image.d.ts +6 -0
  87. package/src/components/image.ts +13 -0
  88. package/src/components/key-value-list.ts +9 -9
  89. package/src/components/loader.d.ts +2 -0
  90. package/src/components/loader.ts +7 -0
  91. package/src/components/section.ts +1 -9
  92. package/src/components/table.ts +1 -9
  93. package/src/keybinding-matchers.d.ts +7 -0
  94. package/src/keybinding-matchers.ts +13 -0
  95. package/src/native/backend.ts +7 -3
  96. package/src/native/describe.d.ts +4 -2
  97. package/src/native/describe.ts +9 -4
  98. package/src/native/node.d.ts +2 -3
  99. package/src/native/node.ts +2 -3
  100. package/src/native/overlay.d.ts +42 -2
  101. package/src/native/overlay.ts +124 -16
  102. package/src/native/state.d.ts +4 -0
  103. package/src/native/state.ts +25 -5
  104. package/src/overlays/btw-history-panel.ts +106 -14
  105. package/src/overlays/btw-history.ts +65 -0
  106. package/src/overlays/btw-inject.ts +91 -0
  107. package/src/overlays/btw-panel.ts +53 -12
  108. package/src/overlays/extensions/extension-dashboard.ts +7 -8
  109. package/src/overlays/hook-editor.ts +6 -0
  110. package/src/overlays/jobs-panel.ts +82 -22
  111. package/src/overlays/login-dialog.ts +8 -26
  112. package/src/overlays/model-browser.ts +69 -10
  113. package/src/overlays/session-selector.ts +25 -5
  114. package/src/overlays/settings-defs.ts +2 -2
  115. package/src/overlays/settings-selector.ts +113 -11
  116. package/src/overlays/tree-selector.ts +83 -27
  117. package/src/overlays/usage-dashboard.ts +4 -6
  118. package/src/prompt/composer.ts +17 -5
  119. package/src/render/code-cell.ts +1 -1
  120. package/src/render/file-list.ts +4 -7
  121. package/src/render/render-utils.d.ts +23 -1
  122. package/src/render/render-utils.ts +38 -6
  123. package/src/setup/scenes/glyph.ts +1 -1
  124. package/src/setup/scenes/language.ts +122 -0
  125. package/src/setup/scenes/types.ts +6 -0
  126. package/src/setup/setup-version.ts +1 -1
  127. package/src/setup/wizard.ts +2 -0
  128. package/src/status-line/startup.ts +36 -70
  129. package/src/terminal-capabilities.d.ts +1 -1
  130. package/src/terminal-capabilities.ts +5 -0
  131. package/src/theme/symbols.d.ts +3 -1
  132. package/src/theme/symbols.ts +16 -9
  133. package/src/theme/theme-class.d.ts +1 -0
  134. package/src/theme/theme-class.ts +15 -3
  135. package/src/theme/theme.d.ts +1 -1
  136. package/src/theme/theme.ts +1 -0
  137. package/src/theme/tui-adapters.d.ts +2 -0
  138. package/src/theme/tui-adapters.ts +8 -3
  139. package/src/thinking.d.ts +8 -6
  140. package/src/thinking.ts +17 -11
  141. package/src/tmux.ts +1 -0
  142. package/src/tools/agent-tree.ts +13 -11
  143. package/src/tools/ask.ts +24 -37
  144. package/src/tools/ast-edit.ts +48 -93
  145. package/src/tools/ast-grep.d.ts +2 -0
  146. package/src/tools/ast-grep.ts +31 -67
  147. package/src/tools/bash.ts +7 -0
  148. package/src/tools/default-renderer.ts +1 -1
  149. package/src/tools/edit.ts +50 -43
  150. package/src/tools/eval.d.ts +2 -0
  151. package/src/tools/eval.ts +2 -0
  152. package/src/tools/fetch.ts +2 -1
  153. package/src/tools/find.d.ts +1 -1
  154. package/src/tools/find.ts +13 -5
  155. package/src/tools/github.ts +14 -46
  156. package/src/tools/glob.ts +2 -1
  157. package/src/tools/grep.ts +47 -277
  158. package/src/tools/grouped-file-output.d.ts +100 -19
  159. package/src/tools/grouped-file-output.ts +414 -103
  160. package/src/tools/hashline-format.d.ts +5 -0
  161. package/src/tools/hashline-format.ts +5 -0
  162. package/src/tools/json-tree.ts +1 -5
  163. package/src/tools/lsp.ts +210 -32
  164. package/src/tools/native-view.d.ts +2 -0
  165. package/src/tools/native-view.ts +11 -5
  166. package/src/tools/output-meta.d.ts +27 -0
  167. package/src/tools/output-meta.ts +68 -4
  168. package/src/tools/proc-render.ts +3 -3
  169. package/src/tools/read.d.ts +14 -4
  170. package/src/tools/read.ts +20 -5
  171. package/src/tools/task.d.ts +4 -3
  172. package/src/tools/task.ts +41 -81
  173. package/src/tools/vibe.ts +4 -4
  174. package/src/tools/wait.d.ts +2 -0
  175. package/src/tools/wait.ts +8 -5
  176. package/src/tools/write.ts +17 -27
  177. package/src/tools/yield.ts +1 -1
  178. package/src/tui.d.ts +12 -0
  179. package/src/tui.ts +91 -9
  180. package/src/utils.d.ts +4 -0
  181. package/src/utils.ts +10 -0
@@ -6,7 +6,7 @@ export { getAvailableThemes, getAvailableThemesWithPaths, getThemeByName, type T
6
6
  export { isValidThemeColor, type ThemeBg, type ThemeColor } from "./schema.js";
7
7
  export { getAvailableSymbolPresets, isValidSymbolPreset, type SpinnerType, type SymbolKey, type SymbolPreset, } from "./symbols.js";
8
8
  export { Theme } from "./theme-class.js";
9
- export { createHighlightStream, getEditorTheme, getMarkdownTheme, getMarkdownThemeWithLinkTargets, getSelectListTheme, getSettingsListTheme, getSymbolTheme, highlightCode, setMarkdownMermaidRendering, warmHighlighter, } from "./tui-adapters.js";
9
+ export { createHighlightStream, getEditorTheme, getMarkdownTheme, getMarkdownThemeWithLinkTargets, getSelectListTheme, getSettingsListTheme, getSymbolTheme, highlightCode, isHighlightLanguage, setMarkdownMermaidRendering, warmHighlighter, } from "./tui-adapters.js";
10
10
  /**
11
11
  * Subscribe to native fallback appearance changes independently of theme changes.
12
12
  * Consumers must re-check the effective background: COLORFGBG can override it.
@@ -6,6 +6,8 @@ import type { SettingsListTheme } from "../components/settings-list.js";
6
6
  import type { SymbolTheme } from "../symbols.js";
7
7
  import type { SlashCommandIconName } from "./symbols.js";
8
8
  import type { Theme } from "./theme-class.js";
9
+ /** Whether {@link highlightCode} colors `lang`; text in any other language comes back unstyled. */
10
+ export declare function isHighlightLanguage(lang: string | undefined): lang is string;
9
11
  /**
10
12
  * Highlight code with syntax coloring based on file extension or language.
11
13
  * Returns array of highlighted lines.
@@ -137,12 +137,12 @@ export type TaskEffort = (typeof TASK_EFFORTS)[number];
137
137
  export declare function resolveTaskEffortLevel(model: Model | undefined, effort: TaskEffort, maxEffort?: Effort): Effort | undefined;
138
138
  /**
139
139
  * Clamps a concrete thinking selector to a per-session effort ceiling (e.g. a
140
- * task spawn's `task.maxEffort`-capped effort hint). `off`/`inherit`/
141
- * `undefined` pass through, as do levels already at or below the ceiling.
142
- * Levels above it snap to the highest model-supported effort at or below the
143
- * ceiling. A model whose floor exceeds the ceiling has nothing valid to snap
144
- * to; the requested level is returned unchanged and the caller is responsible
145
- * for rejecting or skipping such models (see {@link modelSupportsEffortCeiling}).
140
+ * task spawn's `task.maxEffort`). Unset/`inherit`/`off` retain their existing
141
+ * meaning, as do levels already at or below the ceiling. Levels above it snap
142
+ * to the highest model-supported effort at or below the ceiling. A model whose
143
+ * floor exceeds the ceiling has nothing valid to snap to; the requested level
144
+ * is returned unchanged and the caller must reject or skip such models (see
145
+ * {@link modelSupportsEffortCeiling}).
146
146
  */
147
147
  export declare function clampThinkingLevelToCeiling(model: Model | undefined, level: Effort | undefined, ceiling: Effort | undefined): Effort | undefined;
148
148
  export declare function clampThinkingLevelToCeiling(model: Model | undefined, level: ThinkingLevel | undefined, ceiling: Effort | undefined): ThinkingLevel | undefined;
@@ -153,6 +153,8 @@ export declare function clampThinkingLevelToCeiling(model: Model | undefined, le
153
153
  * skip models whose floor would force the session above the ceiling.
154
154
  */
155
155
  export declare function modelSupportsEffortCeiling(model: Model, ceiling: Effort): boolean;
156
+ /** Throws when `model` has no supported effort at or below `task.maxEffort`, so a capped spawn fails instead of running at its floor. */
157
+ export declare function assertModelSupportsEffortCeiling(model: Model, maxEffort: Effort): void;
156
158
  /**
157
159
  * The provisional concrete level shown while `auto` is configured but before a
158
160
  * turn has been classified, and the fallback when classification fails. Prefers
@@ -34,6 +34,8 @@ interface AstGrepRenderArgs {
34
34
  /** Legacy pre-`path` argument name; kept so historical transcripts still render a scope. */
35
35
  paths?: string[];
36
36
  skip?: number;
37
+ /** Language the search parsed the files as; highlighting follows it over the file extension. */
38
+ lang?: string;
37
39
  }
38
40
  /** Render AST grep calls and results. */
39
41
  export declare const astGrepToolRenderer: {
@@ -71,6 +71,8 @@ export interface EvalToolDetails {
71
71
  statusEvents?: EvalStatusEvent[];
72
72
  /** Evictable events dropped from the front of `statusEvents` (see {@link recordStatusEvent}). */
73
73
  statusEventsElided?: number;
74
+ /** Text the cell's tool calls sent to `out://`, oldest first; transcripts draw each as a reply after the call. */
75
+ replies?: string[];
74
76
  isError?: boolean;
75
77
  meta?: OutputMeta;
76
78
  /** First backend that produced cells. Kept for transcript compatibility. */
@@ -1,4 +1,4 @@
1
- import type { Theme } from "../theme/theme.js";
1
+ import { type Theme } from "../theme/theme.js";
2
2
  import type { Component } from "../tui.js";
3
3
  import type { OutputMeta } from "./output-meta.js";
4
4
  import type { NativeToolView, RenderResultContextOptions, RenderResultOptions } from "./renderer.js";
@@ -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.10",
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.10",
42
+ "@linxiraos/pi-agent-core": "1.4.10",
43
+ "@linxiraos/pi-ai": "1.4.10",
44
+ "@linxiraos/pi-catalog": "1.4.10",
45
+ "@linxiraos/pi-natives": "1.4.10",
46
+ "@linxiraos/pi-utils": "1.4.10",
47
+ "@linxiraos/pi-wire": "1.4.10",
48
+ "@linxiraos/pi-snapcompact": "1.4.10"
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(