@google/gemini-cli 0.1.0-development.2

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 (399) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +156 -0
  3. package/dist/.last_build +0 -0
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.js +20 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/package.json +80 -0
  8. package/dist/src/config/auth.d.ts +6 -0
  9. package/dist/src/config/auth.js +33 -0
  10. package/dist/src/config/auth.js.map +1 -0
  11. package/dist/src/config/config.d.ts +13 -0
  12. package/dist/src/config/config.js +211 -0
  13. package/dist/src/config/config.js.map +1 -0
  14. package/dist/src/config/extension.d.ts +20 -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 +72 -0
  21. package/dist/src/config/settings.js +227 -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 +216 -0
  25. package/dist/src/gemini.js.map +1 -0
  26. package/dist/src/generated/git-commit.d.ts +6 -0
  27. package/dist/src/generated/git-commit.js +9 -0
  28. package/dist/src/generated/git-commit.js.map +1 -0
  29. package/dist/src/nonInteractiveCli.d.ts +7 -0
  30. package/dist/src/nonInteractiveCli.js +115 -0
  31. package/dist/src/nonInteractiveCli.js.map +1 -0
  32. package/dist/src/services/CommandService.d.ts +13 -0
  33. package/dist/src/services/CommandService.js +30 -0
  34. package/dist/src/services/CommandService.js.map +1 -0
  35. package/dist/src/ui/App.d.ts +14 -0
  36. package/dist/src/ui/App.js +391 -0
  37. package/dist/src/ui/App.js.map +1 -0
  38. package/dist/src/ui/colors.d.ts +7 -0
  39. package/dist/src/ui/colors.js +48 -0
  40. package/dist/src/ui/colors.js.map +1 -0
  41. package/dist/src/ui/commands/clearCommand.d.ts +7 -0
  42. package/dist/src/ui/commands/clearCommand.js +15 -0
  43. package/dist/src/ui/commands/clearCommand.js.map +1 -0
  44. package/dist/src/ui/commands/helpCommand.d.ts +7 -0
  45. package/dist/src/ui/commands/helpCommand.js +18 -0
  46. package/dist/src/ui/commands/helpCommand.js.map +1 -0
  47. package/dist/src/ui/commands/memoryCommand.d.ts +7 -0
  48. package/dist/src/ui/commands/memoryCommand.js +81 -0
  49. package/dist/src/ui/commands/memoryCommand.js.map +1 -0
  50. package/dist/src/ui/commands/types.d.ts +63 -0
  51. package/dist/src/ui/commands/types.js +7 -0
  52. package/dist/src/ui/commands/types.js.map +1 -0
  53. package/dist/src/ui/components/AboutBox.d.ts +16 -0
  54. package/dist/src/ui/components/AboutBox.js +6 -0
  55. package/dist/src/ui/components/AboutBox.js.map +1 -0
  56. package/dist/src/ui/components/AsciiArt.d.ts +7 -0
  57. package/dist/src/ui/components/AsciiArt.js +26 -0
  58. package/dist/src/ui/components/AsciiArt.js.map +1 -0
  59. package/dist/src/ui/components/AuthDialog.d.ts +15 -0
  60. package/dist/src/ui/components/AuthDialog.js +66 -0
  61. package/dist/src/ui/components/AuthDialog.js.map +1 -0
  62. package/dist/src/ui/components/AuthInProgress.d.ts +11 -0
  63. package/dist/src/ui/components/AuthInProgress.js +27 -0
  64. package/dist/src/ui/components/AuthInProgress.js.map +1 -0
  65. package/dist/src/ui/components/AutoAcceptIndicator.d.ts +12 -0
  66. package/dist/src/ui/components/AutoAcceptIndicator.js +26 -0
  67. package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -0
  68. package/dist/src/ui/components/ConsolePatcher.d.ts +12 -0
  69. package/dist/src/ui/components/ConsolePatcher.js +40 -0
  70. package/dist/src/ui/components/ConsolePatcher.js.map +1 -0
  71. package/dist/src/ui/components/ConsoleSummaryDisplay.d.ts +11 -0
  72. package/dist/src/ui/components/ConsoleSummaryDisplay.js +11 -0
  73. package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -0
  74. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +15 -0
  75. package/dist/src/ui/components/ContextSummaryDisplay.js +41 -0
  76. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -0
  77. package/dist/src/ui/components/DetailedMessagesDisplay.d.ts +14 -0
  78. package/dist/src/ui/components/DetailedMessagesDisplay.js +34 -0
  79. package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -0
  80. package/dist/src/ui/components/EditorSettingsDialog.d.ts +15 -0
  81. package/dist/src/ui/components/EditorSettingsDialog.js +73 -0
  82. package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -0
  83. package/dist/src/ui/components/Footer.d.ts +20 -0
  84. package/dist/src/ui/components/Footer.js +13 -0
  85. package/dist/src/ui/components/Footer.js.map +1 -0
  86. package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +17 -0
  87. package/dist/src/ui/components/GeminiRespondingSpinner.js +16 -0
  88. package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -0
  89. package/dist/src/ui/components/Header.d.ts +12 -0
  90. package/dist/src/ui/components/Header.js +20 -0
  91. package/dist/src/ui/components/Header.js.map +1 -0
  92. package/dist/src/ui/components/Help.d.ts +12 -0
  93. package/dist/src/ui/components/Help.js +10 -0
  94. package/dist/src/ui/components/Help.js.map +1 -0
  95. package/dist/src/ui/components/HistoryItemDisplay.d.ts +18 -0
  96. package/dist/src/ui/components/HistoryItemDisplay.js +17 -0
  97. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
  98. package/dist/src/ui/components/InputPrompt.d.ts +25 -0
  99. package/dist/src/ui/components/InputPrompt.js +280 -0
  100. package/dist/src/ui/components/InputPrompt.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/MemoryUsageDisplay.d.ts +7 -0
  105. package/dist/src/ui/components/MemoryUsageDisplay.js +27 -0
  106. package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -0
  107. package/dist/src/ui/components/ModelStatsDisplay.d.ts +7 -0
  108. package/dist/src/ui/components/ModelStatsDisplay.js +33 -0
  109. package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -0
  110. package/dist/src/ui/components/SessionSummaryDisplay.d.ts +11 -0
  111. package/dist/src/ui/components/SessionSummaryDisplay.js +4 -0
  112. package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -0
  113. package/dist/src/ui/components/ShellModeIndicator.d.ts +7 -0
  114. package/dist/src/ui/components/ShellModeIndicator.js +5 -0
  115. package/dist/src/ui/components/ShellModeIndicator.js.map +1 -0
  116. package/dist/src/ui/components/ShowMoreLines.d.ts +10 -0
  117. package/dist/src/ui/components/ShowMoreLines.js +24 -0
  118. package/dist/src/ui/components/ShowMoreLines.js.map +1 -0
  119. package/dist/src/ui/components/StatsDisplay.d.ts +12 -0
  120. package/dist/src/ui/components/StatsDisplay.js +42 -0
  121. package/dist/src/ui/components/StatsDisplay.js.map +1 -0
  122. package/dist/src/ui/components/SuggestionsDisplay.d.ts +21 -0
  123. package/dist/src/ui/components/SuggestionsDisplay.js +32 -0
  124. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -0
  125. package/dist/src/ui/components/ThemeDialog.d.ts +19 -0
  126. package/dist/src/ui/components/ThemeDialog.js +126 -0
  127. package/dist/src/ui/components/ThemeDialog.js.map +1 -0
  128. package/dist/src/ui/components/Tips.d.ts +12 -0
  129. package/dist/src/ui/components/Tips.js +8 -0
  130. package/dist/src/ui/components/Tips.js.map +1 -0
  131. package/dist/src/ui/components/ToolStatsDisplay.d.ts +7 -0
  132. package/dist/src/ui/components/ToolStatsDisplay.js +41 -0
  133. package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -0
  134. package/dist/src/ui/components/UpdateNotification.d.ts +10 -0
  135. package/dist/src/ui/components/UpdateNotification.js +10 -0
  136. package/dist/src/ui/components/UpdateNotification.js.map +1 -0
  137. package/dist/src/ui/components/messages/CompressionMessage.d.ts +11 -0
  138. package/dist/src/ui/components/messages/CompressionMessage.js +16 -0
  139. package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -0
  140. package/dist/src/ui/components/messages/DiffRenderer.d.ts +15 -0
  141. package/dist/src/ui/components/messages/DiffRenderer.js +212 -0
  142. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -0
  143. package/dist/src/ui/components/messages/ErrorMessage.d.ts +11 -0
  144. package/dist/src/ui/components/messages/ErrorMessage.js +9 -0
  145. package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -0
  146. package/dist/src/ui/components/messages/GeminiMessage.d.ts +14 -0
  147. package/dist/src/ui/components/messages/GeminiMessage.js +10 -0
  148. package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -0
  149. package/dist/src/ui/components/messages/GeminiMessageContent.d.ts +14 -0
  150. package/dist/src/ui/components/messages/GeminiMessageContent.js +15 -0
  151. package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -0
  152. package/dist/src/ui/components/messages/InfoMessage.d.ts +11 -0
  153. package/dist/src/ui/components/messages/InfoMessage.js +9 -0
  154. package/dist/src/ui/components/messages/InfoMessage.js.map +1 -0
  155. package/dist/src/ui/components/messages/ToolConfirmationMessage.d.ts +15 -0
  156. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +111 -0
  157. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -0
  158. package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +18 -0
  159. package/dist/src/ui/components/messages/ToolGroupMessage.js +53 -0
  160. package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -0
  161. package/dist/src/ui/components/messages/ToolMessage.d.ts +15 -0
  162. package/dist/src/ui/components/messages/ToolMessage.js +61 -0
  163. package/dist/src/ui/components/messages/ToolMessage.js.map +1 -0
  164. package/dist/src/ui/components/messages/UserMessage.d.ts +11 -0
  165. package/dist/src/ui/components/messages/UserMessage.js +9 -0
  166. package/dist/src/ui/components/messages/UserMessage.js.map +1 -0
  167. package/dist/src/ui/components/messages/UserShellMessage.d.ts +11 -0
  168. package/dist/src/ui/components/messages/UserShellMessage.js +9 -0
  169. package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -0
  170. package/dist/src/ui/components/shared/MaxSizedBox.d.ts +61 -0
  171. package/dist/src/ui/components/shared/MaxSizedBox.js +384 -0
  172. package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -0
  173. package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +41 -0
  174. package/dist/src/ui/components/shared/RadioButtonSelect.js +52 -0
  175. package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
  176. package/dist/src/ui/components/shared/text-buffer.d.ts +184 -0
  177. package/dist/src/ui/components/shared/text-buffer.js +1010 -0
  178. package/dist/src/ui/components/shared/text-buffer.js.map +1 -0
  179. package/dist/src/ui/constants.d.ts +8 -0
  180. package/dist/src/ui/constants.js +12 -0
  181. package/dist/src/ui/constants.js.map +1 -0
  182. package/dist/src/ui/contexts/OverflowContext.d.ts +19 -0
  183. package/dist/src/ui/contexts/OverflowContext.js +43 -0
  184. package/dist/src/ui/contexts/OverflowContext.js.map +1 -0
  185. package/dist/src/ui/contexts/SessionContext.d.ts +33 -0
  186. package/dist/src/ui/contexts/SessionContext.js +49 -0
  187. package/dist/src/ui/contexts/SessionContext.js.map +1 -0
  188. package/dist/src/ui/contexts/StreamingContext.d.ts +9 -0
  189. package/dist/src/ui/contexts/StreamingContext.js +15 -0
  190. package/dist/src/ui/contexts/StreamingContext.js.map +1 -0
  191. package/dist/src/ui/editors/editorSettingsManager.d.ts +19 -0
  192. package/dist/src/ui/editors/editorSettingsManager.js +54 -0
  193. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -0
  194. package/dist/src/ui/hooks/atCommandProcessor.d.ts +31 -0
  195. package/dist/src/ui/hooks/atCommandProcessor.js +310 -0
  196. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
  197. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +16 -0
  198. package/dist/src/ui/hooks/shellCommandProcessor.js +261 -0
  199. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
  200. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +27 -0
  201. package/dist/src/ui/hooks/slashCommandProcessor.js +1050 -0
  202. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
  203. package/dist/src/ui/hooks/useAuthCommand.d.ts +14 -0
  204. package/dist/src/ui/hooks/useAuthCommand.js +54 -0
  205. package/dist/src/ui/hooks/useAuthCommand.js.map +1 -0
  206. package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +10 -0
  207. package/dist/src/ui/hooks/useAutoAcceptIndicator.js +37 -0
  208. package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -0
  209. package/dist/src/ui/hooks/useBracketedPaste.d.ts +12 -0
  210. package/dist/src/ui/hooks/useBracketedPaste.js +32 -0
  211. package/dist/src/ui/hooks/useBracketedPaste.js.map +1 -0
  212. package/dist/src/ui/hooks/useCompletion.d.ts +21 -0
  213. package/dist/src/ui/hooks/useCompletion.js +372 -0
  214. package/dist/src/ui/hooks/useCompletion.js.map +1 -0
  215. package/dist/src/ui/hooks/useConsoleMessages.d.ts +12 -0
  216. package/dist/src/ui/hooks/useConsoleMessages.js +60 -0
  217. package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -0
  218. package/dist/src/ui/hooks/useEditorSettings.d.ts +16 -0
  219. package/dist/src/ui/hooks/useEditorSettings.js +43 -0
  220. package/dist/src/ui/hooks/useEditorSettings.js.map +1 -0
  221. package/dist/src/ui/hooks/useGeminiStream.d.ts +23 -0
  222. package/dist/src/ui/hooks/useGeminiStream.js +518 -0
  223. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -0
  224. package/dist/src/ui/hooks/useGitBranchName.d.ts +6 -0
  225. package/dist/src/ui/hooks/useGitBranchName.js +61 -0
  226. package/dist/src/ui/hooks/useGitBranchName.js.map +1 -0
  227. package/dist/src/ui/hooks/useHistoryManager.d.ts +22 -0
  228. package/dist/src/ui/hooks/useHistoryManager.js +72 -0
  229. package/dist/src/ui/hooks/useHistoryManager.js.map +1 -0
  230. package/dist/src/ui/hooks/useInputHistory.d.ts +19 -0
  231. package/dist/src/ui/hooks/useInputHistory.js +84 -0
  232. package/dist/src/ui/hooks/useInputHistory.js.map +1 -0
  233. package/dist/src/ui/hooks/useKeypress.d.ts +29 -0
  234. package/dist/src/ui/hooks/useKeypress.js +86 -0
  235. package/dist/src/ui/hooks/useKeypress.js.map +1 -0
  236. package/dist/src/ui/hooks/useLoadingIndicator.d.ts +10 -0
  237. package/dist/src/ui/hooks/useLoadingIndicator.js +44 -0
  238. package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -0
  239. package/dist/src/ui/hooks/useLogger.d.ts +10 -0
  240. package/dist/src/ui/hooks/useLogger.js +29 -0
  241. package/dist/src/ui/hooks/useLogger.js.map +1 -0
  242. package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
  243. package/dist/src/ui/hooks/usePhraseCycler.js +189 -0
  244. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -0
  245. package/dist/src/ui/hooks/usePrivacySettings.d.ts +16 -0
  246. package/dist/src/ui/hooks/usePrivacySettings.js +115 -0
  247. package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -0
  248. package/dist/src/ui/hooks/useReactToolScheduler.d.ts +33 -0
  249. package/dist/src/ui/hooks/useReactToolScheduler.js +186 -0
  250. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -0
  251. package/dist/src/ui/hooks/useRefreshMemoryCommand.d.ts +6 -0
  252. package/dist/src/ui/hooks/useRefreshMemoryCommand.js +7 -0
  253. package/dist/src/ui/hooks/useRefreshMemoryCommand.js.map +1 -0
  254. package/dist/src/ui/hooks/useShellHistory.d.ts +11 -0
  255. package/dist/src/ui/hooks/useShellHistory.js +89 -0
  256. package/dist/src/ui/hooks/useShellHistory.js.map +1 -0
  257. package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +9 -0
  258. package/dist/src/ui/hooks/useShowMemoryCommand.js +58 -0
  259. package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
  260. package/dist/src/ui/hooks/useStateAndRef.d.ts +7 -0
  261. package/dist/src/ui/hooks/useStateAndRef.js +26 -0
  262. package/dist/src/ui/hooks/useStateAndRef.js.map +1 -0
  263. package/dist/src/ui/hooks/useTerminalSize.d.ts +9 -0
  264. package/dist/src/ui/hooks/useTerminalSize.js +27 -0
  265. package/dist/src/ui/hooks/useTerminalSize.js.map +1 -0
  266. package/dist/src/ui/hooks/useThemeCommand.d.ts +15 -0
  267. package/dist/src/ui/hooks/useThemeCommand.js +78 -0
  268. package/dist/src/ui/hooks/useThemeCommand.js.map +1 -0
  269. package/dist/src/ui/hooks/useTimer.d.ts +12 -0
  270. package/dist/src/ui/hooks/useTimer.js +58 -0
  271. package/dist/src/ui/hooks/useTimer.js.map +1 -0
  272. package/dist/src/ui/privacy/CloudFreePrivacyNotice.d.ts +12 -0
  273. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +40 -0
  274. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -0
  275. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.d.ts +10 -0
  276. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +17 -0
  277. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -0
  278. package/dist/src/ui/privacy/GeminiPrivacyNotice.d.ts +10 -0
  279. package/dist/src/ui/privacy/GeminiPrivacyNotice.js +17 -0
  280. package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -0
  281. package/dist/src/ui/privacy/PrivacyNotice.d.ts +12 -0
  282. package/dist/src/ui/privacy/PrivacyNotice.js +25 -0
  283. package/dist/src/ui/privacy/PrivacyNotice.js.map +1 -0
  284. package/dist/src/ui/themes/ansi-light.d.ts +7 -0
  285. package/dist/src/ui/themes/ansi-light.js +139 -0
  286. package/dist/src/ui/themes/ansi-light.js.map +1 -0
  287. package/dist/src/ui/themes/ansi.d.ts +7 -0
  288. package/dist/src/ui/themes/ansi.js +149 -0
  289. package/dist/src/ui/themes/ansi.js.map +1 -0
  290. package/dist/src/ui/themes/atom-one-dark.d.ts +7 -0
  291. package/dist/src/ui/themes/atom-one-dark.js +136 -0
  292. package/dist/src/ui/themes/atom-one-dark.js.map +1 -0
  293. package/dist/src/ui/themes/ayu-light.d.ts +7 -0
  294. package/dist/src/ui/themes/ayu-light.js +128 -0
  295. package/dist/src/ui/themes/ayu-light.js.map +1 -0
  296. package/dist/src/ui/themes/ayu.d.ts +7 -0
  297. package/dist/src/ui/themes/ayu.js +102 -0
  298. package/dist/src/ui/themes/ayu.js.map +1 -0
  299. package/dist/src/ui/themes/default-light.d.ts +7 -0
  300. package/dist/src/ui/themes/default-light.js +100 -0
  301. package/dist/src/ui/themes/default-light.js.map +1 -0
  302. package/dist/src/ui/themes/default.d.ts +7 -0
  303. package/dist/src/ui/themes/default.js +143 -0
  304. package/dist/src/ui/themes/default.js.map +1 -0
  305. package/dist/src/ui/themes/dracula.d.ts +7 -0
  306. package/dist/src/ui/themes/dracula.js +113 -0
  307. package/dist/src/ui/themes/dracula.js.map +1 -0
  308. package/dist/src/ui/themes/github-dark.d.ts +7 -0
  309. package/dist/src/ui/themes/github-dark.js +136 -0
  310. package/dist/src/ui/themes/github-dark.js.map +1 -0
  311. package/dist/src/ui/themes/github-light.d.ts +7 -0
  312. package/dist/src/ui/themes/github-light.js +138 -0
  313. package/dist/src/ui/themes/github-light.js.map +1 -0
  314. package/dist/src/ui/themes/googlecode.d.ts +7 -0
  315. package/dist/src/ui/themes/googlecode.js +135 -0
  316. package/dist/src/ui/themes/googlecode.js.map +1 -0
  317. package/dist/src/ui/themes/no-color.d.ts +7 -0
  318. package/dist/src/ui/themes/no-color.js +84 -0
  319. package/dist/src/ui/themes/no-color.js.map +1 -0
  320. package/dist/src/ui/themes/shades-of-purple.d.ts +11 -0
  321. package/dist/src/ui/themes/shades-of-purple.js +302 -0
  322. package/dist/src/ui/themes/shades-of-purple.js.map +1 -0
  323. package/dist/src/ui/themes/theme-manager.d.ts +33 -0
  324. package/dist/src/ui/themes/theme-manager.js +109 -0
  325. package/dist/src/ui/themes/theme-manager.js.map +1 -0
  326. package/dist/src/ui/themes/theme.d.ts +67 -0
  327. package/dist/src/ui/themes/theme.js +304 -0
  328. package/dist/src/ui/themes/theme.js.map +1 -0
  329. package/dist/src/ui/themes/xcode.d.ts +7 -0
  330. package/dist/src/ui/themes/xcode.js +143 -0
  331. package/dist/src/ui/themes/xcode.js.map +1 -0
  332. package/dist/src/ui/types.d.ts +172 -0
  333. package/dist/src/ui/types.js +43 -0
  334. package/dist/src/ui/types.js.map +1 -0
  335. package/dist/src/ui/utils/CodeColorizer.d.ts +14 -0
  336. package/dist/src/ui/utils/CodeColorizer.js +97 -0
  337. package/dist/src/ui/utils/CodeColorizer.js.map +1 -0
  338. package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +16 -0
  339. package/dist/src/ui/utils/InlineMarkdownRenderer.js +104 -0
  340. package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -0
  341. package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
  342. package/dist/src/ui/utils/MarkdownDisplay.js +197 -0
  343. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
  344. package/dist/src/ui/utils/TableRenderer.d.ts +17 -0
  345. package/dist/src/ui/utils/TableRenderer.js +84 -0
  346. package/dist/src/ui/utils/TableRenderer.js.map +1 -0
  347. package/dist/src/ui/utils/commandUtils.d.ts +22 -0
  348. package/dist/src/ui/utils/commandUtils.js +25 -0
  349. package/dist/src/ui/utils/commandUtils.js.map +1 -0
  350. package/dist/src/ui/utils/computeStats.d.ts +10 -0
  351. package/dist/src/ui/utils/computeStats.js +55 -0
  352. package/dist/src/ui/utils/computeStats.js.map +1 -0
  353. package/dist/src/ui/utils/displayUtils.d.ts +17 -0
  354. package/dist/src/ui/utils/displayUtils.js +24 -0
  355. package/dist/src/ui/utils/displayUtils.js.map +1 -0
  356. package/dist/src/ui/utils/errorParsing.d.ts +15 -0
  357. package/dist/src/ui/utils/errorParsing.js +79 -0
  358. package/dist/src/ui/utils/errorParsing.js.map +1 -0
  359. package/dist/src/ui/utils/formatters.d.ts +13 -0
  360. package/dist/src/ui/utils/formatters.js +56 -0
  361. package/dist/src/ui/utils/formatters.js.map +1 -0
  362. package/dist/src/ui/utils/markdownUtilities.d.ts +6 -0
  363. package/dist/src/ui/utils/markdownUtilities.js +110 -0
  364. package/dist/src/ui/utils/markdownUtilities.js.map +1 -0
  365. package/dist/src/ui/utils/textUtils.d.ts +22 -0
  366. package/dist/src/ui/utils/textUtils.js +58 -0
  367. package/dist/src/ui/utils/textUtils.js.map +1 -0
  368. package/dist/src/ui/utils/updateCheck.d.ts +6 -0
  369. package/dist/src/ui/utils/updateCheck.js +36 -0
  370. package/dist/src/ui/utils/updateCheck.js.map +1 -0
  371. package/dist/src/utils/cleanup.d.ts +6 -0
  372. package/dist/src/utils/cleanup.js +19 -0
  373. package/dist/src/utils/cleanup.js.map +1 -0
  374. package/dist/src/utils/package.d.ts +12 -0
  375. package/dist/src/utils/package.js +24 -0
  376. package/dist/src/utils/package.js.map +1 -0
  377. package/dist/src/utils/readStdin.d.ts +6 -0
  378. package/dist/src/utils/readStdin.js +34 -0
  379. package/dist/src/utils/readStdin.js.map +1 -0
  380. package/dist/src/utils/sandbox-macos-permissive-closed.sb +26 -0
  381. package/dist/src/utils/sandbox-macos-permissive-open.sb +19 -0
  382. package/dist/src/utils/sandbox-macos-permissive-proxied.sb +31 -0
  383. package/dist/src/utils/sandbox-macos-restrictive-closed.sb +87 -0
  384. package/dist/src/utils/sandbox-macos-restrictive-open.sb +90 -0
  385. package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +92 -0
  386. package/dist/src/utils/sandbox.d.ts +7 -0
  387. package/dist/src/utils/sandbox.js +680 -0
  388. package/dist/src/utils/sandbox.js.map +1 -0
  389. package/dist/src/utils/startupWarnings.d.ts +6 -0
  390. package/dist/src/utils/startupWarnings.js +40 -0
  391. package/dist/src/utils/startupWarnings.js.map +1 -0
  392. package/dist/src/utils/userStartupWarnings.d.ts +6 -0
  393. package/dist/src/utils/userStartupWarnings.js +33 -0
  394. package/dist/src/utils/userStartupWarnings.js.map +1 -0
  395. package/dist/src/utils/version.d.ts +6 -0
  396. package/dist/src/utils/version.js +11 -0
  397. package/dist/src/utils/version.js.map +1 -0
  398. package/dist/tsconfig.tsbuildinfo +1 -0
  399. package/package.json +80 -0
