@linxiraos/pi-tui 1.4.6 → 1.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +162 -244
- package/README.md +41 -35
- package/dist/types/app-keybindings.d.ts +20 -0
- package/dist/types/apps/session-picker.d.ts +5 -0
- package/dist/types/charts/chart-plan.d.ts +9 -7
- package/dist/types/charts/table-data.d.ts +4 -2
- package/dist/types/chat/assistant-message.d.ts +15 -3
- package/dist/types/chat/bash-execution.d.ts +6 -1
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/eval-execution.d.ts +2 -0
- package/dist/types/chat/execution-shared.d.ts +14 -8
- package/dist/types/chat/extension-types.d.ts +31 -0
- package/dist/types/chat/figure-markdown.d.ts +2 -0
- package/dist/types/chat/reply-write.d.ts +48 -0
- package/dist/types/chat/svg-figure.d.ts +5 -0
- package/dist/types/chat/table-chart.d.ts +6 -3
- package/dist/types/chat/tool-execution.d.ts +1 -2
- package/dist/types/chat/transcript-outline.d.ts +7 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +13 -3
- package/dist/types/chrome/dynamic-border.d.ts +6 -0
- package/dist/types/chrome/index.d.ts +1 -0
- package/dist/types/chrome/transcript-notice.d.ts +35 -0
- package/dist/types/chrome/transcript-status.d.ts +21 -9
- package/dist/types/components/editor.d.ts +23 -6
- package/dist/types/components/image.d.ts +6 -0
- package/dist/types/components/loader.d.ts +2 -0
- package/dist/types/components/markdown.d.ts +7 -0
- package/dist/types/keybinding-matchers.d.ts +7 -0
- package/dist/types/native/blobs.d.ts +2 -1
- package/dist/types/native/describe.d.ts +4 -2
- package/dist/types/native/node.d.ts +2 -3
- package/dist/types/native/overlay.d.ts +42 -2
- package/dist/types/native/picker.d.ts +4 -4
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/annotation-overlay.d.ts +7 -1
- package/dist/types/overlays/annotation-types.d.ts +28 -0
- package/dist/types/overlays/btw-history-panel.d.ts +15 -0
- package/dist/types/overlays/btw-history.d.ts +24 -0
- package/dist/types/overlays/btw-inject.d.ts +22 -0
- package/dist/types/overlays/btw-panel.d.ts +7 -0
- package/dist/types/overlays/hook-editor.d.ts +2 -0
- package/dist/types/overlays/jobs-panel.d.ts +4 -0
- package/dist/types/overlays/login-dialog.d.ts +5 -1
- package/dist/types/overlays/model-browser.d.ts +11 -2
- package/dist/types/overlays/oauth-selector.d.ts +23 -0
- package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
- package/dist/types/overlays/rewind-selector.d.ts +1 -1
- package/dist/types/overlays/session-selector.d.ts +33 -4
- package/dist/types/prompt/composer.d.ts +56 -5
- package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
- package/dist/types/render/extension-links.d.ts +65 -0
- package/dist/types/render/hyperlink.d.ts +25 -7
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/render-utils.d.ts +23 -1
- package/dist/types/setup/scenes/glyph.d.ts +1 -1
- package/dist/types/setup/scenes/model.d.ts +1 -1
- package/dist/types/setup/scenes/outro.d.ts +5 -4
- package/dist/types/setup/scenes/sign-in.d.ts +13 -8
- package/dist/types/setup/scenes/types.d.ts +16 -1
- package/dist/types/setup/startup-splash.d.ts +1 -1
- package/dist/types/setup/wizard-overlay.d.ts +11 -7
- package/dist/types/setup/wizard.d.ts +5 -1
- package/dist/types/status-line/component.d.ts +1 -1
- package/dist/types/status-line/context-usage.d.ts +28 -6
- package/dist/types/status-line/host.d.ts +6 -2
- package/dist/types/status-line/startup.d.ts +0 -15
- package/dist/types/terminal-capabilities.d.ts +1 -1
- package/dist/types/theme/symbols.d.ts +3 -1
- package/dist/types/theme/theme-class.d.ts +1 -0
- package/dist/types/theme/theme.d.ts +1 -24
- package/dist/types/theme/tui-adapters.d.ts +2 -0
- package/dist/types/thinking.d.ts +8 -6
- package/dist/types/tools/ast-grep.d.ts +2 -0
- package/dist/types/tools/bash-interactive.d.ts +6 -0
- package/dist/types/tools/bash.d.ts +2 -0
- package/dist/types/tools/default-renderer.d.ts +6 -4
- package/dist/types/tools/eval.d.ts +2 -0
- package/dist/types/tools/find.d.ts +1 -1
- package/dist/types/tools/grouped-file-output.d.ts +100 -19
- package/dist/types/tools/hashline-format.d.ts +5 -0
- package/dist/types/tools/irc.d.ts +6 -0
- package/dist/types/tools/json-tree.d.ts +23 -4
- package/dist/types/tools/lsp.d.ts +2 -0
- package/dist/types/tools/mcp.d.ts +6 -5
- package/dist/types/tools/native-view.d.ts +3 -1
- package/dist/types/tools/output-meta.d.ts +27 -0
- package/dist/types/tools/read.d.ts +14 -4
- package/dist/types/tools/renderer.d.ts +2 -0
- package/dist/types/tools/streaming-output.d.ts +11 -0
- package/dist/types/tools/task.d.ts +13 -4
- package/dist/types/tools/url-scheme-host.d.ts +17 -0
- package/dist/types/tools/wait.d.ts +2 -0
- package/dist/types/tools/yield.d.ts +1 -1
- package/dist/types/tui.d.ts +19 -2
- package/dist/types/utils.d.ts +4 -0
- package/package.json +10 -14
- package/src/app-keybindings.d.ts +20 -0
- package/src/app-keybindings.ts +20 -0
- package/src/apps/git/git-tui.ts +10 -17
- package/src/apps/git/sidebar.ts +21 -35
- package/src/apps/ps-top.ts +4 -12
- package/src/apps/session-picker.ts +7 -0
- package/src/charts/chart-plan.d.ts +9 -7
- package/src/charts/chart-plan.ts +20 -79
- package/src/charts/table-data.d.ts +4 -2
- package/src/charts/table-data.ts +55 -6
- package/src/chat/advisor-message.ts +2 -0
- package/src/chat/assistant-message.d.ts +15 -3
- package/src/chat/assistant-message.ts +137 -19
- package/src/chat/background-tan-message.ts +4 -0
- package/src/chat/bash-execution.d.ts +6 -1
- package/src/chat/bash-execution.ts +26 -9
- package/src/chat/chat-transcript-builder.ts +63 -30
- package/src/chat/compaction-summary-message.ts +2 -1
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/eval-execution.d.ts +2 -0
- package/src/chat/eval-execution.ts +14 -7
- package/src/chat/execution-shared.d.ts +14 -8
- package/src/chat/execution-shared.ts +39 -18
- package/src/chat/extension-types.d.ts +31 -0
- package/src/chat/extension-types.ts +34 -0
- package/src/chat/figure-markdown.d.ts +2 -0
- package/src/chat/figure-markdown.ts +6 -4
- package/src/chat/read-tool-group.ts +56 -36
- package/src/chat/reply-write.d.ts +48 -0
- package/src/chat/reply-write.ts +127 -0
- package/src/chat/svg-figure.d.ts +5 -0
- package/src/chat/svg-figure.ts +55 -16
- package/src/chat/table-chart.d.ts +6 -3
- package/src/chat/table-chart.ts +29 -6
- package/src/chat/tool-execution.d.ts +1 -2
- package/src/chat/tool-execution.ts +20 -13
- package/src/chat/transcript-outline.d.ts +7 -0
- package/src/chat/transcript-outline.ts +27 -0
- package/src/chat/transcript-render-helpers.d.ts +13 -3
- package/src/chat/transcript-render-helpers.ts +134 -44
- package/src/chrome/dynamic-border.d.ts +6 -0
- package/src/chrome/dynamic-border.ts +28 -2
- package/src/chrome/index.ts +1 -0
- package/src/chrome/transcript-notice.d.ts +35 -0
- package/src/chrome/transcript-notice.ts +83 -0
- package/src/chrome/transcript-status.d.ts +21 -9
- package/src/chrome/transcript-status.ts +32 -30
- package/src/components/editor.d.ts +23 -6
- package/src/components/editor.ts +133 -25
- package/src/components/image.d.ts +6 -0
- package/src/components/image.ts +13 -0
- package/src/components/key-value-list.ts +9 -9
- package/src/components/loader.d.ts +2 -0
- package/src/components/loader.ts +7 -0
- package/src/components/markdown.d.ts +7 -0
- package/src/components/markdown.ts +116 -6
- package/src/components/section.ts +1 -9
- package/src/components/table.ts +1 -9
- package/src/hotkeys-markdown.ts +1 -0
- package/src/keybinding-matchers.d.ts +7 -0
- package/src/keybinding-matchers.ts +13 -0
- package/src/native/backend.ts +10 -67
- package/src/native/blobs.d.ts +2 -1
- package/src/native/blobs.ts +3 -2
- package/src/native/describe.d.ts +4 -2
- package/src/native/describe.ts +9 -4
- package/src/native/node.d.ts +2 -3
- package/src/native/node.ts +2 -3
- package/src/native/overlay.d.ts +42 -2
- package/src/native/overlay.ts +124 -16
- package/src/native/picker.d.ts +4 -4
- package/src/native/picker.ts +4 -4
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +25 -5
- package/src/overlays/advisor-config.ts +1 -10
- package/src/overlays/annotation-overlay.ts +125 -37
- package/src/overlays/annotation-types.ts +24 -0
- package/src/overlays/btw-history-panel.ts +106 -14
- package/src/overlays/btw-history.ts +65 -0
- package/src/overlays/btw-inject.ts +91 -0
- package/src/overlays/btw-panel.ts +53 -12
- package/src/overlays/extensions/extension-dashboard.ts +7 -8
- package/src/overlays/hook-editor.ts +6 -0
- package/src/overlays/hook-selector.ts +2 -2
- package/src/overlays/jobs-panel.ts +82 -22
- package/src/overlays/login-dialog.ts +39 -31
- package/src/overlays/mcp-add-wizard.ts +1 -1
- package/src/overlays/model-browser.ts +106 -10
- package/src/overlays/model-hub.ts +1 -7
- package/src/overlays/model-picker.ts +1 -10
- package/src/overlays/oauth-selector.ts +44 -6
- package/src/overlays/plan-review-overlay.ts +13 -2
- package/src/overlays/rewind-selector.ts +29 -12
- package/src/overlays/session-selector.ts +338 -47
- package/src/overlays/settings-defs.ts +2 -2
- package/src/overlays/tree-selector.ts +83 -27
- package/src/overlays/usage-dashboard.ts +9 -18
- package/src/prompt/composer.ts +233 -6
- package/src/prompt/custom-editor.ts +6 -1
- package/src/prompt/emoji-autocomplete.ts +0 -2
- package/src/prompt/interactive-context-helpers.ts +29 -4
- package/src/render/code-cell.ts +1 -1
- package/src/render/extension-links.d.ts +65 -0
- package/src/render/extension-links.ts +214 -0
- package/src/render/file-list.ts +4 -7
- package/src/render/hyperlink.d.ts +25 -7
- package/src/render/hyperlink.ts +65 -9
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/render-utils.d.ts +23 -1
- package/src/render/render-utils.ts +38 -6
- package/src/setup/scenes/composer.ts +2 -0
- package/src/setup/scenes/glyph.ts +4 -2
- package/src/setup/scenes/model.ts +192 -29
- package/src/setup/scenes/outro.ts +33 -15
- package/src/setup/scenes/sign-in.ts +196 -400
- package/src/setup/scenes/theme.ts +2 -0
- package/src/setup/scenes/types.ts +18 -1
- package/src/setup/startup-splash.ts +8 -7
- package/src/setup/wizard-overlay.ts +164 -35
- package/src/setup/wizard.ts +11 -2
- package/src/status-line/component.ts +4 -10
- package/src/status-line/context-usage.ts +72 -21
- package/src/status-line/host.ts +6 -2
- package/src/status-line/startup.ts +36 -70
- package/src/terminal-capabilities.d.ts +1 -1
- package/src/terminal-capabilities.ts +5 -0
- package/src/terminal.ts +24 -2
- package/src/theme/defaults.json +1 -0
- package/src/theme/loader.ts +1 -1
- package/src/theme/symbols.d.ts +3 -1
- package/src/theme/symbols.ts +16 -9
- package/src/theme/theme-class.d.ts +1 -0
- package/src/theme/theme-class.ts +15 -3
- package/src/theme/theme.d.ts +1 -24
- package/src/theme/theme.ts +3 -75
- package/src/theme/tui-adapters.d.ts +2 -0
- package/src/theme/tui-adapters.ts +8 -3
- package/src/thinking.d.ts +8 -6
- package/src/thinking.ts +17 -11
- package/src/tmux.ts +1 -0
- package/src/tools/agent-tree.ts +13 -11
- package/src/tools/ask.ts +24 -37
- package/src/tools/ast-edit.ts +48 -93
- package/src/tools/ast-grep.d.ts +2 -0
- package/src/tools/ast-grep.ts +31 -67
- package/src/tools/bash-interactive.d.ts +49 -0
- package/src/tools/bash-interactive.ts +6 -1
- package/src/tools/bash.d.ts +2 -0
- package/src/tools/bash.ts +9 -0
- package/src/tools/default-renderer.d.ts +6 -4
- package/src/tools/default-renderer.ts +10 -7
- package/src/tools/edit.ts +50 -43
- package/src/tools/eval.d.ts +2 -0
- package/src/tools/eval.ts +16 -4
- package/src/tools/fetch.ts +2 -1
- package/src/tools/find.d.ts +1 -1
- package/src/tools/find.ts +13 -5
- package/src/tools/github.ts +14 -46
- package/src/tools/glob.ts +2 -1
- package/src/tools/grep.ts +47 -277
- package/src/tools/grouped-file-output.d.ts +100 -19
- package/src/tools/grouped-file-output.ts +414 -103
- package/src/tools/hashline-format.d.ts +5 -0
- package/src/tools/hashline-format.ts +5 -0
- package/src/tools/irc.d.ts +6 -0
- package/src/tools/irc.ts +6 -0
- package/src/tools/job-widget.ts +13 -1
- package/src/tools/json-tree.d.ts +23 -4
- package/src/tools/json-tree.ts +132 -46
- package/src/tools/lsp.d.ts +2 -0
- package/src/tools/lsp.ts +246 -47
- package/src/tools/mcp.d.ts +6 -5
- package/src/tools/mcp.ts +20 -12
- package/src/tools/native-view.d.ts +3 -1
- package/src/tools/native-view.ts +12 -6
- package/src/tools/output-meta.d.ts +27 -0
- package/src/tools/output-meta.ts +68 -4
- package/src/tools/proc-render.ts +3 -3
- package/src/tools/read.d.ts +14 -4
- package/src/tools/read.ts +20 -5
- package/src/tools/renderer.d.ts +2 -0
- package/src/tools/renderer.ts +2 -0
- package/src/tools/streaming-output.d.ts +11 -0
- package/src/tools/streaming-output.ts +41 -0
- package/src/tools/task.d.ts +13 -4
- package/src/tools/task.ts +100 -97
- package/src/tools/url-scheme-host.d.ts +17 -0
- package/src/tools/url-scheme-host.ts +21 -0
- package/src/tools/vibe.ts +4 -4
- package/src/tools/wait.d.ts +2 -0
- package/src/tools/wait.ts +8 -5
- package/src/tools/write.ts +17 -27
- package/src/tools/yield.d.ts +1 -1
- package/src/tools/yield.ts +19 -10
- package/src/tui.d.ts +19 -2
- package/src/tui.ts +134 -24
- package/src/utils.d.ts +4 -0
- package/src/utils.ts +10 -0
- package/dist/types/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/alabaster.json +0 -103
- package/src/theme/defaults/amethyst.json +0 -106
- package/src/theme/defaults/anthracite.json +0 -103
- package/src/theme/defaults/basalt.json +0 -101
- package/src/theme/defaults/birch.json +0 -105
- package/src/theme/defaults/dark-abyss.json +0 -101
- package/src/theme/defaults/dark-arctic.json +0 -114
- package/src/theme/defaults/dark-aurora.json +0 -105
- package/src/theme/defaults/dark-catppuccin.json +0 -117
- package/src/theme/defaults/dark-cavern.json +0 -101
- package/src/theme/defaults/dark-celestial.json +0 -116
- package/src/theme/defaults/dark-copper.json +0 -105
- package/src/theme/defaults/dark-cosmos.json +0 -100
- package/src/theme/defaults/dark-cyberpunk.json +0 -112
- package/src/theme/defaults/dark-dracula.json +0 -108
- package/src/theme/defaults/dark-eclipse.json +0 -101
- package/src/theme/defaults/dark-ember.json +0 -105
- package/src/theme/defaults/dark-equinox.json +0 -100
- package/src/theme/defaults/dark-forest.json +0 -106
- package/src/theme/defaults/dark-github.json +0 -115
- package/src/theme/defaults/dark-gruvbox.json +0 -122
- package/src/theme/defaults/dark-lavender.json +0 -105
- package/src/theme/defaults/dark-lunar.json +0 -99
- package/src/theme/defaults/dark-midnight.json +0 -105
- package/src/theme/defaults/dark-monochrome.json +0 -104
- package/src/theme/defaults/dark-monokai.json +0 -108
- package/src/theme/defaults/dark-nebula.json +0 -100
- package/src/theme/defaults/dark-neon-noir.json +0 -110
- package/src/theme/defaults/dark-nord.json +0 -108
- package/src/theme/defaults/dark-ocean.json +0 -111
- package/src/theme/defaults/dark-one.json +0 -110
- package/src/theme/defaults/dark-poimandres.json +0 -125
- package/src/theme/defaults/dark-rainforest.json +0 -101
- package/src/theme/defaults/dark-reef.json +0 -101
- package/src/theme/defaults/dark-retro.json +0 -102
- package/src/theme/defaults/dark-rose-pine.json +0 -106
- package/src/theme/defaults/dark-sakura.json +0 -105
- package/src/theme/defaults/dark-slate.json +0 -105
- package/src/theme/defaults/dark-solarized.json +0 -107
- package/src/theme/defaults/dark-solstice.json +0 -100
- package/src/theme/defaults/dark-starfall.json +0 -101
- package/src/theme/defaults/dark-sunset.json +0 -109
- package/src/theme/defaults/dark-swamp.json +0 -100
- package/src/theme/defaults/dark-synthwave.json +0 -113
- package/src/theme/defaults/dark-taiga.json +0 -101
- package/src/theme/defaults/dark-terminal.json +0 -105
- package/src/theme/defaults/dark-tokyo-night.json +0 -111
- package/src/theme/defaults/dark-tundra.json +0 -101
- package/src/theme/defaults/dark-twilight.json +0 -101
- package/src/theme/defaults/dark-volcanic.json +0 -101
- package/src/theme/defaults/graphite.json +0 -102
- package/src/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/index.ts +0 -203
- package/src/theme/defaults/light-arctic.json +0 -117
- package/src/theme/defaults/light-aurora-day.json +0 -101
- package/src/theme/defaults/light-canyon.json +0 -101
- package/src/theme/defaults/light-catppuccin.json +0 -116
- package/src/theme/defaults/light-cirrus.json +0 -100
- package/src/theme/defaults/light-coral.json +0 -105
- package/src/theme/defaults/light-cyberpunk.json +0 -106
- package/src/theme/defaults/light-dawn.json +0 -100
- package/src/theme/defaults/light-dunes.json +0 -101
- package/src/theme/defaults/light-eucalyptus.json +0 -105
- package/src/theme/defaults/light-forest.json +0 -110
- package/src/theme/defaults/light-frost.json +0 -105
- package/src/theme/defaults/light-github.json +0 -125
- package/src/theme/defaults/light-glacier.json +0 -101
- package/src/theme/defaults/light-gruvbox.json +0 -118
- package/src/theme/defaults/light-haze.json +0 -100
- package/src/theme/defaults/light-honeycomb.json +0 -105
- package/src/theme/defaults/light-lagoon.json +0 -101
- package/src/theme/defaults/light-lavender.json +0 -105
- package/src/theme/defaults/light-meadow.json +0 -101
- package/src/theme/defaults/light-mint.json +0 -105
- package/src/theme/defaults/light-monochrome.json +0 -111
- package/src/theme/defaults/light-ocean.json +0 -109
- package/src/theme/defaults/light-one.json +0 -109
- package/src/theme/defaults/light-opal.json +0 -101
- package/src/theme/defaults/light-orchard.json +0 -101
- package/src/theme/defaults/light-paper.json +0 -105
- package/src/theme/defaults/light-poimandres.json +0 -125
- package/src/theme/defaults/light-prism.json +0 -100
- package/src/theme/defaults/light-retro.json +0 -108
- package/src/theme/defaults/light-sand.json +0 -105
- package/src/theme/defaults/light-savanna.json +0 -101
- package/src/theme/defaults/light-solarized.json +0 -112
- package/src/theme/defaults/light-soleil.json +0 -100
- package/src/theme/defaults/light-sunset.json +0 -109
- package/src/theme/defaults/light-synthwave.json +0 -108
- package/src/theme/defaults/light-tokyo-night.json +0 -121
- package/src/theme/defaults/light-wetland.json +0 -101
- package/src/theme/defaults/light-zenith.json +0 -99
- package/src/theme/defaults/limestone.json +0 -104
- package/src/theme/defaults/mahogany.json +0 -107
- package/src/theme/defaults/marble.json +0 -103
- package/src/theme/defaults/obsidian.json +0 -101
- package/src/theme/defaults/onyx.json +0 -101
- package/src/theme/defaults/pearl.json +0 -103
- package/src/theme/defaults/porcelain.json +0 -101
- package/src/theme/defaults/quartz.json +0 -106
- package/src/theme/defaults/sandstone.json +0 -105
- package/src/theme/defaults/titanium.json +0 -100
package/src/tools/ask.ts
CHANGED
|
@@ -25,8 +25,13 @@ import { outputBlockContentWidth, renderStatusLine } from "../render";
|
|
|
25
25
|
import { framedToolCard } from "../render/tool-card";
|
|
26
26
|
import { wrapPrefixedLine } from "../render/hanging-wrap";
|
|
27
27
|
|
|
28
|
-
import {
|
|
29
|
-
|
|
28
|
+
import {
|
|
29
|
+
formatErrorMessage,
|
|
30
|
+
formatMeta,
|
|
31
|
+
formatStatusIcon,
|
|
32
|
+
formatTitle,
|
|
33
|
+
sanitizeCarriageReturns,
|
|
34
|
+
} from "../render/render-utils";
|
|
30
35
|
|
|
31
36
|
/** Result for a single question */
|
|
32
37
|
export interface QuestionResult {
|
|
@@ -177,10 +182,11 @@ function normalizeRenderQuestions(raw: unknown): NonNullable<AskRenderArgs["ques
|
|
|
177
182
|
/** Render a custom free-text answer as a status line plus indented continuation rows. */
|
|
178
183
|
function renderCustomInputLines(uiTheme: Theme, customInput: string): string[] {
|
|
179
184
|
const lines = customInput.split("\n");
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
const icon = formatStatusIcon("success", uiTheme);
|
|
186
|
+
// Continuation rows line up under the answer text, past the glyph's own width.
|
|
187
|
+
const indent = " ".repeat(visibleWidth(icon) + 2);
|
|
188
|
+
const out: string[] = [` ${icon} ${uiTheme.fg("toolOutput", lines[0] ?? "")}`];
|
|
189
|
+
for (let i = 1; i < lines.length; i++) out.push(`${indent}${uiTheme.fg("toolOutput", lines[i])}`);
|
|
184
190
|
return out;
|
|
185
191
|
}
|
|
186
192
|
|
|
@@ -283,9 +289,7 @@ function renderAnswerOptionLines(
|
|
|
283
289
|
|
|
284
290
|
// Nothing was chosen (and no custom answer) → a lone cancelled marker.
|
|
285
291
|
if (selected.size === 0 && customInput === undefined && note === undefined) {
|
|
286
|
-
return [
|
|
287
|
-
` ${uiTheme.styledSymbol("status.warning", "warning")} ${uiTheme.fg("warning", tuiText("askCancelledLabel", "Cancelled"))}`,
|
|
288
|
-
];
|
|
292
|
+
return [` ${formatStatusIcon("warning", uiTheme)} ${uiTheme.fg("warning", "Cancelled")}`];
|
|
289
293
|
}
|
|
290
294
|
|
|
291
295
|
const out: string[] = [];
|
|
@@ -457,7 +461,7 @@ export const askToolRenderer = {
|
|
|
457
461
|
},
|
|
458
462
|
mergeCallAndResult: true,
|
|
459
463
|
renderCall(args: AskRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component {
|
|
460
|
-
const label = formatTitle(
|
|
464
|
+
const label = formatTitle("Ask", uiTheme);
|
|
461
465
|
const mdTheme = getMarkdownTheme();
|
|
462
466
|
const accentStyle = { color: (t: string) => uiTheme.fg("accent", t) };
|
|
463
467
|
const md = (text: string, width: number) =>
|
|
@@ -468,16 +472,11 @@ export const askToolRenderer = {
|
|
|
468
472
|
// throw here takes down the whole TUI render loop — normalize first.
|
|
469
473
|
const questions = normalizeRenderQuestions(args.questions);
|
|
470
474
|
if (questions && questions.length > 0) {
|
|
471
|
-
const header = `${label} ${uiTheme.fg(
|
|
472
|
-
"muted",
|
|
473
|
-
questions.length === 1
|
|
474
|
-
? tuiText("askQuestionOne", "1 question")
|
|
475
|
-
: tuiTextFmt("askQuestionManyFmt", "%d questions", questions.length),
|
|
476
|
-
)}`;
|
|
475
|
+
const header = `${label} ${uiTheme.fg("muted", `${questions.length} questions`)}`;
|
|
477
476
|
return framedToolCard(uiTheme, ({ width, contentWidth }) => {
|
|
478
477
|
const sections = questions.map(q => {
|
|
479
478
|
const meta: string[] = [];
|
|
480
|
-
if (q.multi) meta.push(
|
|
479
|
+
if (q.multi) meta.push("multi");
|
|
481
480
|
if (q.options?.length) meta.push(`options:${q.options.length}`);
|
|
482
481
|
const metaStr = meta.length > 0 ? uiTheme.fg("dim", ` · ${meta.join(" · ")}`) : "";
|
|
483
482
|
// md() returns a shared cached array (module-level Markdown LRU) — copy before appending.
|
|
@@ -493,7 +492,7 @@ export const askToolRenderer = {
|
|
|
493
492
|
|
|
494
493
|
// Single question
|
|
495
494
|
if (typeof args.question !== "string" || !args.question) {
|
|
496
|
-
const errorLine = formatErrorMessage(
|
|
495
|
+
const errorLine = formatErrorMessage("No question provided", uiTheme);
|
|
497
496
|
return framedToolCard(uiTheme, () => ({
|
|
498
497
|
header: errorLine,
|
|
499
498
|
sections: [],
|
|
@@ -538,7 +537,7 @@ export const askToolRenderer = {
|
|
|
538
537
|
if (!rawDetails) {
|
|
539
538
|
const txt = result.content[0];
|
|
540
539
|
const fallback = txt?.type === "text" && txt.text ? sanitizeCarriageReturns(txt.text) : "";
|
|
541
|
-
const header = renderStatusLine({ icon: "warning", title:
|
|
540
|
+
const header = renderStatusLine({ icon: "warning", title: "Ask" }, uiTheme);
|
|
542
541
|
const body = fallback ? `\n${uiTheme.fg("dim", fallback)}` : "";
|
|
543
542
|
return new Text(`${header}${body}`, 0, 0);
|
|
544
543
|
}
|
|
@@ -546,14 +545,7 @@ export const askToolRenderer = {
|
|
|
546
545
|
|
|
547
546
|
// Chat redirect: user chose "Chat about this" instead of answering.
|
|
548
547
|
if (details.chatRedirect) {
|
|
549
|
-
const header = renderStatusLine(
|
|
550
|
-
{
|
|
551
|
-
icon: "info",
|
|
552
|
-
title: tuiText("askTitle", "Ask"),
|
|
553
|
-
meta: [tuiText("askChatRedirectMeta", "chat redirect")],
|
|
554
|
-
},
|
|
555
|
-
uiTheme,
|
|
556
|
-
);
|
|
548
|
+
const header = renderStatusLine({ icon: "info", title: "Ask", meta: ["chat redirect"] }, uiTheme);
|
|
557
549
|
const questions = details.questions ?? [];
|
|
558
550
|
return framedToolCard(uiTheme, ({ width }) => ({
|
|
559
551
|
header,
|
|
@@ -575,11 +567,8 @@ export const askToolRenderer = {
|
|
|
575
567
|
const header = renderStatusLine(
|
|
576
568
|
{
|
|
577
569
|
icon: hasAnySelection ? "success" : "warning",
|
|
578
|
-
title:
|
|
579
|
-
meta:
|
|
580
|
-
results.length === 1
|
|
581
|
-
? [tuiText("askQuestionOne", "1 question")]
|
|
582
|
-
: [tuiTextFmt("askQuestionManyFmt", "%d questions", results.length)],
|
|
570
|
+
title: "Ask",
|
|
571
|
+
meta: [`${results.length} questions`],
|
|
583
572
|
},
|
|
584
573
|
uiTheme,
|
|
585
574
|
);
|
|
@@ -629,8 +618,8 @@ export const askToolRenderer = {
|
|
|
629
618
|
(details.selectedOptions && details.selectedOptions.length > 0);
|
|
630
619
|
const header = renderStatusLine(
|
|
631
620
|
hasSelection
|
|
632
|
-
? { iconOverride: uiTheme.styledSymbol("tool.ask", "accent"), title:
|
|
633
|
-
: { icon: "warning", title:
|
|
621
|
+
? { iconOverride: uiTheme.styledSymbol("tool.ask", "accent"), title: "Ask" }
|
|
622
|
+
: { icon: "warning", title: "Ask" },
|
|
634
623
|
uiTheme,
|
|
635
624
|
);
|
|
636
625
|
const dOptions = details.options;
|
|
@@ -658,9 +647,7 @@ export const askToolRenderer = {
|
|
|
658
647
|
];
|
|
659
648
|
if (dTimedOut) {
|
|
660
649
|
// Distinguish auto-selection from a real user choice in the transcript.
|
|
661
|
-
bodyLines.push(
|
|
662
|
-
uiTheme.fg("dim", tuiText("askAutoSelected", "auto-selected after timeout — not a user choice")),
|
|
663
|
-
);
|
|
650
|
+
bodyLines.push(uiTheme.fg("dim", "auto-selected after timeout — not a user choice"));
|
|
664
651
|
}
|
|
665
652
|
return {
|
|
666
653
|
header,
|
package/src/tools/ast-edit.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { isRecord, sanitizeText } from "@linxiraos/pi-utils";
|
|
2
1
|
import type { Component } from "../tui";
|
|
3
2
|
import { Text } from "../components/text";
|
|
4
|
-
import { replaceTabs } from "../utils";
|
|
5
3
|
import type { Theme } from "../theme/theme";
|
|
6
|
-
import { Ellipsis,
|
|
4
|
+
import { Ellipsis, renderStatusLine, truncateToWidth } from "../render";
|
|
7
5
|
import { framedToolCard } from "../render/tool-card";
|
|
8
6
|
import {
|
|
9
7
|
appendParseErrorsBulletList,
|
|
10
8
|
formatCount,
|
|
11
9
|
formatErrorDetail,
|
|
12
|
-
formatMoreItems,
|
|
13
10
|
formatParseErrorsCountLabel,
|
|
14
11
|
PREVIEW_LIMITS,
|
|
15
12
|
} from "../render/render-utils";
|
|
16
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
classifyGroupedLines,
|
|
15
|
+
createGroupedRowStyler,
|
|
16
|
+
fitGroupsToBudget,
|
|
17
|
+
groupedLinkTargets,
|
|
18
|
+
groupLineIndicesByBlank,
|
|
19
|
+
groupsByFile,
|
|
20
|
+
walkGroupedOutput,
|
|
21
|
+
} from "./grouped-file-output";
|
|
17
22
|
import type { OutputMeta } from "./output-meta";
|
|
18
23
|
import type {
|
|
19
24
|
NativeToolHead,
|
|
@@ -59,34 +64,24 @@ interface AstEditRenderArgs {
|
|
|
59
64
|
const COLLAPSED_CHANGE_LIMIT = PREVIEW_LIMITS.COLLAPSED_LINES * 2;
|
|
60
65
|
|
|
61
66
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* noise. Collapsed mode always shows at least the first group, then fills up
|
|
66
|
-
* to `budget` lines before summarizing the rest as `… N more changes`.
|
|
67
|
+
* Frame body lines for per-file change groups, styled on demand: files apart by
|
|
68
|
+
* a blank line and without tree guides (the frame border is the container), fit
|
|
69
|
+
* to `budget` with the rest summarized as `… N more files`.
|
|
67
70
|
*/
|
|
68
71
|
function buildChangeBody(
|
|
69
72
|
groups: readonly (readonly number[])[],
|
|
70
73
|
styleLine: (index: number) => string,
|
|
71
|
-
|
|
74
|
+
isFileRow: (index: number) => boolean,
|
|
72
75
|
budget: number,
|
|
73
76
|
theme: Theme,
|
|
74
77
|
): string[] {
|
|
78
|
+
const { shown, summary } = fitGroupsToBudget(groups, budget, { isUnit: isFileRow, unit: "file", gap: 1 });
|
|
75
79
|
const lines: string[] = [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const group = groups[i]!;
|
|
79
|
-
const separator = shown > 0 ? 1 : 0;
|
|
80
|
-
const remainingAfter = groups.length - (i + 1);
|
|
81
|
-
const reserved = !expanded && remainingAfter > 0 ? 1 : 0;
|
|
82
|
-
// Always emit the first group; budget only gates subsequent ones.
|
|
83
|
-
if (!expanded && shown > 0 && lines.length + separator + group.length + reserved > budget) break;
|
|
84
|
-
if (separator) lines.push("");
|
|
80
|
+
for (const group of shown) {
|
|
81
|
+
if (lines.length > 0) lines.push("");
|
|
85
82
|
for (const index of group) lines.push(styleLine(index));
|
|
86
|
-
shown++;
|
|
87
83
|
}
|
|
88
|
-
|
|
89
|
-
if (!expanded && remaining > 0) lines.push(theme.fg("muted", formatMoreItems(remaining, "change")));
|
|
84
|
+
if (summary) lines.push(theme.fg("muted", summary));
|
|
90
85
|
return lines;
|
|
91
86
|
}
|
|
92
87
|
|
|
@@ -98,9 +93,7 @@ function patternPreview(pat: string | undefined): string | undefined {
|
|
|
98
93
|
return collapsed || undefined;
|
|
99
94
|
}
|
|
100
95
|
|
|
101
|
-
const AST_EDIT_HEADER_RE = /^(#+)\s+(.*)$/;
|
|
102
96
|
const AST_EDIT_CHANGE_LINE_RE = /^([+\- ])\s*(\d+)(?:│|[:|])(.*)$/;
|
|
103
|
-
const AST_EDIT_HEADER_SUFFIX_RE = /\s+\([^)]*\)\s*$/;
|
|
104
97
|
|
|
105
98
|
/** One file's proposed rewrite: its unified diff text and change counts. */
|
|
106
99
|
interface AstEditFileDiff {
|
|
@@ -117,29 +110,15 @@ interface AstEditFileDiff {
|
|
|
117
110
|
*/
|
|
118
111
|
function parseAstEditChanges(lines: readonly string[]): AstEditFileDiff[] {
|
|
119
112
|
const files: AstEditFileDiff[] = [];
|
|
120
|
-
const dirs: string[] = [];
|
|
121
113
|
let file: AstEditFileDiff | undefined;
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
for (const line of lines) {
|
|
127
|
-
const header = AST_EDIT_HEADER_RE.exec(line);
|
|
128
|
-
if (header) {
|
|
129
|
-
flush();
|
|
130
|
-
const depth = header[1]!.length;
|
|
131
|
-
const rest = header[2]!.trimEnd().replace(AST_EDIT_HEADER_SUFFIX_RE, "");
|
|
132
|
-
dirs.length = depth - 1;
|
|
133
|
-
if (rest.endsWith("/")) {
|
|
134
|
-
dirs[depth - 1] = rest.slice(0, -1);
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
const prefix = dirs.filter(Boolean).join("/");
|
|
138
|
-
file = { path: prefix ? `${prefix}/${rest}` : rest, lines: [], added: 0, removed: 0 };
|
|
114
|
+
for (const event of walkGroupedOutput(lines)) {
|
|
115
|
+
if (event.kind !== "line") {
|
|
116
|
+
if (file && file.lines.length > 0) files.push(file);
|
|
117
|
+
file = event.kind === "file" ? { path: event.path, lines: [], added: 0, removed: 0 } : undefined;
|
|
139
118
|
continue;
|
|
140
119
|
}
|
|
141
|
-
if (!file
|
|
142
|
-
const change = AST_EDIT_CHANGE_LINE_RE.exec(
|
|
120
|
+
if (!file) continue;
|
|
121
|
+
const change = AST_EDIT_CHANGE_LINE_RE.exec(event.text);
|
|
143
122
|
if (!change) continue;
|
|
144
123
|
const lineNumber = Number.parseInt(change[2]!, 10);
|
|
145
124
|
if (file.lastOld === undefined || lineNumber > file.lastOld + 1 || lineNumber < file.lastOld) {
|
|
@@ -150,7 +129,7 @@ function parseAstEditChanges(lines: readonly string[]): AstEditFileDiff[] {
|
|
|
150
129
|
else if (change[1] === "-") file.removed++;
|
|
151
130
|
file.lines.push(`${change[1]}${change[3]}`);
|
|
152
131
|
}
|
|
153
|
-
|
|
132
|
+
if (file && file.lines.length > 0) files.push(file);
|
|
154
133
|
return files;
|
|
155
134
|
}
|
|
156
135
|
|
|
@@ -248,53 +227,23 @@ export const astEditToolRenderer = {
|
|
|
248
227
|
|
|
249
228
|
const textContent = result.details?.displayContent ?? result.content?.find(c => c.type === "text")?.text ?? "";
|
|
250
229
|
const allLines = textContent.split("\n");
|
|
251
|
-
//
|
|
252
|
-
// reconstruct across the blank-line groups the tree list collapses by.
|
|
230
|
+
// Classify the whole output so nested directory headers resolve across blank-line groups.
|
|
253
231
|
const contexts = classifyGroupedLines(allLines, details?.cwd ?? details?.searchPath, details?.searchPath);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
const styleLine = (index: number): string => {
|
|
270
|
-
const cached = styledLines[index];
|
|
271
|
-
if (cached !== undefined) return cached;
|
|
272
|
-
const ctx = contexts[index]!;
|
|
273
|
-
// Swap the inner code-frame gutter `│` for a space so it does not nest a
|
|
274
|
-
// second vertical bar inside the frame border.
|
|
275
|
-
const display = replaceTabs(allLines[index]!.replace("│", " "));
|
|
276
|
-
let styled: string;
|
|
277
|
-
const linkPath =
|
|
278
|
-
ctx.headerPath && rawContexts?.[index]?.kind === ctx.kind && rawContexts[index]?.depth === ctx.depth
|
|
279
|
-
? (rawContexts[index]?.headerPath ?? ctx.headerPath)
|
|
280
|
-
: ctx.headerPath;
|
|
281
|
-
if (ctx.kind === "dir") {
|
|
282
|
-
const accent = uiTheme.fg("accent", display);
|
|
283
|
-
styled = linkPath ? fileHyperlink(linkPath, accent) : accent;
|
|
284
|
-
} else if (ctx.kind === "file") {
|
|
285
|
-
const tinted = uiTheme.fg(ctx.depth === 1 ? "accent" : "dim", display);
|
|
286
|
-
styled = linkPath ? fileHyperlink(linkPath, tinted) : tinted;
|
|
287
|
-
} else if (display.startsWith("+")) {
|
|
288
|
-
styled = uiTheme.fg("toolDiffAdded", display);
|
|
289
|
-
} else if (display.startsWith("-")) {
|
|
290
|
-
styled = uiTheme.fg("toolDiffRemoved", display);
|
|
291
|
-
} else {
|
|
292
|
-
styled = uiTheme.fg("toolOutput", display);
|
|
293
|
-
}
|
|
294
|
-
styledLines[index] = styled;
|
|
295
|
-
return styled;
|
|
296
|
-
};
|
|
297
|
-
const changeGroups = groupLineIndicesByBlank(allLines).filter(indices => {
|
|
232
|
+
const styleLine = createGroupedRowStyler(allLines, contexts, uiTheme, {
|
|
233
|
+
linkTarget: groupedLinkTargets(contexts, textContent, details, options.renderContext?.rawDetails),
|
|
234
|
+
styleBody: index => {
|
|
235
|
+
// Swap the code-frame gutter `│` for a space so it does not nest a
|
|
236
|
+
// second vertical bar inside the frame border.
|
|
237
|
+
const line = allLines[index]!.replace("│", " ");
|
|
238
|
+
const color = line.startsWith("+")
|
|
239
|
+
? "toolDiffAdded"
|
|
240
|
+
: line.startsWith("-")
|
|
241
|
+
? "toolDiffRemoved"
|
|
242
|
+
: "toolOutput";
|
|
243
|
+
return uiTheme.fg(color, line);
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
const changeGroups = groupsByFile(groupLineIndicesByBlank(allLines), contexts).filter(indices => {
|
|
298
247
|
const first = allLines[indices[0]!]!;
|
|
299
248
|
return !first.startsWith("Safety cap reached") && !first.startsWith("Parse issues:");
|
|
300
249
|
});
|
|
@@ -321,7 +270,13 @@ export const astEditToolRenderer = {
|
|
|
321
270
|
({ contentWidth }) => {
|
|
322
271
|
const expanded = Boolean(options.expanded);
|
|
323
272
|
if (bodyMemo === undefined || bodyMemo.expanded !== expanded || bodyMemo.width !== contentWidth) {
|
|
324
|
-
const changeLines = buildChangeBody(
|
|
273
|
+
const changeLines = buildChangeBody(
|
|
274
|
+
changeGroups,
|
|
275
|
+
styleLine,
|
|
276
|
+
index => contexts[index]!.kind === "file",
|
|
277
|
+
expanded ? Number.POSITIVE_INFINITY : COLLAPSED_CHANGE_LIMIT,
|
|
278
|
+
uiTheme,
|
|
279
|
+
);
|
|
325
280
|
const lines = [...changeLines, ...extraLines].map(l => truncateToWidth(l, contentWidth, Ellipsis.Omit));
|
|
326
281
|
while (lines.length > 0 && lines[0].trim() === "") lines.shift();
|
|
327
282
|
bodyMemo = { expanded, width: contentWidth, lines };
|
package/src/tools/ast-grep.d.ts
CHANGED
|
@@ -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: {
|
package/src/tools/ast-grep.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { isRecord, sanitizeText } from "@linxiraos/pi-utils";
|
|
2
1
|
import type { Component } from "../tui";
|
|
3
2
|
import { Text } from "../components/text";
|
|
4
3
|
import type { Theme } from "../theme/theme";
|
|
5
|
-
import {
|
|
4
|
+
import { renderStatusLine, renderTreeList } from "../render";
|
|
6
5
|
import {
|
|
7
6
|
appendParseErrorsBulletList,
|
|
8
7
|
createCachedComponent,
|
|
@@ -14,7 +13,17 @@ import {
|
|
|
14
13
|
PREVIEW_LIMITS,
|
|
15
14
|
toPathList,
|
|
16
15
|
} from "../render/render-utils";
|
|
17
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
classifyGroupedLines,
|
|
18
|
+
createCodeFrameStyler,
|
|
19
|
+
createGroupedRowStyler,
|
|
20
|
+
describeGroupedOutput,
|
|
21
|
+
fitGroupsToBudget,
|
|
22
|
+
groupedLinkTargets,
|
|
23
|
+
groupLineIndicesByBlank,
|
|
24
|
+
groupsByFile,
|
|
25
|
+
isMatchRow,
|
|
26
|
+
} from "./grouped-file-output";
|
|
18
27
|
import { code, compact, node, span } from "../native/describe";
|
|
19
28
|
import type { NativeChild } from "../native/node";
|
|
20
29
|
import { errorText, noteText, resultText, toolHead } from "./native-view";
|
|
@@ -51,6 +60,8 @@ interface AstGrepRenderArgs {
|
|
|
51
60
|
/** Legacy pre-`path` argument name; kept so historical transcripts still render a scope. */
|
|
52
61
|
paths?: string[];
|
|
53
62
|
skip?: number;
|
|
63
|
+
/** Language the search parsed the files as; highlighting follows it over the file extension. */
|
|
64
|
+
lang?: string;
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
const COLLAPSED_MATCH_LIMIT = PREVIEW_LIMITS.COLLAPSED_LINES * 2;
|
|
@@ -121,63 +132,21 @@ export const astGrepToolRenderer = {
|
|
|
121
132
|
|
|
122
133
|
const textContent = result.details?.displayContent ?? result.content?.find(c => c.type === "text")?.text ?? "";
|
|
123
134
|
const allLines = textContent.split("\n");
|
|
124
|
-
//
|
|
125
|
-
// reconstruct across the blank-line groups the tree list collapses by.
|
|
135
|
+
// Classify the whole output so nested directory headers resolve across blank-line groups.
|
|
126
136
|
const contexts = classifyGroupedLines(allLines, details?.cwd ?? details?.searchPath, details?.searchPath);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const rawContexts =
|
|
138
|
-
rawContent !== undefined && rawLines?.length === allLines.length && sanitizeText(rawContent) === textContent
|
|
139
|
-
? classifyGroupedLines(rawLines, rawCwd ?? rawSearchPath, rawSearchPath)
|
|
140
|
-
: undefined;
|
|
141
|
-
// Style lazily: the collapsed tree list only renders the first few groups,
|
|
142
|
-
// so a large result never styles/hyperlinks rows nobody sees.
|
|
143
|
-
const styledLines: (string | undefined)[] = Array.from({ length: allLines.length }, () => undefined);
|
|
144
|
-
const styleLine = (index: number): string => {
|
|
145
|
-
const cached = styledLines[index];
|
|
146
|
-
if (cached !== undefined) return cached;
|
|
147
|
-
const line = allLines[index]!;
|
|
148
|
-
const ctx = contexts[index]!;
|
|
149
|
-
const rawContext = rawContexts?.[index];
|
|
150
|
-
const target =
|
|
151
|
-
ctx.headerPath && rawContext?.kind === ctx.kind && rawContext.depth === ctx.depth
|
|
152
|
-
? (rawContext.headerPath ?? ctx.headerPath)
|
|
153
|
-
: ctx.headerPath;
|
|
154
|
-
let styled: string;
|
|
155
|
-
if (ctx.kind === "dir") {
|
|
156
|
-
const accent = uiTheme.fg("accent", line);
|
|
157
|
-
styled = target ? fileHyperlink(target, accent) : accent;
|
|
158
|
-
} else if (ctx.kind === "file") {
|
|
159
|
-
const tinted = uiTheme.fg(ctx.depth === 1 ? "accent" : "dim", line);
|
|
160
|
-
styled = target ? fileHyperlink(target, tinted) : tinted;
|
|
161
|
-
} else {
|
|
162
|
-
styled = uiTheme.fg(line.startsWith(" meta:") ? "dim" : "toolOutput", line);
|
|
163
|
-
}
|
|
164
|
-
styledLines[index] = styled;
|
|
165
|
-
return styled;
|
|
166
|
-
};
|
|
167
|
-
const matchGroups = groupLineIndicesByBlank(allLines).filter(indices => {
|
|
137
|
+
const styleCodeFrame = createCodeFrameStyler(allLines, contexts, "toolOutput", uiTheme, args?.lang);
|
|
138
|
+
const styleLine = createGroupedRowStyler(allLines, contexts, uiTheme, {
|
|
139
|
+
linkTarget: groupedLinkTargets(contexts, textContent, details, options.renderContext?.rawDetails),
|
|
140
|
+
styleBody: index => {
|
|
141
|
+
const line = allLines[index]!;
|
|
142
|
+
return styleCodeFrame(index) ?? uiTheme.fg(line.startsWith(" meta:") ? "dim" : "toolOutput", line);
|
|
143
|
+
},
|
|
144
|
+
linkLines: true,
|
|
145
|
+
});
|
|
146
|
+
const matchGroups = groupsByFile(groupLineIndicesByBlank(allLines), contexts).filter(indices => {
|
|
168
147
|
const first = allLines[indices[0]!]!;
|
|
169
148
|
return !first.startsWith("Result limit reached") && !first.startsWith("Parse issues:");
|
|
170
149
|
});
|
|
171
|
-
// Line offset at which each group starts. A collapsed tree list stops at the
|
|
172
|
-
// first group that overflows its line budget, so groups starting at or past
|
|
173
|
-
// the budget are never shown — hand it same-length placeholders instead of
|
|
174
|
-
// styling them (renderTreeList only needs their line counts).
|
|
175
|
-
const groupStarts: number[] = [];
|
|
176
|
-
let groupStart = 0;
|
|
177
|
-
for (const group of matchGroups) {
|
|
178
|
-
groupStarts.push(groupStart);
|
|
179
|
-
groupStart += group.length;
|
|
180
|
-
}
|
|
181
150
|
|
|
182
151
|
const extraLines: string[] = [];
|
|
183
152
|
if (limitReached) {
|
|
@@ -192,18 +161,13 @@ export const astGrepToolRenderer = {
|
|
|
192
161
|
return createCachedComponent(
|
|
193
162
|
() => options.expanded,
|
|
194
163
|
width => {
|
|
164
|
+
const { shown, summary } = fitGroupsToBudget(
|
|
165
|
+
matchGroups,
|
|
166
|
+
options.expanded ? Number.POSITIVE_INFINITY : COLLAPSED_MATCH_LIMIT,
|
|
167
|
+
{ isUnit: index => isMatchRow(allLines[index]!), unit: "match", total: matchCount },
|
|
168
|
+
);
|
|
195
169
|
const matchLines = renderTreeList(
|
|
196
|
-
{
|
|
197
|
-
items: matchGroups,
|
|
198
|
-
expanded: options.expanded,
|
|
199
|
-
maxCollapsed: matchGroups.length,
|
|
200
|
-
maxCollapsedLines: COLLAPSED_MATCH_LIMIT,
|
|
201
|
-
itemType: "match",
|
|
202
|
-
renderItem: (group, context) =>
|
|
203
|
-
!options.expanded && groupStarts[context.index]! >= COLLAPSED_MATCH_LIMIT
|
|
204
|
-
? Array.from({ length: group.length }, () => "")
|
|
205
|
-
: group.map(styleLine),
|
|
206
|
-
},
|
|
170
|
+
{ items: shown, trailingSummary: summary, renderItem: group => group.map(styleLine) },
|
|
207
171
|
uiTheme,
|
|
208
172
|
);
|
|
209
173
|
return fitHeaderedRows(header, [...matchLines, ...extraLines], width);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type * as XtermModule from "@linxiraos/pi-utils/vterm";
|
|
2
|
+
import type { Component } from "../tui";
|
|
3
|
+
import type { DescribeContext, NativeNode, NativeUiEvent } from "../native/node";
|
|
4
|
+
import type { Theme } from "../theme/theme";
|
|
5
|
+
/** Resize-only backend exposed by an interactive PTY controller. */
|
|
6
|
+
export interface BashInteractiveTerminalBackend {
|
|
7
|
+
resize(columns: number, rows: number): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Translates a TUI key event into the bytes a terminal would send to a PTY
|
|
11
|
+
* child; key releases encode to "". Shared by the agent `pty` console and
|
|
12
|
+
* `!` commands (`BashExecutionComponent.encodePtyInput`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeInputForPty(data: string, applicationCursorKeysMode: boolean): string;
|
|
15
|
+
/** Interactive terminal overlay driven by an external PTY controller. */
|
|
16
|
+
export declare class BashInteractiveOverlayComponent implements Component {
|
|
17
|
+
#private;
|
|
18
|
+
/** Native sheet: a full-pane glass overlay titled Console. */
|
|
19
|
+
readonly nativeOverlay: {
|
|
20
|
+
readonly role: "zeta.overlay.console";
|
|
21
|
+
readonly size: "full";
|
|
22
|
+
readonly head: "Console";
|
|
23
|
+
};
|
|
24
|
+
constructor(command: string, uiTheme: Theme, getTerminalRows: () => number, terminalCtor: typeof XtermModule.Terminal, backend: BashInteractiveTerminalBackend);
|
|
25
|
+
/** Connects normalized keyboard input and overlay lifecycle events to the controller. */
|
|
26
|
+
setHandlers(onInput: (data: string) => void, onDismiss: () => void, onDispose: () => void): void;
|
|
27
|
+
/** Queues a raw terminal output chunk for virtual-terminal rendering. */
|
|
28
|
+
appendOutput(chunk: string): void;
|
|
29
|
+
/** Resolves when the virtual terminal has processed all queued output. */
|
|
30
|
+
flushOutput(): Promise<void>;
|
|
31
|
+
/** Records process completion and stops forwarding keyboard input. */
|
|
32
|
+
setComplete(result: {
|
|
33
|
+
exitCode: number | undefined;
|
|
34
|
+
cancelled: boolean;
|
|
35
|
+
timedOut: boolean;
|
|
36
|
+
}): void;
|
|
37
|
+
handleInput(data: string): void;
|
|
38
|
+
/** The Force kill button runs the Esc path. */
|
|
39
|
+
handleNativeEvent(event: NativeUiEvent): void;
|
|
40
|
+
/**
|
|
41
|
+
* Native view: the command with its state badge, the PTY screen as an
|
|
42
|
+
* `ansi` node (SGR kept, fixed to the PTY grid), and a footer with the
|
|
43
|
+
* Force kill action while running.
|
|
44
|
+
*/
|
|
45
|
+
describe(cx: DescribeContext): NativeNode;
|
|
46
|
+
render(width: number): readonly string[];
|
|
47
|
+
invalidate(): void;
|
|
48
|
+
dispose(): void;
|
|
49
|
+
}
|
|
@@ -25,7 +25,12 @@ const NATIVE_SHEET_INSET_COLS = 8;
|
|
|
25
25
|
// Action id of the native Force kill button (mirrors Esc).
|
|
26
26
|
const KILL_ACTION = "kill";
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Translates a TUI key event into the bytes a terminal would send to a PTY
|
|
30
|
+
* child; key releases encode to "". Shared by the agent `pty` console and
|
|
31
|
+
* `!` commands (`BashExecutionComponent.encodePtyInput`).
|
|
32
|
+
*/
|
|
33
|
+
export function normalizeInputForPty(data: string, applicationCursorKeysMode: boolean): string {
|
|
29
34
|
const kitty = parseKittySequence(data);
|
|
30
35
|
if (kitty?.eventType === 3) {
|
|
31
36
|
return "";
|
package/src/tools/bash.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface BashToolDetails {
|
|
|
24
24
|
exitCode?: number;
|
|
25
25
|
/** True when the command was killed by its timeout deadline (not a failure). */
|
|
26
26
|
timedOut?: boolean;
|
|
27
|
+
/** Text the command wrote to `out://`, oldest first; transcripts draw each as a reply after the call. */
|
|
28
|
+
replies?: string[];
|
|
27
29
|
/** Live ACP update only; completed results refer to released terminals. */
|
|
28
30
|
terminalId?: string;
|
|
29
31
|
service?: {
|
package/src/tools/bash.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
replaceTabs,
|
|
14
14
|
} from "../render/render-utils";
|
|
15
15
|
import {
|
|
16
|
+
formatMinimizedMeta,
|
|
16
17
|
formatStyledTruncationWarning,
|
|
17
18
|
type OutputMeta,
|
|
18
19
|
stripOutputNotice,
|
|
@@ -69,6 +70,8 @@ export interface BashToolDetails {
|
|
|
69
70
|
exitCode?: number;
|
|
70
71
|
/** True when the command was killed by its timeout deadline (not a failure). */
|
|
71
72
|
timedOut?: boolean;
|
|
73
|
+
/** Text the command wrote to `out://`, oldest first; transcripts draw each as a reply after the call. */
|
|
74
|
+
replies?: string[];
|
|
72
75
|
/** Live ACP update only; completed results refer to released terminals. */
|
|
73
76
|
terminalId?: string;
|
|
74
77
|
service?: {
|
|
@@ -349,6 +352,10 @@ function bashStatsParts(
|
|
|
349
352
|
if (artifactId) {
|
|
350
353
|
statsParts.push(`Artifact: ${artifactId}`);
|
|
351
354
|
}
|
|
355
|
+
const minimized = details?.meta?.minimized;
|
|
356
|
+
if (minimized) {
|
|
357
|
+
statsParts.push(`Minimized: ${formatMinimizedMeta(minimized)}`);
|
|
358
|
+
}
|
|
352
359
|
if (isError && typeof details?.exitCode === "number") {
|
|
353
360
|
statsParts.push(`Exit: ${details.exitCode}`);
|
|
354
361
|
}
|
|
@@ -398,6 +405,8 @@ function shellFootParts(details: BashToolDetails | undefined, artifactId: string
|
|
|
398
405
|
if (service.pid !== undefined) parts.push(`PID ${service.pid}`);
|
|
399
406
|
}
|
|
400
407
|
if (artifactId) parts.push(`Artifact ${artifactId}`);
|
|
408
|
+
const minimized = details?.meta?.minimized;
|
|
409
|
+
if (minimized) parts.push(`Minimized ${formatMinimizedMeta(minimized)}`);
|
|
401
410
|
return parts;
|
|
402
411
|
}
|
|
403
412
|
|
|
@@ -22,10 +22,12 @@ export interface DefaultToolRenderInput {
|
|
|
22
22
|
export declare function formatDefaultToolExecution(input: DefaultToolRenderInput, contentWidth: number, uiTheme: Theme): string;
|
|
23
23
|
/**
|
|
24
24
|
* TSP view of the generic fallback card: the tool label with a one-line args
|
|
25
|
-
* summary as the head target; the result as
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
* summary as the head target; the result as JSON (the host's `json` viewer,
|
|
26
|
+
* else a JSON tree) or raw `ansi` output. The complete output goes over the
|
|
27
|
+
* wire — the card-level disclosure clamp the terminal applies is the only
|
|
28
|
+
* bound, so an expanded card keeps every row. The `json` viewer never cuts;
|
|
29
|
+
* JSON the fallback tree's depth, node or scalar caps would cut keeps the raw
|
|
30
|
+
* path instead.
|
|
29
31
|
*/
|
|
30
32
|
export declare function describeDefaultToolExecution(input: DefaultToolRenderInput): NativeToolView;
|
|
31
33
|
/** Render the generic fallback as the state-tinted card used by direct custom tools. */
|