@deepseek-harness-tui/dsh-tui 0.6.0 → 0.7.0

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 (379) hide show
  1. package/README.md +74 -21
  2. package/bin/dsh-tui.js +115 -25
  3. package/cordis.patch.yml +69 -17
  4. package/cordis.yml +50 -12
  5. package/lib/types/activityPrefs.d.ts +1 -1
  6. package/lib/types/activityPrefs.js +3 -3
  7. package/lib/types/cc/figures.d.ts +27 -20
  8. package/lib/types/cc/figures.d.ts.map +1 -1
  9. package/lib/types/cc/figures.js +43 -34
  10. package/lib/types/cc/format.d.ts +18 -9
  11. package/lib/types/cc/format.d.ts.map +1 -1
  12. package/lib/types/cc/format.js +26 -18
  13. package/lib/types/cc/markdown.d.ts +31 -16
  14. package/lib/types/cc/markdown.d.ts.map +1 -1
  15. package/lib/types/cc/markdown.js +283 -260
  16. package/lib/types/cc/terminal.d.ts +10 -7
  17. package/lib/types/cc/terminal.d.ts.map +1 -1
  18. package/lib/types/cc/terminal.js +62 -50
  19. package/lib/types/command-trees.d.ts +3 -0
  20. package/lib/types/command-trees.d.ts.map +1 -0
  21. package/lib/types/command-trees.js +4 -0
  22. package/lib/types/commands.d.ts +37 -1
  23. package/lib/types/commands.d.ts.map +1 -1
  24. package/lib/types/commands.js +68 -3
  25. package/lib/types/components/ActivityLine.d.ts +1 -1
  26. package/lib/types/components/ActivityLine.d.ts.map +1 -1
  27. package/lib/types/components/ActivityPicker.d.ts.map +1 -1
  28. package/lib/types/components/ActivityPicker.js +3 -4
  29. package/lib/types/components/BtwPanel.d.ts +16 -0
  30. package/lib/types/components/BtwPanel.d.ts.map +1 -0
  31. package/lib/types/components/BtwPanel.js +47 -0
  32. package/lib/types/components/CommandSuggestions.d.ts +4 -2
  33. package/lib/types/components/CommandSuggestions.d.ts.map +1 -1
  34. package/lib/types/components/CommandSuggestions.js +2 -2
  35. package/lib/types/components/EffortSlider.d.ts +15 -0
  36. package/lib/types/components/EffortSlider.d.ts.map +1 -0
  37. package/lib/types/components/EffortSlider.js +17 -0
  38. package/lib/types/components/GoalTodoPanel.d.ts +1 -1
  39. package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
  40. package/lib/types/components/HelpMenu.d.ts +5 -2
  41. package/lib/types/components/HelpMenu.d.ts.map +1 -1
  42. package/lib/types/components/HelpMenu.js +8 -3
  43. package/lib/types/components/HistorySearchDialog.d.ts +1 -1
  44. package/lib/types/components/HistorySearchDialog.d.ts.map +1 -1
  45. package/lib/types/components/HistorySearchDialog.js +21 -10
  46. package/lib/types/components/InterruptedByUser.d.ts +2 -2
  47. package/lib/types/components/InterruptedByUser.d.ts.map +1 -1
  48. package/lib/types/components/InterruptedByUser.js +4 -3
  49. package/lib/types/components/LoadedContextPanel.d.ts +1 -1
  50. package/lib/types/components/LoadedContextPanel.d.ts.map +1 -1
  51. package/lib/types/components/LogoV2.d.ts.map +1 -1
  52. package/lib/types/components/LogoV2.js +2 -1
  53. package/lib/types/components/Markdown.d.ts +11 -11
  54. package/lib/types/components/Markdown.d.ts.map +1 -1
  55. package/lib/types/components/Markdown.js +63 -57
  56. package/lib/types/components/MarkdownTable.d.ts +1 -1
  57. package/lib/types/components/MarkdownTable.js +2 -2
  58. package/lib/types/components/MessageList.d.ts +10 -2
  59. package/lib/types/components/MessageList.d.ts.map +1 -1
  60. package/lib/types/components/MessageList.js +17 -10
  61. package/lib/types/components/ModelPicker.d.ts +4 -1
  62. package/lib/types/components/ModelPicker.d.ts.map +1 -1
  63. package/lib/types/components/ModelPicker.js +16 -4
  64. package/lib/types/components/OverlayAbove.d.ts +20 -0
  65. package/lib/types/components/OverlayAbove.d.ts.map +1 -0
  66. package/lib/types/components/OverlayAbove.js +18 -0
  67. package/lib/types/components/PresetPicker.d.ts +1 -1
  68. package/lib/types/components/PresetPicker.d.ts.map +1 -1
  69. package/lib/types/components/PresetPicker.js +2 -3
  70. package/lib/types/components/PromptInput.d.ts +5 -4
  71. package/lib/types/components/PromptInput.d.ts.map +1 -1
  72. package/lib/types/components/PromptInput.js +186 -39
  73. package/lib/types/components/ResumePicker.d.ts +15 -4
  74. package/lib/types/components/ResumePicker.d.ts.map +1 -1
  75. package/lib/types/components/ResumePicker.js +25 -9
  76. package/lib/types/components/RewindPicker.d.ts +1 -1
  77. package/lib/types/components/RewindPicker.d.ts.map +1 -1
  78. package/lib/types/components/RewindPicker.js +14 -5
  79. package/lib/types/components/SearchBox.d.ts +1 -1
  80. package/lib/types/components/SearchBox.js +1 -1
  81. package/lib/types/components/Spinner/GlimmerMessage.d.ts +1 -2
  82. package/lib/types/components/Spinner/GlimmerMessage.d.ts.map +1 -1
  83. package/lib/types/components/Spinner/GlimmerMessage.js +1 -2
  84. package/lib/types/components/Spinner/SpinnerAnimationRow.d.ts +1 -1
  85. package/lib/types/components/Spinner/SpinnerAnimationRow.js +2 -2
  86. package/lib/types/components/Spinner/SpinnerGlyph.d.ts +1 -1
  87. package/lib/types/components/Spinner/SpinnerGlyph.js +1 -1
  88. package/lib/types/components/Spinner/spinnerUtils.d.ts +13 -18
  89. package/lib/types/components/Spinner/spinnerUtils.d.ts.map +1 -1
  90. package/lib/types/components/Spinner/spinnerUtils.js +67 -71
  91. package/lib/types/components/Spinner/useStalledAnimation.d.ts +1 -2
  92. package/lib/types/components/Spinner/useStalledAnimation.d.ts.map +1 -1
  93. package/lib/types/components/Spinner/useStalledAnimation.js +1 -2
  94. package/lib/types/components/StreamingMarkdown.d.ts +1 -1
  95. package/lib/types/components/StreamingMarkdown.js +1 -1
  96. package/lib/types/components/ThemePicker.d.ts +13 -9
  97. package/lib/types/components/ThemePicker.d.ts.map +1 -1
  98. package/lib/types/components/ThemePicker.js +21 -15
  99. package/lib/types/components/ThinkingToggle.d.ts +1 -1
  100. package/lib/types/components/ThinkingToggle.d.ts.map +1 -1
  101. package/lib/types/components/ThinkingToggle.js +8 -8
  102. package/lib/types/components/ToolUseLoader.d.ts +1 -1
  103. package/lib/types/components/ToolUseLoader.js +1 -1
  104. package/lib/types/components/WorkingSpinner.d.ts +2 -2
  105. package/lib/types/components/WorkingSpinner.js +2 -2
  106. package/lib/types/components/WorkspaceFlowPicker.d.ts +15 -0
  107. package/lib/types/components/WorkspaceFlowPicker.d.ts.map +1 -0
  108. package/lib/types/components/WorkspaceFlowPicker.js +19 -0
  109. package/lib/types/components/WorkspacePicker.d.ts +9 -0
  110. package/lib/types/components/WorkspacePicker.d.ts.map +1 -0
  111. package/lib/types/components/WorkspacePicker.js +13 -0
  112. package/lib/types/components/approvals/ApprovalPanel.d.ts +1 -1
  113. package/lib/types/components/approvals/ApprovalPanel.d.ts.map +1 -1
  114. package/lib/types/components/approvals/ApprovalPanel.js +2 -1
  115. package/lib/types/components/design-system/Byline.d.ts +1 -1
  116. package/lib/types/components/design-system/Byline.js +1 -1
  117. package/lib/types/components/design-system/Divider.d.ts +1 -1
  118. package/lib/types/components/design-system/Divider.js +1 -1
  119. package/lib/types/components/design-system/HintLine.d.ts +12 -0
  120. package/lib/types/components/design-system/HintLine.d.ts.map +1 -0
  121. package/lib/types/components/design-system/HintLine.js +15 -0
  122. package/lib/types/components/design-system/KeyboardShortcutHint.d.ts +1 -1
  123. package/lib/types/components/design-system/KeyboardShortcutHint.js +1 -1
  124. package/lib/types/components/design-system/ListItem.d.ts +2 -2
  125. package/lib/types/components/design-system/ListItem.d.ts.map +1 -1
  126. package/lib/types/components/design-system/ListItem.js +35 -3
  127. package/lib/types/components/design-system/LoadingState.d.ts +1 -2
  128. package/lib/types/components/design-system/LoadingState.d.ts.map +1 -1
  129. package/lib/types/components/design-system/LoadingState.js +1 -2
  130. package/lib/types/components/design-system/Pane.d.ts +2 -2
  131. package/lib/types/components/design-system/Pane.js +2 -2
  132. package/lib/types/components/design-system/ProgressBar.d.ts +1 -2
  133. package/lib/types/components/design-system/ProgressBar.d.ts.map +1 -1
  134. package/lib/types/components/design-system/ProgressBar.js +1 -2
  135. package/lib/types/components/design-system/StatusIcon.d.ts +2 -2
  136. package/lib/types/components/design-system/StatusIcon.js +2 -2
  137. package/lib/types/components/design-system/ThemeProvider.d.ts +1 -1
  138. package/lib/types/components/design-system/ThemeProvider.d.ts.map +1 -1
  139. package/lib/types/components/design-system/ThemeProvider.js +87 -26
  140. package/lib/types/components/design-system/ThemedBox.d.ts +1 -1
  141. package/lib/types/components/design-system/ThemedBox.js +1 -1
  142. package/lib/types/components/design-system/ThemedText.d.ts +2 -2
  143. package/lib/types/components/design-system/ThemedText.js +2 -2
  144. package/lib/types/components/listWindow.d.ts +26 -0
  145. package/lib/types/components/listWindow.d.ts.map +1 -0
  146. package/lib/types/components/listWindow.js +47 -0
  147. package/lib/types/components/messages/AssistantTextMessage.d.ts +1 -2
  148. package/lib/types/components/messages/AssistantTextMessage.d.ts.map +1 -1
  149. package/lib/types/components/messages/AssistantTextMessage.js +1 -2
  150. package/lib/types/components/messages/AssistantThinkingMessage.d.ts +2 -2
  151. package/lib/types/components/messages/AssistantThinkingMessage.d.ts.map +1 -1
  152. package/lib/types/components/messages/AssistantThinkingMessage.js +6 -6
  153. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +12 -4
  154. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  155. package/lib/types/components/messages/AssistantToolUseMessage.js +9 -5
  156. package/lib/types/components/messages/MessageMetadata.d.ts +1 -1
  157. package/lib/types/components/messages/MessageMetadata.js +1 -1
  158. package/lib/types/components/messages/UserPromptMessage.d.ts +1 -1
  159. package/lib/types/components/messages/UserPromptMessage.js +1 -1
  160. package/lib/types/components/questions/AskUserQuestionPanel.d.ts +5 -1
  161. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
  162. package/lib/types/components/questions/AskUserQuestionPanel.js +11 -9
  163. package/lib/types/components/questions/PlanReviewPanel.d.ts +1 -1
  164. package/lib/types/components/questions/PlanReviewPanel.d.ts.map +1 -1
  165. package/lib/types/components/questions/PlanReviewPanel.js +3 -2
  166. package/lib/types/components/trajectory/HotspotView.d.ts +14 -0
  167. package/lib/types/components/trajectory/HotspotView.d.ts.map +1 -0
  168. package/lib/types/components/trajectory/HotspotView.js +83 -0
  169. package/lib/types/components/trajectory/Inspector.d.ts +31 -0
  170. package/lib/types/components/trajectory/Inspector.d.ts.map +1 -0
  171. package/lib/types/components/trajectory/Inspector.js +67 -0
  172. package/lib/types/components/trajectory/Ledger.d.ts +20 -0
  173. package/lib/types/components/trajectory/Ledger.d.ts.map +1 -0
  174. package/lib/types/components/trajectory/Ledger.js +112 -0
  175. package/lib/types/components/trajectory/MiniWake.d.ts +24 -0
  176. package/lib/types/components/trajectory/MiniWake.d.ts.map +1 -0
  177. package/lib/types/components/trajectory/MiniWake.js +99 -0
  178. package/lib/types/components/trajectory/WaveBand.d.ts +33 -0
  179. package/lib/types/components/trajectory/WaveBand.d.ts.map +1 -0
  180. package/lib/types/components/trajectory/WaveBand.js +145 -0
  181. package/lib/types/customTheme.d.ts +6 -6
  182. package/lib/types/customTheme.d.ts.map +1 -1
  183. package/lib/types/customTheme.js +15 -12
  184. package/lib/types/dsh-adapter/approvals.d.ts.map +1 -0
  185. package/lib/types/{channel.d.ts → dsh-adapter/channel.d.ts} +184 -43
  186. package/lib/types/dsh-adapter/channel.d.ts.map +1 -0
  187. package/lib/types/{channel.js → dsh-adapter/channel.js} +972 -201
  188. package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -0
  189. package/lib/types/{childStderr.js → dsh-adapter/childStderr.js} +1 -1
  190. package/lib/types/dsh-adapter/command-trees.d.ts +27 -0
  191. package/lib/types/dsh-adapter/command-trees.d.ts.map +1 -0
  192. package/lib/types/dsh-adapter/command-trees.js +42 -0
  193. package/lib/types/dsh-adapter/compat/index.d.ts +22 -0
  194. package/lib/types/dsh-adapter/compat/index.d.ts.map +1 -0
  195. package/lib/types/{compat → dsh-adapter/compat}/index.js +7 -4
  196. package/lib/types/dsh-adapter/compat/sessionLog.d.ts +86 -0
  197. package/lib/types/dsh-adapter/compat/sessionLog.d.ts.map +1 -0
  198. package/lib/types/dsh-adapter/compat/sessionLog.js +347 -0
  199. package/lib/types/dsh-adapter/contract.d.ts +20 -0
  200. package/lib/types/dsh-adapter/contract.d.ts.map +1 -0
  201. package/lib/types/dsh-adapter/contract.js +109 -0
  202. package/lib/types/dsh-adapter/index.d.ts +80 -0
  203. package/lib/types/dsh-adapter/index.d.ts.map +1 -0
  204. package/lib/types/dsh-adapter/index.js +45 -0
  205. package/lib/types/dsh-adapter/invariant.d.ts.map +1 -0
  206. package/lib/types/dsh-adapter/packaged-skills.d.ts.map +1 -0
  207. package/lib/types/{plugin.d.ts → dsh-adapter/plugin.d.ts} +17 -0
  208. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -0
  209. package/lib/types/{plugin.js → dsh-adapter/plugin.js} +280 -80
  210. package/lib/types/dsh-adapter/presets.d.ts.map +1 -0
  211. package/lib/types/dsh-adapter/providerWizard.d.ts +91 -0
  212. package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -0
  213. package/lib/types/dsh-adapter/providerWizard.js +332 -0
  214. package/lib/types/{questions.d.ts → dsh-adapter/questions.d.ts} +7 -2
  215. package/lib/types/dsh-adapter/questions.d.ts.map +1 -0
  216. package/lib/types/{questions.js → dsh-adapter/questions.js} +15 -7
  217. package/lib/types/dsh-adapter/sideQuestion.d.ts +38 -0
  218. package/lib/types/dsh-adapter/sideQuestion.d.ts.map +1 -0
  219. package/lib/types/dsh-adapter/sideQuestion.js +69 -0
  220. package/lib/types/dsh-adapter/trajectory/aggregate.d.ts +46 -0
  221. package/lib/types/dsh-adapter/trajectory/aggregate.d.ts.map +1 -0
  222. package/lib/types/dsh-adapter/trajectory/aggregate.js +207 -0
  223. package/lib/types/dsh-adapter/trajectory/guards.d.ts +177 -0
  224. package/lib/types/dsh-adapter/trajectory/guards.d.ts.map +1 -0
  225. package/lib/types/dsh-adapter/trajectory/guards.js +235 -0
  226. package/lib/types/dsh-adapter/trajectory/index.d.ts +16 -0
  227. package/lib/types/dsh-adapter/trajectory/index.d.ts.map +1 -0
  228. package/lib/types/dsh-adapter/trajectory/index.js +15 -0
  229. package/lib/types/dsh-adapter/trajectory/inspect.d.ts +40 -0
  230. package/lib/types/dsh-adapter/trajectory/inspect.d.ts.map +1 -0
  231. package/lib/types/dsh-adapter/trajectory/inspect.js +160 -0
  232. package/lib/types/dsh-adapter/trajectory/projection.d.ts +128 -0
  233. package/lib/types/dsh-adapter/trajectory/projection.d.ts.map +1 -0
  234. package/lib/types/dsh-adapter/trajectory/projection.js +653 -0
  235. package/lib/types/dsh-adapter/trajectory/types.d.ts +232 -0
  236. package/lib/types/dsh-adapter/trajectory/types.d.ts.map +1 -0
  237. package/lib/types/dsh-adapter/trajectory/types.js +70 -0
  238. package/lib/types/dsh-adapter/trajectory/wave.d.ts +45 -0
  239. package/lib/types/dsh-adapter/trajectory/wave.d.ts.map +1 -0
  240. package/lib/types/dsh-adapter/trajectory/wave.js +210 -0
  241. package/lib/types/dsh-adapter/types.d.ts +23 -0
  242. package/lib/types/dsh-adapter/types.d.ts.map +1 -0
  243. package/lib/types/dsh-adapter/types.js +1 -0
  244. package/lib/types/dsh-adapter/workspace.d.ts +22 -0
  245. package/lib/types/dsh-adapter/workspace.d.ts.map +1 -0
  246. package/lib/types/dsh-adapter/workspace.js +16 -0
  247. package/lib/types/dsh-adapter/workspaces.d.ts +118 -0
  248. package/lib/types/dsh-adapter/workspaces.d.ts.map +1 -0
  249. package/lib/types/dsh-adapter/workspaces.js +290 -0
  250. package/lib/types/effortPrefs.d.ts +1 -1
  251. package/lib/types/effortPrefs.js +3 -3
  252. package/lib/types/history.js +2 -2
  253. package/lib/types/hooks/useBlink.d.ts +1 -1
  254. package/lib/types/hooks/useBlink.js +1 -1
  255. package/lib/types/i18n.d.ts +977 -36
  256. package/lib/types/i18n.d.ts.map +1 -1
  257. package/lib/types/i18n.js +307 -30
  258. package/lib/types/index.d.ts +1 -69
  259. package/lib/types/index.d.ts.map +1 -1
  260. package/lib/types/index.js +3 -31
  261. package/lib/types/ink/components/App.d.ts.map +1 -1
  262. package/lib/types/ink/components/App.js +33 -19
  263. package/lib/types/ink/dom.d.ts +15 -0
  264. package/lib/types/ink/dom.d.ts.map +1 -1
  265. package/lib/types/ink/dom.js +32 -0
  266. package/lib/types/ink/hooks/use-input.d.ts.map +1 -1
  267. package/lib/types/ink/hooks/use-input.js +8 -0
  268. package/lib/types/ink/hooks/use-terminal-size.d.ts +1 -1
  269. package/lib/types/ink/hooks/use-terminal-size.js +1 -1
  270. package/lib/types/ink/ink.d.ts.map +1 -1
  271. package/lib/types/ink/ink.js +109 -28
  272. package/lib/types/ink/input-suppression.d.ts +20 -0
  273. package/lib/types/ink/input-suppression.d.ts.map +1 -0
  274. package/lib/types/ink/input-suppression.js +26 -0
  275. package/lib/types/ink/log-update.js +21 -6
  276. package/lib/types/ink/parse-keypress.d.ts +31 -0
  277. package/lib/types/ink/parse-keypress.d.ts.map +1 -1
  278. package/lib/types/ink/parse-keypress.js +442 -8
  279. package/lib/types/ink/terminal-querier.d.ts +5 -1
  280. package/lib/types/ink/terminal-querier.d.ts.map +1 -1
  281. package/lib/types/ink/terminal-querier.js +27 -3
  282. package/lib/types/ink/terminal.d.ts +18 -0
  283. package/lib/types/ink/terminal.d.ts.map +1 -1
  284. package/lib/types/ink/terminal.js +32 -4
  285. package/lib/types/ink/termio/csi.d.ts +10 -0
  286. package/lib/types/ink/termio/csi.d.ts.map +1 -1
  287. package/lib/types/ink/termio/csi.js +20 -0
  288. package/lib/types/ink/termio/tokenize.js +10 -0
  289. package/lib/types/modelPrefs.d.ts +1 -1
  290. package/lib/types/modelPrefs.js +3 -3
  291. package/lib/types/presetPrefs.d.ts +1 -1
  292. package/lib/types/presetPrefs.js +3 -3
  293. package/lib/types/screens/Chat.d.ts +20 -4
  294. package/lib/types/screens/Chat.d.ts.map +1 -1
  295. package/lib/types/screens/Chat.js +655 -55
  296. package/lib/types/screens/StatusLine.d.ts +17 -2
  297. package/lib/types/screens/StatusLine.d.ts.map +1 -1
  298. package/lib/types/screens/StatusLine.js +12 -4
  299. package/lib/types/screens/TrajectoryScene.d.ts +16 -0
  300. package/lib/types/screens/TrajectoryScene.d.ts.map +1 -0
  301. package/lib/types/screens/TrajectoryScene.js +305 -0
  302. package/lib/types/sessionHistory.d.ts +9 -1
  303. package/lib/types/sessionHistory.d.ts.map +1 -1
  304. package/lib/types/sessionHistory.js +56 -16
  305. package/lib/types/sessionModes.d.ts +29 -0
  306. package/lib/types/sessionModes.d.ts.map +1 -0
  307. package/lib/types/sessionModes.js +45 -0
  308. package/lib/types/theme.d.ts +27 -3
  309. package/lib/types/theme.d.ts.map +1 -1
  310. package/lib/types/theme.js +48 -4
  311. package/lib/types/themePrefs.d.ts +3 -3
  312. package/lib/types/themePrefs.js +5 -5
  313. package/lib/types/trajectory/format.d.ts +100 -0
  314. package/lib/types/trajectory/format.d.ts.map +1 -0
  315. package/lib/types/trajectory/format.js +213 -0
  316. package/lib/types/trajectory/motion.d.ts +99 -0
  317. package/lib/types/trajectory/motion.d.ts.map +1 -0
  318. package/lib/types/trajectory/motion.js +143 -0
  319. package/lib/types/trajectory/query.d.ts +83 -0
  320. package/lib/types/trajectory/query.d.ts.map +1 -0
  321. package/lib/types/trajectory/query.js +187 -0
  322. package/lib/types/trajectoryPrefs.d.ts +36 -0
  323. package/lib/types/trajectoryPrefs.d.ts.map +1 -0
  324. package/lib/types/trajectoryPrefs.js +65 -0
  325. package/lib/types/update.d.ts +3 -3
  326. package/lib/types/update.d.ts.map +1 -1
  327. package/lib/types/update.js +18 -7
  328. package/lib/types/utils/clipboard.d.ts +101 -29
  329. package/lib/types/utils/clipboard.d.ts.map +1 -1
  330. package/lib/types/utils/clipboard.js +533 -55
  331. package/lib/types/utils/debug.d.ts +1 -1
  332. package/lib/types/utils/debug.js +2 -2
  333. package/lib/types/utils/execFileNoThrow.d.ts.map +1 -1
  334. package/lib/types/utils/execFileNoThrow.js +16 -6
  335. package/lib/types/utils/externalEditor.d.ts +115 -0
  336. package/lib/types/utils/externalEditor.d.ts.map +1 -0
  337. package/lib/types/utils/externalEditor.js +270 -0
  338. package/lib/types/utils/fullscreen.d.ts +2 -2
  339. package/lib/types/utils/fullscreen.js +3 -3
  340. package/lib/types/utils/loaded-context.d.ts +1 -1
  341. package/lib/types/utils/loaded-context.d.ts.map +1 -1
  342. package/lib/types/utils/modifiers.d.ts +24 -0
  343. package/lib/types/utils/modifiers.d.ts.map +1 -1
  344. package/lib/types/utils/modifiers.js +27 -0
  345. package/lib/types/utils/paths.d.ts +45 -0
  346. package/lib/types/utils/paths.d.ts.map +1 -0
  347. package/lib/types/utils/paths.js +69 -0
  348. package/lib/types/utils/shellQuote.d.ts +14 -0
  349. package/lib/types/utils/shellQuote.d.ts.map +1 -0
  350. package/lib/types/utils/shellQuote.js +39 -0
  351. package/lib/types/utils/workspaceRoot.d.ts +21 -0
  352. package/lib/types/utils/workspaceRoot.d.ts.map +1 -0
  353. package/lib/types/utils/workspaceRoot.js +47 -0
  354. package/lib/types/workspaces.d.ts +3 -0
  355. package/lib/types/workspaces.d.ts.map +1 -0
  356. package/lib/types/workspaces.js +4 -0
  357. package/package.json +26 -8
  358. package/lib/types/approvals.d.ts.map +0 -1
  359. package/lib/types/channel.d.ts.map +0 -1
  360. package/lib/types/childStderr.d.ts.map +0 -1
  361. package/lib/types/compat/index.d.ts +0 -20
  362. package/lib/types/compat/index.d.ts.map +0 -1
  363. package/lib/types/compat/sessionLog.d.ts +0 -40
  364. package/lib/types/compat/sessionLog.d.ts.map +0 -1
  365. package/lib/types/compat/sessionLog.js +0 -226
  366. package/lib/types/invariant.d.ts.map +0 -1
  367. package/lib/types/packaged-skills.d.ts.map +0 -1
  368. package/lib/types/plugin.d.ts.map +0 -1
  369. package/lib/types/presets.d.ts.map +0 -1
  370. package/lib/types/questions.d.ts.map +0 -1
  371. /package/lib/types/{approvals.d.ts → dsh-adapter/approvals.d.ts} +0 -0
  372. /package/lib/types/{approvals.js → dsh-adapter/approvals.js} +0 -0
  373. /package/lib/types/{childStderr.d.ts → dsh-adapter/childStderr.d.ts} +0 -0
  374. /package/lib/types/{invariant.d.ts → dsh-adapter/invariant.d.ts} +0 -0
  375. /package/lib/types/{invariant.js → dsh-adapter/invariant.js} +0 -0
  376. /package/lib/types/{packaged-skills.d.ts → dsh-adapter/packaged-skills.d.ts} +0 -0
  377. /package/lib/types/{packaged-skills.js → dsh-adapter/packaged-skills.js} +0 -0
  378. /package/lib/types/{presets.d.ts → dsh-adapter/presets.d.ts} +0 -0
  379. /package/lib/types/{presets.js → dsh-adapter/presets.js} +0 -0
