@linxiraos/pi-tui 1.4.11 → 1.4.13
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 +30 -233
- package/README.md +4 -1
- package/THIRD-PARTY-NOTICES.txt +4 -5
- package/dist/types/apps/shell-visualizer.d.ts +24 -0
- package/dist/types/autocomplete.d.ts +20 -0
- package/dist/types/chat/cache-invalidation-marker.d.ts +15 -7
- package/dist/types/chat/chat-transcript-builder.d.ts +5 -3
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +72 -1
- package/dist/types/chat/image-loading.d.ts +2 -2
- package/dist/types/chat/messages.d.ts +2 -3
- package/dist/types/chat/read-tool-group.d.ts +15 -2
- package/dist/types/chat/skill-message.d.ts +1 -0
- package/dist/types/chat/spotlight.d.ts +203 -0
- package/dist/types/chat/tool-execution.d.ts +26 -5
- package/dist/types/chat/transcript-actions.d.ts +11 -0
- package/dist/types/chat/transcript-browser.d.ts +9 -0
- package/dist/types/chat/transcript-presentation.d.ts +164 -0
- package/dist/types/chat/ttsr-notification.d.ts +2 -0
- package/dist/types/chrome/message-frame.d.ts +2 -0
- package/dist/types/chrome/transcript-container.d.ts +27 -6
- package/dist/types/components/loader.d.ts +0 -2
- package/dist/types/components/markdown.d.ts +11 -1
- package/dist/types/components/settings-list.d.ts +12 -2
- package/dist/types/frame-rate.d.ts +18 -0
- package/dist/types/hotkeys-markdown.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/keybinding-matchers.d.ts +4 -1
- package/dist/types/kitty-graphics.d.ts +1 -1
- package/dist/types/motion-effects.d.ts +10 -0
- package/dist/types/native/encode.d.ts +2 -0
- package/dist/types/native/measure.d.ts +10 -0
- package/dist/types/native/overlay.d.ts +1 -1
- package/dist/types/native/quiet.d.ts +5 -0
- package/dist/types/native/reconcile.d.ts +6 -1
- package/dist/types/native/spans.d.ts +6 -0
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/agent-hub.d.ts +6 -0
- package/dist/types/overlays/link-browser.d.ts +55 -0
- package/dist/types/overlays/running-subagent-badge.d.ts +1 -4
- package/dist/types/overlays/spotlight-sheet.d.ts +36 -0
- package/dist/types/prompt/composer-attachments.d.ts +5 -2
- package/dist/types/prompt/composer-cache.d.ts +7 -2
- package/dist/types/prompt/composer.d.ts +6 -11
- package/dist/types/prompt/custom-editor.d.ts +8 -2
- package/dist/types/prompt/gradient-highlight.d.ts +2 -2
- package/dist/types/prompt/magic-keywords.d.ts +2 -0
- package/dist/types/prompt/model-mention-autocomplete.d.ts +9 -7
- package/dist/types/prompt/model-mention-syntax.d.ts +6 -0
- package/dist/types/prompt/prompt-action-autocomplete.d.ts +2 -1
- package/dist/types/prompt/welcome.d.ts +19 -0
- package/dist/types/render/extension-links.d.ts +0 -6
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/link-hints.d.ts +78 -0
- package/dist/types/render/render-utils.d.ts +0 -2
- package/dist/types/setup/scenes/types.d.ts +8 -0
- package/dist/types/setup/scenes/updates.d.ts +6 -0
- package/dist/types/setup/wizard.d.ts +7 -2
- package/dist/types/spinner-clock.d.ts +34 -0
- package/dist/types/status-line/component.d.ts +8 -4
- package/dist/types/status-line/host.d.ts +62 -0
- package/dist/types/status-line/index.d.ts +1 -0
- package/dist/types/status-line/prompt-cache.d.ts +14 -0
- package/dist/types/status-line/schema.d.ts +1 -1
- package/dist/types/status-line/startup.d.ts +6 -0
- package/dist/types/status-line/types.d.ts +8 -21
- package/dist/types/theme/schema.d.ts +28 -1
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme-class.d.ts +12 -2
- package/dist/types/theme/theme.d.ts +1 -1
- package/dist/types/theme/tui-adapters.d.ts +7 -0
- package/dist/types/thinking.d.ts +12 -0
- package/dist/types/tools/ask.d.ts +1 -1
- package/dist/types/tools/bash.d.ts +21 -0
- package/dist/types/tools/find.d.ts +9 -1
- package/dist/types/tools/grep.d.ts +2 -1
- package/dist/types/tools/grouped-file-output.d.ts +17 -0
- package/dist/types/tools/job-widget.d.ts +2 -2
- package/dist/types/tools/lsp.d.ts +4 -2
- package/dist/types/tools/native-view.d.ts +4 -0
- package/dist/types/tools/renderer.d.ts +9 -1
- package/dist/types/tools/shell-trace.d.ts +10 -0
- package/dist/types/tools/shell-viz-render.d.ts +6 -0
- package/dist/types/tools/shell-viz.d.ts +16 -0
- package/dist/types/tools/wait.d.ts +2 -2
- package/dist/types/tools/web-search-types.d.ts +1 -0
- package/dist/types/tools/write.d.ts +2 -0
- package/dist/types/tui.d.ts +15 -1
- package/package.json +15 -11
- package/src/apps/shell-visualizer.d.ts +24 -0
- package/src/apps/shell-visualizer.ts +167 -0
- package/src/autocomplete.d.ts +20 -0
- package/src/autocomplete.ts +14 -0
- package/src/chat/assistant-message.ts +11 -6
- package/src/chat/cache-invalidation-marker.d.ts +15 -7
- package/src/chat/cache-invalidation-marker.ts +18 -9
- package/src/chat/chat-transcript-builder.d.ts +5 -3
- package/src/chat/chat-transcript-builder.ts +16 -12
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.d.ts +72 -1
- package/src/chat/extension-types.ts +74 -1
- package/src/chat/image-loading.d.ts +2 -2
- package/src/chat/image-loading.ts +2 -2
- package/src/chat/messages.d.ts +2 -3
- package/src/chat/messages.ts +3 -8
- package/src/chat/read-tool-group.d.ts +15 -2
- package/src/chat/read-tool-group.ts +201 -41
- package/src/chat/skill-message.d.ts +1 -0
- package/src/chat/skill-message.ts +4 -0
- package/src/chat/spotlight.d.ts +203 -0
- package/src/chat/spotlight.ts +460 -0
- package/src/chat/tool-execution.d.ts +26 -5
- package/src/chat/tool-execution.ts +360 -38
- package/src/chat/transcript-actions.d.ts +11 -0
- package/src/chat/transcript-actions.ts +13 -1
- package/src/chat/transcript-browser.d.ts +9 -0
- package/src/chat/transcript-browser.ts +18 -0
- package/src/chat/transcript-presentation.d.ts +164 -0
- package/src/chat/transcript-presentation.ts +642 -0
- package/src/chat/ttsr-notification.d.ts +25 -0
- package/src/chat/ttsr-notification.ts +5 -0
- package/src/chrome/message-frame.d.ts +2 -0
- package/src/chrome/message-frame.ts +7 -0
- package/src/chrome/message-notice.d.ts +58 -0
- package/src/chrome/transcript-container.d.ts +27 -6
- package/src/chrome/transcript-container.ts +317 -66
- package/src/components/editor.ts +25 -1
- package/src/components/loader.d.ts +0 -2
- package/src/components/loader.ts +30 -18
- package/src/components/markdown.d.ts +11 -1
- package/src/components/markdown.ts +41 -16
- package/src/components/settings-list.d.ts +12 -2
- package/src/components/settings-list.ts +29 -13
- package/src/frame-rate.d.ts +18 -0
- package/src/frame-rate.ts +36 -0
- package/src/hotkeys-markdown.ts +9 -2
- package/src/index.d.ts +3 -0
- package/src/index.ts +3 -0
- package/src/keybinding-matchers.d.ts +4 -1
- package/src/keybinding-matchers.ts +13 -12
- package/src/kitty-graphics.d.ts +1 -1
- package/src/kitty-graphics.ts +3 -2
- package/src/motion-effects.d.ts +10 -0
- package/src/motion-effects.ts +27 -0
- package/src/native/backend.ts +66 -7
- package/src/native/encode.d.ts +2 -0
- package/src/native/encode.ts +2 -0
- package/src/native/measure.d.ts +10 -0
- package/src/native/measure.ts +185 -0
- package/src/native/overlay.d.ts +1 -1
- package/src/native/overlay.ts +1 -1
- package/src/native/quiet.d.ts +5 -0
- package/src/native/quiet.ts +105 -0
- package/src/native/reconcile.d.ts +6 -1
- package/src/native/reconcile.ts +16 -10
- package/src/native/spans.d.ts +6 -0
- package/src/native/spans.ts +40 -0
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +18 -0
- package/src/overlays/agent-hub.ts +15 -2
- package/src/overlays/ask-dialog.ts +1 -0
- package/src/overlays/btw-history-panel.ts +73 -6
- package/src/overlays/link-browser.ts +295 -0
- package/src/overlays/running-subagent-badge.ts +2 -9
- package/src/overlays/settings-defs.ts +1 -1
- package/src/overlays/settings-selector.ts +17 -3
- package/src/overlays/spotlight-sheet.ts +478 -0
- package/src/overlays/usage-dashboard.ts +6 -5
- package/src/prompt/composer-attachments.d.ts +5 -2
- package/src/prompt/composer-attachments.ts +6 -6
- package/src/prompt/composer-cache.ts +17 -16
- package/src/prompt/composer.ts +30 -123
- package/src/prompt/custom-editor.ts +17 -13
- package/src/prompt/gradient-highlight.d.ts +2 -2
- package/src/prompt/gradient-highlight.ts +5 -4
- package/src/prompt/magic-keywords.d.ts +2 -0
- package/src/prompt/magic-keywords.ts +4 -1
- package/src/prompt/model-mention-autocomplete.ts +73 -20
- package/src/prompt/model-mention-syntax.d.ts +6 -0
- package/src/prompt/model-mention-syntax.ts +9 -0
- package/src/prompt/prompt-action-autocomplete.ts +49 -33
- package/src/prompt/tips.txt +1 -0
- package/src/prompt/welcome.ts +104 -2
- package/src/render/extension-links.d.ts +0 -6
- package/src/render/extension-links.ts +0 -20
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/link-hints.d.ts +78 -0
- package/src/render/link-hints.ts +299 -0
- package/src/render/render-utils.d.ts +0 -2
- package/src/render/render-utils.ts +0 -5
- package/src/setup/scenes/glyph.ts +1 -1
- package/src/setup/scenes/types.ts +8 -0
- package/src/setup/scenes/updates.ts +116 -0
- package/src/setup/wizard.ts +19 -8
- package/src/spinner-clock.d.ts +34 -0
- package/src/spinner-clock.ts +79 -0
- package/src/status-line/component.ts +145 -53
- package/src/status-line/host.ts +51 -0
- package/src/status-line/index.ts +1 -0
- package/src/status-line/presets.ts +3 -1
- package/src/status-line/prompt-cache.ts +154 -0
- package/src/status-line/schema.ts +1 -1
- package/src/status-line/segments.ts +33 -22
- package/src/status-line/startup.ts +22 -4
- package/src/status-line/types.ts +8 -22
- package/src/stdin-buffer.ts +89 -46
- package/src/terminal-capabilities.ts +3 -3
- package/src/terminal.ts +1 -8
- package/src/theme/loader.ts +3 -2
- package/src/theme/schema.d.ts +28 -1
- package/src/theme/schema.ts +30 -1
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +15 -3
- package/src/theme/theme-class.d.ts +12 -2
- package/src/theme/theme-class.ts +23 -0
- package/src/theme/theme-schema.json +1 -1
- package/src/theme/theme.d.ts +1 -1
- package/src/theme/theme.ts +3 -7
- package/src/theme/tui-adapters.d.ts +7 -0
- package/src/theme/tui-adapters.ts +33 -1
- package/src/thinking.d.ts +12 -0
- package/src/thinking.ts +31 -0
- package/src/tools/ask.d.ts +1 -1
- package/src/tools/ask.ts +99 -38
- package/src/tools/ast-edit.ts +51 -32
- package/src/tools/ast-grep.ts +31 -19
- package/src/tools/bash.d.ts +21 -0
- package/src/tools/bash.ts +166 -24
- package/src/tools/find.d.ts +9 -1
- package/src/tools/find.ts +23 -2
- package/src/tools/grep.d.ts +2 -1
- package/src/tools/grep.ts +52 -36
- package/src/tools/grouped-file-output.d.ts +17 -0
- package/src/tools/grouped-file-output.ts +20 -2
- package/src/tools/job-widget.d.ts +2 -2
- package/src/tools/job-widget.ts +2 -2
- package/src/tools/lsp.d.ts +4 -2
- package/src/tools/lsp.ts +537 -642
- package/src/tools/native-view.d.ts +4 -0
- package/src/tools/native-view.ts +8 -2
- package/src/tools/renderer.d.ts +9 -1
- package/src/tools/renderer.ts +9 -1
- package/src/tools/shell-trace.d.ts +10 -0
- package/src/tools/shell-trace.ts +80 -0
- package/src/tools/shell-viz-render.d.ts +6 -0
- package/src/tools/shell-viz-render.ts +156 -0
- package/src/tools/shell-viz.d.ts +16 -0
- package/src/tools/shell-viz.ts +181 -0
- package/src/tools/streaming-output.ts +18 -8
- package/src/tools/wait.d.ts +2 -2
- package/src/tools/wait.ts +39 -34
- package/src/tools/web-search-types.d.ts +1 -0
- package/src/tools/web-search-types.ts +1 -0
- package/src/tools/write.d.ts +2 -0
- package/src/tools/write.ts +2 -0
- package/src/tui.d.ts +15 -1
- package/src/tui.ts +63 -6
- package/src/windows-input-mode.ts +7 -1
- package/dist/types/chat/collab-prompt-message.d.ts +0 -14
- package/dist/types/chrome/collab-qrcode.d.ts +0 -35
- package/src/chat/collab-prompt-message.d.ts +0 -14
- package/src/chat/collab-prompt-message.ts +0 -46
- package/src/chrome/collab-qrcode.ts +0 -99
package/src/tools/ast-edit.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
classifyGroupedLines,
|
|
15
15
|
createGroupedRowStyler,
|
|
16
16
|
fitGroupsToBudget,
|
|
17
|
+
formatScopedSubject,
|
|
17
18
|
groupedLinkTargets,
|
|
18
19
|
groupLineIndicesByBlank,
|
|
19
20
|
groupsByFile,
|
|
@@ -93,6 +94,27 @@ function patternPreview(pat: string | undefined): string | undefined {
|
|
|
93
94
|
return collapsed || undefined;
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
/** The single rewrite's pattern preview, or `N rewrites` for several. */
|
|
98
|
+
function rewriteLabel(args: AstEditRenderArgs | undefined): string | undefined {
|
|
99
|
+
const rewriteCount = args?.ops?.length ?? 0;
|
|
100
|
+
if (rewriteCount === 1) return patternPreview(args?.ops?.[0]?.pat);
|
|
101
|
+
return rewriteCount > 1 ? `${rewriteCount} rewrites` : undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Header subject: `pattern in scope` (or `N rewrites in scope`). The scope is the
|
|
106
|
+
* result's display scope, else the call's requested paths, as in Grep and AST Grep.
|
|
107
|
+
*/
|
|
108
|
+
function astEditSubject(
|
|
109
|
+
label: string | undefined,
|
|
110
|
+
args: AstEditRenderArgs | undefined,
|
|
111
|
+
theme: Theme,
|
|
112
|
+
scopePath?: string,
|
|
113
|
+
): string | undefined {
|
|
114
|
+
const scope = scopePath || args?.paths?.join(", ") || undefined;
|
|
115
|
+
return formatScopedSubject(label, scope, theme);
|
|
116
|
+
}
|
|
117
|
+
|
|
96
118
|
const AST_EDIT_CHANGE_LINE_RE = /^([+\- ])\s*(\d+)(?:│|[:|])(.*)$/;
|
|
97
119
|
|
|
98
120
|
/** One file's proposed rewrite: its unified diff text and change counts. */
|
|
@@ -140,12 +162,9 @@ function astEditDiff(file: AstEditFileDiff): NativeNode {
|
|
|
140
162
|
|
|
141
163
|
/** The single rewrite pattern (`target:"pattern"`), or the rewrite count, for the head. */
|
|
142
164
|
function astEditPatternHead(args: AstEditRenderArgs | undefined): Pick<NativeToolHead, "target" | "targetKind"> {
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
return pattern ? { target: pattern, targetKind: "pattern" } : {};
|
|
147
|
-
}
|
|
148
|
-
return rewriteCount > 1 ? { target: `${rewriteCount} rewrites`, targetKind: "text" } : {};
|
|
165
|
+
const label = rewriteLabel(args);
|
|
166
|
+
if (!label) return {};
|
|
167
|
+
return { target: label, targetKind: args?.ops?.length === 1 ? "pattern" : "text" };
|
|
149
168
|
}
|
|
150
169
|
|
|
151
170
|
/** Scope facts for the final quiet line: `in src · searched 12 files · limit reached; narrow path`. */
|
|
@@ -161,14 +180,8 @@ function astEditScopeStats(details: AstEditToolDetails | undefined): NativeNode
|
|
|
161
180
|
export const astEditToolRenderer = {
|
|
162
181
|
inline: true,
|
|
163
182
|
renderCall(args: AstEditRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component {
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
const rewriteCount = args.ops?.length ?? 0;
|
|
167
|
-
if (rewriteCount > 1) meta.push(`${rewriteCount} rewrites`);
|
|
168
|
-
|
|
169
|
-
const description =
|
|
170
|
-
rewriteCount === 1 ? patternPreview(args.ops?.[0]?.pat) : rewriteCount ? `${rewriteCount} rewrites` : "?";
|
|
171
|
-
const header = renderStatusLine({ icon: "pending", title: "AST Edit", description, meta }, uiTheme);
|
|
183
|
+
const description = astEditSubject(rewriteLabel(args) ?? "?", args, uiTheme);
|
|
184
|
+
const header = renderStatusLine({ icon: "pending", title: "AST Edit", description }, uiTheme);
|
|
172
185
|
// Pending call has no body yet — a lone status line is sleeker than an empty frame.
|
|
173
186
|
return new Text(header, 0, 0);
|
|
174
187
|
},
|
|
@@ -180,10 +193,11 @@ export const astEditToolRenderer = {
|
|
|
180
193
|
args?: AstEditRenderArgs,
|
|
181
194
|
): Component {
|
|
182
195
|
const details = result.details;
|
|
196
|
+
const description = astEditSubject(rewriteLabel(args), args, uiTheme, details?.scopePath);
|
|
183
197
|
|
|
184
198
|
if (result.isError) {
|
|
185
199
|
const errorText = result.content?.find(c => c.type === "text")?.text || "Unknown error";
|
|
186
|
-
const header = renderStatusLine({ icon: "error", title: "AST Edit" }, uiTheme);
|
|
200
|
+
const header = renderStatusLine({ icon: "error", title: "AST Edit", description }, uiTheme);
|
|
187
201
|
return framedToolCard(uiTheme, () => ({
|
|
188
202
|
header,
|
|
189
203
|
sections: [{ content: formatErrorDetail(errorText, uiTheme).split("\n") }],
|
|
@@ -198,32 +212,31 @@ export const astEditToolRenderer = {
|
|
|
198
212
|
const limitReached = details?.limitReached ?? false;
|
|
199
213
|
|
|
200
214
|
if (totalReplacements === 0) {
|
|
201
|
-
const rewriteCount = args?.ops?.length ?? 0;
|
|
202
|
-
const description = rewriteCount === 1 ? patternPreview(args?.ops?.[0]?.pat) : undefined;
|
|
203
215
|
const meta = ["0 replacements"];
|
|
204
|
-
if (details?.scopePath) meta.push(`in ${details.scopePath}`);
|
|
205
216
|
if (filesSearched > 0) meta.push(`searched ${filesSearched}`);
|
|
206
|
-
|
|
207
|
-
//
|
|
208
|
-
// errors are worth a body, so frame solely when there are some.
|
|
217
|
+
// Only parse errors are worth a body, so frame solely when there are some; a
|
|
218
|
+
// framed card carries the counts in its bottom border, as a successful one does.
|
|
209
219
|
const bodyLines: string[] = [];
|
|
210
220
|
appendParseErrorsBulletList(bodyLines, details?.parseErrors, uiTheme, details?.parseErrorsTotal);
|
|
211
|
-
if (bodyLines.length === 0)
|
|
221
|
+
if (bodyLines.length === 0) {
|
|
222
|
+
return new Text(renderStatusLine({ icon: "warning", title: "AST Edit", description, meta }, uiTheme), 0, 0);
|
|
223
|
+
}
|
|
224
|
+
const header = renderStatusLine({ icon: "warning", title: "AST Edit", description }, uiTheme);
|
|
225
|
+
const footerMeta = uiTheme.fg("dim", meta.join(uiTheme.sep.dot));
|
|
212
226
|
return framedToolCard(uiTheme, () => ({
|
|
213
227
|
header,
|
|
228
|
+
footerMeta,
|
|
214
229
|
sections: [{ content: bodyLines }],
|
|
215
230
|
phase: "warning",
|
|
216
231
|
borderColor: "borderMuted",
|
|
217
232
|
}));
|
|
218
233
|
}
|
|
219
234
|
|
|
220
|
-
const summaryParts = [
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
const rewriteCount = args?.ops?.length ?? 0;
|
|
226
|
-
const description = rewriteCount === 1 ? patternPreview(args?.ops?.[0]?.pat) : undefined;
|
|
235
|
+
const summaryParts = [
|
|
236
|
+
formatCount("replacement", totalReplacements),
|
|
237
|
+
formatCount("file", filesTouched),
|
|
238
|
+
`searched ${filesSearched}`,
|
|
239
|
+
];
|
|
227
240
|
|
|
228
241
|
const textContent = result.details?.displayContent ?? result.content?.find(c => c.type === "text")?.text ?? "";
|
|
229
242
|
const allLines = textContent.split("\n");
|
|
@@ -248,11 +261,14 @@ export const astEditToolRenderer = {
|
|
|
248
261
|
return !first.startsWith("Safety cap reached") && !first.startsWith("Parse issues:");
|
|
249
262
|
});
|
|
250
263
|
|
|
251
|
-
const badge = { label: "proposed", color: "warning" as const };
|
|
252
264
|
const header = renderStatusLine(
|
|
253
|
-
{ icon: limitReached ? "warning" : "success", title: "AST Edit", description
|
|
265
|
+
{ icon: limitReached ? "warning" : "success", title: "AST Edit", description },
|
|
254
266
|
uiTheme,
|
|
255
267
|
);
|
|
268
|
+
// An unapplied result is a staged proposal; the bottom rail leads with that state.
|
|
269
|
+
const footerParts = summaryParts.map(part => uiTheme.fg("dim", part));
|
|
270
|
+
if (!details?.applied) footerParts.unshift(uiTheme.fg("warning", "proposed"));
|
|
271
|
+
const footerMeta = footerParts.join(uiTheme.fg("dim", uiTheme.sep.dot));
|
|
256
272
|
|
|
257
273
|
const extraLines: string[] = [];
|
|
258
274
|
if (limitReached) {
|
|
@@ -284,6 +300,7 @@ export const astEditToolRenderer = {
|
|
|
284
300
|
const bodyLines = bodyMemo.lines;
|
|
285
301
|
return {
|
|
286
302
|
header,
|
|
303
|
+
footerMeta,
|
|
287
304
|
sections: bodyLines.length > 0 ? [{ content: bodyLines }] : [],
|
|
288
305
|
phase: options.isPartial ? "partial" : "success",
|
|
289
306
|
borderColor: "borderMuted",
|
|
@@ -310,8 +327,10 @@ export const astEditToolRenderer = {
|
|
|
310
327
|
const details = result.details;
|
|
311
328
|
const patternHead = astEditPatternHead(args);
|
|
312
329
|
if (result.isError) {
|
|
330
|
+
// A failed edit keeps the scope it ran in, as the terminal card does.
|
|
331
|
+
const scope = details?.scopePath || args?.paths?.map(displayPath).join(", ");
|
|
313
332
|
return {
|
|
314
|
-
tool: { title: "AST Edit", ...patternHead },
|
|
333
|
+
tool: { title: "AST Edit", ...patternHead, meta: scope ? [`in ${scope}`] : undefined },
|
|
315
334
|
tone: "error",
|
|
316
335
|
body: [errorText(resultText(result) || "Unknown error")],
|
|
317
336
|
};
|
package/src/tools/ast-grep.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
fitHeaderedRows,
|
|
9
9
|
formatCount,
|
|
10
10
|
formatEmptyMessage,
|
|
11
|
-
|
|
11
|
+
formatErrorDetail,
|
|
12
12
|
formatParseErrorsCountLabel,
|
|
13
13
|
PREVIEW_LIMITS,
|
|
14
14
|
toPathList,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
createGroupedRowStyler,
|
|
20
20
|
describeGroupedOutput,
|
|
21
21
|
fitGroupsToBudget,
|
|
22
|
+
formatScopedSubject,
|
|
22
23
|
groupedLinkTargets,
|
|
23
24
|
groupLineIndicesByBlank,
|
|
24
25
|
groupsByFile,
|
|
@@ -64,6 +65,17 @@ interface AstGrepRenderArgs {
|
|
|
64
65
|
lang?: string;
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
/** Header subject, `pattern in scope`: the result's display scope, or the call's requested paths. */
|
|
69
|
+
function astGrepSubject(
|
|
70
|
+
pattern: string | undefined,
|
|
71
|
+
args: AstGrepRenderArgs | undefined,
|
|
72
|
+
uiTheme: Theme,
|
|
73
|
+
scopePath?: string,
|
|
74
|
+
): string | undefined {
|
|
75
|
+
const scope = scopePath || toPathList(args?.path ?? args?.paths).join(", ") || undefined;
|
|
76
|
+
return formatScopedSubject(pattern || undefined, scope, uiTheme);
|
|
77
|
+
}
|
|
78
|
+
|
|
67
79
|
const COLLAPSED_MATCH_LIMIT = PREVIEW_LIMITS.COLLAPSED_LINES * 2;
|
|
68
80
|
|
|
69
81
|
/** Render AST grep calls and results. */
|
|
@@ -71,11 +83,8 @@ export const astGrepToolRenderer = {
|
|
|
71
83
|
inline: true,
|
|
72
84
|
renderCall(args: AstGrepRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component {
|
|
73
85
|
const meta: string[] = [];
|
|
74
|
-
const scopePaths = toPathList(args.path ?? args.paths);
|
|
75
|
-
if (scopePaths.length) meta.push(`in ${scopePaths.join(", ")}`);
|
|
76
86
|
if (args.skip !== undefined && args.skip > 0) meta.push(`skip:${args.skip}`);
|
|
77
|
-
|
|
78
|
-
const description = args.pat ?? "?";
|
|
87
|
+
const description = astGrepSubject(args.pat || "?", args, uiTheme);
|
|
79
88
|
const text = renderStatusLine({ icon: "pending", title: "AST Grep", description, meta }, uiTheme);
|
|
80
89
|
return new Text(text, 0, 0);
|
|
81
90
|
},
|
|
@@ -87,10 +96,12 @@ export const astGrepToolRenderer = {
|
|
|
87
96
|
args?: AstGrepRenderArgs,
|
|
88
97
|
): Component {
|
|
89
98
|
const details = result.details;
|
|
99
|
+
const description = astGrepSubject(args?.pat, args, uiTheme, details?.scopePath);
|
|
90
100
|
|
|
91
101
|
if (result.isError) {
|
|
92
102
|
const errorText = result.content?.find(c => c.type === "text")?.text || "Unknown error";
|
|
93
|
-
|
|
103
|
+
const header = renderStatusLine({ icon: "error", title: "AST Grep", description }, uiTheme);
|
|
104
|
+
return new Text(`${header}\n${formatErrorDetail(errorText, uiTheme)}`, 0, 0);
|
|
94
105
|
}
|
|
95
106
|
|
|
96
107
|
const matchCount = details?.matchCount ?? 0;
|
|
@@ -99,9 +110,7 @@ export const astGrepToolRenderer = {
|
|
|
99
110
|
const limitReached = details?.limitReached ?? false;
|
|
100
111
|
|
|
101
112
|
if (matchCount === 0) {
|
|
102
|
-
const description = args?.pat;
|
|
103
113
|
const meta = ["0 matches"];
|
|
104
|
-
if (details?.scopePath) meta.push(`in ${details.scopePath}`);
|
|
105
114
|
if (filesSearched > 0) meta.push(`searched ${filesSearched}`);
|
|
106
115
|
const header = renderStatusLine({ icon: "warning", title: "AST Grep", description, meta }, uiTheme);
|
|
107
116
|
const lines = [header, formatEmptyMessage("No matches found", uiTheme)];
|
|
@@ -112,12 +121,8 @@ export const astGrepToolRenderer = {
|
|
|
112
121
|
return new Text(lines.join("\n"), 0, 0);
|
|
113
122
|
}
|
|
114
123
|
|
|
115
|
-
const
|
|
116
|
-
const meta = [...summaryParts];
|
|
117
|
-
if (details?.scopePath) meta.push(`in ${details.scopePath}`);
|
|
118
|
-
meta.push(`searched ${filesSearched}`);
|
|
124
|
+
const meta = [formatCount("match", matchCount), formatCount("file", fileCount), `searched ${filesSearched}`];
|
|
119
125
|
if (limitReached) meta.push(uiTheme.fg("warning", "limit reached"));
|
|
120
|
-
const description = args?.pat;
|
|
121
126
|
const header = renderStatusLine(
|
|
122
127
|
{
|
|
123
128
|
...(limitReached
|
|
@@ -147,6 +152,9 @@ export const astGrepToolRenderer = {
|
|
|
147
152
|
const first = allLines[indices[0]!]!;
|
|
148
153
|
return !first.startsWith("Result limit reached") && !first.startsWith("Parse issues:");
|
|
149
154
|
});
|
|
155
|
+
// Collapsed previews drop the per-match `meta:` capture rows; a match keeps all its rows,
|
|
156
|
+
// since only its first carries the `*` mark.
|
|
157
|
+
const compactGroups = matchGroups.map(group => group.filter(index => !allLines[index]!.startsWith(" meta:")));
|
|
150
158
|
|
|
151
159
|
const extraLines: string[] = [];
|
|
152
160
|
if (limitReached) {
|
|
@@ -162,7 +170,7 @@ export const astGrepToolRenderer = {
|
|
|
162
170
|
() => options.expanded,
|
|
163
171
|
width => {
|
|
164
172
|
const { shown, summary } = fitGroupsToBudget(
|
|
165
|
-
matchGroups,
|
|
173
|
+
options.expanded ? matchGroups : compactGroups,
|
|
166
174
|
options.expanded ? Number.POSITIVE_INFINITY : COLLAPSED_MATCH_LIMIT,
|
|
167
175
|
{ isUnit: index => isMatchRow(allLines[index]!), unit: "match", total: matchCount },
|
|
168
176
|
);
|
|
@@ -190,8 +198,10 @@ export const astGrepToolRenderer = {
|
|
|
190
198
|
const details = result.details;
|
|
191
199
|
const pattern = span(args?.pat ?? "?", "code");
|
|
192
200
|
if (result.isError) {
|
|
201
|
+
// A failed search keeps the scope it ran in, as the terminal card does.
|
|
202
|
+
const scope = details?.scopePath || toPathList(args?.path ?? args?.paths).join(", ");
|
|
193
203
|
return {
|
|
194
|
-
head: toolHead("AST Grep", pattern),
|
|
204
|
+
head: toolHead("AST Grep", pattern, ...compact([scope && `in ${scope}`])),
|
|
195
205
|
tone: "error",
|
|
196
206
|
body: [errorText(resultText(result) || "Unknown error")],
|
|
197
207
|
};
|
|
@@ -214,8 +224,7 @@ export const astGrepToolRenderer = {
|
|
|
214
224
|
)
|
|
215
225
|
: undefined;
|
|
216
226
|
if (matchCount === 0) {
|
|
217
|
-
const meta = ["0 matches"];
|
|
218
|
-
if (details?.scopePath) meta.push(`in ${details.scopePath}`);
|
|
227
|
+
const meta = compact([details?.scopePath && `in ${details.scopePath}`, "0 matches"]);
|
|
219
228
|
if (filesSearched > 0) meta.push(`searched ${filesSearched}`);
|
|
220
229
|
return {
|
|
221
230
|
head: toolHead("AST Grep", pattern, ...meta),
|
|
@@ -228,8 +237,11 @@ export const astGrepToolRenderer = {
|
|
|
228
237
|
]),
|
|
229
238
|
};
|
|
230
239
|
}
|
|
231
|
-
const meta = [
|
|
232
|
-
|
|
240
|
+
const meta = compact([
|
|
241
|
+
details?.scopePath && `in ${details.scopePath}`,
|
|
242
|
+
formatCount("match", matchCount),
|
|
243
|
+
formatCount("file", details?.fileCount ?? 0),
|
|
244
|
+
]);
|
|
233
245
|
meta.push(`searched ${filesSearched}`);
|
|
234
246
|
const head = toolHead("AST Grep", pattern, ...meta);
|
|
235
247
|
if (limitReached) head.push(span(" limit reached", "warning"));
|
package/src/tools/bash.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { Component } from "../tui";
|
|
|
2
2
|
import { type Theme } from "../theme/theme";
|
|
3
3
|
import { type OutputMeta } from "./output-meta";
|
|
4
4
|
import type { NativeToolView, RenderResultContextOptions, RenderResultOptions } from "./renderer";
|
|
5
|
+
import { type ShellTrace } from "@linxiraos/pi-wire";
|
|
6
|
+
import type { SpotlightDetails } from "../chat/spotlight";
|
|
5
7
|
/** Default collapsed shell output preview height. */
|
|
6
8
|
export declare const BASH_DEFAULT_PREVIEW_LINES = 10;
|
|
7
9
|
/**
|
|
@@ -26,6 +28,21 @@ export interface BashToolDetails {
|
|
|
26
28
|
timedOut?: boolean;
|
|
27
29
|
/** Text the command wrote to `out://`, oldest first; transcripts draw each as a reply after the call. */
|
|
28
30
|
replies?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* The embedded shell's live trace of the command (pi-shell `RunTrace`): every frame carries the
|
|
33
|
+
* latest snapshot and the final result the last one. Absent on the PTY and user-shell paths.
|
|
34
|
+
*/
|
|
35
|
+
trace?: ShellTrace;
|
|
36
|
+
/**
|
|
37
|
+
* Working directory the command ran in when the call set one, explicitly or by the
|
|
38
|
+
* executor hoisting a leading `cd <dir>`; absent when it ran in the session cwd.
|
|
39
|
+
* Pairs with {@link trace}: the traced script is the command after hoisting.
|
|
40
|
+
*/
|
|
41
|
+
cwd?: string;
|
|
42
|
+
/** `;` when the hoisted leading cd was `cd <dir>;`, so the card redraws it as written; absent means `&&`. */
|
|
43
|
+
cdSeparator?: ";";
|
|
44
|
+
/** What the session's Spotlight shaping did to the output. */
|
|
45
|
+
spotlight?: SpotlightDetails;
|
|
29
46
|
/** Live ACP update only; completed results refer to released terminals. */
|
|
30
47
|
terminalId?: string;
|
|
31
48
|
service?: {
|
|
@@ -54,6 +71,8 @@ export interface BashRenderArgs {
|
|
|
54
71
|
env?: Record<string, unknown>;
|
|
55
72
|
timeout?: number;
|
|
56
73
|
cwd?: string;
|
|
74
|
+
/** How the `cd <dir>` prefix joins the command: `;` as written by the model, else `&&`. */
|
|
75
|
+
cdSeparator?: ";";
|
|
57
76
|
__partialJson?: string;
|
|
58
77
|
[key: string]: unknown;
|
|
59
78
|
}
|
|
@@ -88,6 +107,8 @@ export declare function getBashEnvForDisplay(args: BashRenderArgs): Record<strin
|
|
|
88
107
|
* `theme.fg("dim", ...)` form render only the first line as dim.
|
|
89
108
|
*/
|
|
90
109
|
export declare function formatBashCommandLines(args: BashRenderArgs, uiTheme: Theme): string[];
|
|
110
|
+
/** The dim `$ cd <dir> && NAME="…" ` prefix ahead of a command's first line (trailing space included). */
|
|
111
|
+
export declare function bashCommandPrefix(args: BashRenderArgs, uiTheme: Theme): string;
|
|
91
112
|
/**
|
|
92
113
|
* Plain (unstyled) command line for native views: `cd <dir> && NAME="…" <command>`,
|
|
93
114
|
* built from the same decoded display args (incl. streamed `__partialJson` env) as the ANSI path.
|