@google/gemini-cli 0.6.0-nightly.20250910.a31830a3 → 0.6.0-preview.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 (336) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +12 -2
  3. package/dist/index.js +0 -0
  4. package/dist/package.json +3 -2
  5. package/dist/src/commands/extensions/disable.d.ts +1 -1
  6. package/dist/src/commands/extensions/disable.js +3 -3
  7. package/dist/src/commands/extensions/disable.js.map +1 -1
  8. package/dist/src/commands/extensions/enable.d.ts +1 -1
  9. package/dist/src/commands/extensions/enable.js +5 -7
  10. package/dist/src/commands/extensions/enable.js.map +1 -1
  11. package/dist/src/commands/extensions/install.d.ts +1 -0
  12. package/dist/src/commands/extensions/install.js +10 -2
  13. package/dist/src/commands/extensions/install.js.map +1 -1
  14. package/dist/src/commands/extensions/install.test.js +75 -2
  15. package/dist/src/commands/extensions/install.test.js.map +1 -1
  16. package/dist/src/commands/extensions/update.js +14 -4
  17. package/dist/src/commands/extensions/update.js.map +1 -1
  18. package/dist/src/config/config.d.ts +1 -1
  19. package/dist/src/config/config.js +19 -5
  20. package/dist/src/config/config.js.map +1 -1
  21. package/dist/src/config/extension.d.ts +17 -8
  22. package/dist/src/config/extension.js +192 -73
  23. package/dist/src/config/extension.js.map +1 -1
  24. package/dist/src/config/extensions/extensionEnablement.d.ts +30 -0
  25. package/dist/src/config/extensions/extensionEnablement.js +113 -0
  26. package/dist/src/config/extensions/extensionEnablement.js.map +1 -0
  27. package/dist/src/config/extensions/extensionEnablement.test.d.ts +6 -0
  28. package/dist/src/config/extensions/extensionEnablement.test.js +116 -0
  29. package/dist/src/config/extensions/extensionEnablement.test.js.map +1 -0
  30. package/dist/src/config/extensions/variableSchema.d.ts +8 -0
  31. package/dist/src/config/extensions/variableSchema.js +4 -0
  32. package/dist/src/config/extensions/variableSchema.js.map +1 -1
  33. package/dist/src/config/keyBindings.d.ts +4 -1
  34. package/dist/src/config/keyBindings.js +8 -0
  35. package/dist/src/config/keyBindings.js.map +1 -1
  36. package/dist/src/config/settings.d.ts +3 -0
  37. package/dist/src/config/settings.js +54 -15
  38. package/dist/src/config/settings.js.map +1 -1
  39. package/dist/src/config/settingsSchema.d.ts +67 -1
  40. package/dist/src/config/settingsSchema.js +64 -1
  41. package/dist/src/config/settingsSchema.js.map +1 -1
  42. package/dist/src/config/settingsSchema.test.js +6 -0
  43. package/dist/src/config/settingsSchema.test.js.map +1 -1
  44. package/dist/src/config/trustedFolders.d.ts +1 -1
  45. package/dist/src/config/trustedFolders.js +9 -4
  46. package/dist/src/config/trustedFolders.js.map +1 -1
  47. package/dist/src/config/trustedFolders.test.js +41 -25
  48. package/dist/src/config/trustedFolders.test.js.map +1 -1
  49. package/dist/src/core/initializer.js +6 -1
  50. package/dist/src/core/initializer.js.map +1 -1
  51. package/dist/src/gemini.js +34 -24
  52. package/dist/src/gemini.js.map +1 -1
  53. package/dist/src/gemini.test.js +11 -2
  54. package/dist/src/gemini.test.js.map +1 -1
  55. package/dist/src/generated/git-commit.d.ts +2 -2
  56. package/dist/src/generated/git-commit.js +2 -2
  57. package/dist/src/generated/git-commit.js.map +1 -1
  58. package/dist/src/nonInteractiveCli.js +23 -9
  59. package/dist/src/nonInteractiveCli.js.map +1 -1
  60. package/dist/src/services/McpPromptLoader.js +43 -8
  61. package/dist/src/services/McpPromptLoader.js.map +1 -1
  62. package/dist/src/services/McpPromptLoader.test.js +228 -1
  63. package/dist/src/services/McpPromptLoader.test.js.map +1 -1
  64. package/dist/src/services/prompt-processors/shellProcessor.js +8 -1
  65. package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -1
  66. package/dist/src/ui/AppContainer.js +69 -32
  67. package/dist/src/ui/AppContainer.js.map +1 -1
  68. package/dist/src/ui/AppContainer.test.js +36 -0
  69. package/dist/src/ui/AppContainer.test.js.map +1 -1
  70. package/dist/src/ui/IdeIntegrationNudge.js +2 -1
  71. package/dist/src/ui/IdeIntegrationNudge.js.map +1 -1
  72. package/dist/src/ui/auth/AuthDialog.js +2 -2
  73. package/dist/src/ui/auth/AuthDialog.js.map +1 -1
  74. package/dist/src/ui/auth/AuthInProgress.js +2 -2
  75. package/dist/src/ui/auth/AuthInProgress.js.map +1 -1
  76. package/dist/src/ui/commands/chatCommand.d.ts +2 -0
  77. package/dist/src/ui/commands/chatCommand.js +82 -3
  78. package/dist/src/ui/commands/chatCommand.js.map +1 -1
  79. package/dist/src/ui/commands/extensionsCommand.js +70 -16
  80. package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
  81. package/dist/src/ui/commands/ideCommand.js +2 -2
  82. package/dist/src/ui/commands/ideCommand.js.map +1 -1
  83. package/dist/src/ui/commands/types.d.ts +4 -1
  84. package/dist/src/ui/commands/types.js +0 -1
  85. package/dist/src/ui/commands/types.js.map +1 -1
  86. package/dist/src/ui/components/AboutBox.js +2 -2
  87. package/dist/src/ui/components/AboutBox.js.map +1 -1
  88. package/dist/src/ui/components/AnsiOutput.d.ts +13 -0
  89. package/dist/src/ui/components/AnsiOutput.js +12 -0
  90. package/dist/src/ui/components/AnsiOutput.js.map +1 -0
  91. package/dist/src/ui/components/AnsiOutput.test.d.ts +6 -0
  92. package/dist/src/ui/components/AnsiOutput.test.js +97 -0
  93. package/dist/src/ui/components/AnsiOutput.test.js.map +1 -0
  94. package/dist/src/ui/components/AutoAcceptIndicator.js +4 -4
  95. package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -1
  96. package/dist/src/ui/components/Composer.js +10 -5
  97. package/dist/src/ui/components/Composer.js.map +1 -1
  98. package/dist/src/ui/components/ConfigInitDisplay.js +2 -1
  99. package/dist/src/ui/components/ConfigInitDisplay.js.map +1 -1
  100. package/dist/src/ui/components/ConsoleSummaryDisplay.js +2 -2
  101. package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -1
  102. package/dist/src/ui/components/ContextSummaryDisplay.js +3 -3
  103. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
  104. package/dist/src/ui/components/ContextUsageDisplay.js +2 -2
  105. package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -1
  106. package/dist/src/ui/components/DebugProfiler.js +2 -2
  107. package/dist/src/ui/components/DebugProfiler.js.map +1 -1
  108. package/dist/src/ui/components/DetailedMessagesDisplay.js +7 -7
  109. package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -1
  110. package/dist/src/ui/components/DialogManager.js +9 -5
  111. package/dist/src/ui/components/DialogManager.js.map +1 -1
  112. package/dist/src/ui/components/EditorSettingsDialog.js +5 -5
  113. package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -1
  114. package/dist/src/ui/components/FolderTrustDialog.js +4 -3
  115. package/dist/src/ui/components/FolderTrustDialog.js.map +1 -1
  116. package/dist/src/ui/components/FolderTrustDialog.test.js +6 -1
  117. package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -1
  118. package/dist/src/ui/components/Footer.d.ts +3 -0
  119. package/dist/src/ui/components/Footer.js +8 -3
  120. package/dist/src/ui/components/Footer.js.map +1 -1
  121. package/dist/src/ui/components/GeminiRespondingSpinner.js +3 -2
  122. package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -1
  123. package/dist/src/ui/components/Header.js +2 -2
  124. package/dist/src/ui/components/Header.js.map +1 -1
  125. package/dist/src/ui/components/Help.js +5 -5
  126. package/dist/src/ui/components/Help.js.map +1 -1
  127. package/dist/src/ui/components/HistoryItemDisplay.d.ts +2 -0
  128. package/dist/src/ui/components/HistoryItemDisplay.js +2 -1
  129. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
  130. package/dist/src/ui/components/InputPrompt.d.ts +3 -0
  131. package/dist/src/ui/components/InputPrompt.js +97 -19
  132. package/dist/src/ui/components/InputPrompt.js.map +1 -1
  133. package/dist/src/ui/components/LoadingIndicator.js +2 -2
  134. package/dist/src/ui/components/LoadingIndicator.js.map +1 -1
  135. package/dist/src/ui/components/LoopDetectionConfirmation.d.ts +13 -0
  136. package/dist/src/ui/components/LoopDetectionConfirmation.js +35 -0
  137. package/dist/src/ui/components/LoopDetectionConfirmation.js.map +1 -0
  138. package/dist/src/ui/components/LoopDetectionConfirmation.test.d.ts +6 -0
  139. package/dist/src/ui/components/LoopDetectionConfirmation.test.js +25 -0
  140. package/dist/src/ui/components/LoopDetectionConfirmation.test.js.map +1 -0
  141. package/dist/src/ui/components/MainContent.js +1 -1
  142. package/dist/src/ui/components/MainContent.js.map +1 -1
  143. package/dist/src/ui/components/MemoryUsageDisplay.js +6 -4
  144. package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -1
  145. package/dist/src/ui/components/ModelStatsDisplay.js +7 -7
  146. package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -1
  147. package/dist/src/ui/components/Notifications.js +2 -2
  148. package/dist/src/ui/components/Notifications.js.map +1 -1
  149. package/dist/src/ui/components/PrepareLabel.d.ts +5 -5
  150. package/dist/src/ui/components/PrepareLabel.js +67 -11
  151. package/dist/src/ui/components/PrepareLabel.js.map +1 -1
  152. package/dist/src/ui/components/PrepareLabel.test.d.ts +6 -0
  153. package/dist/src/ui/components/PrepareLabel.test.js +71 -0
  154. package/dist/src/ui/components/PrepareLabel.test.js.map +1 -0
  155. package/dist/src/ui/components/ProQuotaDialog.js +2 -2
  156. package/dist/src/ui/components/ProQuotaDialog.js.map +1 -1
  157. package/dist/src/ui/components/SettingsDialog.d.ts +2 -1
  158. package/dist/src/ui/components/SettingsDialog.js +73 -17
  159. package/dist/src/ui/components/SettingsDialog.js.map +1 -1
  160. package/dist/src/ui/components/SettingsDialog.test.js +291 -0
  161. package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
  162. package/dist/src/ui/components/ShellConfirmationDialog.js +2 -2
  163. package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -1
  164. package/dist/src/ui/components/ShellInputPrompt.d.ts +11 -0
  165. package/dist/src/ui/components/ShellInputPrompt.js +36 -0
  166. package/dist/src/ui/components/ShellInputPrompt.js.map +1 -0
  167. package/dist/src/ui/components/ShellModeIndicator.js +2 -2
  168. package/dist/src/ui/components/ShellModeIndicator.js.map +1 -1
  169. package/dist/src/ui/components/ShowMoreLines.js +2 -2
  170. package/dist/src/ui/components/ShowMoreLines.js.map +1 -1
  171. package/dist/src/ui/components/StatsDisplay.js +6 -6
  172. package/dist/src/ui/components/StatsDisplay.js.map +1 -1
  173. package/dist/src/ui/components/SuggestionsDisplay.d.ts +5 -2
  174. package/dist/src/ui/components/SuggestionsDisplay.js +17 -11
  175. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
  176. package/dist/src/ui/components/ThemeDialog.js +4 -4
  177. package/dist/src/ui/components/ThemeDialog.js.map +1 -1
  178. package/dist/src/ui/components/ThemeDialog.test.js +10 -0
  179. package/dist/src/ui/components/ThemeDialog.test.js.map +1 -1
  180. package/dist/src/ui/components/Tips.js +2 -2
  181. package/dist/src/ui/components/Tips.js.map +1 -1
  182. package/dist/src/ui/components/ToolStatsDisplay.js +4 -4
  183. package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -1
  184. package/dist/src/ui/components/UpdateNotification.js +2 -2
  185. package/dist/src/ui/components/UpdateNotification.js.map +1 -1
  186. package/dist/src/ui/components/WorkspaceMigrationDialog.js +4 -4
  187. package/dist/src/ui/components/WorkspaceMigrationDialog.js.map +1 -1
  188. package/dist/src/ui/components/messages/CompressionMessage.d.ts +1 -2
  189. package/dist/src/ui/components/messages/CompressionMessage.js +37 -8
  190. package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -1
  191. package/dist/src/ui/components/messages/CompressionMessage.test.d.ts +6 -0
  192. package/dist/src/ui/components/messages/CompressionMessage.test.js +160 -0
  193. package/dist/src/ui/components/messages/CompressionMessage.test.js.map +1 -0
  194. package/dist/src/ui/components/messages/DiffRenderer.d.ts +2 -1
  195. package/dist/src/ui/components/messages/DiffRenderer.js +14 -22
  196. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -1
  197. package/dist/src/ui/components/messages/ErrorMessage.js +2 -2
  198. package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -1
  199. package/dist/src/ui/components/messages/GeminiMessage.js +2 -2
  200. package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -1
  201. package/dist/src/ui/components/messages/InfoMessage.js +2 -2
  202. package/dist/src/ui/components/messages/InfoMessage.js.map +1 -1
  203. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +31 -19
  204. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
  205. package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +3 -0
  206. package/dist/src/ui/components/messages/ToolGroupMessage.js +10 -6
  207. package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -1
  208. package/dist/src/ui/components/messages/ToolMessage.d.ts +4 -0
  209. package/dist/src/ui/components/messages/ToolMessage.js +17 -10
  210. package/dist/src/ui/components/messages/ToolMessage.js.map +1 -1
  211. package/dist/src/ui/components/messages/ToolMessage.test.js +33 -1
  212. package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -1
  213. package/dist/src/ui/components/messages/UserMessage.js +3 -3
  214. package/dist/src/ui/components/messages/UserMessage.js.map +1 -1
  215. package/dist/src/ui/components/messages/UserShellMessage.js +2 -2
  216. package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -1
  217. package/dist/src/ui/components/shared/MaxSizedBox.js +2 -2
  218. package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -1
  219. package/dist/src/ui/components/shared/RadioButtonSelect.js +12 -12
  220. package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -1
  221. package/dist/src/ui/components/shared/text-buffer.d.ts +19 -2
  222. package/dist/src/ui/components/shared/text-buffer.js +191 -133
  223. package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
  224. package/dist/src/ui/components/views/ExtensionsList.d.ts +6 -0
  225. package/dist/src/ui/components/views/ExtensionsList.js +47 -0
  226. package/dist/src/ui/components/views/ExtensionsList.js.map +1 -0
  227. package/dist/src/ui/components/views/ExtensionsList.test.d.ts +6 -0
  228. package/dist/src/ui/components/views/ExtensionsList.test.js +97 -0
  229. package/dist/src/ui/components/views/ExtensionsList.test.js.map +1 -0
  230. package/dist/src/ui/contexts/UIStateContext.d.ts +6 -1
  231. package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
  232. package/dist/src/ui/hooks/keyToAnsi.d.ts +15 -0
  233. package/dist/src/ui/hooks/keyToAnsi.js +67 -0
  234. package/dist/src/ui/hooks/keyToAnsi.js.map +1 -0
  235. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +2 -1
  236. package/dist/src/ui/hooks/shellCommandProcessor.js +58 -15
  237. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
  238. package/dist/src/ui/hooks/shellCommandProcessor.test.js +196 -17
  239. package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -1
  240. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +3 -1
  241. package/dist/src/ui/hooks/slashCommandProcessor.js +15 -45
  242. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
  243. package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +3 -2
  244. package/dist/src/ui/hooks/useAutoAcceptIndicator.js +9 -5
  245. package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -1
  246. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +69 -0
  247. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -1
  248. package/dist/src/ui/hooks/useGeminiStream.d.ts +11 -1
  249. package/dist/src/ui/hooks/useGeminiStream.js +75 -18
  250. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
  251. package/dist/src/ui/hooks/useGitBranchName.js +15 -18
  252. package/dist/src/ui/hooks/useGitBranchName.js.map +1 -1
  253. package/dist/src/ui/hooks/useGitBranchName.test.js +49 -53
  254. package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -1
  255. package/dist/src/ui/hooks/useIdeTrustListener.js +2 -2
  256. package/dist/src/ui/hooks/useIdeTrustListener.js.map +1 -1
  257. package/dist/src/ui/hooks/useQuotaAndFallback.test.js +0 -2
  258. package/dist/src/ui/hooks/useQuotaAndFallback.test.js.map +1 -1
  259. package/dist/src/ui/hooks/useReactToolScheduler.d.ts +3 -2
  260. package/dist/src/ui/hooks/useReactToolScheduler.js +21 -17
  261. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
  262. package/dist/src/ui/hooks/useReverseSearchCompletion.d.ts +1 -1
  263. package/dist/src/ui/hooks/useReverseSearchCompletion.js +67 -20
  264. package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -1
  265. package/dist/src/ui/hooks/useSlashCompletion.d.ts +1 -1
  266. package/dist/src/ui/hooks/useSlashCompletion.js +12 -1
  267. package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -1
  268. package/dist/src/ui/hooks/useSlashCompletion.test.js +14 -2
  269. package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -1
  270. package/dist/src/ui/hooks/useToolScheduler.test.js +6 -4
  271. package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -1
  272. package/dist/src/ui/keyMatchers.test.js +8 -0
  273. package/dist/src/ui/keyMatchers.test.js.map +1 -1
  274. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +5 -5
  275. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -1
  276. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +2 -2
  277. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -1
  278. package/dist/src/ui/privacy/GeminiPrivacyNotice.js +2 -2
  279. package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -1
  280. package/dist/src/ui/state/extensions.d.ts +14 -0
  281. package/dist/src/ui/state/extensions.js +16 -0
  282. package/dist/src/ui/state/extensions.js.map +1 -0
  283. package/dist/src/ui/themes/ayu.js +1 -1
  284. package/dist/src/ui/themes/dracula.js +2 -2
  285. package/dist/src/ui/themes/github-dark.js +1 -1
  286. package/dist/src/ui/themes/theme.js +17 -17
  287. package/dist/src/ui/themes/theme.js.map +1 -1
  288. package/dist/src/ui/types.d.ts +12 -2
  289. package/dist/src/ui/types.js +1 -0
  290. package/dist/src/ui/types.js.map +1 -1
  291. package/dist/src/ui/utils/CodeColorizer.js +3 -2
  292. package/dist/src/ui/utils/CodeColorizer.js.map +1 -1
  293. package/dist/src/ui/utils/InlineMarkdownRenderer.js +7 -7
  294. package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -1
  295. package/dist/src/ui/utils/MarkdownDisplay.js +10 -10
  296. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -1
  297. package/dist/src/ui/utils/MarkdownDisplay.test.js +6 -2
  298. package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -1
  299. package/dist/src/ui/utils/TableRenderer.js +4 -4
  300. package/dist/src/ui/utils/TableRenderer.js.map +1 -1
  301. package/dist/src/ui/utils/clipboardUtils.js +5 -6
  302. package/dist/src/ui/utils/clipboardUtils.js.map +1 -1
  303. package/dist/src/ui/utils/displayUtils.js +4 -4
  304. package/dist/src/ui/utils/displayUtils.js.map +1 -1
  305. package/dist/src/ui/utils/textUtils.d.ts +9 -0
  306. package/dist/src/ui/utils/textUtils.js +52 -3
  307. package/dist/src/ui/utils/textUtils.js.map +1 -1
  308. package/dist/src/utils/commands.d.ts +20 -0
  309. package/dist/src/utils/commands.js +53 -0
  310. package/dist/src/utils/commands.js.map +1 -0
  311. package/dist/src/utils/commands.test.d.ts +6 -0
  312. package/dist/src/utils/commands.test.js +115 -0
  313. package/dist/src/utils/commands.test.js.map +1 -0
  314. package/dist/src/utils/commentJson.d.ts +9 -0
  315. package/dist/src/utils/commentJson.js +48 -0
  316. package/dist/src/utils/commentJson.js.map +1 -0
  317. package/dist/src/utils/commentJson.test.d.ts +6 -0
  318. package/dist/src/utils/commentJson.test.js +146 -0
  319. package/dist/src/utils/commentJson.test.js.map +1 -0
  320. package/dist/src/utils/errors.d.ts +21 -0
  321. package/dist/src/utils/errors.js +93 -0
  322. package/dist/src/utils/errors.js.map +1 -1
  323. package/dist/src/utils/errors.test.d.ts +6 -0
  324. package/dist/src/utils/errors.test.js +303 -0
  325. package/dist/src/utils/errors.test.js.map +1 -0
  326. package/dist/src/utils/sandbox.js +2 -0
  327. package/dist/src/utils/sandbox.js.map +1 -1
  328. package/dist/src/utils/settingsUtils.test.js +37 -2
  329. package/dist/src/utils/settingsUtils.test.js.map +1 -1
  330. package/dist/src/validateNonInterActiveAuth.js +30 -18
  331. package/dist/src/validateNonInterActiveAuth.js.map +1 -1
  332. package/dist/src/zed-integration/schema.d.ts +18 -18
  333. package/dist/src/zed-integration/zedIntegration.js +10 -7
  334. package/dist/src/zed-integration/zedIntegration.js.map +1 -1
  335. package/dist/tsconfig.tsbuildinfo +1 -1
  336. package/package.json +5 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.test.js","sourceRoot":"","sources":["../../../src/utils/commands.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAqB,MAAM,yBAAyB,CAAC;AAEzE,qCAAqC;AACrC,MAAM,YAAY,GAA4B;IAC5C;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,WAAW;QACxB,MAAM,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;QACtB,IAAI,EAAE,WAAW,CAAC,QAAQ;KAC3B;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,gBAAgB;QAC7B,MAAM,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;QACtB,IAAI,EAAE,WAAW,CAAC,IAAI;KACvB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,eAAe;QAC5B,QAAQ,EAAE,CAAC,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-0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Updates a JSON file while preserving comments and formatting.
