@prestyj/cli 4.3.209 → 4.3.237

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 (889) hide show
  1. package/README.md +17 -9
  2. package/dist/cli/auth.d.ts +4 -0
  3. package/dist/cli/auth.d.ts.map +1 -0
  4. package/dist/cli/auth.js +344 -0
  5. package/dist/cli/auth.js.map +1 -0
  6. package/dist/cli/command-routing.d.ts +28 -0
  7. package/dist/cli/command-routing.d.ts.map +1 -0
  8. package/dist/cli/command-routing.js +53 -0
  9. package/dist/cli/command-routing.js.map +1 -0
  10. package/dist/cli/command-routing.test.d.ts +2 -0
  11. package/dist/cli/command-routing.test.d.ts.map +1 -0
  12. package/dist/cli/command-routing.test.js +60 -0
  13. package/dist/cli/command-routing.test.js.map +1 -0
  14. package/dist/cli/mcp.d.ts +2 -0
  15. package/dist/cli/mcp.d.ts.map +1 -0
  16. package/dist/cli/mcp.js +309 -0
  17. package/dist/cli/mcp.js.map +1 -0
  18. package/dist/cli/pixel.d.ts +27 -0
  19. package/dist/cli/pixel.d.ts.map +1 -0
  20. package/dist/cli/pixel.js +103 -0
  21. package/dist/cli/pixel.js.map +1 -0
  22. package/dist/cli/shared.d.ts +13 -0
  23. package/dist/cli/shared.d.ts.map +1 -0
  24. package/dist/cli/shared.js +82 -0
  25. package/dist/cli/shared.js.map +1 -0
  26. package/dist/cli.d.ts +4 -1
  27. package/dist/cli.d.ts.map +1 -1
  28. package/dist/cli.js +174 -724
  29. package/dist/cli.js.map +1 -1
  30. package/dist/config.d.ts +4 -1
  31. package/dist/config.d.ts.map +1 -1
  32. package/dist/config.js +14 -1
  33. package/dist/config.js.map +1 -1
  34. package/dist/config.test.d.ts +2 -0
  35. package/dist/config.test.d.ts.map +1 -0
  36. package/dist/config.test.js +29 -0
  37. package/dist/config.test.js.map +1 -0
  38. package/dist/core/agent-session-compaction.test.d.ts +2 -0
  39. package/dist/core/agent-session-compaction.test.d.ts.map +1 -0
  40. package/dist/core/agent-session-compaction.test.js +114 -0
  41. package/dist/core/agent-session-compaction.test.js.map +1 -0
  42. package/dist/core/agent-session.d.ts +0 -23
  43. package/dist/core/agent-session.d.ts.map +1 -1
  44. package/dist/core/agent-session.js +6 -101
  45. package/dist/core/agent-session.js.map +1 -1
  46. package/dist/core/checkpoint-store.d.ts +93 -0
  47. package/dist/core/checkpoint-store.d.ts.map +1 -0
  48. package/dist/core/checkpoint-store.js +188 -0
  49. package/dist/core/checkpoint-store.js.map +1 -0
  50. package/dist/core/checkpoint-store.test.d.ts +2 -0
  51. package/dist/core/checkpoint-store.test.d.ts.map +1 -0
  52. package/dist/core/checkpoint-store.test.js +111 -0
  53. package/dist/core/checkpoint-store.test.js.map +1 -0
  54. package/dist/core/compaction/compactor.d.ts +4 -0
  55. package/dist/core/compaction/compactor.d.ts.map +1 -1
  56. package/dist/core/compaction/compactor.js +81 -28
  57. package/dist/core/compaction/compactor.js.map +1 -1
  58. package/dist/core/compaction/compactor.test.js +33 -9
  59. package/dist/core/compaction/compactor.test.js.map +1 -1
  60. package/dist/core/compaction/token-estimator.test.js +1 -1
  61. package/dist/core/continue-replay-inventory.test.d.ts +2 -0
  62. package/dist/core/continue-replay-inventory.test.d.ts.map +1 -0
  63. package/dist/core/continue-replay-inventory.test.js +42 -0
  64. package/dist/core/continue-replay-inventory.test.js.map +1 -0
  65. package/dist/core/goal-controller.d.ts +4 -0
  66. package/dist/core/goal-controller.d.ts.map +1 -1
  67. package/dist/core/goal-controller.js +223 -32
  68. package/dist/core/goal-controller.js.map +1 -1
  69. package/dist/core/goal-controller.test.js +387 -22
  70. package/dist/core/goal-controller.test.js.map +1 -1
  71. package/dist/core/goal-lifecycle-smoke.test.js +49 -8
  72. package/dist/core/goal-lifecycle-smoke.test.js.map +1 -1
  73. package/dist/core/goal-prerequisites.d.ts +23 -0
  74. package/dist/core/goal-prerequisites.d.ts.map +1 -0
  75. package/dist/core/goal-prerequisites.js +114 -0
  76. package/dist/core/goal-prerequisites.js.map +1 -0
  77. package/dist/core/goal-prerequisites.test.d.ts +2 -0
  78. package/dist/core/goal-prerequisites.test.d.ts.map +1 -0
  79. package/dist/core/goal-prerequisites.test.js +118 -0
  80. package/dist/core/goal-prerequisites.test.js.map +1 -0
  81. package/dist/core/goal-store.d.ts +12 -1
  82. package/dist/core/goal-store.d.ts.map +1 -1
  83. package/dist/core/goal-store.js +146 -40
  84. package/dist/core/goal-store.js.map +1 -1
  85. package/dist/core/goal-store.test.js +65 -8
  86. package/dist/core/goal-store.test.js.map +1 -1
  87. package/dist/core/goal-verifier.d.ts.map +1 -1
  88. package/dist/core/goal-verifier.js +4 -1
  89. package/dist/core/goal-verifier.js.map +1 -1
  90. package/dist/core/goal-verifier.test.js +43 -0
  91. package/dist/core/goal-verifier.test.js.map +1 -1
  92. package/dist/core/goal-worker.d.ts +2 -0
  93. package/dist/core/goal-worker.d.ts.map +1 -1
  94. package/dist/core/goal-worker.js +31 -7
  95. package/dist/core/goal-worker.js.map +1 -1
  96. package/dist/core/goal-worker.test.js +44 -0
  97. package/dist/core/goal-worker.test.js.map +1 -1
  98. package/dist/core/ideal-review.d.ts +20 -0
  99. package/dist/core/ideal-review.d.ts.map +1 -0
  100. package/dist/core/ideal-review.js +55 -0
  101. package/dist/core/ideal-review.js.map +1 -0
  102. package/dist/core/ideal-review.test.d.ts +2 -0
  103. package/dist/core/ideal-review.test.d.ts.map +1 -0
  104. package/dist/core/ideal-review.test.js +59 -0
  105. package/dist/core/ideal-review.test.js.map +1 -0
  106. package/dist/core/index.d.ts +1 -0
  107. package/dist/core/index.d.ts.map +1 -1
  108. package/dist/core/index.js +1 -0
  109. package/dist/core/index.js.map +1 -1
  110. package/dist/core/loop-breaker.d.ts +46 -0
  111. package/dist/core/loop-breaker.d.ts.map +1 -0
  112. package/dist/core/loop-breaker.js +79 -0
  113. package/dist/core/loop-breaker.js.map +1 -0
  114. package/dist/core/loop-breaker.test.d.ts +2 -0
  115. package/dist/core/loop-breaker.test.d.ts.map +1 -0
  116. package/dist/core/loop-breaker.test.js +110 -0
  117. package/dist/core/loop-breaker.test.js.map +1 -0
  118. package/dist/core/mcp/client.d.ts +20 -0
  119. package/dist/core/mcp/client.d.ts.map +1 -1
  120. package/dist/core/mcp/client.js +55 -11
  121. package/dist/core/mcp/client.js.map +1 -1
  122. package/dist/core/mcp/defaults.d.ts +7 -0
  123. package/dist/core/mcp/defaults.d.ts.map +1 -1
  124. package/dist/core/mcp/defaults.js +14 -0
  125. package/dist/core/mcp/defaults.js.map +1 -1
  126. package/dist/core/mcp/index.d.ts +6 -1
  127. package/dist/core/mcp/index.d.ts.map +1 -1
  128. package/dist/core/mcp/index.js +3 -1
  129. package/dist/core/mcp/index.js.map +1 -1
  130. package/dist/core/mcp/parse-add-command.d.ts +25 -0
  131. package/dist/core/mcp/parse-add-command.d.ts.map +1 -0
  132. package/dist/core/mcp/parse-add-command.js +220 -0
  133. package/dist/core/mcp/parse-add-command.js.map +1 -0
  134. package/dist/core/mcp/parse-add-command.test.d.ts +2 -0
  135. package/dist/core/mcp/parse-add-command.test.d.ts.map +1 -0
  136. package/dist/core/mcp/parse-add-command.test.js +75 -0
  137. package/dist/core/mcp/parse-add-command.test.js.map +1 -0
  138. package/dist/core/mcp/store.d.ts +80 -0
  139. package/dist/core/mcp/store.d.ts.map +1 -0
  140. package/dist/core/mcp/store.js +157 -0
  141. package/dist/core/mcp/store.js.map +1 -0
  142. package/dist/core/mcp/store.test.d.ts +2 -0
  143. package/dist/core/mcp/store.test.d.ts.map +1 -0
  144. package/dist/core/mcp/store.test.js +101 -0
  145. package/dist/core/mcp/store.test.js.map +1 -0
  146. package/dist/core/model-registry.d.ts +2 -2
  147. package/dist/core/model-registry.js +4 -4
  148. package/dist/core/model-registry.js.map +1 -1
  149. package/dist/core/model-registry.test.js +1 -1
  150. package/dist/core/model-registry.test.js.map +1 -1
  151. package/dist/core/prompt-commands.d.ts.map +1 -1
  152. package/dist/core/prompt-commands.js +64 -894
  153. package/dist/core/prompt-commands.js.map +1 -1
  154. package/dist/core/prompt-commands.test.js +49 -41
  155. package/dist/core/prompt-commands.test.js.map +1 -1
  156. package/dist/core/regrounding.d.ts +23 -0
  157. package/dist/core/regrounding.d.ts.map +1 -0
  158. package/dist/core/regrounding.js +21 -0
  159. package/dist/core/regrounding.js.map +1 -0
  160. package/dist/core/regrounding.test.d.ts +2 -0
  161. package/dist/core/regrounding.test.d.ts.map +1 -0
  162. package/dist/core/regrounding.test.js +38 -0
  163. package/dist/core/regrounding.test.js.map +1 -0
  164. package/dist/core/runtime-mode.d.ts +23 -0
  165. package/dist/core/runtime-mode.d.ts.map +1 -0
  166. package/dist/core/runtime-mode.js +30 -0
  167. package/dist/core/runtime-mode.js.map +1 -0
  168. package/dist/core/session-manager.d.ts +4 -0
  169. package/dist/core/session-manager.d.ts.map +1 -1
  170. package/dist/core/session-manager.js +20 -0
  171. package/dist/core/session-manager.js.map +1 -1
  172. package/dist/core/session-restore-display.test.d.ts +2 -0
  173. package/dist/core/session-restore-display.test.d.ts.map +1 -0
  174. package/dist/core/session-restore-display.test.js +78 -0
  175. package/dist/core/session-restore-display.test.js.map +1 -0
  176. package/dist/core/settings-manager.d.ts +4 -2
  177. package/dist/core/settings-manager.d.ts.map +1 -1
  178. package/dist/core/settings-manager.js +3 -6
  179. package/dist/core/settings-manager.js.map +1 -1
  180. package/dist/core/slash-commands.d.ts +0 -2
  181. package/dist/core/slash-commands.d.ts.map +1 -1
  182. package/dist/core/slash-commands.js +10 -15
  183. package/dist/core/slash-commands.js.map +1 -1
  184. package/dist/core/style-packs/index.js +1 -1
  185. package/dist/core/style-packs/index.js.map +1 -1
  186. package/dist/core/task-store.d.ts +26 -0
  187. package/dist/core/task-store.d.ts.map +1 -0
  188. package/dist/core/task-store.js +147 -0
  189. package/dist/core/task-store.js.map +1 -0
  190. package/dist/core/tasks-store.d.ts +24 -0
  191. package/dist/core/tasks-store.d.ts.map +1 -0
  192. package/dist/core/tasks-store.js +81 -0
  193. package/dist/core/tasks-store.js.map +1 -0
  194. package/dist/core/thinking-level.d.ts +5 -0
  195. package/dist/core/thinking-level.d.ts.map +1 -0
  196. package/dist/core/thinking-level.js +59 -0
  197. package/dist/core/thinking-level.js.map +1 -0
  198. package/dist/core/thinking-level.test.d.ts +2 -0
  199. package/dist/core/thinking-level.test.d.ts.map +1 -0
  200. package/dist/core/thinking-level.test.js +38 -0
  201. package/dist/core/thinking-level.test.js.map +1 -0
  202. package/dist/core/verify-commands.js +4 -4
  203. package/dist/core/verify-commands.js.map +1 -1
  204. package/dist/index.d.ts +1 -1
  205. package/dist/index.d.ts.map +1 -1
  206. package/dist/index.js +1 -1
  207. package/dist/index.js.map +1 -1
  208. package/dist/interactive.d.ts.map +1 -1
  209. package/dist/interactive.js +3 -1
  210. package/dist/interactive.js.map +1 -1
  211. package/dist/system-prompt.d.ts +5 -1
  212. package/dist/system-prompt.d.ts.map +1 -1
  213. package/dist/system-prompt.js +76 -48
  214. package/dist/system-prompt.js.map +1 -1
  215. package/dist/system-prompt.test.js +98 -46
  216. package/dist/system-prompt.test.js.map +1 -1
  217. package/dist/tools/bash.d.ts +6 -1
  218. package/dist/tools/bash.d.ts.map +1 -1
  219. package/dist/tools/bash.js +21 -3
  220. package/dist/tools/bash.js.map +1 -1
  221. package/dist/tools/checkpoint-hook.test.d.ts +2 -0
  222. package/dist/tools/checkpoint-hook.test.d.ts.map +1 -0
  223. package/dist/tools/checkpoint-hook.test.js +65 -0
  224. package/dist/tools/checkpoint-hook.test.js.map +1 -0
  225. package/dist/tools/edit-diff.d.ts +17 -4
  226. package/dist/tools/edit-diff.d.ts.map +1 -1
  227. package/dist/tools/edit-diff.js +78 -16
  228. package/dist/tools/edit-diff.js.map +1 -1
  229. package/dist/tools/edit-diff.test.js +31 -1
  230. package/dist/tools/edit-diff.test.js.map +1 -1
  231. package/dist/tools/edit-robustness.test.d.ts +2 -0
  232. package/dist/tools/edit-robustness.test.d.ts.map +1 -0
  233. package/dist/tools/edit-robustness.test.js +415 -0
  234. package/dist/tools/edit-robustness.test.js.map +1 -0
  235. package/dist/tools/edit.d.ts +8 -2
  236. package/dist/tools/edit.d.ts.map +1 -1
  237. package/dist/tools/edit.js +48 -20
  238. package/dist/tools/edit.js.map +1 -1
  239. package/dist/tools/edit.test.js +23 -22
  240. package/dist/tools/edit.test.js.map +1 -1
  241. package/dist/tools/enter-plan.d.ts +1 -1
  242. package/dist/tools/enter-plan.d.ts.map +1 -1
  243. package/dist/tools/enter-plan.js +8 -11
  244. package/dist/tools/enter-plan.js.map +1 -1
  245. package/dist/tools/exit-plan.d.ts.map +1 -1
  246. package/dist/tools/exit-plan.js +8 -9
  247. package/dist/tools/exit-plan.js.map +1 -1
  248. package/dist/tools/goal-mode.test.d.ts +2 -0
  249. package/dist/tools/goal-mode.test.d.ts.map +1 -0
  250. package/dist/tools/goal-mode.test.js +121 -0
  251. package/dist/tools/goal-mode.test.js.map +1 -0
  252. package/dist/tools/goals.d.ts +14 -2
  253. package/dist/tools/goals.d.ts.map +1 -1
  254. package/dist/tools/goals.js +257 -26
  255. package/dist/tools/goals.js.map +1 -1
  256. package/dist/tools/goals.test.js +365 -1
  257. package/dist/tools/goals.test.js.map +1 -1
  258. package/dist/tools/html-extract.d.ts +58 -0
  259. package/dist/tools/html-extract.d.ts.map +1 -0
  260. package/dist/tools/html-extract.js +130 -0
  261. package/dist/tools/html-extract.js.map +1 -0
  262. package/dist/tools/html-extract.test.d.ts +2 -0
  263. package/dist/tools/html-extract.test.d.ts.map +1 -0
  264. package/dist/tools/html-extract.test.js +60 -0
  265. package/dist/tools/html-extract.test.js.map +1 -0
  266. package/dist/tools/index.d.ts +16 -4
  267. package/dist/tools/index.d.ts.map +1 -1
  268. package/dist/tools/index.js +11 -7
  269. package/dist/tools/index.js.map +1 -1
  270. package/dist/tools/pdf-extract.d.ts +18 -0
  271. package/dist/tools/pdf-extract.d.ts.map +1 -0
  272. package/dist/tools/pdf-extract.js +43 -0
  273. package/dist/tools/pdf-extract.js.map +1 -0
  274. package/dist/tools/pdf-extract.test.d.ts +2 -0
  275. package/dist/tools/pdf-extract.test.d.ts.map +1 -0
  276. package/dist/tools/pdf-extract.test.js +15 -0
  277. package/dist/tools/pdf-extract.test.js.map +1 -0
  278. package/dist/tools/plan-mode.test.js +82 -221
  279. package/dist/tools/plan-mode.test.js.map +1 -1
  280. package/dist/tools/prompt-hints.d.ts.map +1 -1
  281. package/dist/tools/prompt-hints.js +6 -9
  282. package/dist/tools/prompt-hints.js.map +1 -1
  283. package/dist/tools/read-only-bash.d.ts +13 -0
  284. package/dist/tools/read-only-bash.d.ts.map +1 -0
  285. package/dist/tools/read-only-bash.js +155 -0
  286. package/dist/tools/read-only-bash.js.map +1 -0
  287. package/dist/tools/read-only-bash.test.d.ts +2 -0
  288. package/dist/tools/read-only-bash.test.d.ts.map +1 -0
  289. package/dist/tools/read-only-bash.test.js +47 -0
  290. package/dist/tools/read-only-bash.test.js.map +1 -0
  291. package/dist/tools/read.d.ts.map +1 -1
  292. package/dist/tools/read.js +14 -1
  293. package/dist/tools/read.js.map +1 -1
  294. package/dist/tools/read.test.js +4 -0
  295. package/dist/tools/read.test.js.map +1 -1
  296. package/dist/tools/screenshot.d.ts +25 -0
  297. package/dist/tools/screenshot.d.ts.map +1 -0
  298. package/dist/tools/screenshot.js +165 -0
  299. package/dist/tools/screenshot.js.map +1 -0
  300. package/dist/tools/screenshot.test.d.ts +2 -0
  301. package/dist/tools/screenshot.test.d.ts.map +1 -0
  302. package/dist/tools/screenshot.test.js +145 -0
  303. package/dist/tools/screenshot.test.js.map +1 -0
  304. package/dist/tools/subagent.d.ts +7 -2
  305. package/dist/tools/subagent.d.ts.map +1 -1
  306. package/dist/tools/subagent.js +32 -11
  307. package/dist/tools/subagent.js.map +1 -1
  308. package/dist/tools/tasks.d.ts.map +1 -1
  309. package/dist/tools/tasks.js +22 -58
  310. package/dist/tools/tasks.js.map +1 -1
  311. package/dist/tools/web-fetch.d.ts +16 -1
  312. package/dist/tools/web-fetch.d.ts.map +1 -1
  313. package/dist/tools/web-fetch.js +357 -45
  314. package/dist/tools/web-fetch.js.map +1 -1
  315. package/dist/tools/web-fetch.test.js +263 -2
  316. package/dist/tools/web-fetch.test.js.map +1 -1
  317. package/dist/tools/web-search.d.ts +14 -0
  318. package/dist/tools/web-search.d.ts.map +1 -1
  319. package/dist/tools/web-search.js +321 -35
  320. package/dist/tools/web-search.js.map +1 -1
  321. package/dist/tools/web-search.test.js +144 -1
  322. package/dist/tools/web-search.test.js.map +1 -1
  323. package/dist/tools/write.d.ts +8 -2
  324. package/dist/tools/write.d.ts.map +1 -1
  325. package/dist/tools/write.js +36 -9
  326. package/dist/tools/write.js.map +1 -1
  327. package/dist/tools/write.test.js +0 -16
  328. package/dist/tools/write.test.js.map +1 -1
  329. package/dist/ui/App.d.ts +52 -272
  330. package/dist/ui/App.d.ts.map +1 -1
  331. package/dist/ui/App.js +1606 -2199
  332. package/dist/ui/App.js.map +1 -1
  333. package/dist/ui/activity-phrases.d.ts.map +1 -1
  334. package/dist/ui/activity-phrases.js +0 -2
  335. package/dist/ui/activity-phrases.js.map +1 -1
  336. package/dist/ui/app-items.d.ts +276 -0
  337. package/dist/ui/app-items.d.ts.map +1 -0
  338. package/dist/ui/app-items.js +52 -0
  339. package/dist/ui/app-items.js.map +1 -0
  340. package/dist/ui/app-items.test.d.ts +2 -0
  341. package/dist/ui/app-items.test.d.ts.map +1 -0
  342. package/dist/ui/app-items.test.js +38 -0
  343. package/dist/ui/app-items.test.js.map +1 -0
  344. package/dist/ui/app-state-persistence.test.js +45 -160
  345. package/dist/ui/app-state-persistence.test.js.map +1 -1
  346. package/dist/ui/assistant-stream-flush-parity.test.d.ts +2 -0
  347. package/dist/ui/assistant-stream-flush-parity.test.d.ts.map +1 -0
  348. package/dist/ui/assistant-stream-flush-parity.test.js +85 -0
  349. package/dist/ui/assistant-stream-flush-parity.test.js.map +1 -0
  350. package/dist/ui/chat-layout-pinning.test.d.ts +2 -0
  351. package/dist/ui/chat-layout-pinning.test.d.ts.map +1 -0
  352. package/dist/ui/chat-layout-pinning.test.js +525 -0
  353. package/dist/ui/chat-layout-pinning.test.js.map +1 -0
  354. package/dist/ui/components/ActivityIndicator.d.ts +1 -2
  355. package/dist/ui/components/ActivityIndicator.d.ts.map +1 -1
  356. package/dist/ui/components/ActivityIndicator.js +63 -94
  357. package/dist/ui/components/ActivityIndicator.js.map +1 -1
  358. package/dist/ui/components/AnimationContext.d.ts.map +1 -1
  359. package/dist/ui/components/AnimationContext.js +3 -5
  360. package/dist/ui/components/AnimationContext.js.map +1 -1
  361. package/dist/ui/components/AssistantMessage.d.ts +6 -2
  362. package/dist/ui/components/AssistantMessage.d.ts.map +1 -1
  363. package/dist/ui/components/AssistantMessage.js +9 -4
  364. package/dist/ui/components/AssistantMessage.js.map +1 -1
  365. package/dist/ui/components/AssistantMessage.test.d.ts +2 -0
  366. package/dist/ui/components/AssistantMessage.test.d.ts.map +1 -0
  367. package/dist/ui/components/AssistantMessage.test.js +387 -0
  368. package/dist/ui/components/AssistantMessage.test.js.map +1 -0
  369. package/dist/ui/components/BackgroundTasksBar.d.ts +1 -3
  370. package/dist/ui/components/BackgroundTasksBar.d.ts.map +1 -1
  371. package/dist/ui/components/BackgroundTasksBar.js +8 -10
  372. package/dist/ui/components/BackgroundTasksBar.js.map +1 -1
  373. package/dist/ui/components/Banner.d.ts +1 -2
  374. package/dist/ui/components/Banner.d.ts.map +1 -1
  375. package/dist/ui/components/Banner.js +9 -4
  376. package/dist/ui/components/Banner.js.map +1 -1
  377. package/dist/ui/components/ChatFooterPane.d.ts +25 -0
  378. package/dist/ui/components/ChatFooterPane.d.ts.map +1 -0
  379. package/dist/ui/components/ChatFooterPane.js +15 -0
  380. package/dist/ui/components/ChatFooterPane.js.map +1 -0
  381. package/dist/ui/components/ChatInputStack.d.ts +36 -0
  382. package/dist/ui/components/ChatInputStack.d.ts.map +1 -0
  383. package/dist/ui/components/ChatInputStack.js +10 -0
  384. package/dist/ui/components/ChatInputStack.js.map +1 -0
  385. package/dist/ui/components/ChatLayout.d.ts +37 -0
  386. package/dist/ui/components/ChatLayout.d.ts.map +1 -0
  387. package/dist/ui/components/ChatLayout.js +21 -0
  388. package/dist/ui/components/ChatLayout.js.map +1 -0
  389. package/dist/ui/components/ChatLivePane.d.ts +18 -0
  390. package/dist/ui/components/ChatLivePane.d.ts.map +1 -0
  391. package/dist/ui/components/ChatLivePane.js +22 -0
  392. package/dist/ui/components/ChatLivePane.js.map +1 -0
  393. package/dist/ui/components/ChatScreen.d.ts +136 -0
  394. package/dist/ui/components/ChatScreen.d.ts.map +1 -0
  395. package/dist/ui/components/ChatScreen.js +16 -0
  396. package/dist/ui/components/ChatScreen.js.map +1 -0
  397. package/dist/ui/components/ChatStatusRow.d.ts +34 -0
  398. package/dist/ui/components/ChatStatusRow.d.ts.map +1 -0
  399. package/dist/ui/components/ChatStatusRow.js +11 -0
  400. package/dist/ui/components/ChatStatusRow.js.map +1 -0
  401. package/dist/ui/components/CompactionNotice.d.ts +4 -2
  402. package/dist/ui/components/CompactionNotice.d.ts.map +1 -1
  403. package/dist/ui/components/CompactionNotice.js +4 -4
  404. package/dist/ui/components/CompactionNotice.js.map +1 -1
  405. package/dist/ui/components/Footer.d.ts +27 -6
  406. package/dist/ui/components/Footer.d.ts.map +1 -1
  407. package/dist/ui/components/Footer.js +75 -30
  408. package/dist/ui/components/Footer.js.map +1 -1
  409. package/dist/ui/components/FooterStatusRow.d.ts +20 -0
  410. package/dist/ui/components/FooterStatusRow.d.ts.map +1 -0
  411. package/dist/ui/components/FooterStatusRow.js +10 -0
  412. package/dist/ui/components/FooterStatusRow.js.map +1 -0
  413. package/dist/ui/components/FullScreenOverlayRouter.d.ts +19 -0
  414. package/dist/ui/components/FullScreenOverlayRouter.d.ts.map +1 -0
  415. package/dist/ui/components/FullScreenOverlayRouter.js +18 -0
  416. package/dist/ui/components/FullScreenOverlayRouter.js.map +1 -0
  417. package/dist/ui/components/GoalOverlay.d.ts +28 -20
  418. package/dist/ui/components/GoalOverlay.d.ts.map +1 -1
  419. package/dist/ui/components/GoalOverlay.js +283 -253
  420. package/dist/ui/components/GoalOverlay.js.map +1 -1
  421. package/dist/ui/components/GoalStatusBar.d.ts.map +1 -1
  422. package/dist/ui/components/GoalStatusBar.js +2 -1
  423. package/dist/ui/components/GoalStatusBar.js.map +1 -1
  424. package/dist/ui/components/IdealHookMessage.d.ts +14 -0
  425. package/dist/ui/components/IdealHookMessage.d.ts.map +1 -0
  426. package/dist/ui/components/IdealHookMessage.js +26 -0
  427. package/dist/ui/components/IdealHookMessage.js.map +1 -0
  428. package/dist/ui/components/InputArea.d.ts +31 -6
  429. package/dist/ui/components/InputArea.d.ts.map +1 -1
  430. package/dist/ui/components/InputArea.js +208 -50
  431. package/dist/ui/components/InputArea.js.map +1 -1
  432. package/dist/ui/components/InputArea.test.js +11 -1
  433. package/dist/ui/components/InputArea.test.js.map +1 -1
  434. package/dist/ui/components/LiveToolPanel.d.ts +30 -0
  435. package/dist/ui/components/LiveToolPanel.d.ts.map +1 -0
  436. package/dist/ui/components/LiveToolPanel.js +66 -0
  437. package/dist/ui/components/LiveToolPanel.js.map +1 -0
  438. package/dist/ui/components/Markdown.d.ts +11 -11
  439. package/dist/ui/components/Markdown.d.ts.map +1 -1
  440. package/dist/ui/components/Markdown.js +28 -198
  441. package/dist/ui/components/Markdown.js.map +1 -1
  442. package/dist/ui/components/ModelSelector.d.ts.map +1 -1
  443. package/dist/ui/components/ModelSelector.js +18 -18
  444. package/dist/ui/components/ModelSelector.js.map +1 -1
  445. package/dist/ui/components/PlanModeLogo.d.ts +3 -0
  446. package/dist/ui/components/PlanModeLogo.d.ts.map +1 -0
  447. package/dist/ui/components/PlanModeLogo.js +49 -0
  448. package/dist/ui/components/PlanModeLogo.js.map +1 -0
  449. package/dist/ui/components/PlanOverlay.d.ts +7 -0
  450. package/dist/ui/components/PlanOverlay.d.ts.map +1 -1
  451. package/dist/ui/components/PlanOverlay.js +17 -3
  452. package/dist/ui/components/PlanOverlay.js.map +1 -1
  453. package/dist/ui/components/PlanOverlay.test.d.ts +2 -0
  454. package/dist/ui/components/PlanOverlay.test.d.ts.map +1 -0
  455. package/dist/ui/components/PlanOverlay.test.js +24 -0
  456. package/dist/ui/components/PlanOverlay.test.js.map +1 -0
  457. package/dist/ui/components/QueueIndicator.d.ts +9 -0
  458. package/dist/ui/components/QueueIndicator.d.ts.map +1 -0
  459. package/dist/ui/components/QueueIndicator.js +9 -0
  460. package/dist/ui/components/QueueIndicator.js.map +1 -0
  461. package/dist/ui/components/RewindOverlay.d.ts +18 -0
  462. package/dist/ui/components/RewindOverlay.d.ts.map +1 -0
  463. package/dist/ui/components/RewindOverlay.js +52 -0
  464. package/dist/ui/components/RewindOverlay.js.map +1 -0
  465. package/dist/ui/components/SelectList.d.ts.map +1 -1
  466. package/dist/ui/components/SelectList.js +5 -0
  467. package/dist/ui/components/SelectList.js.map +1 -1
  468. package/dist/ui/components/ServerToolExecution.d.ts +2 -0
  469. package/dist/ui/components/ServerToolExecution.d.ts.map +1 -1
  470. package/dist/ui/components/ServerToolExecution.js +7 -23
  471. package/dist/ui/components/ServerToolExecution.js.map +1 -1
  472. package/dist/ui/components/SessionSummary.d.ts +5 -0
  473. package/dist/ui/components/SessionSummary.d.ts.map +1 -0
  474. package/dist/ui/components/SessionSummary.js +32 -0
  475. package/dist/ui/components/SessionSummary.js.map +1 -0
  476. package/dist/ui/components/SlashCommandMenu.d.ts +4 -3
  477. package/dist/ui/components/SlashCommandMenu.d.ts.map +1 -1
  478. package/dist/ui/components/SlashCommandMenu.js +38 -26
  479. package/dist/ui/components/SlashCommandMenu.js.map +1 -1
  480. package/dist/ui/components/SlashStyledSelectList.d.ts +21 -0
  481. package/dist/ui/components/SlashStyledSelectList.d.ts.map +1 -0
  482. package/dist/ui/components/SlashStyledSelectList.js +71 -0
  483. package/dist/ui/components/SlashStyledSelectList.js.map +1 -0
  484. package/dist/ui/components/StreamingArea.d.ts +11 -2
  485. package/dist/ui/components/StreamingArea.d.ts.map +1 -1
  486. package/dist/ui/components/StreamingArea.js +20 -23
  487. package/dist/ui/components/StreamingArea.js.map +1 -1
  488. package/dist/ui/components/StreamingArea.test.d.ts +2 -0
  489. package/dist/ui/components/StreamingArea.test.d.ts.map +1 -0
  490. package/dist/ui/components/StreamingArea.test.js +18 -0
  491. package/dist/ui/components/StreamingArea.test.js.map +1 -0
  492. package/dist/ui/components/SubAgentPanel.d.ts +2 -1
  493. package/dist/ui/components/SubAgentPanel.d.ts.map +1 -1
  494. package/dist/ui/components/SubAgentPanel.js +4 -3
  495. package/dist/ui/components/SubAgentPanel.js.map +1 -1
  496. package/dist/ui/components/TaskOverlay.d.ts.map +1 -1
  497. package/dist/ui/components/TaskOverlay.js +53 -82
  498. package/dist/ui/components/TaskOverlay.js.map +1 -1
  499. package/dist/ui/components/TaskPickerMenu.d.ts +9 -0
  500. package/dist/ui/components/TaskPickerMenu.d.ts.map +1 -0
  501. package/dist/ui/components/TaskPickerMenu.js +33 -0
  502. package/dist/ui/components/TaskPickerMenu.js.map +1 -0
  503. package/dist/ui/components/ThemeSelector.js +2 -2
  504. package/dist/ui/components/ThemeSelector.js.map +1 -1
  505. package/dist/ui/components/ToolExecution.d.ts +2 -0
  506. package/dist/ui/components/ToolExecution.d.ts.map +1 -1
  507. package/dist/ui/components/ToolExecution.js +18 -52
  508. package/dist/ui/components/ToolExecution.js.map +1 -1
  509. package/dist/ui/components/ToolGroupExecution.d.ts +6 -2
  510. package/dist/ui/components/ToolGroupExecution.d.ts.map +1 -1
  511. package/dist/ui/components/ToolGroupExecution.js +15 -147
  512. package/dist/ui/components/ToolGroupExecution.js.map +1 -1
  513. package/dist/ui/components/ToolUseLoader.d.ts +3 -1
  514. package/dist/ui/components/ToolUseLoader.d.ts.map +1 -1
  515. package/dist/ui/components/ToolUseLoader.js +2 -2
  516. package/dist/ui/components/ToolUseLoader.js.map +1 -1
  517. package/dist/ui/components/TranscriptViewport.d.ts +34 -0
  518. package/dist/ui/components/TranscriptViewport.d.ts.map +1 -0
  519. package/dist/ui/components/TranscriptViewport.js +45 -0
  520. package/dist/ui/components/TranscriptViewport.js.map +1 -0
  521. package/dist/ui/components/UserMessage.d.ts.map +1 -1
  522. package/dist/ui/components/UserMessage.js +15 -10
  523. package/dist/ui/components/UserMessage.js.map +1 -1
  524. package/dist/ui/components/UserMessage.test.d.ts +2 -0
  525. package/dist/ui/components/UserMessage.test.d.ts.map +1 -0
  526. package/dist/ui/components/UserMessage.test.js +39 -0
  527. package/dist/ui/components/UserMessage.test.js.map +1 -0
  528. package/dist/ui/components/index.d.ts +5 -0
  529. package/dist/ui/components/index.d.ts.map +1 -1
  530. package/dist/ui/components/index.js +5 -0
  531. package/dist/ui/components/index.js.map +1 -1
  532. package/dist/ui/duration-format.d.ts +2 -0
  533. package/dist/ui/duration-format.d.ts.map +1 -0
  534. package/dist/ui/duration-format.js +9 -0
  535. package/dist/ui/duration-format.js.map +1 -0
  536. package/dist/ui/duration-summary.d.ts +2 -0
  537. package/dist/ui/duration-summary.d.ts.map +1 -0
  538. package/dist/ui/duration-summary.js +66 -0
  539. package/dist/ui/duration-summary.js.map +1 -0
  540. package/dist/ui/error-item.d.ts +8 -0
  541. package/dist/ui/error-item.d.ts.map +1 -0
  542. package/dist/ui/error-item.js +32 -0
  543. package/dist/ui/error-item.js.map +1 -0
  544. package/dist/ui/footer-jump-regression.test.d.ts +2 -0
  545. package/dist/ui/footer-jump-regression.test.d.ts.map +1 -0
  546. package/dist/ui/footer-jump-regression.test.js +177 -0
  547. package/dist/ui/footer-jump-regression.test.js.map +1 -0
  548. package/dist/ui/footer-status-layout.test.js +22 -7
  549. package/dist/ui/footer-status-layout.test.js.map +1 -1
  550. package/dist/ui/goal-events.d.ts.map +1 -1
  551. package/dist/ui/goal-events.js +14 -6
  552. package/dist/ui/goal-events.js.map +1 -1
  553. package/dist/ui/goal-events.test.js +40 -2
  554. package/dist/ui/goal-events.test.js.map +1 -1
  555. package/dist/ui/goal-lifecycle-orchestration.test.d.ts +2 -0
  556. package/dist/ui/goal-lifecycle-orchestration.test.d.ts.map +1 -0
  557. package/dist/ui/goal-lifecycle-orchestration.test.js +512 -0
  558. package/dist/ui/goal-lifecycle-orchestration.test.js.map +1 -0
  559. package/dist/ui/goal-overlay.test.js +122 -44
  560. package/dist/ui/goal-overlay.test.js.map +1 -1
  561. package/dist/ui/goal-status-bar.test.js +29 -0
  562. package/dist/ui/goal-status-bar.test.js.map +1 -1
  563. package/dist/ui/goal-summary.d.ts +14 -0
  564. package/dist/ui/goal-summary.d.ts.map +1 -0
  565. package/dist/ui/goal-summary.js +194 -0
  566. package/dist/ui/goal-summary.js.map +1 -0
  567. package/dist/ui/hooks/useAgentLoop.d.ts +25 -4
  568. package/dist/ui/hooks/useAgentLoop.d.ts.map +1 -1
  569. package/dist/ui/hooks/useAgentLoop.js +197 -22
  570. package/dist/ui/hooks/useAgentLoop.js.map +1 -1
  571. package/dist/ui/hooks/useAgentLoop.test.d.ts +2 -0
  572. package/dist/ui/hooks/useAgentLoop.test.d.ts.map +1 -0
  573. package/dist/ui/hooks/useAgentLoop.test.js +8 -0
  574. package/dist/ui/hooks/useAgentLoop.test.js.map +1 -0
  575. package/dist/ui/hooks/useChatLayoutMeasurements.d.ts +45 -0
  576. package/dist/ui/hooks/useChatLayoutMeasurements.d.ts.map +1 -0
  577. package/dist/ui/hooks/useChatLayoutMeasurements.js +97 -0
  578. package/dist/ui/hooks/useChatLayoutMeasurements.js.map +1 -0
  579. package/dist/ui/hooks/useContextCompaction.d.ts +41 -0
  580. package/dist/ui/hooks/useContextCompaction.d.ts.map +1 -0
  581. package/dist/ui/hooks/useContextCompaction.js +149 -0
  582. package/dist/ui/hooks/useContextCompaction.js.map +1 -0
  583. package/dist/ui/hooks/useModeState.d.ts +56 -0
  584. package/dist/ui/hooks/useModeState.d.ts.map +1 -0
  585. package/dist/ui/hooks/useModeState.js +65 -0
  586. package/dist/ui/hooks/useModeState.js.map +1 -0
  587. package/dist/ui/hooks/usePixelFixFlow.d.ts +57 -0
  588. package/dist/ui/hooks/usePixelFixFlow.d.ts.map +1 -0
  589. package/dist/ui/hooks/usePixelFixFlow.js +102 -0
  590. package/dist/ui/hooks/usePixelFixFlow.js.map +1 -0
  591. package/dist/ui/hooks/useSessionPersistence.d.ts +34 -0
  592. package/dist/ui/hooks/useSessionPersistence.d.ts.map +1 -0
  593. package/dist/ui/hooks/useSessionPersistence.js +67 -0
  594. package/dist/ui/hooks/useSessionPersistence.js.map +1 -0
  595. package/dist/ui/hooks/useTaskPickerController.d.ts +19 -0
  596. package/dist/ui/hooks/useTaskPickerController.d.ts.map +1 -0
  597. package/dist/ui/hooks/useTaskPickerController.js +41 -0
  598. package/dist/ui/hooks/useTaskPickerController.js.map +1 -0
  599. package/dist/ui/hooks/useTerminalSize.d.ts +13 -10
  600. package/dist/ui/hooks/useTerminalSize.d.ts.map +1 -1
  601. package/dist/ui/hooks/useTerminalSize.js +21 -16
  602. package/dist/ui/hooks/useTerminalSize.js.map +1 -1
  603. package/dist/ui/hooks/useTranscriptHistory.d.ts +48 -0
  604. package/dist/ui/hooks/useTranscriptHistory.d.ts.map +1 -0
  605. package/dist/ui/hooks/useTranscriptHistory.js +113 -0
  606. package/dist/ui/hooks/useTranscriptHistory.js.map +1 -0
  607. package/dist/ui/hooks/useTranscriptHistory.test.d.ts +2 -0
  608. package/dist/ui/hooks/useTranscriptHistory.test.d.ts.map +1 -0
  609. package/dist/ui/hooks/useTranscriptHistory.test.js +61 -0
  610. package/dist/ui/hooks/useTranscriptHistory.test.js.map +1 -0
  611. package/dist/ui/hooks/useTranscriptScroll.d.ts +30 -0
  612. package/dist/ui/hooks/useTranscriptScroll.d.ts.map +1 -0
  613. package/dist/ui/hooks/useTranscriptScroll.js +44 -0
  614. package/dist/ui/hooks/useTranscriptScroll.js.map +1 -0
  615. package/dist/ui/hooks/useTranscriptScroll.test.d.ts +2 -0
  616. package/dist/ui/hooks/useTranscriptScroll.test.d.ts.map +1 -0
  617. package/dist/ui/hooks/useTranscriptScroll.test.js +119 -0
  618. package/dist/ui/hooks/useTranscriptScroll.test.js.map +1 -0
  619. package/dist/ui/item-helpers.d.ts +26 -0
  620. package/dist/ui/item-helpers.d.ts.map +1 -0
  621. package/dist/ui/item-helpers.js +114 -0
  622. package/dist/ui/item-helpers.js.map +1 -0
  623. package/dist/ui/layout-decisions.d.ts +81 -0
  624. package/dist/ui/layout-decisions.d.ts.map +1 -0
  625. package/dist/ui/layout-decisions.js +89 -0
  626. package/dist/ui/layout-decisions.js.map +1 -0
  627. package/dist/ui/live-area-clamp.test.d.ts +2 -0
  628. package/dist/ui/live-area-clamp.test.d.ts.map +1 -0
  629. package/dist/ui/live-area-clamp.test.js +88 -0
  630. package/dist/ui/live-area-clamp.test.js.map +1 -0
  631. package/dist/ui/live-area-height.d.ts +35 -0
  632. package/dist/ui/live-area-height.d.ts.map +1 -0
  633. package/dist/ui/live-area-height.js +80 -0
  634. package/dist/ui/live-area-height.js.map +1 -0
  635. package/dist/ui/live-area-height.test.d.ts +2 -0
  636. package/dist/ui/live-area-height.test.d.ts.map +1 -0
  637. package/dist/ui/live-area-height.test.js +67 -0
  638. package/dist/ui/live-area-height.test.js.map +1 -0
  639. package/dist/ui/live-frame-height.test.d.ts +2 -0
  640. package/dist/ui/live-frame-height.test.d.ts.map +1 -0
  641. package/dist/ui/live-frame-height.test.js +116 -0
  642. package/dist/ui/live-frame-height.test.js.map +1 -0
  643. package/dist/ui/live-item-flush.d.ts +2 -2
  644. package/dist/ui/live-item-flush.d.ts.map +1 -1
  645. package/dist/ui/live-item-flush.js +8 -4
  646. package/dist/ui/live-item-flush.js.map +1 -1
  647. package/dist/ui/login.js +1 -1
  648. package/dist/ui/long-prompt-regression-harness.test.d.ts +2 -0
  649. package/dist/ui/long-prompt-regression-harness.test.d.ts.map +1 -0
  650. package/dist/ui/long-prompt-regression-harness.test.js +195 -0
  651. package/dist/ui/long-prompt-regression-harness.test.js.map +1 -0
  652. package/dist/ui/mcp.d.ts +62 -0
  653. package/dist/ui/mcp.d.ts.map +1 -0
  654. package/dist/ui/mcp.js +306 -0
  655. package/dist/ui/mcp.js.map +1 -0
  656. package/dist/ui/plan-overlay.test.js +7 -29
  657. package/dist/ui/plan-overlay.test.js.map +1 -1
  658. package/dist/ui/prompt-routing.d.ts +11 -0
  659. package/dist/ui/prompt-routing.d.ts.map +1 -0
  660. package/dist/ui/prompt-routing.js +61 -0
  661. package/dist/ui/prompt-routing.js.map +1 -0
  662. package/dist/ui/queued-message.test.d.ts +2 -0
  663. package/dist/ui/queued-message.test.d.ts.map +1 -0
  664. package/dist/ui/queued-message.test.js +162 -0
  665. package/dist/ui/queued-message.test.js.map +1 -0
  666. package/dist/ui/render.d.ts +38 -34
  667. package/dist/ui/render.d.ts.map +1 -1
  668. package/dist/ui/render.js +128 -41
  669. package/dist/ui/render.js.map +1 -1
  670. package/dist/ui/render.test.d.ts +2 -0
  671. package/dist/ui/render.test.d.ts.map +1 -0
  672. package/dist/ui/render.test.js +16 -0
  673. package/dist/ui/render.test.js.map +1 -0
  674. package/dist/ui/scroll-stabilization.test.js +1 -7
  675. package/dist/ui/scroll-stabilization.test.js.map +1 -1
  676. package/dist/ui/session-summary.d.ts +63 -0
  677. package/dist/ui/session-summary.d.ts.map +1 -0
  678. package/dist/ui/session-summary.js +81 -0
  679. package/dist/ui/session-summary.js.map +1 -0
  680. package/dist/ui/slash-command-images.test.js +12 -11
  681. package/dist/ui/slash-command-images.test.js.map +1 -1
  682. package/dist/ui/stores/transcript-scroll-store.d.ts +27 -0
  683. package/dist/ui/stores/transcript-scroll-store.d.ts.map +1 -0
  684. package/dist/ui/stores/transcript-scroll-store.js +73 -0
  685. package/dist/ui/stores/transcript-scroll-store.js.map +1 -0
  686. package/dist/ui/stores/transcript-scroll-store.test.d.ts +2 -0
  687. package/dist/ui/stores/transcript-scroll-store.test.d.ts.map +1 -0
  688. package/dist/ui/stores/transcript-scroll-store.test.js +73 -0
  689. package/dist/ui/stores/transcript-scroll-store.test.js.map +1 -0
  690. package/dist/ui/streaming-flush-bounce.test.d.ts +2 -0
  691. package/dist/ui/streaming-flush-bounce.test.d.ts.map +1 -0
  692. package/dist/ui/streaming-flush-bounce.test.js +156 -0
  693. package/dist/ui/streaming-flush-bounce.test.js.map +1 -0
  694. package/dist/ui/submit-prompt-command.d.ts +49 -0
  695. package/dist/ui/submit-prompt-command.d.ts.map +1 -0
  696. package/dist/ui/submit-prompt-command.js +107 -0
  697. package/dist/ui/submit-prompt-command.js.map +1 -0
  698. package/dist/ui/submit-slash-commands.d.ts +12 -0
  699. package/dist/ui/submit-slash-commands.d.ts.map +1 -0
  700. package/dist/ui/submit-slash-commands.js +32 -0
  701. package/dist/ui/submit-slash-commands.js.map +1 -0
  702. package/dist/ui/terminal-history-format.d.ts +43 -0
  703. package/dist/ui/terminal-history-format.d.ts.map +1 -0
  704. package/dist/ui/terminal-history-format.js +133 -0
  705. package/dist/ui/terminal-history-format.js.map +1 -0
  706. package/dist/ui/terminal-history-retry-dedup.test.d.ts +2 -0
  707. package/dist/ui/terminal-history-retry-dedup.test.d.ts.map +1 -0
  708. package/dist/ui/terminal-history-retry-dedup.test.js +61 -0
  709. package/dist/ui/terminal-history-retry-dedup.test.js.map +1 -0
  710. package/dist/ui/terminal-history-spacing.d.ts +2 -0
  711. package/dist/ui/terminal-history-spacing.d.ts.map +1 -0
  712. package/dist/ui/terminal-history-spacing.js +2 -0
  713. package/dist/ui/terminal-history-spacing.js.map +1 -0
  714. package/dist/ui/terminal-history-status-renderers.d.ts +15 -0
  715. package/dist/ui/terminal-history-status-renderers.d.ts.map +1 -0
  716. package/dist/ui/terminal-history-status-renderers.js +99 -0
  717. package/dist/ui/terminal-history-status-renderers.js.map +1 -0
  718. package/dist/ui/terminal-history.d.ts +26 -0
  719. package/dist/ui/terminal-history.d.ts.map +1 -0
  720. package/dist/ui/terminal-history.js +916 -0
  721. package/dist/ui/terminal-history.js.map +1 -0
  722. package/dist/ui/terminal-history.test.d.ts +2 -0
  723. package/dist/ui/terminal-history.test.d.ts.map +1 -0
  724. package/dist/ui/terminal-history.test.js +550 -0
  725. package/dist/ui/terminal-history.test.js.map +1 -0
  726. package/dist/ui/testing/screen-recorder.d.ts +29 -0
  727. package/dist/ui/testing/screen-recorder.d.ts.map +1 -0
  728. package/dist/ui/testing/screen-recorder.js +179 -0
  729. package/dist/ui/testing/screen-recorder.js.map +1 -0
  730. package/dist/ui/thinking-level-cycle.test.d.ts +2 -0
  731. package/dist/ui/thinking-level-cycle.test.d.ts.map +1 -0
  732. package/dist/ui/thinking-level-cycle.test.js +45 -0
  733. package/dist/ui/thinking-level-cycle.test.js.map +1 -0
  734. package/dist/ui/thinking-level.d.ts +2 -0
  735. package/dist/ui/thinking-level.d.ts.map +1 -0
  736. package/dist/ui/thinking-level.js +2 -0
  737. package/dist/ui/thinking-level.js.map +1 -0
  738. package/dist/ui/tool-group-summary.d.ts +24 -0
  739. package/dist/ui/tool-group-summary.d.ts.map +1 -0
  740. package/dist/ui/tool-group-summary.js +233 -0
  741. package/dist/ui/tool-group-summary.js.map +1 -0
  742. package/dist/ui/tool-group-summary.test.d.ts +2 -0
  743. package/dist/ui/tool-group-summary.test.d.ts.map +1 -0
  744. package/dist/ui/tool-group-summary.test.js +79 -0
  745. package/dist/ui/tool-group-summary.test.js.map +1 -0
  746. package/dist/ui/tool-line-summary.d.ts +29 -0
  747. package/dist/ui/tool-line-summary.d.ts.map +1 -0
  748. package/dist/ui/tool-line-summary.js +153 -0
  749. package/dist/ui/tool-line-summary.js.map +1 -0
  750. package/dist/ui/transcript/MiscRows.d.ts +26 -0
  751. package/dist/ui/transcript/MiscRows.d.ts.map +1 -0
  752. package/dist/ui/transcript/MiscRows.js +68 -0
  753. package/dist/ui/transcript/MiscRows.js.map +1 -0
  754. package/dist/ui/transcript/StatusRow.d.ts +14 -0
  755. package/dist/ui/transcript/StatusRow.d.ts.map +1 -0
  756. package/dist/ui/transcript/StatusRow.js +14 -0
  757. package/dist/ui/transcript/StatusRow.js.map +1 -0
  758. package/dist/ui/transcript/ToolRows.d.ts +20 -0
  759. package/dist/ui/transcript/ToolRows.d.ts.map +1 -0
  760. package/dist/ui/transcript/ToolRows.js +25 -0
  761. package/dist/ui/transcript/ToolRows.js.map +1 -0
  762. package/dist/ui/transcript/TranscriptItemFrame.d.ts +8 -0
  763. package/dist/ui/transcript/TranscriptItemFrame.d.ts.map +1 -0
  764. package/dist/ui/transcript/TranscriptItemFrame.js +9 -0
  765. package/dist/ui/transcript/TranscriptItemFrame.js.map +1 -0
  766. package/dist/ui/transcript/TranscriptRenderer.d.ts +22 -0
  767. package/dist/ui/transcript/TranscriptRenderer.d.ts.map +1 -0
  768. package/dist/ui/transcript/TranscriptRenderer.js +111 -0
  769. package/dist/ui/transcript/TranscriptRenderer.js.map +1 -0
  770. package/dist/ui/transcript/presentation.d.ts +61 -0
  771. package/dist/ui/transcript/presentation.d.ts.map +1 -0
  772. package/dist/ui/transcript/presentation.js +86 -0
  773. package/dist/ui/transcript/presentation.js.map +1 -0
  774. package/dist/ui/transcript/spacing.d.ts +56 -0
  775. package/dist/ui/transcript/spacing.d.ts.map +1 -0
  776. package/dist/ui/transcript/spacing.js +129 -0
  777. package/dist/ui/transcript/spacing.js.map +1 -0
  778. package/dist/ui/transcript/spacing.test.d.ts +2 -0
  779. package/dist/ui/transcript/spacing.test.d.ts.map +1 -0
  780. package/dist/ui/transcript/spacing.test.js +193 -0
  781. package/dist/ui/transcript/spacing.test.js.map +1 -0
  782. package/dist/ui/transcript/tool-presentation.d.ts +12 -0
  783. package/dist/ui/transcript/tool-presentation.d.ts.map +1 -0
  784. package/dist/ui/transcript/tool-presentation.js +55 -0
  785. package/dist/ui/transcript/tool-presentation.js.map +1 -0
  786. package/dist/ui/transcript/transcript-lines.d.ts +32 -0
  787. package/dist/ui/transcript/transcript-lines.d.ts.map +1 -0
  788. package/dist/ui/transcript/transcript-lines.js +86 -0
  789. package/dist/ui/transcript/transcript-lines.js.map +1 -0
  790. package/dist/ui/transcript/transcript-lines.test.d.ts +2 -0
  791. package/dist/ui/transcript/transcript-lines.test.d.ts.map +1 -0
  792. package/dist/ui/transcript/transcript-lines.test.js +76 -0
  793. package/dist/ui/transcript/transcript-lines.test.js.map +1 -0
  794. package/dist/ui/transcript-viewport-pinning.test.d.ts +2 -0
  795. package/dist/ui/transcript-viewport-pinning.test.d.ts.map +1 -0
  796. package/dist/ui/transcript-viewport-pinning.test.js +148 -0
  797. package/dist/ui/transcript-viewport-pinning.test.js.map +1 -0
  798. package/dist/ui/tui-history-parity.test.d.ts +2 -0
  799. package/dist/ui/tui-history-parity.test.d.ts.map +1 -0
  800. package/dist/ui/tui-history-parity.test.js +381 -0
  801. package/dist/ui/tui-history-parity.test.js.map +1 -0
  802. package/dist/ui/tui-simulation.test.d.ts +2 -0
  803. package/dist/ui/tui-simulation.test.d.ts.map +1 -0
  804. package/dist/ui/tui-simulation.test.js +139 -0
  805. package/dist/ui/tui-simulation.test.js.map +1 -0
  806. package/dist/ui/tui-terminal-recorder.test.d.ts +2 -0
  807. package/dist/ui/tui-terminal-recorder.test.d.ts.map +1 -0
  808. package/dist/ui/tui-terminal-recorder.test.js +134 -0
  809. package/dist/ui/tui-terminal-recorder.test.js.map +1 -0
  810. package/dist/ui/utils/assistant-stream-split.d.ts +23 -0
  811. package/dist/ui/utils/assistant-stream-split.d.ts.map +1 -0
  812. package/dist/ui/utils/assistant-stream-split.js +41 -0
  813. package/dist/ui/utils/assistant-stream-split.js.map +1 -0
  814. package/dist/ui/utils/assistant-stream-split.test.d.ts +2 -0
  815. package/dist/ui/utils/assistant-stream-split.test.d.ts.map +1 -0
  816. package/dist/ui/utils/assistant-stream-split.test.js +40 -0
  817. package/dist/ui/utils/assistant-stream-split.test.js.map +1 -0
  818. package/dist/ui/utils/latex-to-unicode.d.ts +22 -0
  819. package/dist/ui/utils/latex-to-unicode.d.ts.map +1 -0
  820. package/dist/ui/utils/latex-to-unicode.js +538 -0
  821. package/dist/ui/utils/latex-to-unicode.js.map +1 -0
  822. package/dist/ui/utils/markdown-renderer.d.ts +20 -0
  823. package/dist/ui/utils/markdown-renderer.d.ts.map +1 -0
  824. package/dist/ui/utils/markdown-renderer.js +327 -0
  825. package/dist/ui/utils/markdown-renderer.js.map +1 -0
  826. package/dist/ui/utils/markdown-table.d.ts +9 -0
  827. package/dist/ui/utils/markdown-table.d.ts.map +1 -0
  828. package/dist/ui/utils/markdown-table.js +95 -0
  829. package/dist/ui/utils/markdown-table.js.map +1 -0
  830. package/dist/ui/utils/terminal-graphics.d.ts +16 -0
  831. package/dist/ui/utils/terminal-graphics.d.ts.map +1 -0
  832. package/dist/ui/utils/terminal-graphics.js +68 -0
  833. package/dist/ui/utils/terminal-graphics.js.map +1 -0
  834. package/dist/ui/utils/terminal-graphics.test.d.ts +2 -0
  835. package/dist/ui/utils/terminal-graphics.test.d.ts.map +1 -0
  836. package/dist/ui/utils/terminal-graphics.test.js +61 -0
  837. package/dist/ui/utils/terminal-graphics.test.js.map +1 -0
  838. package/dist/ui/utils/terminal-input.d.ts +3 -0
  839. package/dist/ui/utils/terminal-input.d.ts.map +1 -0
  840. package/dist/ui/utils/terminal-input.js +28 -0
  841. package/dist/ui/utils/terminal-input.js.map +1 -0
  842. package/dist/ui/utils/terminal-input.test.d.ts +2 -0
  843. package/dist/ui/utils/terminal-input.test.d.ts.map +1 -0
  844. package/dist/ui/utils/terminal-input.test.js +15 -0
  845. package/dist/ui/utils/terminal-input.test.js.map +1 -0
  846. package/dist/ui/utils/text-utils.d.ts +8 -0
  847. package/dist/ui/utils/text-utils.d.ts.map +1 -0
  848. package/dist/ui/utils/text-utils.js +16 -0
  849. package/dist/ui/utils/text-utils.js.map +1 -0
  850. package/dist/ui/utils/token-to-ansi.js +19 -9
  851. package/dist/ui/utils/token-to-ansi.js.map +1 -1
  852. package/dist/ui/utils/user-message-display.d.ts +7 -0
  853. package/dist/ui/utils/user-message-display.d.ts.map +1 -0
  854. package/dist/ui/utils/user-message-display.js +26 -0
  855. package/dist/ui/utils/user-message-display.js.map +1 -0
  856. package/dist/utils/format.js +7 -9
  857. package/dist/utils/format.js.map +1 -1
  858. package/dist/utils/image.d.ts +9 -0
  859. package/dist/utils/image.d.ts.map +1 -1
  860. package/dist/utils/image.js +25 -0
  861. package/dist/utils/image.js.map +1 -1
  862. package/dist/utils/plan-steps.d.ts.map +1 -1
  863. package/dist/utils/plan-steps.js +5 -1
  864. package/dist/utils/plan-steps.js.map +1 -1
  865. package/dist/utils/plan-steps.test.d.ts +2 -0
  866. package/dist/utils/plan-steps.test.d.ts.map +1 -0
  867. package/dist/utils/plan-steps.test.js +16 -0
  868. package/dist/utils/plan-steps.test.js.map +1 -0
  869. package/package.json +50 -10
  870. package/dist/core/repomap-context.d.ts +0 -11
  871. package/dist/core/repomap-context.d.ts.map +0 -1
  872. package/dist/core/repomap-context.js +0 -68
  873. package/dist/core/repomap-context.js.map +0 -1
  874. package/dist/core/repomap-context.test.d.ts +0 -2
  875. package/dist/core/repomap-context.test.d.ts.map +0 -1
  876. package/dist/core/repomap-context.test.js +0 -47
  877. package/dist/core/repomap-context.test.js.map +0 -1
  878. package/dist/core/repomap.d.ts +0 -74
  879. package/dist/core/repomap.d.ts.map +0 -1
  880. package/dist/core/repomap.js +0 -906
  881. package/dist/core/repomap.js.map +0 -1
  882. package/dist/core/repomap.test.d.ts +0 -2
  883. package/dist/core/repomap.test.d.ts.map +0 -1
  884. package/dist/core/repomap.test.js +0 -494
  885. package/dist/core/repomap.test.js.map +0 -1
  886. package/dist/ui/components/EyesOverlay.d.ts +0 -10
  887. package/dist/ui/components/EyesOverlay.d.ts.map +0 -1
  888. package/dist/ui/components/EyesOverlay.js +0 -220
  889. package/dist/ui/components/EyesOverlay.js.map +0 -1
