@umsai/ums-code 0.0.11-post1

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 (945) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +367 -0
  3. package/dist/.last_build +0 -0
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.js +20 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/package.json +88 -0
  8. package/dist/src/commands/mcp/add.d.ts +7 -0
  9. package/dist/src/commands/mcp/add.js +166 -0
  10. package/dist/src/commands/mcp/add.js.map +1 -0
  11. package/dist/src/commands/mcp/list.d.ts +8 -0
  12. package/dist/src/commands/mcp/list.js +110 -0
  13. package/dist/src/commands/mcp/list.js.map +1 -0
  14. package/dist/src/commands/mcp/remove.d.ts +7 -0
  15. package/dist/src/commands/mcp/remove.js +44 -0
  16. package/dist/src/commands/mcp/remove.js.map +1 -0
  17. package/dist/src/commands/mcp.d.ts +7 -0
  18. package/dist/src/commands/mcp.js +23 -0
  19. package/dist/src/commands/mcp.js.map +1 -0
  20. package/dist/src/config/auth.d.ts +12 -0
  21. package/dist/src/config/auth.js +71 -0
  22. package/dist/src/config/auth.js.map +1 -0
  23. package/dist/src/config/auth.test.d.ts +6 -0
  24. package/dist/src/config/auth.test.js +57 -0
  25. package/dist/src/config/auth.test.js.map +1 -0
  26. package/dist/src/config/config.d.ts +45 -0
  27. package/dist/src/config/config.js +479 -0
  28. package/dist/src/config/config.js.map +1 -0
  29. package/dist/src/config/extension.d.ts +23 -0
  30. package/dist/src/config/extension.js +123 -0
  31. package/dist/src/config/extension.js.map +1 -0
  32. package/dist/src/config/keyBindings.d.ts +66 -0
  33. package/dist/src/config/keyBindings.js +141 -0
  34. package/dist/src/config/keyBindings.js.map +1 -0
  35. package/dist/src/config/keyBindings.test.d.ts +6 -0
  36. package/dist/src/config/keyBindings.test.js +51 -0
  37. package/dist/src/config/keyBindings.test.js.map +1 -0
  38. package/dist/src/config/sandboxConfig.d.ts +13 -0
  39. package/dist/src/config/sandboxConfig.js +75 -0
  40. package/dist/src/config/sandboxConfig.js.map +1 -0
  41. package/dist/src/config/settings.d.ts +56 -0
  42. package/dist/src/config/settings.js +363 -0
  43. package/dist/src/config/settings.js.map +1 -0
  44. package/dist/src/config/settingsSchema.d.ts +613 -0
  45. package/dist/src/config/settingsSchema.js +586 -0
  46. package/dist/src/config/settingsSchema.js.map +1 -0
  47. package/dist/src/config/settingsSchema.test.d.ts +6 -0
  48. package/dist/src/config/settingsSchema.test.js +196 -0
  49. package/dist/src/config/settingsSchema.test.js.map +1 -0
  50. package/dist/src/config/trustedFolders.d.ts +37 -0
  51. package/dist/src/config/trustedFolders.js +118 -0
  52. package/dist/src/config/trustedFolders.js.map +1 -0
  53. package/dist/src/config/trustedFolders.test.d.ts +6 -0
  54. package/dist/src/config/trustedFolders.test.js +160 -0
  55. package/dist/src/config/trustedFolders.test.js.map +1 -0
  56. package/dist/src/gemini.d.ts +9 -0
  57. package/dist/src/gemini.js +262 -0
  58. package/dist/src/gemini.js.map +1 -0
  59. package/dist/src/gemini.test.d.ts +6 -0
  60. package/dist/src/gemini.test.js +193 -0
  61. package/dist/src/gemini.test.js.map +1 -0
  62. package/dist/src/generated/git-commit.d.ts +7 -0
  63. package/dist/src/generated/git-commit.js +10 -0
  64. package/dist/src/generated/git-commit.js.map +1 -0
  65. package/dist/src/nonInteractiveCli.d.ts +7 -0
  66. package/dist/src/nonInteractiveCli.js +103 -0
  67. package/dist/src/nonInteractiveCli.js.map +1 -0
  68. package/dist/src/patches/is-in-ci.d.ts +7 -0
  69. package/dist/src/patches/is-in-ci.js +15 -0
  70. package/dist/src/patches/is-in-ci.js.map +1 -0
  71. package/dist/src/services/BuiltinCommandLoader.d.ts +24 -0
  72. package/dist/src/services/BuiltinCommandLoader.js +91 -0
  73. package/dist/src/services/BuiltinCommandLoader.js.map +1 -0
  74. package/dist/src/services/BuiltinCommandLoader.test.d.ts +6 -0
  75. package/dist/src/services/BuiltinCommandLoader.test.js +111 -0
  76. package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -0
  77. package/dist/src/services/CommandService.d.ts +55 -0
  78. package/dist/src/services/CommandService.js +90 -0
  79. package/dist/src/services/CommandService.js.map +1 -0
  80. package/dist/src/services/CommandService.test.d.ts +6 -0
  81. package/dist/src/services/CommandService.test.js +232 -0
  82. package/dist/src/services/CommandService.test.js.map +1 -0
  83. package/dist/src/services/FileCommandLoader.d.ts +49 -0
  84. package/dist/src/services/FileCommandLoader.js +210 -0
  85. package/dist/src/services/FileCommandLoader.js.map +1 -0
  86. package/dist/src/services/McpPromptLoader.d.ts +25 -0
  87. package/dist/src/services/McpPromptLoader.js +192 -0
  88. package/dist/src/services/McpPromptLoader.js.map +1 -0
  89. package/dist/src/services/prompt-processors/argumentProcessor.d.ts +16 -0
  90. package/dist/src/services/prompt-processors/argumentProcessor.js +20 -0
  91. package/dist/src/services/prompt-processors/argumentProcessor.js.map +1 -0
  92. package/dist/src/services/prompt-processors/shellProcessor.d.ts +35 -0
  93. package/dist/src/services/prompt-processors/shellProcessor.js +162 -0
  94. package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -0
  95. package/dist/src/services/prompt-processors/types.d.ts +40 -0
  96. package/dist/src/services/prompt-processors/types.js +16 -0
  97. package/dist/src/services/prompt-processors/types.js.map +1 -0
  98. package/dist/src/services/types.d.ts +22 -0
  99. package/dist/src/services/types.js +7 -0
  100. package/dist/src/services/types.js.map +1 -0
  101. package/dist/src/test-utils/customMatchers.d.ts +14 -0
  102. package/dist/src/test-utils/customMatchers.js +46 -0
  103. package/dist/src/test-utils/customMatchers.js.map +1 -0
  104. package/dist/src/test-utils/mockCommandContext.d.ts +18 -0
  105. package/dist/src/test-utils/mockCommandContext.js +87 -0
  106. package/dist/src/test-utils/mockCommandContext.js.map +1 -0
  107. package/dist/src/test-utils/mockCommandContext.test.d.ts +6 -0
  108. package/dist/src/test-utils/mockCommandContext.test.js +51 -0
  109. package/dist/src/test-utils/mockCommandContext.test.js.map +1 -0
  110. package/dist/src/test-utils/render.d.ts +8 -0
  111. package/dist/src/test-utils/render.js +10 -0
  112. package/dist/src/test-utils/render.js.map +1 -0
  113. package/dist/src/ui/App.d.ts +15 -0
  114. package/dist/src/ui/App.js +747 -0
  115. package/dist/src/ui/App.js.map +1 -0
  116. package/dist/src/ui/IdeIntegrationNudge.d.ts +16 -0
  117. package/dist/src/ui/IdeIntegrationNudge.js +52 -0
  118. package/dist/src/ui/IdeIntegrationNudge.js.map +1 -0
  119. package/dist/src/ui/colors.d.ts +7 -0
  120. package/dist/src/ui/colors.js +54 -0
  121. package/dist/src/ui/colors.js.map +1 -0
  122. package/dist/src/ui/commands/aboutCommand.d.ts +7 -0
  123. package/dist/src/ui/commands/aboutCommand.js +43 -0
  124. package/dist/src/ui/commands/aboutCommand.js.map +1 -0
  125. package/dist/src/ui/commands/agentsCommand.d.ts +7 -0
  126. package/dist/src/ui/commands/agentsCommand.js +32 -0
  127. package/dist/src/ui/commands/agentsCommand.js.map +1 -0
  128. package/dist/src/ui/commands/authCommand.d.ts +7 -0
  129. package/dist/src/ui/commands/authCommand.js +16 -0
  130. package/dist/src/ui/commands/authCommand.js.map +1 -0
  131. package/dist/src/ui/commands/bugCommand.d.ts +7 -0
  132. package/dist/src/ui/commands/bugCommand.js +71 -0
  133. package/dist/src/ui/commands/bugCommand.js.map +1 -0
  134. package/dist/src/ui/commands/chatCommand.d.ts +7 -0
  135. package/dist/src/ui/commands/chatCommand.js +234 -0
  136. package/dist/src/ui/commands/chatCommand.js.map +1 -0
  137. package/dist/src/ui/commands/clearCommand.d.ts +7 -0
  138. package/dist/src/ui/commands/clearCommand.js +27 -0
  139. package/dist/src/ui/commands/clearCommand.js.map +1 -0
  140. package/dist/src/ui/commands/compressCommand.d.ts +7 -0
  141. package/dist/src/ui/commands/compressCommand.js +64 -0
  142. package/dist/src/ui/commands/compressCommand.js.map +1 -0
  143. package/dist/src/ui/commands/copyCommand.d.ts +7 -0
  144. package/dist/src/ui/commands/copyCommand.js +59 -0
  145. package/dist/src/ui/commands/copyCommand.js.map +1 -0
  146. package/dist/src/ui/commands/corgiCommand.d.ts +7 -0
  147. package/dist/src/ui/commands/corgiCommand.js +15 -0
  148. package/dist/src/ui/commands/corgiCommand.js.map +1 -0
  149. package/dist/src/ui/commands/directoryCommand.d.ts +8 -0
  150. package/dist/src/ui/commands/directoryCommand.js +133 -0
  151. package/dist/src/ui/commands/directoryCommand.js.map +1 -0
  152. package/dist/src/ui/commands/docsCommand.d.ts +7 -0
  153. package/dist/src/ui/commands/docsCommand.js +31 -0
  154. package/dist/src/ui/commands/docsCommand.js.map +1 -0
  155. package/dist/src/ui/commands/editorCommand.d.ts +7 -0
  156. package/dist/src/ui/commands/editorCommand.js +16 -0
  157. package/dist/src/ui/commands/editorCommand.js.map +1 -0
  158. package/dist/src/ui/commands/extensionsCommand.d.ts +7 -0
  159. package/dist/src/ui/commands/extensionsCommand.js +31 -0
  160. package/dist/src/ui/commands/extensionsCommand.js.map +1 -0
  161. package/dist/src/ui/commands/helpCommand.d.ts +7 -0
  162. package/dist/src/ui/commands/helpCommand.js +21 -0
  163. package/dist/src/ui/commands/helpCommand.js.map +1 -0
  164. package/dist/src/ui/commands/ideCommand.d.ts +8 -0
  165. package/dist/src/ui/commands/ideCommand.js +218 -0
  166. package/dist/src/ui/commands/ideCommand.js.map +1 -0
  167. package/dist/src/ui/commands/initCommand.d.ts +7 -0
  168. package/dist/src/ui/commands/initCommand.js +116 -0
  169. package/dist/src/ui/commands/initCommand.js.map +1 -0
  170. package/dist/src/ui/commands/mcpCommand.d.ts +7 -0
  171. package/dist/src/ui/commands/mcpCommand.js +424 -0
  172. package/dist/src/ui/commands/mcpCommand.js.map +1 -0
  173. package/dist/src/ui/commands/memoryCommand.d.ts +7 -0
  174. package/dist/src/ui/commands/memoryCommand.js +224 -0
  175. package/dist/src/ui/commands/memoryCommand.js.map +1 -0
  176. package/dist/src/ui/commands/privacyCommand.d.ts +7 -0
  177. package/dist/src/ui/commands/privacyCommand.js +16 -0
  178. package/dist/src/ui/commands/privacyCommand.js.map +1 -0
  179. package/dist/src/ui/commands/quitCommand.d.ts +8 -0
  180. package/dist/src/ui/commands/quitCommand.js +59 -0
  181. package/dist/src/ui/commands/quitCommand.js.map +1 -0
  182. package/dist/src/ui/commands/restoreCommand.d.ts +8 -0
  183. package/dist/src/ui/commands/restoreCommand.js +128 -0
  184. package/dist/src/ui/commands/restoreCommand.js.map +1 -0
  185. package/dist/src/ui/commands/settingsCommand.d.ts +7 -0
  186. package/dist/src/ui/commands/settingsCommand.js +16 -0
  187. package/dist/src/ui/commands/settingsCommand.js.map +1 -0
  188. package/dist/src/ui/commands/setupGithubCommand.d.ts +9 -0
  189. package/dist/src/ui/commands/setupGithubCommand.js +154 -0
  190. package/dist/src/ui/commands/setupGithubCommand.js.map +1 -0
  191. package/dist/src/ui/commands/setupGithubCommand.test.d.ts +6 -0
  192. package/dist/src/ui/commands/setupGithubCommand.test.js +167 -0
  193. package/dist/src/ui/commands/setupGithubCommand.test.js.map +1 -0
  194. package/dist/src/ui/commands/statsCommand.d.ts +7 -0
  195. package/dist/src/ui/commands/statsCommand.js +53 -0
  196. package/dist/src/ui/commands/statsCommand.js.map +1 -0
  197. package/dist/src/ui/commands/summaryCommand.d.ts +7 -0
  198. package/dist/src/ui/commands/summaryCommand.js +149 -0
  199. package/dist/src/ui/commands/summaryCommand.js.map +1 -0
  200. package/dist/src/ui/commands/terminalSetupCommand.d.ts +13 -0
  201. package/dist/src/ui/commands/terminalSetupCommand.js +41 -0
  202. package/dist/src/ui/commands/terminalSetupCommand.js.map +1 -0
  203. package/dist/src/ui/commands/themeCommand.d.ts +7 -0
  204. package/dist/src/ui/commands/themeCommand.js +16 -0
  205. package/dist/src/ui/commands/themeCommand.js.map +1 -0
  206. package/dist/src/ui/commands/toolsCommand.d.ts +7 -0
  207. package/dist/src/ui/commands/toolsCommand.js +56 -0
  208. package/dist/src/ui/commands/toolsCommand.js.map +1 -0
  209. package/dist/src/ui/commands/types.d.ts +154 -0
  210. package/dist/src/ui/commands/types.js +12 -0
  211. package/dist/src/ui/commands/types.js.map +1 -0
  212. package/dist/src/ui/commands/ums/umsInitCommand.d.ts +7 -0
  213. package/dist/src/ui/commands/ums/umsInitCommand.js +1067 -0
  214. package/dist/src/ui/commands/ums/umsInitCommand.js.map +1 -0
  215. package/dist/src/ui/commands/vimCommand.d.ts +7 -0
  216. package/dist/src/ui/commands/vimCommand.js +23 -0
  217. package/dist/src/ui/commands/vimCommand.js.map +1 -0
  218. package/dist/src/ui/components/AboutBox.d.ts +17 -0
  219. package/dist/src/ui/components/AboutBox.js +6 -0
  220. package/dist/src/ui/components/AboutBox.js.map +1 -0
  221. package/dist/src/ui/components/AsciiArt.d.ts +8 -0
  222. package/dist/src/ui/components/AsciiArt.js +30 -0
  223. package/dist/src/ui/components/AsciiArt.js.map +1 -0
  224. package/dist/src/ui/components/AuthDialog.d.ts +15 -0
  225. package/dist/src/ui/components/AuthDialog.js +164 -0
  226. package/dist/src/ui/components/AuthDialog.js.map +1 -0
  227. package/dist/src/ui/components/AuthDialog.test.d.ts +6 -0
  228. package/dist/src/ui/components/AuthDialog.test.js +220 -0
  229. package/dist/src/ui/components/AuthDialog.test.js.map +1 -0
  230. package/dist/src/ui/components/AuthInProgress.d.ts +11 -0
  231. package/dist/src/ui/components/AuthInProgress.js +28 -0
  232. package/dist/src/ui/components/AuthInProgress.js.map +1 -0
  233. package/dist/src/ui/components/AutoAcceptIndicator.d.ts +12 -0
  234. package/dist/src/ui/components/AutoAcceptIndicator.js +26 -0
  235. package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -0
  236. package/dist/src/ui/components/ConsoleSummaryDisplay.d.ts +11 -0
  237. package/dist/src/ui/components/ConsoleSummaryDisplay.js +11 -0
  238. package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -0
  239. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +20 -0
  240. package/dist/src/ui/components/ContextSummaryDisplay.js +65 -0
  241. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -0
  242. package/dist/src/ui/components/ContextUsageDisplay.d.ts +9 -0
  243. package/dist/src/ui/components/ContextUsageDisplay.js +14 -0
  244. package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -0
  245. package/dist/src/ui/components/DebugProfiler.d.ts +6 -0
  246. package/dist/src/ui/components/DebugProfiler.js +27 -0
  247. package/dist/src/ui/components/DebugProfiler.js.map +1 -0
  248. package/dist/src/ui/components/DetailedMessagesDisplay.d.ts +14 -0
  249. package/dist/src/ui/components/DetailedMessagesDisplay.js +34 -0
  250. package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -0
  251. package/dist/src/ui/components/EditorSettingsDialog.d.ts +15 -0
  252. package/dist/src/ui/components/EditorSettingsDialog.js +74 -0
  253. package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -0
  254. package/dist/src/ui/components/FolderTrustDialog.d.ts +16 -0
  255. package/dist/src/ui/components/FolderTrustDialog.js +39 -0
  256. package/dist/src/ui/components/FolderTrustDialog.js.map +1 -0
  257. package/dist/src/ui/components/FolderTrustDialog.test.d.ts +6 -0
  258. package/dist/src/ui/components/FolderTrustDialog.test.js +26 -0
  259. package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -0
  260. package/dist/src/ui/components/Footer.d.ts +23 -0
  261. package/dist/src/ui/components/Footer.js +25 -0
  262. package/dist/src/ui/components/Footer.js.map +1 -0
  263. package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +17 -0
  264. package/dist/src/ui/components/GeminiRespondingSpinner.js +16 -0
  265. package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -0
  266. package/dist/src/ui/components/Header.d.ts +13 -0
  267. package/dist/src/ui/components/Header.js +28 -0
  268. package/dist/src/ui/components/Header.js.map +1 -0
  269. package/dist/src/ui/components/Header.test.d.ts +6 -0
  270. package/dist/src/ui/components/Header.test.js +37 -0
  271. package/dist/src/ui/components/Header.test.js.map +1 -0
  272. package/dist/src/ui/components/Help.d.ts +12 -0
  273. package/dist/src/ui/components/Help.js +10 -0
  274. package/dist/src/ui/components/Help.js.map +1 -0
  275. package/dist/src/ui/components/HistoryItemDisplay.d.ts +20 -0
  276. package/dist/src/ui/components/HistoryItemDisplay.js +19 -0
  277. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
  278. package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +6 -0
  279. package/dist/src/ui/components/HistoryItemDisplay.test.js +91 -0
  280. package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -0
  281. package/dist/src/ui/components/InputPrompt.d.ts +28 -0
  282. package/dist/src/ui/components/InputPrompt.js +441 -0
  283. package/dist/src/ui/components/InputPrompt.js.map +1 -0
  284. package/dist/src/ui/components/LoadingIndicator.d.ts +15 -0
  285. package/dist/src/ui/components/LoadingIndicator.js +25 -0
  286. package/dist/src/ui/components/LoadingIndicator.js.map +1 -0
  287. package/dist/src/ui/components/LoadingIndicator.test.d.ts +6 -0
  288. package/dist/src/ui/components/LoadingIndicator.test.js +190 -0
  289. package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -0
  290. package/dist/src/ui/components/MemoryUsageDisplay.d.ts +7 -0
  291. package/dist/src/ui/components/MemoryUsageDisplay.js +27 -0
  292. package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -0
  293. package/dist/src/ui/components/ModelStatsDisplay.d.ts +7 -0
  294. package/dist/src/ui/components/ModelStatsDisplay.js +33 -0
  295. package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -0
  296. package/dist/src/ui/components/OpenAIKeyPrompt.d.ts +12 -0
  297. package/dist/src/ui/components/OpenAIKeyPrompt.js +118 -0
  298. package/dist/src/ui/components/OpenAIKeyPrompt.js.map +1 -0
  299. package/dist/src/ui/components/OpenAIKeyPrompt.test.d.ts +6 -0
  300. package/dist/src/ui/components/OpenAIKeyPrompt.test.js +44 -0
  301. package/dist/src/ui/components/OpenAIKeyPrompt.test.js.map +1 -0
  302. package/dist/src/ui/components/PrepareLabel.d.ts +15 -0
  303. package/dist/src/ui/components/PrepareLabel.js +16 -0
  304. package/dist/src/ui/components/PrepareLabel.js.map +1 -0
  305. package/dist/src/ui/components/QuitConfirmationDialog.d.ts +17 -0
  306. package/dist/src/ui/components/QuitConfirmationDialog.js +44 -0
  307. package/dist/src/ui/components/QuitConfirmationDialog.js.map +1 -0
  308. package/dist/src/ui/components/QwenOAuthProgress.d.ts +16 -0
  309. package/dist/src/ui/components/QwenOAuthProgress.js +108 -0
  310. package/dist/src/ui/components/QwenOAuthProgress.js.map +1 -0
  311. package/dist/src/ui/components/QwenOAuthProgress.test.d.ts +6 -0
  312. package/dist/src/ui/components/QwenOAuthProgress.test.js +292 -0
  313. package/dist/src/ui/components/QwenOAuthProgress.test.js.map +1 -0
  314. package/dist/src/ui/components/SessionSummaryDisplay.d.ts +11 -0
  315. package/dist/src/ui/components/SessionSummaryDisplay.js +4 -0
  316. package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -0
  317. package/dist/src/ui/components/SettingsDialog.d.ts +14 -0
  318. package/dist/src/ui/components/SettingsDialog.js +519 -0
  319. package/dist/src/ui/components/SettingsDialog.js.map +1 -0
  320. package/dist/src/ui/components/SettingsDialog.test.d.ts +6 -0
  321. package/dist/src/ui/components/SettingsDialog.test.js +568 -0
  322. package/dist/src/ui/components/SettingsDialog.test.js.map +1 -0
  323. package/dist/src/ui/components/ShellConfirmationDialog.d.ts +15 -0
  324. package/dist/src/ui/components/ShellConfirmationDialog.js +46 -0
  325. package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -0
  326. package/dist/src/ui/components/ShellConfirmationDialog.test.d.ts +6 -0
  327. package/dist/src/ui/components/ShellConfirmationDialog.test.js +40 -0
  328. package/dist/src/ui/components/ShellConfirmationDialog.test.js.map +1 -0
  329. package/dist/src/ui/components/ShellModeIndicator.d.ts +7 -0
  330. package/dist/src/ui/components/ShellModeIndicator.js +5 -0
  331. package/dist/src/ui/components/ShellModeIndicator.js.map +1 -0
  332. package/dist/src/ui/components/ShowMoreLines.d.ts +10 -0
  333. package/dist/src/ui/components/ShowMoreLines.js +24 -0
  334. package/dist/src/ui/components/ShowMoreLines.js.map +1 -0
  335. package/dist/src/ui/components/StatsDisplay.d.ts +12 -0
  336. package/dist/src/ui/components/StatsDisplay.js +43 -0
  337. package/dist/src/ui/components/StatsDisplay.js.map +1 -0
  338. package/dist/src/ui/components/SuggestionsDisplay.d.ts +22 -0
  339. package/dist/src/ui/components/SuggestionsDisplay.js +32 -0
  340. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -0
  341. package/dist/src/ui/components/ThemeDialog.d.ts +19 -0
  342. package/dist/src/ui/components/ThemeDialog.js +143 -0
  343. package/dist/src/ui/components/ThemeDialog.js.map +1 -0
  344. package/dist/src/ui/components/Tips.d.ts +12 -0
  345. package/dist/src/ui/components/Tips.js +8 -0
  346. package/dist/src/ui/components/Tips.js.map +1 -0
  347. package/dist/src/ui/components/TodoDisplay.d.ts +16 -0
  348. package/dist/src/ui/components/TodoDisplay.js +27 -0
  349. package/dist/src/ui/components/TodoDisplay.js.map +1 -0
  350. package/dist/src/ui/components/TodoDisplay.test.d.ts +6 -0
  351. package/dist/src/ui/components/TodoDisplay.test.js +77 -0
  352. package/dist/src/ui/components/TodoDisplay.test.js.map +1 -0
  353. package/dist/src/ui/components/ToolStatsDisplay.d.ts +7 -0
  354. package/dist/src/ui/components/ToolStatsDisplay.js +41 -0
  355. package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -0
  356. package/dist/src/ui/components/UpdateNotification.d.ts +10 -0
  357. package/dist/src/ui/components/UpdateNotification.js +10 -0
  358. package/dist/src/ui/components/UpdateNotification.js.map +1 -0
  359. package/dist/src/ui/components/WelcomeBackDialog.d.ts +13 -0
  360. package/dist/src/ui/components/WelcomeBackDialog.js +31 -0
  361. package/dist/src/ui/components/WelcomeBackDialog.js.map +1 -0
  362. package/dist/src/ui/components/messages/CompressionMessage.d.ts +11 -0
  363. package/dist/src/ui/components/messages/CompressionMessage.js +16 -0
  364. package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -0
  365. package/dist/src/ui/components/messages/DiffRenderer.d.ts +16 -0
  366. package/dist/src/ui/components/messages/DiffRenderer.js +222 -0
  367. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -0
  368. package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +6 -0
  369. package/dist/src/ui/components/messages/DiffRenderer.test.js +239 -0
  370. package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -0
  371. package/dist/src/ui/components/messages/ErrorMessage.d.ts +11 -0
  372. package/dist/src/ui/components/messages/ErrorMessage.js +9 -0
  373. package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -0
  374. package/dist/src/ui/components/messages/GeminiMessage.d.ts +14 -0
  375. package/dist/src/ui/components/messages/GeminiMessage.js +10 -0
  376. package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -0
  377. package/dist/src/ui/components/messages/GeminiMessageContent.d.ts +14 -0
  378. package/dist/src/ui/components/messages/GeminiMessageContent.js +15 -0
  379. package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -0
  380. package/dist/src/ui/components/messages/InfoMessage.d.ts +11 -0
  381. package/dist/src/ui/components/messages/InfoMessage.js +14 -0
  382. package/dist/src/ui/components/messages/InfoMessage.js.map +1 -0
  383. package/dist/src/ui/components/messages/SummaryMessage.d.ts +11 -0
  384. package/dist/src/ui/components/messages/SummaryMessage.js +35 -0
  385. package/dist/src/ui/components/messages/SummaryMessage.js.map +1 -0
  386. package/dist/src/ui/components/messages/ToolConfirmationMessage.d.ts +15 -0
  387. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +145 -0
  388. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -0
  389. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +6 -0
  390. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +37 -0
  391. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -0
  392. package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +18 -0
  393. package/dist/src/ui/components/messages/ToolGroupMessage.js +55 -0
  394. package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -0
  395. package/dist/src/ui/components/messages/ToolMessage.d.ts +15 -0
  396. package/dist/src/ui/components/messages/ToolMessage.js +126 -0
  397. package/dist/src/ui/components/messages/ToolMessage.js.map +1 -0
  398. package/dist/src/ui/components/messages/ToolMessage.test.d.ts +6 -0
  399. package/dist/src/ui/components/messages/ToolMessage.test.js +146 -0
  400. package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -0
  401. package/dist/src/ui/components/messages/UserMessage.d.ts +11 -0
  402. package/dist/src/ui/components/messages/UserMessage.js +12 -0
  403. package/dist/src/ui/components/messages/UserMessage.js.map +1 -0
  404. package/dist/src/ui/components/messages/UserShellMessage.d.ts +11 -0
  405. package/dist/src/ui/components/messages/UserShellMessage.js +9 -0
  406. package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -0
  407. package/dist/src/ui/components/shared/MaxSizedBox.d.ts +61 -0
  408. package/dist/src/ui/components/shared/MaxSizedBox.js +451 -0
  409. package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -0
  410. package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +6 -0
  411. package/dist/src/ui/components/shared/MaxSizedBox.test.js +154 -0
  412. package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -0
  413. package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +46 -0
  414. package/dist/src/ui/components/shared/RadioButtonSelect.js +121 -0
  415. package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
  416. package/dist/src/ui/components/shared/RadioButtonSelect.test.d.ts +6 -0
  417. package/dist/src/ui/components/shared/RadioButtonSelect.test.js +111 -0
  418. package/dist/src/ui/components/shared/RadioButtonSelect.test.js.map +1 -0
  419. package/dist/src/ui/components/shared/TextInput.d.ts +16 -0
  420. package/dist/src/ui/components/shared/TextInput.js +127 -0
  421. package/dist/src/ui/components/shared/TextInput.js.map +1 -0
  422. package/dist/src/ui/components/shared/text-buffer.d.ts +467 -0
  423. package/dist/src/ui/components/shared/text-buffer.js +1533 -0
  424. package/dist/src/ui/components/shared/text-buffer.js.map +1 -0
  425. package/dist/src/ui/components/shared/vim-buffer-actions.d.ts +72 -0
  426. package/dist/src/ui/components/shared/vim-buffer-actions.js +552 -0
  427. package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -0
  428. package/dist/src/ui/components/subagents/constants.d.ts +23 -0
  429. package/dist/src/ui/components/subagents/constants.js +67 -0
  430. package/dist/src/ui/components/subagents/constants.js.map +1 -0
  431. package/dist/src/ui/components/subagents/create/AgentCreationWizard.d.ts +15 -0
  432. package/dist/src/ui/components/subagents/create/AgentCreationWizard.js +171 -0
  433. package/dist/src/ui/components/subagents/create/AgentCreationWizard.js.map +1 -0
  434. package/dist/src/ui/components/subagents/create/ColorSelector.d.ts +15 -0
  435. package/dist/src/ui/components/subagents/create/ColorSelector.js +41 -0
  436. package/dist/src/ui/components/subagents/create/ColorSelector.js.map +1 -0
  437. package/dist/src/ui/components/subagents/create/CreationSummary.d.ts +10 -0
  438. package/dist/src/ui/components/subagents/create/CreationSummary.js +163 -0
  439. package/dist/src/ui/components/subagents/create/CreationSummary.js.map +1 -0
  440. package/dist/src/ui/components/subagents/create/DescriptionInput.d.ts +10 -0
  441. package/dist/src/ui/components/subagents/create/DescriptionInput.js +105 -0
  442. package/dist/src/ui/components/subagents/create/DescriptionInput.js.map +1 -0
  443. package/dist/src/ui/components/subagents/create/GenerationMethodSelector.d.ts +10 -0
  444. package/dist/src/ui/components/subagents/create/GenerationMethodSelector.js +33 -0
  445. package/dist/src/ui/components/subagents/create/GenerationMethodSelector.js.map +1 -0
  446. package/dist/src/ui/components/subagents/create/LocationSelector.d.ts +10 -0
  447. package/dist/src/ui/components/subagents/create/LocationSelector.js +33 -0
  448. package/dist/src/ui/components/subagents/create/LocationSelector.js.map +1 -0
  449. package/dist/src/ui/components/subagents/create/TextEntryStep.d.ts +26 -0
  450. package/dist/src/ui/components/subagents/create/TextEntryStep.js +28 -0
  451. package/dist/src/ui/components/subagents/create/TextEntryStep.js.map +1 -0
  452. package/dist/src/ui/components/subagents/create/ToolSelector.d.ts +16 -0
  453. package/dist/src/ui/components/subagents/create/ToolSelector.js +143 -0
  454. package/dist/src/ui/components/subagents/create/ToolSelector.js.map +1 -0
  455. package/dist/src/ui/components/subagents/index.d.ts +8 -0
  456. package/dist/src/ui/components/subagents/index.js +12 -0
  457. package/dist/src/ui/components/subagents/index.js.map +1 -0
  458. package/dist/src/ui/components/subagents/manage/ActionSelectionStep.d.ts +13 -0
  459. package/dist/src/ui/components/subagents/manage/ActionSelectionStep.js +45 -0
  460. package/dist/src/ui/components/subagents/manage/ActionSelectionStep.js.map +1 -0
  461. package/dist/src/ui/components/subagents/manage/AgentDeleteStep.d.ts +13 -0
  462. package/dist/src/ui/components/subagents/manage/AgentDeleteStep.js +32 -0
  463. package/dist/src/ui/components/subagents/manage/AgentDeleteStep.js.map +1 -0
  464. package/dist/src/ui/components/subagents/manage/AgentEditStep.d.ts +15 -0
  465. package/dist/src/ui/components/subagents/manage/AgentEditStep.js +62 -0
  466. package/dist/src/ui/components/subagents/manage/AgentEditStep.js.map +1 -0
  467. package/dist/src/ui/components/subagents/manage/AgentSelectionStep.d.ts +12 -0
  468. package/dist/src/ui/components/subagents/manage/AgentSelectionStep.js +224 -0
  469. package/dist/src/ui/components/subagents/manage/AgentSelectionStep.js.map +1 -0
  470. package/dist/src/ui/components/subagents/manage/AgentViewerStep.d.ts +11 -0
  471. package/dist/src/ui/components/subagents/manage/AgentViewerStep.js +18 -0
  472. package/dist/src/ui/components/subagents/manage/AgentViewerStep.js.map +1 -0
  473. package/dist/src/ui/components/subagents/manage/AgentsManagerDialog.d.ts +15 -0
  474. package/dist/src/ui/components/subagents/manage/AgentsManagerDialog.js +220 -0
  475. package/dist/src/ui/components/subagents/manage/AgentsManagerDialog.js.map +1 -0
  476. package/dist/src/ui/components/subagents/reducers.d.ts +14 -0
  477. package/dist/src/ui/components/subagents/reducers.js +161 -0
  478. package/dist/src/ui/components/subagents/reducers.js.map +1 -0
  479. package/dist/src/ui/components/subagents/runtime/AgentExecutionDisplay.d.ts +19 -0
  480. package/dist/src/ui/components/subagents/runtime/AgentExecutionDisplay.js +184 -0
  481. package/dist/src/ui/components/subagents/runtime/AgentExecutionDisplay.js.map +1 -0
  482. package/dist/src/ui/components/subagents/types.d.ts +137 -0
  483. package/dist/src/ui/components/subagents/types.js +15 -0
  484. package/dist/src/ui/components/subagents/types.js.map +1 -0
  485. package/dist/src/ui/components/subagents/utils.d.ts +15 -0
  486. package/dist/src/ui/components/subagents/utils.js +79 -0
  487. package/dist/src/ui/components/subagents/utils.js.map +1 -0
  488. package/dist/src/ui/components/ums/UMSKeyPrompt.d.ts +12 -0
  489. package/dist/src/ui/components/ums/UMSKeyPrompt.js +119 -0
  490. package/dist/src/ui/components/ums/UMSKeyPrompt.js.map +1 -0
  491. package/dist/src/ui/components/ums/useUMSAuth.d.ts +20 -0
  492. package/dist/src/ui/components/ums/useUMSAuth.js +78 -0
  493. package/dist/src/ui/components/ums/useUMSAuth.js.map +1 -0
  494. package/dist/src/ui/constants.d.ts +9 -0
  495. package/dist/src/ui/constants.js +13 -0
  496. package/dist/src/ui/constants.js.map +1 -0
  497. package/dist/src/ui/contexts/KeypressContext.d.ts +31 -0
  498. package/dist/src/ui/contexts/KeypressContext.js +388 -0
  499. package/dist/src/ui/contexts/KeypressContext.js.map +1 -0
  500. package/dist/src/ui/contexts/KeypressContext.test.d.ts +6 -0
  501. package/dist/src/ui/contexts/KeypressContext.test.js +754 -0
  502. package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -0
  503. package/dist/src/ui/contexts/OverflowContext.d.ts +19 -0
  504. package/dist/src/ui/contexts/OverflowContext.js +43 -0
  505. package/dist/src/ui/contexts/OverflowContext.js.map +1 -0
  506. package/dist/src/ui/contexts/SessionContext.d.ts +39 -0
  507. package/dist/src/ui/contexts/SessionContext.js +60 -0
  508. package/dist/src/ui/contexts/SessionContext.js.map +1 -0
  509. package/dist/src/ui/contexts/SettingsContext.d.ts +9 -0
  510. package/dist/src/ui/contexts/SettingsContext.js +15 -0
  511. package/dist/src/ui/contexts/SettingsContext.js.map +1 -0
  512. package/dist/src/ui/contexts/StreamingContext.d.ts +9 -0
  513. package/dist/src/ui/contexts/StreamingContext.js +15 -0
  514. package/dist/src/ui/contexts/StreamingContext.js.map +1 -0
  515. package/dist/src/ui/contexts/VimModeContext.d.ts +19 -0
  516. package/dist/src/ui/contexts/VimModeContext.js +48 -0
  517. package/dist/src/ui/contexts/VimModeContext.js.map +1 -0
  518. package/dist/src/ui/editors/editorSettingsManager.d.ts +19 -0
  519. package/dist/src/ui/editors/editorSettingsManager.js +47 -0
  520. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -0
  521. package/dist/src/ui/hooks/atCommandProcessor.d.ts +31 -0
  522. package/dist/src/ui/hooks/atCommandProcessor.js +365 -0
  523. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
  524. package/dist/src/ui/hooks/atCommandProcessor.test.d.ts +6 -0
  525. package/dist/src/ui/hooks/atCommandProcessor.test.js +824 -0
  526. package/dist/src/ui/hooks/atCommandProcessor.test.js.map +1 -0
  527. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +17 -0
  528. package/dist/src/ui/hooks/shellCommandProcessor.js +233 -0
  529. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
  530. package/dist/src/ui/hooks/shellCommandProcessor.test.d.ts +6 -0
  531. package/dist/src/ui/hooks/shellCommandProcessor.test.js +328 -0
  532. package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -0
  533. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +32 -0
  534. package/dist/src/ui/hooks/slashCommandProcessor.js +561 -0
  535. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
  536. package/dist/src/ui/hooks/useAgentsManagerDialog.d.ts +11 -0
  537. package/dist/src/ui/hooks/useAgentsManagerDialog.js +21 -0
  538. package/dist/src/ui/hooks/useAgentsManagerDialog.js.map +1 -0
  539. package/dist/src/ui/hooks/useAtCompletion.d.ts +23 -0
  540. package/dist/src/ui/hooks/useAtCompletion.js +178 -0
  541. package/dist/src/ui/hooks/useAtCompletion.js.map +1 -0
  542. package/dist/src/ui/hooks/useAuthCommand.d.ts +14 -0
  543. package/dist/src/ui/hooks/useAuthCommand.js +65 -0
  544. package/dist/src/ui/hooks/useAuthCommand.js.map +1 -0
  545. package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +10 -0
  546. package/dist/src/ui/hooks/useAutoAcceptIndicator.js +37 -0
  547. package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -0
  548. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.d.ts +6 -0
  549. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +191 -0
  550. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -0
  551. package/dist/src/ui/hooks/useBracketedPaste.d.ts +12 -0
  552. package/dist/src/ui/hooks/useBracketedPaste.js +32 -0
  553. package/dist/src/ui/hooks/useBracketedPaste.js.map +1 -0
  554. package/dist/src/ui/hooks/useCommandCompletion.d.ts +29 -0
  555. package/dist/src/ui/hooks/useCommandCompletion.js +165 -0
  556. package/dist/src/ui/hooks/useCommandCompletion.js.map +1 -0
  557. package/dist/src/ui/hooks/useCompletion.d.ts +24 -0
  558. package/dist/src/ui/hooks/useCompletion.js +88 -0
  559. package/dist/src/ui/hooks/useCompletion.js.map +1 -0
  560. package/dist/src/ui/hooks/useConsoleMessages.d.ts +12 -0
  561. package/dist/src/ui/hooks/useConsoleMessages.js +76 -0
  562. package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -0
  563. package/dist/src/ui/hooks/useDialogClose.d.ts +34 -0
  564. package/dist/src/ui/hooks/useDialogClose.js +62 -0
  565. package/dist/src/ui/hooks/useDialogClose.js.map +1 -0
  566. package/dist/src/ui/hooks/useEditorSettings.d.ts +16 -0
  567. package/dist/src/ui/hooks/useEditorSettings.js +43 -0
  568. package/dist/src/ui/hooks/useEditorSettings.js.map +1 -0
  569. package/dist/src/ui/hooks/useEditorSettings.test.d.ts +6 -0
  570. package/dist/src/ui/hooks/useEditorSettings.test.js +164 -0
  571. package/dist/src/ui/hooks/useEditorSettings.test.js.map +1 -0
  572. package/dist/src/ui/hooks/useFocus.d.ts +10 -0
  573. package/dist/src/ui/hooks/useFocus.js +41 -0
  574. package/dist/src/ui/hooks/useFocus.js.map +1 -0
  575. package/dist/src/ui/hooks/useFolderTrust.d.ts +12 -0
  576. package/dist/src/ui/hooks/useFolderTrust.js +55 -0
  577. package/dist/src/ui/hooks/useFolderTrust.js.map +1 -0
  578. package/dist/src/ui/hooks/useGeminiStream.d.ts +24 -0
  579. package/dist/src/ui/hooks/useGeminiStream.js +692 -0
  580. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -0
  581. package/dist/src/ui/hooks/useGitBranchName.d.ts +6 -0
  582. package/dist/src/ui/hooks/useGitBranchName.js +61 -0
  583. package/dist/src/ui/hooks/useGitBranchName.js.map +1 -0
  584. package/dist/src/ui/hooks/useGitBranchName.test.d.ts +6 -0
  585. package/dist/src/ui/hooks/useGitBranchName.test.js +239 -0
  586. package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -0
  587. package/dist/src/ui/hooks/useHistoryManager.d.ts +22 -0
  588. package/dist/src/ui/hooks/useHistoryManager.js +72 -0
  589. package/dist/src/ui/hooks/useHistoryManager.js.map +1 -0
  590. package/dist/src/ui/hooks/useHistoryManager.test.d.ts +6 -0
  591. package/dist/src/ui/hooks/useHistoryManager.test.js +171 -0
  592. package/dist/src/ui/hooks/useHistoryManager.test.js.map +1 -0
  593. package/dist/src/ui/hooks/useInputHistory.d.ts +19 -0
  594. package/dist/src/ui/hooks/useInputHistory.js +84 -0
  595. package/dist/src/ui/hooks/useInputHistory.js.map +1 -0
  596. package/dist/src/ui/hooks/useInputHistory.test.d.ts +6 -0
  597. package/dist/src/ui/hooks/useInputHistory.test.js +207 -0
  598. package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -0
  599. package/dist/src/ui/hooks/useKeypress.d.ts +17 -0
  600. package/dist/src/ui/hooks/useKeypress.js +27 -0
  601. package/dist/src/ui/hooks/useKeypress.js.map +1 -0
  602. package/dist/src/ui/hooks/useKittyKeyboardProtocol.d.ts +15 -0
  603. package/dist/src/ui/hooks/useKittyKeyboardProtocol.js +20 -0
  604. package/dist/src/ui/hooks/useKittyKeyboardProtocol.js.map +1 -0
  605. package/dist/src/ui/hooks/useLaunchEditor.d.ts +10 -0
  606. package/dist/src/ui/hooks/useLaunchEditor.js +70 -0
  607. package/dist/src/ui/hooks/useLaunchEditor.js.map +1 -0
  608. package/dist/src/ui/hooks/useLoadingIndicator.d.ts +10 -0
  609. package/dist/src/ui/hooks/useLoadingIndicator.js +44 -0
  610. package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -0
  611. package/dist/src/ui/hooks/useLoadingIndicator.test.d.ts +6 -0
  612. package/dist/src/ui/hooks/useLoadingIndicator.test.js +91 -0
  613. package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +1 -0
  614. package/dist/src/ui/hooks/useLogger.d.ts +10 -0
  615. package/dist/src/ui/hooks/useLogger.js +29 -0
  616. package/dist/src/ui/hooks/useLogger.js.map +1 -0
  617. package/dist/src/ui/hooks/useMessageQueue.d.ts +22 -0
  618. package/dist/src/ui/hooks/useMessageQueue.js +49 -0
  619. package/dist/src/ui/hooks/useMessageQueue.js.map +1 -0
  620. package/dist/src/ui/hooks/useMessageQueue.test.d.ts +6 -0
  621. package/dist/src/ui/hooks/useMessageQueue.test.js +158 -0
  622. package/dist/src/ui/hooks/useMessageQueue.test.js.map +1 -0
  623. package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
  624. package/dist/src/ui/hooks/usePhraseCycler.js +187 -0
  625. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -0
  626. package/dist/src/ui/hooks/usePrivacySettings.d.ts +16 -0
  627. package/dist/src/ui/hooks/usePrivacySettings.js +119 -0
  628. package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -0
  629. package/dist/src/ui/hooks/usePrivacySettings.test.d.ts +6 -0
  630. package/dist/src/ui/hooks/usePrivacySettings.test.js +154 -0
  631. package/dist/src/ui/hooks/usePrivacySettings.test.js.map +1 -0
  632. package/dist/src/ui/hooks/useQuitConfirmation.d.ts +14 -0
  633. package/dist/src/ui/hooks/useQuitConfirmation.js +36 -0
  634. package/dist/src/ui/hooks/useQuitConfirmation.js.map +1 -0
  635. package/dist/src/ui/hooks/useQwenAuth.d.ts +20 -0
  636. package/dist/src/ui/hooks/useQwenAuth.js +78 -0
  637. package/dist/src/ui/hooks/useQwenAuth.js.map +1 -0
  638. package/dist/src/ui/hooks/useQwenAuth.test.d.ts +6 -0
  639. package/dist/src/ui/hooks/useQwenAuth.test.js +288 -0
  640. package/dist/src/ui/hooks/useQwenAuth.test.js.map +1 -0
  641. package/dist/src/ui/hooks/useReactToolScheduler.d.ts +33 -0
  642. package/dist/src/ui/hooks/useReactToolScheduler.js +187 -0
  643. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -0
  644. package/dist/src/ui/hooks/useRefreshMemoryCommand.d.ts +6 -0
  645. package/dist/src/ui/hooks/useRefreshMemoryCommand.js +7 -0
  646. package/dist/src/ui/hooks/useRefreshMemoryCommand.js.map +1 -0
  647. package/dist/src/ui/hooks/useReverseSearchCompletion.d.ts +19 -0
  648. package/dist/src/ui/hooks/useReverseSearchCompletion.js +56 -0
  649. package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -0
  650. package/dist/src/ui/hooks/useReverseSearchCompletion.test.d.ts +6 -0
  651. package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +163 -0
  652. package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +1 -0
  653. package/dist/src/ui/hooks/useSettingsCommand.d.ts +10 -0
  654. package/dist/src/ui/hooks/useSettingsCommand.js +21 -0
  655. package/dist/src/ui/hooks/useSettingsCommand.js.map +1 -0
  656. package/dist/src/ui/hooks/useShellHistory.d.ts +13 -0
  657. package/dist/src/ui/hooks/useShellHistory.js +112 -0
  658. package/dist/src/ui/hooks/useShellHistory.js.map +1 -0
  659. package/dist/src/ui/hooks/useShellHistory.test.d.ts +6 -0
  660. package/dist/src/ui/hooks/useShellHistory.test.js +162 -0
  661. package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -0
  662. package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +9 -0
  663. package/dist/src/ui/hooks/useShowMemoryCommand.js +58 -0
  664. package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
  665. package/dist/src/ui/hooks/useSlashCompletion.d.ts +20 -0
  666. package/dist/src/ui/hooks/useSlashCompletion.js +135 -0
  667. package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -0
  668. package/dist/src/ui/hooks/useSlashCompletion.test.d.ts +6 -0
  669. package/dist/src/ui/hooks/useSlashCompletion.test.js +272 -0
  670. package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -0
  671. package/dist/src/ui/hooks/useStateAndRef.d.ts +7 -0
  672. package/dist/src/ui/hooks/useStateAndRef.js +26 -0
  673. package/dist/src/ui/hooks/useStateAndRef.js.map +1 -0
  674. package/dist/src/ui/hooks/useSubagentCreateDialog.d.ts +10 -0
  675. package/dist/src/ui/hooks/useSubagentCreateDialog.js +21 -0
  676. package/dist/src/ui/hooks/useSubagentCreateDialog.js.map +1 -0
  677. package/dist/src/ui/hooks/useTerminalSize.d.ts +9 -0
  678. package/dist/src/ui/hooks/useTerminalSize.js +27 -0
  679. package/dist/src/ui/hooks/useTerminalSize.js.map +1 -0
  680. package/dist/src/ui/hooks/useThemeCommand.d.ts +15 -0
  681. package/dist/src/ui/hooks/useThemeCommand.js +79 -0
  682. package/dist/src/ui/hooks/useThemeCommand.js.map +1 -0
  683. package/dist/src/ui/hooks/useTimer.d.ts +12 -0
  684. package/dist/src/ui/hooks/useTimer.js +58 -0
  685. package/dist/src/ui/hooks/useTimer.js.map +1 -0
  686. package/dist/src/ui/hooks/useTimer.test.d.ts +6 -0
  687. package/dist/src/ui/hooks/useTimer.test.js +90 -0
  688. package/dist/src/ui/hooks/useTimer.test.js.map +1 -0
  689. package/dist/src/ui/hooks/useToolScheduler.test.d.ts +6 -0
  690. package/dist/src/ui/hooks/useToolScheduler.test.js +846 -0
  691. package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -0
  692. package/dist/src/ui/hooks/useWelcomeBack.d.ts +23 -0
  693. package/dist/src/ui/hooks/useWelcomeBack.js +78 -0
  694. package/dist/src/ui/hooks/useWelcomeBack.js.map +1 -0
  695. package/dist/src/ui/hooks/vim.d.ts +28 -0
  696. package/dist/src/ui/hooks/vim.js +639 -0
  697. package/dist/src/ui/hooks/vim.js.map +1 -0
  698. package/dist/src/ui/keyMatchers.d.ts +26 -0
  699. package/dist/src/ui/keyMatchers.js +68 -0
  700. package/dist/src/ui/keyMatchers.js.map +1 -0
  701. package/dist/src/ui/keyMatchers.test.d.ts +6 -0
  702. package/dist/src/ui/keyMatchers.test.js +276 -0
  703. package/dist/src/ui/keyMatchers.test.js.map +1 -0
  704. package/dist/src/ui/privacy/CloudFreePrivacyNotice.d.ts +12 -0
  705. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +41 -0
  706. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -0
  707. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.d.ts +10 -0
  708. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +18 -0
  709. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -0
  710. package/dist/src/ui/privacy/GeminiPrivacyNotice.d.ts +10 -0
  711. package/dist/src/ui/privacy/GeminiPrivacyNotice.js +18 -0
  712. package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -0
  713. package/dist/src/ui/privacy/PrivacyNotice.d.ts +12 -0
  714. package/dist/src/ui/privacy/PrivacyNotice.js +25 -0
  715. package/dist/src/ui/privacy/PrivacyNotice.js.map +1 -0
  716. package/dist/src/ui/semantic-colors.d.ts +7 -0
  717. package/dist/src/ui/semantic-colors.js +24 -0
  718. package/dist/src/ui/semantic-colors.js.map +1 -0
  719. package/dist/src/ui/themes/ansi-light.d.ts +7 -0
  720. package/dist/src/ui/themes/ansi-light.js +142 -0
  721. package/dist/src/ui/themes/ansi-light.js.map +1 -0
  722. package/dist/src/ui/themes/ansi.d.ts +7 -0
  723. package/dist/src/ui/themes/ansi.js +152 -0
  724. package/dist/src/ui/themes/ansi.js.map +1 -0
  725. package/dist/src/ui/themes/atom-one-dark.d.ts +7 -0
  726. package/dist/src/ui/themes/atom-one-dark.js +139 -0
  727. package/dist/src/ui/themes/atom-one-dark.js.map +1 -0
  728. package/dist/src/ui/themes/ayu-light.d.ts +7 -0
  729. package/dist/src/ui/themes/ayu-light.js +131 -0
  730. package/dist/src/ui/themes/ayu-light.js.map +1 -0
  731. package/dist/src/ui/themes/ayu.d.ts +7 -0
  732. package/dist/src/ui/themes/ayu.js +105 -0
  733. package/dist/src/ui/themes/ayu.js.map +1 -0
  734. package/dist/src/ui/themes/color-utils.d.ts +21 -0
  735. package/dist/src/ui/themes/color-utils.js +221 -0
  736. package/dist/src/ui/themes/color-utils.js.map +1 -0
  737. package/dist/src/ui/themes/color-utils.test.d.ts +6 -0
  738. package/dist/src/ui/themes/color-utils.test.js +197 -0
  739. package/dist/src/ui/themes/color-utils.test.js.map +1 -0
  740. package/dist/src/ui/themes/default-light.d.ts +7 -0
  741. package/dist/src/ui/themes/default-light.js +101 -0
  742. package/dist/src/ui/themes/default-light.js.map +1 -0
  743. package/dist/src/ui/themes/default.d.ts +7 -0
  744. package/dist/src/ui/themes/default.js +144 -0
  745. package/dist/src/ui/themes/default.js.map +1 -0
  746. package/dist/src/ui/themes/dracula.d.ts +7 -0
  747. package/dist/src/ui/themes/dracula.js +116 -0
  748. package/dist/src/ui/themes/dracula.js.map +1 -0
  749. package/dist/src/ui/themes/github-dark.d.ts +7 -0
  750. package/dist/src/ui/themes/github-dark.js +139 -0
  751. package/dist/src/ui/themes/github-dark.js.map +1 -0
  752. package/dist/src/ui/themes/github-light.d.ts +7 -0
  753. package/dist/src/ui/themes/github-light.js +141 -0
  754. package/dist/src/ui/themes/github-light.js.map +1 -0
  755. package/dist/src/ui/themes/googlecode.d.ts +7 -0
  756. package/dist/src/ui/themes/googlecode.js +138 -0
  757. package/dist/src/ui/themes/googlecode.js.map +1 -0
  758. package/dist/src/ui/themes/no-color.d.ts +7 -0
  759. package/dist/src/ui/themes/no-color.js +115 -0
  760. package/dist/src/ui/themes/no-color.js.map +1 -0
  761. package/dist/src/ui/themes/qwen-dark.d.ts +7 -0
  762. package/dist/src/ui/themes/qwen-dark.js +105 -0
  763. package/dist/src/ui/themes/qwen-dark.js.map +1 -0
  764. package/dist/src/ui/themes/qwen-light.d.ts +7 -0
  765. package/dist/src/ui/themes/qwen-light.js +131 -0
  766. package/dist/src/ui/themes/qwen-light.js.map +1 -0
  767. package/dist/src/ui/themes/semantic-tokens.d.ts +37 -0
  768. package/dist/src/ui/themes/semantic-tokens.js +94 -0
  769. package/dist/src/ui/themes/semantic-tokens.js.map +1 -0
  770. package/dist/src/ui/themes/shades-of-purple.d.ts +11 -0
  771. package/dist/src/ui/themes/shades-of-purple.js +305 -0
  772. package/dist/src/ui/themes/shades-of-purple.js.map +1 -0
  773. package/dist/src/ui/themes/theme-manager.d.ts +64 -0
  774. package/dist/src/ui/themes/theme-manager.js +203 -0
  775. package/dist/src/ui/themes/theme-manager.js.map +1 -0
  776. package/dist/src/ui/themes/theme-manager.test.d.ts +6 -0
  777. package/dist/src/ui/themes/theme-manager.test.js +83 -0
  778. package/dist/src/ui/themes/theme-manager.test.js.map +1 -0
  779. package/dist/src/ui/themes/theme.d.ts +130 -0
  780. package/dist/src/ui/themes/theme.js +351 -0
  781. package/dist/src/ui/themes/theme.js.map +1 -0
  782. package/dist/src/ui/themes/xcode.d.ts +7 -0
  783. package/dist/src/ui/themes/xcode.js +146 -0
  784. package/dist/src/ui/themes/xcode.js.map +1 -0
  785. package/dist/src/ui/types.d.ts +215 -0
  786. package/dist/src/ui/types.js +46 -0
  787. package/dist/src/ui/types.js.map +1 -0
  788. package/dist/src/ui/utils/CodeColorizer.d.ts +17 -0
  789. package/dist/src/ui/utils/CodeColorizer.js +110 -0
  790. package/dist/src/ui/utils/CodeColorizer.js.map +1 -0
  791. package/dist/src/ui/utils/ConsolePatcher.d.ts +25 -0
  792. package/dist/src/ui/utils/ConsolePatcher.js +52 -0
  793. package/dist/src/ui/utils/ConsolePatcher.js.map +1 -0
  794. package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +16 -0
  795. package/dist/src/ui/utils/InlineMarkdownRenderer.js +111 -0
  796. package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -0
  797. package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
  798. package/dist/src/ui/utils/MarkdownDisplay.js +207 -0
  799. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
  800. package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +6 -0
  801. package/dist/src/ui/utils/MarkdownDisplay.test.js +151 -0
  802. package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -0
  803. package/dist/src/ui/utils/TableRenderer.d.ts +17 -0
  804. package/dist/src/ui/utils/TableRenderer.js +84 -0
  805. package/dist/src/ui/utils/TableRenderer.js.map +1 -0
  806. package/dist/src/ui/utils/clipboardUtils.d.ts +22 -0
  807. package/dist/src/ui/utils/clipboardUtils.js +127 -0
  808. package/dist/src/ui/utils/clipboardUtils.js.map +1 -0
  809. package/dist/src/ui/utils/clipboardUtils.test.d.ts +6 -0
  810. package/dist/src/ui/utils/clipboardUtils.test.js +65 -0
  811. package/dist/src/ui/utils/clipboardUtils.test.js.map +1 -0
  812. package/dist/src/ui/utils/commandUtils.d.ts +24 -0
  813. package/dist/src/ui/utils/commandUtils.js +93 -0
  814. package/dist/src/ui/utils/commandUtils.js.map +1 -0
  815. package/dist/src/ui/utils/commandUtils.test.d.ts +6 -0
  816. package/dist/src/ui/utils/commandUtils.test.js +294 -0
  817. package/dist/src/ui/utils/commandUtils.test.js.map +1 -0
  818. package/dist/src/ui/utils/computeStats.d.ts +10 -0
  819. package/dist/src/ui/utils/computeStats.js +57 -0
  820. package/dist/src/ui/utils/computeStats.js.map +1 -0
  821. package/dist/src/ui/utils/displayUtils.d.ts +17 -0
  822. package/dist/src/ui/utils/displayUtils.js +24 -0
  823. package/dist/src/ui/utils/displayUtils.js.map +1 -0
  824. package/dist/src/ui/utils/displayUtils.test.d.ts +6 -0
  825. package/dist/src/ui/utils/displayUtils.test.js +42 -0
  826. package/dist/src/ui/utils/displayUtils.test.js.map +1 -0
  827. package/dist/src/ui/utils/formatters.d.ts +13 -0
  828. package/dist/src/ui/utils/formatters.js +56 -0
  829. package/dist/src/ui/utils/formatters.js.map +1 -0
  830. package/dist/src/ui/utils/formatters.test.d.ts +6 -0
  831. package/dist/src/ui/utils/formatters.test.js +56 -0
  832. package/dist/src/ui/utils/formatters.test.js.map +1 -0
  833. package/dist/src/ui/utils/isNarrowWidth.d.ts +6 -0
  834. package/dist/src/ui/utils/isNarrowWidth.js +9 -0
  835. package/dist/src/ui/utils/isNarrowWidth.js.map +1 -0
  836. package/dist/src/ui/utils/kittyProtocolDetector.d.ts +13 -0
  837. package/dist/src/ui/utils/kittyProtocolDetector.js +88 -0
  838. package/dist/src/ui/utils/kittyProtocolDetector.js.map +1 -0
  839. package/dist/src/ui/utils/markdownUtilities.d.ts +6 -0
  840. package/dist/src/ui/utils/markdownUtilities.js +110 -0
  841. package/dist/src/ui/utils/markdownUtilities.js.map +1 -0
  842. package/dist/src/ui/utils/markdownUtilities.test.d.ts +6 -0
  843. package/dist/src/ui/utils/markdownUtilities.test.js +42 -0
  844. package/dist/src/ui/utils/markdownUtilities.test.js.map +1 -0
  845. package/dist/src/ui/utils/platformConstants.d.ts +45 -0
  846. package/dist/src/ui/utils/platformConstants.js +46 -0
  847. package/dist/src/ui/utils/platformConstants.js.map +1 -0
  848. package/dist/src/ui/utils/terminalSetup.d.ts +30 -0
  849. package/dist/src/ui/utils/terminalSetup.js +281 -0
  850. package/dist/src/ui/utils/terminalSetup.js.map +1 -0
  851. package/dist/src/ui/utils/textUtils.d.ts +14 -0
  852. package/dist/src/ui/utils/textUtils.js +36 -0
  853. package/dist/src/ui/utils/textUtils.js.map +1 -0
  854. package/dist/src/ui/utils/updateCheck.d.ts +12 -0
  855. package/dist/src/ui/utils/updateCheck.js +78 -0
  856. package/dist/src/ui/utils/updateCheck.js.map +1 -0
  857. package/dist/src/ui/utils/updateCheck.test.d.ts +6 -0
  858. package/dist/src/ui/utils/updateCheck.test.js +145 -0
  859. package/dist/src/ui/utils/updateCheck.test.js.map +1 -0
  860. package/dist/src/utils/checks.d.ts +19 -0
  861. package/dist/src/utils/checks.js +24 -0
  862. package/dist/src/utils/checks.js.map +1 -0
  863. package/dist/src/utils/cleanup.d.ts +8 -0
  864. package/dist/src/utils/cleanup.js +34 -0
  865. package/dist/src/utils/cleanup.js.map +1 -0
  866. package/dist/src/utils/dialogScopeUtils.d.ts +31 -0
  867. package/dist/src/utils/dialogScopeUtils.js +48 -0
  868. package/dist/src/utils/dialogScopeUtils.js.map +1 -0
  869. package/dist/src/utils/events.d.ts +11 -0
  870. package/dist/src/utils/events.js +13 -0
  871. package/dist/src/utils/events.js.map +1 -0
  872. package/dist/src/utils/gitUtils.d.ts +30 -0
  873. package/dist/src/utils/gitUtils.js +89 -0
  874. package/dist/src/utils/gitUtils.js.map +1 -0
  875. package/dist/src/utils/gitUtils.test.d.ts +6 -0
  876. package/dist/src/utils/gitUtils.test.js +113 -0
  877. package/dist/src/utils/gitUtils.test.js.map +1 -0
  878. package/dist/src/utils/handleAutoUpdate.d.ts +11 -0
  879. package/dist/src/utils/handleAutoUpdate.js +101 -0
  880. package/dist/src/utils/handleAutoUpdate.js.map +1 -0
  881. package/dist/src/utils/installationInfo.d.ts +23 -0
  882. package/dist/src/utils/installationInfo.js +153 -0
  883. package/dist/src/utils/installationInfo.js.map +1 -0
  884. package/dist/src/utils/installationInfo.test.d.ts +6 -0
  885. package/dist/src/utils/installationInfo.test.js +242 -0
  886. package/dist/src/utils/installationInfo.test.js.map +1 -0
  887. package/dist/src/utils/package.d.ts +12 -0
  888. package/dist/src/utils/package.js +24 -0
  889. package/dist/src/utils/package.js.map +1 -0
  890. package/dist/src/utils/readStdin.d.ts +6 -0
  891. package/dist/src/utils/readStdin.js +44 -0
  892. package/dist/src/utils/readStdin.js.map +1 -0
  893. package/dist/src/utils/resolvePath.d.ts +6 -0
  894. package/dist/src/utils/resolvePath.js +21 -0
  895. package/dist/src/utils/resolvePath.js.map +1 -0
  896. package/dist/src/utils/sandbox-macos-permissive-closed.sb +32 -0
  897. package/dist/src/utils/sandbox-macos-permissive-open.sb +25 -0
  898. package/dist/src/utils/sandbox-macos-permissive-proxied.sb +37 -0
  899. package/dist/src/utils/sandbox-macos-restrictive-closed.sb +93 -0
  900. package/dist/src/utils/sandbox-macos-restrictive-open.sb +96 -0
  901. package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +98 -0
  902. package/dist/src/utils/sandbox.d.ts +7 -0
  903. package/dist/src/utils/sandbox.js +745 -0
  904. package/dist/src/utils/sandbox.js.map +1 -0
  905. package/dist/src/utils/settingsUtils.d.ts +134 -0
  906. package/dist/src/utils/settingsUtils.js +336 -0
  907. package/dist/src/utils/settingsUtils.js.map +1 -0
  908. package/dist/src/utils/settingsUtils.test.d.ts +6 -0
  909. package/dist/src/utils/settingsUtils.test.js +514 -0
  910. package/dist/src/utils/settingsUtils.test.js.map +1 -0
  911. package/dist/src/utils/spawnWrapper.d.ts +7 -0
  912. package/dist/src/utils/spawnWrapper.js +8 -0
  913. package/dist/src/utils/spawnWrapper.js.map +1 -0
  914. package/dist/src/utils/startupWarnings.d.ts +6 -0
  915. package/dist/src/utils/startupWarnings.js +40 -0
  916. package/dist/src/utils/startupWarnings.js.map +1 -0
  917. package/dist/src/utils/updateEventEmitter.d.ts +11 -0
  918. package/dist/src/utils/updateEventEmitter.js +12 -0
  919. package/dist/src/utils/updateEventEmitter.js.map +1 -0
  920. package/dist/src/utils/userStartupWarnings.d.ts +6 -0
  921. package/dist/src/utils/userStartupWarnings.js +54 -0
  922. package/dist/src/utils/userStartupWarnings.js.map +1 -0
  923. package/dist/src/utils/userStartupWarnings.test.d.ts +6 -0
  924. package/dist/src/utils/userStartupWarnings.test.js +67 -0
  925. package/dist/src/utils/userStartupWarnings.test.js.map +1 -0
  926. package/dist/src/utils/version.d.ts +6 -0
  927. package/dist/src/utils/version.js +11 -0
  928. package/dist/src/utils/version.js.map +1 -0
  929. package/dist/src/validateNonInterActiveAuth.d.ts +7 -0
  930. package/dist/src/validateNonInterActiveAuth.js +40 -0
  931. package/dist/src/validateNonInterActiveAuth.js.map +1 -0
  932. package/dist/src/zed-integration/acp.d.ts +63 -0
  933. package/dist/src/zed-integration/acp.js +225 -0
  934. package/dist/src/zed-integration/acp.js.map +1 -0
  935. package/dist/src/zed-integration/fileSystemService.d.ts +19 -0
  936. package/dist/src/zed-integration/fileSystemService.js +43 -0
  937. package/dist/src/zed-integration/fileSystemService.js.map +1 -0
  938. package/dist/src/zed-integration/schema.d.ts +11782 -0
  939. package/dist/src/zed-integration/schema.js +311 -0
  940. package/dist/src/zed-integration/schema.js.map +1 -0
  941. package/dist/src/zed-integration/zedIntegration.d.ts +10 -0
  942. package/dist/src/zed-integration/zedIntegration.js +765 -0
  943. package/dist/src/zed-integration/zedIntegration.js.map +1 -0
  944. package/dist/tsconfig.tsbuildinfo +1 -0
  945. package/package.json +88 -0
