@linxiraos/pi-tui 1.4.6 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/CHANGELOG.md +162 -244
  2. package/README.md +41 -35
  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/charts/table-data.d.ts +4 -2
  7. package/dist/types/chat/assistant-message.d.ts +15 -3
  8. package/dist/types/chat/bash-execution.d.ts +6 -1
  9. package/dist/types/chat/display-preferences.d.ts +2 -0
  10. package/dist/types/chat/eval-execution.d.ts +2 -0
  11. package/dist/types/chat/execution-shared.d.ts +14 -8
  12. package/dist/types/chat/extension-types.d.ts +31 -0
  13. package/dist/types/chat/figure-markdown.d.ts +2 -0
  14. package/dist/types/chat/reply-write.d.ts +48 -0
  15. package/dist/types/chat/svg-figure.d.ts +5 -0
  16. package/dist/types/chat/table-chart.d.ts +6 -3
  17. package/dist/types/chat/tool-execution.d.ts +1 -2
  18. package/dist/types/chat/transcript-outline.d.ts +7 -0
  19. package/dist/types/chat/transcript-render-helpers.d.ts +13 -3
  20. package/dist/types/chrome/dynamic-border.d.ts +6 -0
  21. package/dist/types/chrome/index.d.ts +1 -0
  22. package/dist/types/chrome/transcript-notice.d.ts +35 -0
  23. package/dist/types/chrome/transcript-status.d.ts +21 -9
  24. package/dist/types/components/editor.d.ts +23 -6
  25. package/dist/types/components/image.d.ts +6 -0
  26. package/dist/types/components/loader.d.ts +2 -0
  27. package/dist/types/components/markdown.d.ts +7 -0
  28. package/dist/types/keybinding-matchers.d.ts +7 -0
  29. package/dist/types/native/blobs.d.ts +2 -1
  30. package/dist/types/native/describe.d.ts +4 -2
  31. package/dist/types/native/node.d.ts +2 -3
  32. package/dist/types/native/overlay.d.ts +42 -2
  33. package/dist/types/native/picker.d.ts +4 -4
  34. package/dist/types/native/state.d.ts +4 -0
  35. package/dist/types/overlays/annotation-overlay.d.ts +7 -1
  36. package/dist/types/overlays/annotation-types.d.ts +28 -0
  37. package/dist/types/overlays/btw-history-panel.d.ts +15 -0
  38. package/dist/types/overlays/btw-history.d.ts +24 -0
  39. package/dist/types/overlays/btw-inject.d.ts +22 -0
  40. package/dist/types/overlays/btw-panel.d.ts +7 -0
  41. package/dist/types/overlays/hook-editor.d.ts +2 -0
  42. package/dist/types/overlays/jobs-panel.d.ts +4 -0
  43. package/dist/types/overlays/login-dialog.d.ts +5 -1
  44. package/dist/types/overlays/model-browser.d.ts +11 -2
  45. package/dist/types/overlays/oauth-selector.d.ts +23 -0
  46. package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
  47. package/dist/types/overlays/rewind-selector.d.ts +1 -1
  48. package/dist/types/overlays/session-selector.d.ts +33 -4
  49. package/dist/types/prompt/composer.d.ts +56 -5
  50. package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
  51. package/dist/types/render/extension-links.d.ts +65 -0
  52. package/dist/types/render/hyperlink.d.ts +25 -7
  53. package/dist/types/render/index.d.ts +1 -0
  54. package/dist/types/render/render-utils.d.ts +23 -1
  55. package/dist/types/setup/scenes/glyph.d.ts +1 -1
  56. package/dist/types/setup/scenes/model.d.ts +1 -1
  57. package/dist/types/setup/scenes/outro.d.ts +5 -4
  58. package/dist/types/setup/scenes/sign-in.d.ts +13 -8
  59. package/dist/types/setup/scenes/types.d.ts +16 -1
  60. package/dist/types/setup/startup-splash.d.ts +1 -1
  61. package/dist/types/setup/wizard-overlay.d.ts +11 -7
  62. package/dist/types/setup/wizard.d.ts +5 -1
  63. package/dist/types/status-line/component.d.ts +1 -1
  64. package/dist/types/status-line/context-usage.d.ts +28 -6
  65. package/dist/types/status-line/host.d.ts +6 -2
  66. package/dist/types/status-line/startup.d.ts +0 -15
  67. package/dist/types/terminal-capabilities.d.ts +1 -1
  68. package/dist/types/theme/symbols.d.ts +3 -1
  69. package/dist/types/theme/theme-class.d.ts +1 -0
  70. package/dist/types/theme/theme.d.ts +1 -24
  71. package/dist/types/theme/tui-adapters.d.ts +2 -0
  72. package/dist/types/thinking.d.ts +8 -6
  73. package/dist/types/tools/ast-grep.d.ts +2 -0
  74. package/dist/types/tools/bash-interactive.d.ts +6 -0
  75. package/dist/types/tools/bash.d.ts +2 -0
  76. package/dist/types/tools/default-renderer.d.ts +6 -4
  77. package/dist/types/tools/eval.d.ts +2 -0
  78. package/dist/types/tools/find.d.ts +1 -1
  79. package/dist/types/tools/grouped-file-output.d.ts +100 -19
  80. package/dist/types/tools/hashline-format.d.ts +5 -0
  81. package/dist/types/tools/irc.d.ts +6 -0
  82. package/dist/types/tools/json-tree.d.ts +23 -4
  83. package/dist/types/tools/lsp.d.ts +2 -0
  84. package/dist/types/tools/mcp.d.ts +6 -5
  85. package/dist/types/tools/native-view.d.ts +3 -1
  86. package/dist/types/tools/output-meta.d.ts +27 -0
  87. package/dist/types/tools/read.d.ts +14 -4
  88. package/dist/types/tools/renderer.d.ts +2 -0
  89. package/dist/types/tools/streaming-output.d.ts +11 -0
  90. package/dist/types/tools/task.d.ts +13 -4
  91. package/dist/types/tools/url-scheme-host.d.ts +17 -0
  92. package/dist/types/tools/wait.d.ts +2 -0
  93. package/dist/types/tools/yield.d.ts +1 -1
  94. package/dist/types/tui.d.ts +19 -2
  95. package/dist/types/utils.d.ts +4 -0
  96. package/package.json +10 -14
  97. package/src/app-keybindings.d.ts +20 -0
  98. package/src/app-keybindings.ts +20 -0
  99. package/src/apps/git/git-tui.ts +10 -17
  100. package/src/apps/git/sidebar.ts +21 -35
  101. package/src/apps/ps-top.ts +4 -12
  102. package/src/apps/session-picker.ts +7 -0
  103. package/src/charts/chart-plan.d.ts +9 -7
  104. package/src/charts/chart-plan.ts +20 -79
  105. package/src/charts/table-data.d.ts +4 -2
  106. package/src/charts/table-data.ts +55 -6
  107. package/src/chat/advisor-message.ts +2 -0
  108. package/src/chat/assistant-message.d.ts +15 -3
  109. package/src/chat/assistant-message.ts +137 -19
  110. package/src/chat/background-tan-message.ts +4 -0
  111. package/src/chat/bash-execution.d.ts +6 -1
  112. package/src/chat/bash-execution.ts +26 -9
  113. package/src/chat/chat-transcript-builder.ts +63 -30
  114. package/src/chat/compaction-summary-message.ts +2 -1
  115. package/src/chat/display-preferences.d.ts +2 -0
  116. package/src/chat/display-preferences.ts +3 -0
  117. package/src/chat/eval-execution.d.ts +2 -0
  118. package/src/chat/eval-execution.ts +14 -7
  119. package/src/chat/execution-shared.d.ts +14 -8
  120. package/src/chat/execution-shared.ts +39 -18
  121. package/src/chat/extension-types.d.ts +31 -0
  122. package/src/chat/extension-types.ts +34 -0
  123. package/src/chat/figure-markdown.d.ts +2 -0
  124. package/src/chat/figure-markdown.ts +6 -4
  125. package/src/chat/read-tool-group.ts +56 -36
  126. package/src/chat/reply-write.d.ts +48 -0
  127. package/src/chat/reply-write.ts +127 -0
  128. package/src/chat/svg-figure.d.ts +5 -0
  129. package/src/chat/svg-figure.ts +55 -16
  130. package/src/chat/table-chart.d.ts +6 -3
  131. package/src/chat/table-chart.ts +29 -6
  132. package/src/chat/tool-execution.d.ts +1 -2
  133. package/src/chat/tool-execution.ts +20 -13
  134. package/src/chat/transcript-outline.d.ts +7 -0
  135. package/src/chat/transcript-outline.ts +27 -0
  136. package/src/chat/transcript-render-helpers.d.ts +13 -3
  137. package/src/chat/transcript-render-helpers.ts +134 -44
  138. package/src/chrome/dynamic-border.d.ts +6 -0
  139. package/src/chrome/dynamic-border.ts +28 -2
  140. package/src/chrome/index.ts +1 -0
  141. package/src/chrome/transcript-notice.d.ts +35 -0
  142. package/src/chrome/transcript-notice.ts +83 -0
  143. package/src/chrome/transcript-status.d.ts +21 -9
  144. package/src/chrome/transcript-status.ts +32 -30
  145. package/src/components/editor.d.ts +23 -6
  146. package/src/components/editor.ts +133 -25
  147. package/src/components/image.d.ts +6 -0
  148. package/src/components/image.ts +13 -0
  149. package/src/components/key-value-list.ts +9 -9
  150. package/src/components/loader.d.ts +2 -0
  151. package/src/components/loader.ts +7 -0
  152. package/src/components/markdown.d.ts +7 -0
  153. package/src/components/markdown.ts +116 -6
  154. package/src/components/section.ts +1 -9
  155. package/src/components/table.ts +1 -9
  156. package/src/hotkeys-markdown.ts +1 -0
  157. package/src/keybinding-matchers.d.ts +7 -0
  158. package/src/keybinding-matchers.ts +13 -0
  159. package/src/native/backend.ts +10 -67
  160. package/src/native/blobs.d.ts +2 -1
  161. package/src/native/blobs.ts +3 -2
  162. package/src/native/describe.d.ts +4 -2
  163. package/src/native/describe.ts +9 -4
  164. package/src/native/node.d.ts +2 -3
  165. package/src/native/node.ts +2 -3
  166. package/src/native/overlay.d.ts +42 -2
  167. package/src/native/overlay.ts +124 -16
  168. package/src/native/picker.d.ts +4 -4
  169. package/src/native/picker.ts +4 -4
  170. package/src/native/state.d.ts +4 -0
  171. package/src/native/state.ts +25 -5
  172. package/src/overlays/advisor-config.ts +1 -10
  173. package/src/overlays/annotation-overlay.ts +125 -37
  174. package/src/overlays/annotation-types.ts +24 -0
  175. package/src/overlays/btw-history-panel.ts +106 -14
  176. package/src/overlays/btw-history.ts +65 -0
  177. package/src/overlays/btw-inject.ts +91 -0
  178. package/src/overlays/btw-panel.ts +53 -12
  179. package/src/overlays/extensions/extension-dashboard.ts +7 -8
  180. package/src/overlays/hook-editor.ts +6 -0
  181. package/src/overlays/hook-selector.ts +2 -2
  182. package/src/overlays/jobs-panel.ts +82 -22
  183. package/src/overlays/login-dialog.ts +39 -31
  184. package/src/overlays/mcp-add-wizard.ts +1 -1
  185. package/src/overlays/model-browser.ts +106 -10
  186. package/src/overlays/model-hub.ts +1 -7
  187. package/src/overlays/model-picker.ts +1 -10
  188. package/src/overlays/oauth-selector.ts +44 -6
  189. package/src/overlays/plan-review-overlay.ts +13 -2
  190. package/src/overlays/rewind-selector.ts +29 -12
  191. package/src/overlays/session-selector.ts +338 -47
  192. package/src/overlays/settings-defs.ts +2 -2
  193. package/src/overlays/tree-selector.ts +83 -27
  194. package/src/overlays/usage-dashboard.ts +9 -18
  195. package/src/prompt/composer.ts +233 -6
  196. package/src/prompt/custom-editor.ts +6 -1
  197. package/src/prompt/emoji-autocomplete.ts +0 -2
  198. package/src/prompt/interactive-context-helpers.ts +29 -4
  199. package/src/render/code-cell.ts +1 -1
  200. package/src/render/extension-links.d.ts +65 -0
  201. package/src/render/extension-links.ts +214 -0
  202. package/src/render/file-list.ts +4 -7
  203. package/src/render/hyperlink.d.ts +25 -7
  204. package/src/render/hyperlink.ts +65 -9
  205. package/src/render/index.d.ts +1 -0
  206. package/src/render/index.ts +1 -0
  207. package/src/render/render-utils.d.ts +23 -1
  208. package/src/render/render-utils.ts +38 -6
  209. package/src/setup/scenes/composer.ts +2 -0
  210. package/src/setup/scenes/glyph.ts +4 -2
  211. package/src/setup/scenes/model.ts +192 -29
  212. package/src/setup/scenes/outro.ts +33 -15
  213. package/src/setup/scenes/sign-in.ts +196 -400
  214. package/src/setup/scenes/theme.ts +2 -0
  215. package/src/setup/scenes/types.ts +18 -1
  216. package/src/setup/startup-splash.ts +8 -7
  217. package/src/setup/wizard-overlay.ts +164 -35
  218. package/src/setup/wizard.ts +11 -2
  219. package/src/status-line/component.ts +4 -10
  220. package/src/status-line/context-usage.ts +72 -21
  221. package/src/status-line/host.ts +6 -2
  222. package/src/status-line/startup.ts +36 -70
  223. package/src/terminal-capabilities.d.ts +1 -1
  224. package/src/terminal-capabilities.ts +5 -0
  225. package/src/terminal.ts +24 -2
  226. package/src/theme/defaults.json +1 -0
  227. package/src/theme/loader.ts +1 -1
  228. package/src/theme/symbols.d.ts +3 -1
  229. package/src/theme/symbols.ts +16 -9
  230. package/src/theme/theme-class.d.ts +1 -0
  231. package/src/theme/theme-class.ts +15 -3
  232. package/src/theme/theme.d.ts +1 -24
  233. package/src/theme/theme.ts +3 -75
  234. package/src/theme/tui-adapters.d.ts +2 -0
  235. package/src/theme/tui-adapters.ts +8 -3
  236. package/src/thinking.d.ts +8 -6
  237. package/src/thinking.ts +17 -11
  238. package/src/tmux.ts +1 -0
  239. package/src/tools/agent-tree.ts +13 -11
  240. package/src/tools/ask.ts +24 -37
  241. package/src/tools/ast-edit.ts +48 -93
  242. package/src/tools/ast-grep.d.ts +2 -0
  243. package/src/tools/ast-grep.ts +31 -67
  244. package/src/tools/bash-interactive.d.ts +49 -0
  245. package/src/tools/bash-interactive.ts +6 -1
  246. package/src/tools/bash.d.ts +2 -0
  247. package/src/tools/bash.ts +9 -0
  248. package/src/tools/default-renderer.d.ts +6 -4
  249. package/src/tools/default-renderer.ts +10 -7
  250. package/src/tools/edit.ts +50 -43
  251. package/src/tools/eval.d.ts +2 -0
  252. package/src/tools/eval.ts +16 -4
  253. package/src/tools/fetch.ts +2 -1
  254. package/src/tools/find.d.ts +1 -1
  255. package/src/tools/find.ts +13 -5
  256. package/src/tools/github.ts +14 -46
  257. package/src/tools/glob.ts +2 -1
  258. package/src/tools/grep.ts +47 -277
  259. package/src/tools/grouped-file-output.d.ts +100 -19
  260. package/src/tools/grouped-file-output.ts +414 -103
  261. package/src/tools/hashline-format.d.ts +5 -0
  262. package/src/tools/hashline-format.ts +5 -0
  263. package/src/tools/irc.d.ts +6 -0
  264. package/src/tools/irc.ts +6 -0
  265. package/src/tools/job-widget.ts +13 -1
  266. package/src/tools/json-tree.d.ts +23 -4
  267. package/src/tools/json-tree.ts +132 -46
  268. package/src/tools/lsp.d.ts +2 -0
  269. package/src/tools/lsp.ts +246 -47
  270. package/src/tools/mcp.d.ts +6 -5
  271. package/src/tools/mcp.ts +20 -12
  272. package/src/tools/native-view.d.ts +3 -1
  273. package/src/tools/native-view.ts +12 -6
  274. package/src/tools/output-meta.d.ts +27 -0
  275. package/src/tools/output-meta.ts +68 -4
  276. package/src/tools/proc-render.ts +3 -3
  277. package/src/tools/read.d.ts +14 -4
  278. package/src/tools/read.ts +20 -5
  279. package/src/tools/renderer.d.ts +2 -0
  280. package/src/tools/renderer.ts +2 -0
  281. package/src/tools/streaming-output.d.ts +11 -0
  282. package/src/tools/streaming-output.ts +41 -0
  283. package/src/tools/task.d.ts +13 -4
  284. package/src/tools/task.ts +100 -97
  285. package/src/tools/url-scheme-host.d.ts +17 -0
  286. package/src/tools/url-scheme-host.ts +21 -0
  287. package/src/tools/vibe.ts +4 -4
  288. package/src/tools/wait.d.ts +2 -0
  289. package/src/tools/wait.ts +8 -5
  290. package/src/tools/write.ts +17 -27
  291. package/src/tools/yield.d.ts +1 -1
  292. package/src/tools/yield.ts +19 -10
  293. package/src/tui.d.ts +19 -2
  294. package/src/tui.ts +134 -24
  295. package/src/utils.d.ts +4 -0
  296. package/src/utils.ts +10 -0
  297. package/dist/types/theme/defaults/index.d.ts +0 -10289
  298. package/src/theme/defaults/alabaster.json +0 -103
  299. package/src/theme/defaults/amethyst.json +0 -106
  300. package/src/theme/defaults/anthracite.json +0 -103
  301. package/src/theme/defaults/basalt.json +0 -101
  302. package/src/theme/defaults/birch.json +0 -105
  303. package/src/theme/defaults/dark-abyss.json +0 -101
  304. package/src/theme/defaults/dark-arctic.json +0 -114
  305. package/src/theme/defaults/dark-aurora.json +0 -105
  306. package/src/theme/defaults/dark-catppuccin.json +0 -117
  307. package/src/theme/defaults/dark-cavern.json +0 -101
  308. package/src/theme/defaults/dark-celestial.json +0 -116
  309. package/src/theme/defaults/dark-copper.json +0 -105
  310. package/src/theme/defaults/dark-cosmos.json +0 -100
  311. package/src/theme/defaults/dark-cyberpunk.json +0 -112
  312. package/src/theme/defaults/dark-dracula.json +0 -108
  313. package/src/theme/defaults/dark-eclipse.json +0 -101
  314. package/src/theme/defaults/dark-ember.json +0 -105
  315. package/src/theme/defaults/dark-equinox.json +0 -100
  316. package/src/theme/defaults/dark-forest.json +0 -106
  317. package/src/theme/defaults/dark-github.json +0 -115
  318. package/src/theme/defaults/dark-gruvbox.json +0 -122
  319. package/src/theme/defaults/dark-lavender.json +0 -105
  320. package/src/theme/defaults/dark-lunar.json +0 -99
  321. package/src/theme/defaults/dark-midnight.json +0 -105
  322. package/src/theme/defaults/dark-monochrome.json +0 -104
  323. package/src/theme/defaults/dark-monokai.json +0 -108
  324. package/src/theme/defaults/dark-nebula.json +0 -100
  325. package/src/theme/defaults/dark-neon-noir.json +0 -110
  326. package/src/theme/defaults/dark-nord.json +0 -108
  327. package/src/theme/defaults/dark-ocean.json +0 -111
  328. package/src/theme/defaults/dark-one.json +0 -110
  329. package/src/theme/defaults/dark-poimandres.json +0 -125
  330. package/src/theme/defaults/dark-rainforest.json +0 -101
  331. package/src/theme/defaults/dark-reef.json +0 -101
  332. package/src/theme/defaults/dark-retro.json +0 -102
  333. package/src/theme/defaults/dark-rose-pine.json +0 -106
  334. package/src/theme/defaults/dark-sakura.json +0 -105
  335. package/src/theme/defaults/dark-slate.json +0 -105
  336. package/src/theme/defaults/dark-solarized.json +0 -107
  337. package/src/theme/defaults/dark-solstice.json +0 -100
  338. package/src/theme/defaults/dark-starfall.json +0 -101
  339. package/src/theme/defaults/dark-sunset.json +0 -109
  340. package/src/theme/defaults/dark-swamp.json +0 -100
  341. package/src/theme/defaults/dark-synthwave.json +0 -113
  342. package/src/theme/defaults/dark-taiga.json +0 -101
  343. package/src/theme/defaults/dark-terminal.json +0 -105
  344. package/src/theme/defaults/dark-tokyo-night.json +0 -111
  345. package/src/theme/defaults/dark-tundra.json +0 -101
  346. package/src/theme/defaults/dark-twilight.json +0 -101
  347. package/src/theme/defaults/dark-volcanic.json +0 -101
  348. package/src/theme/defaults/graphite.json +0 -102
  349. package/src/theme/defaults/index.d.ts +0 -10289
  350. package/src/theme/defaults/index.ts +0 -203
  351. package/src/theme/defaults/light-arctic.json +0 -117
  352. package/src/theme/defaults/light-aurora-day.json +0 -101
  353. package/src/theme/defaults/light-canyon.json +0 -101
  354. package/src/theme/defaults/light-catppuccin.json +0 -116
  355. package/src/theme/defaults/light-cirrus.json +0 -100
  356. package/src/theme/defaults/light-coral.json +0 -105
  357. package/src/theme/defaults/light-cyberpunk.json +0 -106
  358. package/src/theme/defaults/light-dawn.json +0 -100
  359. package/src/theme/defaults/light-dunes.json +0 -101
  360. package/src/theme/defaults/light-eucalyptus.json +0 -105
  361. package/src/theme/defaults/light-forest.json +0 -110
  362. package/src/theme/defaults/light-frost.json +0 -105
  363. package/src/theme/defaults/light-github.json +0 -125
  364. package/src/theme/defaults/light-glacier.json +0 -101
  365. package/src/theme/defaults/light-gruvbox.json +0 -118
  366. package/src/theme/defaults/light-haze.json +0 -100
  367. package/src/theme/defaults/light-honeycomb.json +0 -105
  368. package/src/theme/defaults/light-lagoon.json +0 -101
  369. package/src/theme/defaults/light-lavender.json +0 -105
  370. package/src/theme/defaults/light-meadow.json +0 -101
  371. package/src/theme/defaults/light-mint.json +0 -105
  372. package/src/theme/defaults/light-monochrome.json +0 -111
  373. package/src/theme/defaults/light-ocean.json +0 -109
  374. package/src/theme/defaults/light-one.json +0 -109
  375. package/src/theme/defaults/light-opal.json +0 -101
  376. package/src/theme/defaults/light-orchard.json +0 -101
  377. package/src/theme/defaults/light-paper.json +0 -105
  378. package/src/theme/defaults/light-poimandres.json +0 -125
  379. package/src/theme/defaults/light-prism.json +0 -100
  380. package/src/theme/defaults/light-retro.json +0 -108
  381. package/src/theme/defaults/light-sand.json +0 -105
  382. package/src/theme/defaults/light-savanna.json +0 -101
  383. package/src/theme/defaults/light-solarized.json +0 -112
  384. package/src/theme/defaults/light-soleil.json +0 -100
  385. package/src/theme/defaults/light-sunset.json +0 -109
  386. package/src/theme/defaults/light-synthwave.json +0 -108
  387. package/src/theme/defaults/light-tokyo-night.json +0 -121
  388. package/src/theme/defaults/light-wetland.json +0 -101
  389. package/src/theme/defaults/light-zenith.json +0 -99
  390. package/src/theme/defaults/limestone.json +0 -104
  391. package/src/theme/defaults/mahogany.json +0 -107
  392. package/src/theme/defaults/marble.json +0 -103
  393. package/src/theme/defaults/obsidian.json +0 -101
  394. package/src/theme/defaults/onyx.json +0 -101
  395. package/src/theme/defaults/pearl.json +0 -103
  396. package/src/theme/defaults/porcelain.json +0 -101
  397. package/src/theme/defaults/quartz.json +0 -106
  398. package/src/theme/defaults/sandstone.json +0 -105
  399. package/src/theme/defaults/titanium.json +0 -100