@@ -1,9 +1,16 @@
1
- /* oxlint-disable typescript/no-unsafe-argument, typescript/no-unsafe-assignment,
2
- typescript/no-unsafe-call, typescript/no-unsafe-member-access, typescript/no-unsafe-return,
3
- typescript/restrict-plus-operands, typescript/no-unnecessary-condition,
4
- typescript/no-non-null-assertion, typescript/no-unnecessary-type-assertion,
5
- sonarjs/no-duplicated-branches
6
- -- ported Claude Code renderer (upstream src/utils/markdown.ts); historical lint debt kept with upstream idioms, like vendor/ */
1
+ /**
2
+ * Markdown-to-ANSI renderer over marked's token stream.
3
+ *
4
+ * Converts the shared marked lexer output into styled terminal text: quote
5
+ * gutters, syntax-highlighted fenced blocks, indented list bullets with
6
+ * depth-based numbering, and alignment-padded tables. The visual conventions
7
+ * (▎ bars for blockquotes, theme-colored inline code, OSC 8 hyperlinks) are
8
+ * standard terminal markdown idioms, but this is an independent
9
+ * implementation: a single dispatch switch fans tokens out to dedicated
10
+ * per-type render functions, and all recursive calls thread one immutable
11
+ * RenderState (parent token, list depth, list ordinal, highlighter) instead
12
+ * of passing positional arguments.
13
+ */
7
14
  import chalk from 'chalk';