@@ -0,0 +1,1533 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import stripAnsi from 'strip-ansi';
7
+ import { stripVTControlCharacters } from 'util';
8
+ import { spawnSync } from 'child_process';
9
+ import fs from 'fs';
10
+ import os from 'os';
11
+ import pathMod from 'path';
12
+ import { useState, useCallback, useEffect, useMemo, useReducer } from 'react';
13
+ import stringWidth from 'string-width';
14
+ import { unescapePath } from '@umsai/ums-code-core';
15
+ import { toCodePoints, cpLen, cpSlice } from '../../utils/textUtils.js';
16
+ import { handleVimAction } from './vim-buffer-actions.js';
17
+ // Simple helper for word‑wise ops.
18
+ function isWordChar(ch) {
19
+ if (ch === undefined) {
20
+ return false;
21
+ }
22
+ return !/[\s,.;!?]/.test(ch);
23
+ }
24
+ // Helper functions for line-based word navigation
25
+ export const isWordCharStrict = (char) => /[\w\p{L}\p{N}]/u.test(char); // Matches a single character that is any Unicode letter, any Unicode number, or an underscore
26
+ export const isWhitespace = (char) => /\s/.test(char);
27
+ // Check if a character is a combining mark (only diacritics for now)
28
+ export const isCombiningMark = (char) => /\p{M}/u.test(char);
29
+ // Check if a character should be considered part of a word (including combining marks)
30
+ export const isWordCharWithCombining = (char) => isWordCharStrict(char) || isCombiningMark(char);
31
+ // Get the script of a character (simplified for common scripts)
32
+ export const getCharScript = (char) => {
33
+ if (/[\p{Script=Latin}]/u.test(char))
34
+ return 'latin'; // All Latin script chars including diacritics
35
+ if (/[\p{Script=Han}]/u.test(char))
36
+ return 'han'; // Chinese
37
+ if (/[\p{Script=Arabic}]/u.test(char))
38
+ return 'arabic';
39
+ if (/[\p{Script=Hiragana}]/u.test(char))
40
+ return 'hiragana';
41
+ if (/[\p{Script=Katakana}]/u.test(char))
42
+ return 'katakana';
43
+ if (/[\p{Script=Cyrillic}]/u.test(char))
44
+ return 'cyrillic';
45
+ return 'other';
46
+ };
47
+ // Check if two characters are from different scripts (indicating word boundary)
48
+ export const isDifferentScript = (char1, char2) => {
49
+ if (!isWordCharStrict(char1) || !isWordCharStrict(char2))
50
+ return false;
51
+ return getCharScript(char1) !== getCharScript(char2);
52
+ };
53
+ // Find next word start within a line, starting from col
54
+ export const findNextWordStartInLine = (line, col) => {
55
+ const chars = toCodePoints(line);
56
+ let i = col;
57
+ if (i >= chars.length)
58
+ return null;
59
+ const currentChar = chars[i];
60
+ // Skip current word/sequence based on character type
61
+ if (isWordCharStrict(currentChar)) {
62
+ while (i < chars.length && isWordCharWithCombining(chars[i])) {
63
+ // Check for script boundary - if next character is from different script, stop here
64
+ if (i + 1 < chars.length &&
65
+ isWordCharStrict(chars[i + 1]) &&
66
+ isDifferentScript(chars[i], chars[i + 1])) {
67
+ i++; // Include current character
68
+ break; // Stop at script boundary
69
+ }
70
+ i++;
71
+ }
72
+ }
73
+ else if (!isWhitespace(currentChar)) {
74
+ while (i < chars.length &&
75
+ !isWordCharStrict(chars[i]) &&
76
+ !isWhitespace(chars[i])) {
77
+ i++;
78
+ }
79
+ }
80
+ // Skip whitespace
81
+ while (i < chars.length && isWhitespace(chars[i])) {
82
+ i++;
83
+ }
84
+ return i < chars.length ? i : null;
85
+ };
86
+ // Find previous word start within a line
87
+ export const findPrevWordStartInLine = (line, col) => {
88
+ const chars = toCodePoints(line);
89
+ let i = col;
90
+ if (i <= 0)
91
+ return null;
92
+ i--;
93
+ // Skip whitespace moving backwards
94
+ while (i >= 0 && isWhitespace(chars[i])) {
95
+ i--;
96
+ }
97
+ if (i < 0)
98
+ return null;
99
+ if (isWordCharStrict(chars[i])) {
100
+ // We're in a word, move to its beginning
101
+ while (i >= 0 && isWordCharStrict(chars[i])) {
102
+ // Check for script boundary - if previous character is from different script, stop here
103
+ if (i - 1 >= 0 &&
104
+ isWordCharStrict(chars[i - 1]) &&
105
+ isDifferentScript(chars[i], chars[i - 1])) {
106
+ return i; // Return current position at script boundary
107
+ }
108
+ i--;
109
+ }
110
+ return i + 1;
111
+ }
112
+ else {
113
+ // We're in punctuation, move to its beginning
114
+ while (i >= 0 && !isWordCharStrict(chars[i]) && !isWhitespace(chars[i])) {
115
+ i--;
116
+ }
117
+ return i + 1;
118
+ }
119
+ };
120
+ // Find word end within a line
121
+ export const findWordEndInLine = (line, col) => {
122
+ const chars = toCodePoints(line);
123
+ let i = col;
124
+ // If we're already at the end of a word (including punctuation sequences), advance to next word
125
+ // This includes both regular word endings and script boundaries
126
+ const atEndOfWordChar = i < chars.length &&
127
+ isWordCharWithCombining(chars[i]) &&
128
+ (i + 1 >= chars.length ||
129
+ !isWordCharWithCombining(chars[i + 1]) ||
130
+ (isWordCharStrict(chars[i]) &&
131
+ i + 1 < chars.length &&
132
+ isWordCharStrict(chars[i + 1]) &&
133
+ isDifferentScript(chars[i], chars[i + 1])));
134
+ const atEndOfPunctuation = i < chars.length &&
135
+ !isWordCharWithCombining(chars[i]) &&
136
+ !isWhitespace(chars[i]) &&
137
+ (i + 1 >= chars.length ||
138
+ isWhitespace(chars[i + 1]) ||
139
+ isWordCharWithCombining(chars[i + 1]));
140
+ if (atEndOfWordChar || atEndOfPunctuation) {
141
+ // We're at the end of a word or punctuation sequence, move forward to find next word
142
+ i++;
143
+ // Skip whitespace to find next word or punctuation
144
+ while (i < chars.length && isWhitespace(chars[i])) {
145
+ i++;
146
+ }
147
+ }
148
+ // If we're not on a word character, find the next word or punctuation sequence
149
+ if (i < chars.length && !isWordCharWithCombining(chars[i])) {
150
+ // Skip whitespace to find next word or punctuation
151
+ while (i < chars.length && isWhitespace(chars[i])) {
152
+ i++;
153
+ }
154
+ }
155
+ // Move to end of current word (including combining marks, but stop at script boundaries)
156
+ let foundWord = false;
157
+ let lastBaseCharPos = -1;
158
+ if (i < chars.length && isWordCharWithCombining(chars[i])) {
159
+ // Handle word characters
160
+ while (i < chars.length && isWordCharWithCombining(chars[i])) {
161
+ foundWord = true;
162
+ // Track the position of the last base character (not combining mark)
163
+ if (isWordCharStrict(chars[i])) {
164
+ lastBaseCharPos = i;
165
+ }
166
+ // Check if next character is from a different script (word boundary)
167
+ if (i + 1 < chars.length &&
168
+ isWordCharStrict(chars[i + 1]) &&
169
+ isDifferentScript(chars[i], chars[i + 1])) {
170
+ i++; // Include current character
171
+ if (isWordCharStrict(chars[i - 1])) {
172
+ lastBaseCharPos = i - 1;
173
+ }
174
+ break; // Stop at script boundary
175
+ }
176
+ i++;
177
+ }
178
+ }
179
+ else if (i < chars.length && !isWhitespace(chars[i])) {
180
+ // Handle punctuation sequences (like ████)
181
+ while (i < chars.length &&
182
+ !isWordCharStrict(chars[i]) &&
183
+ !isWhitespace(chars[i])) {
184
+ foundWord = true;
185
+ lastBaseCharPos = i;
186
+ i++;
187
+ }
188
+ }
189
+ // Only return a position if we actually found a word
190
+ // Return the position of the last base character, not combining marks
191
+ if (foundWord && lastBaseCharPos >= col) {
192
+ return lastBaseCharPos;
193
+ }
194
+ return null;
195
+ };
196
+ // Find next word across lines
197
+ export const findNextWordAcrossLines = (lines, cursorRow, cursorCol, searchForWordStart) => {
198
+ // First try current line
199
+ const currentLine = lines[cursorRow] || '';
200
+ const colInCurrentLine = searchForWordStart
201
+ ? findNextWordStartInLine(currentLine, cursorCol)
202
+ : findWordEndInLine(currentLine, cursorCol);
203
+ if (colInCurrentLine !== null) {
204
+ return { row: cursorRow, col: colInCurrentLine };
205
+ }
206
+ // Search subsequent lines
207
+ for (let row = cursorRow + 1; row < lines.length; row++) {
208
+ const line = lines[row] || '';
209
+ const chars = toCodePoints(line);
210
+ // For empty lines, if we haven't found any words yet, return the empty line
211
+ if (chars.length === 0) {
212
+ // Check if there are any words in remaining lines
213
+ let hasWordsInLaterLines = false;
214
+ for (let laterRow = row + 1; laterRow < lines.length; laterRow++) {
215
+ const laterLine = lines[laterRow] || '';
216
+ const laterChars = toCodePoints(laterLine);
217
+ let firstNonWhitespace = 0;
218
+ while (firstNonWhitespace < laterChars.length &&
219
+ isWhitespace(laterChars[firstNonWhitespace])) {
220
+ firstNonWhitespace++;
221
+ }
222
+ if (firstNonWhitespace < laterChars.length) {
223
+ hasWordsInLaterLines = true;
224
+ break;
225
+ }
226
+ }
227
+ // If no words in later lines, return the empty line
228
+ if (!hasWordsInLaterLines) {
229
+ return { row, col: 0 };
230
+ }
231
+ continue;
232
+ }
233
+ // Find first non-whitespace
234
+ let firstNonWhitespace = 0;
235
+ while (firstNonWhitespace < chars.length &&
236
+ isWhitespace(chars[firstNonWhitespace])) {
237
+ firstNonWhitespace++;
238
+ }
239
+ if (firstNonWhitespace < chars.length) {
240
+ if (searchForWordStart) {
241
+ return { row, col: firstNonWhitespace };
242
+ }
243
+ else {
244
+ // For word end, find the end of the first word
245
+ const endCol = findWordEndInLine(line, firstNonWhitespace);
246
+ if (endCol !== null) {
247
+ return { row, col: endCol };
248
+ }
249
+ }
250
+ }
251
+ }
252
+ return null;
253
+ };
254
+ // Find previous word across lines
255
+ export const findPrevWordAcrossLines = (lines, cursorRow, cursorCol) => {
256
+ // First try current line
257
+ const currentLine = lines[cursorRow] || '';
258
+ const colInCurrentLine = findPrevWordStartInLine(currentLine, cursorCol);
259
+ if (colInCurrentLine !== null) {
260
+ return { row: cursorRow, col: colInCurrentLine };
261
+ }
262
+ // Search previous lines
263
+ for (let row = cursorRow - 1; row >= 0; row--) {
264
+ const line = lines[row] || '';
265
+ const chars = toCodePoints(line);
266
+ if (chars.length === 0)
267
+ continue;
268
+ // Find last word start
269
+ let lastWordStart = chars.length;
270
+ while (lastWordStart > 0 && isWhitespace(chars[lastWordStart - 1])) {
271
+ lastWordStart--;
272
+ }
273
+ if (lastWordStart > 0) {
274
+ // Find start of this word
275
+ const wordStart = findPrevWordStartInLine(line, lastWordStart);
276
+ if (wordStart !== null) {
277
+ return { row, col: wordStart };
278
+ }
279
+ }
280
+ }
281
+ return null;
282
+ };
283
+ // Helper functions for vim line operations
284
+ export const getPositionFromOffsets = (startOffset, endOffset, lines) => {
285
+ let offset = 0;
286
+ let startRow = 0;
287
+ let startCol = 0;
288
+ let endRow = 0;
289
+ let endCol = 0;
290
+ // Find start position
291
+ for (let i = 0; i < lines.length; i++) {
292
+ const lineLength = lines[i].length + 1; // +1 for newline
293
+ if (offset + lineLength > startOffset) {
294
+ startRow = i;
295
+ startCol = startOffset - offset;
296
+ break;
297
+ }
298
+ offset += lineLength;
299
+ }
300
+ // Find end position
301
+ offset = 0;
302
+ for (let i = 0; i < lines.length; i++) {
303
+ const lineLength = lines[i].length + (i < lines.length - 1 ? 1 : 0); // +1 for newline except last line
304
+ if (offset + lineLength >= endOffset) {
305
+ endRow = i;
306
+ endCol = endOffset - offset;
307
+ break;
308
+ }
309
+ offset += lineLength;
310
+ }
311
+ return { startRow, startCol, endRow, endCol };
312
+ };
313
+ export const getLineRangeOffsets = (startRow, lineCount, lines) => {
314
+ let startOffset = 0;
315
+ // Calculate start offset
316
+ for (let i = 0; i < startRow; i++) {
317
+ startOffset += lines[i].length + 1; // +1 for newline
318
+ }
319
+ // Calculate end offset
320
+ let endOffset = startOffset;
321
+ for (let i = 0; i < lineCount; i++) {
322
+ const lineIndex = startRow + i;
323
+ if (lineIndex < lines.length) {
324
+ endOffset += lines[lineIndex].length;
325
+ if (lineIndex < lines.length - 1) {
326
+ endOffset += 1; // +1 for newline
327
+ }
328
+ }
329
+ }
330
+ return { startOffset, endOffset };
331
+ };
332
+ export const replaceRangeInternal = (state, startRow, startCol, endRow, endCol, text) => {
333
+ const currentLine = (row) => state.lines[row] || '';
334
+ const currentLineLen = (row) => cpLen(currentLine(row));
335
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
336
+ if (startRow > endRow ||
337
+ (startRow === endRow && startCol > endCol) ||
338
+ startRow < 0 ||
339
+ startCol < 0 ||
340
+ endRow >= state.lines.length ||
341
+ (endRow < state.lines.length && endCol > currentLineLen(endRow))) {
342
+ return state; // Invalid range
343
+ }
344
+ const newLines = [...state.lines];
345
+ const sCol = clamp(startCol, 0, currentLineLen(startRow));
346
+ const eCol = clamp(endCol, 0, currentLineLen(endRow));
347
+ const prefix = cpSlice(currentLine(startRow), 0, sCol);
348
+ const suffix = cpSlice(currentLine(endRow), eCol);
349
+ const normalisedReplacement = text
350
+ .replace(/\r\n/g, '\n')
351
+ .replace(/\r/g, '\n');
352
+ const replacementParts = normalisedReplacement.split('\n');
353
+ // The combined first line of the new text
354
+ const firstLine = prefix + replacementParts[0];
355
+ if (replacementParts.length === 1) {
356
+ // No newlines in replacement: combine prefix, replacement, and suffix on one line.
357
+ newLines.splice(startRow, endRow - startRow + 1, firstLine + suffix);
358
+ }
359
+ else {
360
+ // Newlines in replacement: create new lines.
361
+ const lastLine = replacementParts[replacementParts.length - 1] + suffix;
362
+ const middleLines = replacementParts.slice(1, -1);
363
+ newLines.splice(startRow, endRow - startRow + 1, firstLine, ...middleLines, lastLine);
364
+ }
365
+ const finalCursorRow = startRow + replacementParts.length - 1;
366
+ const finalCursorCol = (replacementParts.length > 1 ? 0 : sCol) +
367
+ cpLen(replacementParts[replacementParts.length - 1]);
368
+ return {
369
+ ...state,
370
+ lines: newLines,
371
+ cursorRow: Math.min(Math.max(finalCursorRow, 0), newLines.length - 1),
372
+ cursorCol: Math.max(0, Math.min(finalCursorCol, cpLen(newLines[finalCursorRow] || ''))),
373
+ preferredCol: null,
374
+ };
375
+ };
376
+ /**
377
+ * Strip characters that can break terminal rendering.
378
+ *
379
+ * Uses Node.js built-in stripVTControlCharacters to handle VT sequences,
380
+ * then filters remaining control characters that can disrupt display.
381
+ *
382
+ * Characters stripped:
383
+ * - ANSI escape sequences (via strip-ansi)
384
+ * - VT control sequences (via Node.js util.stripVTControlCharacters)
385
+ * - C0 control chars (0x00-0x1F) except CR/LF which are handled elsewhere
386
+ * - C1 control chars (0x80-0x9F) that can cause display issues
387
+ *
388
+ * Characters preserved:
389
+ * - All printable Unicode including emojis
390
+ * - DEL (0x7F) - handled functionally by applyOperations, not a display issue
391
+ * - CR/LF (0x0D/0x0A) - needed for line breaks
392
+ */
393
+ function stripUnsafeCharacters(str) {
394
+ const strippedAnsi = stripAnsi(str);
395
+ const strippedVT = stripVTControlCharacters(strippedAnsi);
396
+ return toCodePoints(strippedVT)
397
+ .filter((char) => {
398
+ const code = char.codePointAt(0);
399
+ if (code === undefined)
400
+ return false;
401
+ // Preserve CR/LF for line handling
402
+ if (code === 0x0a || code === 0x0d)
403
+ return true;
404
+ // Remove C0 control chars (except CR/LF) that can break display
405
+ // Examples: BELL(0x07) makes noise, BS(0x08) moves cursor, VT(0x0B), FF(0x0C)
406
+ if (code >= 0x00 && code <= 0x1f)
407
+ return false;
408
+ // Remove C1 control chars (0x80-0x9F) - legacy 8-bit control codes
409
+ if (code >= 0x80 && code <= 0x9f)
410
+ return false;
411
+ // Preserve DEL (0x7F) - it's handled functionally by applyOperations as backspace
412
+ // and doesn't cause rendering issues when displayed
413
+ // Preserve all other characters including Unicode/emojis
414
+ return true;
415
+ })
416
+ .join('');
417
+ }
418
+ function clamp(v, min, max) {
419
+ return v < min ? min : v > max ? max : v;
420
+ }
421
+ function calculateInitialCursorPosition(initialLines, offset) {
422
+ let remainingChars = offset;
423
+ let row = 0;
424
+ while (row < initialLines.length) {
425
+ const lineLength = cpLen(initialLines[row]);
426
+ // Add 1 for the newline character (except for the last line)
427
+ const totalCharsInLineAndNewline = lineLength + (row < initialLines.length - 1 ? 1 : 0);
428
+ if (remainingChars <= lineLength) {
429
+ // Cursor is on this line
430
+ return [row, remainingChars];
431
+ }
432
+ remainingChars -= totalCharsInLineAndNewline;
433
+ row++;
434
+ }
435
+ // Offset is beyond the text, place cursor at the end of the last line
436
+ if (initialLines.length > 0) {
437
+ const lastRow = initialLines.length - 1;
438
+ return [lastRow, cpLen(initialLines[lastRow])];
439
+ }
440
+ return [0, 0]; // Default for empty text
441
+ }
442
+ export function offsetToLogicalPos(text, offset) {
443
+ let row = 0;
444
+ let col = 0;
445
+ let currentOffset = 0;
446
+ if (offset === 0)
447
+ return [0, 0];
448
+ const lines = text.split('\n');
449
+ for (let i = 0; i < lines.length; i++) {
450
+ const line = lines[i];
451
+ const lineLength = cpLen(line);
452
+ const lineLengthWithNewline = lineLength + (i < lines.length - 1 ? 1 : 0);
453
+ if (offset <= currentOffset + lineLength) {
454
+ // Check against lineLength first
455
+ row = i;
456
+ col = offset - currentOffset;
457
+ return [row, col];
458
+ }
459
+ else if (offset <= currentOffset + lineLengthWithNewline) {
460
+ // Check if offset is the newline itself
461
+ row = i;
462
+ col = lineLength; // Position cursor at the end of the current line content
463
+ // If the offset IS the newline, and it's not the last line, advance to next line, col 0
464
+ if (offset === currentOffset + lineLengthWithNewline &&
465
+ i < lines.length - 1) {
466
+ return [i + 1, 0];
467
+ }
468
+ return [row, col]; // Otherwise, it's at the end of the current line content
469
+ }
470
+ currentOffset += lineLengthWithNewline;
471
+ }
472
+ // If offset is beyond the text length, place cursor at the end of the last line
473
+ // or [0,0] if text is empty
474
+ if (lines.length > 0) {
475
+ row = lines.length - 1;
476
+ col = cpLen(lines[row]);
477
+ }
478
+ else {
479
+ row = 0;
480
+ col = 0;
481
+ }
482
+ return [row, col];
483
+ }
484
+ /**
485
+ * Converts logical row/col position to absolute text offset
486
+ * Inverse operation of offsetToLogicalPos
487
+ */
488
+ export function logicalPosToOffset(lines, row, col) {
489
+ let offset = 0;
490
+ // Clamp row to valid range
491
+ const actualRow = Math.min(row, lines.length - 1);
492
+ // Add lengths of all lines before the target row
493
+ for (let i = 0; i < actualRow; i++) {
494
+ offset += cpLen(lines[i]) + 1; // +1 for newline
495
+ }
496
+ // Add column offset within the target row
497
+ if (actualRow >= 0 && actualRow < lines.length) {
498
+ offset += Math.min(col, cpLen(lines[actualRow]));
499
+ }
500
+ return offset;
501
+ }
502
+ // Helper to calculate visual lines and map cursor positions
503
+ function calculateVisualLayout(logicalLines, logicalCursor, viewportWidth) {
504
+ const visualLines = [];
505
+ const logicalToVisualMap = [];
506
+ const visualToLogicalMap = [];
507
+ let currentVisualCursor = [0, 0];
508
+ logicalLines.forEach((logLine, logIndex) => {
509
+ logicalToVisualMap[logIndex] = [];
510
+ if (logLine.length === 0) {
511
+ // Handle empty logical line
512
+ logicalToVisualMap[logIndex].push([visualLines.length, 0]);
513
+ visualToLogicalMap.push([logIndex, 0]);
514
+ visualLines.push('');
515
+ if (logIndex === logicalCursor[0] && logicalCursor[1] === 0) {
516
+ currentVisualCursor = [visualLines.length - 1, 0];
517
+ }
518
+ }
519
+ else {
520
+ // Non-empty logical line
521
+ let currentPosInLogLine = 0; // Tracks position within the current logical line (code point index)
522
+ const codePointsInLogLine = toCodePoints(logLine);
523
+ while (currentPosInLogLine < codePointsInLogLine.length) {
524
+ let currentChunk = '';
525
+ let currentChunkVisualWidth = 0;
526
+ let numCodePointsInChunk = 0;
527
+ let lastWordBreakPoint = -1; // Index in codePointsInLogLine for word break
528
+ let numCodePointsAtLastWordBreak = 0;
529
+ // Iterate through code points to build the current visual line (chunk)
530
+ for (let i = currentPosInLogLine; i < codePointsInLogLine.length; i++) {
531
+ const char = codePointsInLogLine[i];
532
+ const charVisualWidth = stringWidth(char);
533
+ if (currentChunkVisualWidth + charVisualWidth > viewportWidth) {
534
+ // Character would exceed viewport width
535
+ if (lastWordBreakPoint !== -1 &&
536
+ numCodePointsAtLastWordBreak > 0 &&
537
+ currentPosInLogLine + numCodePointsAtLastWordBreak < i) {
538
+ // We have a valid word break point to use, and it's not the start of the current segment
539
+ currentChunk = codePointsInLogLine
540
+ .slice(currentPosInLogLine, currentPosInLogLine + numCodePointsAtLastWordBreak)
541
+ .join('');
542
+ numCodePointsInChunk = numCodePointsAtLastWordBreak;
543
+ }
544
+ else {
545
+ // No word break, or word break is at the start of this potential chunk, or word break leads to empty chunk.
546
+ // Hard break: take characters up to viewportWidth, or just the current char if it alone is too wide.
547
+ if (numCodePointsInChunk === 0 &&
548
+ charVisualWidth > viewportWidth) {
549
+ // Single character is wider than viewport, take it anyway
550
+ currentChunk = char;
551
+ numCodePointsInChunk = 1;
552
+ }
553
+ else if (numCodePointsInChunk === 0 &&
554
+ charVisualWidth <= viewportWidth) {
555
+ // This case should ideally be caught by the next iteration if the char fits.
556
+ // If it doesn't fit (because currentChunkVisualWidth was already > 0 from a previous char that filled the line),
557
+ // then numCodePointsInChunk would not be 0.
558
+ // This branch means the current char *itself* doesn't fit an empty line, which is handled by the above.
559
+ // If we are here, it means the loop should break and the current chunk (which is empty) is finalized.
560
+ }
561
+ }
562
+ break; // Break from inner loop to finalize this chunk
563
+ }
564
+ currentChunk += char;
565
+ currentChunkVisualWidth += charVisualWidth;
566
+ numCodePointsInChunk++;
567
+ // Check for word break opportunity (space)
568
+ if (char === ' ') {
569
+ lastWordBreakPoint = i; // Store code point index of the space
570
+ // Store the state *before* adding the space, if we decide to break here.
571
+ numCodePointsAtLastWordBreak = numCodePointsInChunk - 1; // Chars *before* the space
572
+ }
573
+ }
574
+ // If the inner loop completed without breaking (i.e., remaining text fits)
575
+ // or if the loop broke but numCodePointsInChunk is still 0 (e.g. first char too wide for empty line)
576
+ if (numCodePointsInChunk === 0 &&
577
+ currentPosInLogLine < codePointsInLogLine.length) {
578
+ // This can happen if the very first character considered for a new visual line is wider than the viewport.
579
+ // In this case, we take that single character.
580
+ const firstChar = codePointsInLogLine[currentPosInLogLine];
581
+ currentChunk = firstChar;
582
+ numCodePointsInChunk = 1; // Ensure we advance
583
+ }
584
+ // If after everything, numCodePointsInChunk is still 0 but we haven't processed the whole logical line,
585
+ // it implies an issue, like viewportWidth being 0 or less. Avoid infinite loop.
586
+ if (numCodePointsInChunk === 0 &&
587
+ currentPosInLogLine < codePointsInLogLine.length) {
588
+ // Force advance by one character to prevent infinite loop if something went wrong
589
+ currentChunk = codePointsInLogLine[currentPosInLogLine];
590
+ numCodePointsInChunk = 1;
591
+ }
592
+ logicalToVisualMap[logIndex].push([
593
+ visualLines.length,
594
+ currentPosInLogLine,
595
+ ]);
596
+ visualToLogicalMap.push([logIndex, currentPosInLogLine]);
597
+ visualLines.push(currentChunk);
598
+ // Cursor mapping logic
599
+ // Note: currentPosInLogLine here is the start of the currentChunk within the logical line.
600
+ if (logIndex === logicalCursor[0]) {
601
+ const cursorLogCol = logicalCursor[1]; // This is a code point index
602
+ if (cursorLogCol >= currentPosInLogLine &&
603
+ cursorLogCol < currentPosInLogLine + numCodePointsInChunk // Cursor is within this chunk
604
+ ) {
605
+ currentVisualCursor = [
606
+ visualLines.length - 1,
607
+ cursorLogCol - currentPosInLogLine, // Visual col is also code point index within visual line
608
+ ];
609
+ }
610
+ else if (cursorLogCol === currentPosInLogLine + numCodePointsInChunk &&
611
+ numCodePointsInChunk > 0) {
612
+ // Cursor is exactly at the end of this non-empty chunk
613
+ currentVisualCursor = [
614
+ visualLines.length - 1,
615
+ numCodePointsInChunk,
616
+ ];
617
+ }
618
+ }
619
+ const logicalStartOfThisChunk = currentPosInLogLine;
620
+ currentPosInLogLine += numCodePointsInChunk;
621
+ // If the chunk processed did not consume the entire logical line,
622
+ // and the character immediately following the chunk is a space,
623
+ // advance past this space as it acted as a delimiter for word wrapping.
624
+ if (logicalStartOfThisChunk + numCodePointsInChunk <
625
+ codePointsInLogLine.length &&
626
+ currentPosInLogLine < codePointsInLogLine.length && // Redundant if previous is true, but safe
627
+ codePointsInLogLine[currentPosInLogLine] === ' ') {
628
+ currentPosInLogLine++;
629
+ }
630
+ }
631
+ // After all chunks of a non-empty logical line are processed,
632
+ // if the cursor is at the very end of this logical line, update visual cursor.
633
+ if (logIndex === logicalCursor[0] &&
634
+ logicalCursor[1] === codePointsInLogLine.length // Cursor at end of logical line
635
+ ) {
636
+ const lastVisualLineIdx = visualLines.length - 1;
637
+ if (lastVisualLineIdx >= 0 &&
638
+ visualLines[lastVisualLineIdx] !== undefined) {
639
+ currentVisualCursor = [
640
+ lastVisualLineIdx,
641
+ cpLen(visualLines[lastVisualLineIdx]), // Cursor at end of last visual line for this logical line
642
+ ];
643
+ }
644
+ }
645
+ }
646
+ });
647
+ // If the entire logical text was empty, ensure there's one empty visual line.
648
+ if (logicalLines.length === 0 ||
649
+ (logicalLines.length === 1 && logicalLines[0] === '')) {
650
+ if (visualLines.length === 0) {
651
+ visualLines.push('');
652
+ if (!logicalToVisualMap[0])
653
+ logicalToVisualMap[0] = [];
654
+ logicalToVisualMap[0].push([0, 0]);
655
+ visualToLogicalMap.push([0, 0]);
656
+ }
657
+ currentVisualCursor = [0, 0];
658
+ }
659
+ // Handle cursor at the very end of the text (after all processing)
660
+ // This case might be covered by the loop end condition now, but kept for safety.
661
+ else if (logicalCursor[0] === logicalLines.length - 1 &&
662
+ logicalCursor[1] === cpLen(logicalLines[logicalLines.length - 1]) &&
663
+ visualLines.length > 0) {
664
+ const lastVisLineIdx = visualLines.length - 1;
665
+ currentVisualCursor = [lastVisLineIdx, cpLen(visualLines[lastVisLineIdx])];
666
+ }
667
+ return {
668
+ visualLines,
669
+ visualCursor: currentVisualCursor,
670
+ logicalToVisualMap,
671
+ visualToLogicalMap,
672
+ };
673
+ }
674
+ const historyLimit = 100;
675
+ export const pushUndo = (currentState) => {
676
+ const snapshot = {
677
+ lines: [...currentState.lines],
678
+ cursorRow: currentState.cursorRow,
679
+ cursorCol: currentState.cursorCol,
680
+ };
681
+ const newStack = [...currentState.undoStack, snapshot];
682
+ if (newStack.length > historyLimit) {
683
+ newStack.shift();
684
+ }
685
+ return { ...currentState, undoStack: newStack, redoStack: [] };
686
+ };
687
+ export function textBufferReducer(state, action) {
688
+ const pushUndoLocal = pushUndo;
689
+ const currentLine = (r) => state.lines[r] ?? '';
690
+ const currentLineLen = (r) => cpLen(currentLine(r));
691
+ switch (action.type) {
692
+ case 'set_text': {
693
+ let nextState = state;
694
+ if (action.pushToUndo !== false) {
695
+ nextState = pushUndoLocal(state);
696
+ }
697
+ const newContentLines = action.payload
698
+ .replace(/\r\n?/g, '\n')
699
+ .split('\n');
700
+ const lines = newContentLines.length === 0 ? [''] : newContentLines;
701
+ const lastNewLineIndex = lines.length - 1;
702
+ return {
703
+ ...nextState,
704
+ lines,
705
+ cursorRow: lastNewLineIndex,
706
+ cursorCol: cpLen(lines[lastNewLineIndex] ?? ''),
707
+ preferredCol: null,
708
+ };
709
+ }
710
+ case 'insert': {
711
+ const nextState = pushUndoLocal(state);
712
+ const newLines = [...nextState.lines];
713
+ let newCursorRow = nextState.cursorRow;
714
+ let newCursorCol = nextState.cursorCol;
715
+ const currentLine = (r) => newLines[r] ?? '';
716
+ const str = stripUnsafeCharacters(action.payload.replace(/\r\n/g, '\n').replace(/\r/g, '\n'));
717
+ const parts = str.split('\n');
718
+ const lineContent = currentLine(newCursorRow);
719
+ const before = cpSlice(lineContent, 0, newCursorCol);
720
+ const after = cpSlice(lineContent, newCursorCol);
721
+ if (parts.length > 1) {
722
+ newLines[newCursorRow] = before + parts[0];
723
+ const remainingParts = parts.slice(1);
724
+ const lastPartOriginal = remainingParts.pop() ?? '';
725
+ newLines.splice(newCursorRow + 1, 0, ...remainingParts);
726
+ newLines.splice(newCursorRow + parts.length - 1, 0, lastPartOriginal + after);
727
+ newCursorRow = newCursorRow + parts.length - 1;
728
+ newCursorCol = cpLen(lastPartOriginal);
729
+ }
730
+ else {
731
+ newLines[newCursorRow] = before + parts[0] + after;
732
+ newCursorCol = cpLen(before) + cpLen(parts[0]);
733
+ }
734
+ return {
735
+ ...nextState,
736
+ lines: newLines,
737
+ cursorRow: newCursorRow,
738
+ cursorCol: newCursorCol,
739
+ preferredCol: null,
740
+ };
741
+ }
742
+ case 'backspace': {
743
+ const nextState = pushUndoLocal(state);
744
+ const newLines = [...nextState.lines];
745
+ let newCursorRow = nextState.cursorRow;
746
+ let newCursorCol = nextState.cursorCol;
747
+ const currentLine = (r) => newLines[r] ?? '';
748
+ if (newCursorCol === 0 && newCursorRow === 0)
749
+ return state;
750
+ if (newCursorCol > 0) {
751
+ const lineContent = currentLine(newCursorRow);
752
+ newLines[newCursorRow] =
753
+ cpSlice(lineContent, 0, newCursorCol - 1) +
754
+ cpSlice(lineContent, newCursorCol);
755
+ newCursorCol--;
756
+ }
757
+ else if (newCursorRow > 0) {
758
+ const prevLineContent = currentLine(newCursorRow - 1);
759
+ const currentLineContentVal = currentLine(newCursorRow);
760
+ const newCol = cpLen(prevLineContent);
761
+ newLines[newCursorRow - 1] = prevLineContent + currentLineContentVal;
762
+ newLines.splice(newCursorRow, 1);
763
+ newCursorRow--;
764
+ newCursorCol = newCol;
765
+ }
766
+ return {
767
+ ...nextState,
768
+ lines: newLines,
769
+ cursorRow: newCursorRow,
770
+ cursorCol: newCursorCol,
771
+ preferredCol: null,
772
+ };
773
+ }
774
+ case 'set_viewport_width': {
775
+ if (action.payload === state.viewportWidth) {
776
+ return state;
777
+ }
778
+ return { ...state, viewportWidth: action.payload };
779
+ }
780
+ case 'move': {
781
+ const { dir } = action.payload;
782
+ const { lines, cursorRow, cursorCol, viewportWidth } = state;
783
+ const visualLayout = calculateVisualLayout(lines, [cursorRow, cursorCol], viewportWidth);
784
+ const { visualLines, visualCursor, visualToLogicalMap } = visualLayout;
785
+ let newVisualRow = visualCursor[0];
786
+ let newVisualCol = visualCursor[1];
787
+ let newPreferredCol = state.preferredCol;
788
+ const currentVisLineLen = cpLen(visualLines[newVisualRow] ?? '');
789
+ switch (dir) {
790
+ case 'left':
791
+ newPreferredCol = null;
792
+ if (newVisualCol > 0) {
793
+ newVisualCol--;
794
+ }
795
+ else if (newVisualRow > 0) {
796
+ newVisualRow--;
797
+ newVisualCol = cpLen(visualLines[newVisualRow] ?? '');
798
+ }
799
+ break;
800
+ case 'right':
801
+ newPreferredCol = null;
802
+ if (newVisualCol < currentVisLineLen) {
803
+ newVisualCol++;
804
+ }
805
+ else if (newVisualRow < visualLines.length - 1) {
806
+ newVisualRow++;
807
+ newVisualCol = 0;
808
+ }
809
+ break;
810
+ case 'up':
811
+ if (newVisualRow > 0) {
812
+ if (newPreferredCol === null)
813
+ newPreferredCol = newVisualCol;
814
+ newVisualRow--;
815
+ newVisualCol = clamp(newPreferredCol, 0, cpLen(visualLines[newVisualRow] ?? ''));
816
+ }
817
+ break;
818
+ case 'down':
819
+ if (newVisualRow < visualLines.length - 1) {
820
+ if (newPreferredCol === null)
821
+ newPreferredCol = newVisualCol;
822
+ newVisualRow++;
823
+ newVisualCol = clamp(newPreferredCol, 0, cpLen(visualLines[newVisualRow] ?? ''));
824
+ }
825
+ break;
826
+ case 'home':
827
+ newPreferredCol = null;
828
+ newVisualCol = 0;
829
+ break;
830
+ case 'end':
831
+ newPreferredCol = null;
832
+ newVisualCol = currentVisLineLen;
833
+ break;
834
+ case 'wordLeft': {
835
+ const { cursorRow, cursorCol, lines } = state;
836
+ if (cursorCol === 0 && cursorRow === 0)
837
+ return state;
838
+ let newCursorRow = cursorRow;
839
+ let newCursorCol = cursorCol;
840
+ if (cursorCol === 0) {
841
+ newCursorRow--;
842
+ newCursorCol = cpLen(lines[newCursorRow] ?? '');
843
+ }
844
+ else {
845
+ const lineContent = lines[cursorRow];
846
+ const arr = toCodePoints(lineContent);
847
+ let start = cursorCol;
848
+ let onlySpaces = true;
849
+ for (let i = 0; i < start; i++) {
850
+ if (isWordChar(arr[i])) {
851
+ onlySpaces = false;
852
+ break;
853
+ }
854
+ }
855
+ if (onlySpaces && start > 0) {
856
+ start--;
857
+ }
858
+ else {
859
+ while (start > 0 && !isWordChar(arr[start - 1]))
860
+ start--;
861
+ while (start > 0 && isWordChar(arr[start - 1]))
862
+ start--;
863
+ }
864
+ newCursorCol = start;
865
+ }
866
+ return {
867
+ ...state,
868
+ cursorRow: newCursorRow,
869
+ cursorCol: newCursorCol,
870
+ preferredCol: null,
871
+ };
872
+ }
873
+ case 'wordRight': {
874
+ const { cursorRow, cursorCol, lines } = state;
875
+ if (cursorRow === lines.length - 1 &&
876
+ cursorCol === cpLen(lines[cursorRow] ?? '')) {
877
+ return state;
878
+ }
879
+ let newCursorRow = cursorRow;
880
+ let newCursorCol = cursorCol;
881
+ const lineContent = lines[cursorRow] ?? '';
882
+ const arr = toCodePoints(lineContent);
883
+ if (cursorCol >= arr.length) {
884
+ newCursorRow++;
885
+ newCursorCol = 0;
886
+ }
887
+ else {
888
+ let end = cursorCol;
889
+ while (end < arr.length && !isWordChar(arr[end]))
890
+ end++;
891
+ while (end < arr.length && isWordChar(arr[end]))
892
+ end++;
893
+ newCursorCol = end;
894
+ }
895
+ return {
896
+ ...state,
897
+ cursorRow: newCursorRow,
898
+ cursorCol: newCursorCol,
899
+ preferredCol: null,
900
+ };
901
+ }
902
+ default:
903
+ break;
904
+ }
905
+ if (visualToLogicalMap[newVisualRow]) {
906
+ const [logRow, logStartCol] = visualToLogicalMap[newVisualRow];
907
+ return {
908
+ ...state,
909
+ cursorRow: logRow,
910
+ cursorCol: clamp(logStartCol + newVisualCol, 0, cpLen(state.lines[logRow] ?? '')),
911
+ preferredCol: newPreferredCol,
912
+ };
913
+ }
914
+ return state;
915
+ }
916
+ case 'delete': {
917
+ const { cursorRow, cursorCol, lines } = state;
918
+ const lineContent = currentLine(cursorRow);
919
+ if (cursorCol < currentLineLen(cursorRow)) {
920
+ const nextState = pushUndoLocal(state);
921
+ const newLines = [...nextState.lines];
922
+ newLines[cursorRow] =
923
+ cpSlice(lineContent, 0, cursorCol) +
924
+ cpSlice(lineContent, cursorCol + 1);
925
+ return { ...nextState, lines: newLines, preferredCol: null };
926
+ }
927
+ else if (cursorRow < lines.length - 1) {
928
+ const nextState = pushUndoLocal(state);
929
+ const nextLineContent = currentLine(cursorRow + 1);
930
+ const newLines = [...nextState.lines];
931
+ newLines[cursorRow] = lineContent + nextLineContent;
932
+ newLines.splice(cursorRow + 1, 1);
933
+ return { ...nextState, lines: newLines, preferredCol: null };
934
+ }
935
+ return state;
936
+ }
937
+ case 'delete_word_left': {
938
+ const { cursorRow, cursorCol } = state;
939
+ if (cursorCol === 0 && cursorRow === 0)
940
+ return state;
941
+ if (cursorCol === 0) {
942
+ // Act as a backspace
943
+ const nextState = pushUndoLocal(state);
944
+ const prevLineContent = currentLine(cursorRow - 1);
945
+ const currentLineContentVal = currentLine(cursorRow);
946
+ const newCol = cpLen(prevLineContent);
947
+ const newLines = [...nextState.lines];
948
+ newLines[cursorRow - 1] = prevLineContent + currentLineContentVal;
949
+ newLines.splice(cursorRow, 1);
950
+ return {
951
+ ...nextState,
952
+ lines: newLines,
953
+ cursorRow: cursorRow - 1,
954
+ cursorCol: newCol,
955
+ preferredCol: null,
956
+ };
957
+ }
958
+ const nextState = pushUndoLocal(state);
959
+ const lineContent = currentLine(cursorRow);
960
+ const arr = toCodePoints(lineContent);
961
+ let start = cursorCol;
962
+ let onlySpaces = true;
963
+ for (let i = 0; i < start; i++) {
964
+ if (isWordChar(arr[i])) {
965
+ onlySpaces = false;
966
+ break;
967
+ }
968
+ }
969
+ if (onlySpaces && start > 0) {
970
+ start--;
971
+ }
972
+ else {
973
+ while (start > 0 && !isWordChar(arr[start - 1]))
974
+ start--;
975
+ while (start > 0 && isWordChar(arr[start - 1]))
976
+ start--;
977
+ }
978
+ const newLines = [...nextState.lines];
979
+ newLines[cursorRow] =
980
+ cpSlice(lineContent, 0, start) + cpSlice(lineContent, cursorCol);
981
+ return {
982
+ ...nextState,
983
+ lines: newLines,
984
+ cursorCol: start,
985
+ preferredCol: null,
986
+ };
987
+ }
988
+ case 'delete_word_right': {
989
+ const { cursorRow, cursorCol, lines } = state;
990
+ const lineContent = currentLine(cursorRow);
991
+ const arr = toCodePoints(lineContent);
992
+ if (cursorCol >= arr.length && cursorRow === lines.length - 1)
993
+ return state;
994
+ if (cursorCol >= arr.length) {
995
+ // Act as a delete
996
+ const nextState = pushUndoLocal(state);
997
+ const nextLineContent = currentLine(cursorRow + 1);
998
+ const newLines = [...nextState.lines];
999
+ newLines[cursorRow] = lineContent + nextLineContent;
1000
+ newLines.splice(cursorRow + 1, 1);
1001
+ return { ...nextState, lines: newLines, preferredCol: null };
1002
+ }
1003
+ const nextState = pushUndoLocal(state);
1004
+ let end = cursorCol;
1005
+ while (end < arr.length && !isWordChar(arr[end]))
1006
+ end++;
1007
+ while (end < arr.length && isWordChar(arr[end]))
1008
+ end++;
1009
+ const newLines = [...nextState.lines];
1010
+ newLines[cursorRow] =
1011
+ cpSlice(lineContent, 0, cursorCol) + cpSlice(lineContent, end);
1012
+ return { ...nextState, lines: newLines, preferredCol: null };
1013
+ }
1014
+ case 'kill_line_right': {
1015
+ const { cursorRow, cursorCol, lines } = state;
1016
+ const lineContent = currentLine(cursorRow);
1017
+ if (cursorCol < currentLineLen(cursorRow)) {
1018
+ const nextState = pushUndoLocal(state);
1019
+ const newLines = [...nextState.lines];
1020
+ newLines[cursorRow] = cpSlice(lineContent, 0, cursorCol);
1021
+ return { ...nextState, lines: newLines };
1022
+ }
1023
+ else if (cursorRow < lines.length - 1) {
1024
+ // Act as a delete
1025
+ const nextState = pushUndoLocal(state);
1026
+ const nextLineContent = currentLine(cursorRow + 1);
1027
+ const newLines = [...nextState.lines];
1028
+ newLines[cursorRow] = lineContent + nextLineContent;
1029
+ newLines.splice(cursorRow + 1, 1);
1030
+ return { ...nextState, lines: newLines, preferredCol: null };
1031
+ }
1032
+ return state;
1033
+ }
1034
+ case 'kill_line_left': {
1035
+ const { cursorRow, cursorCol } = state;
1036
+ if (cursorCol > 0) {
1037
+ const nextState = pushUndoLocal(state);
1038
+ const lineContent = currentLine(cursorRow);
1039
+ const newLines = [...nextState.lines];
1040
+ newLines[cursorRow] = cpSlice(lineContent, cursorCol);
1041
+ return {
1042
+ ...nextState,
1043
+ lines: newLines,
1044
+ cursorCol: 0,
1045
+ preferredCol: null,
1046
+ };
1047
+ }
1048
+ return state;
1049
+ }
1050
+ case 'undo': {
1051
+ const stateToRestore = state.undoStack[state.undoStack.length - 1];
1052
+ if (!stateToRestore)
1053
+ return state;
1054
+ const currentSnapshot = {
1055
+ lines: [...state.lines],
1056
+ cursorRow: state.cursorRow,
1057
+ cursorCol: state.cursorCol,
1058
+ };
1059
+ return {
1060
+ ...state,
1061
+ ...stateToRestore,
1062
+ undoStack: state.undoStack.slice(0, -1),
1063
+ redoStack: [...state.redoStack, currentSnapshot],
1064
+ };
1065
+ }
1066
+ case 'redo': {
1067
+ const stateToRestore = state.redoStack[state.redoStack.length - 1];
1068
+ if (!stateToRestore)
1069
+ return state;
1070
+ const currentSnapshot = {
1071
+ lines: [...state.lines],
1072
+ cursorRow: state.cursorRow,
1073
+ cursorCol: state.cursorCol,
1074
+ };
1075
+ return {
1076
+ ...state,
1077
+ ...stateToRestore,
1078
+ redoStack: state.redoStack.slice(0, -1),
1079
+ undoStack: [...state.undoStack, currentSnapshot],
1080
+ };
1081
+ }
1082
+ case 'replace_range': {
1083
+ const { startRow, startCol, endRow, endCol, text } = action.payload;
1084
+ const nextState = pushUndoLocal(state);
1085
+ return replaceRangeInternal(nextState, startRow, startCol, endRow, endCol, text);
1086
+ }
1087
+ case 'move_to_offset': {
1088
+ const { offset } = action.payload;
1089
+ const [newRow, newCol] = offsetToLogicalPos(state.lines.join('\n'), offset);
1090
+ return {
1091
+ ...state,
1092
+ cursorRow: newRow,
1093
+ cursorCol: newCol,
1094
+ preferredCol: null,
1095
+ };
1096
+ }
1097
+ case 'create_undo_snapshot': {
1098
+ return pushUndoLocal(state);
1099
+ }
1100
+ // Vim-specific operations
1101
+ case 'vim_delete_word_forward':
1102
+ case 'vim_delete_word_backward':
1103
+ case 'vim_delete_word_end':
1104
+ case 'vim_change_word_forward':
1105
+ case 'vim_change_word_backward':
1106
+ case 'vim_change_word_end':
1107
+ case 'vim_delete_line':
1108
+ case 'vim_change_line':
1109
+ case 'vim_delete_to_end_of_line':
1110
+ case 'vim_change_to_end_of_line':
1111
+ case 'vim_change_movement':
1112
+ case 'vim_move_left':
1113
+ case 'vim_move_right':
1114
+ case 'vim_move_up':
1115
+ case 'vim_move_down':
1116
+ case 'vim_move_word_forward':
1117
+ case 'vim_move_word_backward':
1118
+ case 'vim_move_word_end':
1119
+ case 'vim_delete_char':
1120
+ case 'vim_insert_at_cursor':
1121
+ case 'vim_append_at_cursor':
1122
+ case 'vim_open_line_below':
1123
+ case 'vim_open_line_above':
1124
+ case 'vim_append_at_line_end':
1125
+ case 'vim_insert_at_line_start':
1126
+ case 'vim_move_to_line_start':
1127
+ case 'vim_move_to_line_end':
1128
+ case 'vim_move_to_first_nonwhitespace':
1129
+ case 'vim_move_to_first_line':
1130
+ case 'vim_move_to_last_line':
1131
+ case 'vim_move_to_line':
1132
+ case 'vim_escape_insert_mode':
1133
+ return handleVimAction(state, action);
1134
+ default: {
1135
+ const exhaustiveCheck = action;
1136
+ console.error(`Unknown action encountered: ${exhaustiveCheck}`);
1137
+ return state;
1138
+ }
1139
+ }
1140
+ }
1141
+ // --- End of reducer logic ---
1142
+ export function useTextBuffer({ initialText = '', initialCursorOffset = 0, viewport, stdin, setRawMode, onChange, isValidPath, shellModeActive = false, }) {
1143
+ const initialState = useMemo(() => {
1144
+ const lines = initialText.split('\n');
1145
+ const [initialCursorRow, initialCursorCol] = calculateInitialCursorPosition(lines.length === 0 ? [''] : lines, initialCursorOffset);
1146
+ return {
1147
+ lines: lines.length === 0 ? [''] : lines,
1148
+ cursorRow: initialCursorRow,
1149
+ cursorCol: initialCursorCol,
1150
+ preferredCol: null,
1151
+ undoStack: [],
1152
+ redoStack: [],
1153
+ clipboard: null,
1154
+ selectionAnchor: null,
1155
+ viewportWidth: viewport.width,
1156
+ };
1157
+ }, [initialText, initialCursorOffset, viewport.width]);
1158
+ const [state, dispatch] = useReducer(textBufferReducer, initialState);
1159
+ const { lines, cursorRow, cursorCol, preferredCol, selectionAnchor } = state;
1160
+ const text = useMemo(() => lines.join('\n'), [lines]);
1161
+ const visualLayout = useMemo(() => calculateVisualLayout(lines, [cursorRow, cursorCol], state.viewportWidth), [lines, cursorRow, cursorCol, state.viewportWidth]);
1162
+ const { visualLines, visualCursor } = visualLayout;
1163
+ const [visualScrollRow, setVisualScrollRow] = useState(0);
1164
+ useEffect(() => {
1165
+ if (onChange) {
1166
+ onChange(text);
1167
+ }
1168
+ }, [text, onChange]);
1169
+ useEffect(() => {
1170
+ dispatch({ type: 'set_viewport_width', payload: viewport.width });
1171
+ }, [viewport.width]);
1172
+ // Update visual scroll (vertical)
1173
+ useEffect(() => {
1174
+ const { height } = viewport;
1175
+ let newVisualScrollRow = visualScrollRow;
1176
+ if (visualCursor[0] < visualScrollRow) {
1177
+ newVisualScrollRow = visualCursor[0];
1178
+ }
1179
+ else if (visualCursor[0] >= visualScrollRow + height) {
1180
+ newVisualScrollRow = visualCursor[0] - height + 1;
1181
+ }
1182
+ if (newVisualScrollRow !== visualScrollRow) {
1183
+ setVisualScrollRow(newVisualScrollRow);
1184
+ }
1185
+ }, [visualCursor, visualScrollRow, viewport]);
1186
+ const insert = useCallback((ch, { paste = false } = {}) => {
1187
+ if (/[\n\r]/.test(ch)) {
1188
+ dispatch({ type: 'insert', payload: ch });
1189
+ return;
1190
+ }
1191
+ const minLengthToInferAsDragDrop = 3;
1192
+ if (ch.length >= minLengthToInferAsDragDrop &&
1193
+ !shellModeActive &&
1194
+ paste) {
1195
+ let potentialPath = ch.trim();
1196
+ const quoteMatch = potentialPath.match(/^'(.*)'$/);
1197
+ if (quoteMatch) {
1198
+ potentialPath = quoteMatch[1];
1199
+ }
1200
+ potentialPath = potentialPath.trim();
1201
+ if (isValidPath(unescapePath(potentialPath))) {
1202
+ ch = `@${potentialPath} `;
1203
+ }
1204
+ }
1205
+ let currentText = '';
1206
+ for (const char of toCodePoints(ch)) {
1207
+ if (char.codePointAt(0) === 127) {
1208
+ if (currentText.length > 0) {
1209
+ dispatch({ type: 'insert', payload: currentText });
1210
+ currentText = '';
1211
+ }
1212
+ dispatch({ type: 'backspace' });
1213
+ }
1214
+ else {
1215
+ currentText += char;
1216
+ }
1217
+ }
1218
+ if (currentText.length > 0) {
1219
+ dispatch({ type: 'insert', payload: currentText });
1220
+ }
1221
+ }, [isValidPath, shellModeActive]);
1222
+ const newline = useCallback(() => {
1223
+ dispatch({ type: 'insert', payload: '\n' });
1224
+ }, []);
1225
+ const backspace = useCallback(() => {
1226
+ dispatch({ type: 'backspace' });
1227
+ }, []);
1228
+ const del = useCallback(() => {
1229
+ dispatch({ type: 'delete' });
1230
+ }, []);
1231
+ const move = useCallback((dir) => {
1232
+ dispatch({ type: 'move', payload: { dir } });
1233
+ }, []);
1234
+ const undo = useCallback(() => {
1235
+ dispatch({ type: 'undo' });
1236
+ }, []);
1237
+ const redo = useCallback(() => {
1238
+ dispatch({ type: 'redo' });
1239
+ }, []);
1240
+ const setText = useCallback((newText) => {
1241
+ dispatch({ type: 'set_text', payload: newText });
1242
+ }, []);
1243
+ const deleteWordLeft = useCallback(() => {
1244
+ dispatch({ type: 'delete_word_left' });
1245
+ }, []);
1246
+ const deleteWordRight = useCallback(() => {
1247
+ dispatch({ type: 'delete_word_right' });
1248
+ }, []);
1249
+ const killLineRight = useCallback(() => {
1250
+ dispatch({ type: 'kill_line_right' });
1251
+ }, []);
1252
+ const killLineLeft = useCallback(() => {
1253
+ dispatch({ type: 'kill_line_left' });
1254
+ }, []);
1255
+ // Vim-specific operations
1256
+ const vimDeleteWordForward = useCallback((count) => {
1257
+ dispatch({ type: 'vim_delete_word_forward', payload: { count } });
1258
+ }, []);
1259
+ const vimDeleteWordBackward = useCallback((count) => {
1260
+ dispatch({ type: 'vim_delete_word_backward', payload: { count } });
1261
+ }, []);
1262
+ const vimDeleteWordEnd = useCallback((count) => {
1263
+ dispatch({ type: 'vim_delete_word_end', payload: { count } });
1264
+ }, []);
1265
+ const vimChangeWordForward = useCallback((count) => {
1266
+ dispatch({ type: 'vim_change_word_forward', payload: { count } });
1267
+ }, []);
1268
+ const vimChangeWordBackward = useCallback((count) => {
1269
+ dispatch({ type: 'vim_change_word_backward', payload: { count } });
1270
+ }, []);
1271
+ const vimChangeWordEnd = useCallback((count) => {
1272
+ dispatch({ type: 'vim_change_word_end', payload: { count } });
1273
+ }, []);
1274
+ const vimDeleteLine = useCallback((count) => {
1275
+ dispatch({ type: 'vim_delete_line', payload: { count } });
1276
+ }, []);
1277
+ const vimChangeLine = useCallback((count) => {
1278
+ dispatch({ type: 'vim_change_line', payload: { count } });
1279
+ }, []);
1280
+ const vimDeleteToEndOfLine = useCallback(() => {
1281
+ dispatch({ type: 'vim_delete_to_end_of_line' });
1282
+ }, []);
1283
+ const vimChangeToEndOfLine = useCallback(() => {
1284
+ dispatch({ type: 'vim_change_to_end_of_line' });
1285
+ }, []);
1286
+ const vimChangeMovement = useCallback((movement, count) => {
1287
+ dispatch({ type: 'vim_change_movement', payload: { movement, count } });
1288
+ }, []);
1289
+ // New vim navigation and operation methods
1290
+ const vimMoveLeft = useCallback((count) => {
1291
+ dispatch({ type: 'vim_move_left', payload: { count } });
1292
+ }, []);
1293
+ const vimMoveRight = useCallback((count) => {
1294
+ dispatch({ type: 'vim_move_right', payload: { count } });
1295
+ }, []);
1296
+ const vimMoveUp = useCallback((count) => {
1297
+ dispatch({ type: 'vim_move_up', payload: { count } });
1298
+ }, []);
1299
+ const vimMoveDown = useCallback((count) => {
1300
+ dispatch({ type: 'vim_move_down', payload: { count } });
1301
+ }, []);
1302
+ const vimMoveWordForward = useCallback((count) => {
1303
+ dispatch({ type: 'vim_move_word_forward', payload: { count } });
1304
+ }, []);
1305
+ const vimMoveWordBackward = useCallback((count) => {
1306
+ dispatch({ type: 'vim_move_word_backward', payload: { count } });
1307
+ }, []);
1308
+ const vimMoveWordEnd = useCallback((count) => {
1309
+ dispatch({ type: 'vim_move_word_end', payload: { count } });
1310
+ }, []);
1311
+ const vimDeleteChar = useCallback((count) => {
1312
+ dispatch({ type: 'vim_delete_char', payload: { count } });
1313
+ }, []);
1314
+ const vimInsertAtCursor = useCallback(() => {
1315
+ dispatch({ type: 'vim_insert_at_cursor' });
1316
+ }, []);
1317
+ const vimAppendAtCursor = useCallback(() => {
1318
+ dispatch({ type: 'vim_append_at_cursor' });
1319
+ }, []);
1320
+ const vimOpenLineBelow = useCallback(() => {
1321
+ dispatch({ type: 'vim_open_line_below' });
1322
+ }, []);
1323
+ const vimOpenLineAbove = useCallback(() => {
1324
+ dispatch({ type: 'vim_open_line_above' });
1325
+ }, []);
1326
+ const vimAppendAtLineEnd = useCallback(() => {
1327
+ dispatch({ type: 'vim_append_at_line_end' });
1328
+ }, []);
1329
+ const vimInsertAtLineStart = useCallback(() => {
1330
+ dispatch({ type: 'vim_insert_at_line_start' });
1331
+ }, []);
1332
+ const vimMoveToLineStart = useCallback(() => {
1333
+ dispatch({ type: 'vim_move_to_line_start' });
1334
+ }, []);
1335
+ const vimMoveToLineEnd = useCallback(() => {
1336
+ dispatch({ type: 'vim_move_to_line_end' });
1337
+ }, []);
1338
+ const vimMoveToFirstNonWhitespace = useCallback(() => {
1339
+ dispatch({ type: 'vim_move_to_first_nonwhitespace' });
1340
+ }, []);
1341
+ const vimMoveToFirstLine = useCallback(() => {
1342
+ dispatch({ type: 'vim_move_to_first_line' });
1343
+ }, []);
1344
+ const vimMoveToLastLine = useCallback(() => {
1345
+ dispatch({ type: 'vim_move_to_last_line' });
1346
+ }, []);
1347
+ const vimMoveToLine = useCallback((lineNumber) => {
1348
+ dispatch({ type: 'vim_move_to_line', payload: { lineNumber } });
1349
+ }, []);
1350
+ const vimEscapeInsertMode = useCallback(() => {
1351
+ dispatch({ type: 'vim_escape_insert_mode' });
1352
+ }, []);
1353
+ const openInExternalEditor = useCallback(async (opts = {}) => {
1354
+ const editor = opts.editor ??
1355
+ process.env['VISUAL'] ??
1356
+ process.env['EDITOR'] ??
1357
+ (process.platform === 'win32' ? 'notepad' : 'vi');
1358
+ const tmpDir = fs.mkdtempSync(pathMod.join(os.tmpdir(), 'gemini-edit-'));
1359
+ const filePath = pathMod.join(tmpDir, 'buffer.txt');
1360
+ fs.writeFileSync(filePath, text, 'utf8');
1361
+ dispatch({ type: 'create_undo_snapshot' });
1362
+ const wasRaw = stdin?.isRaw ?? false;
1363
+ try {
1364
+ setRawMode?.(false);
1365
+ const { status, error } = spawnSync(editor, [filePath], {
1366
+ stdio: 'inherit',
1367
+ });
1368
+ if (error)
1369
+ throw error;
1370
+ if (typeof status === 'number' && status !== 0)
1371
+ throw new Error(`External editor exited with status ${status}`);
1372
+ let newText = fs.readFileSync(filePath, 'utf8');
1373
+ newText = newText.replace(/\r\n?/g, '\n');
1374
+ dispatch({ type: 'set_text', payload: newText, pushToUndo: false });
1375
+ }
1376
+ catch (err) {
1377
+ console.error('[useTextBuffer] external editor error', err);
1378
+ }
1379
+ finally {
1380
+ if (wasRaw)
1381
+ setRawMode?.(true);
1382
+ try {
1383
+ fs.unlinkSync(filePath);
1384
+ }
1385
+ catch {
1386
+ /* ignore */
1387
+ }
1388
+ try {
1389
+ fs.rmdirSync(tmpDir);
1390
+ }
1391
+ catch {
1392
+ /* ignore */
1393
+ }
1394
+ }
1395
+ }, [text, stdin, setRawMode]);
1396
+ const handleInput = useCallback((key) => {
1397
+ const { sequence: input } = key;
1398
+ if (key.paste) {
1399
+ // Do not do any other processing on pastes so ensure we handle them
1400
+ // before all other cases.
1401
+ insert(input, { paste: key.paste });
1402
+ return;
1403
+ }
1404
+ if (key.name === 'return' ||
1405
+ input === '\r' ||
1406
+ input === '\n' ||
1407
+ input === '\\\r' // VSCode terminal represents shift + enter this way
1408
+ )
1409
+ newline();
1410
+ else if (key.name === 'left' && !key.meta && !key.ctrl)
1411
+ move('left');
1412
+ else if (key.ctrl && key.name === 'b')
1413
+ move('left');
1414
+ else if (key.name === 'right' && !key.meta && !key.ctrl)
1415
+ move('right');
1416
+ else if (key.ctrl && key.name === 'f')
1417
+ move('right');
1418
+ else if (key.name === 'up')
1419
+ move('up');
1420
+ else if (key.name === 'down')
1421
+ move('down');
1422
+ else if ((key.ctrl || key.meta) && key.name === 'left')
1423
+ move('wordLeft');
1424
+ else if (key.meta && key.name === 'b')
1425
+ move('wordLeft');
1426
+ else if ((key.ctrl || key.meta) && key.name === 'right')
1427
+ move('wordRight');
1428
+ else if (key.meta && key.name === 'f')
1429
+ move('wordRight');
1430
+ else if (key.name === 'home')
1431
+ move('home');
1432
+ else if (key.ctrl && key.name === 'a')
1433
+ move('home');
1434
+ else if (key.name === 'end')
1435
+ move('end');
1436
+ else if (key.ctrl && key.name === 'e')
1437
+ move('end');
1438
+ else if (key.ctrl && key.name === 'w')
1439
+ deleteWordLeft();
1440
+ else if ((key.meta || key.ctrl) &&
1441
+ (key.name === 'backspace' || input === '\x7f'))
1442
+ deleteWordLeft();
1443
+ else if ((key.meta || key.ctrl) && key.name === 'delete')
1444
+ deleteWordRight();
1445
+ else if (key.name === 'backspace' ||
1446
+ input === '\x7f' ||
1447
+ (key.ctrl && key.name === 'h'))
1448
+ backspace();
1449
+ else if (key.name === 'delete' || (key.ctrl && key.name === 'd'))
1450
+ del();
1451
+ else if (input && !key.ctrl && !key.meta) {
1452
+ insert(input, { paste: key.paste });
1453
+ }
1454
+ }, [newline, move, deleteWordLeft, deleteWordRight, backspace, del, insert]);
1455
+ const renderedVisualLines = useMemo(() => visualLines.slice(visualScrollRow, visualScrollRow + viewport.height), [visualLines, visualScrollRow, viewport.height]);
1456
+ const replaceRange = useCallback((startRow, startCol, endRow, endCol, text) => {
1457
+ dispatch({
1458
+ type: 'replace_range',
1459
+ payload: { startRow, startCol, endRow, endCol, text },
1460
+ });
1461
+ }, []);
1462
+ const replaceRangeByOffset = useCallback((startOffset, endOffset, replacementText) => {
1463
+ const [startRow, startCol] = offsetToLogicalPos(text, startOffset);
1464
+ const [endRow, endCol] = offsetToLogicalPos(text, endOffset);
1465
+ replaceRange(startRow, startCol, endRow, endCol, replacementText);
1466
+ }, [text, replaceRange]);
1467
+ const moveToOffset = useCallback((offset) => {
1468
+ dispatch({ type: 'move_to_offset', payload: { offset } });
1469
+ }, []);
1470
+ const returnValue = {
1471
+ lines,
1472
+ text,
1473
+ cursor: [cursorRow, cursorCol],
1474
+ preferredCol,
1475
+ selectionAnchor,
1476
+ allVisualLines: visualLines,
1477
+ viewportVisualLines: renderedVisualLines,
1478
+ visualCursor,
1479
+ visualScrollRow,
1480
+ setText,
1481
+ insert,
1482
+ newline,
1483
+ backspace,
1484
+ del,
1485
+ move,
1486
+ undo,
1487
+ redo,
1488
+ replaceRange,
1489
+ replaceRangeByOffset,
1490
+ moveToOffset,
1491
+ deleteWordLeft,
1492
+ deleteWordRight,
1493
+ killLineRight,
1494
+ killLineLeft,
1495
+ handleInput,
1496
+ openInExternalEditor,
1497
+ // Vim-specific operations
1498
+ vimDeleteWordForward,
1499
+ vimDeleteWordBackward,
1500
+ vimDeleteWordEnd,
1501
+ vimChangeWordForward,
1502
+ vimChangeWordBackward,
1503
+ vimChangeWordEnd,
1504
+ vimDeleteLine,
1505
+ vimChangeLine,
1506
+ vimDeleteToEndOfLine,
1507
+ vimChangeToEndOfLine,
1508
+ vimChangeMovement,
1509
+ vimMoveLeft,
1510
+ vimMoveRight,
1511
+ vimMoveUp,
1512
+ vimMoveDown,
1513
+ vimMoveWordForward,
1514
+ vimMoveWordBackward,
1515
+ vimMoveWordEnd,
1516
+ vimDeleteChar,
1517
+ vimInsertAtCursor,
1518
+ vimAppendAtCursor,
1519
+ vimOpenLineBelow,
1520
+ vimOpenLineAbove,
1521
+ vimAppendAtLineEnd,
1522
+ vimInsertAtLineStart,
1523
+ vimMoveToLineStart,
1524
+ vimMoveToLineEnd,
1525
+ vimMoveToFirstNonWhitespace,
1526
+ vimMoveToFirstLine,
1527
+ vimMoveToLastLine,
1528
+ vimMoveToLine,
1529
+ vimEscapeInsertMode,
1530
+ };
1531
+ return returnValue;
1532
+ }
1533
+ //# sourceMappingURL=text-buffer.js.map