@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.
Files changed (363) hide show
  1. package/CHANGELOG.md +208 -207
  2. package/README.md +34 -34
  3. package/dist/types/app-keybindings.d.ts +20 -0
  4. package/dist/types/apps/session-picker.d.ts +5 -0
  5. package/dist/types/charts/chart-plan.d.ts +9 -7
  6. package/dist/types/chat/assistant-message.d.ts +15 -3
  7. package/dist/types/chat/bash-execution.d.ts +2 -0
  8. package/dist/types/chat/display-preferences.d.ts +2 -0
  9. package/dist/types/chat/extension-types.d.ts +31 -0
  10. package/dist/types/chat/reply-write.d.ts +48 -0
  11. package/dist/types/chat/table-chart.d.ts +4 -3
  12. package/dist/types/chat/tool-execution.d.ts +1 -2
  13. package/dist/types/chat/transcript-outline.d.ts +7 -0
  14. package/dist/types/chat/transcript-render-helpers.d.ts +2 -0
  15. package/dist/types/chrome/context-map.d.ts +15 -0
  16. package/dist/types/chrome/context-presentation.d.ts +48 -0
  17. package/dist/types/chrome/context-view-model.d.ts +77 -0
  18. package/dist/types/chrome/index.d.ts +1 -0
  19. package/dist/types/chrome/transcript-notice.d.ts +35 -0
  20. package/dist/types/chrome/transcript-status.d.ts +20 -8
  21. package/dist/types/components/editor.d.ts +8 -0
  22. package/dist/types/components/image.d.ts +20 -0
  23. package/dist/types/components/loader.d.ts +1 -1
  24. package/dist/types/components/markdown.d.ts +7 -0
  25. package/dist/types/native/blobs.d.ts +11 -1
  26. package/dist/types/native/picker.d.ts +4 -4
  27. package/dist/types/overlays/advisor-config.d.ts +6 -0
  28. package/dist/types/overlays/agent-hub-projection.d.ts +3 -1
  29. package/dist/types/overlays/annotation-overlay.d.ts +7 -1
  30. package/dist/types/overlays/annotation-types.d.ts +28 -0
  31. package/dist/types/overlays/ask-dialog.d.ts +12 -3
  32. package/dist/types/overlays/btw-history-panel.d.ts +16 -2
  33. package/dist/types/overlays/btw-history.d.ts +7 -0
  34. package/dist/types/overlays/btw-panel.d.ts +2 -0
  35. package/dist/types/overlays/context-viewer-format.d.ts +42 -0
  36. package/dist/types/overlays/context-viewer-overview.d.ts +70 -0
  37. package/dist/types/overlays/context-viewer.d.ts +25 -0
  38. package/dist/types/overlays/hook-input.d.ts +1 -0
  39. package/dist/types/overlays/login-dialog.d.ts +5 -1
  40. package/dist/types/overlays/mcp-add-wizard.d.ts +2 -0
  41. package/dist/types/overlays/model-browser.d.ts +10 -1
  42. package/dist/types/overlays/oauth-selector.d.ts +23 -0
  43. package/dist/types/overlays/pause-screen.d.ts +13 -3
  44. package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
  45. package/dist/types/overlays/rewind-selector.d.ts +1 -1
  46. package/dist/types/overlays/running-subagent-badge.d.ts +7 -1
  47. package/dist/types/overlays/session-selector.d.ts +22 -2
  48. package/dist/types/prompt/composer.d.ts +43 -0
  49. package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
  50. package/dist/types/prompt/macos-spelling.d.ts +2 -2
  51. package/dist/types/render/extension-links.d.ts +65 -0
  52. package/dist/types/render/hyperlink.d.ts +38 -7
  53. package/dist/types/render/index.d.ts +1 -0
  54. package/dist/types/render/output-pane.d.ts +1 -1
  55. package/dist/types/render/render-utils.d.ts +7 -1
  56. package/dist/types/setup/scenes/glyph.d.ts +1 -1
  57. package/dist/types/setup/scenes/model.d.ts +1 -1
  58. package/dist/types/setup/scenes/outro.d.ts +5 -4
  59. package/dist/types/setup/scenes/sign-in.d.ts +13 -8
  60. package/dist/types/setup/scenes/types.d.ts +16 -1
  61. package/dist/types/setup/startup-splash.d.ts +1 -1
  62. package/dist/types/setup/wizard-overlay.d.ts +11 -7
  63. package/dist/types/setup/wizard.d.ts +5 -1
  64. package/dist/types/status-line/component.d.ts +3 -3
  65. package/dist/types/status-line/context-usage.d.ts +42 -35
  66. package/dist/types/status-line/host.d.ts +6 -2
  67. package/dist/types/terminal-capabilities.d.ts +7 -0
  68. package/dist/types/theme/symbols.d.ts +1 -1
  69. package/dist/types/theme/theme.d.ts +0 -23
  70. package/dist/types/tools/ask.d.ts +4 -0
  71. package/dist/types/tools/bash-interactive.d.ts +6 -0
  72. package/dist/types/tools/bash.d.ts +2 -0
  73. package/dist/types/tools/default-renderer.d.ts +6 -4
  74. package/dist/types/tools/edit.d.ts +3 -1
  75. package/dist/types/tools/fetch.d.ts +1 -0
  76. package/dist/types/tools/github.d.ts +3 -0
  77. package/dist/types/tools/grouped-file-output.d.ts +2 -0
  78. package/dist/types/tools/irc.d.ts +6 -0
  79. package/dist/types/tools/json-tree.d.ts +23 -4
  80. package/dist/types/tools/lsp.d.ts +2 -0
  81. package/dist/types/tools/mcp.d.ts +7 -6
  82. package/dist/types/tools/native-view.d.ts +1 -1
  83. package/dist/types/tools/read.d.ts +3 -0
  84. package/dist/types/tools/renderer.d.ts +2 -0
  85. package/dist/types/tools/streaming-output.d.ts +11 -0
  86. package/dist/types/tools/task.d.ts +9 -1
  87. package/dist/types/tools/url-scheme-host.d.ts +17 -0
  88. package/dist/types/tools/wait.d.ts +16 -2
  89. package/dist/types/tools/yield.d.ts +1 -1
  90. package/dist/types/tui.d.ts +9 -2
  91. package/dist/types/vim.d.ts +39 -0
  92. package/package.json +10 -14
  93. package/src/app-keybindings.d.ts +20 -0
  94. package/src/app-keybindings.ts +20 -0
  95. package/src/apps/session-picker.ts +7 -0
  96. package/src/charts/chart-plan.d.ts +9 -7
  97. package/src/charts/chart-plan.ts +20 -50
  98. package/src/chat/advisor-message.ts +2 -0
  99. package/src/chat/assistant-message.d.ts +15 -3
  100. package/src/chat/assistant-message.ts +137 -19
  101. package/src/chat/background-tan-message.ts +4 -0
  102. package/src/chat/bash-execution.d.ts +2 -0
  103. package/src/chat/bash-execution.ts +13 -1
  104. package/src/chat/chat-transcript-builder.ts +58 -28
  105. package/src/chat/compaction-summary-message.ts +2 -1
  106. package/src/chat/display-preferences.d.ts +2 -0
  107. package/src/chat/display-preferences.ts +3 -0
  108. package/src/chat/extension-types.d.ts +31 -0
  109. package/src/chat/extension-types.ts +34 -0
  110. package/src/chat/read-tool-group.ts +1 -2
  111. package/src/chat/reply-write.d.ts +48 -0
  112. package/src/chat/reply-write.ts +127 -0
  113. package/src/chat/skill-message.ts +2 -6
  114. package/src/chat/table-chart.d.ts +4 -3
  115. package/src/chat/table-chart.ts +10 -4
  116. package/src/chat/tool-execution.d.ts +1 -2
  117. package/src/chat/tool-execution.ts +20 -13
  118. package/src/chat/transcript-outline.d.ts +7 -0
  119. package/src/chat/transcript-outline.ts +27 -0
  120. package/src/chat/transcript-render-helpers.d.ts +2 -0
  121. package/src/chat/transcript-render-helpers.ts +66 -24
  122. package/src/chrome/context-map.ts +62 -0
  123. package/src/chrome/context-presentation.ts +26 -0
  124. package/src/chrome/context-view-model.ts +73 -0
  125. package/src/chrome/index.ts +1 -0
  126. package/src/chrome/transcript-container.ts +89 -59
  127. package/src/chrome/transcript-notice.d.ts +35 -0
  128. package/src/chrome/transcript-notice.ts +83 -0
  129. package/src/chrome/transcript-status.d.ts +20 -8
  130. package/src/chrome/transcript-status.ts +29 -29
  131. package/src/components/editor.d.ts +8 -0
  132. package/src/components/editor.ts +465 -14
  133. package/src/components/image.d.ts +20 -0
  134. package/src/components/image.ts +83 -18
  135. package/src/components/loader.d.ts +1 -1
  136. package/src/components/loader.ts +1 -1
  137. package/src/components/markdown.d.ts +7 -0
  138. package/src/components/markdown.ts +225 -13
  139. package/src/hotkeys-markdown.ts +2 -0
  140. package/src/native/backend.ts +5 -66
  141. package/src/native/blobs.d.ts +11 -1
  142. package/src/native/blobs.ts +5 -3
  143. package/src/native/picker.d.ts +4 -4
  144. package/src/native/picker.ts +4 -4
  145. package/src/overlays/advisor-config.ts +10 -12
  146. package/src/overlays/agent-hub-projection.d.ts +3 -1
  147. package/src/overlays/agent-hub-projection.ts +6 -5
  148. package/src/overlays/agent-hub.ts +51 -42
  149. package/src/overlays/annotation-overlay.ts +125 -37
  150. package/src/overlays/annotation-types.ts +24 -0
  151. package/src/overlays/ask-dialog.ts +125 -35
  152. package/src/overlays/btw-history-panel.ts +124 -12
  153. package/src/overlays/btw-history.ts +11 -0
  154. package/src/overlays/btw-panel.ts +8 -4
  155. package/src/overlays/context-viewer-format.ts +145 -0
  156. package/src/overlays/context-viewer-overview.ts +381 -0
  157. package/src/overlays/context-viewer.ts +728 -0
  158. package/src/overlays/hook-input.ts +2 -0
  159. package/src/overlays/hook-selector.ts +2 -2
  160. package/src/overlays/login-dialog.ts +31 -5
  161. package/src/overlays/mcp-add-wizard.ts +6 -1
  162. package/src/overlays/model-browser.ts +37 -0
  163. package/src/overlays/model-hub.ts +1 -7
  164. package/src/overlays/model-picker.ts +1 -10
  165. package/src/overlays/oauth-selector.ts +44 -6
  166. package/src/overlays/pause-screen.ts +166 -33
  167. package/src/overlays/plan-review-overlay.ts +13 -2
  168. package/src/overlays/rewind-selector.ts +29 -12
  169. package/src/overlays/running-subagent-badge.ts +12 -1
  170. package/src/overlays/session-selector.ts +313 -42
  171. package/src/overlays/settings-defs.ts +1 -0
  172. package/src/overlays/usage-dashboard.ts +20 -14
  173. package/src/prompt/composer.ts +216 -1
  174. package/src/prompt/custom-editor.ts +6 -1
  175. package/src/prompt/emoji-autocomplete.ts +0 -2
  176. package/src/prompt/interactive-context-helpers.ts +29 -4
  177. package/src/prompt/macos-spelling.ts +24 -15
  178. package/src/render/extension-links.d.ts +65 -0
  179. package/src/render/extension-links.ts +214 -0
  180. package/src/render/hyperlink.d.ts +38 -7
  181. package/src/render/hyperlink.ts +102 -23
  182. package/src/render/index.d.ts +1 -0
  183. package/src/render/index.ts +1 -0
  184. package/src/render/output-pane.d.ts +1 -1
  185. package/src/render/output-pane.ts +60 -17
  186. package/src/render/render-utils.d.ts +7 -1
  187. package/src/render/render-utils.ts +11 -2
  188. package/src/setup/scenes/composer.ts +2 -0
  189. package/src/setup/scenes/glyph.ts +3 -1
  190. package/src/setup/scenes/model.ts +192 -29
  191. package/src/setup/scenes/outro.ts +33 -15
  192. package/src/setup/scenes/sign-in.ts +194 -392
  193. package/src/setup/scenes/theme.ts +2 -0
  194. package/src/setup/scenes/types.ts +18 -1
  195. package/src/setup/startup-splash.ts +8 -7
  196. package/src/setup/wizard-overlay.ts +164 -35
  197. package/src/setup/wizard.ts +11 -2
  198. package/src/status-line/component.ts +10 -14
  199. package/src/status-line/context-usage.ts +122 -597
  200. package/src/status-line/host.ts +6 -2
  201. package/src/terminal-capabilities.d.ts +7 -0
  202. package/src/terminal-capabilities.ts +10 -0
  203. package/src/terminal.ts +24 -2
  204. package/src/theme/defaults.json +1 -0
  205. package/src/theme/loader.ts +1 -1
  206. package/src/theme/symbols.d.ts +1 -1
  207. package/src/theme/symbols.ts +16 -0
  208. package/src/theme/theme.d.ts +0 -23
  209. package/src/theme/theme.ts +2 -75
  210. package/src/tools/ask.d.ts +4 -0
  211. package/src/tools/ask.ts +4 -0
  212. package/src/tools/ast-grep.ts +3 -2
  213. package/src/tools/bash-interactive.d.ts +49 -0
  214. package/src/tools/bash-interactive.ts +6 -1
  215. package/src/tools/bash.d.ts +2 -0
  216. package/src/tools/bash.ts +7 -23
  217. package/src/tools/default-renderer.d.ts +6 -4
  218. package/src/tools/default-renderer.ts +9 -6
  219. package/src/tools/edit.d.ts +3 -1
  220. package/src/tools/edit.ts +8 -4
  221. package/src/tools/eval.ts +14 -4
  222. package/src/tools/fetch.d.ts +1 -0
  223. package/src/tools/fetch.ts +1 -0
  224. package/src/tools/find.ts +3 -10
  225. package/src/tools/github.d.ts +3 -0
  226. package/src/tools/github.ts +23 -3
  227. package/src/tools/glob.ts +4 -3
  228. package/src/tools/grep.ts +3 -4
  229. package/src/tools/grouped-file-output.d.ts +2 -0
  230. package/src/tools/grouped-file-output.ts +8 -2
  231. package/src/tools/irc.d.ts +6 -0
  232. package/src/tools/irc.ts +6 -0
  233. package/src/tools/job-widget.ts +13 -1
  234. package/src/tools/json-tree.d.ts +23 -4
  235. package/src/tools/json-tree.ts +132 -42
  236. package/src/tools/lsp.d.ts +2 -0
  237. package/src/tools/lsp.ts +36 -15
  238. package/src/tools/mcp.d.ts +7 -6
  239. package/src/tools/mcp.ts +41 -15
  240. package/src/tools/native-view.d.ts +1 -1
  241. package/src/tools/native-view.ts +3 -3
  242. package/src/tools/read.d.ts +3 -0
  243. package/src/tools/read.ts +3 -1
  244. package/src/tools/renderer.d.ts +2 -0
  245. package/src/tools/renderer.ts +2 -0
  246. package/src/tools/streaming-output.d.ts +11 -0
  247. package/src/tools/streaming-output.ts +41 -0
  248. package/src/tools/task.d.ts +9 -1
  249. package/src/tools/task.ts +59 -16
  250. package/src/tools/url-scheme-host.d.ts +17 -0
  251. package/src/tools/url-scheme-host.ts +21 -0
  252. package/src/tools/vibe.ts +14 -3
  253. package/src/tools/wait.d.ts +16 -2
  254. package/src/tools/wait.ts +16 -2
  255. package/src/tools/yield.d.ts +1 -1
  256. package/src/tools/yield.ts +18 -9
  257. package/src/tui.d.ts +9 -2
  258. package/src/tui.ts +102 -34
  259. package/src/vim.d.ts +39 -0
  260. package/src/vim.ts +313 -22
  261. package/dist/types/theme/defaults/index.d.ts +0 -10289
  262. package/src/theme/defaults/alabaster.json +0 -103
  263. package/src/theme/defaults/amethyst.json +0 -106
  264. package/src/theme/defaults/anthracite.json +0 -103
  265. package/src/theme/defaults/basalt.json +0 -101
  266. package/src/theme/defaults/birch.json +0 -105
  267. package/src/theme/defaults/dark-abyss.json +0 -101
  268. package/src/theme/defaults/dark-arctic.json +0 -114
  269. package/src/theme/defaults/dark-aurora.json +0 -105
  270. package/src/theme/defaults/dark-catppuccin.json +0 -117
  271. package/src/theme/defaults/dark-cavern.json +0 -101
  272. package/src/theme/defaults/dark-celestial.json +0 -116
  273. package/src/theme/defaults/dark-copper.json +0 -105
  274. package/src/theme/defaults/dark-cosmos.json +0 -100
  275. package/src/theme/defaults/dark-cyberpunk.json +0 -112
  276. package/src/theme/defaults/dark-dracula.json +0 -108
  277. package/src/theme/defaults/dark-eclipse.json +0 -101
  278. package/src/theme/defaults/dark-ember.json +0 -105
  279. package/src/theme/defaults/dark-equinox.json +0 -100
  280. package/src/theme/defaults/dark-forest.json +0 -106
  281. package/src/theme/defaults/dark-github.json +0 -115
  282. package/src/theme/defaults/dark-gruvbox.json +0 -122
  283. package/src/theme/defaults/dark-lavender.json +0 -105
  284. package/src/theme/defaults/dark-lunar.json +0 -99
  285. package/src/theme/defaults/dark-midnight.json +0 -105
  286. package/src/theme/defaults/dark-monochrome.json +0 -104
  287. package/src/theme/defaults/dark-monokai.json +0 -108
  288. package/src/theme/defaults/dark-nebula.json +0 -100
  289. package/src/theme/defaults/dark-neon-noir.json +0 -110
  290. package/src/theme/defaults/dark-nord.json +0 -108
  291. package/src/theme/defaults/dark-ocean.json +0 -111
  292. package/src/theme/defaults/dark-one.json +0 -110
  293. package/src/theme/defaults/dark-poimandres.json +0 -125
  294. package/src/theme/defaults/dark-rainforest.json +0 -101
  295. package/src/theme/defaults/dark-reef.json +0 -101
  296. package/src/theme/defaults/dark-retro.json +0 -102
  297. package/src/theme/defaults/dark-rose-pine.json +0 -106
  298. package/src/theme/defaults/dark-sakura.json +0 -105
  299. package/src/theme/defaults/dark-slate.json +0 -105
  300. package/src/theme/defaults/dark-solarized.json +0 -107
  301. package/src/theme/defaults/dark-solstice.json +0 -100
  302. package/src/theme/defaults/dark-starfall.json +0 -101
  303. package/src/theme/defaults/dark-sunset.json +0 -109
  304. package/src/theme/defaults/dark-swamp.json +0 -100
  305. package/src/theme/defaults/dark-synthwave.json +0 -113
  306. package/src/theme/defaults/dark-taiga.json +0 -101
  307. package/src/theme/defaults/dark-terminal.json +0 -105
  308. package/src/theme/defaults/dark-tokyo-night.json +0 -111
  309. package/src/theme/defaults/dark-tundra.json +0 -101
  310. package/src/theme/defaults/dark-twilight.json +0 -101
  311. package/src/theme/defaults/dark-volcanic.json +0 -101
  312. package/src/theme/defaults/graphite.json +0 -102
  313. package/src/theme/defaults/index.d.ts +0 -10289
  314. package/src/theme/defaults/index.ts +0 -203
  315. package/src/theme/defaults/light-arctic.json +0 -117
  316. package/src/theme/defaults/light-aurora-day.json +0 -101
  317. package/src/theme/defaults/light-canyon.json +0 -101
  318. package/src/theme/defaults/light-catppuccin.json +0 -116
  319. package/src/theme/defaults/light-cirrus.json +0 -100
  320. package/src/theme/defaults/light-coral.json +0 -105
  321. package/src/theme/defaults/light-cyberpunk.json +0 -106
  322. package/src/theme/defaults/light-dawn.json +0 -100
  323. package/src/theme/defaults/light-dunes.json +0 -101
  324. package/src/theme/defaults/light-eucalyptus.json +0 -105
  325. package/src/theme/defaults/light-forest.json +0 -110
  326. package/src/theme/defaults/light-frost.json +0 -105
  327. package/src/theme/defaults/light-github.json +0 -125
  328. package/src/theme/defaults/light-glacier.json +0 -101
  329. package/src/theme/defaults/light-gruvbox.json +0 -118
  330. package/src/theme/defaults/light-haze.json +0 -100
  331. package/src/theme/defaults/light-honeycomb.json +0 -105
  332. package/src/theme/defaults/light-lagoon.json +0 -101
  333. package/src/theme/defaults/light-lavender.json +0 -105
  334. package/src/theme/defaults/light-meadow.json +0 -101
  335. package/src/theme/defaults/light-mint.json +0 -105
  336. package/src/theme/defaults/light-monochrome.json +0 -111
  337. package/src/theme/defaults/light-ocean.json +0 -109
  338. package/src/theme/defaults/light-one.json +0 -109
  339. package/src/theme/defaults/light-opal.json +0 -101
  340. package/src/theme/defaults/light-orchard.json +0 -101
  341. package/src/theme/defaults/light-paper.json +0 -105
  342. package/src/theme/defaults/light-poimandres.json +0 -125
  343. package/src/theme/defaults/light-prism.json +0 -100
  344. package/src/theme/defaults/light-retro.json +0 -108
  345. package/src/theme/defaults/light-sand.json +0 -105
  346. package/src/theme/defaults/light-savanna.json +0 -101
  347. package/src/theme/defaults/light-solarized.json +0 -112
  348. package/src/theme/defaults/light-soleil.json +0 -100
  349. package/src/theme/defaults/light-sunset.json +0 -109
  350. package/src/theme/defaults/light-synthwave.json +0 -108
  351. package/src/theme/defaults/light-tokyo-night.json +0 -121
  352. package/src/theme/defaults/light-wetland.json +0 -101
  353. package/src/theme/defaults/light-zenith.json +0 -99
  354. package/src/theme/defaults/limestone.json +0 -104
  355. package/src/theme/defaults/mahogany.json +0 -107
  356. package/src/theme/defaults/marble.json +0 -103
  357. package/src/theme/defaults/obsidian.json +0 -101
  358. package/src/theme/defaults/onyx.json +0 -101
  359. package/src/theme/defaults/pearl.json +0 -103
  360. package/src/theme/defaults/porcelain.json +0 -101
  361. package/src/theme/defaults/quartz.json +0 -106
  362. package/src/theme/defaults/sandstone.json +0 -105
  363. package/src/theme/defaults/titanium.json +0 -100
