@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/charts/chart-plan.ts
CHANGED
|
@@ -33,7 +33,6 @@ import {
|
|
|
33
33
|
isNumber,
|
|
34
34
|
type NumberCell,
|
|
35
35
|
parseCell,
|
|
36
|
-
plainCell,
|
|
37
36
|
type Status,
|
|
38
37
|
type TableAnalysis,
|
|
39
38
|
type TableColumn,
|
|
@@ -536,20 +535,6 @@ const NEST_SEPARATORS = [" — ", " – ", ": ", " · ", ", ", " ", "/", "-", "_
|
|
|
536
535
|
/** Where a long row name's description starts (`Payroll (10 people…)`, `@watzon — #19, #53`). */
|
|
537
536
|
const DESCRIPTION = / [—–] | - |: | \(/;
|
|
538
537
|
|
|
539
|
-
/**
|
|
540
|
-
* Measures that improve upward, by header: pass and success rates, retrieval
|
|
541
|
-
* scores, throughput, speedups and savings.
|
|
542
|
-
*/
|
|
543
|
-
const HIGHER_BETTER =
|
|
544
|
-
/(?:^|[^\w])(?:pass(?:ed|es|ing)?|pass ?%|pass ?rate|success(?:es|ful)?|succeeded|accuracy|acc|recall|precision|prec|f1|em|exact[_ ]?match|scores?|wins?|win ?rate|hit ?rate|throughput|qps|rps|ops\/s|req\/s|tok\/s|tokens\/s|speedup|faster|improvement|savings?|saved|gain|coverage|quality|relevance|correct|solved|ok|renders|completion ?rate|uptime|performance|profits?|roi|pnl|growth|per \$|\/\$)(?![\w])/i;
|
|
545
|
-
/** Measures that improve downward, by header: cost, time, failures. */
|
|
546
|
-
const LOWER_BETTER =
|
|
547
|
-
/(?:^|[^\w])(?:cost|costs|price|bill|spend|usd|latency|time|duration|wall(?: ?clock)?|elapsed|errors?|err|fail(?:s|ed|ures?)?|timeouts?|miss(?:es)?|crash(?:es)?|regressions?|bugs?|warnings?|retries|turns|p\d{2}|blockers|violations|leaks?|stalls?|load|\$\/\w+)(?![\w])/i;
|
|
548
|
-
/** Resources a before/after change aims to shrink: lower is better only beside a baseline. */
|
|
549
|
-
const LOWER_IN_CHANGE =
|
|
550
|
-
/(?:^|[^\w])(?:tokens?|tok|rss|memory|mem|heap|allocs?|allocations?|clones|size|bytes|cpu|gc|input|output)(?![\w])/i;
|
|
551
|
-
/** Names of shares and counts that describe rather than score: no polarity whatever else they say. */
|
|
552
|
-
const NEUTRAL = /(?:^|[^\w])(?:share|shares|% of|portion|fraction|distribution|breakdown)(?![\w])/i;
|
|
553
538
|
/** Label headers naming rival options a table compares (models, configs, arms). */
|
|
554
539
|
const RIVALS =
|
|
555
540
|
/(?:^|[^\w])(?:models?|config(?:uration)?s?|arms?|variants?|approach(?:es)?|options?|plans?|polic(?:y|ies)|providers?|modes?|strateg(?:y|ies)|candidates?|settings?|shapes?|backends?|engines?|librar(?:y|ies)|implementations?|vendors?|tools?|methods?|algorithms?|setups?|runs?)(?![\w])/i;
|
|
@@ -606,13 +591,16 @@ export function planChart(table: TableAnalysis): ChartPlan | undefined {
|
|
|
606
591
|
|
|
607
592
|
/**
|
|
608
593
|
* Whether a model should pick `table`'s chart (`tui.autoGraph: smart`):
|
|
609
|
-
* multi-series tables,
|
|
610
|
-
* `guess` plots (`Thread | State`, `Finding | Current`),
|
|
611
|
-
* tells a
|
|
594
|
+
* multi-series tables, tables whose rows may be named by a number the
|
|
595
|
+
* `guess` plots (`Thread | State`, `Finding | Current`), and any other chart
|
|
596
|
+
* the guess would draw — only meaning tells a measure from page references,
|
|
597
|
+
* step numbers or figures quoted in prose, which the judge charts as none.
|
|
612
598
|
*/
|
|
613
599
|
export function shouldJudge(table: TableAnalysis, guess: ChartPlan | undefined): boolean {
|
|
614
600
|
if (!guess || table.rows.length < 3) return false;
|
|
615
|
-
|
|
601
|
+
if (table.measures.length >= 2 || leadingMeasures(table, guess).length > 0) return true;
|
|
602
|
+
const spec = buildChart(table, guess);
|
|
603
|
+
return spec !== undefined && worthCharting(spec);
|
|
616
604
|
}
|
|
617
605
|
|
|
618
606
|
/** Measure columns before `guess`'s text label column: numbers that may only name their rows. */
|
|
@@ -696,38 +684,33 @@ export function drawnNames(spec: ChartSpec): Set<string> {
|
|
|
696
684
|
}
|
|
697
685
|
|
|
698
686
|
/**
|
|
699
|
-
* The local guess at what `plan`'s rows and measures mean:
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
* `(current)` row names, and a status
|
|
687
|
+
* The local guess at what `plan`'s rows and measures mean: each measure's
|
|
688
|
+
* {@link Polarity} as far as its unit says ({@link dimPolarity}; what a name
|
|
689
|
+
* means — `Memory` as a capacity or a cost — is the judge's call), rivals from
|
|
690
|
+
* the label's header, focus from bolded or `(current)` row names, and a status
|
|
691
|
+
* column whose cells vary.
|
|
703
692
|
*/
|
|
704
693
|
export function guessMeaning(
|
|
705
694
|
table: TableAnalysis,
|
|
706
695
|
plan: ChartPlan,
|
|
707
696
|
): Pick<ChartPlan, "polarity" | "rowPolarity" | "rivals" | "focus" | "status"> {
|
|
708
697
|
const label = plan.label === undefined ? undefined : table.columns[plan.label];
|
|
709
|
-
// A comparison of two conditions reads
|
|
698
|
+
// A comparison of two conditions reads money and sizes the way a change does: as what it cuts.
|
|
710
699
|
const change =
|
|
711
700
|
plan.kind === "change" || plan.kind === "stat" || table.columns.some(column => BEFORE.test(column.header));
|
|
712
701
|
const polarity: Record<number, Polarity> = {};
|
|
713
702
|
for (const column of table.columns) {
|
|
714
|
-
if (column === label) continue;
|
|
715
703
|
// A signed delta's sign convention (saved vs. spent) is not in its unit.
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
(column.role === "measure" && !delta
|
|
720
|
-
? dimPolarity(column.dim, column.unit, change, column.scores)
|
|
721
|
-
: undefined);
|
|
704
|
+
if (column === label || column.role !== "measure" || DELTA.test(column.header) || column.signedShare >= 0.5)
|
|
705
|
+
continue;
|
|
706
|
+
const guessed = dimPolarity(column.dim, column.unit, change, column.scores);
|
|
722
707
|
if (guessed) polarity[column.index] = guessed;
|
|
723
708
|
}
|
|
724
709
|
const rowPolarity: Record<number, Polarity> = {};
|
|
725
710
|
if (label && rowsAreMetrics(table, plan))
|
|
726
711
|
for (const row of [...table.rows, ...table.totals]) {
|
|
727
712
|
const first = plan.series.map(index => table.columns[index]!.cells[row]).find(isNumber);
|
|
728
|
-
const guessed =
|
|
729
|
-
headerPolarity(label.cells[row]!.text, true) ??
|
|
730
|
-
(first ? dimPolarity(first.dim, first.unit, true, false) : undefined);
|
|
713
|
+
const guessed = first && dimPolarity(first.dim, first.unit, change, false);
|
|
731
714
|
if (guessed) rowPolarity[row] = guessed;
|
|
732
715
|
}
|
|
733
716
|
return {
|
|
@@ -745,23 +728,10 @@ export function rowsAreMetrics(table: TableAnalysis, plan: ChartPlan): boolean {
|
|
|
745
728
|
}
|
|
746
729
|
|
|
747
730
|
/**
|
|
748
|
-
* A measure's {@link Polarity} from its
|
|
749
|
-
* none); `change` admits resources a change aims to shrink.
|
|
750
|
-
*/
|
|
751
|
-
function headerPolarity(name: string, change: boolean): Polarity | undefined {
|
|
752
|
-
// `gtTagRelevance`: camelCase words read apart.
|
|
753
|
-
const plain = plainCell(name).text.replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
754
|
-
if (NEUTRAL.test(plain)) return undefined;
|
|
755
|
-
if (HIGHER_BETTER.test(plain)) return "higher";
|
|
756
|
-
if (LOWER_BETTER.test(plain)) return "lower";
|
|
757
|
-
if (change && LOWER_IN_CHANGE.test(plain)) return "lower";
|
|
758
|
-
return undefined;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
/**
|
|
762
|
-
* A measure's {@link Polarity} from its unit when its name gives none:
|
|
731
|
+
* A measure's {@link Polarity} from the unit its values are written in:
|
|
763
732
|
* scores out of a total and rates per second climb, durations shrink, and
|
|
764
|
-
* money and sizes shrink beside a baseline.
|
|
733
|
+
* money and sizes shrink beside a baseline (`change`). Elsewhere a size may
|
|
734
|
+
* be a capacity (`L2 cache`, `Memory`) and money a budget: no polarity.
|
|
765
735
|
*/
|
|
766
736
|
function dimPolarity(dim: Dimension | undefined, unit: string, change: boolean, scores: boolean): Polarity | undefined {
|
|
767
737
|
if (scores) return "higher";
|
|
@@ -1553,10 +1523,6 @@ export function buildChart(table: TableAnalysis, plan: ChartPlan): ChartSpec | u
|
|
|
1553
1523
|
// its rows are in different units.
|
|
1554
1524
|
if (arrows.length === 1 && plan.kind !== "paired" && plan.kind !== "range" && !plan.transpose)
|
|
1555
1525
|
return buildChart(table, { ...plan, kind: arrows[0]!.mixed ? "change" : "paired", series: [arrows[0]!.index] });
|
|
1556
|
-
// A dumbbell of two measures beside their ratio (`pi-walker | Go | Speedup`): the ratio restates the gap the
|
|
1557
|
-
// dumbbell draws (on a log axis its length), so the pair draws alone.
|
|
1558
|
-
const pair = plan.kind === "paired" && !plan.transpose ? ratioPair(table, columns) : undefined;
|
|
1559
|
-
if (pair) return buildChart(table, { ...plan, series: pair.map(column => column.index) });
|
|
1560
1526
|
// Unitless before/after values spanning decades are rows of different quantities, and rows of very different
|
|
1561
1527
|
// sizes beside a baseline column share no readable axis; their factors do (`3.95M → 190k` is 21× less).
|
|
1562
1528
|
// Intervals keep their values: a range chart prints the factor between a pair's midpoints beside both.
|
|
@@ -2840,31 +2806,6 @@ function againstBaseline(
|
|
|
2840
2806
|
return [baseline, ...columns.filter(column => column !== baseline)];
|
|
2841
2807
|
}
|
|
2842
2808
|
|
|
2843
|
-
/** Relative slack within which a ratio column restates the ratio of two others (`4.1×` for 75.3 / 18.2). */
|
|
2844
|
-
const RATIO_SLACK = 0.05;
|
|
2845
|
-
|
|
2846
|
-
/**
|
|
2847
|
-
* Of three plotted columns, the two same-unit measures when the third is their ratio (`Speedup`
|
|
2848
|
-
* `4.1×`, a `ratio` column) matching `a ÷ b` or `b ÷ a` within {@link RATIO_SLACK}
|
|
2849
|
-
* in every row holding all three, two rows at least; else `undefined`.
|
|
2850
|
-
*/
|
|
2851
|
-
function ratioPair(table: TableAnalysis, columns: readonly TableColumn[]): [TableColumn, TableColumn] | undefined {
|
|
2852
|
-
if (columns.length !== 3) return undefined;
|
|
2853
|
-
const ratio = columns.find(column => column.dim === "ratio");
|
|
2854
|
-
const rest = columns.filter(column => column !== ratio);
|
|
2855
|
-
const [a, b] = rest;
|
|
2856
|
-
if (!ratio || !a || !b || a.dim !== b.dim || a.unit !== b.unit || a.dim === "ratio") return undefined;
|
|
2857
|
-
const near = (value: number, target: number) => Math.abs(value - target) <= RATIO_SLACK * target;
|
|
2858
|
-
let matched = 0;
|
|
2859
|
-
for (const row of table.rows) {
|
|
2860
|
-
const [x, y, r] = [a.cells[row], b.cells[row], ratio.cells[row]];
|
|
2861
|
-
if (!isNumber(x) || !isNumber(y) || !isNumber(r) || x.value <= 0 || y.value <= 0) continue;
|
|
2862
|
-
if (!near(r.value, x.value / y.value) && !near(r.value, y.value / x.value)) return undefined;
|
|
2863
|
-
matched++;
|
|
2864
|
-
}
|
|
2865
|
-
return matched >= 2 ? [a, b] : undefined;
|
|
2866
|
-
}
|
|
2867
|
-
|
|
2868
2809
|
/**
|
|
2869
2810
|
* Measure columns pairing a before condition with another over the same
|
|
2870
2811
|
* metric (`Baseline Turns` → `Iter1 Turns`, `Baseline Tokens In` → `Iter1
|
|
@@ -101,8 +101,10 @@ export interface TableColumn {
|
|
|
101
101
|
/**
|
|
102
102
|
* Index of the measure column this one restates, read from the values: a
|
|
103
103
|
* proportional copy (`pass` 33/38 beside `pass%` 87%, `Samples` beside `% of
|
|
104
|
-
* Total`, `Leverage vs $200` beside the cost)
|
|
105
|
-
* (`Offset` summing `Verts`)
|
|
104
|
+
* Total`, `Leverage vs $200` beside the cost), a running total of it
|
|
105
|
+
* (`Offset` summing `Verts`), or its ratio to another column of its unit
|
|
106
|
+
* (`ratio` 0.997 for `Python (ms)` ÷ `C++ (ms)`, `Speedup` 4.1×: the
|
|
107
|
+
* numerator's index). Such a column is never a measure of its own.
|
|
106
108
|
*/
|
|
107
109
|
readonly restates?: number;
|
|
108
110
|
}
|
package/src/charts/table-data.ts
CHANGED
|
@@ -108,8 +108,10 @@ export interface TableColumn {
|
|
|
108
108
|
/**
|
|
109
109
|
* Index of the measure column this one restates, read from the values: a
|
|
110
110
|
* proportional copy (`pass` 33/38 beside `pass%` 87%, `Samples` beside `% of
|
|
111
|
-
* Total`, `Leverage vs $200` beside the cost)
|
|
112
|
-
* (`Offset` summing `Verts`)
|
|
111
|
+
* Total`, `Leverage vs $200` beside the cost), a running total of it
|
|
112
|
+
* (`Offset` summing `Verts`), or its ratio to another column of its unit
|
|
113
|
+
* (`ratio` 0.997 for `Python (ms)` ÷ `C++ (ms)`, `Speedup` 4.1×: the
|
|
114
|
+
* numerator's index). Such a column is never a measure of its own.
|
|
113
115
|
*/
|
|
114
116
|
readonly restates?: number;
|
|
115
117
|
}
|
|
@@ -906,10 +908,11 @@ function plainValue(column: TableColumn, row: number): NumberCell | undefined {
|
|
|
906
908
|
|
|
907
909
|
/**
|
|
908
910
|
* Columns restating another column's values: `y = k·x` within the written
|
|
909
|
-
* precision over three or more rows where `x` varies,
|
|
910
|
-
* (`Offset` stepping by `Verts`)
|
|
911
|
-
* stays, unless the second is a share
|
|
912
|
-
* table bolded more of its cells
|
|
911
|
+
* precision over three or more rows where `x` varies, a running total
|
|
912
|
+
* (`Offset` stepping by `Verts`), or the ratio of two others ({@link quotient}).
|
|
913
|
+
* Of a proportional pair the first column stays, unless the second is a share
|
|
914
|
+
* summing to 100% beside counts or the table bolded more of its cells
|
|
915
|
+
* (`**87%**` beside `33/38`).
|
|
913
916
|
*/
|
|
914
917
|
function restatedColumns(measures: readonly TableColumn[], rows: readonly number[]): Map<number, number> {
|
|
915
918
|
const restated = new Map<number, number>();
|
|
@@ -931,9 +934,55 @@ function restatedColumns(measures: readonly TableColumn[], rows: readonly number
|
|
|
931
934
|
const source = measures.find(other => other !== column && runningTotal(column, other, rows));
|
|
932
935
|
if (source) restated.set(column.index, source.index);
|
|
933
936
|
}
|
|
937
|
+
const kept = measures.filter(column => !restated.has(column.index));
|
|
938
|
+
for (const ratio of kept) {
|
|
939
|
+
if (restated.has(ratio.index)) continue;
|
|
940
|
+
const terms = kept.filter(column => column !== ratio && !restated.has(column.index));
|
|
941
|
+
const over = terms
|
|
942
|
+
.flatMap(a => terms.map(b => [a, b] as const))
|
|
943
|
+
.find(([a, b]) => a !== b && quotient(ratio, a, b, rows));
|
|
944
|
+
if (over) restated.set(ratio.index, over[0].index);
|
|
945
|
+
}
|
|
934
946
|
return restated;
|
|
935
947
|
}
|
|
936
948
|
|
|
949
|
+
/** Most relative rounding a row's quotient may carry to count toward proving it (`2×` beside its terms proves little). */
|
|
950
|
+
const LOOSE_QUOTIENT = 0.05;
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* `ratio = a ÷ b` in every row holding all three, `a` and `b` in one unit
|
|
954
|
+
* (`Python (ms)` ÷ `old C++ (ms)` = `0.997`; `Go` ÷ `pi-walker` = `4.1×`),
|
|
955
|
+
* within the precision each figure is written to, over three or more rows
|
|
956
|
+
* pinned to {@link LOOSE_QUOTIENT}. Percent columns are left alone: a part's
|
|
957
|
+
* share of a whole (`Share` = `Tokens` ÷ `Total`) is a measure the table states.
|
|
958
|
+
*
|
|
959
|
+
* Bare numbers all read as counts, and of three columns related so each is
|
|
960
|
+
* the others' quotient or product (`C++ = Python ÷ ratio` holds too), the
|
|
961
|
+
* ratio is the one that varies less from row to row than both its terms:
|
|
962
|
+
* workloads of different sizes move both timings, not their ratio. Where none
|
|
963
|
+
* does, none is taken for the ratio.
|
|
964
|
+
*/
|
|
965
|
+
function quotient(ratio: TableColumn, a: TableColumn, b: TableColumn, rows: readonly number[]): boolean {
|
|
966
|
+
if ((ratio.dim !== "count" && ratio.dim !== "ratio") || a.dim !== b.dim || a.unit !== b.unit) return false;
|
|
967
|
+
let tight = 0;
|
|
968
|
+
const matched: (readonly [number, number, number])[] = [];
|
|
969
|
+
for (const row of rows) {
|
|
970
|
+
const [r, x, y] = [plainValue(ratio, row), plainValue(a, row), plainValue(b, row)];
|
|
971
|
+
if (!r || !x || !y) continue;
|
|
972
|
+
if (x.value <= 0 || y.value <= 0 || r.value <= 0) return false;
|
|
973
|
+
const exact = x.value / y.value;
|
|
974
|
+
const slack = writtenSlack(r) + exact * (writtenSlack(x) / x.value + writtenSlack(y) / y.value) + 1e-9 * exact;
|
|
975
|
+
if (Math.abs(r.value - exact) > slack) return false;
|
|
976
|
+
if (slack <= LOOSE_QUOTIENT * exact) tight++;
|
|
977
|
+
matched.push([r.value, x.value, y.value]);
|
|
978
|
+
}
|
|
979
|
+
if (tight < 3) return false;
|
|
980
|
+
if (ratio.dim !== a.dim) return true;
|
|
981
|
+
const spread = (at: 0 | 1 | 2) =>
|
|
982
|
+
Math.max(...matched.map(values => values[at])) / Math.min(...matched.map(values => values[at]));
|
|
983
|
+
return spread(0) < spread(1) && spread(0) < spread(2);
|
|
984
|
+
}
|
|
985
|
+
|
|
937
986
|
/** How many of `rows` the table bolded in `column`. */
|
|
938
987
|
function emphasized(column: TableColumn, rows: readonly number[]): number {
|
|
939
988
|
return rows.filter(row => column.cells[row]?.emphasis).length;
|
|
@@ -2,6 +2,7 @@ import { type Component } from "../tui";
|
|
|
2
2
|
import { Disclosure } from "../components/disclosure";
|
|
3
3
|
import { visibleWidth } from "../utils";
|
|
4
4
|
import type { AdvisorMessageDetails, AdvisorNote, AdvisorSeverity } from "./messages";
|
|
5
|
+
import { chatTranscriptDisplayPreferences } from "./display-preferences";
|
|
5
6
|
import { formatBadge, replaceTabs, type ToolUIColor, wrapTextWithAnsi } from "../render/render-utils";
|
|
6
7
|
import { Ellipsis, truncateToWidth } from "../render";
|
|
7
8
|
import type { Theme } from "../theme";
|
|
@@ -274,6 +275,7 @@ export function createAdvisorMessageCard(
|
|
|
274
275
|
body: () => new AdvisorNotes(notes, 0, uiTheme),
|
|
275
276
|
expanded: getExpanded(),
|
|
276
277
|
paddingX: 1,
|
|
278
|
+
maxCollapsedRows: chatTranscriptDisplayPreferences.advisorCollapsedLines || undefined,
|
|
277
279
|
});
|
|
278
280
|
// The tool-output toggle owns expansion state; synchronize the controlled
|
|
279
281
|
// disclosure from the callback on every render.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AssistantMessage, ImageContent } from "@linxiraos/pi-ai";
|
|
2
2
|
import { type Component, Container } from "../tui";
|
|
3
3
|
import { type ImageBudget } from "../components/image";
|
|
4
|
-
import type { AssistantThinkingRenderer } from "./extension-types";
|
|
4
|
+
import type { AssistantTextRenderer, AssistantTextRendering, AssistantThinkingRenderer } from "./extension-types";
|
|
5
5
|
import type { DescribeContext, NativeNode, NativeUiEvent } from "../native/node";
|
|
6
6
|
import { type CacheInvalidation } from "./cache-invalidation-marker";
|
|
7
7
|
import { type ServedModelMismatch } from "./served-model-marker";
|
|
@@ -38,7 +38,7 @@ export declare class AssistantMessageComponent extends Container {
|
|
|
38
38
|
* for lack of a target is re-rendered with its reaction stripped.
|
|
39
39
|
*/
|
|
40
40
|
pickReactionTarget(transcript: readonly Component[]): void;
|
|
41
|
-
constructor(message?: AssistantMessage, hideThinkingBlock?: boolean, onImageUpdate?: () => void, thinkingRenderers?: readonly AssistantThinkingRenderer[], imageBudget?: ImageBudget, proseOnlyThinking?: boolean, linkTargets?: ReadonlyMap<string, string>, expandThinkingBlocks?: boolean);
|
|
41
|
+
constructor(message?: AssistantMessage, hideThinkingBlock?: boolean, onImageUpdate?: () => void, thinkingRenderers?: readonly AssistantThinkingRenderer[], imageBudget?: ImageBudget, proseOnlyThinking?: boolean, linkTargets?: ReadonlyMap<string, string>, expandThinkingBlocks?: boolean, textRendering?: AssistantTextRendering);
|
|
42
42
|
/**
|
|
43
43
|
* Show or clear the trailing cache-invalidation divider. Set at `message_end`
|
|
44
44
|
* (live) or during rebuild, once the turn's usage is known and compared
|
|
@@ -87,7 +87,7 @@ export declare class AssistantMessageComponent extends Container {
|
|
|
87
87
|
*/
|
|
88
88
|
setExpanded(expanded: boolean): void;
|
|
89
89
|
isTranscriptBlockFinalized(): boolean;
|
|
90
|
-
/**
|
|
90
|
+
/** Hold image and figure rendering until the completed block can enter immutable scrollback. */
|
|
91
91
|
isTranscriptBlockPending(): boolean;
|
|
92
92
|
render(width: number): readonly string[];
|
|
93
93
|
/**
|
|
@@ -122,7 +122,19 @@ export declare class AssistantMessageComponent extends Container {
|
|
|
122
122
|
renderTranscriptBlockEmergencyRow(width: number): string | undefined;
|
|
123
123
|
getTranscriptBlockVersion(): number;
|
|
124
124
|
markTranscriptBlockFinalized(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Swap the extension text renderers (the setting enabling them changed) and redraw with them.
|
|
127
|
+
* Enabling them also drops rows already published as stable, since a renderer may rewrite them;
|
|
128
|
+
* callers MUST pair this with a scrollback-clearing display reset, as for
|
|
129
|
+
* {@link resetTranscriptStableRows}.
|
|
130
|
+
*/
|
|
131
|
+
setTextRenderers(renderers: readonly AssistantTextRenderer[]): void;
|
|
125
132
|
applyRetryRecovery(retryRecovery: AssistantMessage["retryRecovery"]): void;
|
|
133
|
+
/**
|
|
134
|
+
* Draw the current message again when it is the reply sent at `timestamp`, re-running the
|
|
135
|
+
* extension text renderers; returns whether it was. The caller schedules the frame.
|
|
136
|
+
*/
|
|
137
|
+
rerenderMessage(timestamp: number): boolean;
|
|
126
138
|
messagePersistenceKey(): string | undefined;
|
|
127
139
|
/** Toggle rendering for assistant-native and tool-result images. */
|
|
128
140
|
setImagesVisible(visible: boolean): void;
|
|
@@ -5,6 +5,7 @@ import { Image, type ImageBudget } from "../components/image";
|
|
|
5
5
|
import { ImageProtocol, TERMINAL } from "../terminal-capabilities";
|
|
6
6
|
import {
|
|
7
7
|
type DefaultTextStyle,
|
|
8
|
+
endsInsideOpenFence,
|
|
8
9
|
holdPartialTableRow,
|
|
9
10
|
Markdown,
|
|
10
11
|
type MarkdownTheme,
|
|
@@ -14,10 +15,10 @@ import {
|
|
|
14
15
|
} from "../components/markdown";
|
|
15
16
|
import { Spacer } from "../components/spacer";
|
|
16
17
|
import { Text } from "../components/text";
|
|
17
|
-
import { formatDuration, formatNumber } from "@linxiraos/pi-utils";
|
|
18
|
+
import { formatDuration, formatNumber, logger } from "@linxiraos/pi-utils";
|
|
18
19
|
import chalk from "@linxiraos/pi-utils/chalk";
|
|
19
20
|
import { LRUCache } from "@linxiraos/pi-utils/lru";
|
|
20
|
-
import type { AssistantThinkingRenderer } from "./extension-types";
|
|
21
|
+
import type { AssistantTextRenderer, AssistantTextRendering, AssistantThinkingRenderer } from "./extension-types";
|
|
21
22
|
import { ensureThemeSync, getMarkdownTheme, getMarkdownThemeWithLinkTargets, getThemeEpoch, theme } from "../theme";
|
|
22
23
|
import { card, col, elapsed, node, span, text } from "../native/describe";
|
|
23
24
|
import { hasTranscriptActions, runTranscriptAction } from "./transcript-actions";
|
|
@@ -51,6 +52,8 @@ import { chartFence, hasChartTable, lookupTableChart, splitTableCharts } from ".
|
|
|
51
52
|
*/
|
|
52
53
|
const MAX_TRANSCRIPT_ERROR_ROWS = 8;
|
|
53
54
|
const EMPTY_STABLE_RENDER: readonly string[] = [];
|
|
55
|
+
/** Text renderers that threw once; each failure is logged once per renderer, not per frame. */
|
|
56
|
+
const failedTextRenderers = new WeakSet<AssistantTextRenderer>();
|
|
54
57
|
|
|
55
58
|
/** The native head of a finished thinking block: "Thought for 12s", or "Thought" when it was never seen streaming. */
|
|
56
59
|
function thoughtLabel(clock: { start: number; end?: number } | undefined): string {
|
|
@@ -245,6 +248,19 @@ function lerpHex(from: string, to: string, t: number): string {
|
|
|
245
248
|
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
|
|
246
249
|
}
|
|
247
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Drop the closing border the renderer draws for a source that ends inside an
|
|
253
|
+
* open fence. That row is not part of the message yet: the live block reaches
|
|
254
|
+
* it only when the closer arrives, so publishing it would make the settled
|
|
255
|
+
* prefix disagree with the block render and freeze mid-stream retirement.
|
|
256
|
+
*/
|
|
257
|
+
function trimFabricatedCloser(rows: readonly string[], source: string): readonly string[] {
|
|
258
|
+
if (!endsInsideOpenFence(source)) return rows;
|
|
259
|
+
let last = rows.length;
|
|
260
|
+
while (last > 0 && rows[last - 1]!.trim() === "") last--;
|
|
261
|
+
return last > 0 ? rows.slice(0, last - 1) : rows;
|
|
262
|
+
}
|
|
263
|
+
|
|
248
264
|
/**
|
|
249
265
|
* Renders an assistant message; streaming content remains mutable until the
|
|
250
266
|
* provider finalizes it because later deltas can revise earlier Markdown.
|
|
@@ -390,8 +406,10 @@ export class AssistantMessageComponent extends Container {
|
|
|
390
406
|
#reactionTarget: ReactionTarget | undefined;
|
|
391
407
|
/** Reaction lifted from the reply's opening emoji, once resolved. */
|
|
392
408
|
#reaction: string | undefined;
|
|
393
|
-
/** Display form of {@link #lastMessage} (reaction handled) the native description is built from. */
|
|
409
|
+
/** Display form of {@link #lastMessage} (reaction handled, extension text renderers applied) the native description is built from. */
|
|
394
410
|
#displayedMessage: AssistantMessage | undefined;
|
|
411
|
+
/** {@link #displayedMessage} before extension text renderers: the reply as written, which thinking state and the native Copy follow. */
|
|
412
|
+
#answerMessage: AssistantMessage | undefined;
|
|
395
413
|
/** Thinking-extension components per content index, recorded when the slow path mounts them. */
|
|
396
414
|
#thinkingExtensions = new Map<number, Component[]>();
|
|
397
415
|
/** Collapse state of thinking sections toggled in the terminal, by content index; cleared by {@link setHideThinkingBlock}. */
|
|
@@ -523,9 +541,65 @@ export class AssistantMessageComponent extends Container {
|
|
|
523
541
|
content[index] = { ...block, text };
|
|
524
542
|
return { ...message, content };
|
|
525
543
|
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Display form with the extension text renderers applied, in registration order: each gets the
|
|
547
|
+
* previous one's output. A renderer that throws or returns a non-string leaves its input drawn;
|
|
548
|
+
* a throw is logged once per renderer. A block whose text and `streaming` flag are unchanged
|
|
549
|
+
* since its last render reuses that output: a block sealed at a tool call keeps receiving
|
|
550
|
+
* updates while the call's arguments stream. {@link rerenderMessage} and
|
|
551
|
+
* {@link setTextRenderers} drop the reused output.
|
|
552
|
+
*/
|
|
553
|
+
#renderText(message: AssistantMessage, streaming: boolean): AssistantMessage {
|
|
554
|
+
const rendering = this.#textRendering;
|
|
555
|
+
if (!rendering) return message;
|
|
556
|
+
// Renderers are display-only: hand them a deep copy so no edit, however nested, reaches the stored message.
|
|
557
|
+
let view: AssistantMessage | undefined;
|
|
558
|
+
let content: AssistantMessage["content"] | undefined;
|
|
559
|
+
// Blocks stream in order: only the last one can still grow.
|
|
560
|
+
const tail = message.content.length - 1;
|
|
561
|
+
for (let index = 0; index < message.content.length; index++) {
|
|
562
|
+
const block = message.content[index]!;
|
|
563
|
+
if (block.type !== "text" || block.text.length === 0) continue;
|
|
564
|
+
const blockStreaming = streaming && index === tail;
|
|
565
|
+
const cached = this.#renderedText.get(index);
|
|
566
|
+
let text: string;
|
|
567
|
+
if (cached?.input === block.text && cached.streaming === blockStreaming) {
|
|
568
|
+
text = cached.output;
|
|
569
|
+
} else {
|
|
570
|
+
view ??= structuredClone(message);
|
|
571
|
+
text = block.text;
|
|
572
|
+
for (const renderer of rendering.renderers) {
|
|
573
|
+
try {
|
|
574
|
+
const rendered = renderer({
|
|
575
|
+
message: view,
|
|
576
|
+
contentIndex: rendering.contentOffset + index,
|
|
577
|
+
text,
|
|
578
|
+
streaming: blockStreaming,
|
|
579
|
+
});
|
|
580
|
+
if (typeof rendered === "string") text = rendered;
|
|
581
|
+
} catch (error) {
|
|
582
|
+
if (failedTextRenderers.has(renderer)) continue;
|
|
583
|
+
failedTextRenderers.add(renderer);
|
|
584
|
+
logger.warn("Assistant text renderer failed; drawing its input", { error: String(error) });
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
this.#renderedText.set(index, { input: block.text, streaming: blockStreaming, output: text });
|
|
588
|
+
}
|
|
589
|
+
if (text === block.text) continue;
|
|
590
|
+
content ??= message.content.slice();
|
|
591
|
+
content[index] = { ...block, text };
|
|
592
|
+
}
|
|
593
|
+
return content ? { ...message, content } : message;
|
|
594
|
+
}
|
|
526
595
|
#hideThinkingBlock: boolean;
|
|
527
596
|
readonly #onImageUpdate?: () => void;
|
|
528
597
|
readonly #thinkingRenderers: readonly AssistantThinkingRenderer[];
|
|
598
|
+
#textRendering: AssistantTextRendering | undefined;
|
|
599
|
+
/** Index in the full reply's `content` of this component's first block, kept across renderer swaps. */
|
|
600
|
+
readonly #textContentOffset: number;
|
|
601
|
+
/** Last renderer output per content index, reused while the block's input and `streaming` flag hold; see {@link #renderText}. */
|
|
602
|
+
readonly #renderedText = new Map<number, { input: string; streaming: boolean; output: string }>();
|
|
529
603
|
readonly #imageBudget?: ImageBudget;
|
|
530
604
|
#proseOnlyThinking: boolean;
|
|
531
605
|
#expandThinkingBlocks: boolean;
|
|
@@ -539,11 +613,14 @@ export class AssistantMessageComponent extends Container {
|
|
|
539
613
|
proseOnlyThinking = true,
|
|
540
614
|
linkTargets?: ReadonlyMap<string, string>,
|
|
541
615
|
expandThinkingBlocks = false,
|
|
616
|
+
textRendering?: AssistantTextRendering,
|
|
542
617
|
) {
|
|
543
618
|
super();
|
|
544
619
|
this.#hideThinkingBlock = hideThinkingBlock;
|
|
545
620
|
this.#onImageUpdate = onImageUpdate;
|
|
546
621
|
this.#thinkingRenderers = thinkingRenderers;
|
|
622
|
+
this.#textRendering = textRendering?.renderers.length ? textRendering : undefined;
|
|
623
|
+
this.#textContentOffset = textRendering?.contentOffset ?? 0;
|
|
547
624
|
this.#imageBudget = imageBudget;
|
|
548
625
|
this.#proseOnlyThinking = proseOnlyThinking;
|
|
549
626
|
this.#expandThinkingBlocks = expandThinkingBlocks;
|
|
@@ -792,8 +869,9 @@ export class AssistantMessageComponent extends Container {
|
|
|
792
869
|
return this.#transcriptBlockFinalized;
|
|
793
870
|
}
|
|
794
871
|
|
|
795
|
-
/**
|
|
872
|
+
/** Hold image and figure rendering until the completed block can enter immutable scrollback. */
|
|
796
873
|
isTranscriptBlockPending(): boolean {
|
|
874
|
+
if (this.#showImages && this.#kittyConversionsAwaited.size > 0) return true;
|
|
797
875
|
for (const block of this.#figureBlocks.values()) if (block.pending) return true;
|
|
798
876
|
return false;
|
|
799
877
|
}
|
|
@@ -815,7 +893,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
815
893
|
*/
|
|
816
894
|
override describe(cx?: DescribeContext): NativeNode {
|
|
817
895
|
const media = cx?.supports("media") === true;
|
|
818
|
-
const tail = this.#
|
|
896
|
+
const tail = this.#answerMessage ? this.#thinkingTailIndex(this.#answerMessage) : undefined;
|
|
819
897
|
const rate =
|
|
820
898
|
tail !== undefined && this.#lastUpdateTransient && this.#thinkingRateLive
|
|
821
899
|
? Math.round(Math.min(SPEED_MAX, sharedSpeedTracker.getSpeed()) * 10) / 10
|
|
@@ -886,13 +964,15 @@ export class AssistantMessageComponent extends Container {
|
|
|
886
964
|
let answered = false;
|
|
887
965
|
if (message) {
|
|
888
966
|
const live = !this.#transcriptBlockFinalized && this.#lastUpdateTransient;
|
|
967
|
+
// Which block streams, and whether there is an answer to copy, follow the reply as written:
|
|
968
|
+
// text renderers change only how it is drawn (one may hide all of it).
|
|
969
|
+
const answer = this.#answerMessage ?? message;
|
|
889
970
|
let tailIndex = -1;
|
|
890
|
-
for (let index = 0; index <
|
|
891
|
-
const content =
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
) {
|
|
971
|
+
for (let index = 0; index < answer.content.length; index++) {
|
|
972
|
+
const content = answer.content[index]!;
|
|
973
|
+
const answerText = content.type === "text" && canonicalizeMessage(content.text) !== "";
|
|
974
|
+
answered ||= answerText;
|
|
975
|
+
if (answerText || (content.type === "thinking" && canonicalizeMessage(content.thinking))) {
|
|
896
976
|
tailIndex = index;
|
|
897
977
|
}
|
|
898
978
|
}
|
|
@@ -900,7 +980,6 @@ export class AssistantMessageComponent extends Container {
|
|
|
900
980
|
const content = message.content[index]!;
|
|
901
981
|
const streaming = live && index === tailIndex;
|
|
902
982
|
if (content.type === "text" && canonicalizeMessage(content.text)) {
|
|
903
|
-
answered = true;
|
|
904
983
|
// A native terminal sizes table columns by every row it gets: send a growing row once
|
|
905
984
|
// its line ends. Hold before trimming, which would drop the newline ending a finished row.
|
|
906
985
|
const source = (streaming ? holdPartialTableRow(content.text) : content.text).trim();
|
|
@@ -1157,7 +1236,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
1157
1236
|
/** The answer as the transcript shows it: its text blocks' markdown, a blank line apart, without thinking or tool calls. */
|
|
1158
1237
|
#answerText(): string {
|
|
1159
1238
|
const blocks: string[] = [];
|
|
1160
|
-
for (const content of this.#
|
|
1239
|
+
for (const content of this.#answerMessage?.content ?? []) {
|
|
1161
1240
|
if (content.type === "text" && canonicalizeMessage(content.text)) blocks.push(content.text.trim());
|
|
1162
1241
|
}
|
|
1163
1242
|
return blocks.join("\n\n");
|
|
@@ -1219,7 +1298,8 @@ export class AssistantMessageComponent extends Container {
|
|
|
1219
1298
|
* every guard skips publication and nothing ever retracts it.
|
|
1220
1299
|
*/
|
|
1221
1300
|
#publishStableSnapshot(rendered: readonly string[], width: number): void {
|
|
1222
|
-
|
|
1301
|
+
// Extension text renderers may rewrite text they already drew, and published rows never retract.
|
|
1302
|
+
if (!this.#midStreamPublication || this.#textRendering) return;
|
|
1223
1303
|
const parts = this.#currentStableSnapshot();
|
|
1224
1304
|
if (!parts) return;
|
|
1225
1305
|
const last = parts.at(-1);
|
|
@@ -1364,12 +1444,12 @@ export class AssistantMessageComponent extends Container {
|
|
|
1364
1444
|
const renderer = role === "head" ? head : role === "replay" ? replay : head?.index === index ? head : replay;
|
|
1365
1445
|
if (renderer?.index === index && renderer.kind === kind) {
|
|
1366
1446
|
renderer.md.setText(trimmed);
|
|
1367
|
-
return renderer.md.render(width);
|
|
1447
|
+
return trimFabricatedCloser(renderer.md.render(width), trimmed);
|
|
1368
1448
|
}
|
|
1369
1449
|
const md = this.#createMarkdown(kind, trimmed);
|
|
1370
1450
|
if (role === "head") this.#stableHeadRenderer = { index, kind, md };
|
|
1371
1451
|
else if (role === "replay") this.#stableReplayRenderer = { index, kind, md };
|
|
1372
|
-
return md.render(width);
|
|
1452
|
+
return trimFabricatedCloser(md.render(width), trimmed);
|
|
1373
1453
|
}
|
|
1374
1454
|
|
|
1375
1455
|
/** Markdown for a text or thinking block; live children and stable-row renders share it so stable rows prefix the block render. */
|
|
@@ -1496,11 +1576,30 @@ export class AssistantMessageComponent extends Container {
|
|
|
1496
1576
|
this.#stopThinkingAnimation();
|
|
1497
1577
|
// If the live pulse was on screen when the block sealed, drop the fast path
|
|
1498
1578
|
// and rebuild so the placeholder is removed — finalized blocks never animate.
|
|
1579
|
+
// A sealed block's text is also complete and can retire to scrollback before the
|
|
1580
|
+
// reply's final update reaches it: give the text renderers their final call now
|
|
1581
|
+
// (sealed renders pass `streaming: false`).
|
|
1582
|
+
const sealRenderers = this.#textRendering !== undefined && this.#lastUpdateTransient;
|
|
1499
1583
|
if (this.#thinkingDots) {
|
|
1500
1584
|
this.#fastPathKey = undefined;
|
|
1501
1585
|
this.#fastPathItems = undefined;
|
|
1502
|
-
if (this.#lastMessage) this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
|
|
1503
1586
|
}
|
|
1587
|
+
if ((this.#thinkingDots || sealRenderers) && this.#lastMessage) {
|
|
1588
|
+
this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* Swap the extension text renderers (the setting enabling them changed) and redraw with them.
|
|
1594
|
+
* Enabling them also drops rows already published as stable, since a renderer may rewrite them;
|
|
1595
|
+
* callers MUST pair this with a scrollback-clearing display reset, as for
|
|
1596
|
+
* {@link resetTranscriptStableRows}.
|
|
1597
|
+
*/
|
|
1598
|
+
setTextRenderers(renderers: readonly AssistantTextRenderer[]): void {
|
|
1599
|
+
this.#textRendering = renderers.length ? { renderers, contentOffset: this.#textContentOffset } : undefined;
|
|
1600
|
+
this.#renderedText.clear();
|
|
1601
|
+
if (this.#textRendering) this.resetTranscriptStableRows();
|
|
1602
|
+
if (this.#lastMessage) this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
|
|
1504
1603
|
}
|
|
1505
1604
|
|
|
1506
1605
|
applyRetryRecovery(retryRecovery: AssistantMessage["retryRecovery"]): void {
|
|
@@ -1509,6 +1608,18 @@ export class AssistantMessageComponent extends Container {
|
|
|
1509
1608
|
this.updateContent({ ...this.#lastMessage, retryRecovery });
|
|
1510
1609
|
}
|
|
1511
1610
|
|
|
1611
|
+
/**
|
|
1612
|
+
* Draw the current message again when it is the reply sent at `timestamp`, re-running the
|
|
1613
|
+
* extension text renderers; returns whether it was. The caller schedules the frame.
|
|
1614
|
+
*/
|
|
1615
|
+
rerenderMessage(timestamp: number): boolean {
|
|
1616
|
+
if (this.#lastMessage?.timestamp !== timestamp) return false;
|
|
1617
|
+
// The renderers' state may have changed: run them again rather than reuse their last output.
|
|
1618
|
+
this.#renderedText.clear();
|
|
1619
|
+
this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
|
|
1620
|
+
return true;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1512
1623
|
messagePersistenceKey(): string | undefined {
|
|
1513
1624
|
if (!this.#lastMessage) return undefined;
|
|
1514
1625
|
return [
|
|
@@ -1620,6 +1731,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
1620
1731
|
})
|
|
1621
1732
|
.catch(() => {
|
|
1622
1733
|
this.#kittyConversionsAwaited.delete(key);
|
|
1734
|
+
this.#onImageUpdate?.();
|
|
1623
1735
|
});
|
|
1624
1736
|
}
|
|
1625
1737
|
}
|
|
@@ -1811,6 +1923,12 @@ export class AssistantMessageComponent extends Container {
|
|
|
1811
1923
|
// verbatim message so re-renders re-derive the reaction deterministically.
|
|
1812
1924
|
// Narration the provider returned as thinking renders as answer text.
|
|
1813
1925
|
message = this.#displayMessage(presentNarrationAsAnswer(message), this.#lastUpdateTransient);
|
|
1926
|
+
this.#answerMessage = message;
|
|
1927
|
+
// A sealed block (closed at a tool call) keeps receiving transient updates; its text is final.
|
|
1928
|
+
// Thinking state below reads `answer`: renderers transform display only, so one that hides the
|
|
1929
|
+
// streaming text must not make the closed thought before it look live again.
|
|
1930
|
+
const answer = message;
|
|
1931
|
+
message = this.#renderText(message, this.#lastUpdateTransient && !this.#transcriptBlockFinalized);
|
|
1814
1932
|
this.#displayedMessage = message;
|
|
1815
1933
|
|
|
1816
1934
|
// Streaming-speed gauge: only a live, in-flight render of the single
|
|
@@ -1828,7 +1946,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
1828
1946
|
// Native terminals show the live rate on visible thinking too, not only the hidden pulse.
|
|
1829
1947
|
const isThinkingNow =
|
|
1830
1948
|
this.#lastUpdateTransient &&
|
|
1831
|
-
(isNativeRendering() ? this.#thinkingTailIndex(
|
|
1949
|
+
(isNativeRendering() ? this.#thinkingTailIndex(answer) !== undefined : this.#shouldAnimateThinking(answer));
|
|
1832
1950
|
if (isThinkingNow) {
|
|
1833
1951
|
const currentTokens = message.usage.reasoningTokens ?? message.usage.output;
|
|
1834
1952
|
this.#thinkingTokens = currentTokens;
|
|
@@ -1931,7 +2049,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
1931
2049
|
if (this.#figureBlocks.get(index) !== block) block.dispose();
|
|
1932
2050
|
}
|
|
1933
2051
|
|
|
1934
|
-
if (this.#shouldAnimateThinking(
|
|
2052
|
+
if (this.#shouldAnimateThinking(answer)) {
|
|
1935
2053
|
if (hasVisibleContent) this.#contentContainer.addChild(new Spacer(1));
|
|
1936
2054
|
this.#thinkingDots = new Text(this.#thinkingDotsLabel(), 1, 0);
|
|
1937
2055
|
this.#contentContainer.addChild(this.#thinkingDots);
|