8
+ */
9
+ export declare function updateSettingsFilePreservingFormat(filePath: string, updates: Record<string, unknown>): void;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import * as fs from 'node:fs';
7
+ import { parse, stringify } from 'comment-json';
8
+ /**
9
+ * Updates a JSON file while preserving comments and formatting.
10
+ */
11
+ export function updateSettingsFilePreservingFormat(filePath, updates) {
12
+ if (!fs.existsSync(filePath)) {
13
+ fs.writeFileSync(filePath, JSON.stringify(updates, null, 2), 'utf-8');
14
+ return;
15
+ }
16
+ const originalContent = fs.readFileSync(filePath, 'utf-8');
17
+ let parsed;
18
+ try {
19
+ parsed = parse(originalContent);
20
+ }
21
+ catch (error) {
22
+ console.error('Error parsing settings file:', error);
23
+ console.error('Settings file may be corrupted. Please check the JSON syntax.');
24
+ return;
25
+ }
26
+ const updatedStructure = applyUpdates(parsed, updates);
27
+ const updatedContent = stringify(updatedStructure, null, 2);
28
+ fs.writeFileSync(filePath, updatedContent, 'utf-8');
29
+ }
30
+ function applyUpdates(current, updates) {
31
+ const result = current;
32
+ for (const key of Object.getOwnPropertyNames(updates)) {
33
+ const value = updates[key];
34
+ if (typeof value === 'object' &&
35
+ value !== null &&
36
+ !Array.isArray(value) &&
37
+ typeof result[key] === 'object' &&
38
+ result[key] !== null &&
39
+ !Array.isArray(result[key])) {
40
+ result[key] = applyUpdates(result[key], value);
41
+ }
42
+ else {
43
+ result[key] = value;
44
+ }
45
+ }
46
+ return result;
47
+ }
48
+ //# sourceMappingURL=commentJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commentJson.js","sourceRoot":"","sources":["../../../src/utils/commentJson.ts"],"names":[],"mappings":"AAAA;;;;GAI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,KAAK,KAAK,IAAI;YACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACrB,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ;YAC/B,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI;YACpB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAC3B,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CACxB,MAAM,CAAC,GAAG,CAA4B,EACtC,KAAgC,CACjC,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export {};
@@ -0,0 +1,146 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
7
+ import * as fs from 'node:fs';
8
+ import * as path from 'node:path';
9
+ import * as os from 'node:os';
10
+ import { updateSettingsFilePreservingFormat } from './commentJson.js';
11
+ describe('commentJson', () => {
12
+ let tempDir;
13
+ let testFilePath;
14
+ beforeEach(() => {
15
+ // Create a temporary directory for test files
16
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'preserve-format-test-'));
17
+ testFilePath = path.join(tempDir, 'settings.json');
18
+ });
19
+ afterEach(() => {
20
+ // Clean up temporary directory
21
+ if (fs.existsSync(tempDir)) {
22
+ fs.rmSync(tempDir, { recursive: true, force: true });
23
+ }
24
+ });
25
+ describe('updateSettingsFilePreservingFormat', () => {
26
+ it('should preserve comments when updating settings', () => {
27
+ const originalContent = `{
28
+ // Model configuration
29
+ "model": "gemini-2.5-pro",
30
+ "ui": {
31
+ // Theme setting
32
+ "theme": "dark"
33
+ }
34
+ }`;
35
+ fs.writeFileSync(testFilePath, originalContent, 'utf-8');
36
+ updateSettingsFilePreservingFormat(testFilePath, {
37
+ model: 'gemini-2.5-flash',
38
+ });
39
+ const updatedContent = fs.readFileSync(testFilePath, 'utf-8');
40
+ expect(updatedContent).toContain('// Model configuration');
41
+ expect(updatedContent).toContain('// Theme setting');
42
+ expect(updatedContent).toContain('"model": "gemini-2.5-flash"');
43
+ expect(updatedContent).toContain('"theme": "dark"');
44
+ });
45
+ it('should handle nested object updates', () => {
46
+ const originalContent = `{
47
+ "ui": {
48
+ "theme": "dark",
49
+ "showLineNumbers": true
50
+ }
51
+ }`;
52
+ fs.writeFileSync(testFilePath, originalContent, 'utf-8');
53
+ updateSettingsFilePreservingFormat(testFilePath, {
54
+ ui: {
55
+ theme: 'light',
56
+ showLineNumbers: true,
57
+ },
58
+ });
59
+ const updatedContent = fs.readFileSync(testFilePath, 'utf-8');
60
+ expect(updatedContent).toContain('"theme": "light"');
61
+ expect(updatedContent).toContain('"showLineNumbers": true');
62
+ });
63
+ it('should add new fields while preserving existing structure', () => {
64
+ const originalContent = `{
65
+ // Existing config
66
+ "model": "gemini-2.5-pro"
67
+ }`;
68
+ fs.writeFileSync(testFilePath, originalContent, 'utf-8');
69
+ updateSettingsFilePreservingFormat(testFilePath, {
70
+ model: 'gemini-2.5-pro',
71
+ newField: 'newValue',
72
+ });
73
+ const updatedContent = fs.readFileSync(testFilePath, 'utf-8');
74
+ expect(updatedContent).toContain('// Existing config');
75
+ expect(updatedContent).toContain('"newField": "newValue"');
76
+ });
77
+ it('should create file if it does not exist', () => {
78
+ updateSettingsFilePreservingFormat(testFilePath, {
79
+ model: 'gemini-2.5-pro',
80
+ });
81
+ expect(fs.existsSync(testFilePath)).toBe(true);
82
+ const content = fs.readFileSync(testFilePath, 'utf-8');
83
+ expect(content).toContain('"model": "gemini-2.5-pro"');
84
+ });
85
+ it('should handle complex real-world scenario', () => {
86
+ const complexContent = `{
87
+ // Settings
88
+ "model": "gemini-2.5-pro",
89
+ "mcpServers": {
90
+ // Active server
91
+ "context7": {
92
+ "headers": {
93
+ "API_KEY": "test-key" // API key
94
+ }
95
+ }
96
+ }
97
+ }`;
98
+ fs.writeFileSync(testFilePath, complexContent, 'utf-8');
99
+ updateSettingsFilePreservingFormat(testFilePath, {
100
+ model: 'gemini-2.5-flash',
101
+ mcpServers: {
102
+ context7: {
103
+ headers: {
104
+ API_KEY: 'new-test-key',
105
+ },
106
+ },
107
+ },
108
+ newSection: {
109
+ setting: 'value',
110
+ },
111
+ });
112
+ const updatedContent = fs.readFileSync(testFilePath, 'utf-8');
113
+ // Verify comments preserved
114
+ expect(updatedContent).toContain('// Settings');
115
+ expect(updatedContent).toContain('// Active server');
116
+ expect(updatedContent).toContain('// API key');
117
+ // Verify updates applied
118
+ expect(updatedContent).toContain('"model": "gemini-2.5-flash"');
119
+ expect(updatedContent).toContain('"newSection"');
120
+ expect(updatedContent).toContain('"API_KEY": "new-test-key"');
121
+ });
122
+ it('should handle corrupted JSON files gracefully', () => {
123
+ const corruptedContent = `{
124
+ "model": "gemini-2.5-pro",
125
+ "ui": {
126
+ "theme": "dark"
127
+ // Missing closing brace
128
+ `;
129
+ fs.writeFileSync(testFilePath, corruptedContent, 'utf-8');
130
+ const consoleSpy = vi
131
+ .spyOn(console, 'error')
132
+ .mockImplementation(() => { });
133
+ expect(() => {
134
+ updateSettingsFilePreservingFormat(testFilePath, {
135
+ model: 'gemini-2.5-flash',
136
+ });
137
+ }).not.toThrow();
138
+ expect(consoleSpy).toHaveBeenCalledWith('Error parsing settings file:', expect.any(Error));
139
+ expect(consoleSpy).toHaveBeenCalledWith('Settings file may be corrupted. Please check the JSON syntax.');
140
+ const unchangedContent = fs.readFileSync(testFilePath, 'utf-8');
141
+ expect(unchangedContent).toBe(corruptedContent);
142
+ consoleSpy.mockRestore();
143
+ });
144
+ });
145
+ });
146
+ //# sourceMappingURL=commentJson.test.js.map
@@ -0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,CAAC,CAAC"}
@@ -3,4 +3,25 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import type { Config } from '@google/gemini-cli-core';
6
7
  export declare function getErrorMessage(error: unknown): string;