@@ -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", " log tail unavailable"));
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) return [title, noteText("log tail unavailable")];
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(options.mode === "full" ? "Full log:" : `Last ${options.tail} log lines:`);
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 { Ellipsis, fileHyperlink, renderFileList, renderStatusLine, renderTreeList, truncateToWidth } from "../render";
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 [header, ...listLines].map(l => truncateToWidth(l, width, Ellipsis.Omit));
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 [header, ...fileLines, ...extraLines].map(l => truncateToWidth(l, width, Ellipsis.Omit));
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 [header, ...listLines].map(l => truncateToWidth(l, width, Ellipsis.Omit));
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 [header, ...matchLines, ...extraLines].map(l => truncateToWidth(l, width, Ellipsis.Omit));
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
  // =============================================================================
@@ -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. */
@@ -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) return 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) };
@@ -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. The positional form remains the
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 become expandable nodes labelled with
78
- * their key and size, scalars become `key: value` leaves styled by type.
79
- * Bounded by depth, node count and scalar length; no width math.
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;
@@ -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. The positional form remains the
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
- id: nextId++,
241
- key,
242
- value: nodeValue,
243
- depth,
244
- kind: jsonNodeKind(nodeValue),
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
- let roots: readonly JsonTreeNode[];
248
- if (isRecord(value)) {
249
- const objectRoots: JsonTreeNode[] = [];
250
- for (const key in value) {
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 = values.map((child, index) => node(child, `[${index}]`, item.depth + 1));
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
- const objectChildren: JsonTreeNode[] = [];
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
- for (let index = 0; index < value.length; index++) out.push([`[${index}]`, value[index]]);
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): string {
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 become expandable nodes labelled with
435
- * their key and size, scalars become `key: value` leaves styled by type.
436
- * Bounded by depth, node count and scalar length; no width math.
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
- const [key, child] = entries[index];
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 = (key: string | undefined, entry: unknown, depth: number): TspTreeNode => {
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), "muted")];
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
+ }
@@ -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
  }