@@ -0,0 +1,327 @@
1
+ import chalk from "chalk";
2
+ import { common, createLowlight } from "lowlight";
3
+ import stripAnsi from "strip-ansi";
4
+ import wrapAnsi from "wrap-ansi";
5
+ import { convertLatexToUnicode } from "./latex-to-unicode.js";
6
+ import { renderAnsiTable } from "./markdown-table.js";
7
+ import { stripUnsafeCharacters } from "./text-utils.js";
8
+ const EMPTY_RENDER_LINE = "";
9
+ const MASK_SENTINEL = "\uE000";
10
+ const MASK_PATTERN = /\uE000(\d+)\uE000/g;
11
+ const lowlight = createLowlight(common);
12
+ function colorize(text, color) {
13
+ return color ? chalk.hex(color)(text) : text;
14
+ }
15
+ function convertLatexPreservingSpans(text) {
16
+ const preserved = [];
17
+ const masked = text.replace(/(`+)([^`\n]+?)\1|https?:\/\/\S+/g, (match) => {
18
+ const index = preserved.push(match) - 1;
19
+ return `${MASK_SENTINEL}${index}${MASK_SENTINEL}`;
20
+ });
21
+ const converted = convertLatexToUnicode(masked);
22
+ return converted.replace(MASK_PATTERN, (match, index) => preserved[Number(index)] ?? match);
23
+ }
24
+ export function renderInlineMarkdownToAnsi(rawText, theme, defaultColor) {
25
+ const baseColor = defaultColor ?? theme.text;
26
+ const text = convertLatexPreservingSpans(rawText);
27
+ if (!/[*_~`<[]|https?:\/\//.test(text)) {
28
+ return colorize(text, baseColor);
29
+ }
30
+ const inlineRegex = /(\*\*\*.*?\*\*\*|\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>|https?:\/\/\S+)/g;
31
+ let result = "";
32
+ let lastIndex = 0;
33
+ let match;
34
+ while ((match = inlineRegex.exec(text)) !== null) {
35
+ if (match.index > lastIndex) {
36
+ result += colorize(text.slice(lastIndex, match.index), baseColor);
37
+ }
38
+ const fullMatch = match[0];
39
+ let styledPart = "";
40
+ if (fullMatch.endsWith("***") && fullMatch.startsWith("***") && fullMatch.length > 6) {
41
+ styledPart = chalk.bold(chalk.italic(renderInlineMarkdownToAnsi(fullMatch.slice(3, -3), theme, baseColor)));
42
+ }
43
+ else if (fullMatch.endsWith("**") && fullMatch.startsWith("**") && fullMatch.length > 4) {
44
+ styledPart = chalk.bold(renderInlineMarkdownToAnsi(fullMatch.slice(2, -2), theme, baseColor));
45
+ }
46
+ else if (fullMatch.length > 2 &&
47
+ ((fullMatch.startsWith("*") && fullMatch.endsWith("*")) ||
48
+ (fullMatch.startsWith("_") && fullMatch.endsWith("_"))) &&
49
+ !/\w/.test(text.substring(match.index - 1, match.index)) &&
50
+ !/\w/.test(text.substring(inlineRegex.lastIndex, inlineRegex.lastIndex + 1)) &&
51
+ !/\S[./\\]/.test(text.substring(match.index - 2, match.index)) &&
52
+ !/[./\\]\S/.test(text.substring(inlineRegex.lastIndex, inlineRegex.lastIndex + 2))) {
53
+ styledPart = chalk.italic(renderInlineMarkdownToAnsi(fullMatch.slice(1, -1), theme, baseColor));
54
+ }
55
+ else if (fullMatch.startsWith("~~") && fullMatch.endsWith("~~") && fullMatch.length > 4) {
56
+ styledPart = chalk.strikethrough(renderInlineMarkdownToAnsi(fullMatch.slice(2, -2), theme, baseColor));
57
+ }
58
+ else if (fullMatch.startsWith("`") && fullMatch.endsWith("`") && fullMatch.length > 1) {
59
+ const codeMatch = fullMatch.match(/^(`+)(.+?)\1$/s);
60
+ if (codeMatch?.[2])
61
+ styledPart = colorize(codeMatch[2], theme.accent);
62
+ }
63
+ else if (fullMatch.startsWith("[") && fullMatch.includes("](") && fullMatch.endsWith(")")) {
64
+ const linkMatch = fullMatch.match(/\[(.*?)\]\((.*?)\)/);
65
+ if (linkMatch) {
66
+ const linkText = linkMatch[1] ?? "";
67
+ const url = linkMatch[2] ?? "";
68
+ styledPart = `${renderInlineMarkdownToAnsi(linkText, theme, baseColor)}${colorize(" (", baseColor)}${colorize(url, theme.link)}${colorize(")", baseColor)}`;
69
+ }
70
+ }
71
+ else if (fullMatch.startsWith("<u>") && fullMatch.endsWith("</u>") && fullMatch.length > 7) {
72
+ styledPart = chalk.underline(renderInlineMarkdownToAnsi(fullMatch.slice(3, -4), theme, baseColor));
73
+ }
74
+ else if (fullMatch.match(/^https?:\/\//)) {
75
+ styledPart = colorize(fullMatch, theme.link);
76
+ }
77
+ result += styledPart || colorize(fullMatch, baseColor);
78
+ lastIndex = inlineRegex.lastIndex;
79
+ }
80
+ if (lastIndex < text.length) {
81
+ result += colorize(text.slice(lastIndex), baseColor);
82
+ }
83
+ return result;
84
+ }
85
+ export function wrapAnsiMarkdownLine(text, width) {
86
+ return wrapAnsi(text || " ", Math.max(1, width), { hard: true, wordWrap: true }).split("\n");
87
+ }
88
+ function renderHastToAnsi(node, theme, inheritedColor) {
89
+ if (node.type === "text")
90
+ return colorize(node.value, inheritedColor ?? theme.text);
91
+ if (node.type === "element") {
92
+ const nodeClasses = node.properties?.className ?? [];
93
+ const elementColorClass = nodeClasses.find((className) => getHighlightColor(className, theme));
94
+ const colorToPassDown = elementColorClass
95
+ ? getHighlightColor(elementColorClass, theme)
96
+ : inheritedColor;
97
+ return node.children
98
+ .map((child) => renderHastToAnsi(child, theme, colorToPassDown))
99
+ .join("");
100
+ }
101
+ if (node.type === "root") {
102
+ return node.children
103
+ .map((child) => renderHastToAnsi(child, theme, inheritedColor))
104
+ .join("");
105
+ }
106
+ return "";
107
+ }
108
+ function getHighlightColor(className, theme) {
109
+ switch (className) {
110
+ case "hljs-keyword":
111
+ case "hljs-selector-tag":
112
+ case "hljs-title":
113
+ return theme.secondary;
114
+ case "hljs-string":
115
+ case "hljs-attr":
116
+ case "hljs-symbol":
117
+ return theme.success;
118
+ case "hljs-number":
119
+ case "hljs-literal":
120
+ return theme.warning;
121
+ case "hljs-comment":
122
+ case "hljs-quote":
123
+ return theme.textDim;
124
+ case "hljs-built_in":
125
+ case "hljs-type":
126
+ case "hljs-class":
127
+ return theme.accent;
128
+ case "hljs-variable":
129
+ case "hljs-template-variable":
130
+ return theme.primary;
131
+ case "hljs-deletion":
132
+ return theme.error;
133
+ case "hljs-addition":
134
+ return theme.success;
135
+ default:
136
+ return undefined;
137
+ }
138
+ }
139
+ function highlightLineToAnsi(line, language, theme) {
140
+ try {
141
+ const strippedLine = stripAnsi(line);
142
+ const tree = !language || !lowlight.registered(language)
143
+ ? lowlight.highlightAuto(strippedLine)
144
+ : lowlight.highlight(language, strippedLine);
145
+ const rendered = renderHastToAnsi(tree, theme, undefined);
146
+ return rendered.length > 0 ? rendered : strippedLine;
147
+ }
148
+ catch {
149
+ return stripAnsi(line);
150
+ }
151
+ }
152
+ export function renderMarkdownCodeBlockToAnsi({ content, language, maxWidth, theme, hideLineNumbers = false, }) {
153
+ const finalLines = content.join("\n").replace(/\n$/u, "").split(/\r?\n/);
154
+ const padWidth = String(finalLines.length).length;
155
+ return finalLines.map((line, index) => {
156
+ const visibleLine = line.slice(0, Math.max(0, maxWidth));
157
+ const highlighted = highlightLineToAnsi(visibleLine, language ?? null, theme);
158
+ if (hideLineNumbers)
159
+ return highlighted;
160
+ return `${colorize(String(index + 1).padStart(padWidth, " "), theme.textDim)} ${highlighted}`;
161
+ });
162
+ }
163
+ export function renderMarkdownToAnsiLines({ text, theme, width, isPending = false, availableTerminalHeight, renderMarkdown = true, }) {
164
+ const safeText = stripUnsafeCharacters(text);
165
+ if (!safeText)
166
+ return [];
167
+ if (!renderMarkdown) {
168
+ return renderMarkdownCodeBlockToAnsi({
169
+ content: safeText.split(/\r?\n/),
170
+ language: "markdown",
171
+ maxWidth: width - 1,
172
+ theme,
173
+ hideLineNumbers: true,
174
+ });
175
+ }
176
+ const lines = safeText.split(/\r?\n/);
177
+ const headerRegex = /^ *(#{1,4}) +(.*)/;
178
+ const codeFenceRegex = /^ *(`{3,}|~{3,}) *([\w-]*?) *$/;
179
+ const ulItemRegex = /^([ \t]*)([-*+]) +(.*)/;
180
+ const olItemRegex = /^([ \t]*)(\d+)\. +(.*)/;
181
+ const hrRegex = /^ *(?:-{2,}|(?:[-*_] *){3,}) *$/;
182
+ const tableRowRegex = /^\s*\|(.+)\|\s*$/;
183
+ const tableSeparatorRegex = /^\s*\|?\s*(:?-+:?)\s*(\|\s*(:?-+:?)\s*)+\|?\s*$/;
184
+ const output = [];
185
+ let inCodeBlock = false;
186
+ let lastLineEmpty = true;
187
+ let codeBlockContent = [];
188
+ let codeBlockLang = null;
189
+ let codeBlockFence = "";
190
+ let inTable = false;
191
+ let tableRows = [];
192
+ let tableHeaders = [];
193
+ const addLines = (renderedLines) => {
194
+ if (renderedLines.length === 0)
195
+ return;
196
+ output.push(...renderedLines);
197
+ lastLineEmpty = false;
198
+ };
199
+ const addInlineLine = (rawLine, defaultColor = theme.text) => {
200
+ addLines(wrapAnsiMarkdownLine(renderInlineMarkdownToAnsi(rawLine, theme, defaultColor), width));
201
+ };
202
+ const addCodeBlock = (content) => {
203
+ const maxWidth = Math.max(1, width - 1);
204
+ if (isPending && availableTerminalHeight !== undefined) {
205
+ const minLinesForMessage = 1;
206
+ const reservedLines = 2;
207
+ const maxCodeLinesWhenPending = Math.max(0, availableTerminalHeight - reservedLines);
208
+ if (content.length > maxCodeLinesWhenPending) {
209
+ if (maxCodeLinesWhenPending < minLinesForMessage) {
210
+ addLines([colorize("... code is being written ...", theme.textMuted)]);
211
+ return;
212
+ }
213
+ addLines(renderMarkdownCodeBlockToAnsi({
214
+ content: content.slice(0, maxCodeLinesWhenPending),
215
+ language: codeBlockLang,
216
+ maxWidth,
217
+ theme,
218
+ }));
219
+ addLines([colorize("... generating more ...", theme.textMuted)]);
220
+ return;
221
+ }
222
+ }
223
+ addLines(renderMarkdownCodeBlockToAnsi({ content, language: codeBlockLang, maxWidth, theme }));
224
+ };
225
+ const flushTable = () => {
226
+ if (tableHeaders.length > 0 && tableRows.length > 0) {
227
+ const styledHeaders = tableHeaders.map((header) => renderInlineMarkdownToAnsi(stripUnsafeCharacters(header), theme, theme.link));
228
+ const styledRows = tableRows.map((row) => row.map((cell) => renderInlineMarkdownToAnsi(stripUnsafeCharacters(cell), theme, theme.text)));
229
+ addLines(renderAnsiTable({ headers: styledHeaders, rows: styledRows, terminalWidth: width, theme }));
230
+ }
231
+ inTable = false;
232
+ tableRows = [];
233
+ tableHeaders = [];
234
+ };
235
+ lines.forEach((line, index) => {
236
+ if (inCodeBlock) {
237
+ const fenceMatch = line.match(codeFenceRegex);
238
+ if (fenceMatch &&
239
+ fenceMatch[1]?.startsWith(codeBlockFence[0] ?? "") &&
240
+ fenceMatch[1].length >= codeBlockFence.length) {
241
+ addCodeBlock(codeBlockContent);
242
+ inCodeBlock = false;
243
+ codeBlockContent = [];
244
+ codeBlockLang = null;
245
+ codeBlockFence = "";
246
+ }
247
+ else {
248
+ codeBlockContent.push(line);
249
+ }
250
+ return;
251
+ }
252
+ const codeFenceMatch = line.match(codeFenceRegex);
253
+ const headerMatch = line.match(headerRegex);
254
+ const ulMatch = line.match(ulItemRegex);
255
+ const olMatch = line.match(olItemRegex);
256
+ const hrMatch = line.match(hrRegex);
257
+ const tableRowMatch = line.match(tableRowRegex);
258
+ const tableSeparatorMatch = line.match(tableSeparatorRegex);
259
+ if (codeFenceMatch) {
260
+ inCodeBlock = true;
261
+ codeBlockFence = codeFenceMatch[1] ?? "```";
262
+ codeBlockLang = codeFenceMatch[2] || null;
263
+ }
264
+ else if (tableRowMatch && !inTable) {
265
+ if (index + 1 < lines.length && tableSeparatorRegex.test(lines[index + 1] ?? "")) {
266
+ inTable = true;
267
+ tableHeaders = tableRowMatch[1]?.split("|").map((cell) => cell.trim()) ?? [];
268
+ tableRows = [];
269
+ }
270
+ else {
271
+ addInlineLine(line);
272
+ }
273
+ }
274
+ else if (inTable && tableSeparatorMatch) {
275
+ // Separator belongs to current table.
276
+ }
277
+ else if (inTable && tableRowMatch) {
278
+ const cells = tableRowMatch[1]?.split("|").map((cell) => cell.trim()) ?? [];
279
+ while (cells.length < tableHeaders.length)
280
+ cells.push("");
281
+ if (cells.length > tableHeaders.length)
282
+ cells.length = tableHeaders.length;
283
+ tableRows.push(cells);
284
+ }
285
+ else if (inTable && !tableRowMatch) {
286
+ flushTable();
287
+ if (line.trim().length > 0)
288
+ addInlineLine(line);
289
+ }
290
+ else if (hrMatch) {
291
+ addLines([chalk.dim("─".repeat(Math.max(1, width)))]);
292
+ }
293
+ else if (headerMatch) {
294
+ const level = headerMatch[1]?.length ?? 1;
295
+ const headerText = headerMatch[2] ?? "";
296
+ const headerColor = level <= 2 ? theme.link : level === 4 ? theme.textMuted : theme.text;
297
+ const rendered = renderInlineMarkdownToAnsi(headerText, theme, headerColor);
298
+ const styled = level <= 3 ? chalk.bold(rendered) : chalk.italic(rendered);
299
+ addLines(wrapAnsiMarkdownLine(styled, width));
300
+ }
301
+ else if (ulMatch) {
302
+ const indentation = (ulMatch[1] ?? "").length + 1;
303
+ const prefix = `${" ".repeat(indentation)}${ulMatch[2] ?? "-"} `;
304
+ addLines(wrapAnsiMarkdownLine(`${prefix}${renderInlineMarkdownToAnsi(ulMatch[3] ?? "", theme, theme.text)}`, width));
305
+ }
306
+ else if (olMatch) {
307
+ const indentation = (olMatch[1] ?? "").length + 1;
308
+ const prefix = `${" ".repeat(indentation)}${olMatch[2] ?? "1"}. `;
309
+ addLines(wrapAnsiMarkdownLine(`${prefix}${renderInlineMarkdownToAnsi(olMatch[3] ?? "", theme, theme.text)}`, width));
310
+ }
311
+ else if (line.trim().length === 0 && !inCodeBlock) {
312
+ if (!lastLineEmpty) {
313
+ output.push(EMPTY_RENDER_LINE);
314
+ lastLineEmpty = true;
315
+ }
316
+ }
317
+ else {
318
+ addInlineLine(line);
319
+ }
320
+ });
321
+ if (inCodeBlock)
322
+ addCodeBlock(codeBlockContent);
323
+ if (inTable)
324
+ flushTable();
325
+ return output;
326
+ }
327
+ //# sourceMappingURL=markdown-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-renderer.js","sourceRoot":"","sources":["../../../src/ui/utils/markdown-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,EAA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CAAC;AAChB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Theme } from "../theme/theme.js";
2
+ export interface RenderAnsiTableOptions {
3
+ headers: readonly string[];
4
+ rows: readonly (readonly string[])[];
5
+ terminalWidth: number;
6
+ theme: Theme;
7
+ }
8
+ export declare function renderAnsiTable({ headers, rows, terminalWidth, theme, }: RenderAnsiTableOptions): string[];
9
+ //# sourceMappingURL=markdown-table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-table.d.ts","sourceRoot":"","sources":["../../../src/ui/utils/markdown-table.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA8B/C,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,IAAI,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,IAAI,EACJ,aAAa,EACb,KAAK,GACN,EAAE,sBAAsB,GAAG,MAAM,EAAE,CAgGnC"}
@@ -0,0 +1,95 @@
1
+ import chalk from "chalk";
2
+ import stringWidth from "string-width";
3
+ import stripAnsi from "strip-ansi";
4
+ import wrapAnsi from "wrap-ansi";
5
+ const COLUMN_PADDING = 2;
6
+ const TABLE_MARGIN = 2;
7
+ const MIN_COLUMN_WIDTH = 5;
8
+ function colorize(text, color) {
9
+ return color ? chalk.hex(color)(text) : text;
10
+ }
11
+ function visualWidth(text) {
12
+ return stringWidth(stripAnsi(text));
13
+ }
14
+ function wrapAnsiLines(text, width) {
15
+ return wrapAnsi(text || " ", Math.max(1, width), { hard: true, wordWrap: true }).split("\n");
16
+ }
17
+ function padRightAnsi(text, width) {
18
+ return text + " ".repeat(Math.max(0, width - visualWidth(text)));
19
+ }
20
+ function normalizedCell(rows, rowIndex, colIndex) {
21
+ return rows[rowIndex]?.[colIndex] ?? "";
22
+ }
23
+ export function renderAnsiTable({ headers, rows, terminalWidth, theme, }) {
24
+ const allRows = [headers, ...rows];
25
+ const numColumns = Math.max(headers.length, ...rows.map((row) => row.length), 1);
26
+ const constraints = Array.from({ length: numColumns }, (_, colIndex) => {
27
+ const values = Array.from({ length: allRows.length }, (_, rowIndex) => normalizedCell(allRows, rowIndex, colIndex));
28
+ const maxContentWidth = Math.max(...values.map(visualWidth), MIN_COLUMN_WIDTH);
29
+ const maxWordWidth = Math.max(...values.flatMap((value) => stripAnsi(value)
30
+ .split(/\s+/u)
31
+ .filter(Boolean)
32
+ .map((word) => stringWidth(word))), MIN_COLUMN_WIDTH);
33
+ return { minWidth: maxWordWidth, maxWidth: Math.max(maxWordWidth, maxContentWidth) };
34
+ });
35
+ const fixedOverhead = numColumns + 1 + numColumns * COLUMN_PADDING;
36
+ const availableWidth = Math.max(0, terminalWidth - fixedOverhead - TABLE_MARGIN);
37
+ const totalMinWidth = constraints.reduce((sum, item) => sum + item.minWidth, 0);
38
+ let finalContentWidths;
39
+ if (totalMinWidth > availableWidth) {
40
+ const shortColumns = constraints.filter((item) => item.maxWidth <= MIN_COLUMN_WIDTH);
41
+ const totalShortColumnWidth = shortColumns.reduce((sum, item) => sum + item.minWidth, 0);
42
+ const finalTotalShortColumnWidth = totalShortColumnWidth >= availableWidth ? 0 : totalShortColumnWidth;
43
+ const scalableWidth = totalMinWidth - finalTotalShortColumnWidth;
44
+ const scale = scalableWidth > 0 ? (availableWidth - finalTotalShortColumnWidth) / scalableWidth : 0;
45
+ finalContentWidths = constraints.map((item) => {
46
+ if (item.maxWidth <= MIN_COLUMN_WIDTH && finalTotalShortColumnWidth > 0)
47
+ return item.minWidth;
48
+ return Math.max(1, Math.floor(item.minWidth * scale));
49
+ });
50
+ }
51
+ else {
52
+ const surplus = availableWidth - totalMinWidth;
53
+ const totalGrowthNeed = constraints.reduce((sum, item) => sum + (item.maxWidth - item.minWidth), 0);
54
+ finalContentWidths = constraints.map((item) => {
55
+ if (totalGrowthNeed === 0)
56
+ return item.minWidth;
57
+ const share = (item.maxWidth - item.minWidth) / totalGrowthNeed;
58
+ return Math.min(item.maxWidth, item.minWidth + Math.floor(surplus * share));
59
+ });
60
+ }
61
+ const actualColumnWidths = Array.from({ length: numColumns }, () => 0);
62
+ const wrapAndMeasureRow = (row) => Array.from({ length: numColumns }, (_, colIndex) => {
63
+ const contentWidth = Math.max(1, finalContentWidths[colIndex] ?? 1);
64
+ const lines = wrapAnsiLines(row[colIndex] ?? "", contentWidth).map((line) => {
65
+ actualColumnWidths[colIndex] = Math.max(actualColumnWidths[colIndex] ?? 0, visualWidth(line));
66
+ return line;
67
+ });
68
+ return lines.length > 0 ? lines : [""];
69
+ });
70
+ const wrappedHeaders = wrapAndMeasureRow(headers);
71
+ const wrappedRows = rows.map((row) => wrapAndMeasureRow(row));
72
+ const adjustedWidths = actualColumnWidths.map((width) => width + COLUMN_PADDING);
73
+ const border = (left, middle, right) => colorize(left + adjustedWidths.map((width) => "─".repeat(Math.max(0, width))).join(middle) + right, theme.border);
74
+ const visualRowLines = (cells, isHeader = false) => {
75
+ const maxHeight = Math.max(...cells.map((cell) => cell.length), 1);
76
+ return Array.from({ length: maxHeight }, (_, lineIndex) => {
77
+ const row = cells
78
+ .map((cell, index) => {
79
+ const contentWidth = Math.max(0, (adjustedWidths[index] ?? 0) - COLUMN_PADDING);
80
+ const content = padRightAnsi(cell[lineIndex] ?? "", contentWidth);
81
+ return ` ${isHeader ? chalk.bold(colorize(content, theme.link)) : content} `;
82
+ })
83
+ .join(colorize("│", theme.border));
84
+ return colorize("│", theme.border) + row + colorize("│", theme.border);
85
+ });
86
+ };
87
+ return [
88
+ border("┌", "┬", "┐"),
89
+ ...visualRowLines(wrappedHeaders, true),
90
+ border("├", "┼", "┤"),
91
+ ...wrappedRows.flatMap((row) => visualRowLines(row)),
92
+ border("└", "┴", "┘"),
93
+ ];
94
+ }
95
+ //# s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the current terminal supports.
4
+ *
5
+ * @param env Environment to inspect (defaults to `process.env`).
6
+ * @param isTTY Whether stdout is a TTY (defaults to `process.stdout.isTTY`).
7
+ * Graphics are only emitted to a real interactive terminal.
8
+ */
9
+ export declare function detectGraphicsProtocol(env?: NodeJS.ProcessEnv, isTTY?: boolean): GraphicsProtocol;
10
+ /**
11
+ * Encode a base64 image payload into an inline-image escape sequence for the
12
+ * given protocol. Returns an empty string for the "none" protocol so callers
13
+ * can append unconditionally.
14
+ */
15
+ export declare function encodeInlineImage(base64: string, protocol: GraphicsProtocol): string;
16
+ //# sourceMappingURL=terminal-graphics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-graphics.d.ts","sourceRoot":"","sources":["../../../src/ui/utils/terminal-graphics.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAK1D;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,KAAK,GAAE,OAAuC,GAC7C,gBAAgB,CAyBlB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAsBpF"}
@@ -0,0 +1,68 @@
1
+ // Inline terminal image rendering via the iTerm2 and kitty graphics protocols.
2
+ //
3
+ // Two protocols cover the common graphics-capable terminals:
4
+ // - "iterm" → iTerm2 / WezTerm (OSC 1337 File=inline=1)
5
+ // - "kitty" → kitty / Ghostty (APC _G chunked transmission)
6
+ //
7
+ // Detection defaults to "none" on any uncertainty (non-TTY, unknown TERM,
8
+ // tmux without passthrough) so we never emit raw escape sequences into a
9
+ // terminal that would print them as garbage.
10
+ /** kitty transmits image data in <= 4096-byte base64 chunks. */
11
+ const KITTY_CHUNK_SIZE = 4096;
12
+ /**
13
+ * Detect which inline-image graphics protocol the current terminal supports.
14
+ *
15
+ * @param env Environment to inspect (defaults to `process.env`).
16
+ * @param isTTY Whether stdout is a TTY (defaults to `process.stdout.isTTY`).
17
+ * Graphics are only emitted to a real interactive terminal.
18
+ */
19
+ export function detectGraphicsProtocol(env = process.env, isTTY = Boolean(process.stdout.isTTY)) {
20
+ if (!isTTY)
21
+ return "none";
22
+ // tmux rewrites/strips graphics sequences unless passthrough is configured.
23
+ // We don't enable passthrough by default, so treat tmux as unsupported.
24
+ if (env["TMUX"] || env["TERM"]?.includes("tmux") || env["TERM"]?.includes("screen")) {
25
+ return "none";
26
+ }
27
+ const termProgram = env["TERM_PROGRAM"];
28
+ // iTerm2 and WezTerm both implement the iTerm2 inline-image OSC.
29
+ if (termProgram === "iTerm.app" || termProgram === "WezTerm" || env["WEZTERM_PANE"]) {
30
+ return "iterm";
31
+ }
32
+ // kitty and Ghostty implement the kitty graphics protocol.
33
+ if (env["KITTY_WINDOW_ID"] || env["TERM"]?.includes("kitty")) {
34
+ return "kitty";
35
+ }
36
+ if (termProgram === "ghostty" || env["GHOSTTY_RESOURCES_DIR"] || env["GHOSTTY_BIN_DIR"]) {
37
+ return "kitty";
38
+ }
39
+ return "none";
40
+ }
41
+ /**
42
+ * Encode a base64 image payload into an inline-image escape sequence for the
43
+ * given protocol. Returns an empty string for the "none" protocol so callers
44
+ * can append unconditionally.
45
+ */
46
+ export function encodeInlineImage(base64, protocol) {
47
+ if (protocol === "none" || base64.length === 0)
48
+ return "";
49
+ if (protocol === "iterm") {
50
+ // OSC 1337 ; File = inline=1 ; preserveAspectRatio=1 : <base64> BEL
51
+ return `\u001b]1337;File=inline=1;preserveAspectRatio=1:${base64}\u0007`;
52
+ }
53
+ // kitty graphics protocol: chunked APC transmission.
54
+ // first chunk: _G f=100,a=T,m=<1|0> ; <chunk> ST
55
+ // later chunks: _G m=<1|0> ; <chunk> ST
56
+ // m=1 marks "more chunks follow", m=0 marks the final chunk.
57
+ const chunks = [];
58
+ for (let offset = 0; offset < base64.length; offset += KITTY_CHUNK_SIZE) {
59
+ const chunk = base64.slice(offset, offset + KITTY_CHUNK_SIZE);
60
+ const isFirst = offset === 0;
61
+ const isLast = offset + KITTY_CHUNK_SIZE >= base64.length;
62
+ const more = isLast ? 0 : 1;
63
+ const control = isFirst ? `f=100,a=T,m=${more}` : `m=${more}`;
64
+ chunks.push(`\u001b_G${control};${chunk}\u001b\\`);
65
+ }
66
+ return chunks.join("");
67
+ }
68
+ //# sourceMappingURL=terminal-graphics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-graphics.js","sourceRoot":"","sources":["../../../src/ui/utils/terminal-graphics.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,6DAA6D;AAC7D,2DAA2D;AAC3D,iEAAiE;AACjE,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,6CAA6C;AAI7C,gEAAgE;AAChE,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAyB,OAAO,CAAC,GAAG,EACpC,QAAiB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAE9C,IAAI,CAAC,KAAK;QAAE,OAAO,MAAM,CAAC;IAE1B,4EAA4E;IAC5E,wEAAwE;IACxE,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,WAAW,GAAG,GAAG,CAAC,cAAc,CAAC,CAAC;IAExC,iEAAiE;IACjE,IAAI,WAAW,KAAK,WAAW,IAAI,WAAW,KAAK,SAAS,IAAI,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QACpF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,2DAA2D;IAC3D,IAAI,GAAG,CAAC,i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,IAAI,KAAK,UAAU,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=terminal-graphics.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-graphics.test.d.ts","sourceRoot":"","sources":["../../../src/ui/utils/terminal-graphics.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { detectGraphicsProtocol, encodeInlineImage } from "./terminal-graphics.js";
3
+ describe("detectGraphicsProtocol", () => {
4
+ it("detects iTerm2 and WezTerm as the iterm protocol", () => {
5
+ expect(detectGraphicsProtocol({ TERM_PROGRAM: "iTerm.app" }, true)).toBe("iterm");
6
+ expect(detectGraphicsProtocol({ TERM_PROGRAM: "WezTerm" }, true)).toBe("iterm");
7
+ expect(detectGraphicsProtocol({ WEZTERM_PANE: "0" }, true)).toBe("iterm");
8
+ });
9
+ it("detects kitty, Ghostty, and xterm-kitty as the kitty protocol", () => {
10
+ expect(detectGraphicsProtocol({ KITTY_WINDOW_ID: "1" }, true)).toBe("kitty");
11
+ expect(detectGraphicsProtocol({ TERM: "xterm-kitty" }, true)).toBe("kitty");
12
+ expect(detectGraphicsProtocol({ TERM_PROGRAM: "ghostty" }, true)).toBe("kitty");
13
+ expect(detectGraphicsProtocol({ GHOSTTY_RESOURCES_DIR: "/x" }, true)).toBe("kitty");
14
+ });
15
+ it("returns none for unsupported terminals, missing env, and non-TTY", () => {
16
+ expect(detectGraphicsProtocol({ TERM: "xterm-256color" }, true)).toBe("none");
17
+ expect(detectGraphicsProtocol({}, true)).toBe("none");
18
+ expect(detectGraphicsProtocol({ KITTY_WINDOW_ID: "1" }, false)).toBe("none");
19
+ });
20
+ it("returns none inside tmux even when a graphics terminal is detected", () => {
21
+ expect(detectGraphicsProtocol({ KITTY_WINDOW_ID: "1", TMUX: "/tmp/tmux" }, true)).toBe("none");
22
+ expect(detectGraphicsProtocol({ TERM: "screen-256color" }, true)).toBe("none");
23
+ });
24
+ });
25
+ describe("encodeInlineImage", () => {
26
+ const base64 = Buffer.from("hello world image bytes").toString("base64");
27
+ it("produces a single iTerm2 OSC 1337 sequence terminated by BEL", () => {
28
+ const out = encodeInlineImage(base64, "iterm");
29
+ expect(out.startsWith("\u001b]1337;File=inline=1;preserveAspectRatio=1:")).toBe(true);
30
+ expect(out.endsWith("\u0007")).toBe(true);
31
+ expect(out).toContain(base64);
32
+ // Exactly one BEL terminator → a single sequence.
33
+ expect(out.split("\u0007")).toHaveLength(2);
34
+ });
35
+ it("returns an empty string for the none protocol or empty payload", () => {
36
+ expect(encodeInlineImage(base64, "none")).toBe("");
37
+ expect(encodeInlineImage("", "iterm")).toBe("");
38
+ });
39
+ it("chunks kitty payloads at 4096 chars with correct continuation markers", () => {
40
+ const big = "A".repeat(4096 * 2 + 100);
41
+ const out = encodeInlineImage(big, "kitty");
42
+ const chunks = out.split("\u001b\\").filter((c) => c.length > 0);
43
+ expect(chunks).toHaveLength(3);
44
+ // First chunk carries the format/action keys and m=1 (more follow).
45
+ expect(chunks[0].startsWith("\u001b_Gf=100,a=T,m=1;")).toBe(true);
46
+ // Middle chunk is a continuation with m=1.
47
+ expect(chunks[1].startsWith("\u001b_Gm=1;")).toBe(true);
48
+ // Final chunk closes with m=0.
49
+ expect(chunks[2].startsWith("\u001b_Gm=0;")).toBe(true);
50
+ // Round-trip: concatenated payloads equal the input base64.
51
+ const payloads = chunks.map((c) => c.slice(c.indexOf(";") + 1)).join("");
52
+ expect(payloads).toBe(big);
53
+ });
54
+ it("emits a single final kitty chunk for payloads under one chunk", () => {
55
+ const out = encodeInlineImage(base64, "kitty");
56
+ const chunks = out.split("\u001b\\").filter((c) => c.length > 0);
57
+ expect(chunks).toHaveLength(1);
58
+ expect(chunks[0].startsWith("\u001b_Gf=100,a=T,m=0;")).toBe(true);
59
+ });
60
+ });
61
+ //# sourceMappingURL=terminal-graphics.test.js.map