@linxiraos/pi-tui 1.4.4 → 1.4.7
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 +208 -207
- package/README.md +34 -34
- 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/chat/assistant-message.d.ts +15 -3
- package/dist/types/chat/bash-execution.d.ts +2 -0
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +31 -0
- package/dist/types/chat/reply-write.d.ts +48 -0
- package/dist/types/chat/table-chart.d.ts +4 -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 +2 -0
- package/dist/types/chrome/context-map.d.ts +15 -0
- package/dist/types/chrome/context-presentation.d.ts +48 -0
- package/dist/types/chrome/context-view-model.d.ts +77 -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 +20 -8
- package/dist/types/components/editor.d.ts +8 -0
- package/dist/types/components/image.d.ts +20 -0
- package/dist/types/components/loader.d.ts +1 -1
- package/dist/types/components/markdown.d.ts +7 -0
- package/dist/types/native/blobs.d.ts +11 -1
- package/dist/types/native/picker.d.ts +4 -4
- package/dist/types/overlays/advisor-config.d.ts +6 -0
- package/dist/types/overlays/agent-hub-projection.d.ts +3 -1
- package/dist/types/overlays/annotation-overlay.d.ts +7 -1
- package/dist/types/overlays/annotation-types.d.ts +28 -0
- package/dist/types/overlays/ask-dialog.d.ts +12 -3
- package/dist/types/overlays/btw-history-panel.d.ts +16 -2
- package/dist/types/overlays/btw-history.d.ts +7 -0
- package/dist/types/overlays/btw-panel.d.ts +2 -0
- package/dist/types/overlays/context-viewer-format.d.ts +42 -0
- package/dist/types/overlays/context-viewer-overview.d.ts +70 -0
- package/dist/types/overlays/context-viewer.d.ts +25 -0
- package/dist/types/overlays/hook-input.d.ts +1 -0
- package/dist/types/overlays/login-dialog.d.ts +5 -1
- package/dist/types/overlays/mcp-add-wizard.d.ts +2 -0
- package/dist/types/overlays/model-browser.d.ts +10 -1
- package/dist/types/overlays/oauth-selector.d.ts +23 -0
- package/dist/types/overlays/pause-screen.d.ts +13 -3
- 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/running-subagent-badge.d.ts +7 -1
- package/dist/types/overlays/session-selector.d.ts +22 -2
- package/dist/types/prompt/composer.d.ts +43 -0
- package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
- package/dist/types/prompt/macos-spelling.d.ts +2 -2
- package/dist/types/render/extension-links.d.ts +65 -0
- package/dist/types/render/hyperlink.d.ts +38 -7
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/output-pane.d.ts +1 -1
- package/dist/types/render/render-utils.d.ts +7 -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 +3 -3
- package/dist/types/status-line/context-usage.d.ts +42 -35
- package/dist/types/status-line/host.d.ts +6 -2
- package/dist/types/terminal-capabilities.d.ts +7 -0
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme.d.ts +0 -23
- package/dist/types/tools/ask.d.ts +4 -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/edit.d.ts +3 -1
- package/dist/types/tools/fetch.d.ts +1 -0
- package/dist/types/tools/github.d.ts +3 -0
- package/dist/types/tools/grouped-file-output.d.ts +2 -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 +7 -6
- package/dist/types/tools/native-view.d.ts +1 -1
- package/dist/types/tools/read.d.ts +3 -0
- 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 +9 -1
- package/dist/types/tools/url-scheme-host.d.ts +17 -0
- package/dist/types/tools/wait.d.ts +16 -2
- package/dist/types/tools/yield.d.ts +1 -1
- package/dist/types/tui.d.ts +9 -2
- package/dist/types/vim.d.ts +39 -0
- package/package.json +10 -14
- package/src/app-keybindings.d.ts +20 -0
- package/src/app-keybindings.ts +20 -0
- package/src/apps/session-picker.ts +7 -0
- package/src/charts/chart-plan.d.ts +9 -7
- package/src/charts/chart-plan.ts +20 -50
- 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 +2 -0
- package/src/chat/bash-execution.ts +13 -1
- package/src/chat/chat-transcript-builder.ts +58 -28
- 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/extension-types.d.ts +31 -0
- package/src/chat/extension-types.ts +34 -0
- package/src/chat/read-tool-group.ts +1 -2
- package/src/chat/reply-write.d.ts +48 -0
- package/src/chat/reply-write.ts +127 -0
- package/src/chat/skill-message.ts +2 -6
- package/src/chat/table-chart.d.ts +4 -3
- package/src/chat/table-chart.ts +10 -4
- 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 +2 -0
- package/src/chat/transcript-render-helpers.ts +66 -24
- package/src/chrome/context-map.ts +62 -0
- package/src/chrome/context-presentation.ts +26 -0
- package/src/chrome/context-view-model.ts +73 -0
- package/src/chrome/index.ts +1 -0
- package/src/chrome/transcript-container.ts +89 -59
- package/src/chrome/transcript-notice.d.ts +35 -0
- package/src/chrome/transcript-notice.ts +83 -0
- package/src/chrome/transcript-status.d.ts +20 -8
- package/src/chrome/transcript-status.ts +29 -29
- package/src/components/editor.d.ts +8 -0
- package/src/components/editor.ts +465 -14
- package/src/components/image.d.ts +20 -0
- package/src/components/image.ts +83 -18
- package/src/components/loader.d.ts +1 -1
- package/src/components/loader.ts +1 -1
- package/src/components/markdown.d.ts +7 -0
- package/src/components/markdown.ts +225 -13
- package/src/hotkeys-markdown.ts +2 -0
- package/src/native/backend.ts +5 -66
- package/src/native/blobs.d.ts +11 -1
- package/src/native/blobs.ts +5 -3
- package/src/native/picker.d.ts +4 -4
- package/src/native/picker.ts +4 -4
- package/src/overlays/advisor-config.ts +10 -12
- package/src/overlays/agent-hub-projection.d.ts +3 -1
- package/src/overlays/agent-hub-projection.ts +6 -5
- package/src/overlays/agent-hub.ts +51 -42
- package/src/overlays/annotation-overlay.ts +125 -37
- package/src/overlays/annotation-types.ts +24 -0
- package/src/overlays/ask-dialog.ts +125 -35
- package/src/overlays/btw-history-panel.ts +124 -12
- package/src/overlays/btw-history.ts +11 -0
- package/src/overlays/btw-panel.ts +8 -4
- package/src/overlays/context-viewer-format.ts +145 -0
- package/src/overlays/context-viewer-overview.ts +381 -0
- package/src/overlays/context-viewer.ts +728 -0
- package/src/overlays/hook-input.ts +2 -0
- package/src/overlays/hook-selector.ts +2 -2
- package/src/overlays/login-dialog.ts +31 -5
- package/src/overlays/mcp-add-wizard.ts +6 -1
- package/src/overlays/model-browser.ts +37 -0
- 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/pause-screen.ts +166 -33
- package/src/overlays/plan-review-overlay.ts +13 -2
- package/src/overlays/rewind-selector.ts +29 -12
- package/src/overlays/running-subagent-badge.ts +12 -1
- package/src/overlays/session-selector.ts +313 -42
- package/src/overlays/settings-defs.ts +1 -0
- package/src/overlays/usage-dashboard.ts +20 -14
- package/src/prompt/composer.ts +216 -1
- 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/prompt/macos-spelling.ts +24 -15
- package/src/render/extension-links.d.ts +65 -0
- package/src/render/extension-links.ts +214 -0
- package/src/render/hyperlink.d.ts +38 -7
- package/src/render/hyperlink.ts +102 -23
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/output-pane.d.ts +1 -1
- package/src/render/output-pane.ts +60 -17
- package/src/render/render-utils.d.ts +7 -1
- package/src/render/render-utils.ts +11 -2
- package/src/setup/scenes/composer.ts +2 -0
- package/src/setup/scenes/glyph.ts +3 -1
- package/src/setup/scenes/model.ts +192 -29
- package/src/setup/scenes/outro.ts +33 -15
- package/src/setup/scenes/sign-in.ts +194 -392
- 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 +10 -14
- package/src/status-line/context-usage.ts +122 -597
- package/src/status-line/host.ts +6 -2
- package/src/terminal-capabilities.d.ts +7 -0
- package/src/terminal-capabilities.ts +10 -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 +1 -1
- package/src/theme/symbols.ts +16 -0
- package/src/theme/theme.d.ts +0 -23
- package/src/theme/theme.ts +2 -75
- package/src/tools/ask.d.ts +4 -0
- package/src/tools/ask.ts +4 -0
- package/src/tools/ast-grep.ts +3 -2
- 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 +7 -23
- package/src/tools/default-renderer.d.ts +6 -4
- package/src/tools/default-renderer.ts +9 -6
- package/src/tools/edit.d.ts +3 -1
- package/src/tools/edit.ts +8 -4
- package/src/tools/eval.ts +14 -4
- package/src/tools/fetch.d.ts +1 -0
- package/src/tools/fetch.ts +1 -0
- package/src/tools/find.ts +3 -10
- package/src/tools/github.d.ts +3 -0
- package/src/tools/github.ts +23 -3
- package/src/tools/glob.ts +4 -3
- package/src/tools/grep.ts +3 -4
- package/src/tools/grouped-file-output.d.ts +2 -0
- package/src/tools/grouped-file-output.ts +8 -2
- 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 -42
- package/src/tools/lsp.d.ts +2 -0
- package/src/tools/lsp.ts +36 -15
- package/src/tools/mcp.d.ts +7 -6
- package/src/tools/mcp.ts +41 -15
- package/src/tools/native-view.d.ts +1 -1
- package/src/tools/native-view.ts +3 -3
- package/src/tools/read.d.ts +3 -0
- package/src/tools/read.ts +3 -1
- 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 +9 -1
- package/src/tools/task.ts +59 -16
- package/src/tools/url-scheme-host.d.ts +17 -0
- package/src/tools/url-scheme-host.ts +21 -0
- package/src/tools/vibe.ts +14 -3
- package/src/tools/wait.d.ts +16 -2
- package/src/tools/wait.ts +16 -2
- package/src/tools/yield.d.ts +1 -1
- package/src/tools/yield.ts +18 -9
- package/src/tui.d.ts +9 -2
- package/src/tui.ts +102 -34
- package/src/vim.d.ts +39 -0
- package/src/vim.ts +313 -22
- 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/github.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
type ToolUIColor,
|
|
22
22
|
type ToolUIStatus,
|
|
23
23
|
TRUNCATE_LENGTHS,
|
|
24
|
+
sanitizeDisplayWarning,
|
|
24
25
|
truncateToWidth as truncateVisualWidth,
|
|
25
26
|
} from "../render/render-utils";
|
|
26
27
|
|
|
@@ -236,6 +237,11 @@ function renderRunBlock(run: GhRunWatchRunDetails, width: number, theme: Theme):
|
|
|
236
237
|
return lines;
|
|
237
238
|
}
|
|
238
239
|
|
|
240
|
+
function formatUnavailableLog(entry: GhRunWatchFailedLogDetails): string {
|
|
241
|
+
const reason = entry.unavailableReason ? sanitizeDisplayWarning(entry.unavailableReason) : "";
|
|
242
|
+
return `log tail unavailable${reason ? `: ${reason}` : ""}`;
|
|
243
|
+
}
|
|
244
|
+
|
|
239
245
|
function renderFailedLogs(
|
|
240
246
|
failedLogs: GhRunWatchFailedLogDetails[],
|
|
241
247
|
width: number,
|
|
@@ -254,7 +260,7 @@ function renderFailedLogs(
|
|
|
254
260
|
);
|
|
255
261
|
|
|
256
262
|
if (!entry.available || !entry.tail) {
|
|
257
|
-
lines.push(theme.fg("dim",
|
|
263
|
+
lines.push(theme.fg("dim", truncateVisualWidth(` ${formatUnavailableLog(entry)}`, Math.max(8, width))));
|
|
258
264
|
continue;
|
|
259
265
|
}
|
|
260
266
|
|
|
@@ -463,7 +469,9 @@ function describeWatch(watch: GhRunWatchViewDetails, isError: boolean): NativeTo
|
|
|
463
469
|
const failed = (watch.failedLogs ?? []).flatMap((entry): NativeChild[] => {
|
|
464
470
|
const context = entry.workflowName ? `${entry.workflowName} #${entry.runId}` : `run #${entry.runId}`;
|
|
465
471
|
const title = text([span(plainText(entry.jobName), "error"), span(` ${plainText(context)}`, "muted")]);
|
|
466
|
-
if (!entry.available || !entry.tail)
|
|
472
|
+
if (!entry.available || !entry.tail) {
|
|
473
|
+
return [title, noteText(formatUnavailableLog(entry))];
|
|
474
|
+
}
|
|
467
475
|
return [title, ansi(entry.tail, { follow: true, preview: { lines: PREVIEW_LIMITS.OUTPUT_COLLAPSED } })];
|
|
468
476
|
});
|
|
469
477
|
return {
|
|
@@ -659,6 +667,7 @@ export interface GhRunWatchFailedLogDetails {
|
|
|
659
667
|
conclusion?: string;
|
|
660
668
|
tail?: string;
|
|
661
669
|
available: boolean;
|
|
670
|
+
unavailableReason?: string;
|
|
662
671
|
}
|
|
663
672
|
|
|
664
673
|
/** Live workflow watcher display snapshot. */
|
|
@@ -708,6 +717,8 @@ export interface GhFailedJobLog {
|
|
|
708
717
|
full?: string;
|
|
709
718
|
tail?: string;
|
|
710
719
|
available: boolean;
|
|
720
|
+
unavailableReason?: string;
|
|
721
|
+
truncated?: boolean;
|
|
711
722
|
}
|
|
712
723
|
|
|
713
724
|
/** Choose the terminal conclusion or current job state. */
|
|
@@ -764,12 +775,21 @@ export function renderFailedJobLogs(
|
|
|
764
775
|
lines.push("");
|
|
765
776
|
const logText = options.mode === "full" ? entry.full : entry.tail;
|
|
766
777
|
if (entry.available && logText) {
|
|
767
|
-
lines.push(
|
|
778
|
+
lines.push(
|
|
779
|
+
options.mode === "full"
|
|
780
|
+
? entry.truncated
|
|
781
|
+
? "Partial log (capture truncated):"
|
|
782
|
+
: "Full log:"
|
|
783
|
+
: entry.truncated
|
|
784
|
+
? `Last ${options.tail} captured log lines (log capture truncated):`
|
|
785
|
+
: `Last ${options.tail} log lines:`,
|
|
786
|
+
);
|
|
768
787
|
lines.push("```text");
|
|
769
788
|
lines.push(logText);
|
|
770
789
|
lines.push("```");
|
|
771
790
|
} else {
|
|
772
791
|
lines.push(options.mode === "full" ? "Full log unavailable." : "Log tail unavailable.");
|
|
792
|
+
if (entry.unavailableReason) pushLine(lines, "Reason", entry.unavailableReason);
|
|
773
793
|
}
|
|
774
794
|
lines.push("");
|
|
775
795
|
}
|
package/src/tools/glob.ts
CHANGED
|
@@ -15,9 +15,10 @@ import type { OutputMeta } from "./output-meta";
|
|
|
15
15
|
import type { TruncationResult } from "./streaming-output";
|
|
16
16
|
import { toPathList } from "../render/render-utils";
|
|
17
17
|
import * as path from "node:path";
|
|
18
|
-
import {
|
|
18
|
+
import { fileHyperlink, renderFileList, renderStatusLine, renderTreeList } from "../render";
|
|
19
19
|
import {
|
|
20
20
|
createCachedComponent,
|
|
21
|
+
fitHeaderedRows,
|
|
21
22
|
formatCount,
|
|
22
23
|
formatEmptyMessage,
|
|
23
24
|
formatErrorMessage,
|
|
@@ -205,7 +206,7 @@ export const globToolRenderer = {
|
|
|
205
206
|
},
|
|
206
207
|
uiTheme,
|
|
207
208
|
);
|
|
208
|
-
return
|
|
209
|
+
return fitHeaderedRows(header, listLines, width);
|
|
209
210
|
},
|
|
210
211
|
);
|
|
211
212
|
}
|
|
@@ -295,7 +296,7 @@ export const globToolRenderer = {
|
|
|
295
296
|
},
|
|
296
297
|
uiTheme,
|
|
297
298
|
);
|
|
298
|
-
return
|
|
299
|
+
return fitHeaderedRows(header, [...fileLines, ...extraLines], width);
|
|
299
300
|
},
|
|
300
301
|
);
|
|
301
302
|
},
|
package/src/tools/grep.ts
CHANGED
|
@@ -16,19 +16,18 @@ import { type Theme } from "../theme/theme";
|
|
|
16
16
|
import type { OutputMeta } from "./output-meta";
|
|
17
17
|
import type { TruncationResult } from "./streaming-output";
|
|
18
18
|
import {
|
|
19
|
-
Ellipsis,
|
|
20
19
|
fileHyperlink,
|
|
21
20
|
getTreeBranch,
|
|
22
21
|
getTreeContinuePrefix,
|
|
23
22
|
renderStatusLine,
|
|
24
23
|
renderTreeList,
|
|
25
|
-
truncateToWidth,
|
|
26
24
|
uriHyperlink,
|
|
27
25
|
} from "../render";
|
|
28
26
|
import { tuiText, tuiTextFmt } from "../i18n";
|
|
29
27
|
import {
|
|
30
28
|
toPathList,
|
|
31
29
|
createCachedComponent,
|
|
30
|
+
fitHeaderedRows,
|
|
32
31
|
formatCount,
|
|
33
32
|
formatEmptyMessage,
|
|
34
33
|
formatErrorMessage,
|
|
@@ -420,7 +419,7 @@ export const grepToolRenderer = {
|
|
|
420
419
|
},
|
|
421
420
|
uiTheme,
|
|
422
421
|
);
|
|
423
|
-
return
|
|
422
|
+
return fitHeaderedRows(header, listLines, width);
|
|
424
423
|
},
|
|
425
424
|
);
|
|
426
425
|
}
|
|
@@ -511,7 +510,7 @@ export const grepToolRenderer = {
|
|
|
511
510
|
uiTheme,
|
|
512
511
|
!options.expanded,
|
|
513
512
|
);
|
|
514
|
-
return
|
|
513
|
+
return fitHeaderedRows(header, [...matchLines, ...extraLines], width);
|
|
515
514
|
},
|
|
516
515
|
);
|
|
517
516
|
},
|
|
@@ -18,6 +18,8 @@ export interface GroupedFileSection {
|
|
|
18
18
|
export interface GroupedFilesOutput {
|
|
19
19
|
model: string[];
|
|
20
20
|
display: string[];
|
|
21
|
+
/** Per file, the `model` index just past its last line: a head cut keeping `n` lines shows it whole when this is <= n. */
|
|
22
|
+
modelEnds: Map<string, number>;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Render a list of files as a multi-level, prefix-folded directory tree shared by
|
|
@@ -31,6 +31,8 @@ export interface GroupedFileSection {
|
|
|
31
31
|
export interface GroupedFilesOutput {
|
|
32
32
|
model: string[];
|
|
33
33
|
display: string[];
|
|
34
|
+
/** Per file, the `model` index just past its last line: a head cut keeping `n` lines shows it whole when this is <= n. */
|
|
35
|
+
modelEnds: Map<string, number>;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/**
|
|
@@ -66,6 +68,7 @@ export function formatGroupedFiles(
|
|
|
66
68
|
const tree = buildPathTree(inputs);
|
|
67
69
|
const model: string[] = [];
|
|
68
70
|
const display: string[] = [];
|
|
71
|
+
const modelEnds = new Map<string, number>();
|
|
69
72
|
let emitted = false;
|
|
70
73
|
|
|
71
74
|
for (const event of walkPathTree(tree)) {
|
|
@@ -86,9 +89,10 @@ export function formatGroupedFiles(
|
|
|
86
89
|
const header = `${hashes} ${event.name}${section.headerSuffix ?? ""}`;
|
|
87
90
|
model.push(header, ...section.modelLines);
|
|
88
91
|
display.push(header, ...(section.displayLines ?? section.modelLines));
|
|
92
|
+
modelEnds.set(event.key, model.length);
|
|
89
93
|
}
|
|
90
94
|
|
|
91
|
-
return { model, display };
|
|
95
|
+
return { model, display, modelEnds };
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
/** One file's rendered search matches, plus its hashline tag when editable. */
|
|
@@ -122,6 +126,7 @@ export function formatFileMatches(
|
|
|
122
126
|
}
|
|
123
127
|
const model: string[] = [];
|
|
124
128
|
const display: string[] = [];
|
|
129
|
+
const modelEnds = new Map<string, number>();
|
|
125
130
|
for (const filePath of files) {
|
|
126
131
|
const rendered = renderFile(filePath);
|
|
127
132
|
if (rendered.model.length === 0) continue;
|
|
@@ -132,8 +137,9 @@ export function formatFileMatches(
|
|
|
132
137
|
if (rendered.tag) model.push(formatHashlineHeader(filePath, rendered.tag));
|
|
133
138
|
model.push(...rendered.model);
|
|
134
139
|
display.push(...rendered.display);
|
|
140
|
+
modelEnds.set(filePath, model.length);
|
|
135
141
|
}
|
|
136
|
-
return { model, display };
|
|
142
|
+
return { model, display, modelEnds };
|
|
137
143
|
}
|
|
138
144
|
|
|
139
145
|
// =============================================================================
|
package/src/tools/irc.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ export interface IrcMessage {
|
|
|
25
25
|
* the broadcaster, mostly to say the message was not for it.
|
|
26
26
|
*/
|
|
27
27
|
broadcast?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Interim acknowledgement or progress on something the recipient asked
|
|
30
|
+
* (`agent://<id>?progress`): it neither answers that request nor asks one,
|
|
31
|
+
* so the recipient's `wait` keeps waiting for the actual reply.
|
|
32
|
+
*/
|
|
33
|
+
progress?: boolean;
|
|
28
34
|
}
|
|
29
35
|
/** Delivery outcome for one peer recipient. */
|
|
30
36
|
export interface IrcDeliveryReceipt {
|
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 { 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);
|
|
@@ -83,7 +85,7 @@ export function formatArgsInline(
|
|
|
83
85
|
const pairs: string[] = [];
|
|
84
86
|
let length = 0;
|
|
85
87
|
for (const key in args) {
|
|
86
|
-
if (!Object.hasOwn(args, key)) continue;
|
|
88
|
+
if (!Object.hasOwn(args, key) || key in HIDDEN_ARG_KEYS) continue;
|
|
87
89
|
const pair = `${options.sanitizeText?.(key) ?? key}=${formatScalar(args[key], 24, options)}`;
|
|
88
90
|
const added = pair.length + (pairs.length > 0 ? 2 : 0);
|
|
89
91
|
if (length + added > maxWidth && pairs.length > 0) {
|
|
@@ -155,6 +157,57 @@ export function formatOutputInline(data: unknown, maxWidth = 80): string {
|
|
|
155
157
|
return `Output: ${formatArgsInline(data as Record<string, unknown>, maxWidth - "Output: ".length, options) || "{}"}`;
|
|
156
158
|
}
|
|
157
159
|
|
|
160
|
+
/** Object keys a one-line JSON form shows unquoted. */
|
|
161
|
+
const BARE_KEY = /^[\w$-]+$/;
|
|
162
|
+
|
|
163
|
+
/** One styled run of a one-line JSON form. */
|
|
164
|
+
type InlineRun = readonly [text: string, color: ThemeColor];
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A container's one-line form (`[[3, "vt"], 98]`, `{lines: 70, done: true}`)
|
|
168
|
+
* as styled runs, so tree rows show small containers whole instead of one row
|
|
169
|
+
* per value; undefined for a scalar or a form past {@link JSON_TREE_INLINE_LEN}
|
|
170
|
+
* characters. Keys stay bare unless {@link BARE_KEY} rejects them, strings are
|
|
171
|
+
* JSON-escaped, and `clean` sanitizes both first.
|
|
172
|
+
*/
|
|
173
|
+
function inlineJson(value: unknown, clean: (text: string) => string): InlineRun[] | undefined {
|
|
174
|
+
if (!Array.isArray(value) && !isRecord(value)) return undefined;
|
|
175
|
+
const runs: InlineRun[] = [];
|
|
176
|
+
let length = 0;
|
|
177
|
+
// Every container pushes a bracket before descending, so cycles hit the cap too.
|
|
178
|
+
const push = (text: string, color: ThemeColor): boolean => {
|
|
179
|
+
length += text.length;
|
|
180
|
+
if (length > JSON_TREE_INLINE_LEN) return false;
|
|
181
|
+
const last = runs.at(-1);
|
|
182
|
+
if (last?.[1] === color) runs[runs.length - 1] = [last[0] + text, color];
|
|
183
|
+
else runs.push([text, color]);
|
|
184
|
+
return true;
|
|
185
|
+
};
|
|
186
|
+
const walk = (entry: unknown): boolean => {
|
|
187
|
+
if (Array.isArray(entry)) {
|
|
188
|
+
if (!push("[", "muted")) return false;
|
|
189
|
+
for (let index = 0; index < entry.length; index++) {
|
|
190
|
+
if ((index > 0 && !push(", ", "muted")) || !walk(entry[index])) return false;
|
|
191
|
+
}
|
|
192
|
+
return push("]", "muted");
|
|
193
|
+
}
|
|
194
|
+
if (isRecord(entry)) {
|
|
195
|
+
if (!push("{", "muted")) return false;
|
|
196
|
+
let sep = "";
|
|
197
|
+
for (const key in entry) {
|
|
198
|
+
const name = clean(key);
|
|
199
|
+
if (!push(`${sep}${BARE_KEY.test(name) ? name : JSON.stringify(name)}: `, "muted")) return false;
|
|
200
|
+
if (!walk(entry[key])) return false;
|
|
201
|
+
sep = ", ";
|
|
202
|
+
}
|
|
203
|
+
return push("}", "muted");
|
|
204
|
+
}
|
|
205
|
+
if (typeof entry === "string") return push(JSON.stringify(clean(entry)), "syntaxString");
|
|
206
|
+
return push(clean(formatScalar(entry, JSON_TREE_INLINE_LEN)), jsonScalarToken(entry));
|
|
207
|
+
};
|
|
208
|
+
return walk(value) ? runs : undefined;
|
|
209
|
+
}
|
|
210
|
+
|
|
158
211
|
/** JSON hierarchy policy accepted by {@link renderJsonTreeLines}. */
|
|
159
212
|
export interface JsonTreeRenderOptions {
|
|
160
213
|
maxDepth: number;
|
|
@@ -176,7 +229,7 @@ export interface JsonTreeRenderOptions {
|
|
|
176
229
|
rootConnectors?: "hooked" | "siblings";
|
|
177
230
|
}
|
|
178
231
|
|
|
179
|
-
type JsonTreeNodeKind = "array" | "object" | "scalar" | "placeholder";
|
|
232
|
+
type JsonTreeNodeKind = "array" | "object" | "inline" | "scalar" | "placeholder";
|
|
180
233
|
|
|
181
234
|
interface JsonTreeNode {
|
|
182
235
|
id: number;
|
|
@@ -184,6 +237,10 @@ interface JsonTreeNode {
|
|
|
184
237
|
value: unknown;
|
|
185
238
|
depth: number;
|
|
186
239
|
kind: JsonTreeNodeKind;
|
|
240
|
+
/** The key's color: `dim` for array indices, else `muted`. */
|
|
241
|
+
keyColor?: ThemeColor;
|
|
242
|
+
/** The one-line form of an `inline` container. */
|
|
243
|
+
inline?: readonly InlineRun[];
|
|
187
244
|
placeholder?: "…";
|
|
188
245
|
children?: readonly JsonTreeNode[];
|
|
189
246
|
}
|
|
@@ -195,7 +252,8 @@ function jsonNodeKind(value: unknown): JsonTreeNodeKind {
|
|
|
195
252
|
}
|
|
196
253
|
|
|
197
254
|
/**
|
|
198
|
-
* Render a JSON value as bounded tree lines
|
|
255
|
+
* Render a JSON value as bounded tree lines, containers that fit
|
|
256
|
+
* {@link JSON_TREE_INLINE_LEN} on one row. The positional form remains the
|
|
199
257
|
* public tool-renderer contract; the options form exposes sanitization and root
|
|
200
258
|
* connector policy for specialized adapters such as nested task output.
|
|
201
259
|
*/
|
|
@@ -236,26 +294,18 @@ export function renderJsonTreeLines(
|
|
|
236
294
|
const hookedRoots = (options.rootConnectors ?? "hooked") === "hooked";
|
|
237
295
|
let nextId = 0;
|
|
238
296
|
|
|
239
|
-
const node = (nodeValue: unknown, key: string | undefined, depth: number): JsonTreeNode =>
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
value: nodeValue,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
297
|
+
const node = (nodeValue: unknown, key: string | undefined, depth: number, keyColor?: ThemeColor): JsonTreeNode => {
|
|
298
|
+
const inline = inlineJson(nodeValue, sanitize);
|
|
299
|
+
const kind = inline ? "inline" : jsonNodeKind(nodeValue);
|
|
300
|
+
return { id: nextId++, key, value: nodeValue, depth, kind, keyColor, inline };
|
|
301
|
+
};
|
|
302
|
+
const entryNodes = (entries: readonly JsonEntry[], depth: number): JsonTreeNode[] =>
|
|
303
|
+
entries.map(([key, child, keyColor]) => node(child, key, depth, keyColor));
|
|
246
304
|
|
|
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
|
-
}
|
|
305
|
+
const roots: readonly JsonTreeNode[] =
|
|
306
|
+
Array.isArray(value) || isRecord(value)
|
|
307
|
+
? entryNodes(jsonEntries(value, hiddenRootKeys), 1)
|
|
308
|
+
: [node(value, undefined, 0)];
|
|
259
309
|
|
|
260
310
|
const prefixStyle = { vertical: (symbol: string) => symbol };
|
|
261
311
|
const hook = theme.tree.hook;
|
|
@@ -288,7 +338,7 @@ export function renderJsonTreeLines(
|
|
|
288
338
|
},
|
|
289
339
|
];
|
|
290
340
|
} else {
|
|
291
|
-
children =
|
|
341
|
+
children = entryNodes(jsonEntries(values), item.depth + 1);
|
|
292
342
|
}
|
|
293
343
|
} else if (item.kind === "object" && isRecord(item.value)) {
|
|
294
344
|
const record = item.value;
|
|
@@ -307,9 +357,7 @@ export function renderJsonTreeLines(
|
|
|
307
357
|
} else if (keys.length === 0) {
|
|
308
358
|
children = [];
|
|
309
359
|
} else {
|
|
310
|
-
|
|
311
|
-
for (const key in record) objectChildren.push(node(record[key], key, item.depth + 1));
|
|
312
|
-
children = objectChildren;
|
|
360
|
+
children = entryNodes(jsonEntries(record), item.depth + 1);
|
|
313
361
|
}
|
|
314
362
|
}
|
|
315
363
|
item.children = children;
|
|
@@ -331,11 +379,13 @@ export function renderJsonTreeLines(
|
|
|
331
379
|
let body: readonly string[];
|
|
332
380
|
const displayKey = item.key ? sanitize(item.key) : undefined;
|
|
333
381
|
const label = theme.fg(
|
|
334
|
-
"muted",
|
|
382
|
+
item.keyColor ?? "muted",
|
|
335
383
|
displayKey || (item.kind === "array" ? "array" : item.kind === "object" ? "object" : "value"),
|
|
336
384
|
);
|
|
337
385
|
if (item.kind === "placeholder") {
|
|
338
386
|
body = [theme.fg("dim", item.placeholder ?? "…")];
|
|
387
|
+
} else if (item.kind === "inline") {
|
|
388
|
+
body = [`${label}: ${(item.inline ?? []).map(([text, color]) => theme.fg(color, text)).join("")}`];
|
|
339
389
|
} else if (item.kind === "array") {
|
|
340
390
|
body = [`${label} ${theme.fg("dim", `[${(item.value as unknown[]).length}]`)}`];
|
|
341
391
|
} else if (item.kind === "object") {
|
|
@@ -406,34 +456,42 @@ export interface JsonTreeDescribeOptions {
|
|
|
406
456
|
onTruncated?: () => void;
|
|
407
457
|
}
|
|
408
458
|
|
|
409
|
-
type JsonEntry = readonly [key: string, value: unknown];
|
|
459
|
+
type JsonEntry = readonly [key: string, value: unknown, keyColor: ThemeColor];
|
|
410
460
|
|
|
411
461
|
function clipScalar(value: string, maxLen: number): string {
|
|
412
462
|
return value.length > maxLen ? `${value.slice(0, maxLen)}…` : value;
|
|
413
463
|
}
|
|
414
464
|
|
|
465
|
+
/**
|
|
466
|
+
* `value`'s entries: an array's indices dim and right-aligned like line
|
|
467
|
+
* numbers, an object's keys (less `hidden`) muted.
|
|
468
|
+
*/
|
|
415
469
|
function jsonEntries(value: unknown[] | Record<string, unknown>, hidden?: readonly string[]): JsonEntry[] {
|
|
416
470
|
const out: JsonEntry[] = [];
|
|
417
471
|
if (Array.isArray(value)) {
|
|
418
|
-
|
|
472
|
+
const width = String(value.length - 1).length;
|
|
473
|
+
for (let index = 0; index < value.length; index++) {
|
|
474
|
+
out.push([String(index).padStart(width), value[index], "dim"]);
|
|
475
|
+
}
|
|
419
476
|
return out;
|
|
420
477
|
}
|
|
421
478
|
for (const key in value) {
|
|
422
|
-
if (!hidden?.includes(key)) out.push([key, value[key]]);
|
|
479
|
+
if (!hidden?.includes(key)) out.push([key, value[key], "muted"]);
|
|
423
480
|
}
|
|
424
481
|
return out;
|
|
425
482
|
}
|
|
426
483
|
|
|
427
|
-
function jsonScalarToken(value: unknown):
|
|
484
|
+
function jsonScalarToken(value: unknown): ThemeColor {
|
|
428
485
|
if (typeof value === "number" || typeof value === "bigint") return "syntaxNumber";
|
|
429
486
|
if (typeof value === "boolean" || value === null || value === undefined) return "syntaxKeyword";
|
|
430
487
|
return "dim";
|
|
431
488
|
}
|
|
432
489
|
|
|
433
490
|
/**
|
|
434
|
-
* TSP `tree` of a JSON value: containers
|
|
435
|
-
*
|
|
436
|
-
*
|
|
491
|
+
* TSP `tree` of a JSON value: containers that fit {@link JSON_TREE_INLINE_LEN}
|
|
492
|
+
* become `key: [1, "a"]` leaves, larger ones expandable nodes labelled with
|
|
493
|
+
* their key and size, scalars `key: value` leaves styled by type. Bounded by
|
|
494
|
+
* depth, node count and scalar length; no width math.
|
|
437
495
|
*/
|
|
438
496
|
export function describeJsonTree(value: unknown, options: JsonTreeDescribeOptions = {}): NativeNode {
|
|
439
497
|
const maxDepth = Math.max(0, options.maxDepth ?? JSON_TREE_MAX_DEPTH_EXPANDED);
|
|
@@ -452,26 +510,29 @@ export function describeJsonTree(value: unknown, options: JsonTreeDescribeOption
|
|
|
452
510
|
out.push(leaf([span(`… ${entries.length - index} more`, "dim")]));
|
|
453
511
|
break;
|
|
454
512
|
}
|
|
455
|
-
|
|
456
|
-
out.push(describeValue(key, child, depth));
|
|
513
|
+
out.push(describeValue(entries[index], depth));
|
|
457
514
|
}
|
|
458
515
|
return out;
|
|
459
516
|
};
|
|
460
517
|
|
|
461
|
-
const describeValue = (
|
|
518
|
+
const describeValue = (
|
|
519
|
+
[key, entry, keyColor]: readonly [key: string | undefined, value: unknown, keyColor?: ThemeColor],
|
|
520
|
+
depth: number,
|
|
521
|
+
): TspTreeNode => {
|
|
462
522
|
budget--;
|
|
463
523
|
const id = `${nextId++}`;
|
|
464
|
-
const keySpans: TspSpan[] = key === undefined ? [] : [span(plainText(key),
|
|
524
|
+
const keySpans: TspSpan[] = key === undefined ? [] : [span(plainText(key), keyColor)];
|
|
525
|
+
const prefix = keySpans.length > 0 ? [...keySpans, span(": ", "muted")] : [];
|
|
526
|
+
const inline = inlineJson(entry, plainText);
|
|
527
|
+
if (inline) return { id, label: [...prefix, ...inline.map(([text, color]) => span(text, color))] };
|
|
465
528
|
if (Array.isArray(entry) || isRecord(entry)) {
|
|
466
529
|
const entries = jsonEntries(entry);
|
|
467
530
|
const size = Array.isArray(entry) ? `[${entry.length}]` : `{${entries.length}}`;
|
|
468
531
|
const label = keySpans.length > 0 ? [...keySpans, span(` ${size}`, "dim")] : [span(size, "dim")];
|
|
469
|
-
if (entries.length === 0) return { id, label };
|
|
470
532
|
if (depth >= maxDepth) truncated = true;
|
|
471
533
|
const children = depth >= maxDepth ? [leaf([span("…", "dim")])] : describeEntries(entries, depth + 1);
|
|
472
534
|
return { id, label, open: depth < openDepth, children };
|
|
473
535
|
}
|
|
474
|
-
const prefix = keySpans.length > 0 ? [...keySpans, span(": ", "muted")] : [];
|
|
475
536
|
if (typeof entry === "string") {
|
|
476
537
|
const lines = plainText(entry).split("\n");
|
|
477
538
|
if (lines.some(line => line.length > maxScalarLen)) truncated = true;
|
|
@@ -504,8 +565,37 @@ export function describeJsonTree(value: unknown, options: JsonTreeDescribeOption
|
|
|
504
565
|
nodes =
|
|
505
566
|
entries.length > 0 ? describeEntries(entries, 1) : [leaf([span(Array.isArray(value) ? "[]" : "{}", "dim")])];
|
|
506
567
|
} else {
|
|
507
|
-
nodes = [describeValue(undefined, value, 0)];
|
|
568
|
+
nodes = [describeValue([undefined, value], 0)];
|
|
508
569
|
}
|
|
509
570
|
if (truncated) options.onTruncated?.();
|
|
510
571
|
return node("tree", { nodes });
|
|
511
572
|
}
|
|
573
|
+
|
|
574
|
+
/** Options of {@link describeJsonValue}: the `json` node's own, plus the fallback tree's. */
|
|
575
|
+
export interface JsonValueDescribeOptions extends JsonTreeDescribeOptions {
|
|
576
|
+
/** The host draws the `json` kind (`cx.supports("json")`). */
|
|
577
|
+
native?: boolean;
|
|
578
|
+
/** `json` node: container levels expanded below the top-level entries (default 0). */
|
|
579
|
+
open?: number;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* A JSON value for a TSP host: the terminal's own `json` viewer when it draws
|
|
584
|
+
* the kind, which folds and previews containers itself and never cuts (so
|
|
585
|
+
* `onTruncated` never fires), else {@link describeJsonTree} with the same
|
|
586
|
+
* options. Root keys the tree would hide are left out of the sent value too;
|
|
587
|
+
* strings are sanitized like the tree's labels.
|
|
588
|
+
*/
|
|
589
|
+
export function describeJsonValue(value: unknown, options: JsonValueDescribeOptions = {}): NativeNode {
|
|
590
|
+
if (!options.native) return describeJsonTree(value, options);
|
|
591
|
+
let shown = value;
|
|
592
|
+
if (isRecord(value)) {
|
|
593
|
+
const hidden = options.hiddenRootKeys ?? DEFAULT_HIDDEN_ROOT_KEYS;
|
|
594
|
+
if (hidden.some(key => Object.hasOwn(value, key))) {
|
|
595
|
+
const kept: Record<string, unknown> = {};
|
|
596
|
+
for (const key in value) if (!hidden.includes(key)) kept[key] = value[key];
|
|
597
|
+
shown = kept;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return node("json", { value: sanitizeTextDeep(shown), open: options.open || undefined });
|
|
601
|
+
}
|
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
|
}
|