@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/lsp.ts
CHANGED
|
@@ -83,6 +83,8 @@ export interface FileDiagnosticsResult {
|
|
|
83
83
|
summary: string;
|
|
84
84
|
/** Whether there are any errors (severity 1) */
|
|
85
85
|
errored: boolean;
|
|
86
|
+
/** Servers that sent no fresh report in time: the file is unverified for them, not clean. */
|
|
87
|
+
unreported?: string[];
|
|
86
88
|
/** Whether the file was formatted */
|
|
87
89
|
formatter?: FileFormatResult;
|
|
88
90
|
}
|
|
@@ -163,6 +165,9 @@ export function renderCall(args: LspParams, _options: RenderResultOptions, theme
|
|
|
163
165
|
// Result Rendering
|
|
164
166
|
// =============================================================================
|
|
165
167
|
|
|
168
|
+
/** A diagnostics status line for a file no server reported on in time: unverified, never "No issues". */
|
|
169
|
+
const UNREPORTED_LINE_RE = /\bno diagnostics report yet\b/;
|
|
170
|
+
|
|
166
171
|
/**
|
|
167
172
|
* Render LSP tool result with intelligent formatting based on result type.
|
|
168
173
|
* Detects hover, diagnostics, references, symbols, etc. and formats accordingly.
|
|
@@ -190,6 +195,7 @@ export function renderResult(
|
|
|
190
195
|
const refMatch = text.match(/(\d+)\s+reference\(s\)/);
|
|
191
196
|
const symbolsMatch = text.match(/Symbols in (.+):/);
|
|
192
197
|
const hasStatusError = text.includes(theme.status.error);
|
|
198
|
+
const unreportedCount = lines.filter(line => UNREPORTED_LINE_RE.test(line)).length;
|
|
193
199
|
|
|
194
200
|
// Static request info
|
|
195
201
|
const request = args ?? result.details?.request;
|
|
@@ -218,12 +224,12 @@ export function renderResult(
|
|
|
218
224
|
bodyLines: renderHover(codeBlockMatch, text, lines, expanded, theme),
|
|
219
225
|
};
|
|
220
226
|
}
|
|
221
|
-
if (errorMatch || warningMatch || hasStatusError) {
|
|
227
|
+
if (errorMatch || warningMatch || hasStatusError || unreportedCount > 0) {
|
|
222
228
|
const errorCount = errorMatch ? Number.parseInt(errorMatch[1], 10) : 0;
|
|
223
229
|
const warnCount = warningMatch ? Number.parseInt(warningMatch[1], 10) : 0;
|
|
224
230
|
return {
|
|
225
231
|
label: "Diagnostics",
|
|
226
|
-
state: errorCount > 0 ? "error" : warnCount > 0 ? "warning" : "success",
|
|
232
|
+
state: errorCount > 0 ? "error" : warnCount > 0 || unreportedCount > 0 ? "warning" : "success",
|
|
227
233
|
bodyLines: renderDiagnostics(errorMatch, warningMatch, lines, expanded, theme),
|
|
228
234
|
};
|
|
229
235
|
}
|
|
@@ -384,17 +390,19 @@ function renderDiagnostics(
|
|
|
384
390
|
): string[] {
|
|
385
391
|
const errorCount = errorMatch ? Number.parseInt(errorMatch[1], 10) : 0;
|
|
386
392
|
const warnCount = warningMatch ? Number.parseInt(warningMatch[1], 10) : 0;
|
|
393
|
+
const unreportedLines = lines.filter(line => UNREPORTED_LINE_RE.test(line));
|
|
387
394
|
|
|
388
395
|
const icon =
|
|
389
396
|
errorCount > 0
|
|
390
397
|
? theme.styledSymbol("status.error", "error")
|
|
391
|
-
: warnCount > 0
|
|
398
|
+
: warnCount > 0 || unreportedLines.length > 0
|
|
392
399
|
? theme.styledSymbol("status.warning", "warning")
|
|
393
400
|
: theme.styledSymbol("tool.lsp", "accent");
|
|
394
401
|
|
|
395
402
|
const meta: string[] = [];
|
|
396
403
|
if (errorCount > 0) meta.push(`${errorCount} error${errorCount !== 1 ? "s" : ""}`);
|
|
397
404
|
if (warnCount > 0) meta.push(`${warnCount} warning${warnCount !== 1 ? "s" : ""}`);
|
|
405
|
+
if (unreportedLines.length > 0) meta.push(formatCount("unverified file", unreportedLines.length));
|
|
398
406
|
if (meta.length === 0) meta.push("No issues");
|
|
399
407
|
|
|
400
408
|
const diagLines = lines.filter(l => l.includes(theme.status.error) || /:\d+:\d+/.test(l));
|
|
@@ -404,10 +412,14 @@ function renderDiagnostics(
|
|
|
404
412
|
const fallbackDiagnostics: RawDiagnostic[] = diagLines.map(line => ({
|
|
405
413
|
raw: sanitizeDiagnosticDisplayText(line.trim()),
|
|
406
414
|
}));
|
|
415
|
+
// Unverified files lead: they are the rows a reader must not miss among diagnostics.
|
|
416
|
+
const items: DiagnosticItem[] = [
|
|
417
|
+
...unreportedLines.map(line => ({ raw: sanitizeDiagnosticDisplayText(line.trim()) })),
|
|
418
|
+
...(parsedDiagnostics.length > 0 ? parsedDiagnostics : fallbackDiagnostics),
|
|
419
|
+
];
|
|
407
420
|
|
|
408
421
|
if (expanded) {
|
|
409
422
|
let output = `${icon} ${theme.fg("dim", meta.join(theme.sep.dot))}`;
|
|
410
|
-
const items: DiagnosticItem[] = parsedDiagnostics.length > 0 ? parsedDiagnostics : fallbackDiagnostics;
|
|
411
423
|
for (let i = 0; i < items.length; i++) {
|
|
412
424
|
const item = items[i];
|
|
413
425
|
const isLast = i === items.length - 1;
|
|
@@ -432,10 +444,8 @@ function renderDiagnostics(
|
|
|
432
444
|
}
|
|
433
445
|
|
|
434
446
|
// Collapsed view
|
|
435
|
-
const previewItems
|
|
436
|
-
|
|
437
|
-
const remaining =
|
|
438
|
-
(parsedDiagnostics.length > 0 ? parsedDiagnostics.length : fallbackDiagnostics.length) - previewItems.length;
|
|
447
|
+
const previewItems = items.slice(0, 3);
|
|
448
|
+
const remaining = items.length - previewItems.length;
|
|
439
449
|
const clipped = previewItems.some(
|
|
440
450
|
item => !("raw" in item) && visibleWidth(formatDiagnosticMessage(item)) > TRUNCATE_LENGTHS.CONTENT,
|
|
441
451
|
);
|
|
@@ -788,6 +798,8 @@ interface LspDiagnosticsParse {
|
|
|
788
798
|
diagnostics: ParsedDiagnostic[];
|
|
789
799
|
failures: string[];
|
|
790
800
|
warnings: string[];
|
|
801
|
+
/** Files a server sent no report for in time: unverified, never "No issues". */
|
|
802
|
+
unreported: string[];
|
|
791
803
|
/** Lines neither a diagnostic nor a status line (kept verbatim). */
|
|
792
804
|
other: string[];
|
|
793
805
|
}
|
|
@@ -803,10 +815,10 @@ const FILE_SUMMARY_RE = /: (?:no issues|\d+ \w+\(s\)(?:, \d+ \w+\(s\))*)$/;
|
|
|
803
815
|
* Parse a diagnostics response: grouped (`# dir/`, `## file`, ` 12:5 [error] …`)
|
|
804
816
|
* or flat (`file:12:5 [error] …`) diagnostic lines, and the per-file status
|
|
805
817
|
* lines (`✗ file: all language servers failed (…)`, `⚠ …some servers failed`,
|
|
806
|
-
* `✓ file: no issues`, `✗ file: 2 error(s)`).
|
|
818
|
+
* `⚠ file: no diagnostics report yet from …`, `✓ file: no issues`, `✗ file: 2 error(s)`).
|
|
807
819
|
*/
|
|
808
820
|
function parseLspDiagnostics(lines: readonly string[]): LspDiagnosticsParse {
|
|
809
|
-
const out: LspDiagnosticsParse = { diagnostics: [], failures: [], warnings: [], other: [] };
|
|
821
|
+
const out: LspDiagnosticsParse = { diagnostics: [], failures: [], warnings: [], unreported: [], other: [] };
|
|
810
822
|
let file: string | undefined;
|
|
811
823
|
for (const event of walkGroupedOutput(lines)) {
|
|
812
824
|
if (event.kind !== "line") {
|
|
@@ -824,6 +836,10 @@ function parseLspDiagnostics(lines: readonly string[]): LspDiagnosticsParse {
|
|
|
824
836
|
out.warnings.push(line.replace(STATUS_GLYPH_RE, ""));
|
|
825
837
|
continue;
|
|
826
838
|
}
|
|
839
|
+
if (UNREPORTED_LINE_RE.test(line)) {
|
|
840
|
+
out.unreported.push(line.replace(STATUS_GLYPH_RE, ""));
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
827
843
|
if (FILE_SUMMARY_RE.test(line)) continue;
|
|
828
844
|
const parsed = parseDiagnosticMessage(file && DIAGNOSTIC_AT_RE.test(line) ? `${file}:${line}` : line);
|
|
829
845
|
if (parsed) out.diagnostics.push(parsed);
|
|
@@ -888,25 +904,30 @@ function statusRow(message: string, tone: "error" | "warning", key: string): Nat
|
|
|
888
904
|
}
|
|
889
905
|
|
|
890
906
|
/**
|
|
891
|
-
* Diagnostics view: a card when there are diagnostics or
|
|
892
|
-
* severity icon · `file:line:col` · source · message), an inline `No issues`
|
|
893
|
-
* otherwise. A failed server is
|
|
907
|
+
* Diagnostics view: a card when there are diagnostics, failures or unverified files
|
|
908
|
+
* (rows of severity icon · `file:line:col` · source · message), an inline `No issues`
|
|
909
|
+
* otherwise. A failed server or a missing report is a row, never "No issues".
|
|
894
910
|
*/
|
|
895
911
|
function describeLspDiagnostics(request: Partial<LspParams> | undefined, fallbackAction: string, lines: string[]) {
|
|
896
912
|
const parsed = parseLspDiagnostics(lines);
|
|
897
913
|
const counts = diagnosticCounts(parsed.diagnostics);
|
|
898
914
|
const failed =
|
|
899
915
|
parsed.failures.length > 0 ? [span(formatCount("server failure", parsed.failures.length), "error")] : undefined;
|
|
916
|
+
const unverified =
|
|
917
|
+
parsed.unreported.length > 0
|
|
918
|
+
? [span(formatCount("unverified file", parsed.unreported.length), "warning")]
|
|
919
|
+
: undefined;
|
|
900
920
|
const rows: NativeNode[] = [
|
|
901
921
|
...parsed.failures.map((message, i) => statusRow(message, "error", `x${i}`)),
|
|
922
|
+
...parsed.unreported.map((message, i) => statusRow(message, "warning", `u${i}`)),
|
|
902
923
|
...parsed.diagnostics.map((diag, i) => diagnosticRow(diag, `d${i}`)),
|
|
903
924
|
...parsed.warnings.map((message, i) => statusRow(message, "warning", `w${i}`)),
|
|
904
925
|
];
|
|
905
926
|
if (parsed.other.length > 0) rows.push(keyed(code(parsed.other.join("\n"), { wrap: true }), "other"));
|
|
906
927
|
const hasErrors = parsed.failures.length > 0 || parsed.diagnostics.some(d => d.severity === "error");
|
|
907
|
-
const meta = compact<TspText>([counts, failed, !counts && !failed && "No issues"]);
|
|
928
|
+
const meta = compact<TspText>([counts, failed, unverified, !counts && !failed && !unverified && "No issues"]);
|
|
908
929
|
const head = lspNativeHead(request, fallbackAction, meta);
|
|
909
|
-
if (parsed.diagnostics.length === 0 && parsed.failures.length === 0) {
|
|
930
|
+
if (parsed.diagnostics.length === 0 && parsed.failures.length === 0 && parsed.unreported.length === 0) {
|
|
910
931
|
return { tool: head, inline: true, body: rows.length > 0 ? rows : undefined } satisfies NativeToolView;
|
|
911
932
|
}
|
|
912
933
|
return {
|
package/src/tools/mcp.d.ts
CHANGED
|
@@ -22,12 +22,13 @@ export declare function renderMCPResult(result: {
|
|
|
22
22
|
details?: MCPToolDetails;
|
|
23
23
|
isError?: boolean;
|
|
24
24
|
}, options: RenderResultOptions, theme: Theme, args?: Record<string, unknown>): Component;
|
|
25
|
-
/** Native MCP call view: the head
|
|
26
|
-
export declare function describeMCPCall(args: Record<string, unknown>, label: string): NativeToolView;
|
|
25
|
+
/** Native MCP call view: the head plus the folded args, inline while pending. */
|
|
26
|
+
export declare function describeMCPCall(args: Record<string, unknown>, label: string, options?: RenderResultOptions): NativeToolView;
|
|
27
27
|
/**
|
|
28
|
-
* Native MCP result view: JSON output as
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* Native MCP result view: JSON output as the host's `json` viewer (when it
|
|
29
|
+
* draws one) or a JSON tree, Markdown when the preference is on, otherwise
|
|
30
|
+
* the raw text as tool output; the folded Args section follows, so the
|
|
31
|
+
* collapsed preview still leads with the output.
|
|
31
32
|
*/
|
|
32
33
|
export declare function describeMCPResult(result: {
|
|
33
34
|
content: Array<{
|
|
@@ -36,7 +37,7 @@ export declare function describeMCPResult(result: {
|
|
|
36
37
|
}>;
|
|
37
38
|
details?: MCPToolDetails;
|
|
38
39
|
isError?: boolean;
|
|
39
|
-
},
|
|
40
|
+
}, options: RenderResultOptions, args?: Record<string, unknown>): NativeToolView | undefined;
|
|
40
41
|
import type { OutputMeta } from "./output-meta";
|
|
41
42
|
/** Set whether plain MCP text results render as Markdown. */
|
|
42
43
|
export declare function setMcpRenderMarkdownResults(enabled: boolean): void;
|
package/src/tools/mcp.ts
CHANGED
|
@@ -9,14 +9,14 @@ import { type Component, Markdown } from "../index";
|
|
|
9
9
|
import type { NativeToolHead, NativeToolView, RenderResultOptions } from "./renderer";
|
|
10
10
|
import { isRecord, sanitizeText } from "@linxiraos/pi-utils";
|
|
11
11
|
import { INTENT_FIELD } from "@linxiraos/pi-wire";
|
|
12
|
-
import { ansi, md } from "../native/describe";
|
|
13
|
-
import type { NativeChild } from "../native/node";
|
|
12
|
+
import { ansi, md, node, span } from "../native/describe";
|
|
13
|
+
import type { NativeChild, NativeNode } from "../native/node";
|
|
14
14
|
import { OwnerMemo } from "../native/memo";
|
|
15
15
|
import { plainText } from "../native/spans";
|
|
16
16
|
import { errorText, noteText, truncationNotice } from "./native-view";
|
|
17
17
|
import { getMarkdownTheme, type Theme } from "../theme/theme";
|
|
18
18
|
import {
|
|
19
|
-
|
|
19
|
+
describeJsonValue,
|
|
20
20
|
formatArgsInline,
|
|
21
21
|
JSON_TREE_MAX_DEPTH_COLLAPSED,
|
|
22
22
|
JSON_TREE_MAX_DEPTH_EXPANDED,
|
|
@@ -291,8 +291,7 @@ function visibleMcpArgs(args: Record<string, unknown> | undefined): [string, unk
|
|
|
291
291
|
const MCP_ARGS_SUMMARY_CHARS = 160;
|
|
292
292
|
|
|
293
293
|
/** Native MCP head: the tool title with a one-line args summary as target. */
|
|
294
|
-
function mcpHead(title: string,
|
|
295
|
-
const entries = visibleMcpArgs(args);
|
|
294
|
+
function mcpHead(title: string, entries: readonly [string, unknown][]): NativeToolHead {
|
|
296
295
|
const summary =
|
|
297
296
|
entries.length > 0
|
|
298
297
|
? formatArgsInline(Object.fromEntries(entries), MCP_ARGS_SUMMARY_CHARS, { characterBudget: true })
|
|
@@ -300,25 +299,49 @@ function mcpHead(title: string, args: Record<string, unknown> | undefined): Nati
|
|
|
300
299
|
return { title, target: summary ? plainText(summary) : undefined, targetKind: "text" };
|
|
301
300
|
}
|
|
302
301
|
|
|
303
|
-
/**
|
|
304
|
-
|
|
305
|
-
|
|
302
|
+
/**
|
|
303
|
+
* Native counterpart of the ANSI card's Args tree: the complete arguments,
|
|
304
|
+
* folded under an `Args` section because the head summary clips each value.
|
|
305
|
+
* The host's `json` viewer, when it draws one, lists the arguments with their
|
|
306
|
+
* containers folded to one-line previews.
|
|
307
|
+
*/
|
|
308
|
+
function mcpArgsSection(entries: readonly [string, unknown][], json: boolean): NativeNode | undefined {
|
|
309
|
+
if (entries.length === 0) return undefined;
|
|
310
|
+
return node(
|
|
311
|
+
"section",
|
|
312
|
+
{ head: [span("Args", "muted")], collapsible: true, collapsed: true },
|
|
313
|
+
[describeJsonValue(Object.fromEntries(entries), { native: json })],
|
|
314
|
+
"args",
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** Native MCP call view: the head plus the folded args, inline while pending. */
|
|
319
|
+
export function describeMCPCall(
|
|
320
|
+
args: Record<string, unknown>,
|
|
321
|
+
label: string,
|
|
322
|
+
options?: RenderResultOptions,
|
|
323
|
+
): NativeToolView {
|
|
324
|
+
const entries = visibleMcpArgs(args);
|
|
325
|
+
const section = mcpArgsSection(entries, options?.json === true);
|
|
326
|
+
return { tool: mcpHead(label, entries), body: section ? [section] : undefined, inline: true };
|
|
306
327
|
}
|
|
307
328
|
|
|
308
329
|
const mcpResultMemo = new OwnerMemo<NativeToolView | undefined>();
|
|
309
330
|
|
|
310
331
|
/**
|
|
311
|
-
* Native MCP result view: JSON output as
|
|
312
|
-
*
|
|
313
|
-
*
|
|
332
|
+
* Native MCP result view: JSON output as the host's `json` viewer (when it
|
|
333
|
+
* draws one) or a JSON tree, Markdown when the preference is on, otherwise
|
|
334
|
+
* the raw text as tool output; the folded Args section follows, so the
|
|
335
|
+
* collapsed preview still leads with the output.
|
|
314
336
|
*/
|
|
315
337
|
export function describeMCPResult(
|
|
316
338
|
result: { content: Array<{ type: string; text?: string }>; details?: MCPToolDetails; isError?: boolean },
|
|
317
|
-
|
|
339
|
+
options: RenderResultOptions,
|
|
318
340
|
args?: Record<string, unknown>,
|
|
319
341
|
): NativeToolView | undefined {
|
|
342
|
+
const json = options.json === true;
|
|
320
343
|
// Callers allocate a fresh args object per streamed delta, so identity is a sound dep.
|
|
321
|
-
return mcpResultMemo.get(result, [renderMarkdownResults, args], () => {
|
|
344
|
+
return mcpResultMemo.get(result, [renderMarkdownResults, args, json], () => {
|
|
322
345
|
const textContent = (result.content ?? [])
|
|
323
346
|
.filter(block => block.type === "text")
|
|
324
347
|
.map(block => block.text ?? "")
|
|
@@ -340,13 +363,16 @@ export function describeMCPResult(
|
|
|
340
363
|
}
|
|
341
364
|
if (!output) body.push(noteText("(no output)"));
|
|
342
365
|
else if (isError) body.push(errorText(output));
|
|
343
|
-
else if (isJson) body.push(
|
|
366
|
+
else if (isJson) body.push(describeJsonValue(parsed, { native: json }));
|
|
344
367
|
else if (renderMarkdownResults) body.push(md(output));
|
|
345
368
|
else body.push(ansi(output));
|
|
346
369
|
const warning = truncationNotice(result.details?.meta);
|
|
347
370
|
if (warning) body.push(warning);
|
|
371
|
+
const entries = visibleMcpArgs(args);
|
|
372
|
+
const section = mcpArgsSection(entries, json);
|
|
373
|
+
if (section) body.push(section);
|
|
348
374
|
return {
|
|
349
|
-
tool: mcpHead(title,
|
|
375
|
+
tool: mcpHead(title, entries),
|
|
350
376
|
tone: isError ? "error" : undefined,
|
|
351
377
|
body,
|
|
352
378
|
preview: { lines: 4 },
|
|
@@ -6,7 +6,7 @@ import { type OutputMeta } from "./output-meta";
|
|
|
6
6
|
import type { NativeToolHead, NativeToolView, ToolRenderResult } from "./renderer";
|
|
7
7
|
/** A path for native heads: relative to the working directory when inside it, else `~`-shortened. */
|
|
8
8
|
export declare function displayPath(filePath: string): string;
|
|
9
|
-
/**
|
|
9
|
+
/** Configured file link for a head's path target, when the path is absolute. */
|
|
10
10
|
export declare function fileHref(filePath: string | undefined): string | undefined;
|
|
11
11
|
/** Diff stats as one head `meta` string, `+8 −1` (U+2212 minus), or undefined when nothing changed. */
|
|
12
12
|
export declare function diffStatsMeta(added: number, removed: number): string | undefined;
|
package/src/tools/native-view.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* semantic nodes/spans only, with ANSI-free, sanitized text.
|
|
5
5
|
*/
|
|
6
6
|
import * as path from "node:path";
|
|
7
|
-
import { pathToFileURL } from "node:url";
|
|
8
7
|
import type { TspSpan, TspText, TspTone } from "@linxiraos/pi-wire";
|
|
9
8
|
import { ansi, code, compact, keyed, node, row, span, text } from "../native/describe";
|
|
10
9
|
import type { NativeChild, NativeNode } from "../native/node";
|
|
10
|
+
import { tryFileUri } from "../render/hyperlink";
|
|
11
11
|
import { type ParsedDiagnostic, parseDiagnosticMessage, shortenPath } from "../render/render-utils";
|
|
12
12
|
import { plainText } from "../native/spans";
|
|
13
13
|
import type { FileDiagnosticsResult } from "./lsp";
|
|
@@ -23,9 +23,9 @@ export function displayPath(filePath: string): string {
|
|
|
23
23
|
return shortenPath(filePath);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/** Configured file link for a head's path target, when the path is absolute. */
|
|
27
27
|
export function fileHref(filePath: string | undefined): string | undefined {
|
|
28
|
-
return filePath && path.isAbsolute(filePath) ?
|
|
28
|
+
return filePath && path.isAbsolute(filePath) ? tryFileUri(filePath) : undefined;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/** Diff stats as one head `meta` string, `+8 −1` (U+2212 minus), or undefined when nothing changed. */
|
package/src/tools/read.d.ts
CHANGED
|
@@ -29,7 +29,10 @@ export interface ReadToolDetails {
|
|
|
29
29
|
suffixResolution?: {
|
|
30
30
|
from: string;
|
|
31
31
|
to: string;
|
|
32
|
+
raw?: boolean;
|
|
32
33
|
};
|
|
34
|
+
/** Raw source output keeps descriptive diagnostics in details, not in the body. */
|
|
35
|
+
raw?: boolean;
|
|
33
36
|
url?: string;
|
|
34
37
|
finalUrl?: string;
|
|
35
38
|
contentType?: string;
|
package/src/tools/read.ts
CHANGED
|
@@ -62,7 +62,9 @@ export interface ReadToolDetails {
|
|
|
62
62
|
* screenshots, URL reads and other images not backed by a file. Display-only.
|
|
63
63
|
*/
|
|
64
64
|
mediaPath?: string;
|
|
65
|
-
suffixResolution?: { from: string; to: string };
|
|
65
|
+
suffixResolution?: { from: string; to: string; raw?: boolean };
|
|
66
|
+
/** Raw source output keeps descriptive diagnostics in details, not in the body. */
|
|
67
|
+
raw?: boolean;
|
|
66
68
|
url?: string;
|
|
67
69
|
finalUrl?: string;
|
|
68
70
|
contentType?: string;
|
package/src/tools/renderer.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface RenderResultOptions {
|
|
|
36
36
|
cancelled?: boolean;
|
|
37
37
|
/** The native host shows files by path (`cx.supports("media")`). Native describe hooks only. */
|
|
38
38
|
media?: boolean;
|
|
39
|
+
/** The native host draws raw JSON values (`cx.supports("json")`). Native describe hooks only. */
|
|
40
|
+
json?: boolean;
|
|
39
41
|
}
|
|
40
42
|
/** Render options for a result, plus the tool-specific context the transcript threads through. */
|
|
41
43
|
export type RenderResultContextOptions = RenderResultOptions & {
|
package/src/tools/renderer.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface RenderResultOptions {
|
|
|
37
37
|
cancelled?: boolean;
|
|
38
38
|
/** The native host shows files by path (`cx.supports("media")`). Native describe hooks only. */
|
|
39
39
|
media?: boolean;
|
|
40
|
+
/** The native host draws raw JSON values (`cx.supports("json")`). Native describe hooks only. */
|
|
41
|
+
json?: boolean;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
/** Render options for a result, plus the tool-specific context the transcript threads through. */
|
|
@@ -177,6 +177,17 @@ export declare function truncateLineBytes(line: string, maxBytes?: number): {
|
|
|
177
177
|
text: string;
|
|
178
178
|
wasTruncated: boolean;
|
|
179
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* Where `text` shows in `output` written through an {@link OutputSink} with
|
|
182
|
+
* `maxColumns`, searching from `from`: each of its lines whole, or, where the
|
|
183
|
+
* cap cut the output line, a head of it and `…` ending that output line.
|
|
184
|
+
* Only the first line can be cut short of its first 16 characters (after
|
|
185
|
+
* other text on its output line); such text is not found.
|
|
186
|
+
*/
|
|
187
|
+
export declare function findColumnCapped(output: string, text: string, from?: number): {
|
|
188
|
+
start: number;
|
|
189
|
+
end: number;
|
|
190
|
+
} | undefined;
|
|
180
191
|
/** Shared helper to build a no-truncation result. */
|
|
181
192
|
export declare function noTruncResult(content: string, totalLines?: number, totalBytes?: number): TruncationResult;
|
|
182
193
|
/**
|
|
@@ -323,6 +323,47 @@ export function truncateLineBytes(
|
|
|
323
323
|
return { text: materializeString(`${head}…`), wasTruncated: true };
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
/** Leading characters of a text's first line {@link findColumnCapped} searches for. */
|
|
327
|
+
const CAPPED_PROBE_CHARS = 16;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Where `text` shows in `output` written through an {@link OutputSink} with
|
|
331
|
+
* `maxColumns`, searching from `from`: each of its lines whole, or, where the
|
|
332
|
+
* cap cut the output line, a head of it and `…` ending that output line.
|
|
333
|
+
* Only the first line can be cut short of its first 16 characters (after
|
|
334
|
+
* other text on its output line); such text is not found.
|
|
335
|
+
*/
|
|
336
|
+
export function findColumnCapped(output: string, text: string, from = 0): { start: number; end: number } | undefined {
|
|
337
|
+
if (!text) return undefined;
|
|
338
|
+
const lines = text.split(NL);
|
|
339
|
+
const probe = lines[0] ? lines[0].slice(0, CAPPED_PROBE_CHARS) : NL;
|
|
340
|
+
for (let at = output.indexOf(probe, from); at !== -1; at = output.indexOf(probe, at + 1)) {
|
|
341
|
+
const end = cappedLinesEnd(output, at, lines);
|
|
342
|
+
if (end !== undefined) return { start: at, end };
|
|
343
|
+
}
|
|
344
|
+
return undefined;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** End of `lines` shown in column-capped `output` from `at`, if they show there. */
|
|
348
|
+
function cappedLinesEnd(output: string, at: number, lines: readonly string[]): number | undefined {
|
|
349
|
+
let pos = at;
|
|
350
|
+
for (let i = 0; i < lines.length; i++) {
|
|
351
|
+
const line = lines[i];
|
|
352
|
+
const last = i === lines.length - 1;
|
|
353
|
+
if (output.startsWith(line, pos) && (last || output[pos + line.length] === NL)) {
|
|
354
|
+
pos += last ? line.length : line.length + 1;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
let eol = output.indexOf(NL, pos);
|
|
358
|
+
if (eol === -1) eol = output.length;
|
|
359
|
+
if (eol === pos || output[eol - 1] !== ELLIPSIS || !line.startsWith(output.slice(pos, eol - 1))) return undefined;
|
|
360
|
+
if (last) return eol;
|
|
361
|
+
if (eol === output.length) return undefined;
|
|
362
|
+
pos = eol + 1;
|
|
363
|
+
}
|
|
364
|
+
return pos;
|
|
365
|
+
}
|
|
366
|
+
|
|
326
367
|
// =============================================================================
|
|
327
368
|
// Content truncation (line + byte aware, no full Buffer allocation)
|
|
328
369
|
// =============================================================================
|
package/src/tools/task.d.ts
CHANGED
|
@@ -105,8 +105,9 @@ export interface TaskItem {
|
|
|
105
105
|
sourceSession?: string;
|
|
106
106
|
/** Optional model selector override for the historical source session. */
|
|
107
107
|
model?: string | string[];
|
|
108
|
-
/**
|
|
108
|
+
/** Inline instructions; exactly one of task or taskFile is required. */
|
|
109
109
|
task?: string;
|
|
110
|
+
taskFile?: string;
|
|
110
111
|
/** How open-ended the work is; required by the schema and the child's sole `auto` thinking classification input. */
|
|
111
112
|
solutionSpace?: string;
|
|
112
113
|
/** Per-spawn thinking effort: lowest/middle/highest level the resolved model supports. Overrides the agent's default selector (e.g. `auto`). */
|
|
@@ -137,6 +138,8 @@ export interface TaskParams {
|
|
|
137
138
|
model?: string | string[];
|
|
138
139
|
/** The work (flat form). */
|
|
139
140
|
task?: string;
|
|
141
|
+
/** Absolute path or local:// URL to a UTF-8 file (flat form), mutually exclusive with task. */
|
|
142
|
+
taskFile?: string;
|
|
140
143
|
/** How open-ended the work is (flat form); see {@link TaskItem.solutionSpace}. */
|
|
141
144
|
solutionSpace?: string;
|
|
142
145
|
/** Per-spawn thinking effort (flat form): lowest/middle/highest level the resolved model supports. */
|
|
@@ -212,6 +215,9 @@ export interface AgentProgress {
|
|
|
212
215
|
status: "pending" | "running" | "completed" | "failed" | "aborted";
|
|
213
216
|
task: string;
|
|
214
217
|
assignment?: string;
|
|
218
|
+
taskFile?: string;
|
|
219
|
+
/** SHA-256 of the exact task file bytes before decoding and trimming. */
|
|
220
|
+
taskFileSha256?: string;
|
|
215
221
|
description?: string;
|
|
216
222
|
lastIntent?: string;
|
|
217
223
|
currentTool?: string;
|
|
@@ -319,6 +325,8 @@ export interface SingleResult {
|
|
|
319
325
|
agentSource: AgentSource;
|
|
320
326
|
task: string;
|
|
321
327
|
assignment?: string;
|
|
328
|
+
taskFile?: string;
|
|
329
|
+
taskFileSha256?: string;
|
|
322
330
|
description?: string;
|
|
323
331
|
lastIntent?: string;
|
|
324
332
|
exitCode: number;
|