@google/gemini-cli 0.1.1 → 0.1.3-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (391) hide show
  1. package/README.md +7 -6
  2. package/dist/.last_build +0 -0
  3. package/dist/google-gemini-cli-0.1.3.tgz +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 +77 -0
  8. package/dist/src/config/auth.d.ts +6 -0
  9. package/dist/src/config/auth.js +38 -0
  10. package/dist/src/config/auth.js.map +1 -0
  11. package/dist/src/config/config.d.ts +14 -0
  12. package/dist/src/config/config.js +225 -0
  13. package/dist/src/config/config.js.map +1 -0
  14. package/dist/src/config/extension.d.ts +19 -0
  15. package/dist/src/config/extension.js +81 -0
  16. package/dist/src/config/extension.js.map +1 -0
  17. package/dist/src/config/sandboxConfig.d.ts +13 -0
  18. package/dist/src/config/sandboxConfig.js +75 -0
  19. package/dist/src/config/sandboxConfig.js.map +1 -0
  20. package/dist/src/config/settings.d.ts +69 -0
  21. package/dist/src/config/settings.js +165 -0
  22. package/dist/src/config/settings.js.map +1 -0
  23. package/dist/src/gemini.d.ts +6 -0
  24. package/dist/src/gemini.js +212 -0
  25. package/dist/src/gemini.js.map +1 -0
  26. package/dist/src/gemini.test.d.ts +6 -0
  27. package/dist/src/gemini.test.js +122 -0
  28. package/dist/src/gemini.test.js.map +1 -0
  29. package/dist/src/generated/git-commit.d.ts +6 -0
  30. package/dist/src/generated/git-commit.js +9 -0
  31. package/dist/src/generated/git-commit.js.map +1 -0
  32. package/dist/src/nonInteractiveCli.d.ts +7 -0
  33. package/dist/src/nonInteractiveCli.js +112 -0
  34. package/dist/src/nonInteractiveCli.js.map +1 -0
  35. package/dist/src/ui/App.d.ts +14 -0
  36. package/dist/src/ui/App.js +398 -0
  37. package/dist/src/ui/App.js.map +1 -0
  38. package/dist/src/ui/App.test.d.ts +6 -0
  39. package/dist/src/ui/App.test.js +280 -0
  40. package/dist/src/ui/App.test.js.map +1 -0
  41. package/dist/src/ui/colors.d.ts +7 -0
  42. package/dist/src/ui/colors.js +48 -0
  43. package/dist/src/ui/colors.js.map +1 -0
  44. package/dist/src/ui/components/AboutBox.d.ts +14 -0
  45. package/dist/src/ui/components/AboutBox.js +6 -0
  46. package/dist/src/ui/components/AboutBox.js.map +1 -0
  47. package/dist/src/ui/components/AsciiArt.d.ts +7 -0
  48. package/dist/src/ui/components/AsciiArt.js +26 -0
  49. package/dist/src/ui/components/AsciiArt.js.map +1 -0
  50. package/dist/src/ui/components/AuthDialog.d.ts +15 -0
  51. package/dist/src/ui/components/AuthDialog.js +67 -0
  52. package/dist/src/ui/components/AuthDialog.js.map +1 -0
  53. package/dist/src/ui/components/AuthDialog.test.d.ts +6 -0
  54. package/dist/src/ui/components/AuthDialog.test.js +69 -0
  55. package/dist/src/ui/components/AuthDialog.test.js.map +1 -0
  56. package/dist/src/ui/components/AuthInProgress.d.ts +11 -0
  57. package/dist/src/ui/components/AuthInProgress.js +27 -0
  58. package/dist/src/ui/components/AuthInProgress.js.map +1 -0
  59. package/dist/src/ui/components/AutoAcceptIndicator.d.ts +12 -0
  60. package/dist/src/ui/components/AutoAcceptIndicator.js +26 -0
  61. package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -0
  62. package/dist/src/ui/components/ConsolePatcher.d.ts +12 -0
  63. package/dist/src/ui/components/ConsolePatcher.js +40 -0
  64. package/dist/src/ui/components/ConsolePatcher.js.map +1 -0
  65. package/dist/src/ui/components/ConsoleSummaryDisplay.d.ts +11 -0
  66. package/dist/src/ui/components/ConsoleSummaryDisplay.js +11 -0
  67. package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -0
  68. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +15 -0
  69. package/dist/src/ui/components/ContextSummaryDisplay.js +41 -0
  70. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -0
  71. package/dist/src/ui/components/DetailedMessagesDisplay.d.ts +14 -0
  72. package/dist/src/ui/components/DetailedMessagesDisplay.js +34 -0
  73. package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -0
  74. package/dist/src/ui/components/EditorSettingsDialog.d.ts +15 -0
  75. package/dist/src/ui/components/EditorSettingsDialog.js +73 -0
  76. package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -0
  77. package/dist/src/ui/components/Footer.d.ts +22 -0
  78. package/dist/src/ui/components/Footer.js +13 -0
  79. package/dist/src/ui/components/Footer.js.map +1 -0
  80. package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +17 -0
  81. package/dist/src/ui/components/GeminiRespondingSpinner.js +16 -0
  82. package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -0
  83. package/dist/src/ui/components/Header.d.ts +12 -0
  84. package/dist/src/ui/components/Header.js +20 -0
  85. package/dist/src/ui/components/Header.js.map +1 -0
  86. package/dist/src/ui/components/Help.d.ts +12 -0
  87. package/dist/src/ui/components/Help.js +7 -0
  88. package/dist/src/ui/components/Help.js.map +1 -0
  89. package/dist/src/ui/components/HistoryItemDisplay.d.ts +18 -0
  90. package/dist/src/ui/components/HistoryItemDisplay.js +15 -0
  91. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
  92. package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +6 -0
  93. package/dist/src/ui/components/HistoryItemDisplay.test.js +85 -0
  94. package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -0
  95. package/dist/src/ui/components/InputPrompt.d.ts +24 -0
  96. package/dist/src/ui/components/InputPrompt.js +313 -0
  97. package/dist/src/ui/components/InputPrompt.js.map +1 -0
  98. package/dist/src/ui/components/InputPrompt.test.d.ts +6 -0
  99. package/dist/src/ui/components/InputPrompt.test.js +154 -0
  100. package/dist/src/ui/components/InputPrompt.test.js.map +1 -0
  101. package/dist/src/ui/components/LoadingIndicator.d.ts +15 -0
  102. package/dist/src/ui/components/LoadingIndicator.js +19 -0
  103. package/dist/src/ui/components/LoadingIndicator.js.map +1 -0
  104. package/dist/src/ui/components/LoadingIndicator.test.d.ts +6 -0
  105. package/dist/src/ui/components/LoadingIndicator.test.js +141 -0
  106. package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -0
  107. package/dist/src/ui/components/MemoryUsageDisplay.d.ts +7 -0
  108. package/dist/src/ui/components/MemoryUsageDisplay.js +27 -0
  109. package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -0
  110. package/dist/src/ui/components/SessionSummaryDisplay.d.ts +13 -0
  111. package/dist/src/ui/components/SessionSummaryDisplay.js +20 -0
  112. package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -0
  113. package/dist/src/ui/components/SessionSummaryDisplay.test.d.ts +6 -0
  114. package/dist/src/ui/components/SessionSummaryDisplay.test.js +41 -0
  115. package/dist/src/ui/components/SessionSummaryDisplay.test.js.map +1 -0
  116. package/dist/src/ui/components/ShellModeIndicator.d.ts +7 -0
  117. package/dist/src/ui/components/ShellModeIndicator.js +5 -0
  118. package/dist/src/ui/components/ShellModeIndicator.js.map +1 -0
  119. package/dist/src/ui/components/ShowMoreLines.d.ts +10 -0
  120. package/dist/src/ui/components/ShowMoreLines.js +24 -0
  121. package/dist/src/ui/components/ShowMoreLines.js.map +1 -0
  122. package/dist/src/ui/components/Stats.d.ts +39 -0
  123. package/dist/src/ui/components/Stats.js +23 -0
  124. package/dist/src/ui/components/Stats.js.map +1 -0
  125. package/dist/src/ui/components/Stats.test.d.ts +6 -0
  126. package/dist/src/ui/components/Stats.test.js +57 -0
  127. package/dist/src/ui/components/Stats.test.js.map +1 -0
  128. package/dist/src/ui/components/StatsDisplay.d.ts +14 -0
  129. package/dist/src/ui/components/StatsDisplay.js +28 -0
  130. package/dist/src/ui/components/StatsDisplay.js.map +1 -0
  131. package/dist/src/ui/components/StatsDisplay.test.d.ts +6 -0
  132. package/dist/src/ui/components/StatsDisplay.test.js +51 -0
  133. package/dist/src/ui/components/StatsDisplay.test.js.map +1 -0
  134. package/dist/src/ui/components/SuggestionsDisplay.d.ts +21 -0
  135. package/dist/src/ui/components/SuggestionsDisplay.js +32 -0
  136. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -0
  137. package/dist/src/ui/components/ThemeDialog.d.ts +19 -0
  138. package/dist/src/ui/components/ThemeDialog.js +126 -0
  139. package/dist/src/ui/components/ThemeDialog.js.map +1 -0
  140. package/dist/src/ui/components/Tips.d.ts +12 -0
  141. package/dist/src/ui/components/Tips.js +8 -0
  142. package/dist/src/ui/components/Tips.js.map +1 -0
  143. package/dist/src/ui/components/UpdateNotification.d.ts +10 -0
  144. package/dist/src/ui/components/UpdateNotification.js +10 -0
  145. package/dist/src/ui/components/UpdateNotification.js.map +1 -0
  146. package/dist/src/ui/components/messages/CompressionMessage.d.ts +11 -0
  147. package/dist/src/ui/components/messages/CompressionMessage.js +16 -0
  148. package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -0
  149. package/dist/src/ui/components/messages/DiffRenderer.d.ts +15 -0
  150. package/dist/src/ui/components/messages/DiffRenderer.js +212 -0
  151. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -0
  152. package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +6 -0
  153. package/dist/src/ui/components/messages/DiffRenderer.test.js +239 -0
  154. package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -0
  155. package/dist/src/ui/components/messages/ErrorMessage.d.ts +11 -0
  156. package/dist/src/ui/components/messages/ErrorMessage.js +9 -0
  157. package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -0
  158. package/dist/src/ui/components/messages/GeminiMessage.d.ts +14 -0
  159. package/dist/src/ui/components/messages/GeminiMessage.js +10 -0
  160. package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -0
  161. package/dist/src/ui/components/messages/GeminiMessageContent.d.ts +14 -0
  162. package/dist/src/ui/components/messages/GeminiMessageContent.js +15 -0
  163. package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -0
  164. package/dist/src/ui/components/messages/InfoMessage.d.ts +11 -0
  165. package/dist/src/ui/components/messages/InfoMessage.js +9 -0
  166. package/dist/src/ui/components/messages/InfoMessage.js.map +1 -0
  167. package/dist/src/ui/components/messages/ToolConfirmationMessage.d.ts +15 -0
  168. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +111 -0
  169. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -0
  170. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +6 -0
  171. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +37 -0
  172. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -0
  173. package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +18 -0
  174. package/dist/src/ui/components/messages/ToolGroupMessage.js +53 -0
  175. package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -0
  176. package/dist/src/ui/components/messages/ToolMessage.d.ts +15 -0
  177. package/dist/src/ui/components/messages/ToolMessage.js +61 -0
  178. package/dist/src/ui/components/messages/ToolMessage.js.map +1 -0
  179. package/dist/src/ui/components/messages/ToolMessage.test.d.ts +6 -0
  180. package/dist/src/ui/components/messages/ToolMessage.test.js +116 -0
  181. package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -0
  182. package/dist/src/ui/components/messages/UserMessage.d.ts +11 -0
  183. package/dist/src/ui/components/messages/UserMessage.js +9 -0
  184. package/dist/src/ui/components/messages/UserMessage.js.map +1 -0
  185. package/dist/src/ui/components/messages/UserShellMessage.d.ts +11 -0
  186. package/dist/src/ui/components/messages/UserShellMessage.js +9 -0
  187. package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -0
  188. package/dist/src/ui/components/shared/MaxSizedBox.d.ts +61 -0
  189. package/dist/src/ui/components/shared/MaxSizedBox.js +383 -0
  190. package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -0
  191. package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +6 -0
  192. package/dist/src/ui/components/shared/MaxSizedBox.test.js +134 -0
  193. package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -0
  194. package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +41 -0
  195. package/dist/src/ui/components/shared/RadioButtonSelect.js +52 -0
  196. package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
  197. package/dist/src/ui/components/shared/text-buffer.d.ts +121 -0
  198. package/dist/src/ui/components/shared/text-buffer.js +1147 -0
  199. package/dist/src/ui/components/shared/text-buffer.js.map +1 -0
  200. package/dist/src/ui/constants.d.ts +8 -0
  201. package/dist/src/ui/constants.js +12 -0
  202. package/dist/src/ui/constants.js.map +1 -0
  203. package/dist/src/ui/contexts/OverflowContext.d.ts +19 -0
  204. package/dist/src/ui/contexts/OverflowContext.js +43 -0
  205. package/dist/src/ui/contexts/OverflowContext.js.map +1 -0
  206. package/dist/src/ui/contexts/SessionContext.d.ts +35 -0
  207. package/dist/src/ui/contexts/SessionContext.js +132 -0
  208. package/dist/src/ui/contexts/SessionContext.js.map +1 -0
  209. package/dist/src/ui/contexts/SessionContext.test.d.ts +6 -0
  210. package/dist/src/ui/contexts/SessionContext.test.js +151 -0
  211. package/dist/src/ui/contexts/SessionContext.test.js.map +1 -0
  212. package/dist/src/ui/contexts/StreamingContext.d.ts +9 -0
  213. package/dist/src/ui/contexts/StreamingContext.js +15 -0
  214. package/dist/src/ui/contexts/StreamingContext.js.map +1 -0
  215. package/dist/src/ui/editors/editorSettingsManager.d.ts +19 -0
  216. package/dist/src/ui/editors/editorSettingsManager.js +50 -0
  217. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -0
  218. package/dist/src/ui/hooks/atCommandProcessor.d.ts +31 -0
  219. package/dist/src/ui/hooks/atCommandProcessor.js +312 -0
  220. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
  221. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +16 -0
  222. package/dist/src/ui/hooks/shellCommandProcessor.js +261 -0
  223. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
  224. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +31 -0
  225. package/dist/src/ui/hooks/slashCommandProcessor.js +922 -0
  226. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
  227. package/dist/src/ui/hooks/useAuthCommand.d.ts +15 -0
  228. package/dist/src/ui/hooks/useAuthCommand.js +65 -0
  229. package/dist/src/ui/hooks/useAuthCommand.js.map +1 -0
  230. package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +10 -0
  231. package/dist/src/ui/hooks/useAutoAcceptIndicator.js +37 -0
  232. package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -0
  233. package/dist/src/ui/hooks/useCompletion.d.ts +21 -0
  234. package/dist/src/ui/hooks/useCompletion.js +321 -0
  235. package/dist/src/ui/hooks/useCompletion.js.map +1 -0
  236. package/dist/src/ui/hooks/useConsoleMessages.d.ts +12 -0
  237. package/dist/src/ui/hooks/useConsoleMessages.js +59 -0
  238. package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -0
  239. package/dist/src/ui/hooks/useEditorSettings.d.ts +16 -0
  240. package/dist/src/ui/hooks/useEditorSettings.js +43 -0
  241. package/dist/src/ui/hooks/useEditorSettings.js.map +1 -0
  242. package/dist/src/ui/hooks/useGeminiStream.d.ts +23 -0
  243. package/dist/src/ui/hooks/useGeminiStream.js +552 -0
  244. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -0
  245. package/dist/src/ui/hooks/useGeminiStream.test.d.ts +6 -0
  246. package/dist/src/ui/hooks/useGeminiStream.test.js +823 -0
  247. package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -0
  248. package/dist/src/ui/hooks/useGitBranchName.d.ts +6 -0
  249. package/dist/src/ui/hooks/useGitBranchName.js +61 -0
  250. package/dist/src/ui/hooks/useGitBranchName.js.map +1 -0
  251. package/dist/src/ui/hooks/useHistoryManager.d.ts +22 -0
  252. package/dist/src/ui/hooks/useHistoryManager.js +72 -0
  253. package/dist/src/ui/hooks/useHistoryManager.js.map +1 -0
  254. package/dist/src/ui/hooks/useInputHistory.d.ts +19 -0
  255. package/dist/src/ui/hooks/useInputHistory.js +84 -0
  256. package/dist/src/ui/hooks/useInputHistory.js.map +1 -0
  257. package/dist/src/ui/hooks/useLoadingIndicator.d.ts +10 -0
  258. package/dist/src/ui/hooks/useLoadingIndicator.js +44 -0
  259. package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -0
  260. package/dist/src/ui/hooks/useLogger.d.ts +10 -0
  261. package/dist/src/ui/hooks/useLogger.js +29 -0
  262. package/dist/src/ui/hooks/useLogger.js.map +1 -0
  263. package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
  264. package/dist/src/ui/hooks/usePhraseCycler.js +189 -0
  265. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -0
  266. package/dist/src/ui/hooks/useReactToolScheduler.d.ts +33 -0
  267. package/dist/src/ui/hooks/useReactToolScheduler.js +186 -0
  268. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -0
  269. package/dist/src/ui/hooks/useRefreshMemoryCommand.d.ts +6 -0
  270. package/dist/src/ui/hooks/useRefreshMemoryCommand.js +7 -0
  271. package/dist/src/ui/hooks/useRefreshMemoryCommand.js.map +1 -0
  272. package/dist/src/ui/hooks/useShellHistory.d.ts +11 -0
  273. package/dist/src/ui/hooks/useShellHistory.js +89 -0
  274. package/dist/src/ui/hooks/useShellHistory.js.map +1 -0
  275. package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +9 -0
  276. package/dist/src/ui/hooks/useShowMemoryCommand.js +58 -0
  277. package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
  278. package/dist/src/ui/hooks/useStateAndRef.d.ts +7 -0
  279. package/dist/src/ui/hooks/useStateAndRef.js +26 -0
  280. package/dist/src/ui/hooks/useStateAndRef.js.map +1 -0
  281. package/dist/src/ui/hooks/useTerminalSize.d.ts +9 -0
  282. package/dist/src/ui/hooks/useTerminalSize.js +27 -0
  283. package/dist/src/ui/hooks/useTerminalSize.js.map +1 -0
  284. package/dist/src/ui/hooks/useThemeCommand.d.ts +15 -0
  285. package/dist/src/ui/hooks/useThemeCommand.js +78 -0
  286. package/dist/src/ui/hooks/useThemeCommand.js.map +1 -0
  287. package/dist/src/ui/hooks/useTimer.d.ts +12 -0
  288. package/dist/src/ui/hooks/useTimer.js +58 -0
  289. package/dist/src/ui/hooks/useTimer.js.map +1 -0
  290. package/dist/src/ui/themes/ansi-light.d.ts +7 -0
  291. package/dist/src/ui/themes/ansi-light.js +139 -0
  292. package/dist/src/ui/themes/ansi-light.js.map +1 -0
  293. package/dist/src/ui/themes/ansi.d.ts +7 -0
  294. package/dist/src/ui/themes/ansi.js +149 -0
  295. package/dist/src/ui/themes/ansi.js.map +1 -0
  296. package/dist/src/ui/themes/atom-one-dark.d.ts +7 -0
  297. package/dist/src/ui/themes/atom-one-dark.js +136 -0
  298. package/dist/src/ui/themes/atom-one-dark.js.map +1 -0
  299. package/dist/src/ui/themes/ayu-light.d.ts +7 -0
  300. package/dist/src/ui/themes/ayu-light.js +128 -0
  301. package/dist/src/ui/themes/ayu-light.js.map +1 -0
  302. package/dist/src/ui/themes/ayu.d.ts +7 -0
  303. package/dist/src/ui/themes/ayu.js +102 -0
  304. package/dist/src/ui/themes/ayu.js.map +1 -0
  305. package/dist/src/ui/themes/default-light.d.ts +7 -0
  306. package/dist/src/ui/themes/default-light.js +100 -0
  307. package/dist/src/ui/themes/default-light.js.map +1 -0
  308. package/dist/src/ui/themes/default.d.ts +7 -0
  309. package/dist/src/ui/themes/default.js +143 -0
  310. package/dist/src/ui/themes/default.js.map +1 -0
  311. package/dist/src/ui/themes/dracula.d.ts +7 -0
  312. package/dist/src/ui/themes/dracula.js +113 -0
  313. package/dist/src/ui/themes/dracula.js.map +1 -0
  314. package/dist/src/ui/themes/github-dark.d.ts +7 -0
  315. package/dist/src/ui/themes/github-dark.js +136 -0
  316. package/dist/src/ui/themes/github-dark.js.map +1 -0
  317. package/dist/src/ui/themes/github-light.d.ts +7 -0
  318. package/dist/src/ui/themes/github-light.js +138 -0
  319. package/dist/src/ui/themes/github-light.js.map +1 -0
  320. package/dist/src/ui/themes/googlecode.d.ts +7 -0
  321. package/dist/src/ui/themes/googlecode.js +135 -0
  322. package/dist/src/ui/themes/googlecode.js.map +1 -0
  323. package/dist/src/ui/themes/no-color.d.ts +7 -0
  324. package/dist/src/ui/themes/no-color.js +84 -0
  325. package/dist/src/ui/themes/no-color.js.map +1 -0
  326. package/dist/src/ui/themes/theme-manager.d.ts +33 -0
  327. package/dist/src/ui/themes/theme-manager.js +107 -0
  328. package/dist/src/ui/themes/theme-manager.js.map +1 -0
  329. package/dist/src/ui/themes/theme.d.ts +67 -0
  330. package/dist/src/ui/themes/theme.js +304 -0
  331. package/dist/src/ui/themes/theme.js.map +1 -0
  332. package/dist/src/ui/themes/xcode.d.ts +7 -0
  333. package/dist/src/ui/themes/xcode.js +143 -0
  334. package/dist/src/ui/themes/xcode.js.map +1 -0
  335. package/dist/src/ui/types.d.ts +149 -0
  336. package/dist/src/ui/types.js +41 -0
  337. package/dist/src/ui/types.js.map +1 -0
  338. package/dist/src/ui/utils/CodeColorizer.d.ts +14 -0
  339. package/dist/src/ui/utils/CodeColorizer.js +97 -0
  340. package/dist/src/ui/utils/CodeColorizer.js.map +1 -0
  341. package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
  342. package/dist/src/ui/utils/MarkdownDisplay.js +221 -0
  343. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
  344. package/dist/src/ui/utils/commandUtils.d.ts +22 -0
  345. package/dist/src/ui/utils/commandUtils.js +25 -0
  346. package/dist/src/ui/utils/commandUtils.js.map +1 -0
  347. package/dist/src/ui/utils/errorParsing.d.ts +15 -0
  348. package/dist/src/ui/utils/errorParsing.js +80 -0
  349. package/dist/src/ui/utils/errorParsing.js.map +1 -0
  350. package/dist/src/ui/utils/formatters.d.ts +13 -0
  351. package/dist/src/ui/utils/formatters.js +56 -0
  352. package/dist/src/ui/utils/formatters.js.map +1 -0
  353. package/dist/src/ui/utils/markdownUtilities.d.ts +6 -0
  354. package/dist/src/ui/utils/markdownUtilities.js +110 -0
  355. package/dist/src/ui/utils/markdownUtilities.js.map +1 -0
  356. package/dist/src/ui/utils/textUtils.d.ts +22 -0
  357. package/dist/src/ui/utils/textUtils.js +58 -0
  358. package/dist/src/ui/utils/textUtils.js.map +1 -0
  359. package/dist/src/ui/utils/updateCheck.d.ts +6 -0
  360. package/dist/src/ui/utils/updateCheck.js +34 -0
  361. package/dist/src/ui/utils/updateCheck.js.map +1 -0
  362. package/dist/src/utils/cleanup.d.ts +6 -0
  363. package/dist/src/utils/cleanup.js +19 -0
  364. package/dist/src/utils/cleanup.js.map +1 -0
  365. package/dist/src/utils/package.d.ts +12 -0
  366. package/dist/src/utils/package.js +24 -0
  367. package/dist/src/utils/package.js.map +1 -0
  368. package/dist/src/utils/readStdin.d.ts +6 -0
  369. package/dist/src/utils/readStdin.js +34 -0
  370. package/dist/src/utils/readStdin.js.map +1 -0
  371. package/dist/src/utils/sandbox.d.ts +7 -0
  372. package/dist/src/utils/sandbox.js +680 -0
  373. package/dist/src/utils/sandbox.js.map +1 -0
  374. package/dist/src/utils/startupWarnings.d.ts +6 -0
  375. package/dist/src/utils/startupWarnings.js +40 -0
  376. package/dist/src/utils/startupWarnings.js.map +1 -0
  377. package/dist/src/utils/version.d.ts +6 -0
  378. package/dist/src/utils/version.js +11 -0
  379. package/dist/src/utils/version.js.map +1 -0
  380. package/dist/tsconfig.tsbuildinfo +1 -0
  381. package/package.json +63 -71
  382. package/LICENSE +0 -202
  383. package/bundle/gemini.js +0 -257368
  384. package/bundle/shell.json +0 -18
  385. package/bundle/shell.md +0 -16
  386. /package/{bundle → dist/src/utils}/sandbox-macos-permissive-closed.sb +0 -0
  387. /package/{bundle → dist/src/utils}/sandbox-macos-permissive-open.sb +0 -0
  388. /package/{bundle → dist/src/utils}/sandbox-macos-permissive-proxied.sb +0 -0
  389. /package/{bundle → dist/src/utils}/sandbox-macos-restrictive-closed.sb +0 -0
  390. /package/{bundle → dist/src/utils}/sandbox-macos-restrictive-open.sb +0 -0
  391. /package/{bundle → dist/src/utils}/sandbox-macos-restrictive-proxied.sb +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorSettingsManager.js","sourceRoot":"","sources":["../../../../src/ui/editors/editorSettingsManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,wBAAwB,EACxB,kBAAkB,GAEnB,MAAM,yBAAyB,CAAC;AAQjC,MAAM,CAAC,MAAM,oBAAoB,GAA+B;IAC9D,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;CACX,CAAC;AAEF,MAAM,qBAAqB;IACR,gBAAgB,CAAkB;IAEnD;QACE,MAAM,WAAW,GAAiB;YAChC,KAAK;YACL,QAAQ;YACR,UAAU;YACV,QAAQ;YACR,KAAK;SACN,CAAC;QACF,IAAI,CAAC,gBAAgB,GAAG;YACtB;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE,KAAK;aAChB;YACD,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC1B,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;gBAC3C,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;gBAE1D,IAAI,WAAW,GAAG,CAAC,kBAAkB;oBACnC,CAAC,CAAC,6BAA6B;oBAC/B,CAAC,CAAC,EAAE,CAAC;gBACP,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC;gBAE5D,OAAO;oBACL,IAAI,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAAG,WAAW;oBAC9C,IAAI;oBACJ,QAAQ,EAAE,CAAC,SAAS,IAAI,CAAC,kBAAkB;iBAC5C,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;IAED,0BAA0B;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { PartListUnion } from '@google/genai';