@@ -52,8 +52,6 @@ const EMOTICONS: ReadonlyArray<readonly [pattern: string, char: string]> = [
52
52
  ["<3", "❤️"],
53
53
  ["xD", "😆"],
54
54
  ["XD", "😆"],
55
- ["B)", "😎"],
56
- ["8)", "😎"],
57
55
  ];
58
56
 
59
57
  const MAX_SUGGESTIONS = 12;
@@ -3,12 +3,17 @@ import type { AssistantMessage, Model, TextContent } from "@linxiraos/pi-ai";
3
3
  import { getMarkdownLinkUrls } from "../index";
4
4
  import { EMPTY_LINK_TARGETS } from "../render/render-utils";
5
5
  import type { ImageBudget } from "../components/image";
6
- import type { AssistantThinkingRenderer } from "../chat/extension-types";
6
+ import type { AssistantTextRenderer, AssistantThinkingRenderer } from "../chat/extension-types";
7
7
  import { AssistantMessageComponent } from "../chat/assistant-message";
8
+ import { ReplyWriteComponent } from "../chat/reply-write";
8
9
  /** Session display capabilities supplied unchanged by the interactive host. */
9
10
  export interface AssistantMessageSession {
10
11
  readonly model?: Model;
11
- readonly extensionRunner?: { getAssistantThinkingRenderers(): readonly AssistantThinkingRenderer[] };
12
+ readonly extensionRunner?: {
13
+ getAssistantThinkingRenderers(): readonly AssistantThinkingRenderer[];
14
+ /** Empty while the setting that enables them is off; hosts predating it may omit it. */
15
+ getAssistantTextRenderers?(): readonly AssistantTextRenderer[];
16
+ };
12
17
  }