8
15
  import { marked } from 'marked';
9
16
  import stripAnsi from 'strip-ansi';
@@ -13,37 +20,44 @@ import { colorize } from '../ink/colorize.js';
13
20
  import { getActiveTheme } from '../theme.js';
14
21
  import { logForDebugging } from '../utils/debug.js';
15
22
  import { createHyperlink } from './hyperlink.js';
16
- // Ported from the leaked Claude Code source (src/utils/markdown.ts), with the
17
- // app-level theme/color plumbing replaced by fixed ANSI styling and
18
- // stripPromptXMLTags inlined. Renders marked tokens to ANSI strings.
19
- const BLOCKQUOTE_BAR = '\u258e'; // ▎ - left one-quarter block
20
- const STRIPPED_TAGS_RE = /<(commit_analysis|context|function_analysis|pr_analysis)>.*?<\/\1>\n?/gs;
21
- /** Inline code color: the active theme's permission accent (Gentle Mist Blue). */
22
- const permissionColor = (text) => colorize(text, getActiveTheme().permission, 'foreground');
23
+ // '\n' is used unconditionally — os.EOL is '\r\n' on Windows, and the stray
24
+ // '\r' breaks the character-to-segment mapping in applyStylesToWrappedText,
25
+ // shifting styled text to the right.
26
+ const EOL = '\n';
27
+ /** Left one-quarter block (U+258E), the blockquote gutter marker. */
28
+ const QUOTE_BAR = '\u258e';
29
+ /** Tool-analysis tag blocks that carry no user-facing content; dropped before lexing. */
30
+ const TOOL_ANALYSIS_TAG_BLOCKS = /<(commit_analysis|context|function_analysis|pr_analysis)>.*?<\/\1>\n?/gs;
31
+ /**
32
+ * Matches `owner/repo#NNN` style GitHub issue/PR references. Only the
33
+ * qualified form is recognized: a bare `#NNN` would guess the current
34
+ * repository and be wrong whenever the assistant discusses a different one.
35
+ * The owner segment excludes dots (GitHub usernames are alphanumerics plus
36
+ * hyphens) so hostnames like docs.example.io/guide#42 don't false-positive;
37
+ * the repo segment allows dots (e.g. cc.kurs.web). Lookbehind is avoided —
38
+ * it defeats YARR JIT in JSC.
39
+ */
40
+ const ISSUE_REFERENCE_PATTERN = /(^|[^\w./-])([A-Za-z0-9][\w-]*\/[A-Za-z0-9][\w.-]*)#(\d+)\b/g;
23
41
  /**
24
- * Strip tool-analysis XML tags (`<commit_analysis>`, `<context>`, `<function_analysis>`,
25
- * `<pr_analysis>`) and their contents, then trim the result.
26
- * @param content - Markdown text that may contain the wrapped tool-analysis tag blocks.
27
- * @returns The content with those blocks removed and surrounding whitespace trimmed.
42
+ * Strip tool-analysis XML blocks (`<commit_analysis>`, `<context>`,
43
+ * `<function_analysis>`, `<pr_analysis>`) and their contents, then trim.
44
+ * @param content - Markdown that may wrap the tool-analysis tag blocks.
45
+ * @returns The content with those blocks removed and whitespace trimmed.
28
46
  */