8
+ /**
9
+ * Handles errors consistently for both JSON and text output formats.
10
+ * In JSON mode, outputs formatted JSON error and exits.
11
+ * In text mode, outputs error message and re-throws.
12
+ */
13
+ export declare function handleError(error: unknown, config: Config, customErrorCode?: string | number): never;
14
+ /**
15
+ * Handles tool execution errors specifically.
16
+ * In JSON mode, outputs formatted JSON error and exits.
17
+ * In text mode, outputs error message to stderr only.
18
+ */
19
+ export declare function handleToolError(toolName: string, toolError: Error, config: Config, errorCode?: string | number, resultDisplay?: string): void;
20
+ /**
21
+ * Handles cancellation/abort signals consistently.
22
+ */
23
+ export declare function handleCancellationError(config: Config): never;
24
+ /**
25
+ * Handles max session turns exceeded consistently.
26
+ */
27
+ export declare function handleMaxTurnsExceededError(config: Config): never;
@@ -3,10 +3,103 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { OutputFormat, JsonFormatter, parseAndFormatApiError, FatalTurnLimitedError, FatalToolExecutionError, FatalCancellationError, } from '@google/gemini-cli-core';
6
7
  export function getErrorMessage(error) {
7
8
  if (error instanceof Error) {
8
9
  return error.message;
9
10
  }
10
11
  return String(error);
11
12
  }
