@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/mcp.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { plainText } from "../native/spans";
|
|
|
16
16
|
import { errorText, noteText, truncationNotice } from "./native-view";
|
|
17
17
|
import { getMarkdownTheme, type Theme } from "../theme/theme";
|
|
18
18
|
import {
|
|
19
|
-
|
|
19
|
+
describeJsonValue,
|
|
20
20
|
formatArgsInline,
|
|
21
21
|
JSON_TREE_MAX_DEPTH_COLLAPSED,
|
|
22
22
|
JSON_TREE_MAX_DEPTH_EXPANDED,
|
|
@@ -302,38 +302,46 @@ function mcpHead(title: string, entries: readonly [string, unknown][]): NativeTo
|
|
|
302
302
|
/**
|
|
303
303
|
* Native counterpart of the ANSI card's Args tree: the complete arguments,
|
|
304
304
|
* folded under an `Args` section because the head summary clips each value.
|
|
305
|
+
* The host's `json` viewer, when it draws one, lists the arguments with their
|
|
306
|
+
* containers folded to one-line previews.
|
|
305
307
|
*/
|
|
306
|
-
function mcpArgsSection(entries: readonly [string, unknown][]): NativeNode | undefined {
|
|
308
|
+
function mcpArgsSection(entries: readonly [string, unknown][], json: boolean): NativeNode | undefined {
|
|
307
309
|
if (entries.length === 0) return undefined;
|
|
308
310
|
return node(
|
|
309
311
|
"section",
|
|
310
312
|
{ head: [span("Args", "muted")], collapsible: true, collapsed: true },
|
|
311
|
-
[
|
|
313
|
+
[describeJsonValue(Object.fromEntries(entries), { native: json })],
|
|
312
314
|
"args",
|
|
313
315
|
);
|
|
314
316
|
}
|
|
315
317
|
|
|
316
318
|
/** Native MCP call view: the head plus the folded args, inline while pending. */
|
|
317
|
-
export function describeMCPCall(
|
|
319
|
+
export function describeMCPCall(
|
|
320
|
+
args: Record<string, unknown>,
|
|
321
|
+
label: string,
|
|
322
|
+
options?: RenderResultOptions,
|
|
323
|
+
): NativeToolView {
|
|
318
324
|
const entries = visibleMcpArgs(args);
|
|
319
|
-
const section = mcpArgsSection(entries);
|
|
325
|
+
const section = mcpArgsSection(entries, options?.json === true);
|
|
320
326
|
return { tool: mcpHead(label, entries), body: section ? [section] : undefined, inline: true };
|
|
321
327
|
}
|
|
322
328
|
|
|
323
329
|
const mcpResultMemo = new OwnerMemo<NativeToolView | undefined>();
|
|
324
330
|
|
|
325
331
|
/**
|
|
326
|
-
* Native MCP result view: JSON output as
|
|
327
|
-
*
|
|
328
|
-
*
|
|
332
|
+
* Native MCP result view: JSON output as the host's `json` viewer (when it
|
|
333
|
+
* draws one) or a JSON tree, Markdown when the preference is on, otherwise
|
|
334
|
+
* the raw text as tool output; the folded Args section follows, so the
|
|
335
|
+
* collapsed preview still leads with the output.
|
|
329
336
|
*/
|
|
330
337
|
export function describeMCPResult(
|
|
331
338
|
result: { content: Array<{ type: string; text?: string }>; details?: MCPToolDetails; isError?: boolean },
|
|
332
|
-
|
|
339
|
+
options: RenderResultOptions,
|
|
333
340
|
args?: Record<string, unknown>,
|
|
334
341
|
): NativeToolView | undefined {
|
|
342
|
+
const json = options.json === true;
|
|
335
343
|
// Callers allocate a fresh args object per streamed delta, so identity is a sound dep.
|
|
336
|
-
return mcpResultMemo.get(result, [renderMarkdownResults, args], () => {
|
|
344
|
+
return mcpResultMemo.get(result, [renderMarkdownResults, args, json], () => {
|
|
337
345
|
const textContent = (result.content ?? [])
|
|
338
346
|
.filter(block => block.type === "text")
|
|
339
347
|
.map(block => block.text ?? "")
|
|
@@ -355,13 +363,13 @@ export function describeMCPResult(
|
|
|
355
363
|
}
|
|
356
364
|
if (!output) body.push(noteText("(no output)"));
|
|
357
365
|
else if (isError) body.push(errorText(output));
|
|
358
|
-
else if (isJson) body.push(
|
|
366
|
+
else if (isJson) body.push(describeJsonValue(parsed, { native: json }));
|
|
359
367
|
else if (renderMarkdownResults) body.push(md(output));
|
|
360
368
|
else body.push(ansi(output));
|
|
361
369
|
const warning = truncationNotice(result.details?.meta);
|
|
362
370
|
if (warning) body.push(warning);
|
|
363
371
|
const entries = visibleMcpArgs(args);
|
|
364
|
-
const section = mcpArgsSection(entries);
|
|
372
|
+
const section = mcpArgsSection(entries, json);
|
|
365
373
|
if (section) body.push(section);
|
|
366
374
|
return {
|
|
367
375
|
tool: mcpHead(title, entries),
|
|
@@ -6,8 +6,10 @@ import { type OutputMeta } from "./output-meta";
|
|
|
6
6
|
import type { NativeToolHead, NativeToolView, ToolRenderResult } from "./renderer";
|
|
7
7
|
/** A path for native heads: relative to the working directory when inside it, else `~`-shortened. */
|
|
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
|
/**
|
package/src/tools/native-view.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { TspSpan, TspText, TspTone } from "@linxiraos/pi-wire";
|
|
|
8
8
|
import { ansi, code, compact, keyed, node, row, span, text } from "../native/describe";
|
|
9
9
|
import type { NativeChild, NativeNode } from "../native/node";
|
|
10
10
|
import { tryFileUri } from "../render/hyperlink";
|
|
11
|
-
import { type ParsedDiagnostic, parseDiagnosticMessage, shortenPath } from "../render/render-utils";
|
|
11
|
+
import { type ParsedDiagnostic, parseDiagnosticMessage, pathNameStart, shortenPath } from "../render/render-utils";
|
|
12
12
|
import { plainText } from "../native/spans";
|
|
13
13
|
import type { FileDiagnosticsResult } from "./lsp";
|
|
14
14
|
import { formatArtifactErrorNotice, formatTruncationMetaNotice, type OutputMeta } from "./output-meta";
|
|
@@ -23,11 +23,18 @@ export function displayPath(filePath: string): string {
|
|
|
23
23
|
return shortenPath(filePath);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/** Configured file link for a head's path target, when the path is absolute. */
|
|
27
27
|
export function fileHref(filePath: string | undefined): string | undefined {
|
|
28
28
|
return filePath && path.isAbsolute(filePath) ? tryFileUri(filePath) : undefined;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/** Link for a head target that is a web URL (`www.` gains `https://`), else undefined. */
|
|
32
|
+
export function urlHref(target: string | undefined): string | undefined {
|
|
33
|
+
if (!target) return undefined;
|
|
34
|
+
const candidate = /^www\./i.test(target) ? `https://${target}` : target;
|
|
35
|
+
return /^https?:\/\/\S+$/i.test(candidate) ? candidate : undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
/** Diff stats as one head `meta` string, `+8 −1` (U+2212 minus), or undefined when nothing changed. */
|
|
32
39
|
export function diffStatsMeta(added: number, removed: number): string | undefined {
|
|
33
40
|
const parts: string[] = [];
|
|
@@ -74,11 +81,10 @@ export function fileRow(
|
|
|
74
81
|
} = {},
|
|
75
82
|
): NativeNode {
|
|
76
83
|
const isDir = filePath.endsWith("/");
|
|
77
|
-
const
|
|
78
|
-
const cut = bare.lastIndexOf("/") + 1;
|
|
84
|
+
const cut = pathNameStart(filePath);
|
|
79
85
|
const spans: TspSpan[] = [];
|
|
80
|
-
if (cut > 0) spans.push(span(
|
|
81
|
-
spans.push(span(
|
|
86
|
+
if (cut > 0) spans.push(span(filePath.slice(0, cut), "dim"));
|
|
87
|
+
spans.push(span(filePath.slice(cut) || "…", "strong", p.href ? { href: p.href } : undefined));
|
|
82
88
|
if (p.range) spans.push(span(p.range, "muted"));
|
|
83
89
|
const children: NativeChild[] = [
|
|
84
90
|
p.lead ?? node("icon", { name: p.icon ?? (isDir ? "folder" : "file"), tone: p.tone }),
|
|
@@ -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.
|
package/src/tools/output-meta.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { Theme } from "../theme/theme";
|
|
2
|
-
import {
|
|
2
|
+
import { sanitizeText } from "@linxiraos/pi-utils";
|
|
3
|
+
import {
|
|
4
|
+
flattenLine,
|
|
5
|
+
formatBytes,
|
|
6
|
+
shortenEmbeddedPaths,
|
|
7
|
+
TRUNCATE_LENGTHS,
|
|
8
|
+
truncateToWidth,
|
|
9
|
+
wrapBrackets,
|
|
10
|
+
} from "../render/render-utils";
|
|
3
11
|
import type { OutputArtifactError } from "./streaming-output";
|
|
4
12
|
import { formatGroupedFiles } from "./grouped-file-output";
|
|
5
13
|
|
|
@@ -76,9 +84,23 @@ export interface LimitsMeta {
|
|
|
76
84
|
artifactElidedBytes?: number;
|
|
77
85
|
lines?: { first: number; last: number };
|
|
78
86
|
selectorBase?: string;
|
|
87
|
+
/** The first cut line exceeds what one `:raw` read returns; that read stops at this many bytes. */
|
|
88
|
+
rawByteCap?: number;
|
|
79
89
|
};
|
|
80
90
|
}
|
|
81
91
|
|
|
92
|
+
/**
|
|
93
|
+
* The bash minimizer rewrote this output: `filter` is the native filter label
|
|
94
|
+
* (`chain` for a minimized `&&`/`;` chain), the byte counts are the raw capture
|
|
95
|
+
* and the minimized text, and `artifactId` holds the raw capture.
|
|
96
|
+
*/
|
|
97
|
+
export interface MinimizedMeta {
|
|
98
|
+
filter: string;
|
|
99
|
+
inputBytes: number;
|
|
100
|
+
outputBytes: number;
|
|
101
|
+
artifactId: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
82
104
|
/**
|
|
83
105
|
* Structured metadata for tool outputs.
|
|
84
106
|
*/
|
|
@@ -91,6 +113,7 @@ export interface OutputMeta {
|
|
|
91
113
|
pagedSource?: true;
|
|
92
114
|
diagnostics?: DiagnosticMeta;
|
|
93
115
|
limits?: LimitsMeta;
|
|
116
|
+
minimized?: MinimizedMeta;
|
|
94
117
|
}
|
|
95
118
|
|
|
96
119
|
// Regex: split on the first `:digits:digits` boundary to separate path from the rest
|
|
@@ -202,6 +225,33 @@ export function stripRawOutputArtifactNotice(text: string): { text: string; arti
|
|
|
202
225
|
return artifactId === undefined ? { text } : { text: stripped, artifactId };
|
|
203
226
|
}
|
|
204
227
|
|
|
228
|
+
/** The column-cap clause {@link formatOutputNotice} puts in a notice, alone or after other parts. */
|
|
229
|
+
const COLUMN_TRUNCATION_CLAUSE = "Some lines truncated to ";
|
|
230
|
+
/**
|
|
231
|
+
* The rest of the clause as {@link formatOutputNotice} writes it: the cap as JavaScript prints a
|
|
232
|
+
* finite number (the setting takes any, `768.5` included), its unit, then a `. ` suffix or the bracket.
|
|
233
|
+
*/
|
|
234
|
+
const COLUMN_TRUNCATION_TAIL = String.raw`-?\d+(?:\.\d+)?(?:e[+-]\d+)? (?:chars|bytes)(?:\. .*)?\]$`;
|
|
235
|
+
const COLUMN_TRUNCATION_NOTICE = new RegExp(String.raw`^\[${COLUMN_TRUNCATION_CLAUSE}${COLUMN_TRUNCATION_TAIL}`, "u");
|
|
236
|
+
const COLUMN_TRUNCATION_IN_NOTICE = new RegExp(
|
|
237
|
+
String.raw`^\[.*\. ${COLUMN_TRUNCATION_CLAUSE}${COLUMN_TRUNCATION_TAIL}`,
|
|
238
|
+
"u",
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
/** Whether `line` is the column-cap notice {@link formatOutputNotice} emits (`[Some lines truncated to 768 chars…]`). */
|
|
242
|
+
export function isColumnTruncationNotice(line: string): boolean {
|
|
243
|
+
return COLUMN_TRUNCATION_NOTICE.test(line.trim());
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Whether the bracketed notice `line` carries the column-cap clause: alone, or after the parts
|
|
248
|
+
* {@link formatOutputNotice} joins before it (`[Showing lines 1-4 of 5. … Some lines truncated to 768 chars…]`).
|
|
249
|
+
*/
|
|
250
|
+
export function hasColumnTruncationClause(line: string): boolean {
|
|
251
|
+
const trimmed = line.trim();
|
|
252
|
+
return COLUMN_TRUNCATION_NOTICE.test(trimmed) || COLUMN_TRUNCATION_IN_NOTICE.test(trimmed);
|
|
253
|
+
}
|
|
254
|
+
|
|
205
255
|
function isGeneratedOutputNoticeLine(line: string): boolean {
|
|
206
256
|
if (!line.startsWith("[") || !line.endsWith("]")) return false;
|
|
207
257
|
const body = line.slice(1, -1);
|
|
@@ -209,7 +259,7 @@ function isGeneratedOutputNoticeLine(line: string): boolean {
|
|
|
209
259
|
body.startsWith("Showing ") ||
|
|
210
260
|
/^\d+ matches limit reached\. Use limit=\d+ for more/u.test(body) ||
|
|
211
261
|
/^\d+ results limit reached(?:\.|$)/u.test(body) ||
|
|
212
|
-
|
|
262
|
+
isColumnTruncationNotice(line)
|
|
213
263
|
);
|
|
214
264
|
}
|
|
215
265
|
|
|
@@ -297,6 +347,17 @@ export function formatArtifactErrorNotice(error: OutputArtifactError): string {
|
|
|
297
347
|
return `Full output was not saved completely (artifact ${error} failed)`;
|
|
298
348
|
}
|
|
299
349
|
|
|
350
|
+
/**
|
|
351
|
+
* `git 120.4KB → 3.2KB`: the minimizer filter that ran and the bytes it took the output from and to.
|
|
352
|
+
* Native labels are short words; a rehydrated session or extension may carry any text, so the label
|
|
353
|
+
* is sanitized to one plain line, its home paths shortened to `~`, and width-bounded.
|
|
354
|
+
*/
|
|
355
|
+
export function formatMinimizedMeta(minimized: MinimizedMeta): string {
|
|
356
|
+
const label = shortenEmbeddedPaths(flattenLine(sanitizeText(minimized.filter)));
|
|
357
|
+
const filter = truncateToWidth(label, TRUNCATE_LENGTHS.SHORT);
|
|
358
|
+
return `${filter} ${formatBytes(minimized.inputBytes)} → ${formatBytes(minimized.outputBytes)}`;
|
|
359
|
+
}
|
|
360
|
+
|
|
300
361
|
/**
|
|
301
362
|
* Format notices from OutputMeta for LLM consumption.
|
|
302
363
|
* Returns empty string if no notices needed.
|
|
@@ -340,14 +401,17 @@ export function formatOutputNotice(meta: OutputMeta | undefined): string {
|
|
|
340
401
|
// notices always read "chars", so default missing units to it. Otherwise
|
|
341
402
|
// a resumed legacy session renders "… 768 undefined" and stripOutputNotice
|
|
342
403
|
// stops matching the persisted "… 768 chars" text.
|
|
343
|
-
let columnNotice =
|
|
404
|
+
let columnNotice = `${COLUMN_TRUNCATION_CLAUSE}${c.maxColumn} ${c.unit ?? "chars"}`;
|
|
344
405
|
// An artifact cut to a head/tail sample renumbers its lines, so only a complete one names a line.
|
|
345
406
|
const selectorBase =
|
|
346
407
|
c.selectorBase ?? (c.artifactId != null && !c.artifactElidedBytes ? `artifact://${c.artifactId}` : undefined);
|
|
347
408
|
if (c.lines && selectorBase !== undefined) {
|
|
348
409
|
// One line per selector: a span of cut lines can exceed what one read returns.
|
|
349
410
|
const { first, last } = c.lines;
|
|
350
|
-
columnNotice +=
|
|
411
|
+
columnNotice +=
|
|
412
|
+
c.rawByteCap === undefined
|
|
413
|
+
? `. Use ${selectorBase}:raw:${first}-${first} to read line ${first} whole`
|
|
414
|
+
: `. Use ${selectorBase}:raw:${first}-${first} to read line ${first} uncut, byte-capped at ${formatBytes(c.rawByteCap)}`;
|
|
351
415
|
if (last > first) columnNotice += `; cut lines run to line ${last}, each read the same way`;
|
|
352
416
|
} else if (c.artifactId != null) {
|
|
353
417
|
columnNotice += `. ${formatFullOutputReference(c.artifactId, c.artifactElidedBytes)}`;
|
package/src/tools/proc-render.ts
CHANGED
|
@@ -138,10 +138,10 @@ function jobRow(job: JobSnapshot, theme: Theme): string {
|
|
|
138
138
|
? "error"
|
|
139
139
|
: job.status === "running"
|
|
140
140
|
? "running"
|
|
141
|
-
: "
|
|
141
|
+
: "success",
|
|
142
142
|
theme,
|
|
143
143
|
);
|
|
144
|
-
return `${icon} ${formatBadge(job.type, job.status === "failed" ? "error" : job.status === "cancelled" ? "warning" : "accent", theme)} ${theme.fg("toolOutput", safe(job.id))} ${theme.fg("dim", safe(job.label))} ${theme.fg("dim", formatDuration(job.durationMs))}`;
|
|
144
|
+
return `${icon} ${formatBadge(job.type, job.status === "failed" ? "error" : job.status === "cancelled" ? "warning" : "accent", theme)} ${theme.fg("toolOutput", safe(job.id))} ${theme.fg("dim", safe(job.intent || job.label))} ${theme.fg("dim", formatDuration(job.durationMs))}`;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/** Render live and completed process writes with the URL-selected operation. */
|
|
@@ -303,7 +303,7 @@ function jobItem(job: JobSnapshot, badge?: { text: string; tone: TspTone }): Nat
|
|
|
303
303
|
"item",
|
|
304
304
|
{
|
|
305
305
|
label: [span(job.type, "accent"), span(" "), span(safe(job.id), "toolOutput")],
|
|
306
|
-
detail: [span(safe(job.label), "muted")],
|
|
306
|
+
detail: [span(safe(job.intent || job.label), "muted")],
|
|
307
307
|
value: badge ? [span(badge.text, badge.tone)] : [span(formatDuration(job.durationMs), "muted")],
|
|
308
308
|
tone: badge?.tone ?? jobTone(job.status),
|
|
309
309
|
},
|
package/src/tools/read.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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. */
|
package/src/tools/read.ts
CHANGED
|
@@ -242,6 +242,20 @@ export function splitInternalUrlSel(
|
|
|
242
242
|
return { path, sel: chunks.join(":") };
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
/** A read query after a filesystem path: `?key=` (`?q=…`, `?limit=…&where=…`), not a `\\?\` long-path prefix. */
|
|
246
|
+
const READ_QUERY_RE = /(?<!^\\\\)\?\w+=/;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Split a filesystem read target from its query (`data.json?q=.items` →
|
|
250
|
+
* `data.json`, `?q=.items`), the display twin of the read tool's JSON, SQLite
|
|
251
|
+
* and image-question parsers. URLs own their query string and stay whole, as
|
|
252
|
+
* does a `?` inside a file name.
|
|
253
|
+
*/
|
|
254
|
+
export function splitReadQuery(readPath: string): { path: string; query?: string } {
|
|
255
|
+
const at = splitUrlScheme(readPath) ? -1 : readPath.search(READ_QUERY_RE);
|
|
256
|
+
return at > 0 ? { path: readPath.slice(0, at), query: readPath.slice(at) } : { path: readPath };
|
|
257
|
+
}
|
|
258
|
+
|
|
245
259
|
/** Recognize HTTP URLs and www-prefixed external read targets. */
|
|
246
260
|
export function isReadableUrlPath(value: string): boolean {
|
|
247
261
|
return /^https?:\/\/?/i.test(value) || /^www\./i.test(value);
|
|
@@ -466,11 +480,11 @@ function readRangeStart(rawPath: string, args: ReadRenderArgs | undefined): numb
|
|
|
466
480
|
}
|
|
467
481
|
|
|
468
482
|
/**
|
|
469
|
-
* Read content as numbered, wrapped `code` (no path header: the head
|
|
470
|
-
* the file), matching the ANSI preview's hanging wrap. Numbers come from
|
|
483
|
+
* Read content as one numbered, wrapped `code` block (no path header: the head
|
|
484
|
+
* names the file), matching the ANSI preview's hanging wrap. Numbers come from
|
|
471
485
|
* `lineNumbers` (`displayContent`'s per-line numbers, `null` for an elided
|
|
472
|
-
* block
|
|
473
|
-
* up from `start`.
|
|
486
|
+
* block, which Tern shows as a `…` gap row where the numbers jump) when they
|
|
487
|
+
* cover every line, else count up from `start`.
|
|
474
488
|
*/
|
|
475
489
|
export function readContentCode(
|
|
476
490
|
content: string,
|
|
@@ -479,10 +493,11 @@ export function readContentCode(
|
|
|
479
493
|
path: string | undefined,
|
|
480
494
|
): NativeNode[] {
|
|
481
495
|
const lines = content.split("\n");
|
|
482
|
-
|
|
496
|
+
const block = numberedCode(
|
|
483
497
|
lines.map((text, i) => ({ n: numbers && numbers.length === lines.length ? numbers[i]! : start + i, text })),
|
|
484
498
|
{ path, wrap: true },
|
|
485
499
|
);
|
|
500
|
+
return block ? [block] : [];
|
|
486
501
|
}
|
|
487
502
|
|
|
488
503
|
/** An image content block as the read tool emits it (base64 data + mime type). */
|
package/src/tools/renderer.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface RenderResultOptions {
|
|
|
36
36
|
cancelled?: boolean;
|
|
37
37
|
/** The native host shows files by path (`cx.supports("media")`). Native describe hooks only. */
|
|
38
38
|
media?: boolean;
|
|
39
|
+
/** The native host draws raw JSON values (`cx.supports("json")`). Native describe hooks only. */
|
|
40
|
+
json?: boolean;
|
|
39
41
|
}
|
|
40
42
|
/** Render options for a result, plus the tool-specific context the transcript threads through. */
|
|
41
43
|
export type RenderResultContextOptions = RenderResultOptions & {
|
package/src/tools/renderer.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface RenderResultOptions {
|
|
|
37
37
|
cancelled?: boolean;
|
|
38
38
|
/** The native host shows files by path (`cx.supports("media")`). Native describe hooks only. */
|
|
39
39
|
media?: boolean;
|
|
40
|
+
/** The native host draws raw JSON values (`cx.supports("json")`). Native describe hooks only. */
|
|
41
|
+
json?: boolean;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
/** Render options for a result, plus the tool-specific context the transcript threads through. */
|
|
@@ -177,6 +177,17 @@ export declare function truncateLineBytes(line: string, maxBytes?: number): {
|
|
|
177
177
|
text: string;
|
|
178
178
|
wasTruncated: boolean;
|
|
179
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* Where `text` shows in `output` written through an {@link OutputSink} with
|
|
182
|
+
* `maxColumns`, searching from `from`: each of its lines whole, or, where the
|
|
183
|
+
* cap cut the output line, a head of it and `…` ending that output line.
|
|
184
|
+
* Only the first line can be cut short of its first 16 characters (after
|
|
185
|
+
* other text on its output line); such text is not found.
|
|
186
|
+
*/
|
|
187
|
+
export declare function findColumnCapped(output: string, text: string, from?: number): {
|
|
188
|
+
start: number;
|
|
189
|
+
end: number;
|
|
190
|
+
} | undefined;
|
|
180
191
|
/** Shared helper to build a no-truncation result. */
|
|
181
192
|
export declare function noTruncResult(content: string, totalLines?: number, totalBytes?: number): TruncationResult;
|
|
182
193
|
/**
|
|
@@ -323,6 +323,47 @@ export function truncateLineBytes(
|
|
|
323
323
|
return { text: materializeString(`${head}…`), wasTruncated: true };
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
/** Leading characters of a text's first line {@link findColumnCapped} searches for. */
|
|
327
|
+
const CAPPED_PROBE_CHARS = 16;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Where `text` shows in `output` written through an {@link OutputSink} with
|
|
331
|
+
* `maxColumns`, searching from `from`: each of its lines whole, or, where the
|
|
332
|
+
* cap cut the output line, a head of it and `…` ending that output line.
|
|
333
|
+
* Only the first line can be cut short of its first 16 characters (after
|
|
334
|
+
* other text on its output line); such text is not found.
|
|
335
|
+
*/
|
|
336
|
+
export function findColumnCapped(output: string, text: string, from = 0): { start: number; end: number } | undefined {
|
|
337
|
+
if (!text) return undefined;
|
|
338
|
+
const lines = text.split(NL);
|
|
339
|
+
const probe = lines[0] ? lines[0].slice(0, CAPPED_PROBE_CHARS) : NL;
|
|
340
|
+
for (let at = output.indexOf(probe, from); at !== -1; at = output.indexOf(probe, at + 1)) {
|
|
341
|
+
const end = cappedLinesEnd(output, at, lines);
|
|
342
|
+
if (end !== undefined) return { start: at, end };
|
|
343
|
+
}
|
|
344
|
+
return undefined;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** End of `lines` shown in column-capped `output` from `at`, if they show there. */
|
|
348
|
+
function cappedLinesEnd(output: string, at: number, lines: readonly string[]): number | undefined {
|
|
349
|
+
let pos = at;
|
|
350
|
+
for (let i = 0; i < lines.length; i++) {
|
|
351
|
+
const line = lines[i];
|
|
352
|
+
const last = i === lines.length - 1;
|
|
353
|
+
if (output.startsWith(line, pos) && (last || output[pos + line.length] === NL)) {
|
|
354
|
+
pos += last ? line.length : line.length + 1;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
let eol = output.indexOf(NL, pos);
|
|
358
|
+
if (eol === -1) eol = output.length;
|
|
359
|
+
if (eol === pos || output[eol - 1] !== ELLIPSIS || !line.startsWith(output.slice(pos, eol - 1))) return undefined;
|
|
360
|
+
if (last) return eol;
|
|
361
|
+
if (eol === output.length) return undefined;
|
|
362
|
+
pos = eol + 1;
|
|
363
|
+
}
|
|
364
|
+
return pos;
|
|
365
|
+
}
|
|
366
|
+
|
|
326
367
|
// =============================================================================
|
|
327
368
|
// Content truncation (line + byte aware, no full Buffer allocation)
|
|
328
369
|
// =============================================================================
|
package/src/tools/task.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Usage } from "@linxiraos/pi-ai";
|
|
2
2
|
import type { ThemeColor } from "../theme/theme";
|
|
3
3
|
import type { ConfiguredThinkingLevel } from "../render/render-utils";
|
|
4
|
-
import type { RenderResultOptions, NativeToolView, ToolRenderResult } from "./renderer";
|
|
5
4
|
import { type Component } from "../tui";
|
|
5
|
+
import type { RenderResultOptions } from "./renderer";
|
|
6
6
|
import { type Theme } from "../theme/theme";
|
|
7
|
+
import type { NativeToolView, ToolRenderResult } from "./renderer";
|
|
7
8
|
/** Render context threaded in from `ToolExecutionComponent.#buildRenderContext`. */
|
|
8
9
|
interface TaskRenderContext {
|
|
9
10
|
hasResult?: boolean;
|
|
@@ -103,10 +104,11 @@ export interface TaskItem {
|
|
|
103
104
|
agent?: string;
|
|
104
105
|
/** Historical source session selected by the bundled consult agent. */
|
|
105
106
|
sourceSession?: string;
|
|
106
|
-
/**
|
|
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;
|
|
111
|
+
taskFile?: string;
|
|
110
112
|
/** How open-ended the work is; required by the schema and the child's sole `auto` thinking classification input. */
|
|
111
113
|
solutionSpace?: string;
|
|
112
114
|
/** Per-spawn thinking effort: lowest/middle/highest level the resolved model supports. Overrides the agent's default selector (e.g. `auto`). */
|
|
@@ -133,10 +135,12 @@ export interface TaskParams {
|
|
|
133
135
|
agent?: string;
|
|
134
136
|
/** Historical source session selected by the bundled consult agent. */
|
|
135
137
|
sourceSession?: string;
|
|
136
|
-
/**
|
|
138
|
+
/** See {@link TaskItem.model}. */
|
|
137
139
|
model?: string | string[];
|
|
138
140
|
/** The work (flat form). */
|
|
139
141
|
task?: string;
|
|
142
|
+
/** Absolute path or local:// URL to a UTF-8 file (flat form), mutually exclusive with task. */
|
|
143
|
+
taskFile?: string;
|
|
140
144
|
/** How open-ended the work is (flat form); see {@link TaskItem.solutionSpace}. */
|
|
141
145
|
solutionSpace?: string;
|
|
142
146
|
/** Per-spawn thinking effort (flat form): lowest/middle/highest level the resolved model supports. */
|
|
@@ -212,6 +216,9 @@ export interface AgentProgress {
|
|
|
212
216
|
status: "pending" | "running" | "completed" | "failed" | "aborted";
|
|
213
217
|
task: string;
|
|
214
218
|
assignment?: string;
|
|
219
|
+
taskFile?: string;
|
|
220
|
+
/** SHA-256 of the exact task file bytes before decoding and trimming. */
|
|
221
|
+
taskFileSha256?: string;
|
|
215
222
|
description?: string;
|
|
216
223
|
lastIntent?: string;
|
|
217
224
|
currentTool?: string;
|
|
@@ -319,6 +326,8 @@ export interface SingleResult {
|
|
|
319
326
|
agentSource: AgentSource;
|
|
320
327
|
task: string;
|
|
321
328
|
assignment?: string;
|
|
329
|
+
taskFile?: string;
|
|
330
|
+
taskFileSha256?: string;
|
|
322
331
|
description?: string;
|
|
323
332
|
lastIntent?: string;
|
|
324
333
|
exitCode: number;
|