@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,922 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { useCallback, useMemo } from 'react';
7
+ import open from 'open';
8
+ import process from 'node:process';
9
+ import { useStateAndRef } from './useStateAndRef.js';
10
+ import { GitService, Logger, MCPDiscoveryState, MCPServerStatus, getMCPDiscoveryState, getMCPServerStatus, } from '@google/gemini-cli-core';
11
+ import { useSessionStats } from '../contexts/SessionContext.js';
12
+ import { MessageType, } from '../types.js';
13
+ import { promises as fs } from 'fs';
14
+ import path from 'path';
15
+ import { createShowMemoryAction } from './useShowMemoryCommand.js';
16
+ import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
17
+ import { formatDuration, formatMemoryUsage } from '../utils/formatters.js';
18
+ import { getCliVersion } from '../../utils/version.js';
19
+ /**
20
+ * Hook to define and process slash commands (e.g., /help, /clear).
21
+ */
22
+ export const useSlashCommandProcessor = (config, settings, history, addItem, clearItems, loadHistory, refreshStatic, setShowHelp, onDebugMessage, openThemeDialog, openAuthDialog, openEditorDialog, performMemoryRefresh, toggleCorgiMode, showToolDescriptions = false, setQuittingMessages) => {
23
+ const session = useSessionStats();
24
+ const gitService = useMemo(() => {
25
+ if (!config?.getProjectRoot()) {
26
+ return;
27
+ }
28
+ return new GitService(config.getProjectRoot());
29
+ }, [config]);
30
+ const pendingHistoryItems = [];
31
+ const [pendingCompressionItemRef, setPendingCompressionItem] = useStateAndRef(null);
32
+ if (pendingCompressionItemRef.current != null) {
33
+ pendingHistoryItems.push(pendingCompressionItemRef.current);
34
+ }
35
+ const addMessage = useCallback((message) => {
36
+ // Convert Message to HistoryItemWithoutId
37
+ let historyItemContent;
38
+ if (message.type === MessageType.ABOUT) {
39
+ historyItemContent = {
40
+ type: 'about',
41
+ cliVersion: message.cliVersion,
42
+ osVersion: message.osVersion,
43
+ sandboxEnv: message.sandboxEnv,
44
+ modelVersion: message.modelVersion,
45
+ };
46
+ }
47
+ else if (message.type === MessageType.STATS) {
48
+ historyItemContent = {
49
+ type: 'stats',
50
+ stats: message.stats,
51
+ lastTurnStats: message.lastTurnStats,
52
+ duration: message.duration,
53
+ };
54
+ }
55
+ else if (message.type === MessageType.QUIT) {
56
+ historyItemContent = {
57
+ type: 'quit',
58
+ stats: message.stats,
59
+ duration: message.duration,
60
+ };
61
+ }
62
+ else if (message.type === MessageType.COMPRESSION) {
63
+ historyItemContent = {
64
+ type: 'compression',
65
+ compression: message.compression,
66
+ };
67
+ }
68
+ else {
69
+ historyItemContent = {
70
+ type: message.type,
71
+ text: message.content,
72
+ };
73
+ }
74
+ addItem(historyItemContent, message.timestamp.getTime());
75
+ }, [addItem]);
76
+ const showMemoryAction = useCallback(async () => {
77
+ const actionFn = createShowMemoryAction(config, settings, addMessage);
78
+ await actionFn();
79
+ }, [config, settings, addMessage]);
80
+ const addMemoryAction = useCallback((_mainCommand, _subCommand, args) => {
81
+ if (!args || args.trim() === '') {
82
+ addMessage({
83
+ type: MessageType.ERROR,
84
+ content: 'Usage: /memory add <text to remember>',
85
+ timestamp: new Date(),
86
+ });
87
+ return;
88
+ }
89
+ // UI feedback for attempting to schedule
90
+ addMessage({
91
+ type: MessageType.INFO,
92
+ content: `Attempting to save to memory: "${args.trim()}"`,
93
+ timestamp: new Date(),
94
+ });
95
+ // Return info for scheduling the tool call
96
+ return {
97
+ shouldScheduleTool: true,
98
+ toolName: 'save_memory',
99
+ toolArgs: { fact: args.trim() },
100
+ };
101
+ }, [addMessage]);
102
+ const savedChatTags = useCallback(async () => {
103
+ const geminiDir = config?.getProjectTempDir();
104
+ if (!geminiDir) {
105
+ return [];
106
+ }
107
+ try {
108
+ const files = await fs.readdir(geminiDir);
109
+ return files
110
+ .filter((file) => file.startsWith('checkpoint-') && file.endsWith('.json'))
111
+ .map((file) => file.replace('checkpoint-', '').replace('.json', ''));
112
+ }
113
+ catch (_err) {
114
+ return [];
115
+ }
116
+ }, [config]);
117
+ const slashCommands = useMemo(() => {
118
+ const commands = [
119
+ {
120
+ name: 'help',
121
+ altName: '?',
122
+ description: 'for help on gemini-cli',
123
+ action: (_mainCommand, _subCommand, _args) => {
124
+ onDebugMessage('Opening help.');
125
+ setShowHelp(true);
126
+ },
127
+ },
128
+ {
129
+ name: 'docs',
130
+ description: 'open full Gemini CLI documentation in your browser',
131
+ action: async (_mainCommand, _subCommand, _args) => {
132
+ const docsUrl = 'https://goo.gle/gemini-cli-docs';
133
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
134
+ addMessage({
135
+ type: MessageType.INFO,
136
+ content: `Please open the following URL in your browser to view the documentation:\n${docsUrl}`,
137
+ timestamp: new Date(),
138
+ });
139
+ }
140
+ else {
141
+ addMessage({
142
+ type: MessageType.INFO,
143
+ content: `Opening documentation in your browser: ${docsUrl}`,
144
+ timestamp: new Date(),
145
+ });
146
+ await open(docsUrl);
147
+ }
148
+ },
149
+ },
150
+ {
151
+ name: 'clear',
152
+ description: 'clear the screen and conversation history',
153
+ action: async (_mainCommand, _subCommand, _args) => {
154
+ onDebugMessage('Clearing terminal and resetting chat.');
155
+ clearItems();
156
+ await config?.getGeminiClient()?.resetChat();
157
+ console.clear();
158
+ refreshStatic();
159
+ },
160
+ },
161
+ {
162
+ name: 'theme',
163
+ description: 'change the theme',
164
+ action: (_mainCommand, _subCommand, _args) => {
165
+ openThemeDialog();
166
+ },
167
+ },
168
+ {
169
+ name: 'auth',
170
+ description: 'change the auth method',
171
+ action: (_mainCommand, _subCommand, _args) => {
172
+ openAuthDialog();
173
+ },
174
+ },
175
+ {
176
+ name: 'editor',
177
+ description: 'set external editor preference',
178
+ action: (_mainCommand, _subCommand, _args) => {
179
+ openEditorDialog();
180
+ },
181
+ },
182
+ {
183
+ name: 'stats',
184
+ altName: 'usage',
185
+ description: 'check session stats',
186
+ action: (_mainCommand, _subCommand, _args) => {
187
+ const now = new Date();
188
+ const { sessionStartTime, cumulative, currentTurn } = session.stats;
189
+ const wallDuration = now.getTime() - sessionStartTime.getTime();
190
+ addMessage({
191
+ type: MessageType.STATS,
192
+ stats: cumulative,
193
+ lastTurnStats: currentTurn,
194
+ duration: formatDuration(wallDuration),
195
+ timestamp: new Date(),
196
+ });
197
+ },
198
+ },
199
+ {
200
+ name: 'mcp',
201
+ description: 'list configured MCP servers and tools',
202
+ action: async (_mainCommand, _subCommand, _args) => {
203
+ // Check if the _subCommand includes a specific flag to control description visibility
204
+ let useShowDescriptions = showToolDescriptions;
205
+ if (_subCommand === 'desc' || _subCommand === 'descriptions') {
206
+ useShowDescriptions = true;
207
+ }
208
+ else if (_subCommand === 'nodesc' ||
209
+ _subCommand === 'nodescriptions') {
210
+ useShowDescriptions = false;
211
+ }
212
+ else if (_args === 'desc' || _args === 'descriptions') {
213
+ useShowDescriptions = true;
214
+ }
215
+ else if (_args === 'nodesc' || _args === 'nodescriptions') {
216
+ useShowDescriptions = false;
217
+ }
218
+ // Check if the _subCommand includes a specific flag to show detailed tool schema
219
+ let useShowSchema = false;
220
+ if (_subCommand === 'schema' || _args === 'schema') {
221
+ useShowSchema = true;
222
+ }
223
+ const toolRegistry = await config?.getToolRegistry();
224
+ if (!toolRegistry) {
225
+ addMessage({
226
+ type: MessageType.ERROR,
227
+ content: 'Could not retrieve tool registry.',
228
+ timestamp: new Date(),
229
+ });
230
+ return;
231
+ }
232
+ const mcpServers = config?.getMcpServers() || {};
233
+ const serverNames = Object.keys(mcpServers);
234
+ if (serverNames.length === 0) {
235
+ const docsUrl = 'https://goo.gle/gemini-cli-docs-mcp';
236
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
237
+ addMessage({
238
+ type: MessageType.INFO,
239
+ content: `No MCP servers configured. Please open the following URL in your browser to view documentation:\n${docsUrl}`,
240
+ timestamp: new Date(),
241
+ });
242
+ }
243
+ else {
244
+ addMessage({
245
+ type: MessageType.INFO,
246
+ content: `No MCP servers configured. Opening documentation in your browser: ${docsUrl}`,
247
+ timestamp: new Date(),
248
+ });
249
+ await open(docsUrl);
250
+ }
251
+ return;
252
+ }
253
+ // Check if any servers are still connecting
254
+ const connectingServers = serverNames.filter((name) => getMCPServerStatus(name) === MCPServerStatus.CONNECTING);
255
+ const discoveryState = getMCPDiscoveryState();
256
+ let message = '';
257
+ // Add overall discovery status message if needed
258
+ if (discoveryState === MCPDiscoveryState.IN_PROGRESS ||
259
+ connectingServers.length > 0) {
260
+ message += `\u001b[33m⏳ MCP servers are starting up (${connectingServers.length} initializing)...\u001b[0m\n`;
261
+ message += `\u001b[90mNote: First startup may take longer. Tool availability will update automatically.\u001b[0m\n\n`;
262
+ }
263
+ message += 'Configured MCP servers:\n\n';
264
+ for (const serverName of serverNames) {
265
+ const serverTools = toolRegistry.getToolsByServer(serverName);
266
+ const status = getMCPServerStatus(serverName);
267
+ // Add status indicator with descriptive text
268
+ let statusIndicator = '';
269
+ let statusText = '';
270
+ switch (status) {
271
+ case MCPServerStatus.CONNECTED:
272
+ statusIndicator = '🟢';
273
+ statusText = 'Ready';
274
+ break;
275
+ case MCPServerStatus.CONNECTING:
276
+ statusIndicator = '🔄';
277
+ statusText = 'Starting... (first startup may take longer)';
278
+ break;
279
+ case MCPServerStatus.DISCONNECTED:
280
+ default:
281
+ statusIndicator = '🔴';
282
+ statusText = 'Disconnected';
283
+ break;
284
+ }
285
+ // Get server description if available
286
+ const server = mcpServers[serverName];
287
+ // Format server header with bold formatting and status
288
+ message += `${statusIndicator} \u001b[1m${serverName}\u001b[0m - ${statusText}`;
289
+ // Add tool count with conditional messaging
290
+ if (status === MCPServerStatus.CONNECTED) {
291
+ message += ` (${serverTools.length} tools)`;
292
+ }
293
+ else if (status === MCPServerStatus.CONNECTING) {
294
+ message += ` (tools will appear when ready)`;
295
+ }
296
+ else {
297
+ message += ` (${serverTools.length} tools cached)`;
298
+ }
299
+ // Add server description with proper handling of multi-line descriptions
300
+ if ((useShowDescriptions || useShowSchema) && server?.description) {
301
+ const greenColor = '\u001b[32m';
302
+ const resetColor = '\u001b[0m';
303
+ const descLines = server.description.trim().split('\n');
304
+ if (descLines) {
305
+ message += ':\n';
306
+ for (let i = 0; i < descLines.length; i++) {
307
+ message += ` ${greenColor}${descLines[i]}${resetColor}\n`;
308
+ }
309
+ }
310
+ else {
311
+ message += '\n';
312
+ }
313
+ }
314
+ else {
315
+ message += '\n';
316
+ }
317
+ // Reset formatting after server entry
318
+ message += '\u001b[0m';
319
+ if (serverTools.length > 0) {
320
+ serverTools.forEach((tool) => {
321
+ if ((useShowDescriptions || useShowSchema) &&
322
+ tool.description) {
323
+ // Format tool name in cyan using simple ANSI cyan color
324
+ message += ` - \u001b[36m${tool.name}\u001b[0m`;
325
+ // Apply green color to the description text
326
+ const greenColor = '\u001b[32m';
327
+ const resetColor = '\u001b[0m';
328
+ // Handle multi-line descriptions by properly indenting and preserving formatting
329
+ const descLines = tool.description.trim().split('\n');
330
+ if (descLines) {
331
+ message += ':\n';
332
+ for (let i = 0; i < descLines.length; i++) {
333
+ message += ` ${greenColor}${descLines[i]}${resetColor}\n`;
334
+ }
335
+ }
336
+ else {
337
+ message += '\n';
338
+ }
339
+ // Reset is handled inline with each line now
340
+ }
341
+ else {
342
+ // Use cyan color for the tool name even when not showing descriptions
343
+ message += ` - \u001b[36m${tool.name}\u001b[0m\n`;
344
+ }
345
+ if (useShowSchema) {
346
+ // Prefix the parameters in cyan
347
+ message += ` \u001b[36mParameters:\u001b[0m\n`;
348
+ // Apply green color to the parameter text
349
+ const greenColor = '\u001b[32m';
350
+ const resetColor = '\u001b[0m';
351
+ const paramsLines = JSON.stringify(tool.schema.parameters, null, 2)
352
+ .trim()
353
+ .split('\n');
354
+ if (paramsLines) {
355
+ for (let i = 0; i < paramsLines.length; i++) {
356
+ message += ` ${greenColor}${paramsLines[i]}${resetColor}\n`;
357
+ }
358
+ }
359
+ }
360
+ });
361
+ }
362
+ else {
363
+ message += ' No tools available\n';
364
+ }
365
+ message += '\n';
366
+ }
367
+ // Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
368
+ message += '\u001b[0m';
369
+ addMessage({
370
+ type: MessageType.INFO,
371
+ content: message,
372
+ timestamp: new Date(),
373
+ });
374
+ },
375
+ },
376
+ {
377
+ name: 'memory',
378
+ description: 'manage memory. Usage: /memory <show|refresh|add> [text for add]',
379
+ action: (mainCommand, subCommand, args) => {
380
+ switch (subCommand) {
381
+ case 'show':
382
+ showMemoryAction();
383
+ return; // Explicitly return void
384
+ case 'refresh':
385
+ performMemoryRefresh();
386
+ return; // Explicitly return void
387
+ case 'add':
388
+ return addMemoryAction(mainCommand, subCommand, args); // Return the object
389
+ default:
390
+ addMessage({
391
+ type: MessageType.ERROR,
392
+ content: `Unknown /memory command: ${subCommand}. Available: show, refresh, add`,
393
+ timestamp: new Date(),
394
+ });
395
+ return; // Explicitly return void
396
+ }
397
+ },
398
+ },
399
+ {
400
+ name: 'tools',
401
+ description: 'list available Gemini CLI tools',
402
+ action: async (_mainCommand, _subCommand, _args) => {
403
+ // Check if the _subCommand includes a specific flag to control description visibility
404
+ let useShowDescriptions = showToolDescriptions;
405
+ if (_subCommand === 'desc' || _subCommand === 'descriptions') {
406
+ useShowDescriptions = true;
407
+ }
408
+ else if (_subCommand === 'nodesc' ||
409
+ _subCommand === 'nodescriptions') {
410
+ useShowDescriptions = false;
411
+ }
412
+ else if (_args === 'desc' || _args === 'descriptions') {
413
+ useShowDescriptions = true;
414
+ }
415
+ else if (_args === 'nodesc' || _args === 'nodescriptions') {
416
+ useShowDescriptions = false;
417
+ }
418
+ const toolRegistry = await config?.getToolRegistry();
419
+ const tools = toolRegistry?.getAllTools();
420
+ if (!tools) {
421
+ addMessage({
422
+ type: MessageType.ERROR,
423
+ content: 'Could not retrieve tools.',
424
+ timestamp: new Date(),
425
+ });
426
+ return;
427
+ }
428
+ // Filter out MCP tools by checking if they have a serverName property
429
+ const geminiTools = tools.filter((tool) => !('serverName' in tool));
430
+ let message = 'Available Gemini CLI tools:\n\n';
431
+ if (geminiTools.length > 0) {
432
+ geminiTools.forEach((tool) => {
433
+ if (useShowDescriptions && tool.description) {
434
+ // Format tool name in cyan using simple ANSI cyan color
435
+ message += ` - \u001b[36m${tool.displayName} (${tool.name})\u001b[0m:\n`;
436
+ // Apply green color to the description text
437
+ const greenColor = '\u001b[32m';
438
+ const resetColor = '\u001b[0m';
439
+ // Handle multi-line descriptions by properly indenting and preserving formatting
440
+ const descLines = tool.description.trim().split('\n');
441
+ // If there are multiple lines, add proper indentation for each line
442
+ if (descLines) {
443
+ for (let i = 0; i < descLines.length; i++) {
444
+ message += ` ${greenColor}${descLines[i]}${resetColor}\n`;
445
+ }
446
+ }
447
+ }
448
+ else {
449
+ // Use cyan color for the tool name even when not showing descriptions
450
+ message += ` - \u001b[36m${tool.displayName}\u001b[0m\n`;
451
+ }
452
+ });
453
+ }
454
+ else {
455
+ message += ' No tools available\n';
456
+ }
457
+ message += '\n';
458
+ // Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
459
+ message += '\u001b[0m';
460
+ addMessage({
461
+ type: MessageType.INFO,
462
+ content: message,
463
+ timestamp: new Date(),
464
+ });
465
+ },
466
+ },
467
+ {
468
+ name: 'corgi',
469
+ action: (_mainCommand, _subCommand, _args) => {
470
+ toggleCorgiMode();
471
+ },
472
+ },
473
+ {
474
+ name: 'about',
475
+ description: 'show version info',
476
+ action: async (_mainCommand, _subCommand, _args) => {
477
+ const osVersion = process.platform;
478
+ let sandboxEnv = 'no sandbox';
479
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
480
+ sandboxEnv = process.env.SANDBOX;
481
+ }
482
+ else if (process.env.SANDBOX === 'sandbox-exec') {
483
+ sandboxEnv = `sandbox-exec (${process.env.SEATBELT_PROFILE || 'unknown'})`;
484
+ }
485
+ const modelVersion = config?.getModel() || 'Unknown';
486
+ const cliVersion = await getCliVersion();
487
+ addMessage({
488
+ type: MessageType.ABOUT,
489
+ timestamp: new Date(),
490
+ cliVersion,
491
+ osVersion,
492
+ sandboxEnv,
493
+ modelVersion,
494
+ });
495
+ },
496
+ },
497
+ {
498
+ name: 'bug',
499
+ description: 'submit a bug report',
500
+ action: async (_mainCommand, _subCommand, args) => {
501
+ let bugDescription = _subCommand || '';
502
+ if (args) {
503
+ bugDescription += ` ${args}`;
504
+ }
505
+ bugDescription = bugDescription.trim();
506
+ const osVersion = `${process.platform} ${process.version}`;
507
+ let sandboxEnv = 'no sandbox';
508
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
509
+ sandboxEnv = process.env.SANDBOX.replace(/^gemini-(?:code-)?/, '');
510
+ }
511
+ else if (process.env.SANDBOX === 'sandbox-exec') {
512
+ sandboxEnv = `sandbox-exec (${process.env.SEATBELT_PROFILE || 'unknown'})`;
513
+ }
514
+ const modelVersion = config?.getModel() || 'Unknown';
515
+ const cliVersion = await getCliVersion();
516
+ const memoryUsage = formatMemoryUsage(process.memoryUsage().rss);
517
+ const diagnosticInfo = `
518
+ ## Describe the bug
519
+ A clear and concise description of what the bug is.
520
+
521
+ ## Additional context
522
+ Add any other context about the problem here.
523
+
524
+ ## Diagnostic Information
525
+ * **CLI Version:** ${cliVersion}
526
+ * **Git Commit:** ${GIT_COMMIT_INFO}
527
+ * **Operating System:** ${osVersion}
528
+ * **Sandbox Environment:** ${sandboxEnv}
529
+ * **Model Version:** ${modelVersion}
530
+ * **Memory Usage:** ${memoryUsage}
531
+ `;
532
+ let bugReportUrl = 'https://github.com/google-gemini/gemini-cli/issues/new?template=bug_report.md&title={title}&body={body}';
533
+ const bugCommand = config?.getBugCommand();
534
+ if (bugCommand?.urlTemplate) {
535
+ bugReportUrl = bugCommand.urlTemplate;
536
+ }
537
+ bugReportUrl = bugReportUrl
538
+ .replace('{title}', encodeURIComponent(bugDescription))
539
+ .replace('{body}', encodeURIComponent(diagnosticInfo));
540
+ addMessage({
541
+ type: MessageType.INFO,
542
+ content: `To submit your bug report, please open the following URL in your browser:\n${bugReportUrl}`,
543
+ timestamp: new Date(),
544
+ });
545
+ (async () => {
546
+ try {
547
+ await open(bugReportUrl);
548
+ }
549
+ catch (error) {
550
+ const errorMessage = error instanceof Error ? error.message : String(error);
551
+ addMessage({
552
+ type: MessageType.ERROR,
553
+ content: `Could not open URL in browser: ${errorMessage}`,
554
+ timestamp: new Date(),
555
+ });
556
+ }
557
+ })();
558
+ },
559
+ },
560
+ {
561
+ name: 'chat',
562
+ description: 'Manage conversation history. Usage: /chat <list|save|resume> [tag]',
563
+ action: async (_mainCommand, subCommand, args) => {
564
+ const tag = (args || '').trim();
565
+ const logger = new Logger(config?.getSessionId() || '');
566
+ await logger.initialize();
567
+ const chat = await config?.getGeminiClient()?.getChat();
568
+ if (!chat) {
569
+ addMessage({
570
+ type: MessageType.ERROR,
571
+ content: 'No chat client available for conversation status.',
572
+ timestamp: new Date(),
573
+ });
574
+ return;
575
+ }
576
+ switch (subCommand) {
577
+ case 'save': {
578
+ const history = chat.getHistory();
579
+ if (history.length > 0) {
580
+ await logger.saveCheckpoint(chat?.getHistory() || [], tag);
581
+ addMessage({
582
+ type: MessageType.INFO,
583
+ content: `Conversation checkpoint saved${tag ? ' with tag: ' + tag : ''}.`,
584
+ timestamp: new Date(),
585
+ });
586
+ }
587
+ else {
588
+ addMessage({
589
+ type: MessageType.INFO,
590
+ content: 'No conversation found to save.',
591
+ timestamp: new Date(),
592
+ });
593
+ }
594
+ return;
595
+ }
596
+ case 'resume':
597
+ case 'restore':
598
+ case 'load': {
599
+ const conversation = await logger.loadCheckpoint(tag);
600
+ if (conversation.length === 0) {
601
+ addMessage({
602
+ type: MessageType.INFO,
603
+ content: `No saved checkpoint found${tag ? ' with tag: ' + tag : ''}.`,
604
+ timestamp: new Date(),
605
+ });
606
+ return;
607
+ }
608
+ clearItems();
609
+ chat.clearHistory();
610
+ const rolemap = {
611
+ user: MessageType.USER,
612
+ model: MessageType.GEMINI,
613
+ };
614
+ let hasSystemPrompt = false;
615
+ let i = 0;
616
+ for (const item of conversation) {
617
+ i += 1;
618
+ const text = item.parts
619
+ ?.filter((m) => !!m.text)
620
+ .map((m) => m.text)
621
+ .join('') || '';
622
+ if (!text) {
623
+ // Parsing Part[] back to various non-text output not yet implemented.
624
+ continue;
625
+ }
626
+ chat.addHistory(item);
627
+ if (i === 1 && text.match(/context for our chat/)) {
628
+ hasSystemPrompt = true;
629
+ }
630
+ if (i > 2 || !hasSystemPrompt) {
631
+ addItem({
632
+ type: (item.role && rolemap[item.role]) || MessageType.GEMINI,
633
+ text,
634
+ }, i);
635
+ }
636
+ }
637
+ console.clear();
638
+ refreshStatic();
639
+ return;
640
+ }
641
+ case 'list':
642
+ addMessage({
643
+ type: MessageType.INFO,
644
+ content: 'list of saved conversations: ' +
645
+ (await savedChatTags()).join(', '),
646
+ timestamp: new Date(),
647
+ });
648
+ return;
649
+ default:
650
+ addMessage({
651
+ type: MessageType.ERROR,
652
+ content: `Unknown /chat command: ${subCommand}. Available: list, save, resume`,
653
+ timestamp: new Date(),
654
+ });
655
+ return;
656
+ }
657
+ },
658
+ completion: async () => (await savedChatTags()).map((tag) => 'resume ' + tag),
659
+ },
660
+ {
661
+ name: 'quit',
662
+ altName: 'exit',
663
+ description: 'exit the cli',
664
+ action: async (mainCommand, _subCommand, _args) => {
665
+ const now = new Date();
666
+ const { sessionStartTime, cumulative } = session.stats;
667
+ const wallDuration = now.getTime() - sessionStartTime.getTime();
668
+ setQuittingMessages([
669
+ {
670
+ type: 'user',
671
+ text: `/${mainCommand}`,
672
+ id: now.getTime() - 1,
673
+ },
674
+ {
675
+ type: 'quit',
676
+ stats: cumulative,
677
+ duration: formatDuration(wallDuration),
678
+ id: now.getTime(),
679
+ },
680
+ ]);
681
+ setTimeout(() => {
682
+ process.exit(0);
683
+ }, 100);
684
+ },
685
+ },
686
+ {
687
+ name: 'compress',
688
+ altName: 'summarize',
689
+ description: 'Compresses the context by replacing it with a summary.',
690
+ action: async (_mainCommand, _subCommand, _args) => {
691
+ if (pendingCompressionItemRef.current !== null) {
692
+ addMessage({
693
+ type: MessageType.ERROR,
694
+ content: 'Already compressing, wait for previous request to complete',
695
+ timestamp: new Date(),
696
+ });
697
+ return;
698
+ }
699
+ setPendingCompressionItem({
700
+ type: MessageType.COMPRESSION,
701
+ compression: {
702
+ isPending: true,
703
+ originalTokenCount: null,
704
+ newTokenCount: null,
705
+ },
706
+ });
707
+ try {
708
+ const compressed = await config
709
+ .getGeminiClient()
710
+ .tryCompressChat(true);
711
+ if (compressed) {
712
+ addMessage({
713
+ type: MessageType.COMPRESSION,
714
+ compression: {
715
+ isPending: false,
716
+ originalTokenCount: compressed.originalTokenCount,
717
+ newTokenCount: compressed.newTokenCount,
718
+ },
719
+ timestamp: new Date(),
720
+ });
721
+ }
722
+ else {
723
+ addMessage({
724
+ type: MessageType.ERROR,
725
+ content: 'Failed to compress chat history.',
726
+ timestamp: new Date(),
727
+ });
728
+ }
729
+ }
730
+ catch (e) {
731
+ addMessage({
732
+ type: MessageType.ERROR,
733
+ content: `Failed to compress chat history: ${e instanceof Error ? e.message : String(e)}`,
734
+ timestamp: new Date(),
735
+ });
736
+ }
737
+ setPendingCompressionItem(null);
738
+ },
739
+ },
740
+ ];
741
+ if (config?.getCheckpointingEnabled()) {
742
+ commands.push({
743
+ name: 'restore',
744
+ description: 'restore a tool call. This will reset the conversation and file history to the state it was in when the tool call was suggested',
745
+ completion: async () => {
746
+ const checkpointDir = config?.getProjectTempDir()
747
+ ? path.join(config.getProjectTempDir(), 'checkpoints')
748
+ : undefined;
749
+ if (!checkpointDir) {
750
+ return [];
751
+ }
752
+ try {
753
+ const files = await fs.readdir(checkpointDir);
754
+ return files
755
+ .filter((file) => file.endsWith('.json'))
756
+ .map((file) => file.replace('.json', ''));
757
+ }
758
+ catch (_err) {
759
+ return [];
760
+ }
761
+ },
762
+ action: async (_mainCommand, subCommand, _args) => {
763
+ const checkpointDir = config?.getProjectTempDir()
764
+ ? path.join(config.getProjectTempDir(), 'checkpoints')
765
+ : undefined;
766
+ if (!checkpointDir) {
767
+ addMessage({
768
+ type: MessageType.ERROR,
769
+ content: 'Could not determine the .gemini directory path.',
770
+ timestamp: new Date(),
771
+ });
772
+ return;
773
+ }
774
+ try {
775
+ // Ensure the directory exists before trying to read it.
776
+ await fs.mkdir(checkpointDir, { recursive: true });
777
+ const files = await fs.readdir(checkpointDir);
778
+ const jsonFiles = files.filter((file) => file.endsWith('.json'));
779
+ if (!subCommand) {
780
+ if (jsonFiles.length === 0) {
781
+ addMessage({
782
+ type: MessageType.INFO,
783
+ content: 'No restorable tool calls found.',
784
+ timestamp: new Date(),
785
+ });
786
+ return;
787
+ }
788
+ const truncatedFiles = jsonFiles.map((file) => {
789
+ const components = file.split('.');
790
+ if (components.length <= 1) {
791
+ return file;
792
+ }
793
+ components.pop();
794
+ return components.join('.');
795
+ });
796
+ const fileList = truncatedFiles.join('\n');
797
+ addMessage({
798
+ type: MessageType.INFO,
799
+ content: `Available tool calls to restore:\n\n${fileList}`,
800
+ timestamp: new Date(),
801
+ });
802
+ return;
803
+ }
804
+ const selectedFile = subCommand.endsWith('.json')
805
+ ? subCommand
806
+ : `${subCommand}.json`;
807
+ if (!jsonFiles.includes(selectedFile)) {
808
+ addMessage({
809
+ type: MessageType.ERROR,
810
+ content: `File not found: ${selectedFile}`,
811
+ timestamp: new Date(),
812
+ });
813
+ return;
814
+ }
815
+ const filePath = path.join(checkpointDir, selectedFile);
816
+ const data = await fs.readFile(filePath, 'utf-8');
817
+ const toolCallData = JSON.parse(data);
818
+ if (toolCallData.history) {
819
+ loadHistory(toolCallData.history);
820
+ }
821
+ if (toolCallData.clientHistory) {
822
+ await config
823
+ ?.getGeminiClient()
824
+ ?.setHistory(toolCallData.clientHistory);
825
+ }
826
+ if (toolCallData.commitHash) {
827
+ await gitService?.restoreProjectFromSnapshot(toolCallData.commitHash);
828
+ addMessage({
829
+ type: MessageType.INFO,
830
+ content: `Restored project to the state before the tool call.`,
831
+ timestamp: new Date(),
832
+ });
833
+ }
834
+ return {
835
+ shouldScheduleTool: true,
836
+ toolName: toolCallData.toolCall.name,
837
+ toolArgs: toolCallData.toolCall.args,
838
+ };
839
+ }
840
+ catch (error) {
841
+ addMessage({
842
+ type: MessageType.ERROR,
843
+ content: `Could not read restorable tool calls. This is the error: ${error}`,
844
+ timestamp: new Date(),
845
+ });
846
+ }
847
+ },
848
+ });
849
+ }
850
+ return commands;
851
+ }, [
852
+ onDebugMessage,
853
+ setShowHelp,
854
+ refreshStatic,
855
+ openThemeDialog,
856
+ openAuthDialog,
857
+ openEditorDialog,
858
+ clearItems,
859
+ performMemoryRefresh,
860
+ showMemoryAction,
861
+ addMemoryAction,
862
+ addMessage,
863
+ toggleCorgiMode,
864
+ savedChatTags,
865
+ config,
866
+ showToolDescriptions,
867
+ session,
868
+ gitService,
869
+ loadHistory,
870
+ addItem,
871
+ setQuittingMessages,
872
+ pendingCompressionItemRef,
873
+ setPendingCompressionItem,
874
+ ]);
875
+ const handleSlashCommand = useCallback(async (rawQuery) => {
876
+ if (typeof rawQuery !== 'string') {
877
+ return false;
878
+ }
879
+ const trimmed = rawQuery.trim();
880
+ if (!trimmed.startsWith('/') && !trimmed.startsWith('?')) {
881
+ return false;
882
+ }
883
+ const userMessageTimestamp = Date.now();
884
+ if (trimmed !== '/quit' && trimmed !== '/exit') {
885
+ addItem({ type: MessageType.USER, text: trimmed }, userMessageTimestamp);
886
+ }
887
+ let subCommand;
888
+ let args;
889
+ const commandToMatch = (() => {
890
+ if (trimmed.startsWith('?')) {
891
+ return 'help';
892
+ }
893
+ const parts = trimmed.substring(1).trim().split(/\s+/);
894
+ if (parts.length > 1) {
895
+ subCommand = parts[1];
896
+ }
897
+ if (parts.length > 2) {
898
+ args = parts.slice(2).join(' ');
899
+ }
900
+ return parts[0];
901
+ })();
902
+ const mainCommand = commandToMatch;
903
+ for (const cmd of slashCommands) {
904
+ if (mainCommand === cmd.name || mainCommand === cmd.altName) {
905
+ const actionResult = await cmd.action(mainCommand, subCommand, args);
906
+ if (typeof actionResult === 'object' &&
907
+ actionResult?.shouldScheduleTool) {
908
+ return actionResult; // Return the object for useGeminiStream
909
+ }
910
+ return true; // Command was handled, but no tool to schedule
911
+ }
912
+ }
913
+ addMessage({
914
+ type: MessageType.ERROR,
915
+ content: `Unknown command: ${trimmed}`,
916
+ timestamp: new Date(),
917
+ });
918
+ return true; // Indicate command was processed (even if unknown)
919
+ }, [addItem, slashCommands, addMessage]);
920
+ return { handleSlashCommand, slashCommands, pendingHistoryItems };
921
+ };
922
+ //# sourceMappingURL=slashCommandProcessor.js.map