13
18
 
14
19
  /** Host state required to construct and refresh assistant transcript segments. */
@@ -109,12 +114,15 @@ export function assistantMessageLinkTargets(
109
114
  /**
110
115
  * Construct an {@link AssistantMessageComponent} wired to the live context's
111
116
  * thinking/image settings. `message` is omitted for the streaming placeholder
112
- * component and supplied when rendering a persisted turn.
117
+ * component and supplied when rendering a persisted turn. `contentOffset` is
118
+ * the index in the full reply of the first block of a segment drawn after a
119
+ * tool call, so extension text renderers see the reply's own block indexes.
113
120
  */
114
121
  export function createAssistantMessageComponent(
115
122
  ctx: AssistantMessageHost,
116
123
  message?: AssistantMessage,
117
124
  linkTargets: ReadonlyMap<string, string> = getAssistantMessageLinkTargets(ctx),
125
+ contentOffset = 0,
118
126
  ): AssistantMessageComponent {
119
127
  const component = new AssistantMessageComponent(
120
128
  message,
@@ -125,7 +133,25 @@ export function createAssistantMessageComponent(
125
133
  ctx.proseOnlyThinking,
126
134
  linkTargets,
127
135
  ctx.expandThinkingBlocks,
136
+ { renderers: ctx.viewSession.extensionRunner?.getAssistantTextRenderers?.() ?? [], contentOffset },
128
137
  );
138
+ applyHostDisplay(ctx, component);
139
+ return component;
140
+ }
141
+
142
+ /** Construct a {@link ReplyWriteComponent} (an `out://` write) drawn like the context's assistant prose. */
143
+ export function createReplyWriteComponent(ctx: AssistantMessageHost): ReplyWriteComponent {
144
+ const component = new ReplyWriteComponent({
145
+ requestRender: () => ctx.ui.requestRender(),
146
+ imageBudget: ctx.ui.imageBudget,
147
+ linkTargets: getAssistantMessageLinkTargets(ctx),
148
+ });
149
+ applyHostDisplay(ctx, component);
150
+ return component;
151
+ }
152
+
153
+ /** Apply the context's image, chart, expansion, and scrollback-publication display state. */
154
+ function applyHostDisplay(ctx: AssistantMessageHost, component: AssistantMessageComponent): void {
129
155
  component.setImagesVisible(ctx.assistantImagesVisible);
130
156
  component.setTableChartsVisible(ctx.tableChartsVisible);
131
157
  component.setToolResultImagesVisible(!ctx.hideToolActivity);
@@ -136,5 +162,4 @@ export function createAssistantMessageComponent(
136
162
  const compat = ctx.viewSession.model?.compat;
137
163
  const wireRevisable = compat !== undefined && "streamRevision" in compat && compat.streamRevision === "possible";
138
164
  component.setMidStreamPublication(!wireRevisable);
139
- return component;
140
165
  }
@@ -74,7 +74,7 @@ function formatHeader(options: CodeCellOptions, theme: Theme): { title: string;
74
74
  if (status) {
75
75
  const icon = formatStatusIcon(
76
76
  status === "complete"
77
- ? "done"
77
+ ? "success"
78
78
  : status === "error"
79
79
  ? "error"
80
80
  : status === "warning"
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Set the registered schemes (lowercase, without `:`). Bumps {@link extensionLinksVersion} on any
3
+ * change so cached markdown renders are redrawn.
4
+ */
5
+ export declare function setExtensionLinks(next: Iterable<string>): void;
6
+ /** Changes whenever the scheme set changes; part of the markdown render cache key. */
7
+ export declare function extensionLinksVersion(): number;
8
+ /**
9
+ * Whether activating a registered-scheme link (a click or a hint tag) reaches its extension: a
10
+ * scheme is registered and the terminal is plain.
11
+ */
12
+ export declare function extensionLinksRouted(): boolean;
13
+ /**
14
+ * Set by the interactive product: whether the user has a way to pick a link drawn now (a bound
15
+ * hint key, mouse clicks). `undefined` when nothing in this process can pick one.
16
+ */
17
+ export declare function setExtensionLinkPicking(provider: (() => boolean) | undefined): void;
18
+ /**
19
+ * Whether a registered-scheme link drawn now can be activated: links are routed and the product
20
+ * offers a way to pick them. Process-wide, so a UI-less extension runner (a subagent's, whose
21
+ * transcript the user may focus) answers like the interactive one.
22
+ */
23
+ export declare function extensionLinkClicksAvailable(): boolean;
24
+ /** The registered scheme `href` uses, or `undefined` for every other link. */
25
+ export declare function extensionLinkScheme(href: string): string | undefined;
26
+ /**
27
+ * Draw an extension link's label: dotted-underlined (plain underline where the terminal has no
28
+ * styled underlines, re-applied after any style reset inside it) and wrapped in the OSC 8 marker
29
+ * {@link extensionLinkLabels} reads back in a plain terminal; as given in Tern's native view. Never
30
+ * followed by a ` (url)` suffix. `key` tells apart links of one URL drawn near each other; it must
31
+ * not change between renders of the same text, or rows rendered twice stop matching.
32
+ */
33
+ export declare function formatExtensionLink(label: string, href: string, key: string): string;
34
+ /**
35
+ * Tags for `count` links in keyboard link-hint mode: single letters while they suffice, otherwise
36
+ * two letters each, so no tag is a prefix of another. At most the alphabet squared (676) are made;
37
+ * links past that stay untagged.
38
+ */
39
+ export declare function linkHintTags(count: number): string[];
40
+ /**
41
+ * `line` without omp's extension-link markers (the OSC 8 open and close around each label), for
42
+ * terminal output. Every other hyperlink is kept as is.
43
+ */
44
+ export declare function stripExtensionLinkMarkers(line: string): string;
45
+ /** One extension link label drawn on a rendered row (before {@link stripExtensionLinkMarkers}). */
46
+ export interface ExtensionLinkLabel {
47
+ readonly url: string;
48
+ /**
49
+ * The marker's params, unique to each drawn link and repeated on every row a wrapped label
50
+ * spans, so a row's parts of one label can be told from an adjacent label of the same URL.
51
+ */
52
+ readonly id: string;
53
+ /** First 0-based cell the label covers. */
54
+ readonly start: number;
55
+ /** Cell just past the label. */
56
+ readonly end: number;
57
+ /** Whether only blank cells follow the label on its row, so a wrapped label may go on below. */
58
+ readonly endsRow: boolean;
59
+ }
60
+ /**
61
+ * The extension link labels drawn on a rendered row, left to right. Only omp's own markers with a
62
+ * registered scheme match, so ordinary hyperlinks (even of a registered scheme) and rows drawn for
63
+ * a scheme that is no longer registered never do.
64
+ */
65
+ export declare function extensionLinkLabels(line: string): ExtensionLinkLabel[];
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Links whose scheme an extension registered (`pi.registerLinkScheme`). Markdown draws them
3
+ * without the ` (url)` suffix. In a plain terminal the rendered row carries an OSC 8 marker with the
4
+ * URL so a click's cell or a hint tag can be traced back to it ({@link extensionLinkLabels}); the TUI
5
+ * strips that marker from every row it writes ({@link stripExtensionLinkMarkers}), so the terminal
6
+ * never receives the link as a hyperlink it could open.
7
+ */
8
+ import { isNativeRendering, onNativeRenderingChange } from "../native/state";
9
+ import { TERMINAL } from "../terminal-capabilities";
10
+ import { visibleWidth } from "../utils";
11
+
12
+ let schemes: ReadonlySet<string> = new Set();
13
+ let version = 0;
14
+ let pickingProvider: (() => boolean) | undefined;
15
+ // Tern's native view routes its own link clicks, so markers are drawn only for a plain terminal.
16
+ onNativeRenderingChange(() => {
17
+ version++;
18
+ });
19
+
20
+ /** One OSC 8 sequence (BEL or ST terminated); group 1 is its params, group 2 its URI (empty for a close). */
21
+ const OSC8_PATTERN = /\x1b\]8;([^;\x07\x1b]*);([^\x07\x1b]*)(?:\x07|\x1b\\)/g;
22
+
23
+ /**
24
+ * The OSC 8 params tagging omp's own markers, so they are stripped from terminal output even after
25
+ * their scheme is no longer registered. Each drawn link gets its own `-<n>` suffix, derived from the
26
+ * link itself so every render of the same text draws the same bytes; a label wrapped across rows
27
+ * repeats its marker, suffix included, on every row.
28
+ */
29
+ const MARKER_ID = "id=omp-extension-link";
30
+ const MARKER_PARAMS_PATTERN = /^id=omp-extension-link(?:-\d+)?$/;
31
+ const MARKER_OPEN = `\x1b]8;${MARKER_ID}`;
32
+
33
+ /**
34
+ * Set the registered schemes (lowercase, without `:`). Bumps {@link extensionLinksVersion} on any
35
+ * change so cached markdown renders are redrawn.
36
+ */
37
+ export function setExtensionLinks(next: Iterable<string>): void {
38
+ const nextSchemes = new Set(next);
39
+ if (nextSchemes.size === schemes.size && [...nextSchemes].every(s => schemes.has(s))) return;
40
+ schemes = nextSchemes;
41
+ version++;
42
+ }
43
+
44
+ /** Changes whenever the scheme set changes; part of the markdown render cache key. */
45
+ export function extensionLinksVersion(): number {
46
+ return version;
47
+ }
48
+
49
+ /**
50
+ * Whether activating a registered-scheme link (a click or a hint tag) reaches its extension: a
51
+ * scheme is registered and the terminal is plain.
52
+ */
53
+ export function extensionLinksRouted(): boolean {
54
+ return schemes.size > 0 && !isNativeRendering();
55
+ }
56
+
57
+ /**
58
+ * Set by the interactive product: whether the user has a way to pick a link drawn now (a bound
59
+ * hint key, mouse clicks). `undefined` when nothing in this process can pick one.
60
+ */
61
+ export function setExtensionLinkPicking(provider: (() => boolean) | undefined): void {
62
+ pickingProvider = provider;
63
+ }
64
+
65
+ /**
66
+ * Whether a registered-scheme link drawn now can be activated: links are routed and the product
67
+ * offers a way to pick them. Process-wide, so a UI-less extension runner (a subagent's, whose
68
+ * transcript the user may focus) answers like the interactive one.
69
+ */
70
+ export function extensionLinkClicksAvailable(): boolean {
71
+ return extensionLinksRouted() && pickingProvider?.() === true;
72
+ }
73
+
74
+ /** The registered scheme `href` uses, or `undefined` for every other link. */
75
+ export function extensionLinkScheme(href: string): string | undefined {
76
+ if (schemes.size === 0) return undefined;
77
+ const colon = href.indexOf(":");
78
+ if (colon <= 0) return undefined;
79
+ const scheme = href.slice(0, colon).toLowerCase();
80
+ return schemes.has(scheme) ? scheme : undefined;
81
+ }
82
+
83
+ /** Dotted underline (`4:4`) where the terminal draws styled underlines, else the plain one. */
84
+ const UNDERLINE = TERMINAL.styledUnderlines
85
+ ? { on: "\x1b[4:4m", off: "\x1b[4:0m" }
86
+ : { on: "\x1b[4m", off: "\x1b[24m" };
87
+
88
+ /** An SGR sequence; group 1 is its params. */
89
+ const SGR_PATTERN = /\x1b\[([0-9:;]*)m/g;
90
+
91
+ /** Whether an SGR with these params turns underlining off: a full reset, `24` or `4:0`. */
92
+ function endsUnderline(params: string): boolean {
93
+ const codes = params.split(";");
94
+ for (let index = 0; index < codes.length; index++) {
95
+ const code = codes[index]!;
96
+ if (code === "" || code === "0" || code === "24" || code === "4:0") return true;
97
+ // Skip a color's arguments: `38;5;n` / `38;2;r;g;b` (also 48 and 58), whose `0`s are no reset.
98
+ if (code === "38" || code === "48" || code === "58") {
99
+ const mode = codes[index + 1];
100
+ index += mode === "5" ? 2 : mode === "2" ? 4 : 0;
101
+ }
102
+ }
103
+ return false;
104
+ }
105
+
106
+ /**
107
+ * Draw an extension link's label: dotted-underlined (plain underline where the terminal has no
108
+ * styled underlines, re-applied after any style reset inside it) and wrapped in the OSC 8 marker
109
+ * {@link extensionLinkLabels} reads back in a plain terminal; as given in Tern's native view. Never
110
+ * followed by a ` (url)` suffix. `key` tells apart links of one URL drawn near each other; it must
111
+ * not change between renders of the same text, or rows rendered twice stop matching.
112
+ */
113
+ export function formatExtensionLink(label: string, href: string, key: string): string {
114
+ if (isNativeRendering()) return label;
115
+ const safe = href.replaceAll("\x1b", "").replaceAll("\x07", "");
116
+ if (!safe) return label;
117
+ const body = label.replace(SGR_PATTERN, (sequence, params: string) =>
118
+ endsUnderline(params) ? sequence + UNDERLINE.on : sequence,
119
+ );
120
+ const id = Bun.hash.crc32(`${safe}\0${key}`);
121
+ return `${MARKER_OPEN}-${id};${safe}\x07${UNDERLINE.on}${body}${UNDERLINE.off}\x1b]8;;\x07`;
122
+ }
123
+
124
+ /** Hint tag letters, home row first. */
125
+ const LINK_HINT_ALPHABET = "asdfghjklqwertyuiopzxcvbnm";
126
+
127
+ /**
128
+ * Tags for `count` links in keyboard link-hint mode: single letters while they suffice, otherwise
129
+ * two letters each, so no tag is a prefix of another. At most the alphabet squared (676) are made;
130
+ * links past that stay untagged.
131
+ */
132
+ export function linkHintTags(count: number): string[] {
133
+ if (count <= LINK_HINT_ALPHABET.length) return LINK_HINT_ALPHABET.slice(0, Math.max(0, count)).split("");
134
+ const tags: string[] = [];
135
+ for (const first of LINK_HINT_ALPHABET) {
136
+ for (const second of LINK_HINT_ALPHABET) {
137
+ if (tags.length === count) return tags;
138
+ tags.push(`${first}${second}`);
139
+ }
140
+ }
141
+ return tags;
142
+ }
143
+
144
+ /**
145
+ * `line` without omp's extension-link markers (the OSC 8 open and close around each label), for
146
+ * terminal output. Every other hyperlink is kept as is.
147
+ */
148
+ export function stripExtensionLinkMarkers(line: string): string {
149
+ if (!line.includes(MARKER_OPEN)) return line;
150
+ let inside = false;
151
+ return line.replace(OSC8_PATTERN, (sequence: string, params: string, uri: string) => {
152
+ if (uri === "") {
153
+ const closesOwn = inside;
154
+ inside = false;
155
+ return closesOwn ? "" : sequence;
156
+ }
157
+ inside = MARKER_PARAMS_PATTERN.test(params);
158
+ return inside ? "" : sequence;
159
+ });
160
+ }
161
+
162
+ /** One extension link label drawn on a rendered row (before {@link stripExtensionLinkMarkers}). */
163
+ export interface ExtensionLinkLabel {
164
+ readonly url: string;
165
+ /**
166
+ * The marker's params, unique to each drawn link and repeated on every row a wrapped label
167
+ * spans, so a row's parts of one label can be told from an adjacent label of the same URL.
168
+ */
169
+ readonly id: string;
170
+ /** First 0-based cell the label covers. */
171
+ readonly start: number;
172
+ /** Cell just past the label. */
173
+ readonly end: number;
174
+ /** Whether only blank cells follow the label on its row, so a wrapped label may go on below. */
175
+ readonly endsRow: boolean;
176
+ }
177
+
178
+ /**
179
+ * The extension link labels drawn on a rendered row, left to right. Only omp's own markers with a
180
+ * registered scheme match, so ordinary hyperlinks (even of a registered scheme) and rows drawn for
181
+ * a scheme that is no longer registered never do.
182
+ */
183
+ export function extensionLinkLabels(line: string): ExtensionLinkLabel[] {
184
+ if (schemes.size === 0 || !line.includes(MARKER_OPEN)) return [];
185
+ const labels: ExtensionLinkLabel[] = [];
186
+ let x = 0;
187
+ let cursor = 0;
188
+ /** Code-unit index where the last pushed label's text ends. */
189
+ let lastClose = 0;
190
+ let open: { url: string; id: string; start: number } | undefined;
191
+ for (const match of line.matchAll(OSC8_PATTERN)) {
192
+ x += visibleWidth(line.slice(cursor, match.index));
193
+ if (open && x > open.start) {
194
+ labels.push({ ...open, end: x, endsRow: false });
195
+ lastClose = match.index;
196
+ }
197
+ open = undefined;
198
+ const params = match[1]!;
199
+ const uri = match[2]!;
200
+ cursor = match.index + match[0].length;
201
+ if (uri && MARKER_PARAMS_PATTERN.test(params) && extensionLinkScheme(uri)) {
202
+ open = { url: uri, id: params, start: x };
203
+ }
204
+ }
205
+ x += visibleWidth(line.slice(cursor));
206
+ if (open && x > open.start) {
207
+ labels.push({ ...open, end: x, endsRow: true });
208
+ } else {
209
+ const last = labels.at(-1);
210
+ if (last && Bun.stripANSI(line.slice(lastClose)).trim() === "")
211
+ labels[labels.length - 1] = { ...last, endsRow: true };
212
+ }
213
+ return labels;
214
+ }
@@ -6,6 +6,7 @@ import { node, span } from "../native/describe";
6
6
  import type { NativeNode } from "../native/node";
7
7
  import type { Theme } from "../theme/theme";
8
8
  import { fileLinkSpan } from "./hyperlink";
9
+ import { formatStyledPath } from "./render-utils";
9
10
  import { renderTreeList } from "./tree-list";
10
11
 
11
12
  /** A file-list item with optional display metadata. */
@@ -69,15 +70,11 @@ export function renderFileList(options: FileListOptions, theme: Theme): string[]
69
70
  const isDirectory = entry.isDirectory ?? entry.path.endsWith("/");
70
71
  const displayPath = entry.path;
71
72
  const lang = isDirectory ? undefined : getLanguageFromPath(displayPath);
72
- const icon = !showIcons
73
- ? ""
74
- : isDirectory
75
- ? theme.fg("accent", theme.icon.folder)
76
- : theme.fg("muted", theme.getLangIcon(lang));
77
- const labelColor = isDirectory ? "accent" : "toolOutput";
73
+ // Type icons stay muted beside the dim directory and colored file name.
74
+ const icon = !showIcons ? "" : theme.fg("muted", isDirectory ? theme.icon.folder : theme.getLangIcon(lang));
78
75
  const meta = entry.meta ? ` ${theme.fg("dim", entry.meta)}` : "";
79
76
  const iconPrefix = icon ? `${icon} ` : "";
80
- const pathStr = theme.fg(labelColor, displayPath);
77
+ const pathStr = formatStyledPath(displayPath, theme);
81
78
  const linkedPath = entry.absPath && hyperlinkFn ? hyperlinkFn(entry.absPath, pathStr) : pathStr;
82
79
  return `${iconPrefix}${linkedPath}${meta}`;
83
80
  },
@@ -1,14 +1,31 @@
1
1
  import type { TspSpan } from "@linxiraos/pi-wire";
2
2
  import { type TerminalId } from "../terminal-capabilities";
3
+ export interface FileLinkConfig {
4
+ scheme?: string;
5
+ host?: string;
6
+ }
7
+ interface FileUriOptions {
8
+ line?: number;
9
+ col?: number;
10
+ /** Native image open actions need a local file URL rather than a desktop handler. */
11
+ local?: boolean;
12
+ }
13
+ /**
14
+ * Resolve the remote file-link configuration once at host startup. Passing an
15
+ * explicit object lets SDK hosts and tests configure links without changing the
16
+ * process environment; an empty object restores ordinary file links. An invalid
17
+ * scheme or host logs a warning and keeps ordinary links.
18
+ */
19
+ export declare function applyFileLinkSetting(config?: FileLinkConfig): void;
3
20
  /**
4
- * A `file:` URL for `filePath`, or `undefined` when Node cannot encode it.
21
+ * A file-link target for `filePath`, or `undefined` when Node cannot encode it.
5
22
  *
6
23
  * Node rejects a malformed UNC target (a UNC path escaped twice by its author,
7
24
  * e.g. `\\\wsl.localhost\…`) with `ERR_INVALID_ARG_VALUE: Empty UNC servername`.
8
25
  * A stored session keeps whatever a tool call recorded, so a transcript must
9
26
  * render such a path without a link rather than throw while it rebuilds.
10
27
  */
11
- export declare function tryFileUri(filePath: string): string | undefined;
28
+ export declare function tryFileUri(filePath: string, opts?: FileUriOptions): string | undefined;
12
29
  /**
13
30
  * Build the OSC 8 target for a file path on `terminalId`.
14
31
  *
@@ -23,7 +40,8 @@ export declare function tryFileUri(filePath: string): string | undefined;
23
40
  * The VS Code family instead navigates the documented
24
41
  * `vscode://file/<path>:<line>:<col>` form. Everywhere else the plain `file:`
25
42
  * URI is right, with the location left in the visible text — terminals that
26
- * parse a `path:line:col` suffix resolve that on their own.
43
+ * parse a `path:line:col` suffix resolve that on their own. A configured custom
44
+ * handler takes precedence and receives optional `line`/`col` query parameters.
27
45
  *
28
46
  * Returns `undefined` when `filePath` cannot be encoded — a malformed UNC
29
47
  * target on the `file:` branch, or a lone surrogate on the `vscode://` branch.
@@ -85,9 +103,8 @@ export declare function urlLinkSpan(target: string, displayText: string, s?: str
85
103
  /** Whether native link spans and nodes may carry an `href`: everything but an explicit `off` policy. */
86
104
  export declare function isNativeLinkEnabled(): boolean;
87
105
  /**
88
- * A native link span to a filesystem path as a plain `file://` URI (the
89
- * terminal opens it through the system; the location stays in the visible
90
- * text). Honours an explicit `off` policy.
106
+ * A native link span to a filesystem path using the configured file-link
107
+ * target. Honours an explicit `off` policy.
91
108
  */
92
109
  export declare function fileLinkSpan(filePath: string, displayText: string, s?: string): TspSpan;
93
110
  /**
@@ -101,9 +118,10 @@ export declare function fileLinkSpan(filePath: string, displayText: string, s?:
101
118
  *
102
119
  * @param filePath - Filesystem path
103
120
  * @param displayText - Text to render as the hyperlink anchor (may contain ANSI codes)
104
- * @param opts - Optional line/col position appended as `?line=N&col=M` query params
121
+ * @param opts - Optional line/col position (custom handlers use query params; VS Code uses a path suffix)
105
122
  */
106
123
  export declare function fileHyperlink(filePath: string, displayText: string, opts?: {
107
124
  line?: number;
108
125
  col?: number;
109
126
  }): string;
127
+ export {};
@@ -5,7 +5,9 @@
5
5
  * sequences when the active terminal supports hyperlinks and the user setting
6
6
  * permits it. Falls back to plain text when disabled.
7
7
  */
8
+ import * as os from "node:os";
8
9
  import * as url from "node:url";
10
+ import { logger } from "@linxiraos/pi-utils";
9
11
  import type { TspSpan } from "@linxiraos/pi-wire";
10
12
  import { span } from "../native/describe";
11
13
  import { setTerminalHyperlinks, TERMINAL, type TerminalId } from "../terminal-capabilities";
@@ -24,6 +26,52 @@ const DETECTED_TERMINAL_HYPERLINKS = TERMINAL.hyperlinks;
24
26
  type HyperlinkMode = "off" | "auto" | "always";
25
27
  let hyperlinkMode: HyperlinkMode = "auto";
26
28
 
29
+ export interface FileLinkConfig {
30
+ scheme?: string;
31
+ host?: string;
32
+ }
33
+
34
+ interface FileUriOptions {
35
+ line?: number;
36
+ col?: number;
37
+ /** Native image open actions need a local file URL rather than a desktop handler. */
38
+ local?: boolean;
39
+ }
40
+
41
+ let fileLinkTarget: { scheme: string; host: string } | undefined;
42
+
43
+ /** URI scheme syntax (RFC 3986 §3.1), matched after lowercasing. */
44
+ const FILE_LINK_SCHEME = /^[a-z][a-z0-9+.-]*$/;
45
+ /** A bare host name with an optional port: no userinfo, path, query, or whitespace that would reshape the URI. */
46
+ const FILE_LINK_HOST = /^[A-Za-z0-9._-]+(?::\d{1,5})?$/;
47
+
48
+ /**
49
+ * Resolve the remote file-link configuration once at host startup. Passing an
50
+ * explicit object lets SDK hosts and tests configure links without changing the
51
+ * process environment; an empty object restores ordinary file links. An invalid
52
+ * scheme or host logs a warning and keeps ordinary links.
53
+ */
54
+ export function applyFileLinkSetting(
55
+ config: FileLinkConfig = {
56
+ scheme: Bun.env.ZETA_LINK_SCHEME,
57
+ host: Bun.env.ZETA_LINK_HOST,
58
+ },
59
+ ): void {
60
+ fileLinkTarget = undefined;
61
+ if (!config.scheme) return;
62
+ const scheme = config.scheme.toLowerCase();
63
+ if (!FILE_LINK_SCHEME.test(scheme)) {
64
+ logger.warn("Invalid ZETA_LINK_SCHEME; using ordinary file links", { scheme: config.scheme });
65
+ return;
66
+ }
67
+ const host = config.host || os.hostname();
68
+ if (!FILE_LINK_HOST.test(host)) {
69
+ logger.warn("Invalid ZETA_LINK_HOST; using ordinary file links", { host });
70
+ return;
71
+ }
72
+ fileLinkTarget = { scheme, host };
73
+ }
74
+
27
75
  /** Stable 8-char hex ID derived from a URI — hints terminals to coalesce identical adjacent links. */
28
76
  function buildLinkId(uri: string): string {
29
77
  let h = 0;
@@ -35,16 +83,24 @@ function buildLinkId(uri: string): string {
35
83
  }
36
84
 
37
85
  /**
38
- * A `file:` URL for `filePath`, or `undefined` when Node cannot encode it.
86
+ * A file-link target for `filePath`, or `undefined` when Node cannot encode it.
39
87
  *
40
88
  * Node rejects a malformed UNC target (a UNC path escaped twice by its author,
41
89
  * e.g. `\\\wsl.localhost\…`) with `ERR_INVALID_ARG_VALUE: Empty UNC servername`.
42
90
  * A stored session keeps whatever a tool call recorded, so a transcript must
43
91
  * render such a path without a link rather than throw while it rebuilds.
44
92
  */
45
- export function tryFileUri(filePath: string): string | undefined {
93
+ export function tryFileUri(filePath: string, opts?: FileUriOptions): string | undefined {
46
94
  try {
47
- return url.pathToFileURL(filePath).href;
95
+ const fileUrl = url.pathToFileURL(filePath);
96
+ if (!fileLinkTarget || opts?.local) return fileUrl.href;
97
+ // Preserve UNC servers so the handler can reconstruct the network path.
98
+ const targetPath = fileUrl.host ? `//${fileUrl.host}${fileUrl.pathname}` : fileUrl.pathname;
99
+ const position = new URLSearchParams();
100
+ if (opts?.line !== undefined) position.set("line", String(opts.line));
101
+ if (opts?.col !== undefined) position.set("col", String(opts.col));
102
+ const query = position.size ? `?${position}` : "";
103
+ return `${fileLinkTarget.scheme}://${fileLinkTarget.host}${targetPath}${query}`;
48
104
  } catch {
49
105
  return undefined;
50
106
  }
@@ -64,7 +120,8 @@ export function tryFileUri(filePath: string): string | undefined {
64
120
  * The VS Code family instead navigates the documented
65
121
  * `vscode://file/<path>:<line>:<col>` form. Everywhere else the plain `file:`
66
122
  * URI is right, with the location left in the visible text — terminals that
67
- * parse a `path:line:col` suffix resolve that on their own.
123
+ * parse a `path:line:col` suffix resolve that on their own. A configured custom
124
+ * handler takes precedence and receives optional `line`/`col` query parameters.
68
125
  *
69
126
  * Returns `undefined` when `filePath` cannot be encoded — a malformed UNC
70
127
  * target on the `file:` branch, or a lone surrogate on the `vscode://` branch.
@@ -74,7 +131,7 @@ export function fileUriForTerminal(
74
131
  opts: { line?: number; col?: number } | undefined,
75
132
  terminalId: TerminalId,
76
133
  ): string | undefined {
77
- if (terminalId !== "vscode") return tryFileUri(filePath);
134
+ if (fileLinkTarget || terminalId !== "vscode") return tryFileUri(filePath, opts);
78
135
  // vscode:// takes a filesystem path with forward slashes. Encode each
79
136
  // segment independently so separators and a Windows drive colon stay
80
137
  // structural while reserved bytes in file names cannot become URI syntax.
@@ -222,9 +279,8 @@ export function isNativeLinkEnabled(): boolean {
222
279
  }
223
280
 
224
281
  /**
225
- * A native link span to a filesystem path as a plain `file://` URI (the
226
- * terminal opens it through the system; the location stays in the visible
227
- * text). Honours an explicit `off` policy.
282
+ * A native link span to a filesystem path using the configured file-link
283
+ * target. Honours an explicit `off` policy.
228
284
  */
229
285
  export function fileLinkSpan(filePath: string, displayText: string, s = "path"): TspSpan {
230
286
  if (hyperlinkMode === "off") return span(displayText, s);
@@ -244,7 +300,7 @@ export function fileLinkSpan(filePath: string, displayText: string, s = "path"):
244
300
  *
245
301
  * @param filePath - Filesystem path
246
302
  * @param displayText - Text to render as the hyperlink anchor (may contain ANSI codes)
247
- * @param opts - Optional line/col position appended as `?line=N&col=M` query params
303
+ * @param opts - Optional line/col position (custom handlers use query params; VS Code uses a path suffix)
248
304
  */
249
305
  export function fileHyperlink(filePath: string, displayText: string, opts?: { line?: number; col?: number }): string {
250
306
  const uri = fileUriForTerminal(filePath, opts, TERMINAL.id);
@@ -2,6 +2,7 @@
2
2
  * Public exports for shared TUI components.
3
3
  */
4
4
  export * from "./code-cell";
5
+ export * from "./extension-links";
5
6
  export * from "./file-list";
6
7
  export * from "./hyperlink";
7
8
  export * from "./output-block";
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  export * from "./code-cell";
6
+ export * from "./extension-links";
6
7
  export * from "./file-list";
7
8
  export * from "./hyperlink";
8
9
  export * from "./output-block";
@@ -49,6 +49,8 @@ export declare const PREVIEW_LIMITS: {
49
49
  readonly EXPANDED_LINES: 12;
50
50
  /** Items (files, results) shown in collapsed view */
51
51
  readonly COLLAPSED_ITEMS: 8;
52
+ /** Definition, type-definition and implementation locations shown in collapsed view */
53
+ readonly LOCATIONS_COLLAPSED: 2;
52
54
  /** Output preview lines in collapsed view */
53
55
  readonly OUTPUT_COLLAPSED: 3;
54
56
  /** Output preview lines in expanded view */
@@ -188,11 +190,31 @@ export declare function formatErrorMessage(message: string | undefined, theme: T
188
190
  export declare function formatErrorDetail(message: string | undefined, theme: Theme): string;
189
191
  /** Render a muted empty-state message with a warning icon. */
190
192
  export declare function formatEmptyMessage(message: string, theme: Theme): string;
193
+ /**
194
+ * Color of a file's name, or a whole URL, in tool bodies: it keeps paths apart
195
+ * from the tool titles above them (bronze in titanium).
196
+ */
197
+ export declare const FILE_NAME_COLOR = "customMessageLabel";
198
+ /**
199
+ * Where a display path's final segment (file or folder name) starts, past its
200
+ * last `/` or `\` separator; a trailing-slash directory keeps its slash on the
201
+ * name. Shared by the terminal ({@link formatStyledPath}) and Tern file rows.
202
+ */
203
+ export declare function pathNameStart(filePath: string): number;
204
+ /**
205
+ * A file path in a tool body: the directory (with its trailing separator) dim,
206
+ * the final segment in {@link FILE_NAME_COLOR}. Tool headers keep paths in
207
+ * their plain subject color instead.
208
+ */
209
+ export declare function formatStyledPath(filePath: string, theme: Theme): string;
191
210
  /** Marker displayed in the gutter of a code frame. */
192
211
  export type CodeFrameMarker = "" | " " | "*" | "+" | "-" | ">";
193
212
  /** Format a code-frame row with a padded line-number gutter. */
194
213
  export declare function formatCodeFrameLine(marker: CodeFrameMarker, lineNumber: string | number, content: string, lineNumberWidth: number): string;
195
- /** Status states supported by shared tool renderer icons. */
214
+ /**
215
+ * Status states supported by shared tool renderer icons. `done` is a deprecated
216
+ * alias of `success`, kept for extension renderers.
217
+ */
196
218
  export type ToolUIStatus = "success" | "done" | "error" | "warning" | "info" | "pending" | "running" | "aborted";
197
219
  /** Semantic foreground colors used by tool renderer labels. */
198
220
  export type ToolUIColor = "success" | "error" | "warning" | "accent" | "muted";