29
47
  export function stripPromptXMLTags(content) {
30
- return content.replace(STRIPPED_TAGS_RE, '').trim();
48
+ return content.replace(TOOL_ANALYSIS_TAG_BLOCKS, '').trim();
31
49
  }
32
- // Use \n unconditionally — os.EOL is \r\n on Windows, and the extra \r
33
- // breaks the character-to-segment mapping in applyStylesToWrappedText,
34
- // causing styled text to shift right.
35
- const EOL = '\n';
36
- let markedConfigured = false;
50
+ let markedInitialized = false;
37
51
  /**
38
- * Configure the shared `marked` instance once: disable strikethrough parsing so
39
- * `~100` renders literally instead of as deleted text.
52
+ * Configure the shared `marked` instance once. Strikethrough parsing is
53
+ * disabled so that `~100` renders literally instead of as deleted text —
54
+ * models use `~` far more often for "approximate" than for real
55
+ * strikethrough.
40
56
  */
41
57
  export function configureMarked() {
42
- if (markedConfigured)
58
+ if (markedInitialized)
43
59
  return;
44
- markedConfigured = true;
45
- // Disable strikethrough parsing - the model often uses ~ for "approximate"
46
- // (e.g., ~100) and rarely intends actual strikethrough formatting
60
+ markedInitialized = true;
47
61
  marked.use({
48
62
  tokenizer: {
49
63
  del() {
@@ -52,6 +66,34 @@ export function configureMarked() {
52
66
  },
53
67
  });
54
68
  }
69
+ /** Inline code is painted with the active theme's permission accent. */
70
+ function paintInlineCode(text) {
71
+ return colorize(text, getActiveTheme().permission, 'foreground');
72
+ }
73
+ /** A fresh context for block-level children: list state reset, no parent. */
74
+ function fresh(state) {
75
+ return { highlight: state.highlight, parent: null, listDepth: 0, ordinal: null };
76
+ }
77
+ /** Same context, different parent token. */
78
+ function withParent(state, parent) {
79
+ return { ...state, parent };
80
+ }
81
+ /** Inline-styled children keep the outer parent but shed list context. */
82
+ function inlineChildren(state) {
83
+ return { ...state, listDepth: 0, ordinal: null };
84
+ }
85
+ /**
86
+ * Render one marked token to ANSI text, recursing into child tokens.
87
+ * @param token - The marked token to render.
88
+ * @param listDepth - Nesting depth of the enclosing list; drives indentation and numbering style.
89
+ * @param orderedListNumber - Current ordinal of the enclosing ordered list item, or null for unordered lists.
90
+ * @param parent - The parent token; linkification is skipped inside links and prefixes are added inside list items.
91
+ * @param highlight - Optional cli-highlight surface for code blocks; null disables syntax highlighting.
92
+ * @returns The rendered ANSI string for the token, or '' for unrendered token types.
93
+ */
94
+ export function formatToken(token, listDepth = 0, orderedListNumber = null, parent = null, highlight = null) {
95
+ return dispatch(token, { highlight, parent, listDepth, ordinal: orderedListNumber });
96
+ }
55
97
  /**
56
98
  * Render markdown content to ANSI-styled text via the shared `marked` instance.
57
99
  * @param content - Markdown source to render.
@@ -60,231 +102,225 @@ export function configureMarked() {
60
102
  */
61
103
  export function applyMarkdown(content, highlight = null) {
62
104
  configureMarked();
105
+ const rootState = {
106
+ highlight,
107
+ parent: null,
108
+ listDepth: 0,
109
+ ordinal: null,
110
+ };
63
111
  return marked
64
112
  .lexer(stripPromptXMLTags(content))
65
- .map(_ => formatToken(_, 0, null, null, highlight))
113
+ .map(token => dispatch(token, rootState))
66
114
  .join('')
67
115
  .trim();
68
116
  }
69
117
  /**
70
- * Render one marked token to ANSI text, recursing into child tokens.
71
- * @param token - The marked token to render.
72
- * @param listDepth - Nesting depth of the enclosing list; drives indentation and numbering style.
73
- * @param orderedListNumber - Current ordinal of the enclosing ordered list item, or null for unordered lists.
74
- * @param parent - The parent token; linkification is skipped inside links and prefixes are added inside list items.
75
- * @param highlight - Optional cli-highlight surface for code blocks; null disables syntax highlighting.
76
- * @returns The rendered ANSI string for the token, or '' for unrendered token types.
118
+ * Type guard that narrows to the concrete marked token of `kind`.
119
+ * Plain `switch` narrowing fails here: Tokens.Generic declares `type: string`,
120
+ * so every case keeps Generic in the union. Guarding against MarkedToken
121
+ * (which excludes Generic) yields exact types for the per-type renderers.
77
122
  */
78
- export function formatToken(token, listDepth = 0, orderedListNumber = null, parent = null, highlight = null) {
79
- switch (token.type) {
80
- case 'blockquote': {
81
- const inner = (token.tokens ?? [])
82
- .map(_ => formatToken(_, 0, null, null, highlight))
83
- .join('');
84
- // Prefix each line with a dim vertical bar. Keep text italic but at
85
- // normal brightness — chalk.dim is nearly invisible on dark themes.
86
- const bar = chalk.dim(BLOCKQUOTE_BAR);
87
- return inner
88
- .split(EOL)
89
- .map(line => stripAnsi(line).trim() ? `${bar} ${chalk.italic(line)}` : line)
90
- .join(EOL);
91
- }
92
- case 'code': {
93
- if (!highlight) {
94
- return token.text + EOL;
95
- }
96
- let language = 'plaintext';
97
- if (token.lang) {
98
- if (highlight.supportsLanguage(token.lang)) {
99
- language = token.lang;
100
- }
101
- else {
102
- logForDebugging(`Language not supported while highlighting code, falling back to plaintext: ${token.lang}`);
103
- }
104
- }
105
- return highlight.highlight(token.text, { language }) + EOL;
106
- }
107
- case 'codespan': {
108
- // inline code
109
- return permissionColor(token.text);
110
- }
111
- case 'em':
112
- return chalk.italic((token.tokens ?? [])
113
- .map(_ => formatToken(_, 0, null, parent, highlight))
114
- .join(''));
115
- case 'strong':
116
- return chalk.bold((token.tokens ?? [])
117
- .map(_ => formatToken(_, 0, null, parent, highlight))
118
- .join(''));
119
- case 'heading':
120
- switch (token.depth) {
121
- case 1: // h1
122
- return (chalk.bold.italic.underline((token.tokens ?? [])
123
- .map(_ => formatToken(_, 0, null, null, highlight))
124
- .join('')) +
125
- EOL +
126
- EOL);
127
- case 2: // h2
128
- return (chalk.bold((token.tokens ?? [])
129
- .map(_ => formatToken(_, 0, null, null, highlight))
130
- .join('')) +
131
- EOL +
132
- EOL);
133
- default: // h3+
134
- return (chalk.bold((token.tokens ?? [])
135
- .map(_ => formatToken(_, 0, null, null, highlight))
136
- .join('')) +
137
- EOL +
138
- EOL);
139
- }
140
- case 'hr':
141
- return '---';
142
- case 'image':
143
- return token.href;
144
- case 'link': {
145
- // Prevent mailto links from being displayed as clickable links
146
- if (token.href.startsWith('mailto:')) {
147
- // Extract email from mailto: link and display as plain text
148
- const email = token.href.replace(/^mailto:/, '');
149
- return email;
150
- }
151
- // Extract display text from the link's child tokens
152
- const linkText = (token.tokens ?? [])
153
- .map(_ => formatToken(_, 0, null, token, highlight))
154
- .join('');
155
- const plainLinkText = stripAnsi(linkText);
156
- // If the link has meaningful display text (different from the URL),
157
- // show it as a clickable hyperlink. In terminals that support OSC 8,
158
- // users see the text and can hover/click to see the URL.
159
- if (plainLinkText && plainLinkText !== token.href) {
160
- return createHyperlink(token.href, linkText);
161
- }
162
- // When the display text matches the URL (or is empty), just show the URL
163
- return createHyperlink(token.href);
164
- }
165
- case 'list': {
166
- return token.items
167
- .map((_, index) => formatToken(_, listDepth, token.ordered ? token.start + index : null, token, highlight))
168
- .join('');
123
+ function isToken(token, kind) {
124
+ return token.type === kind;
125
+ }
126
+ /** Fan-out point: narrows the token union, then delegates to the per-type render functions. */
127
+ function dispatch(token, state) {
128
+ if (isToken(token, 'blockquote'))
129
+ return renderBlockquote(token, state);
130
+ if (isToken(token, 'code'))
131
+ return renderCodeBlock(token, state);
132
+ if (isToken(token, 'codespan'))
133
+ return paintInlineCode(token.text);
134
+ if (isToken(token, 'em'))
135
+ return renderEmphasis(token, state);
136
+ if (isToken(token, 'strong'))
137
+ return renderStrong(token, state);
138
+ if (isToken(token, 'heading'))
139
+ return renderHeading(token, state);
140
+ if (isToken(token, 'hr'))
141
+ return '---';
142
+ if (isToken(token, 'image'))
143
+ return token.href;
144
+ if (isToken(token, 'link'))
145
+ return renderLink(token, state);
146
+ if (isToken(token, 'list'))
147
+ return renderList(token, state);
148
+ if (isToken(token, 'list_item'))
149
+ return renderListItem(token, state);
150
+ if (isToken(token, 'paragraph'))
151
+ return renderParagraph(token, state);
152
+ if (isToken(token, 'space') || isToken(token, 'br'))
153
+ return EOL;
154
+ if (isToken(token, 'text'))
155
+ return renderText(token, state);
156
+ if (isToken(token, 'table'))
157
+ return renderTable(token, state);
158
+ if (isToken(token, 'escape'))
159
+ return token.text;
160
+ if (isToken(token, 'def') || isToken(token, 'del') || isToken(token, 'html')) {
161
+ // Link definitions, strikethrough, and raw HTML carry no ANSI
162
+ // representation.
163
+ return '';
164
+ }
165
+ // Unknown / extension token types render as nothing.
166
+ return '';
167
+ }
168
+ function renderBlockquote(token, state) {
169
+ const inner = token.tokens.map(child => dispatch(child, fresh(state))).join('');
170
+ // Dim gutter bar per line; keep the text italic but at normal brightness —
171
+ // chalk.dim is nearly invisible on dark themes.
172
+ const gutter = chalk.dim(QUOTE_BAR);
173
+ return inner
174
+ .split(EOL)
175
+ .map(line => (stripAnsi(line).trim() ? `${gutter} ${chalk.italic(line)}` : line))
176
+ .join(EOL);
177
+ }
178
+ function renderCodeBlock(token, state) {
179
+ if (!state.highlight) {
180
+ return token.text + EOL;
181
+ }
182
+ let language = 'plaintext';
183
+ if (token.lang) {
184
+ if (state.highlight.supportsLanguage(token.lang)) {
185
+ language = token.lang;
169
186
  }
170
- case 'list_item':
171
- return (token.tokens ?? [])
172
- .map(_ => `${' '.repeat(listDepth)}${formatToken(_, listDepth + 1, orderedListNumber, token, highlight)}`)
173
- .join('');
174
- case 'paragraph':
175
- return ((token.tokens ?? [])
176
- .map(_ => formatToken(_, 0, null, null, highlight))
177
- .join('') + EOL);
178
- case 'space':
179
- return EOL;
180
- case 'br':
181
- return EOL;
182
- case 'text':
183
- if (parent?.type === 'link') {
184
- // Already inside a markdown link — the link handler will wrap this
185
- // in an OSC 8 hyperlink. Linkifying here would nest a second OSC 8
186
- // sequence, and terminals honor the innermost one, overriding the
187
- // link's actual href.
188
- return token.text;
189
- }
190
- if (parent?.type === 'list_item') {
191
- return `${orderedListNumber === null ? '-' : getListNumber(listDepth, orderedListNumber) + '.'} ${token.tokens ? token.tokens.map(_ => formatToken(_, listDepth, orderedListNumber, token, highlight)).join('') : linkifyIssueReferences(token.text)}${EOL}`;
192
- }
193
- return linkifyIssueReferences(token.text);
194
- case 'table': {
195
- const tableToken = token;
196
- // Helper function to get the text content that will be displayed (after stripAnsi)
197
- function getDisplayText(tokens) {
198
- return stripAnsi(tokens
199
- ?.map(_ => formatToken(_, 0, null, null, highlight))
200
- .join('') ?? '');
201
- }
202
- // Determine column widths based on displayed content (without formatting)
203
- const columnWidths = tableToken.header.map((header, index) => {
204
- let maxWidth = stringWidth(getDisplayText(header.tokens));
205
- for (const row of tableToken.rows) {
206
- const cellLength = stringWidth(getDisplayText(row[index]?.tokens));
207
- maxWidth = Math.max(maxWidth, cellLength);
208
- }
209
- return Math.max(maxWidth, 3); // Minimum width of 3
210
- });
211
- // Format header row
212
- let tableOutput = '| ';
213
- tableToken.header.forEach((header, index) => {
214
- const content = header.tokens
215
- ?.map(_ => formatToken(_, 0, null, null, highlight))
216
- .join('') ?? '';
217
- const displayText = getDisplayText(header.tokens);
218
- const width = columnWidths[index];
219
- const align = tableToken.align?.[index];
220
- tableOutput +=
221
- padAligned(content, stringWidth(displayText), width, align) + ' | ';
222
- });
223
- tableOutput = tableOutput.trimEnd() + EOL;
224
- // Add separator row
225
- tableOutput += '|';
226
- columnWidths.forEach((width) => {
227
- // Always use dashes, don't show alignment colons in the output
228
- const separator = '-'.repeat(width + 2); // +2 for spaces on each side
229
- tableOutput += separator + '|';
230
- });
231
- tableOutput += EOL;
232
- // Format data rows
233
- tableToken.rows.forEach((row) => {
234
- tableOutput += '| ';
235
- row.forEach((cell, index) => {
236
- const content = cell.tokens
237
- ?.map(_ => formatToken(_, 0, null, null, highlight))
238
- .join('') ?? '';
239
- const displayText = getDisplayText(cell.tokens);
240
- const width = columnWidths[index];
241
- const align = tableToken.align?.[index];
242
- tableOutput +=
243
- padAligned(content, stringWidth(displayText), width, align) + ' | ';
244
- });
245
- tableOutput = tableOutput.trimEnd() + EOL;
246
- });
247
- return tableOutput + EOL;
187
+ else {
188
+ logForDebugging(`Language not supported while highlighting code, falling back to plaintext: ${token.lang}`);
248
189
  }
249
- case 'escape':
250
- // Markdown escape: \) → ), \\ → \, etc.
251
- return token.text;
252
- case 'def':
253
- case 'del':
254
- case 'html':
255
- // These token types are not rendered
256
- return '';
257
190
  }
258
- return '';
191
+ return state.highlight.highlight(token.text, { language }) + EOL;
192
+ }
193
+ function renderEmphasis(token, state) {
194
+ const inner = token.tokens.map(child => dispatch(child, inlineChildren(state))).join('');
195
+ return chalk.italic(inner);
196
+ }
197
+ function renderStrong(token, state) {
198
+ const inner = token.tokens.map(child => dispatch(child, inlineChildren(state))).join('');
199
+ return chalk.bold(inner);
200
+ }
201
+ function renderHeading(token, state) {
202
+ const text = token.tokens.map(child => dispatch(child, fresh(state))).join('');
203
+ // H1 gets the full banner treatment; every deeper level shares the bold style.
204
+ const styled = token.depth === 1 ? chalk.bold.italic.underline(text) : chalk.bold(text);
205
+ return styled + EOL + EOL;
206
+ }
207
+ function renderLink(token, state) {
208
+ // mailto: links are shown as plain email addresses, not clickable links.
209
+ if (token.href.startsWith('mailto:')) {
210
+ return token.href.slice('mailto:'.length);
211
+ }
212
+ const label = token.tokens
213
+ .map(child => dispatch(child, withParent(fresh(state), token)))
214
+ .join('');
215
+ const plainLabel = stripAnsi(label);
216
+ // Meaningful display text (different from the URL) becomes a clickable
217
+ // hyperlink; otherwise just show the URL.
218
+ if (plainLabel && plainLabel !== token.href) {
219
+ return createHyperlink(token.href, label);
220
+ }
221
+ return createHyperlink(token.href);
222
+ }
223
+ function renderList(token, state) {
224
+ // ordered lists always carry a numeric start ("" only occurs for unordered),
225
+ // but the type says otherwise, so coerce defensively.
226
+ const start = typeof token.start === 'number' ? token.start : 1;
227
+ return token.items
228
+ .map((item, index) => {
229
+ const ordinal = token.ordered ? start + index : null;
230
+ return dispatch(item, { ...state, ordinal });
231
+ })
232
+ .join('');
233
+ }
234
+ function renderListItem(token, state) {
235
+ const indent = ' '.repeat(state.listDepth);
236
+ const childState = withParent({ ...state, listDepth: state.listDepth + 1 }, token);
237
+ return token.tokens.map(child => indent + dispatch(child, childState)).join('');
238
+ }
239
+ function renderParagraph(token, state) {
240
+ return token.tokens.map(child => dispatch(child, fresh(state))).join('') + EOL;
241
+ }
242
+ function renderText(token, state) {
243
+ const { parent, listDepth, ordinal } = state;
244
+ if (parent?.type === 'link') {
245
+ // Already inside a link: the link handler wraps everything in one OSC 8
246
+ // sequence, and a nested one would override the real href. Stay plain.
247
+ return token.text;
248
+ }
249
+ if (parent?.type === 'list_item') {
250
+ const bullet = ordinal === null ? '-' : `${formatListMarker(listDepth, ordinal)}.`;
251
+ const body = token.tokens
252
+ ? token.tokens.map(child => dispatch(child, withParent(state, token))).join('')
253
+ : linkifyIssueReferences(token.text);
254
+ return `${bullet} ${body}${EOL}`;
255
+ }
256
+ return linkifyIssueReferences(token.text);
257
+ }
258
+ function renderTable(token, state) {
259
+ const rows = [token.header, ...token.rows];
260
+ // Column widths derive from the visible (ANSI-stripped) cell text; 3 is
261
+ // the minimum so a separator row always reads as a table divider.
262
+ const columnWidths = token.header.map((_, colIndex) => {
263
+ let widest = 3;
264
+ for (const row of rows) {
265
+ widest = Math.max(widest, stringWidth(cellDisplayText(row[colIndex], state)));
266
+ }
267
+ return widest;
268
+ });
269
+ const headerLine = renderTableRow(token.header, columnWidths, token.align, state);
270
+ // Dashes only — alignment colons are not echoed into the output.
271
+ const divider = `|${columnWidths.map(width => `${'-'.repeat(width + 2)}|`).join('')}${EOL}`;
272
+ const bodyLines = token.rows
273
+ .map(row => renderTableRow(row, columnWidths, token.align, state))
274
+ .join('');
275
+ return headerLine + divider + bodyLines + EOL;
276
+ }
277
+ /** Rendered cell content, stripped of ANSI codes, for width measurement. */
278
+ function cellDisplayText(cell, state) {
279
+ return stripAnsi(cell.tokens.map(child => dispatch(child, fresh(state))).join(''));
280
+ }
281
+ function renderTableRow(cells, columnWidths, aligns, state) {
282
+ let line = '| ';
283
+ cells.forEach((cell, index) => {
284
+ const content = cell.tokens.map(child => dispatch(child, fresh(state))).join('');
285
+ line +=
286
+ padAligned(content, stringWidth(cellDisplayText(cell, state)), columnWidths[index], aligns[index]) + ' | ';
287
+ });
288
+ return line.trimEnd() + EOL;
259
289
  }
260
- // Matches owner/repo#NNN style GitHub issue/PR references. The qualified form
261
- // is unambiguous — bare #NNN was removed because it guessed the current repo
262
- // and was wrong whenever the assistant discussed a different one.
263
- // Owner segment disallows dots (GitHub usernames are alphanumerics + hyphens
264
- // only) so hostnames like docs.github.io/guide#42 don't false-positive. Repo
265
- // segment allows dots (e.g. cc.kurs.web). Lookbehind is avoided — it defeats
266
- // YARR JIT in JSC.
267
- const ISSUE_REF_PATTERN = /(^|[^\w./-])([A-Za-z0-9][\w-]*\/[A-Za-z0-9][\w.-]*)#(\d+)\b/g;
268
290
  /**
269
- * Replaces owner/repo#123 references with clickable hyperlinks to GitHub.
291
+ * Replace `owner/repo#123` references with clickable GitHub links.
292
+ * No-op when the terminal lacks OSC 8 hyperlink support.
270
293
  */
271
294
  function linkifyIssueReferences(text) {
272
295
  if (!supportsHyperlinks()) {
273
296
  return text;
274
297
  }
275
- return text.replace(ISSUE_REF_PATTERN, (_match, prefix, repo, num) => prefix +
276
- createHyperlink(`https://github.com/${repo}/issues/${num}`, `${repo}#${num}`));
298
+ return text.replace(ISSUE_REFERENCE_PATTERN, (_match, prefix, repo, issueNumber) => prefix +
299
+ createHyperlink(`https://github.com/${repo}/issues/${issueNumber}`, `${repo}#${issueNumber}`));
277
300
  }
278
- function numberToLetter(n) {
279
- let result = '';
280
- while (n > 0) {
281
- n--;
282
- result = String.fromCharCode(97 + (n % 26)) + result;
283
- n = Math.floor(n / 26);
301
+ /**
302
+ * Ordered-list marker for a given nesting depth: decimal at depth 1,
303
+ * letters at depth 2, roman numerals at depth 3, decimal beyond.
304
+ */
305
+ function formatListMarker(listDepth, ordinal) {
306
+ switch (listDepth) {
307
+ case 2:
308
+ return toAlphaIndex(ordinal);
309
+ case 3:
310
+ return toRomanNumeral(ordinal);
311
+ default:
312
+ return ordinal.toString();
284
313
  }
285
- return result;
286
314
  }
287
- const ROMAN_VALUES = [
315
+ /** Bijective base-26 conversion: 1 → a, 26 → z, 27 → aa. */
316
+ function toAlphaIndex(n) {
317
+ if (n <= 0)
318
+ return '';
319
+ const digit = String.fromCharCode(97 + ((n - 1) % 26));
320
+ return toAlphaIndex(Math.floor((n - 1) / 26)) + digit;
321
+ }
322
+ /** Standard greedy roman-numeral symbol table (lowercase). */
323
+ const ROMAN_SYMBOLS = [
288
324
  [1000, 'm'],
289
325
  [900, 'cm'],
290
326
  [500, 'd'],
@@ -299,33 +335,20 @@ const ROMAN_VALUES = [
299
335
  [4, 'iv'],
300
336
  [1, 'i'],
301
337
  ];
302
- function numberToRoman(n) {
303
- let result = '';
304
- for (const [value, numeral] of ROMAN_VALUES) {
338
+ function toRomanNumeral(n) {
339
+ let out = '';
340
+ for (const [value, glyph] of ROMAN_SYMBOLS) {
305
341
  while (n >= value) {
306
- result += numeral;
342
+ out += glyph;
307
343
  n -= value;
308
344
  }
309
345
  }
310
- return result;
311
- }
312
- function getListNumber(listDepth, orderedListNumber) {
313
- switch (listDepth) {
314
- case 0:
315
- case 1:
316
- return orderedListNumber.toString();
317
- case 2:
318
- return numberToLetter(orderedListNumber);
319
- case 3:
320
- return numberToRoman(orderedListNumber);
321
- default:
322
- return orderedListNumber.toString();
323
- }
346
+ return out;
324
347
  }
325
348
  /**
326
- * Pad `content` to `targetWidth` according to alignment. `displayWidth` is the
327
- * visible width of `content` (caller computes this, e.g. via stringWidth on
328
- * stripAnsi'd text, so ANSI codes in `content` don't affect padding).
349
+ * Pad `content` to `targetWidth` according to alignment. `displayWidth` is
350
+ * the visible width of `content` (callers compute it via stringWidth on the
351
+ * ANSI-stripped text, so embedded escape codes don't affect padding).
329
352
  * @param content - The text to pad, which may carry ANSI codes.
330
353
  * @param displayWidth - Visible width of `content` without ANSI codes.
331
354
  * @param targetWidth - Column width to pad `content` to.
@@ -333,13 +356,13 @@ function getListNumber(listDepth, orderedListNumber) {
333
356
  * @returns `content` padded with spaces to `targetWidth`.
334
357
  */
335
358
  export function padAligned(content, displayWidth, targetWidth, align) {
336
- const padding = Math.max(0, targetWidth - displayWidth);
359
+ const extra = Math.max(0, targetWidth - displayWidth);
337
360
  if (align === 'center') {
338
- const leftPad = Math.floor(padding / 2);
339
- return ' '.repeat(leftPad) + content + ' '.repeat(padding - leftPad);
361
+ const left = Math.floor(extra / 2);
362
+ return ' '.repeat(left) + content + ' '.repeat(extra - left);
340
363
  }
341
364
  if (align === 'right') {
342
- return ' '.repeat(padding) + content;
365
+ return ' '.repeat(extra) + content;
343
366
  }
344
- return content + ' '.repeat(padding);
367
+ return content + ' '.repeat(extra);
345
368
  }
@@ -1,15 +1,18 @@
1
- /** `(ctrl+o to expand)` hint in dim chalk, like the leak's ctrlOToExpand().
1
+ /**
2
+ * The `(ctrl+o to expand)` hint, dimmed.
2
3
  * @returns The dim hint text.
3
4
  */
4
5
  export declare function ctrlOToExpand(): string;
5
6
  /**
6
- * Renders the content with line-based truncation for terminal display.
7
- * If the content exceeds the maximum number of lines, it truncates the content
8
- * and adds a message indicating the number of additional lines.
7
+ * Render `content` with line-based truncation for terminal display.
8
+ * Content that fits in the visible budget is returned unchanged (modulo
9
+ * trailing whitespace); longer content is folded with an overflow hint.
9
10
  * @param content - Text to render; trailing whitespace is trimmed.
10
- * @param terminalWidth - Terminal width in columns; the wrap width reserves 4 columns of padding.
11
- * @param suppressExpandHint - When true, omit the `(ctrl+o to expand)` suffix from the overflow hint.
12
- * @returns The truncated text, or '' when `content` is blank after trimming.
11
+ * @param terminalWidth - Terminal width in columns; the wrap width reserves
12
+ * 4 columns of padding.
13
+ * @param suppressExpandHint - When true, omit the `(ctrl+o to expand)`
14
+ * suffix from the overflow hint.
15
+ * @returns The truncated text, or `''` when `content` is blank after trimming.
13
16
  */
14
17
  export declare function renderTruncatedContent(content: string, terminalWidth: number, suppressExpandHint?: boolean): string;
15
18
  //# sourceMappingURL=terminal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../../src/cc/terminal.ts"],"names":[],"mappings":"AAsDA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,kBAAkB,UAAQ,GACzB,MAAM,CAsCR"}
1
+ {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../../src/cc/terminal.ts"],"names":[],"mappings":"AA+DA;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,kBAAkB,UAAQ,GACzB,MAAM,CAuCR"}