@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/irc.ts
CHANGED
|
@@ -27,6 +27,12 @@ export interface IrcMessage {
|
|
|
27
27
|
* the broadcaster, mostly to say the message was not for it.
|
|
28
28
|
*/
|
|
29
29
|
broadcast?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Interim acknowledgement or progress on something the recipient asked
|
|
32
|
+
* (`agent://<id>?progress`): it neither answers that request nor asks one,
|
|
33
|
+
* so the recipient's `wait` keeps waiting for the actual reply.
|
|
34
|
+
*/
|
|
35
|
+
progress?: boolean;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
/** Delivery outcome for one peer recipient. */
|
package/src/tools/job-widget.ts
CHANGED
|
@@ -190,10 +190,22 @@ function headlineGlance(view: JobWidgetView): JobWidgetGlance | undefined {
|
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
/** The meter's `140/190` when the headline only restates its numerator (`140`). */
|
|
194
|
+
function meterWhole(headline: JobWidgetGlance, view: JobWidgetView): string | undefined {
|
|
195
|
+
const meter = view.blocks.find((block): block is JobWidgetMeterBlock => block.kind === "meter");
|
|
196
|
+
const whole = meter ? plainLine(meter.text) : "";
|
|
197
|
+
return /^\s*\/\s*\S/.test(whole.slice(headline.text.trim().length)) && whole.startsWith(headline.text.trim())
|
|
198
|
+
? whole
|
|
199
|
+
: undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
193
202
|
/** What one glance at the widget reads: the headline, else the latest figure of its first spark or meter. */
|
|
194
203
|
export function jobWidgetGlance(view: JobWidgetView): JobWidgetGlance | undefined {
|
|
195
204
|
const headline = headlineGlance(view);
|
|
196
|
-
if (headline)
|
|
205
|
+
if (headline) {
|
|
206
|
+
const whole = meterWhole(headline, view);
|
|
207
|
+
return whole ? { ...headline, text: whole } : headline;
|
|
208
|
+
}
|
|
197
209
|
for (const block of view.blocks) {
|
|
198
210
|
if (block.kind === "spark" && block.values.length > 0 && plainLine(block.last)) {
|
|
199
211
|
return { text: plainLine(block.last), label: plainLine(block.label) };
|
package/src/tools/json-tree.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare const JSON_TREE_MAX_LINES_EXPANDED = 200;
|
|
|
12
12
|
export declare const JSON_TREE_SCALAR_LEN_COLLAPSED = 60;
|
|
13
13
|
/** Maximum expanded JSON scalar width. */
|
|
14
14
|
export declare const JSON_TREE_SCALAR_LEN_EXPANDED = 2000;
|
|
15
|
+
/** Characters a container's one-line form may take before a JSON tree lists its entries instead. */
|
|
16
|
+
export declare const JSON_TREE_INLINE_LEN = 60;
|
|
15
17
|
/** Sanitization, string summary, and budgeting policy for inline JSON. */
|
|
16
18
|
export interface InlineFormatOptions {
|
|
17
19
|
sanitizeText?: (text: string) => string;
|
|
@@ -46,7 +48,8 @@ export interface JsonTreeRenderOptions {
|
|
|
46
48
|
rootConnectors?: "hooked" | "siblings";
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
|
-
* Render a JSON value as bounded tree lines
|
|
51
|
+
* Render a JSON value as bounded tree lines, containers that fit
|
|
52
|
+
* {@link JSON_TREE_INLINE_LEN} on one row. The positional form remains the
|
|
50
53
|
* public tool-renderer contract; the options form exposes sanitization and root
|
|
51
54
|
* connector policy for specialized adapters such as nested task output.
|
|
52
55
|
*/
|
|
@@ -74,8 +77,24 @@ export interface JsonTreeDescribeOptions {
|
|
|
74
77
|
onTruncated?: () => void;
|
|
75
78
|
}
|
|
76
79
|
/**
|
|
77
|
-
* TSP `tree` of a JSON value: containers
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
+
* TSP `tree` of a JSON value: containers that fit {@link JSON_TREE_INLINE_LEN}
|
|
81
|
+
* become `key: [1, "a"]` leaves, larger ones expandable nodes labelled with
|
|
82
|
+
* their key and size, scalars `key: value` leaves styled by type. Bounded by
|
|
83
|
+
* depth, node count and scalar length; no width math.
|
|
80
84
|
*/
|
|
81
85
|
export declare function describeJsonTree(value: unknown, options?: JsonTreeDescribeOptions): NativeNode;
|
|
86
|
+
/** Options of {@link describeJsonValue}: the `json` node's own, plus the fallback tree's. */
|
|
87
|
+
export interface JsonValueDescribeOptions extends JsonTreeDescribeOptions {
|
|
88
|
+
/** The host draws the `json` kind (`cx.supports("json")`). */
|
|
89
|
+
native?: boolean;
|
|
90
|
+
/** `json` node: container levels expanded below the top-level entries (default 0). */
|
|
91
|
+
open?: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A JSON value for a TSP host: the terminal's own `json` viewer when it draws
|
|
95
|
+
* the kind, which folds and previews containers itself and never cuts (so
|
|
96
|
+
* `onTruncated` never fires), else {@link describeJsonTree} with the same
|
|
97
|
+
* options. Root keys the tree would hide are left out of the sent value too;
|
|
98
|
+
* strings are sanitized like the tree's labels.
|
|
99
|
+
*/
|
|
100
|
+
export declare function describeJsonValue(value: unknown, options?: JsonValueDescribeOptions): NativeNode;
|
package/src/tools/json-tree.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* JSON tree rendering utilities shared across tool renderers.
|
|
3
3
|
*/
|
|
4
4
|
import { INTENT_FIELD, type TspSpan, type TspTreeNode } from "@linxiraos/pi-wire";
|
|
5
|
-
import { sanitizeText } from "@linxiraos/pi-utils";
|
|
5
|
+
import { isRecord, sanitizeText, sanitizeTextDeep } from "@linxiraos/pi-utils";
|
|
6
6
|
import { TreeView, treeRowPrefix } from "../components/tree-view";
|
|
7
7
|
import { truncateToWidth } from "../render/render-utils";
|
|
8
8
|
import type { Theme, ThemeColor } from "../theme/theme";
|
|
@@ -22,6 +22,8 @@ export const JSON_TREE_MAX_LINES_EXPANDED = 200;
|
|
|
22
22
|
export const JSON_TREE_SCALAR_LEN_COLLAPSED = 60;
|
|
23
23
|
/** Maximum expanded JSON scalar width. */
|
|
24
24
|
export const JSON_TREE_SCALAR_LEN_EXPANDED = 2000;
|
|
25
|
+
/** Characters a container's one-line form may take before a JSON tree lists its entries instead. */
|
|
26
|
+
export const JSON_TREE_INLINE_LEN = 60;
|
|
25
27
|
|
|
26
28
|
const HIDDEN_ARG_KEYS = { [INTENT_FIELD]: 1, __partialJson: 1 };
|
|
27
29
|
const DEFAULT_HIDDEN_ROOT_KEYS: readonly string[] = Object.keys(HIDDEN_ARG_KEYS);
|
|
@@ -33,10 +35,6 @@ const ARGS_INLINE_MORE_WIDTH = Bun.stringWidth(ARGS_INLINE_MORE);
|
|
|
33
35
|
/** Minimal value footprint (quotes + a couple chars) reserved for each not-yet-rendered key. */
|
|
34
36
|
const ARGS_INLINE_TAIL_VALUE_RESERVE = 4;
|
|
35
37
|
|
|
36
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
37
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
38
|
/** Sanitization, string summary, and budgeting policy for inline JSON. */
|
|
41
39
|
export interface InlineFormatOptions {
|
|
42
40
|
sanitizeText?: (text: string) => string;
|
|
@@ -83,7 +81,7 @@ export function formatArgsInline(
|
|
|
83
81
|
const pairs: string[] = [];
|
|
84
82
|
let length = 0;
|
|
85
83
|
for (const key in args) {
|
|
86
|
-
if (!Object.hasOwn(args, key)) continue;
|
|
84
|
+
if (!Object.hasOwn(args, key) || key in HIDDEN_ARG_KEYS) continue;
|
|
87
85
|
const pair = `${options.sanitizeText?.(key) ?? key}=${formatScalar(args[key], 24, options)}`;
|
|
88
86
|
const added = pair.length + (pairs.length > 0 ? 2 : 0);
|
|
89
87
|
if (length + added > maxWidth && pairs.length > 0) {
|
|
@@ -155,6 +153,57 @@ export function formatOutputInline(data: unknown, maxWidth = 80): string {
|
|
|
155
153
|
return `Output: ${formatArgsInline(data as Record<string, unknown>, maxWidth - "Output: ".length, options) || "{}"}`;
|
|
156
154
|
}
|
|
157
155
|
|
|
156
|
+
/** Object keys a one-line JSON form shows unquoted. */
|
|
157
|
+
const BARE_KEY = /^[\w$-]+$/;
|
|
158
|
+
|
|
159
|
+
/** One styled run of a one-line JSON form. */
|
|
160
|
+
type InlineRun = readonly [text: string, color: ThemeColor];
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* A container's one-line form (`[[3, "vt"], 98]`, `{lines: 70, done: true}`)
|
|
164
|
+
* as styled runs, so tree rows show small containers whole instead of one row
|
|
165
|
+
* per value; undefined for a scalar or a form past {@link JSON_TREE_INLINE_LEN}
|
|
166
|
+
* characters. Keys stay bare unless {@link BARE_KEY} rejects them, strings are
|
|
167
|
+
* JSON-escaped, and `clean` sanitizes both first.
|
|
168
|
+
*/
|
|
169
|
+
function inlineJson(value: unknown, clean: (text: string) => string): InlineRun[] | undefined {
|
|
170
|
+
if (!Array.isArray(value) && !isRecord(value)) return undefined;
|
|
171
|
+
const runs: InlineRun[] = [];
|
|
172
|
+
let length = 0;
|
|
173
|
+
// Every container pushes a bracket before descending, so cycles hit the cap too.
|
|
174
|
+
const push = (text: string, color: ThemeColor): boolean => {
|
|
175
|
+
length += text.length;
|
|
176
|
+
if (length > JSON_TREE_INLINE_LEN) return false;
|
|
177
|
+
const last = runs.at(-1);
|
|
178
|
+
if (last?.[1] === color) runs[runs.length - 1] = [last[0] + text, color];
|
|
179
|
+
else runs.push([text, color]);
|
|
180
|
+
return true;
|
|
181
|
+
};
|
|
182
|
+
const walk = (entry: unknown): boolean => {
|
|
183
|
+
if (Array.isArray(entry)) {
|
|
184
|
+
if (!push("[", "muted")) return false;
|
|
185
|
+
for (let index = 0; index < entry.length; index++) {
|
|
186
|
+
if ((index > 0 && !push(", ", "muted")) || !walk(entry[index])) return false;
|
|
187
|
+
}
|
|
188
|
+
return push("]", "muted");
|
|
189
|
+
}
|
|
190
|
+
if (isRecord(entry)) {
|
|
191
|
+
if (!push("{", "muted")) return false;
|
|
192
|
+
let sep = "";
|
|
193
|
+
for (const key in entry) {
|
|
194
|
+
const name = clean(key);
|
|
195
|
+
if (!push(`${sep}${BARE_KEY.test(name) ? name : JSON.stringify(name)}: `, "muted")) return false;
|
|
196
|
+
if (!walk(entry[key])) return false;
|
|
197
|
+
sep = ", ";
|
|
198
|
+
}
|
|
199
|
+
return push("}", "muted");
|
|
200
|
+
}
|
|
201
|
+
if (typeof entry === "string") return push(JSON.stringify(clean(entry)), "syntaxString");
|
|
202
|
+
return push(clean(formatScalar(entry, JSON_TREE_INLINE_LEN)), jsonScalarToken(entry));
|
|
203
|
+
};
|
|
204
|
+
return walk(value) ? runs : undefined;
|
|
205
|
+
}
|
|
206
|
+
|
|
158
207
|
/** JSON hierarchy policy accepted by {@link renderJsonTreeLines}. */
|
|
159
208
|
export interface JsonTreeRenderOptions {
|
|
160
209
|
maxDepth: number;
|
|
@@ -176,7 +225,7 @@ export interface JsonTreeRenderOptions {
|
|
|
176
225
|
rootConnectors?: "hooked" | "siblings";
|
|
177
226
|
}
|
|
178
227
|
|
|
179
|
-
type JsonTreeNodeKind = "array" | "object" | "scalar" | "placeholder";
|
|
228
|
+
type JsonTreeNodeKind = "array" | "object" | "inline" | "scalar" | "placeholder";
|
|
180
229
|
|
|
181
230
|
interface JsonTreeNode {
|
|
182
231
|
id: number;
|
|
@@ -184,6 +233,10 @@ interface JsonTreeNode {
|
|
|
184
233
|
value: unknown;
|
|
185
234
|
depth: number;
|
|
186
235
|
kind: JsonTreeNodeKind;
|
|
236
|
+
/** The key's color: `dim` for array indices, else `muted`. */
|
|
237
|
+
keyColor?: ThemeColor;
|
|
238
|
+
/** The one-line form of an `inline` container. */
|
|
239
|
+
inline?: readonly InlineRun[];
|
|
187
240
|
placeholder?: "…";
|
|
188
241
|
children?: readonly JsonTreeNode[];
|
|
189
242
|
}
|
|
@@ -195,7 +248,8 @@ function jsonNodeKind(value: unknown): JsonTreeNodeKind {
|
|
|
195
248
|
}
|
|
196
249
|
|
|
197
250
|
/**
|
|
198
|
-
* Render a JSON value as bounded tree lines
|
|
251
|
+
* Render a JSON value as bounded tree lines, containers that fit
|
|
252
|
+
* {@link JSON_TREE_INLINE_LEN} on one row. The positional form remains the
|
|
199
253
|
* public tool-renderer contract; the options form exposes sanitization and root
|
|
200
254
|
* connector policy for specialized adapters such as nested task output.
|
|
201
255
|
*/
|
|
@@ -236,26 +290,18 @@ export function renderJsonTreeLines(
|
|
|
236
290
|
const hookedRoots = (options.rootConnectors ?? "hooked") === "hooked";
|
|
237
291
|
let nextId = 0;
|
|
238
292
|
|
|
239
|
-
const node = (nodeValue: unknown, key: string | undefined, depth: number): JsonTreeNode =>
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
value: nodeValue,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
293
|
+
const node = (nodeValue: unknown, key: string | undefined, depth: number, keyColor?: ThemeColor): JsonTreeNode => {
|
|
294
|
+
const inline = inlineJson(nodeValue, sanitize);
|
|
295
|
+
const kind = inline ? "inline" : jsonNodeKind(nodeValue);
|
|
296
|
+
return { id: nextId++, key, value: nodeValue, depth, kind, keyColor, inline };
|
|
297
|
+
};
|
|
298
|
+
const entryNodes = (entries: readonly JsonEntry[], depth: number): JsonTreeNode[] =>
|
|
299
|
+
entries.map(([key, child, keyColor]) => node(child, key, depth, keyColor));
|
|
246
300
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (!hiddenRootKeys.includes(key)) objectRoots.push(node(value[key], key, 1));
|
|
252
|
-
}
|
|
253
|
-
roots = objectRoots;
|
|
254
|
-
} else if (Array.isArray(value)) {
|
|
255
|
-
roots = value.map((child, index) => node(child, `[${index}]`, 1));
|
|
256
|
-
} else {
|
|
257
|
-
roots = [node(value, undefined, 0)];
|
|
258
|
-
}
|
|
301
|
+
const roots: readonly JsonTreeNode[] =
|
|
302
|
+
Array.isArray(value) || isRecord(value)
|
|
303
|
+
? entryNodes(jsonEntries(value, hiddenRootKeys), 1)
|
|
304
|
+
: [node(value, undefined, 0)];
|
|
259
305
|
|
|
260
306
|
const prefixStyle = { vertical: (symbol: string) => symbol };
|
|
261
307
|
const hook = theme.tree.hook;
|
|
@@ -288,7 +334,7 @@ export function renderJsonTreeLines(
|
|
|
288
334
|
},
|
|
289
335
|
];
|
|
290
336
|
} else {
|
|
291
|
-
children =
|
|
337
|
+
children = entryNodes(jsonEntries(values), item.depth + 1);
|
|
292
338
|
}
|
|
293
339
|
} else if (item.kind === "object" && isRecord(item.value)) {
|
|
294
340
|
const record = item.value;
|
|
@@ -307,9 +353,7 @@ export function renderJsonTreeLines(
|
|
|
307
353
|
} else if (keys.length === 0) {
|
|
308
354
|
children = [];
|
|
309
355
|
} else {
|
|
310
|
-
|
|
311
|
-
for (const key in record) objectChildren.push(node(record[key], key, item.depth + 1));
|
|
312
|
-
children = objectChildren;
|
|
356
|
+
children = entryNodes(jsonEntries(record), item.depth + 1);
|
|
313
357
|
}
|
|
314
358
|
}
|
|
315
359
|
item.children = children;
|
|
@@ -331,11 +375,13 @@ export function renderJsonTreeLines(
|
|
|
331
375
|
let body: readonly string[];
|
|
332
376
|
const displayKey = item.key ? sanitize(item.key) : undefined;
|
|
333
377
|
const label = theme.fg(
|
|
334
|
-
"muted",
|
|
378
|
+
item.keyColor ?? "muted",
|
|
335
379
|
displayKey || (item.kind === "array" ? "array" : item.kind === "object" ? "object" : "value"),
|
|
336
380
|
);
|
|
337
381
|
if (item.kind === "placeholder") {
|
|
338
382
|
body = [theme.fg("dim", item.placeholder ?? "…")];
|
|
383
|
+
} else if (item.kind === "inline") {
|
|
384
|
+
body = [`${label}: ${(item.inline ?? []).map(([text, color]) => theme.fg(color, text)).join("")}`];
|
|
339
385
|
} else if (item.kind === "array") {
|
|
340
386
|
body = [`${label} ${theme.fg("dim", `[${(item.value as unknown[]).length}]`)}`];
|
|
341
387
|
} else if (item.kind === "object") {
|
|
@@ -406,34 +452,42 @@ export interface JsonTreeDescribeOptions {
|
|
|
406
452
|
onTruncated?: () => void;
|
|
407
453
|
}
|
|
408
454
|
|
|
409
|
-
type JsonEntry = readonly [key: string, value: unknown];
|
|
455
|
+
type JsonEntry = readonly [key: string, value: unknown, keyColor: ThemeColor];
|
|
410
456
|
|
|
411
457
|
function clipScalar(value: string, maxLen: number): string {
|
|
412
458
|
return value.length > maxLen ? `${value.slice(0, maxLen)}…` : value;
|
|
413
459
|
}
|
|
414
460
|
|
|
461
|
+
/**
|
|
462
|
+
* `value`'s entries: an array's indices dim and right-aligned like line
|
|
463
|
+
* numbers, an object's keys (less `hidden`) muted.
|
|
464
|
+
*/
|
|
415
465
|
function jsonEntries(value: unknown[] | Record<string, unknown>, hidden?: readonly string[]): JsonEntry[] {
|
|
416
466
|
const out: JsonEntry[] = [];
|
|
417
467
|
if (Array.isArray(value)) {
|
|
418
|
-
|
|
468
|
+
const width = String(value.length - 1).length;
|
|
469
|
+
for (let index = 0; index < value.length; index++) {
|
|
470
|
+
out.push([String(index).padStart(width), value[index], "dim"]);
|
|
471
|
+
}
|
|
419
472
|
return out;
|
|
420
473
|
}
|
|
421
474
|
for (const key in value) {
|
|
422
|
-
if (!hidden?.includes(key)) out.push([key, value[key]]);
|
|
475
|
+
if (!hidden?.includes(key)) out.push([key, value[key], "muted"]);
|
|
423
476
|
}
|
|
424
477
|
return out;
|
|
425
478
|
}
|
|
426
479
|
|
|
427
|
-
function jsonScalarToken(value: unknown):
|
|
480
|
+
function jsonScalarToken(value: unknown): ThemeColor {
|
|
428
481
|
if (typeof value === "number" || typeof value === "bigint") return "syntaxNumber";
|
|
429
482
|
if (typeof value === "boolean" || value === null || value === undefined) return "syntaxKeyword";
|
|
430
483
|
return "dim";
|
|
431
484
|
}
|
|
432
485
|
|
|
433
486
|
/**
|
|
434
|
-
* TSP `tree` of a JSON value: containers
|
|
435
|
-
*
|
|
436
|
-
*
|
|
487
|
+
* TSP `tree` of a JSON value: containers that fit {@link JSON_TREE_INLINE_LEN}
|
|
488
|
+
* become `key: [1, "a"]` leaves, larger ones expandable nodes labelled with
|
|
489
|
+
* their key and size, scalars `key: value` leaves styled by type. Bounded by
|
|
490
|
+
* depth, node count and scalar length; no width math.
|
|
437
491
|
*/
|
|
438
492
|
export function describeJsonTree(value: unknown, options: JsonTreeDescribeOptions = {}): NativeNode {
|
|
439
493
|
const maxDepth = Math.max(0, options.maxDepth ?? JSON_TREE_MAX_DEPTH_EXPANDED);
|
|
@@ -452,26 +506,29 @@ export function describeJsonTree(value: unknown, options: JsonTreeDescribeOption
|
|
|
452
506
|
out.push(leaf([span(`… ${entries.length - index} more`, "dim")]));
|
|
453
507
|
break;
|
|
454
508
|
}
|
|
455
|
-
|
|
456
|
-
out.push(describeValue(key, child, depth));
|
|
509
|
+
out.push(describeValue(entries[index], depth));
|
|
457
510
|
}
|
|
458
511
|
return out;
|
|
459
512
|
};
|
|
460
513
|
|
|
461
|
-
const describeValue = (
|
|
514
|
+
const describeValue = (
|
|
515
|
+
[key, entry, keyColor]: readonly [key: string | undefined, value: unknown, keyColor?: ThemeColor],
|
|
516
|
+
depth: number,
|
|
517
|
+
): TspTreeNode => {
|
|
462
518
|
budget--;
|
|
463
519
|
const id = `${nextId++}`;
|
|
464
|
-
const keySpans: TspSpan[] = key === undefined ? [] : [span(plainText(key),
|
|
520
|
+
const keySpans: TspSpan[] = key === undefined ? [] : [span(plainText(key), keyColor)];
|
|
521
|
+
const prefix = keySpans.length > 0 ? [...keySpans, span(": ", "muted")] : [];
|
|
522
|
+
const inline = inlineJson(entry, plainText);
|
|
523
|
+
if (inline) return { id, label: [...prefix, ...inline.map(([text, color]) => span(text, color))] };
|
|
465
524
|
if (Array.isArray(entry) || isRecord(entry)) {
|
|
466
525
|
const entries = jsonEntries(entry);
|
|
467
526
|
const size = Array.isArray(entry) ? `[${entry.length}]` : `{${entries.length}}`;
|
|
468
527
|
const label = keySpans.length > 0 ? [...keySpans, span(` ${size}`, "dim")] : [span(size, "dim")];
|
|
469
|
-
if (entries.length === 0) return { id, label };
|
|
470
528
|
if (depth >= maxDepth) truncated = true;
|
|
471
529
|
const children = depth >= maxDepth ? [leaf([span("…", "dim")])] : describeEntries(entries, depth + 1);
|
|
472
530
|
return { id, label, open: depth < openDepth, children };
|
|
473
531
|
}
|
|
474
|
-
const prefix = keySpans.length > 0 ? [...keySpans, span(": ", "muted")] : [];
|
|
475
532
|
if (typeof entry === "string") {
|
|
476
533
|
const lines = plainText(entry).split("\n");
|
|
477
534
|
if (lines.some(line => line.length > maxScalarLen)) truncated = true;
|
|
@@ -504,8 +561,37 @@ export function describeJsonTree(value: unknown, options: JsonTreeDescribeOption
|
|
|
504
561
|
nodes =
|
|
505
562
|
entries.length > 0 ? describeEntries(entries, 1) : [leaf([span(Array.isArray(value) ? "[]" : "{}", "dim")])];
|
|
506
563
|
} else {
|
|
507
|
-
nodes = [describeValue(undefined, value, 0)];
|
|
564
|
+
nodes = [describeValue([undefined, value], 0)];
|
|
508
565
|
}
|
|
509
566
|
if (truncated) options.onTruncated?.();
|
|
510
567
|
return node("tree", { nodes });
|
|
511
568
|
}
|
|
569
|
+
|
|
570
|
+
/** Options of {@link describeJsonValue}: the `json` node's own, plus the fallback tree's. */
|
|
571
|
+
export interface JsonValueDescribeOptions extends JsonTreeDescribeOptions {
|
|
572
|
+
/** The host draws the `json` kind (`cx.supports("json")`). */
|
|
573
|
+
native?: boolean;
|
|
574
|
+
/** `json` node: container levels expanded below the top-level entries (default 0). */
|
|
575
|
+
open?: number;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* A JSON value for a TSP host: the terminal's own `json` viewer when it draws
|
|
580
|
+
* the kind, which folds and previews containers itself and never cuts (so
|
|
581
|
+
* `onTruncated` never fires), else {@link describeJsonTree} with the same
|
|
582
|
+
* options. Root keys the tree would hide are left out of the sent value too;
|
|
583
|
+
* strings are sanitized like the tree's labels.
|
|
584
|
+
*/
|
|
585
|
+
export function describeJsonValue(value: unknown, options: JsonValueDescribeOptions = {}): NativeNode {
|
|
586
|
+
if (!options.native) return describeJsonTree(value, options);
|
|
587
|
+
let shown = value;
|
|
588
|
+
if (isRecord(value)) {
|
|
589
|
+
const hidden = options.hiddenRootKeys ?? DEFAULT_HIDDEN_ROOT_KEYS;
|
|
590
|
+
if (hidden.some(key => Object.hasOwn(value, key))) {
|
|
591
|
+
const kept: Record<string, unknown> = {};
|
|
592
|
+
for (const key in value) if (!hidden.includes(key)) kept[key] = value[key];
|
|
593
|
+
shown = kept;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return node("json", { value: sanitizeTextDeep(shown), open: options.open || undefined });
|
|
597
|
+
}
|
package/src/tools/lsp.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface FileDiagnosticsResult {
|
|
|
31
31
|
summary: string;
|
|
32
32
|
/** Whether there are any errors (severity 1) */
|
|
33
33
|
errored: boolean;
|
|
34
|
+
/** Servers that sent no fresh report in time: the file is unverified for them, not clean. */
|
|
35
|
+
unreported?: string[];
|
|
34
36
|
/** Whether the file was formatted */
|
|
35
37
|
formatter?: FileFormatResult;
|
|
36
38
|
}
|