7
+ import { Config } from '@google/gemini-cli-core';
8
+ import { UseHistoryManagerReturn } from './useHistoryManager.js';
9
+ interface HandleAtCommandParams {
10
+ query: string;
11
+ config: Config;
12
+ addItem: UseHistoryManagerReturn['addItem'];
13
+ onDebugMessage: (message: string) => void;
14
+ messageId: number;
15
+ signal: AbortSignal;
16
+ }
17
+ interface HandleAtCommandResult {
18
+ processedQuery: PartListUnion | null;
19
+ shouldProceed: boolean;
20
+ }
21
+ /**
22
+ * Processes user input potentially containing one or more '@<path>' commands.
23
+ * If found, it attempts to read the specified files/directories using the
24
+ * 'read_many_files' tool. The user query is modified to include resolved paths,
25
+ * and the content of the files is appended in a structured block.
26
+ *
27
+ * @returns An object indicating whether the main hook should proceed with an
28
+ * LLM call and the processed query parts (including file content).
29
+ */
30
+ export declare function handleAtCommand({ query, config, addItem, onDebugMessage, messageId: userMessageTimestamp, signal, }: HandleAtCommandParams): Promise<HandleAtCommandResult>;
31
+ export {};
@@ -0,0 +1,312 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import * as fs from 'fs/promises';
7
+ import * as path from 'path';
8
+ import { getErrorMessage, isNodeError, unescapePath, } from '@google/gemini-cli-core';
9
+ import { ToolCallStatus, } from '../types.js';
10
+ /**
11
+ * Parses a query string to find all '@<path>' commands and text segments.
12
+ * Handles \ escaped spaces within paths.
13
+ */
14
+ function parseAllAtCommands(query) {
15
+ const parts = [];
16
+ let currentIndex = 0;
17
+ while (currentIndex < query.length) {
18
+ let atIndex = -1;
19
+ let nextSearchIndex = currentIndex;
20
+ // Find next unescaped '@'
21
+ while (nextSearchIndex < query.length) {
22
+ if (query[nextSearchIndex] === '@' &&
23
+ (nextSearchIndex === 0 || query[nextSearchIndex - 1] !== '\\')) {
24
+ atIndex = nextSearchIndex;
25
+ break;
26
+ }
27
+ nextSearchIndex++;
28
+ }
29
+ if (atIndex === -1) {
30
+ // No more @
31
+ if (currentIndex < query.length) {
32
+ parts.push({ type: 'text', content: query.substring(currentIndex) });
33
+ }
34
+ break;
35
+ }
36
+ // Add text before @
37
+ if (atIndex > currentIndex) {
38
+ parts.push({
39
+ type: 'text',
40
+ content: query.substring(currentIndex, atIndex),
41
+ });
42
+ }
43
+ // Parse @path
44
+ let pathEndIndex = atIndex + 1;
45
+ let inEscape = false;
46
+ while (pathEndIndex < query.length) {
47
+ const char = query[pathEndIndex];
48
+ if (inEscape) {
49
+ inEscape = false;
50
+ }
51
+ else if (char === '\\') {
52
+ inEscape = true;
53
+ }
54
+ else if (/\s/.test(char)) {
55
+ // Path ends at first whitespace not escaped
56
+ break;
57
+ }
58
+ pathEndIndex++;
59
+ }
60
+ const rawAtPath = query.substring(atIndex, pathEndIndex);
61
+ // unescapePath expects the @ symbol to be present, and will handle it.
62
+ const atPath = unescapePath(rawAtPath);
63
+ parts.push({ type: 'atPath', content: atPath });
64
+ currentIndex = pathEndIndex;
65
+ }
66
+ // Filter out empty text parts that might result from consecutive @paths or leading/trailing spaces
67
+ return parts.filter((part) => !(part.type === 'text' && part.content.trim() === ''));
68
+ }
69
+ /**
70
+ * Processes user input potentially containing one or more '@<path>' commands.
71
+ * If found, it attempts to read the specified files/directories using the
72
+ * 'read_many_files' tool. The user query is modified to include resolved paths,
73
+ * and the content of the files is appended in a structured block.
74
+ *
75
+ * @returns An object indicating whether the main hook should proceed with an
76
+ * LLM call and the processed query parts (including file content).
77
+ */
78
+ export async function handleAtCommand({ query, config, addItem, onDebugMessage, messageId: userMessageTimestamp, signal, }) {
79
+ const commandParts = parseAllAtCommands(query);
80
+ const atPathCommandParts = commandParts.filter((part) => part.type === 'atPath');
81
+ if (atPathCommandParts.length === 0) {
82
+ addItem({ type: 'user', text: query }, userMessageTimestamp);
83
+ return { processedQuery: [{ text: query }], shouldProceed: true };
84
+ }
85
+ addItem({ type: 'user', text: query }, userMessageTimestamp);
86
+ // Get centralized file discovery service
87
+ const fileDiscovery = config.getFileService();
88
+ const respectGitIgnore = config.getFileFilteringRespectGitIgnore();
89
+ const pathSpecsToRead = [];
90
+ const atPathToResolvedSpecMap = new Map();
91
+ const contentLabelsForDisplay = [];
92
+ const ignoredPaths = [];
93
+ const toolRegistry = await config.getToolRegistry();
94
+ const readManyFilesTool = toolRegistry.getTool('read_many_files');
95
+ const globTool = toolRegistry.getTool('glob');
96
+ if (!readManyFilesTool) {
97
+ addItem({ type: 'error', text: 'Error: read_many_files tool not found.' }, userMessageTimestamp);
98
+ return { processedQuery: null, shouldProceed: false };
99
+ }
100
+ for (const atPathPart of atPathCommandParts) {
101
+ const originalAtPath = atPathPart.content; // e.g., "@file.txt" or "@"
102
+ if (originalAtPath === '@') {
103
+ onDebugMessage('Lone @ detected, will be treated as text in the modified query.');
104
+ continue;
105
+ }
106
+ const pathName = originalAtPath.substring(1);
107
+ if (!pathName) {
108
+ // This case should ideally not be hit if parseAllAtCommands ensures content after @
109
+ // but as a safeguard:
110
+ addItem({
111
+ type: 'error',
112
+ text: `Error: Invalid @ command '${originalAtPath}'. No path specified.`,
113
+ }, userMessageTimestamp);
114
+ // Decide if this is a fatal error for the whole command or just skip this @ part
115
+ // For now, let's be strict and fail the command if one @path is malformed.
116
+ return { processedQuery: null, shouldProceed: false };
117
+ }
118
+ // Check if path should be ignored by git
119
+ if (fileDiscovery.shouldGitIgnoreFile(pathName)) {
120
+ const reason = respectGitIgnore
121
+ ? 'git-ignored and will be skipped'
122
+ : 'ignored by custom patterns';
123
+ onDebugMessage(`Path ${pathName} is ${reason}.`);
124
+ ignoredPaths.push(pathName);
125
+ continue;
126
+ }
127
+ let currentPathSpec = pathName;
128
+ let resolvedSuccessfully = false;
129
+ try {
130
+ const absolutePath = path.resolve(config.getTargetDir(), pathName);
131
+ const stats = await fs.stat(absolutePath);
132
+ if (stats.isDirectory()) {
133
+ currentPathSpec = pathName.endsWith('/')
134
+ ? `${pathName}**`
135
+ : `${pathName}/**`;
136
+ onDebugMessage(`Path ${pathName} resolved to directory, using glob: ${currentPathSpec}`);
137
+ }
138
+ else {
139
+ onDebugMessage(`Path ${pathName} resolved to file: ${currentPathSpec}`);
140
+ }
141
+ resolvedSuccessfully = true;
142
+ }
143
+ catch (error) {
144
+ if (isNodeError(error) && error.code === 'ENOENT') {
145
+ if (config.getEnableRecursiveFileSearch() && globTool) {
146
+ onDebugMessage(`Path ${pathName} not found directly, attempting glob search.`);
147
+ try {
148
+ const globResult = await globTool.execute({ pattern: `**/*${pathName}*`, path: config.getTargetDir() }, signal);
149
+ if (globResult.llmContent &&
150
+ typeof globResult.llmContent === 'string' &&
151
+ !globResult.llmContent.startsWith('No files found') &&
152
+ !globResult.llmContent.startsWith('Error:')) {
153
+ const lines = globResult.llmContent.split('\n');
154
+ if (lines.length > 1 && lines[1]) {
155
+ const firstMatchAbsolute = lines[1].trim();
156
+ currentPathSpec = path.relative(config.getTargetDir(), firstMatchAbsolute);
157
+ onDebugMessage(`Glob search for ${pathName} found ${firstMatchAbsolute}, using relative path: ${currentPathSpec}`);
158
+ resolvedSuccessfully = true;
159
+ }
160
+ else {
161
+ onDebugMessage(`Glob search for '**/*${pathName}*' did not return a usable path. Path ${pathName} will be skipped.`);
162
+ }
163
+ }
164
+ else {
165
+ onDebugMessage(`Glob search for '**/*${pathName}*' found no files or an error. Path ${pathName} will be skipped.`);
166
+ }
167
+ }
168
+ catch (globError) {
169
+ console.error(`Error during glob search for ${pathName}: ${getErrorMessage(globError)}`);
170
+ onDebugMessage(`Error during glob search for ${pathName}. Path ${pathName} will be skipped.`);
171
+ }
172
+ }
173
+ else {
174
+ onDebugMessage(`Glob tool not found. Path ${pathName} will be skipped.`);
175
+ }
176
+ }
177
+ else {
178
+ console.error(`Error stating path ${pathName}: ${getErrorMessage(error)}`);
179
+ onDebugMessage(`Error stating path ${pathName}. Path ${pathName} will be skipped.`);
180
+ }
181
+ }
182
+ if (resolvedSuccessfully) {
183
+ pathSpecsToRead.push(currentPathSpec);
184
+ atPathToResolvedSpecMap.set(originalAtPath, currentPathSpec);
185
+ contentLabelsForDisplay.push(pathName);
186
+ }
187
+ }
188
+ // Construct the initial part of the query for the LLM
189
+ let initialQueryText = '';
190
+ for (let i = 0; i < commandParts.length; i++) {
191
+ const part = commandParts[i];
192
+ if (part.type === 'text') {
193
+ initialQueryText += part.content;
194
+ }
195
+ else {
196
+ // type === 'atPath'
197
+ const resolvedSpec = atPathToResolvedSpecMap.get(part.content);
198
+ if (i > 0 &&
199
+ initialQueryText.length > 0 &&
200
+ !initialQueryText.endsWith(' ') &&
201
+ resolvedSpec) {
202
+ // Add space if previous part was text and didn't end with space, or if previous was @path
203
+ const prevPart = commandParts[i - 1];
204
+ if (prevPart.type === 'text' ||
205
+ (prevPart.type === 'atPath' &&
206
+ atPathToResolvedSpecMap.has(prevPart.content))) {
207
+ initialQueryText += ' ';
208
+ }
209
+ }
210
+ if (resolvedSpec) {
211
+ initialQueryText += `@${resolvedSpec}`;
212
+ }
213
+ else {
214
+ // If not resolved for reading (e.g. lone @ or invalid path that was skipped),
215
+ // add the original @-string back, ensuring spacing if it's not the first element.
216
+ if (i > 0 &&
217
+ initialQueryText.length > 0 &&
218
+ !initialQueryText.endsWith(' ') &&
219
+ !part.content.startsWith(' ')) {
220
+ initialQueryText += ' ';
221
+ }
222
+ initialQueryText += part.content;
223
+ }
224
+ }
225
+ }
226
+ initialQueryText = initialQueryText.trim();
227
+ // Inform user about ignored paths
228
+ if (ignoredPaths.length > 0) {
229
+ const ignoreType = respectGitIgnore ? 'git-ignored' : 'custom-ignored';
230
+ onDebugMessage(`Ignored ${ignoredPaths.length} ${ignoreType} files: ${ignoredPaths.join(', ')}`);
231
+ }
232
+ // Fallback for lone "@" or completely invalid @-commands resulting in empty initialQueryText
233
+ if (pathSpecsToRead.length === 0) {
234
+ onDebugMessage('No valid file paths found in @ commands to read.');
235
+ if (initialQueryText === '@' && query.trim() === '@') {
236
+ // If the only thing was a lone @, pass original query (which might have spaces)
237
+ return { processedQuery: [{ text: query }], shouldProceed: true };
238
+ }
239
+ else if (!initialQueryText && query) {
240
+ // If all @-commands were invalid and no surrounding text, pass original query
241
+ return { processedQuery: [{ text: query }], shouldProceed: true };
242
+ }
243
+ // Otherwise, proceed with the (potentially modified) query text that doesn't involve file reading
244
+ return {
245
+ processedQuery: [{ text: initialQueryText || query }],
246
+ shouldProceed: true,
247
+ };
248
+ }
249
+ const processedQueryParts = [{ text: initialQueryText }];
250
+ const toolArgs = {
251
+ paths: pathSpecsToRead,
252
+ respectGitIgnore, // Use configuration setting
253
+ };
254
+ let toolCallDisplay;
255
+ try {
256
+ const result = await readManyFilesTool.execute(toolArgs, signal);
257
+ toolCallDisplay = {
258
+ callId: `client-read-${userMessageTimestamp}`,
259
+ name: readManyFilesTool.displayName,
260
+ description: readManyFilesTool.getDescription(toolArgs),
261
+ status: ToolCallStatus.Success,
262
+ resultDisplay: result.returnDisplay ||
263
+ `Successfully read: ${contentLabelsForDisplay.join(', ')}`,
264
+ confirmationDetails: undefined,
265
+ };
266
+ if (Array.isArray(result.llmContent)) {
267
+ const fileContentRegex = /^--- (.*?) ---\n\n([\s\S]*?)\n\n$/;
268
+ processedQueryParts.push({
269
+ text: '\n--- Content from referenced files ---',
270
+ });
271
+ for (const part of result.llmContent) {
272
+ if (typeof part === 'string') {
273
+ const match = fileContentRegex.exec(part);
274
+ if (match) {
275
+ const filePathSpecInContent = match[1]; // This is a resolved pathSpec
276
+ const fileActualContent = match[2].trim();
277
+ processedQueryParts.push({
278
+ text: `\nContent from @${filePathSpecInContent}:\n`,
279
+ });
280
+ processedQueryParts.push({ text: fileActualContent });
281
+ }
282
+ else {
283
+ processedQueryParts.push({ text: part });
284
+ }
285
+ }
286
+ else {
287
+ // part is a Part object.
288
+ processedQueryParts.push(part);
289
+ }
290
+ }
291
+ processedQueryParts.push({ text: '\n--- End of content ---' });
292
+ }
293
+ else {
294
+ onDebugMessage('read_many_files tool returned no content or empty content.');
295
+ }
296
+ addItem({ type: 'tool_group', tools: [toolCallDisplay] }, userMessageTimestamp);
297
+ return { processedQuery: processedQueryParts, shouldProceed: true };
298
+ }
299
+ catch (error) {
300
+ toolCallDisplay = {
301
+ callId: `client-read-${userMessageTimestamp}`,
302
+ name: readManyFilesTool.displayName,
303
+ description: readManyFilesTool.getDescription(toolArgs),
304
+ status: ToolCallStatus.Error,
305
+ resultDisplay: `Error reading files (${contentLabelsForDisplay.join(', ')}): ${getErrorMessage(error)}`,
306
+ confirmationDetails: undefined,
307
+ };
308
+ addItem({ type: 'tool_group', tools: [toolCallDisplay] }, userMessageTimestamp);
309
+ return { processedQuery: null, shouldProceed: false };
310
+ }
311
+ }
312
+ //# sourceMappingURL=atCommandProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atCommandProcessor.js","sourceRoot":"","sources":["../../../../src/ui/hooks/atCommandProcessor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAEL,eAAe,EACf,WAAW,EACX,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAGL,cAAc,GACf,MAAM,aAAa,CAAC;AAsBrB;;;GAGG;AACH,SAAS,kBAAkB,CAAC,KAAa;IACvC,MAAM,KAAK,GAAoB,EAAE,CAAC;IAClC,IAAI,YAAY,GAAG,CAAC,CAAC;I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7C,EACD,oBAAoB,CACrB,CAAC;QACF,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACtE,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,eAAe,GAAG;YAChB,MAAM,EAAE,eAAe,oBAAoB,EAAE;YAC7C,IAAI,EAAE,iBAAiB,CAAC,WAAW;YACnC,WAAW,EAAE,iBAAiB,CAAC,cAAc,CAAC,QAAQ,CAAC;YACvD,MAAM,EAAE,cAAc,CAAC,KAAK;YAC5B,aAAa,EAAE,wBAAwB,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,eAAe,CAAC,KAAK,CAAC,EAAE;YACvG,mBAAmB,EAAE,SAAS;SAC/B,CAAC;QACF,OAAO,CACL,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,eAAe,CAAC,EAG7C,EACD,oBAAoB,CACrB,CAAC;QACF,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IACxD,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { HistoryItemWithoutId } from '../types.js';
7
+ import { Config, GeminiClient } from '@google/gemini-cli-core';
8
+ import { type PartListUnion } from '@google/genai';
9
+ import { UseHistoryManagerReturn } from './useHistoryManager.js';
10
+ /**
11
+ * Hook to process shell commands.
12
+ * Orchestrates command execution and updates history and agent context.
13
+ */
14
+ export declare const useShellCommandProcessor: (addItemToHistory: UseHistoryManagerReturn["addItem"], setPendingHistoryItem: React.Dispatch<React.SetStateAction<HistoryItemWithoutId | null>>, onExec: (command: Promise<void>) => void, onDebugMessage: (message: string) => void, config: Config, geminiClient: GeminiClient) => {
15
+ handleShellCommand: (rawQuery: PartListUnion, abortSignal: AbortSignal) => boolean;
16
+ };
@@ -0,0 +1,261 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { spawn } from 'child_process';
7
+ import { StringDecoder } from 'string_decoder';
8
+ import { useCallback } from 'react';
9
+ import { formatMemoryUsage } from '../utils/formatters.js';
10
+ import { isBinary } from '../utils/textUtils.js';
11
+ import crypto from 'crypto';
12
+ import path from 'path';
13
+ import os from 'os';
14
+ import fs from 'fs';
15
+ import stripAnsi from 'strip-ansi';
16
+ const OUTPUT_UPDATE_INTERVAL_MS = 1000;
17
+ const MAX_OUTPUT_LENGTH = 10000;
18
+ /**
19
+ * Executes a shell command using `spawn`, capturing all output and lifecycle events.
20
+ * This is the single, unified implementation for shell execution.
21
+ *
22
+ * @param commandToExecute The exact command string to run.
23
+ * @param cwd The working directory to execute the command in.
24
+ * @param abortSignal An AbortSignal to terminate the process.
25
+ * @param onOutputChunk A callback for streaming real-time output.
26
+ * @param onDebugMessage A callback for logging debug information.
27
+ * @returns A promise that resolves with the complete execution result.
28
+ */
29
+ function executeShellCommand(commandToExecute, cwd, abortSignal, onOutputChunk, onDebugMessage) {
30
+ return new Promise((resolve) => {
31
+ const isWindows = os.platform() === 'win32';
32
+ const shell = isWindows ? 'cmd.exe' : 'bash';
33
+ const shellArgs = isWindows
34
+ ? ['/c', commandToExecute]
35
+ : ['-c', commandToExecute];
36
+ const child = spawn(shell, shellArgs, {
37
+ cwd,
38
+ stdio: ['ignore', 'pipe', 'pipe'],
39
+ detached: !isWindows, // Use process groups on non-Windows for robust killing
40
+ });
41
+ // Use decoders to handle multi-byte characters safely (for streaming output).
42
+ const stdoutDecoder = new StringDecoder('utf8');
43
+ const stderrDecoder = new StringDecoder('utf8');
44
+ let stdout = '';
45
+ let stderr = '';
46
+ const outputChunks = [];
47
+ let error = null;
48
+ let exited = false;
49
+ let streamToUi = true;
50
+ const MAX_SNIFF_SIZE = 4096;
51
+ let sniffedBytes = 0;
52
+ const handleOutput = (data, stream) => {
53
+ outputChunks.push(data);
54
+ if (streamToUi && sniffedBytes < MAX_SNIFF_SIZE) {
55
+ // Use a limited-size buffer for the check to avoid performance issues.
56
+ const sniffBuffer = Buffer.concat(outputChunks.slice(0, 20));
57
+ sniffedBytes = sniffBuffer.length;
58
+ if (isBinary(sniffBuffer)) {
59
+ streamToUi = false;
60
+ // Overwrite any garbled text that may have streamed with a clear message.
61
+ onOutputChunk('[Binary output detected. Halting stream...]');
62
+ }
63
+ }
64
+ const decodedChunk = stream === 'stdout'
65
+ ? stdoutDecoder.write(data)
66
+ : stderrDecoder.write(data);
67
+ if (stream === 'stdout') {
68
+ stdout += stripAnsi(decodedChunk);
69
+ }
70
+ else {
71
+ stderr += stripAnsi(decodedChunk);
72
+ }
73
+ if (!exited && streamToUi) {
74
+ // Send only the new chunk to avoid re-rendering the whole output.
75
+ const combinedOutput = stdout + (stderr ? `\n${stderr}` : '');
76
+ onOutputChunk(combinedOutput);
77
+ }
78
+ else if (!exited && !streamToUi) {
79
+ // Send progress updates for the binary stream
80
+ const totalBytes = outputChunks.reduce((sum, chunk) => sum + chunk.length, 0);
81
+ onOutputChunk(`[Receiving binary output... ${formatMemoryUsage(totalBytes)} received]`);
82
+ }
83
+ };
84
+ child.stdout.on('data', (data) => handleOutput(data, 'stdout'));
85
+ child.stderr.on('data', (data) => handleOutput(data, 'stderr'));
86
+ child.on('error', (err) => {
87
+ error = err;
88
+ });
89
+ const abortHandler = async () => {
90
+ if (child.pid && !exited) {
91
+ onDebugMessage(`Aborting shell command (PID: ${child.pid})`);
92
+ if (isWindows) {
93
+ spawn('taskkill', ['/pid', child.pid.toString(), '/f', '/t']);
94
+ }
95
+ else {
96
+ try {
97
+ // Kill the entire process group (negative PID).
98
+ // SIGTERM first, then SIGKILL if it doesn't die.
99
+ process.kill(-child.pid, 'SIGTERM');
100
+ await new Promise((res) => setTimeout(res, 200));
101
+ if (!exited) {
102
+ process.kill(-child.pid, 'SIGKILL');
103
+ }
104
+ }
105
+ catch (_e) {
106
+ // Fallback to killing just the main process if group kill fails.
107
+ if (!exited)
108
+ child.kill('SIGKILL');
109
+ }
110
+ }
111
+ }
112
+ };
113
+ abortSignal.addEventListener('abort', abortHandler, { once: true });
114
+ child.on('exit', (code, signal) => {
115
+ exited = true;
116
+ abortSignal.removeEventListener('abort', abortHandler);
117
+ // Handle any final bytes lingering in the decoders
118
+ stdout += stdoutDecoder.end();
119
+ stderr += stderrDecoder.end();
120
+ const finalBuffer = Buffer.concat(outputChunks);
121
+ resolve({
122
+ rawOutput: finalBuffer,
123
+ output: stdout + (stderr ? `\n${stderr}` : ''),
124
+ exitCode: code,
125
+ signal,
126
+ error,
127
+ aborted: abortSignal.aborted,
128
+ });
129
+ });
130
+ });
131
+ }
132
+ function addShellCommandToGeminiHistory(geminiClient, rawQuery, resultText) {
133
+ const modelContent = resultText.length > MAX_OUTPUT_LENGTH
134
+ ? resultText.substring(0, MAX_OUTPUT_LENGTH) + '\n... (truncated)'
135
+ : resultText;
136
+ geminiClient.addHistory({
137
+ role: 'user',
138
+ parts: [
139
+ {
140
+ text: `I ran the following shell command:
141
+ \`\`\`sh
142
+ ${rawQuery}
143
+ \`\`\`
144
+
145
+ This produced the following result:
146
+ \`\`\`
147
+ ${modelContent}
148
+ \`\`\``,
149
+ },
150
+ ],
151
+ });
152
+ }
153
+ /**
154
+ * Hook to process shell commands.
155
+ * Orchestrates command execution and updates history and agent context.
156
+ */
157
+ export const useShellCommandProcessor = (addItemToHistory, setPendingHistoryItem, onExec, onDebugMessage, config, geminiClient) => {
158
+ const handleShellCommand = useCallback((rawQuery, abortSignal) => {
159
+ if (typeof rawQuery !== 'string' || rawQuery.trim() === '') {
160
+ return false;
161
+ }
162
+ const userMessageTimestamp = Date.now();
163
+ addItemToHistory({ type: 'user_shell', text: rawQuery }, userMessageTimestamp);
164
+ const isWindows = os.platform() === 'win32';
165
+ const targetDir = config.getTargetDir();
166
+ let commandToExecute = rawQuery;
167
+ let pwdFilePath;
168
+ // On non-windows, wrap the command to capture the final working directory.
169
+ if (!isWindows) {
170
+ let command = rawQuery.trim();
171
+ const pwdFileName = `shell_pwd_${crypto.randomBytes(6).toString('hex')}.tmp`;
172
+ pwdFilePath = path.join(os.tmpdir(), pwdFileName);
173
+ // Ensure command ends with a separator before adding our own.
174
+ if (!command.endsWith(';') && !command.endsWith('&')) {
175
+ command += ';';
176
+ }
177
+ commandToExecute = `{ ${command} }; __code=$?; pwd > "${pwdFilePath}"; exit $__code`;
178
+ }
179
+ const execPromise = new Promise((resolve) => {
180
+ let lastUpdateTime = 0;
181
+ onDebugMessage(`Executing in ${targetDir}: ${commandToExecute}`);
182
+ executeShellCommand(commandToExecute, targetDir, abortSignal, (streamedOutput) => {
183
+ // Throttle pending UI updates to avoid excessive re-renders.
184
+ if (Date.now() - lastUpdateTime > OUTPUT_UPDATE_INTERVAL_MS) {
185
+ setPendingHistoryItem({ type: 'info', text: streamedOutput });
186
+ lastUpdateTime = Date.now();
187
+ }
188
+ }, onDebugMessage)
189
+ .then((result) => {
190
+ // TODO(abhipatel12) - Consider updating pending item and using timeout to ensure
191
+ // there is no jump where intermediate output is skipped.
192
+ setPendingHistoryItem(null);
193
+ let historyItemType = 'info';
194
+ let mainContent;
195
+ // The context sent to the model utilizes a text tokenizer which means raw binary data is
196
+ // cannot be parsed and understood and thus would only pollute the context window and waste
197
+ // tokens.
198
+ if (isBinary(result.rawOutput)) {
199
+ mainContent =
200
+ '[Command produced binary output, which is not shown.]';
201
+ }
202
+ else {
203
+ mainContent =
204
+ result.output.trim() || '(Command produced no output)';
205
+ }
206
+ let finalOutput = mainContent;
207
+ if (result.error) {
208
+ historyItemType = 'error';
209
+ finalOutput = `${result.error.message}\n${finalOutput}`;
210
+ }
211
+ else if (result.aborted) {
212
+ finalOutput = `Command was cancelled.\n${finalOutput}`;
213
+ }
214
+ else if (result.signal) {
215
+ historyItemType = 'error';
216
+ finalOutput = `Command terminated by signal: ${result.signal}.\n${finalOutput}`;
217
+ }
218
+ else if (result.exitCode !== 0) {
219
+ historyItemType = 'error';
220
+ finalOutput = `Command exited with code ${result.exitCode}.\n${finalOutput}`;
221
+ }
222
+ if (pwdFilePath && fs.existsSync(pwdFilePath)) {
223
+ const finalPwd = fs.readFileSync(pwdFilePath, 'utf8').trim();
224
+ if (finalPwd && finalPwd !== targetDir) {
225
+ const warning = `WARNING: shell mode is stateless; the directory change to '${finalPwd}' will not persist.`;
226
+ finalOutput = `${warning}\n\n${finalOutput}`;
227
+ }
228
+ }
229
+ // Add the complete, contextual result to the local UI history.
230
+ addItemToHistory({ type: historyItemType, text: finalOutput }, userMessageTimestamp);
231
+ // Add the same complete, contextual result to the LLM's history.
232
+ addShellCommandToGeminiHistory(geminiClient, rawQuery, finalOutput);
233
+ })
234
+ .catch((err) => {
235
+ setPendingHistoryItem(null);
236
+ const errorMessage = err instanceof Error ? err.message : String(err);
237
+ addItemToHistory({
238
+ type: 'error',
239
+ text: `An unexpected error occurred: ${errorMessage}`,
240
+ }, userMessageTimestamp);
241
+ })
242
+ .finally(() => {
243
+ if (pwdFilePath && fs.existsSync(pwdFilePath)) {
244
+ fs.unlinkSync(pwdFilePath);
245
+ }
246
+ resolve();
247
+ });
248
+ });
249
+ onExec(execPromise);
250
+ return true; // Command was initiated
251
+ }, [
252
+ config,
253
+ onDebugMessage,
254
+ addItemToHistory,
255
+ setPendingHistoryItem,
256
+ onExec,
257
+ geminiClient,
258
+ ]);
259
+ return { handleShellCommand };
260
+ };
261
+ //# sourceMappingURL=shellCommandProcessor.js.map