@@ -0,0 +1,1050 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { useCallback, useMemo, useEffect, useState } 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 { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
16
+ import { formatDuration, formatMemoryUsage } from '../utils/formatters.js';
17
+ import { getCliVersion } from '../../utils/version.js';
18
+ import { CommandService } from '../../services/CommandService.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, toggleCorgiMode, showToolDescriptions = false, setQuittingMessages, openPrivacyNotice) => {
23
+ const session = useSessionStats();
24
+ const [commands, setCommands] = useState([]);
25
+ const gitService = useMemo(() => {
26
+ if (!config?.getProjectRoot()) {
27
+ return;
28
+ }
29
+ return new GitService(config.getProjectRoot());
30
+ }, [config]);
31
+ const logger = useMemo(() => {
32
+ const l = new Logger(config?.getSessionId() || '');
33
+ // The logger's initialize is async, but we can create the instance
34
+ // synchronously. Commands that use it will await its initialization.
35
+ return l;
36
+ }, [config]);
37
+ const [pendingCompressionItemRef, setPendingCompressionItem] = useStateAndRef(null);
38
+ const pendingHistoryItems = useMemo(() => {
39
+ const items = [];
40
+ if (pendingCompressionItemRef.current != null) {
41
+ items.push(pendingCompressionItemRef.current);
42
+ }
43
+ return items;
44
+ }, [pendingCompressionItemRef]);
45
+ const addMessage = useCallback((message) => {
46
+ // Convert Message to HistoryItemWithoutId
47
+ let historyItemContent;
48
+ if (message.type === MessageType.ABOUT) {
49
+ historyItemContent = {
50
+ type: 'about',
51
+ cliVersion: message.cliVersion,
52
+ osVersion: message.osVersion,
53
+ sandboxEnv: message.sandboxEnv,
54
+ modelVersion: message.modelVersion,
55
+ selectedAuthType: message.selectedAuthType,
56
+ gcpProject: message.gcpProject,
57
+ };
58
+ }
59
+ else if (message.type === MessageType.STATS) {
60
+ historyItemContent = {
61
+ type: 'stats',
62
+ duration: message.duration,
63
+ };
64
+ }
65
+ else if (message.type === MessageType.MODEL_STATS) {
66
+ historyItemContent = {
67
+ type: 'model_stats',
68
+ };
69
+ }
70
+ else if (message.type === MessageType.TOOL_STATS) {
71
+ historyItemContent = {
72
+ type: 'tool_stats',
73
+ };
74
+ }
75
+ else if (message.type === MessageType.QUIT) {
76
+ historyItemContent = {
77
+ type: 'quit',
78
+ duration: message.duration,
79
+ };
80
+ }
81
+ else if (message.type === MessageType.COMPRESSION) {
82
+ historyItemContent = {
83
+ type: 'compression',
84
+ compression: message.compression,
85
+ };
86
+ }
87
+ else {
88
+ historyItemContent = {
89
+ type: message.type,
90
+ text: message.content,
91
+ };
92
+ }
93
+ addItem(historyItemContent, message.timestamp.getTime());
94
+ }, [addItem]);
95
+ const commandContext = useMemo(() => ({
96
+ services: {
97
+ config,
98
+ settings,
99
+ git: gitService,
100
+ logger,
101
+ },
102
+ ui: {
103
+ addItem,
104
+ clear: () => {
105
+ clearItems();
106
+ console.clear();
107
+ refreshStatic();
108
+ },
109
+ setDebugMessage: onDebugMessage,
110
+ },
111
+ session: {
112
+ stats: session.stats,
113
+ },
114
+ }), [
115
+ config,
116
+ settings,
117
+ gitService,
118
+ logger,
119
+ addItem,
120
+ clearItems,
121
+ refreshStatic,
122
+ session.stats,
123
+ onDebugMessage,
124
+ ]);
125
+ const commandService = useMemo(() => new CommandService(), []);
126
+ useEffect(() => {
127
+ const load = async () => {
128
+ await commandService.loadCommands();
129
+ setCommands(commandService.getCommands());
130
+ };
131
+ load();
132
+ }, [commandService]);
133
+ const savedChatTags = useCallback(async () => {
134
+ const geminiDir = config?.getProjectTempDir();
135
+ if (!geminiDir) {
136
+ return [];
137
+ }
138
+ try {
139
+ const files = await fs.readdir(geminiDir);
140
+ return files
141
+ .filter((file) => file.startsWith('checkpoint-') && file.endsWith('.json'))
142
+ .map((file) => file.replace('checkpoint-', '').replace('.json', ''));
143
+ }
144
+ catch (_err) {
145
+ return [];
146
+ }
147
+ }, [config]);
148
+ // Define legacy commands
149
+ // This list contains all commands that have NOT YET been migrated to the
150
+ // new system. As commands are migrated, they are removed from this list.
151
+ const legacyCommands = useMemo(() => {
152
+ const commands = [
153
+ // `/help` and `/clear` have been migrated and REMOVED from this list.
154
+ {
155
+ name: 'docs',
156
+ description: 'open full Gemini CLI documentation in your browser',
157
+ action: async (_mainCommand, _subCommand, _args) => {
158
+ const docsUrl = 'https://goo.gle/gemini-cli-docs';
159
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
160
+ addMessage({
161
+ type: MessageType.INFO,
162
+ content: `Please open the following URL in your browser to view the documentation:\n${docsUrl}`,
163
+ timestamp: new Date(),
164
+ });
165
+ }
166
+ else {
167
+ addMessage({
168
+ type: MessageType.INFO,
169
+ content: `Opening documentation in your browser: ${docsUrl}`,
170
+ timestamp: new Date(),
171
+ });
172
+ await open(docsUrl);
173
+ }
174
+ },
175
+ },
176
+ {
177
+ name: 'theme',
178
+ description: 'change the theme',
179
+ action: (_mainCommand, _subCommand, _args) => {
180
+ openThemeDialog();
181
+ },
182
+ },
183
+ {
184
+ name: 'auth',
185
+ description: 'change the auth method',
186
+ action: (_mainCommand, _subCommand, _args) => openAuthDialog(),
187
+ },
188
+ {
189
+ name: 'editor',
190
+ description: 'set external editor preference',
191
+ action: (_mainCommand, _subCommand, _args) => openEditorDialog(),
192
+ },
193
+ {
194
+ name: 'privacy',
195
+ description: 'display the privacy notice',
196
+ action: (_mainCommand, _subCommand, _args) => openPrivacyNotice(),
197
+ },
198
+ {
199
+ name: 'stats',
200
+ altName: 'usage',
201
+ description: 'check session stats. Usage: /stats [model|tools]',
202
+ action: (_mainCommand, subCommand, _args) => {
203
+ if (subCommand === 'model') {
204
+ addMessage({
205
+ type: MessageType.MODEL_STATS,
206
+ timestamp: new Date(),
207
+ });
208
+ return;
209
+ }
210
+ else if (subCommand === 'tools') {
211
+ addMessage({
212
+ type: MessageType.TOOL_STATS,
213
+ timestamp: new Date(),
214
+ });
215
+ return;
216
+ }
217
+ const now = new Date();
218
+ const { sessionStartTime } = session.stats;
219
+ const wallDuration = now.getTime() - sessionStartTime.getTime();
220
+ addMessage({
221
+ type: MessageType.STATS,
222
+ duration: formatDuration(wallDuration),
223
+ timestamp: new Date(),
224
+ });
225
+ },
226
+ },
227
+ {
228
+ name: 'mcp',
229
+ description: 'list configured MCP servers and tools',
230
+ action: async (_mainCommand, _subCommand, _args) => {
231
+ // Check if the _subCommand includes a specific flag to control description visibility
232
+ let useShowDescriptions = showToolDescriptions;
233
+ if (_subCommand === 'desc' || _subCommand === 'descriptions') {
234
+ useShowDescriptions = true;
235
+ }
236
+ else if (_subCommand === 'nodesc' ||
237
+ _subCommand === 'nodescriptions') {
238
+ useShowDescriptions = false;
239
+ }
240
+ else if (_args === 'desc' || _args === 'descriptions') {
241
+ useShowDescriptions = true;
242
+ }
243
+ else if (_args === 'nodesc' || _args === 'nodescriptions') {
244
+ useShowDescriptions = false;
245
+ }
246
+ // Check if the _subCommand includes a specific flag to show detailed tool schema
247
+ let useShowSchema = false;
248
+ if (_subCommand === 'schema' || _args === 'schema') {
249
+ useShowSchema = true;
250
+ }
251
+ const toolRegistry = await config?.getToolRegistry();
252
+ if (!toolRegistry) {
253
+ addMessage({
254
+ type: MessageType.ERROR,
255
+ content: 'Could not retrieve tool registry.',
256
+ timestamp: new Date(),
257
+ });
258
+ return;
259
+ }
260
+ const mcpServers = config?.getMcpServers() || {};
261
+ const serverNames = Object.keys(mcpServers);
262
+ if (serverNames.length === 0) {
263
+ const docsUrl = 'https://goo.gle/gemini-cli-docs-mcp';
264
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
265
+ addMessage({
266
+ type: MessageType.INFO,
267
+ content: `No MCP servers configured. Please open the following URL in your browser to view documentation:\n${docsUrl}`,
268
+ timestamp: new Date(),
269
+ });
270
+ }
271
+ else {
272
+ addMessage({
273
+ type: MessageType.INFO,
274
+ content: `No MCP servers configured. Opening documentation in your browser: ${docsUrl}`,
275
+ timestamp: new Date(),
276
+ });
277
+ await open(docsUrl);
278
+ }
279
+ return;
280
+ }
281
+ // Check if any servers are still connecting
282
+ const connectingServers = serverNames.filter((name) => getMCPServerStatus(name) === MCPServerStatus.CONNECTING);
283
+ const discoveryState = getMCPDiscoveryState();
284
+ let message = '';
285
+ // Add overall discovery status message if needed
286
+ if (discoveryState === MCPDiscoveryState.IN_PROGRESS ||
287
+ connectingServers.length > 0) {
288
+ message += `\u001b[33m⏳ MCP servers are starting up (${connectingServers.length} initializing)...\u001b[0m\n`;
289
+ message += `\u001b[90mNote: First startup may take longer. Tool availability will update automatically.\u001b[0m\n\n`;
290
+ }
291
+ message += 'Configured MCP servers:\n\n';
292
+ for (const serverName of serverNames) {
293
+ const serverTools = toolRegistry.getToolsByServer(serverName);
294
+ const status = getMCPServerStatus(serverName);
295
+ // Add status indicator with descriptive text
296
+ let statusIndicator = '';
297
+ let statusText = '';
298
+ switch (status) {
299
+ case MCPServerStatus.CONNECTED:
300
+ statusIndicator = '🟢';
301
+ statusText = 'Ready';
302
+ break;
303
+ case MCPServerStatus.CONNECTING:
304
+ statusIndicator = '🔄';
305
+ statusText = 'Starting... (first startup may take longer)';
306
+ break;
307
+ case MCPServerStatus.DISCONNECTED:
308
+ default:
309
+ statusIndicator = '🔴';
310
+ statusText = 'Disconnected';
311
+ break;
312
+ }
313
+ // Get server description if available
314
+ const server = mcpServers[serverName];
315
+ // Format server header with bold formatting and status
316
+ message += `${statusIndicator} \u001b[1m${serverName}\u001b[0m - ${statusText}`;
317
+ // Add tool count with conditional messaging
318
+ if (status === MCPServerStatus.CONNECTED) {
319
+ message += ` (${serverTools.length} tools)`;
320
+ }
321
+ else if (status === MCPServerStatus.CONNECTING) {
322
+ message += ` (tools will appear when ready)`;
323
+ }
324
+ else {
325
+ message += ` (${serverTools.length} tools cached)`;
326
+ }
327
+ // Add server description with proper handling of multi-line descriptions
328
+ if ((useShowDescriptions || useShowSchema) && server?.description) {
329
+ const greenColor = '\u001b[32m';
330
+ const resetColor = '\u001b[0m';
331
+ const descLines = server.description.trim().split('\n');
332
+ if (descLines) {
333
+ message += ':\n';
334
+ for (const descLine of descLines) {
335
+ message += ` ${greenColor}${descLine}${resetColor}\n`;
336
+ }
337
+ }
338
+ else {
339
+ message += '\n';
340
+ }
341
+ }
342
+ else {
343
+ message += '\n';
344
+ }
345
+ // Reset formatting after server entry
346
+ message += '\u001b[0m';
347
+ if (serverTools.length > 0) {
348
+ serverTools.forEach((tool) => {
349
+ if ((useShowDescriptions || useShowSchema) &&
350
+ tool.description) {
351
+ // Format tool name in cyan using simple ANSI cyan color
352
+ message += ` - \u001b[36m${tool.name}\u001b[0m`;
353
+ // Apply green color to the description text
354
+ const greenColor = '\u001b[32m';
355
+ const resetColor = '\u001b[0m';
356
+ // Handle multi-line descriptions by properly indenting and preserving formatting
357
+ const descLines = tool.description.trim().split('\n');
358
+ if (descLines) {
359
+ message += ':\n';
360
+ for (const descLine of descLines) {
361
+ message += ` ${greenColor}${descLine}${resetColor}\n`;
362
+ }
363
+ }
364
+ else {
365
+ message += '\n';
366
+ }
367
+ // Reset is handled inline with each line now
368
+ }
369
+ else {
370
+ // Use cyan color for the tool name even when not showing descriptions
371
+ message += ` - \u001b[36m${tool.name}\u001b[0m\n`;
372
+ }
373
+ if (useShowSchema) {
374
+ // Prefix the parameters in cyan
375
+ message += ` \u001b[36mParameters:\u001b[0m\n`;
376
+ // Apply green color to the parameter text
377
+ const greenColor = '\u001b[32m';
378
+ const resetColor = '\u001b[0m';
379
+ const paramsLines = JSON.stringify(tool.schema.parameters, null, 2)
380
+ .trim()
381
+ .split('\n');
382
+ if (paramsLines) {
383
+ for (const paramsLine of paramsLines) {
384
+ message += ` ${greenColor}${paramsLine}${resetColor}\n`;
385
+ }
386
+ }
387
+ }
388
+ });
389
+ }
390
+ else {
391
+ message += ' No tools available\n';
392
+ }
393
+ message += '\n';
394
+ }
395
+ // Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
396
+ message += '\u001b[0m';
397
+ addMessage({
398
+ type: MessageType.INFO,
399
+ content: message,
400
+ timestamp: new Date(),
401
+ });
402
+ },
403
+ },
404
+ {
405
+ name: 'tools',
406
+ description: 'list available Gemini CLI tools',
407
+ action: async (_mainCommand, _subCommand, _args) => {
408
+ // Check if the _subCommand includes a specific flag to control description visibility
409
+ let useShowDescriptions = showToolDescriptions;
410
+ if (_subCommand === 'desc' || _subCommand === 'descriptions') {
411
+ useShowDescriptions = true;
412
+ }
413
+ else if (_subCommand === 'nodesc' ||
414
+ _subCommand === 'nodescriptions') {
415
+ useShowDescriptions = false;
416
+ }
417
+ else if (_args === 'desc' || _args === 'descriptions') {
418
+ useShowDescriptions = true;
419
+ }
420
+ else if (_args === 'nodesc' || _args === 'nodescriptions') {
421
+ useShowDescriptions = false;
422
+ }
423
+ const toolRegistry = await config?.getToolRegistry();
424
+ const tools = toolRegistry?.getAllTools();
425
+ if (!tools) {
426
+ addMessage({
427
+ type: MessageType.ERROR,
428
+ content: 'Could not retrieve tools.',
429
+ timestamp: new Date(),
430
+ });
431
+ return;
432
+ }
433
+ // Filter out MCP tools by checking if they have a serverName property
434
+ const geminiTools = tools.filter((tool) => !('serverName' in tool));
435
+ let message = 'Available Gemini CLI tools:\n\n';
436
+ if (geminiTools.length > 0) {
437
+ geminiTools.forEach((tool) => {
438
+ if (useShowDescriptions && tool.description) {
439
+ // Format tool name in cyan using simple ANSI cyan color
440
+ message += ` - \u001b[36m${tool.displayName} (${tool.name})\u001b[0m:\n`;
441
+ // Apply green color to the description text
442
+ const greenColor = '\u001b[32m';
443
+ const resetColor = '\u001b[0m';
444
+ // Handle multi-line descriptions by properly indenting and preserving formatting
445
+ const descLines = tool.description.trim().split('\n');
446
+ // If there are multiple lines, add proper indentation for each line
447
+ if (descLines) {
448
+ for (const descLine of descLines) {
449
+ message += ` ${greenColor}${descLine}${resetColor}\n`;
450
+ }
451
+ }
452
+ }
453
+ else {
454
+ // Use cyan color for the tool name even when not showing descriptions
455
+ message += ` - \u001b[36m${tool.displayName}\u001b[0m\n`;
456
+ }
457
+ });
458
+ }
459
+ else {
460
+ message += ' No tools available\n';
461
+ }
462
+ message += '\n';
463
+ // Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
464
+ message += '\u001b[0m';
465
+ addMessage({
466
+ type: MessageType.INFO,
467
+ content: message,
468
+ timestamp: new Date(),
469
+ });
470
+ },
471
+ },
472
+ {
473
+ name: 'corgi',
474
+ action: (_mainCommand, _subCommand, _args) => {
475
+ toggleCorgiMode();
476
+ },
477
+ },
478
+ {
479
+ name: 'about',
480
+ description: 'show version info',
481
+ action: async (_mainCommand, _subCommand, _args) => {
482
+ const osVersion = process.platform;
483
+ let sandboxEnv = 'no sandbox';
484
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
485
+ sandboxEnv = process.env.SANDBOX;
486
+ }
487
+ else if (process.env.SANDBOX === 'sandbox-exec') {
488
+ sandboxEnv = `sandbox-exec (${process.env.SEATBELT_PROFILE || 'unknown'})`;
489
+ }
490
+ const modelVersion = config?.getModel() || 'Unknown';
491
+ const cliVersion = await getCliVersion();
492
+ const selectedAuthType = settings.merged.selectedAuthType || '';
493
+ const gcpProject = process.env.GOOGLE_CLOUD_PROJECT || '';
494
+ addMessage({
495
+ type: MessageType.ABOUT,
496
+ timestamp: new Date(),
497
+ cliVersion,
498
+ osVersion,
499
+ sandboxEnv,
500
+ modelVersion,
501
+ selectedAuthType,
502
+ gcpProject,
503
+ });
504
+ },
505
+ },
506
+ {
507
+ name: 'bug',
508
+ description: 'submit a bug report',
509
+ action: async (_mainCommand, _subCommand, args) => {
510
+ let bugDescription = _subCommand || '';
511
+ if (args) {
512
+ bugDescription += ` ${args}`;
513
+ }
514
+ bugDescription = bugDescription.trim();
515
+ const osVersion = `${process.platform} ${process.version}`;
516
+ let sandboxEnv = 'no sandbox';
517
+ if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
518
+ sandboxEnv = process.env.SANDBOX.replace(/^gemini-(?:code-)?/, '');
519
+ }
520
+ else if (process.env.SANDBOX === 'sandbox-exec') {
521
+ sandboxEnv = `sandbox-exec (${process.env.SEATBELT_PROFILE || 'unknown'})`;
522
+ }
523
+ const modelVersion = config?.getModel() || 'Unknown';
524
+ const cliVersion = await getCliVersion();
525
+ const memoryUsage = formatMemoryUsage(process.memoryUsage().rss);
526
+ const info = `
527
+ * **CLI Version:** ${cliVersion}
528
+ * **Git Commit:** ${GIT_COMMIT_INFO}
529
+ * **Operating System:** ${osVersion}
530
+ * **Sandbox Environment:** ${sandboxEnv}
531
+ * **Model Version:** ${modelVersion}
532
+ * **Memory Usage:** ${memoryUsage}
533
+ `;
534
+ let bugReportUrl = 'https://github.com/google-gemini/gemini-cli/issues/new?template=bug_report.yml&title={title}&info={info}';
535
+ const bugCommand = config?.getBugCommand();
536
+ if (bugCommand?.urlTemplate) {
537
+ bugReportUrl = bugCommand.urlTemplate;
538
+ }
539
+ bugReportUrl = bugReportUrl
540
+ .replace('{title}', encodeURIComponent(bugDescription))
541
+ .replace('{info}', encodeURIComponent(info));
542
+ addMessage({
543
+ type: MessageType.INFO,
544
+ content: `To submit your bug report, please open the following URL in your browser:\n${bugReportUrl}`,
545
+ timestamp: new Date(),
546
+ });
547
+ (async () => {
548
+ try {
549
+ await open(bugReportUrl);
550
+ }
551
+ catch (error) {
552
+ const errorMessage = error instanceof Error ? error.message : String(error);
553
+ addMessage({
554
+ type: MessageType.ERROR,
555
+ content: `Could not open URL in browser: ${errorMessage}`,
556
+ timestamp: new Date(),
557
+ });
558
+ }
559
+ })();
560
+ },
561
+ },
562
+ {
563
+ name: 'chat',
564
+ description: 'Manage conversation history. Usage: /chat <list|save|resume> <tag>',
565
+ action: async (_mainCommand, subCommand, args) => {
566
+ const tag = (args || '').trim();
567
+ const logger = new Logger(config?.getSessionId() || '');
568
+ await logger.initialize();
569
+ const chat = await config?.getGeminiClient()?.getChat();
570
+ if (!chat) {
571
+ addMessage({
572
+ type: MessageType.ERROR,
573
+ content: 'No chat client available for conversation status.',
574
+ timestamp: new Date(),
575
+ });
576
+ return;
577
+ }
578
+ if (!subCommand) {
579
+ addMessage({
580
+ type: MessageType.ERROR,
581
+ content: 'Missing command\nUsage: /chat <list|save|resume> <tag>',
582
+ timestamp: new Date(),
583
+ });
584
+ return;
585
+ }
586
+ switch (subCommand) {
587
+ case 'save': {
588
+ if (!tag) {
589
+ addMessage({
590
+ type: MessageType.ERROR,
591
+ content: 'Missing tag. Usage: /chat save <tag>',
592
+ timestamp: new Date(),
593
+ });
594
+ return;
595
+ }
596
+ const history = chat.getHistory();
597
+ if (history.length > 0) {
598
+ await logger.saveCheckpoint(chat?.getHistory() || [], tag);
599
+ addMessage({
600
+ type: MessageType.INFO,
601
+ content: `Conversation checkpoint saved with tag: ${tag}.`,
602
+ timestamp: new Date(),
603
+ });
604
+ }
605
+ else {
606
+ addMessage({
607
+ type: MessageType.INFO,
608
+ content: 'No conversation found to save.',
609
+ timestamp: new Date(),
610
+ });
611
+ }
612
+ return;
613
+ }
614
+ case 'resume':
615
+ case 'restore':
616
+ case 'load': {
617
+ if (!tag) {
618
+ addMessage({
619
+ type: MessageType.ERROR,
620
+ content: 'Missing tag. Usage: /chat resume <tag>',
621
+ timestamp: new Date(),
622
+ });
623
+ return;
624
+ }
625
+ const conversation = await logger.loadCheckpoint(tag);
626
+ if (conversation.length === 0) {
627
+ addMessage({
628
+ type: MessageType.INFO,
629
+ content: `No saved checkpoint found with tag: ${tag}.`,
630
+ timestamp: new Date(),
631
+ });
632
+ return;
633
+ }
634
+ clearItems();
635
+ chat.clearHistory();
636
+ const rolemap = {
637
+ user: MessageType.USER,
638
+ model: MessageType.GEMINI,
639
+ };
640
+ let hasSystemPrompt = false;
641
+ let i = 0;
642
+ for (const item of conversation) {
643
+ i += 1;
644
+ // Add each item to history regardless of whether we display
645
+ // it.
646
+ chat.addHistory(item);
647
+ const text = item.parts
648
+ ?.filter((m) => !!m.text)
649
+ .map((m) => m.text)
650
+ .join('') || '';
651
+ if (!text) {
652
+ // Parsing Part[] back to various non-text output not yet implemented.
653
+ continue;
654
+ }
655
+ if (i === 1 && text.match(/context for our chat/)) {
656
+ hasSystemPrompt = true;
657
+ }
658
+ if (i > 2 || !hasSystemPrompt) {
659
+ addItem({
660
+ type: (item.role && rolemap[item.role]) || MessageType.GEMINI,
661
+ text,
662
+ }, i);
663
+ }
664
+ }
665
+ console.clear();
666
+ refreshStatic();
667
+ return;
668
+ }
669
+ case 'list':
670
+ addMessage({
671
+ type: MessageType.INFO,
672
+ content: 'list of saved conversations: ' +
673
+ (await savedChatTags()).join(', '),
674
+ timestamp: new Date(),
675
+ });
676
+ return;
677
+ default:
678
+ addMessage({
679
+ type: MessageType.ERROR,
680
+ content: `Unknown /chat command: ${subCommand}. Available: list, save, resume`,
681
+ timestamp: new Date(),
682
+ });
683
+ return;
684
+ }
685
+ },
686
+ completion: async () => (await savedChatTags()).map((tag) => 'resume ' + tag),
687
+ },
688
+ {
689
+ name: 'quit',
690
+ altName: 'exit',
691
+ description: 'exit the cli',
692
+ action: async (mainCommand, _subCommand, _args) => {
693
+ const now = new Date();
694
+ const { sessionStartTime } = session.stats;
695
+ const wallDuration = now.getTime() - sessionStartTime.getTime();
696
+ setQuittingMessages([
697
+ {
698
+ type: 'user',
699
+ text: `/${mainCommand}`,
700
+ id: now.getTime() - 1,
701
+ },
702
+ {
703
+ type: 'quit',
704
+ duration: formatDuration(wallDuration),
705
+ id: now.getTime(),
706
+ },
707
+ ]);
708
+ setTimeout(() => {
709
+ process.exit(0);
710
+ }, 100);
711
+ },
712
+ },
713
+ {
714
+ name: 'compress',
715
+ altName: 'summarize',
716
+ description: 'Compresses the context by replacing it with a summary.',
717
+ action: async (_mainCommand, _subCommand, _args) => {
718
+ if (pendingCompressionItemRef.current !== null) {
719
+ addMessage({
720
+ type: MessageType.ERROR,
721
+ content: 'Already compressing, wait for previous request to complete',
722
+ timestamp: new Date(),
723
+ });
724
+ return;
725
+ }
726
+ setPendingCompressionItem({
727
+ type: MessageType.COMPRESSION,
728
+ compression: {
729
+ isPending: true,
730
+ originalTokenCount: null,
731
+ newTokenCount: null,
732
+ },
733
+ });
734
+ try {
735
+ const compressed = await config
736
+ .getGeminiClient()
737
+ .tryCompressChat(true);
738
+ if (compressed) {
739
+ addMessage({
740
+ type: MessageType.COMPRESSION,
741
+ compression: {
742
+ isPending: false,
743
+ originalTokenCount: compressed.originalTokenCount,
744
+ newTokenCount: compressed.newTokenCount,
745
+ },
746
+ timestamp: new Date(),
747
+ });
748
+ }
749
+ else {
750
+ addMessage({
751
+ type: MessageType.ERROR,
752
+ content: 'Failed to compress chat history.',
753
+ timestamp: new Date(),
754
+ });
755
+ }
756
+ }
757
+ catch (e) {
758
+ addMessage({
759
+ type: MessageType.ERROR,
760
+ content: `Failed to compress chat history: ${e instanceof Error ? e.message : String(e)}`,
761
+ timestamp: new Date(),
762
+ });
763
+ }
764
+ setPendingCompressionItem(null);
765
+ },
766
+ },
767
+ ];
768
+ if (config?.getCheckpointingEnabled()) {
769
+ commands.push({
770
+ name: 'restore',
771
+ 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',
772
+ completion: async () => {
773
+ const checkpointDir = config?.getProjectTempDir()
774
+ ? path.join(config.getProjectTempDir(), 'checkpoints')
775
+ : undefined;
776
+ if (!checkpointDir) {
777
+ return [];
778
+ }
779
+ try {
780
+ const files = await fs.readdir(checkpointDir);
781
+ return files
782
+ .filter((file) => file.endsWith('.json'))
783
+ .map((file) => file.replace('.json', ''));
784
+ }
785
+ catch (_err) {
786
+ return [];
787
+ }
788
+ },
789
+ action: async (_mainCommand, subCommand, _args) => {
790
+ const checkpointDir = config?.getProjectTempDir()
791
+ ? path.join(config.getProjectTempDir(), 'checkpoints')
792
+ : undefined;
793
+ if (!checkpointDir) {
794
+ addMessage({
795
+ type: MessageType.ERROR,
796
+ content: 'Could not determine the .gemini directory path.',
797
+ timestamp: new Date(),
798
+ });
799
+ return;
800
+ }
801
+ try {
802
+ // Ensure the directory exists before trying to read it.
803
+ await fs.mkdir(checkpointDir, { recursive: true });
804
+ const files = await fs.readdir(checkpointDir);
805
+ const jsonFiles = files.filter((file) => file.endsWith('.json'));
806
+ if (!subCommand) {
807
+ if (jsonFiles.length === 0) {
808
+ addMessage({
809
+ type: MessageType.INFO,
810
+ content: 'No restorable tool calls found.',
811
+ timestamp: new Date(),
812
+ });
813
+ return;
814
+ }
815
+ const truncatedFiles = jsonFiles.map((file) => {
816
+ const components = file.split('.');
817
+ if (components.length <= 1) {
818
+ return file;
819
+ }
820
+ components.pop();
821
+ return components.join('.');
822
+ });
823
+ const fileList = truncatedFiles.join('\n');
824
+ addMessage({
825
+ type: MessageType.INFO,
826
+ content: `Available tool calls to restore:\n\n${fileList}`,
827
+ timestamp: new Date(),
828
+ });
829
+ return;
830
+ }
831
+ const selectedFile = subCommand.endsWith('.json')
832
+ ? subCommand
833
+ : `${subCommand}.json`;
834
+ if (!jsonFiles.includes(selectedFile)) {
835
+ addMessage({
836
+ type: MessageType.ERROR,
837
+ content: `File not found: ${selectedFile}`,
838
+ timestamp: new Date(),
839
+ });
840
+ return;
841
+ }
842
+ const filePath = path.join(checkpointDir, selectedFile);
843
+ const data = await fs.readFile(filePath, 'utf-8');
844
+ const toolCallData = JSON.parse(data);
845
+ if (toolCallData.history) {
846
+ loadHistory(toolCallData.history);
847
+ }
848
+ if (toolCallData.clientHistory) {
849
+ await config
850
+ ?.getGeminiClient()
851
+ ?.setHistory(toolCallData.clientHistory);
852
+ }
853
+ if (toolCallData.commitHash) {
854
+ await gitService?.restoreProjectFromSnapshot(toolCallData.commitHash);
855
+ addMessage({
856
+ type: MessageType.INFO,
857
+ content: `Restored project to the state before the tool call.`,
858
+ timestamp: new Date(),
859
+ });
860
+ }
861
+ return {
862
+ type: 'tool',
863
+ toolName: toolCallData.toolCall.name,
864
+ toolArgs: toolCallData.toolCall.args,
865
+ };
866
+ }
867
+ catch (error) {
868
+ addMessage({
869
+ type: MessageType.ERROR,
870
+ content: `Could not read restorable tool calls. This is the error: ${error}`,
871
+ timestamp: new Date(),
872
+ });
873
+ }
874
+ },
875
+ });
876
+ }
877
+ return commands;
878
+ }, [
879
+ addMessage,
880
+ openThemeDialog,
881
+ openAuthDialog,
882
+ openEditorDialog,
883
+ openPrivacyNotice,
884
+ toggleCorgiMode,
885
+ savedChatTags,
886
+ config,
887
+ settings,
888
+ showToolDescriptions,
889
+ session,
890
+ gitService,
891
+ loadHistory,
892
+ addItem,
893
+ setQuittingMessages,
894
+ pendingCompressionItemRef,
895
+ setPendingCompressionItem,
896
+ clearItems,
897
+ refreshStatic,
898
+ ]);
899
+ const handleSlashCommand = useCallback(async (rawQuery) => {
900
+ if (typeof rawQuery !== 'string') {
901
+ return false;
902
+ }
903
+ const trimmed = rawQuery.trim();
904
+ if (!trimmed.startsWith('/') && !trimmed.startsWith('?')) {
905
+ return false;
906
+ }
907
+ const userMessageTimestamp = Date.now();
908
+ if (trimmed !== '/quit' && trimmed !== '/exit') {
909
+ addItem({ type: MessageType.USER, text: trimmed }, userMessageTimestamp);
910
+ }
911
+ const parts = trimmed.substring(1).trim().split(/\s+/);
912
+ const commandPath = parts.filter((p) => p); // The parts of the command, e.g., ['memory', 'add']
913
+ // --- Start of New Tree Traversal Logic ---
914
+ let currentCommands = commands;
915
+ let commandToExecute;
916
+ let pathIndex = 0;
917
+ for (const part of commandPath) {
918
+ const foundCommand = currentCommands.find((cmd) => cmd.name === part || cmd.altName === part);
919
+ if (foundCommand) {
920
+ commandToExecute = foundCommand;
921
+ pathIndex++;
922
+ if (foundCommand.subCommands) {
923
+ currentCommands = foundCommand.subCommands;
924
+ }
925
+ else {
926
+ break;
927
+ }
928
+ }
929
+ else {
930
+ break;
931
+ }
932
+ }
933
+ if (commandToExecute) {
934
+ const args = parts.slice(pathIndex).join(' ');
935
+ if (commandToExecute.action) {
936
+ const result = await commandToExecute.action(commandContext, args);
937
+ if (result) {
938
+ switch (result.type) {
939
+ case 'tool':
940
+ return {
941
+ type: 'schedule_tool',
942
+ toolName: result.toolName,
943
+ toolArgs: result.toolArgs,
944
+ };
945
+ case 'message':
946
+ addItem({
947
+ type: result.messageType === 'error'
948
+ ? MessageType.ERROR
949
+ : MessageType.INFO,
950
+ text: result.content,
951
+ }, Date.now());
952
+ return { type: 'handled' };
953
+ case 'dialog':
954
+ switch (result.dialog) {
955
+ case 'help':
956
+ setShowHelp(true);
957
+ return { type: 'handled' };
958
+ default: {
959
+ const unhandled = result.dialog;
960
+ throw new Error(`Unhandled slash command result: ${unhandled}`);
961
+ }
962
+ }
963
+ default: {
964
+ const unhandled = result;
965
+ throw new Error(`Unhandled slash command result: ${unhandled}`);
966
+ }
967
+ }
968
+ }
969
+ return { type: 'handled' };
970
+ }
971
+ else if (commandToExecute.subCommands) {
972
+ const helpText = `Command '/${commandToExecute.name}' requires a subcommand. Available:\n${commandToExecute.subCommands
973
+ .map((sc) => ` - ${sc.name}: ${sc.description || ''}`)
974
+ .join('\n')}`;
975
+ addMessage({
976
+ type: MessageType.INFO,
977
+ content: helpText,
978
+ timestamp: new Date(),
979
+ });
980
+ return { type: 'handled' };
981
+ }
982
+ }
983
+ // --- End of New Tree Traversal Logic ---
984
+ // --- Legacy Fallback Logic (for commands not yet migrated) ---
985
+ const mainCommand = parts[0];
986
+ const subCommand = parts[1];
987
+ const legacyArgs = parts.slice(2).join(' ');
988
+ for (const cmd of legacyCommands) {
989
+ if (mainCommand === cmd.name || mainCommand === cmd.altName) {
990
+ const actionResult = await cmd.action(mainCommand, subCommand, legacyArgs);
991
+ if (actionResult?.type === 'tool') {
992
+ return {
993
+ type: 'schedule_tool',
994
+ toolName: actionResult.toolName,
995
+ toolArgs: actionResult.toolArgs,
996
+ };
997
+ }
998
+ if (actionResult?.type === 'message') {
999
+ addItem({
1000
+ type: actionResult.messageType === 'error'
1001
+ ? MessageType.ERROR
1002
+ : MessageType.INFO,
1003
+ text: actionResult.content,
1004
+ }, Date.now());
1005
+ }
1006
+ return { type: 'handled' };
1007
+ }
1008
+ }
1009
+ addMessage({
1010
+ type: MessageType.ERROR,
1011
+ content: `Unknown command: ${trimmed}`,
1012
+ timestamp: new Date(),
1013
+ });
1014
+ return { type: 'handled' };
1015
+ }, [
1016
+ addItem,
1017
+ setShowHelp,
1018
+ commands,
1019
+ legacyCommands,
1020
+ commandContext,
1021
+ addMessage,
1022
+ ]);
1023
+ const allCommands = useMemo(() => {
1024
+ // Adapt legacy commands to the new SlashCommand interface
1025
+ const adaptedLegacyCommands = legacyCommands.map((legacyCmd) => ({
1026
+ name: legacyCmd.name,
1027
+ altName: legacyCmd.altName,
1028
+ description: legacyCmd.description,
1029
+ action: async (_context, args) => {
1030
+ const parts = args.split(/\s+/);
1031
+ const subCommand = parts[0] || undefined;
1032
+ const restOfArgs = parts.slice(1).join(' ') || undefined;
1033
+ return legacyCmd.action(legacyCmd.name, subCommand, restOfArgs);
1034
+ },
1035
+ completion: legacyCmd.completion
1036
+ ? async (_context, _partialArg) => legacyCmd.completion()
1037
+ : undefined,
1038
+ }));
1039
+ const newCommandNames = new Set(commands.map((c) => c.name));
1040
+ const filteredAdaptedLegacy = adaptedLegacyCommands.filter((c) => !newCommandNames.has(c.name));
1041
+ return [...commands, ...filteredAdaptedLegacy];
1042
+ }, [commands, legacyCommands]);
1043
+ return {
1044
+ handleSlashCommand,
1045
+ slashCommands: allCommands,
1046
+ pendingHistoryItems,
1047
+ commandContext,
1048
+ };
1049
+ };
1050
+ //# sourceMappingURL=slashCommandProcessor.js.map