13
+ /**
14
+ * Extracts the appropriate error code from an error object.
15
+ */
16
+ function extractErrorCode(error) {
17
+ const errorWithCode = error;
18
+ // Prioritize exitCode for FatalError types, fall back to other codes
19
+ if (typeof errorWithCode.exitCode === 'number') {
20
+ return errorWithCode.exitCode;
21
+ }
22
+ if (errorWithCode.code !== undefined) {
23
+ return errorWithCode.code;
24
+ }
25
+ if (errorWithCode.status !== undefined) {
26
+ return errorWithCode.status;
27
+ }
28
+ return 1; // Default exit code
29
+ }
30
+ /**
31
+ * Converts an error code to a numeric exit code.
32
+ */
33
+ function getNumericExitCode(errorCode) {
34
+ return typeof errorCode === 'number' ? errorCode : 1;
35
+ }
36
+ /**
37
+ * Handles errors consistently for both JSON and text output formats.
38
+ * In JSON mode, outputs formatted JSON error and exits.
39
+ * In text mode, outputs error message and re-throws.
40
+ */
41
+ export function handleError(error, config, customErrorCode) {
42
+ const errorMessage = parseAndFormatApiError(error, config.getContentGeneratorConfig()?.authType);
43
+ if (config.getOutputFormat() === OutputFormat.JSON) {
44
+ const formatter = new JsonFormatter();
45
+ const errorCode = customErrorCode ?? extractErrorCode(error);
46
+ const formattedError = formatter.formatError(error instanceof Error ? error : new Error(getErrorMessage(error)), errorCode);
47
+ console.error(formattedError);
48
+ process.exit(getNumericExitCode(errorCode));
49
+ }
50
+ else {
51
+ console.error(errorMessage);
52
+ throw error;
53
+ }
54
+ }
55
+ /**
56
+ * Handles tool execution errors specifically.
57
+ * In JSON mode, outputs formatted JSON error and exits.
58
+ * In text mode, outputs error message to stderr only.
59
+ */
60
+ export function handleToolError(toolName, toolError, config, errorCode, resultDisplay) {
61
+ const errorMessage = `Error executing tool ${toolName}: ${resultDisplay || toolError.message}`;
62
+ const toolExecutionError = new FatalToolExecutionError(errorMessage);
63
+ if (config.getOutputFormat() === OutputFormat.JSON) {
64
+ const formatter = new JsonFormatter();
65
+ const formattedError = formatter.formatError(toolExecutionError, errorCode ?? toolExecutionError.exitCode);
66
+ console.error(formattedError);
67
+ process.exit(typeof errorCode === 'number' ? errorCode : toolExecutionError.exitCode);
68
+ }
69
+ else {
70
+ console.error(errorMessage);
71
+ }
72
+ }
73
+ /**
74
+ * Handles cancellation/abort signals consistently.
75
+ */
76
+ export function handleCancellationError(config) {
77
+ const cancellationError = new FatalCancellationError('Operation cancelled.');
78
+ if (config.getOutputFormat() === OutputFormat.JSON) {
79
+ const formatter = new JsonFormatter();
80
+ const formattedError = formatter.formatError(cancellationError, cancellationError.exitCode);
81
+ console.error(formattedError);
82
+ process.exit(cancellationError.exitCode);
83
+ }
84
+ else {
85
+ console.error(cancellationError.message);
86
+ process.exit(cancellationError.exitCode);
87
+ }
88
+ }
89
+ /**
90
+ * Handles max session turns exceeded consistently.
91
+ */
92
+ export function handleMaxTurnsExceededError(config) {
93
+ const maxTurnsError = new FatalTurnLimitedError('Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json.');
94
+ if (config.getOutputFormat() === OutputFormat.JSON) {
95
+ const formatter = new JsonFormatter();
96
+ const formattedError = formatter.formatError(maxTurnsError, maxTurnsError.exitCode);
97
+ console.error(formattedError);
98
+ process.exit(maxTurnsError.exitCode);
99
+ }
100
+ else {
101
+ console.error(maxTurnsError.message);
102
+ process.exit(maxTurnsError.exitCode);
103
+ }
104
+ }
12
105
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAQD;;GAEG;AACH,SAAS,gBAAgB,CAAC,KAAc;IACtC,MAAM,aAAa,GAAG,KAAsB,CAAC;IAE7C,q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