@google/gemini-cli 0.1.10-dev.0 → 0.1.10-dev.11
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.
- package/LICENSE +202 -0
- package/README.md +142 -0
- package/dist/.last_build +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +80 -0
- package/dist/src/config/auth.d.ts +6 -0
- package/dist/src/config/auth.js +32 -0
- package/dist/src/config/auth.js.map +1 -0
- package/dist/src/config/config.d.ts +14 -0
- package/dist/src/config/config.js +235 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/extension.d.ts +20 -0
- package/dist/src/config/extension.js +81 -0
- package/dist/src/config/extension.js.map +1 -0
- package/dist/src/config/sandboxConfig.d.ts +13 -0
- package/dist/src/config/sandboxConfig.js +75 -0
- package/dist/src/config/sandboxConfig.js.map +1 -0
- package/dist/src/config/settings.d.ts +70 -0
- package/dist/src/config/settings.js +165 -0
- package/dist/src/config/settings.js.map +1 -0
- package/dist/src/gemini.d.ts +6 -0
- package/dist/src/gemini.js +217 -0
- package/dist/src/gemini.js.map +1 -0
- package/dist/src/gemini.test.d.ts +6 -0
- package/dist/src/gemini.test.js +122 -0
- package/dist/src/gemini.test.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +6 -0
- package/dist/src/generated/git-commit.js +9 -0
- package/dist/src/generated/git-commit.js.map +1 -0
- package/dist/src/nonInteractiveCli.d.ts +7 -0
- package/dist/src/nonInteractiveCli.js +115 -0
- package/dist/src/nonInteractiveCli.js.map +1 -0
- package/dist/src/ui/App.d.ts +14 -0
- package/dist/src/ui/App.js +387 -0
- package/dist/src/ui/App.js.map +1 -0
- package/dist/src/ui/App.test.d.ts +6 -0
- package/dist/src/ui/App.test.js +299 -0
- package/dist/src/ui/App.test.js.map +1 -0
- package/dist/src/ui/colors.d.ts +7 -0
- package/dist/src/ui/colors.js +48 -0
- package/dist/src/ui/colors.js.map +1 -0
- package/dist/src/ui/components/AboutBox.d.ts +16 -0
- package/dist/src/ui/components/AboutBox.js +6 -0
- package/dist/src/ui/components/AboutBox.js.map +1 -0
- package/dist/src/ui/components/AsciiArt.d.ts +7 -0
- package/dist/src/ui/components/AsciiArt.js +26 -0
- package/dist/src/ui/components/AsciiArt.js.map +1 -0
- package/dist/src/ui/components/AuthDialog.d.ts +15 -0
- package/dist/src/ui/components/AuthDialog.js +47 -0
- package/dist/src/ui/components/AuthDialog.js.map +1 -0
- package/dist/src/ui/components/AuthDialog.test.d.ts +6 -0
- package/dist/src/ui/components/AuthDialog.test.js +69 -0
- package/dist/src/ui/components/AuthDialog.test.js.map +1 -0
- package/dist/src/ui/components/AuthInProgress.d.ts +11 -0
- package/dist/src/ui/components/AuthInProgress.js +27 -0
- package/dist/src/ui/components/AuthInProgress.js.map +1 -0
- package/dist/src/ui/components/AutoAcceptIndicator.d.ts +12 -0
- package/dist/src/ui/components/AutoAcceptIndicator.js +26 -0
- package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -0
- package/dist/src/ui/components/ConsolePatcher.d.ts +12 -0
- package/dist/src/ui/components/ConsolePatcher.js +40 -0
- package/dist/src/ui/components/ConsolePatcher.js.map +1 -0
- package/dist/src/ui/components/ConsoleSummaryDisplay.d.ts +11 -0
- package/dist/src/ui/components/ConsoleSummaryDisplay.js +11 -0
- package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -0
- package/dist/src/ui/components/ContextSummaryDisplay.d.ts +15 -0
- package/dist/src/ui/components/ContextSummaryDisplay.js +41 -0
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -0
- package/dist/src/ui/components/DetailedMessagesDisplay.d.ts +14 -0
- package/dist/src/ui/components/DetailedMessagesDisplay.js +34 -0
- package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -0
- package/dist/src/ui/components/EditorSettingsDialog.d.ts +15 -0
- package/dist/src/ui/components/EditorSettingsDialog.js +73 -0
- package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -0
- package/dist/src/ui/components/Footer.d.ts +20 -0
- package/dist/src/ui/components/Footer.js +13 -0
- package/dist/src/ui/components/Footer.js.map +1 -0
- package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +17 -0
- package/dist/src/ui/components/GeminiRespondingSpinner.js +16 -0
- package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -0
- package/dist/src/ui/components/Header.d.ts +12 -0
- package/dist/src/ui/components/Header.js +20 -0
- package/dist/src/ui/components/Header.js.map +1 -0
- package/dist/src/ui/components/Help.d.ts +12 -0
- package/dist/src/ui/components/Help.js +9 -0
- package/dist/src/ui/components/Help.js.map +1 -0
- package/dist/src/ui/components/HistoryItemDisplay.d.ts +18 -0
- package/dist/src/ui/components/HistoryItemDisplay.js +17 -0
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.js +81 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -0
- package/dist/src/ui/components/InputPrompt.d.ts +24 -0
- package/dist/src/ui/components/InputPrompt.js +331 -0
- package/dist/src/ui/components/InputPrompt.js.map +1 -0
- package/dist/src/ui/components/InputPrompt.test.d.ts +6 -0
- package/dist/src/ui/components/InputPrompt.test.js +154 -0
- package/dist/src/ui/components/InputPrompt.test.js.map +1 -0
- package/dist/src/ui/components/LoadingIndicator.d.ts +15 -0
- package/dist/src/ui/components/LoadingIndicator.js +19 -0
- package/dist/src/ui/components/LoadingIndicator.js.map +1 -0
- package/dist/src/ui/components/LoadingIndicator.test.d.ts +6 -0
- package/dist/src/ui/components/LoadingIndicator.test.js +141 -0
- package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -0
- package/dist/src/ui/components/MemoryUsageDisplay.d.ts +7 -0
- package/dist/src/ui/components/MemoryUsageDisplay.js +27 -0
- package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -0
- package/dist/src/ui/components/ModelStatsDisplay.d.ts +7 -0
- package/dist/src/ui/components/ModelStatsDisplay.js +33 -0
- package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.js +217 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/SessionSummaryDisplay.d.ts +11 -0
- package/dist/src/ui/components/SessionSummaryDisplay.js +4 -0
- package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -0
- package/dist/src/ui/components/SessionSummaryDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/SessionSummaryDisplay.test.js +60 -0
- package/dist/src/ui/components/SessionSummaryDisplay.test.js.map +1 -0
- package/dist/src/ui/components/ShellModeIndicator.d.ts +7 -0
- package/dist/src/ui/components/ShellModeIndicator.js +5 -0
- package/dist/src/ui/components/ShellModeIndicator.js.map +1 -0
- package/dist/src/ui/components/ShowMoreLines.d.ts +10 -0
- package/dist/src/ui/components/ShowMoreLines.js +24 -0
- package/dist/src/ui/components/ShowMoreLines.js.map +1 -0
- package/dist/src/ui/components/StatsDisplay.d.ts +12 -0
- package/dist/src/ui/components/StatsDisplay.js +42 -0
- package/dist/src/ui/components/StatsDisplay.js.map +1 -0
- package/dist/src/ui/components/StatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/StatsDisplay.test.js +275 -0
- package/dist/src/ui/components/StatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/SuggestionsDisplay.d.ts +21 -0
- package/dist/src/ui/components/SuggestionsDisplay.js +32 -0
- package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -0
- package/dist/src/ui/components/ThemeDialog.d.ts +19 -0
- package/dist/src/ui/components/ThemeDialog.js +126 -0
- package/dist/src/ui/components/ThemeDialog.js.map +1 -0
- package/dist/src/ui/components/Tips.d.ts +12 -0
- package/dist/src/ui/components/Tips.js +8 -0
- package/dist/src/ui/components/Tips.js.map +1 -0
- package/dist/src/ui/components/ToolStatsDisplay.d.ts +7 -0
- package/dist/src/ui/components/ToolStatsDisplay.js +41 -0
- package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.js +160 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/UpdateNotification.d.ts +10 -0
- package/dist/src/ui/components/UpdateNotification.js +10 -0
- package/dist/src/ui/components/UpdateNotification.js.map +1 -0
- package/dist/src/ui/components/messages/CompressionMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/CompressionMessage.js +16 -0
- package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -0
- package/dist/src/ui/components/messages/DiffRenderer.d.ts +15 -0
- package/dist/src/ui/components/messages/DiffRenderer.js +212 -0
- package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +6 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.js +239 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -0
- package/dist/src/ui/components/messages/ErrorMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/ErrorMessage.js +9 -0
- package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -0
- package/dist/src/ui/components/messages/GeminiMessage.d.ts +14 -0
- package/dist/src/ui/components/messages/GeminiMessage.js +10 -0
- package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -0
- package/dist/src/ui/components/messages/GeminiMessageContent.d.ts +14 -0
- package/dist/src/ui/components/messages/GeminiMessageContent.js +15 -0
- package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -0
- package/dist/src/ui/components/messages/InfoMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/InfoMessage.js +9 -0
- package/dist/src/ui/components/messages/InfoMessage.js.map +1 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.d.ts +15 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +111 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +37 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +18 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.js +53 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -0
- package/dist/src/ui/components/messages/ToolMessage.d.ts +15 -0
- package/dist/src/ui/components/messages/ToolMessage.js +61 -0
- package/dist/src/ui/components/messages/ToolMessage.js.map +1 -0
- package/dist/src/ui/components/messages/ToolMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolMessage.test.js +116 -0
- package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -0
- package/dist/src/ui/components/messages/UserMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/UserMessage.js +9 -0
- package/dist/src/ui/components/messages/UserMessage.js.map +1 -0
- package/dist/src/ui/components/messages/UserShellMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/UserShellMessage.js +9 -0
- package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -0
- package/dist/src/ui/components/shared/MaxSizedBox.d.ts +61 -0
- package/dist/src/ui/components/shared/MaxSizedBox.js +384 -0
- package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +6 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.js +134 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +41 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.js +52 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
- package/dist/src/ui/components/shared/text-buffer.d.ts +128 -0
- package/dist/src/ui/components/shared/text-buffer.js +1122 -0
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -0
- package/dist/src/ui/constants.d.ts +8 -0
- package/dist/src/ui/constants.js +12 -0
- package/dist/src/ui/constants.js.map +1 -0
- package/dist/src/ui/contexts/OverflowContext.d.ts +19 -0
- package/dist/src/ui/contexts/OverflowContext.js +43 -0
- package/dist/src/ui/contexts/OverflowContext.js.map +1 -0
- package/dist/src/ui/contexts/SessionContext.d.ts +33 -0
- package/dist/src/ui/contexts/SessionContext.js +49 -0
- package/dist/src/ui/contexts/SessionContext.js.map +1 -0
- package/dist/src/ui/contexts/SessionContext.test.d.ts +6 -0
- package/dist/src/ui/contexts/SessionContext.test.js +96 -0
- package/dist/src/ui/contexts/SessionContext.test.js.map +1 -0
- package/dist/src/ui/contexts/StreamingContext.d.ts +9 -0
- package/dist/src/ui/contexts/StreamingContext.js +15 -0
- package/dist/src/ui/contexts/StreamingContext.js.map +1 -0
- package/dist/src/ui/editors/editorSettingsManager.d.ts +19 -0
- package/dist/src/ui/editors/editorSettingsManager.js +54 -0
- package/dist/src/ui/editors/editorSettingsManager.js.map +1 -0
- package/dist/src/ui/hooks/atCommandProcessor.d.ts +31 -0
- package/dist/src/ui/hooks/atCommandProcessor.js +312 -0
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
- package/dist/src/ui/hooks/shellCommandProcessor.d.ts +16 -0
- package/dist/src/ui/hooks/shellCommandProcessor.js +261 -0
- package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +31 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js +981 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
- package/dist/src/ui/hooks/useAuthCommand.d.ts +14 -0
- package/dist/src/ui/hooks/useAuthCommand.js +54 -0
- package/dist/src/ui/hooks/useAuthCommand.js.map +1 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +10 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js +37 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -0
- package/dist/src/ui/hooks/useBracketedPaste.d.ts +12 -0
- package/dist/src/ui/hooks/useBracketedPaste.js +32 -0
- package/dist/src/ui/hooks/useBracketedPaste.js.map +1 -0
- package/dist/src/ui/hooks/useCompletion.d.ts +21 -0
- package/dist/src/ui/hooks/useCompletion.js +322 -0
- package/dist/src/ui/hooks/useCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useConsoleMessages.d.ts +12 -0
- package/dist/src/ui/hooks/useConsoleMessages.js +60 -0
- package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -0
- package/dist/src/ui/hooks/useEditorSettings.d.ts +16 -0
- package/dist/src/ui/hooks/useEditorSettings.js +43 -0
- package/dist/src/ui/hooks/useEditorSettings.js.map +1 -0
- package/dist/src/ui/hooks/useGeminiStream.d.ts +23 -0
- package/dist/src/ui/hooks/useGeminiStream.js +524 -0
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -0
- package/dist/src/ui/hooks/useGeminiStream.test.d.ts +6 -0
- package/dist/src/ui/hooks/useGeminiStream.test.js +775 -0
- package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -0
- package/dist/src/ui/hooks/useGitBranchName.d.ts +6 -0
- package/dist/src/ui/hooks/useGitBranchName.js +61 -0
- package/dist/src/ui/hooks/useGitBranchName.js.map +1 -0
- package/dist/src/ui/hooks/useHistoryManager.d.ts +22 -0
- package/dist/src/ui/hooks/useHistoryManager.js +72 -0
- package/dist/src/ui/hooks/useHistoryManager.js.map +1 -0
- package/dist/src/ui/hooks/useInputHistory.d.ts +19 -0
- package/dist/src/ui/hooks/useInputHistory.js +84 -0
- package/dist/src/ui/hooks/useInputHistory.js.map +1 -0
- package/dist/src/ui/hooks/useKeypress.d.ts +29 -0
- package/dist/src/ui/hooks/useKeypress.js +86 -0
- package/dist/src/ui/hooks/useKeypress.js.map +1 -0
- package/dist/src/ui/hooks/useLoadingIndicator.d.ts +10 -0
- package/dist/src/ui/hooks/useLoadingIndicator.js +44 -0
- package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -0
- package/dist/src/ui/hooks/useLogger.d.ts +10 -0
- package/dist/src/ui/hooks/useLogger.js +29 -0
- package/dist/src/ui/hooks/useLogger.js.map +1 -0
- package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
- package/dist/src/ui/hooks/usePhraseCycler.js +189 -0
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -0
- package/dist/src/ui/hooks/usePrivacySettings.d.ts +16 -0
- package/dist/src/ui/hooks/usePrivacySettings.js +115 -0
- package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -0
- package/dist/src/ui/hooks/useReactToolScheduler.d.ts +33 -0
- package/dist/src/ui/hooks/useReactToolScheduler.js +186 -0
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -0
- package/dist/src/ui/hooks/useRefreshMemoryCommand.d.ts +6 -0
- package/dist/src/ui/hooks/useRefreshMemoryCommand.js +7 -0
- package/dist/src/ui/hooks/useRefreshMemoryCommand.js.map +1 -0
- package/dist/src/ui/hooks/useShellHistory.d.ts +11 -0
- package/dist/src/ui/hooks/useShellHistory.js +89 -0
- package/dist/src/ui/hooks/useShellHistory.js.map +1 -0
- package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +9 -0
- package/dist/src/ui/hooks/useShowMemoryCommand.js +58 -0
- package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
- package/dist/src/ui/hooks/useStateAndRef.d.ts +7 -0
- package/dist/src/ui/hooks/useStateAndRef.js +26 -0
- package/dist/src/ui/hooks/useStateAndRef.js.map +1 -0
- package/dist/src/ui/hooks/useTerminalSize.d.ts +9 -0
- package/dist/src/ui/hooks/useTerminalSize.js +27 -0
- package/dist/src/ui/hooks/useTerminalSize.js.map +1 -0
- package/dist/src/ui/hooks/useThemeCommand.d.ts +15 -0
- package/dist/src/ui/hooks/useThemeCommand.js +78 -0
- package/dist/src/ui/hooks/useThemeCommand.js.map +1 -0
- package/dist/src/ui/hooks/useTimer.d.ts +12 -0
- package/dist/src/ui/hooks/useTimer.js +58 -0
- package/dist/src/ui/hooks/useTimer.js.map +1 -0
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.d.ts +12 -0
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +40 -0
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -0
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.d.ts +10 -0
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +17 -0
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -0
- package/dist/src/ui/privacy/GeminiPrivacyNotice.d.ts +10 -0
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js +17 -0
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -0
- package/dist/src/ui/privacy/PrivacyNotice.d.ts +12 -0
- package/dist/src/ui/privacy/PrivacyNotice.js +25 -0
- package/dist/src/ui/privacy/PrivacyNotice.js.map +1 -0
- package/dist/src/ui/themes/ansi-light.d.ts +7 -0
- package/dist/src/ui/themes/ansi-light.js +139 -0
- package/dist/src/ui/themes/ansi-light.js.map +1 -0
- package/dist/src/ui/themes/ansi.d.ts +7 -0
- package/dist/src/ui/themes/ansi.js +149 -0
- package/dist/src/ui/themes/ansi.js.map +1 -0
- package/dist/src/ui/themes/atom-one-dark.d.ts +7 -0
- package/dist/src/ui/themes/atom-one-dark.js +136 -0
- package/dist/src/ui/themes/atom-one-dark.js.map +1 -0
- package/dist/src/ui/themes/ayu-light.d.ts +7 -0
- package/dist/src/ui/themes/ayu-light.js +128 -0
- package/dist/src/ui/themes/ayu-light.js.map +1 -0
- package/dist/src/ui/themes/ayu.d.ts +7 -0
- package/dist/src/ui/themes/ayu.js +102 -0
- package/dist/src/ui/themes/ayu.js.map +1 -0
- package/dist/src/ui/themes/default-light.d.ts +7 -0
- package/dist/src/ui/themes/default-light.js +100 -0
- package/dist/src/ui/themes/default-light.js.map +1 -0
- package/dist/src/ui/themes/default.d.ts +7 -0
- package/dist/src/ui/themes/default.js +143 -0
- package/dist/src/ui/themes/default.js.map +1 -0
- package/dist/src/ui/themes/dracula.d.ts +7 -0
- package/dist/src/ui/themes/dracula.js +113 -0
- package/dist/src/ui/themes/dracula.js.map +1 -0
- package/dist/src/ui/themes/github-dark.d.ts +7 -0
- package/dist/src/ui/themes/github-dark.js +136 -0
- package/dist/src/ui/themes/github-dark.js.map +1 -0
- package/dist/src/ui/themes/github-light.d.ts +7 -0
- package/dist/src/ui/themes/github-light.js +138 -0
- package/dist/src/ui/themes/github-light.js.map +1 -0
- package/dist/src/ui/themes/googlecode.d.ts +7 -0
- package/dist/src/ui/themes/googlecode.js +135 -0
- package/dist/src/ui/themes/googlecode.js.map +1 -0
- package/dist/src/ui/themes/no-color.d.ts +7 -0
- package/dist/src/ui/themes/no-color.js +84 -0
- package/dist/src/ui/themes/no-color.js.map +1 -0
- package/dist/src/ui/themes/shades-of-purple.d.ts +11 -0
- package/dist/src/ui/themes/shades-of-purple.js +302 -0
- package/dist/src/ui/themes/shades-of-purple.js.map +1 -0
- package/dist/src/ui/themes/theme-manager.d.ts +33 -0
- package/dist/src/ui/themes/theme-manager.js +109 -0
- package/dist/src/ui/themes/theme-manager.js.map +1 -0
- package/dist/src/ui/themes/theme.d.ts +67 -0
- package/dist/src/ui/themes/theme.js +304 -0
- package/dist/src/ui/themes/theme.js.map +1 -0
- package/dist/src/ui/themes/xcode.d.ts +7 -0
- package/dist/src/ui/themes/xcode.js +143 -0
- package/dist/src/ui/themes/xcode.js.map +1 -0
- package/dist/src/ui/types.d.ts +162 -0
- package/dist/src/ui/types.js +43 -0
- package/dist/src/ui/types.js.map +1 -0
- package/dist/src/ui/utils/CodeColorizer.d.ts +14 -0
- package/dist/src/ui/utils/CodeColorizer.js +97 -0
- package/dist/src/ui/utils/CodeColorizer.js.map +1 -0
- package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
- package/dist/src/ui/utils/MarkdownDisplay.js +276 -0
- package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +6 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.js +176 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -0
- package/dist/src/ui/utils/TableRenderer.d.ts +17 -0
- package/dist/src/ui/utils/TableRenderer.js +66 -0
- package/dist/src/ui/utils/TableRenderer.js.map +1 -0
- package/dist/src/ui/utils/commandUtils.d.ts +22 -0
- package/dist/src/ui/utils/commandUtils.js +25 -0
- package/dist/src/ui/utils/commandUtils.js.map +1 -0
- package/dist/src/ui/utils/computeStats.d.ts +10 -0
- package/dist/src/ui/utils/computeStats.js +55 -0
- package/dist/src/ui/utils/computeStats.js.map +1 -0
- package/dist/src/ui/utils/displayUtils.d.ts +17 -0
- package/dist/src/ui/utils/displayUtils.js +24 -0
- package/dist/src/ui/utils/displayUtils.js.map +1 -0
- package/dist/src/ui/utils/errorParsing.d.ts +15 -0
- package/dist/src/ui/utils/errorParsing.js +79 -0
- package/dist/src/ui/utils/errorParsing.js.map +1 -0
- package/dist/src/ui/utils/formatters.d.ts +13 -0
- package/dist/src/ui/utils/formatters.js +56 -0
- package/dist/src/ui/utils/formatters.js.map +1 -0
- package/dist/src/ui/utils/markdownUtilities.d.ts +6 -0
- package/dist/src/ui/utils/markdownUtilities.js +110 -0
- package/dist/src/ui/utils/markdownUtilities.js.map +1 -0
- package/dist/src/ui/utils/textUtils.d.ts +22 -0
- package/dist/src/ui/utils/textUtils.js +58 -0
- package/dist/src/ui/utils/textUtils.js.map +1 -0
- package/dist/src/ui/utils/updateCheck.d.ts +6 -0
- package/dist/src/ui/utils/updateCheck.js +36 -0
- package/dist/src/ui/utils/updateCheck.js.map +1 -0
- package/dist/src/utils/cleanup.d.ts +6 -0
- package/dist/src/utils/cleanup.js +19 -0
- package/dist/src/utils/cleanup.js.map +1 -0
- package/dist/src/utils/package.d.ts +12 -0
- package/dist/src/utils/package.js +24 -0
- package/dist/src/utils/package.js.map +1 -0
- package/dist/src/utils/readStdin.d.ts +6 -0
- package/dist/src/utils/readStdin.js +34 -0
- package/dist/src/utils/readStdin.js.map +1 -0
- package/dist/src/utils/sandbox-macos-permissive-closed.sb +26 -0
- package/dist/src/utils/sandbox-macos-permissive-open.sb +19 -0
- package/dist/src/utils/sandbox-macos-permissive-proxied.sb +31 -0
- package/dist/src/utils/sandbox-macos-restrictive-closed.sb +87 -0
- package/dist/src/utils/sandbox-macos-restrictive-open.sb +90 -0
- package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +92 -0
- package/dist/src/utils/sandbox.d.ts +7 -0
- package/dist/src/utils/sandbox.js +680 -0
- package/dist/src/utils/sandbox.js.map +1 -0
- package/dist/src/utils/startupWarnings.d.ts +6 -0
- package/dist/src/utils/startupWarnings.js +40 -0
- package/dist/src/utils/startupWarnings.js.map +1 -0
- package/dist/src/utils/version.d.ts +6 -0
- package/dist/src/utils/version.js +11 -0
- package/dist/src/utils/version.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,981 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useMemo } from 'react';
|
|
7
|
+
import open from 'open';
|
|
8
|
+
import process from 'node:process';
|
|
9
|
+
import { useStateAndRef } from './useStateAndRef.js';
|
|
10
|
+
import { GitService, Logger, MCPDiscoveryState, MCPServerStatus, getMCPDiscoveryState, getMCPServerStatus, } from '@google/gemini-cli-core';
|
|
11
|
+
import { useSessionStats } from '../contexts/SessionContext.js';
|
|
12
|
+
import { MessageType, } from '../types.js';
|
|
13
|
+
import { promises as fs } from 'fs';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import { createShowMemoryAction } from './useShowMemoryCommand.js';
|
|
16
|
+
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
|
|
17
|
+
import { formatDuration, formatMemoryUsage } from '../utils/formatters.js';
|
|
18
|
+
import { getCliVersion } from '../../utils/version.js';
|
|
19
|
+
/**
|
|
20
|
+
* Hook to define and process slash commands (e.g., /help, /clear).
|
|
21
|
+
*/
|
|
22
|
+
export const useSlashCommandProcessor = (config, settings, history, addItem, clearItems, loadHistory, refreshStatic, setShowHelp, onDebugMessage, openThemeDialog, openAuthDialog, openEditorDialog, performMemoryRefresh, toggleCorgiMode, showToolDescriptions = false, setQuittingMessages, openPrivacyNotice) => {
|
|
23
|
+
const session = useSessionStats();
|
|
24
|
+
const gitService = useMemo(() => {
|
|
25
|
+
if (!config?.getProjectRoot()) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
return new GitService(config.getProjectRoot());
|
|
29
|
+
}, [config]);
|
|
30
|
+
const pendingHistoryItems = [];
|
|
31
|
+
const [pendingCompressionItemRef, setPendingCompressionItem] = useStateAndRef(null);
|
|
32
|
+
if (pendingCompressionItemRef.current != null) {
|
|
33
|
+
pendingHistoryItems.push(pendingCompressionItemRef.current);
|
|
34
|
+
}
|
|
35
|
+
const addMessage = useCallback((message) => {
|
|
36
|
+
// Convert Message to HistoryItemWithoutId
|
|
37
|
+
let historyItemContent;
|
|
38
|
+
if (message.type === MessageType.ABOUT) {
|
|
39
|
+
historyItemContent = {
|
|
40
|
+
type: 'about',
|
|
41
|
+
cliVersion: message.cliVersion,
|
|
42
|
+
osVersion: message.osVersion,
|
|
43
|
+
sandboxEnv: message.sandboxEnv,
|
|
44
|
+
modelVersion: message.modelVersion,
|
|
45
|
+
selectedAuthType: message.selectedAuthType,
|
|
46
|
+
gcpProject: message.gcpProject,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
else if (message.type === MessageType.STATS) {
|
|
50
|
+
historyItemContent = {
|
|
51
|
+
type: 'stats',
|
|
52
|
+
duration: message.duration,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else if (message.type === MessageType.MODEL_STATS) {
|
|
56
|
+
historyItemContent = {
|
|
57
|
+
type: 'model_stats',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
else if (message.type === MessageType.TOOL_STATS) {
|
|
61
|
+
historyItemContent = {
|
|
62
|
+
type: 'tool_stats',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
else if (message.type === MessageType.QUIT) {
|
|
66
|
+
historyItemContent = {
|
|
67
|
+
type: 'quit',
|
|
68
|
+
duration: message.duration,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
else if (message.type === MessageType.COMPRESSION) {
|
|
72
|
+
historyItemContent = {
|
|
73
|
+
type: 'compression',
|
|
74
|
+
compression: message.compression,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
historyItemContent = {
|
|
79
|
+
type: message.type,
|
|
80
|
+
text: message.content,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
addItem(historyItemContent, message.timestamp.getTime());
|
|
84
|
+
}, [addItem]);
|
|
85
|
+
const showMemoryAction = useCallback(async () => {
|
|
86
|
+
const actionFn = createShowMemoryAction(config, settings, addMessage);
|
|
87
|
+
await actionFn();
|
|
88
|
+
}, [config, settings, addMessage]);
|
|
89
|
+
const addMemoryAction = useCallback((_mainCommand, _subCommand, args) => {
|
|
90
|
+
if (!args || args.trim() === '') {
|
|
91
|
+
addMessage({
|
|
92
|
+
type: MessageType.ERROR,
|
|
93
|
+
content: 'Usage: /memory add <text to remember>',
|
|
94
|
+
timestamp: new Date(),
|
|
95
|
+
});
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// UI feedback for attempting to schedule
|
|
99
|
+
addMessage({
|
|
100
|
+
type: MessageType.INFO,
|
|
101
|
+
content: `Attempting to save to memory: "${args.trim()}"`,
|
|
102
|
+
timestamp: new Date(),
|
|
103
|
+
});
|
|
104
|
+
// Return info for scheduling the tool call
|
|
105
|
+
return {
|
|
106
|
+
shouldScheduleTool: true,
|
|
107
|
+
toolName: 'save_memory',
|
|
108
|
+
toolArgs: { fact: args.trim() },
|
|
109
|
+
};
|
|
110
|
+
}, [addMessage]);
|
|
111
|
+
const savedChatTags = useCallback(async () => {
|
|
112
|
+
const geminiDir = config?.getProjectTempDir();
|
|
113
|
+
if (!geminiDir) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const files = await fs.readdir(geminiDir);
|
|
118
|
+
return files
|
|
119
|
+
.filter((file) => file.startsWith('checkpoint-') && file.endsWith('.json'))
|
|
120
|
+
.map((file) => file.replace('checkpoint-', '').replace('.json', ''));
|
|
121
|
+
}
|
|
122
|
+
catch (_err) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
}, [config]);
|
|
126
|
+
const slashCommands = useMemo(() => {
|
|
127
|
+
const commands = [
|
|
128
|
+
{
|
|
129
|
+
name: 'help',
|
|
130
|
+
altName: '?',
|
|
131
|
+
description: 'for help on gemini-cli',
|
|
132
|
+
action: (_mainCommand, _subCommand, _args) => {
|
|
133
|
+
onDebugMessage('Opening help.');
|
|
134
|
+
setShowHelp(true);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'docs',
|
|
139
|
+
description: 'open full Gemini CLI documentation in your browser',
|
|
140
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
|
141
|
+
const docsUrl = 'https://goo.gle/gemini-cli-docs';
|
|
142
|
+
if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
|
|
143
|
+
addMessage({
|
|
144
|
+
type: MessageType.INFO,
|
|
145
|
+
content: `Please open the following URL in your browser to view the documentation:\n${docsUrl}`,
|
|
146
|
+
timestamp: new Date(),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
addMessage({
|
|
151
|
+
type: MessageType.INFO,
|
|
152
|
+
content: `Opening documentation in your browser: ${docsUrl}`,
|
|
153
|
+
timestamp: new Date(),
|
|
154
|
+
});
|
|
155
|
+
await open(docsUrl);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: 'clear',
|
|
161
|
+
description: 'clear the screen and conversation history',
|
|
162
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
|
163
|
+
onDebugMessage('Clearing terminal and resetting chat.');
|
|
164
|
+
clearItems();
|
|
165
|
+
await config?.getGeminiClient()?.resetChat();
|
|
166
|
+
console.clear();
|
|
167
|
+
refreshStatic();
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: 'theme',
|
|
172
|
+
description: 'change the theme',
|
|
173
|
+
action: (_mainCommand, _subCommand, _args) => {
|
|
174
|
+
openThemeDialog();
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'auth',
|
|
179
|
+
description: 'change the auth method',
|
|
180
|
+
action: (_mainCommand, _subCommand, _args) => {
|
|
181
|
+
openAuthDialog();
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: 'editor',
|
|
186
|
+
description: 'set external editor preference',
|
|
187
|
+
action: (_mainCommand, _subCommand, _args) => {
|
|
188
|
+
openEditorDialog();
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'privacy',
|
|
193
|
+
description: 'display the privacy notice',
|
|
194
|
+
action: (_mainCommand, _subCommand, _args) => {
|
|
195
|
+
openPrivacyNotice();
|
|
196
|
+
},
|
|
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: 'memory',
|
|
406
|
+
description: 'manage memory. Usage: /memory <show|refresh|add> [text for add]',
|
|
407
|
+
action: (mainCommand, subCommand, args) => {
|
|
408
|
+
switch (subCommand) {
|
|
409
|
+
case 'show':
|
|
410
|
+
showMemoryAction();
|
|
411
|
+
return;
|
|
412
|
+
case 'refresh':
|
|
413
|
+
performMemoryRefresh();
|
|
414
|
+
return;
|
|
415
|
+
case 'add':
|
|
416
|
+
return addMemoryAction(mainCommand, subCommand, args); // Return the object
|
|
417
|
+
case undefined:
|
|
418
|
+
addMessage({
|
|
419
|
+
type: MessageType.ERROR,
|
|
420
|
+
content: 'Missing command\nUsage: /memory <show|refresh|add> [text for add]',
|
|
421
|
+
timestamp: new Date(),
|
|
422
|
+
});
|
|
423
|
+
return;
|
|
424
|
+
default:
|
|
425
|
+
addMessage({
|
|
426
|
+
type: MessageType.ERROR,
|
|
427
|
+
content: `Unknown /memory command: ${subCommand}. Available: show, refresh, add`,
|
|
428
|
+
timestamp: new Date(),
|
|
429
|
+
});
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
name: 'tools',
|
|
436
|
+
description: 'list available Gemini CLI tools',
|
|
437
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
|
438
|
+
// Check if the _subCommand includes a specific flag to control description visibility
|
|
439
|
+
let useShowDescriptions = showToolDescriptions;
|
|
440
|
+
if (_subCommand === 'desc' || _subCommand === 'descriptions') {
|
|
441
|
+
useShowDescriptions = true;
|
|
442
|
+
}
|
|
443
|
+
else if (_subCommand === 'nodesc' ||
|
|
444
|
+
_subCommand === 'nodescriptions') {
|
|
445
|
+
useShowDescriptions = false;
|
|
446
|
+
}
|
|
447
|
+
else if (_args === 'desc' || _args === 'descriptions') {
|
|
448
|
+
useShowDescriptions = true;
|
|
449
|
+
}
|
|
450
|
+
else if (_args === 'nodesc' || _args === 'nodescriptions') {
|
|
451
|
+
useShowDescriptions = false;
|
|
452
|
+
}
|
|
453
|
+
const toolRegistry = await config?.getToolRegistry();
|
|
454
|
+
const tools = toolRegistry?.getAllTools();
|
|
455
|
+
if (!tools) {
|
|
456
|
+
addMessage({
|
|
457
|
+
type: MessageType.ERROR,
|
|
458
|
+
content: 'Could not retrieve tools.',
|
|
459
|
+
timestamp: new Date(),
|
|
460
|
+
});
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
// Filter out MCP tools by checking if they have a serverName property
|
|
464
|
+
const geminiTools = tools.filter((tool) => !('serverName' in tool));
|
|
465
|
+
let message = 'Available Gemini CLI tools:\n\n';
|
|
466
|
+
if (geminiTools.length > 0) {
|
|
467
|
+
geminiTools.forEach((tool) => {
|
|
468
|
+
if (useShowDescriptions && tool.description) {
|
|
469
|
+
// Format tool name in cyan using simple ANSI cyan color
|
|
470
|
+
message += ` - \u001b[36m${tool.displayName} (${tool.name})\u001b[0m:\n`;
|
|
471
|
+
// Apply green color to the description text
|
|
472
|
+
const greenColor = '\u001b[32m';
|
|
473
|
+
const resetColor = '\u001b[0m';
|
|
474
|
+
// Handle multi-line descriptions by properly indenting and preserving formatting
|
|
475
|
+
const descLines = tool.description.trim().split('\n');
|
|
476
|
+
// If there are multiple lines, add proper indentation for each line
|
|
477
|
+
if (descLines) {
|
|
478
|
+
for (const descLine of descLines) {
|
|
479
|
+
message += ` ${greenColor}${descLine}${resetColor}\n`;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
// Use cyan color for the tool name even when not showing descriptions
|
|
485
|
+
message += ` - \u001b[36m${tool.displayName}\u001b[0m\n`;
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
message += ' No tools available\n';
|
|
491
|
+
}
|
|
492
|
+
message += '\n';
|
|
493
|
+
// Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
|
|
494
|
+
message += '\u001b[0m';
|
|
495
|
+
addMessage({
|
|
496
|
+
type: MessageType.INFO,
|
|
497
|
+
content: message,
|
|
498
|
+
timestamp: new Date(),
|
|
499
|
+
});
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
name: 'corgi',
|
|
504
|
+
action: (_mainCommand, _subCommand, _args) => {
|
|
505
|
+
toggleCorgiMode();
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
name: 'about',
|
|
510
|
+
description: 'show version info',
|
|
511
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
|
512
|
+
const osVersion = process.platform;
|
|
513
|
+
let sandboxEnv = 'no sandbox';
|
|
514
|
+
if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
|
|
515
|
+
sandboxEnv = process.env.SANDBOX;
|
|
516
|
+
}
|
|
517
|
+
else if (process.env.SANDBOX === 'sandbox-exec') {
|
|
518
|
+
sandboxEnv = `sandbox-exec (${process.env.SEATBELT_PROFILE || 'unknown'})`;
|
|
519
|
+
}
|
|
520
|
+
const modelVersion = config?.getModel() || 'Unknown';
|
|
521
|
+
const cliVersion = await getCliVersion();
|
|
522
|
+
const selectedAuthType = settings.merged.selectedAuthType || '';
|
|
523
|
+
const gcpProject = process.env.GOOGLE_CLOUD_PROJECT || '';
|
|
524
|
+
addMessage({
|
|
525
|
+
type: MessageType.ABOUT,
|
|
526
|
+
timestamp: new Date(),
|
|
527
|
+
cliVersion,
|
|
528
|
+
osVersion,
|
|
529
|
+
sandboxEnv,
|
|
530
|
+
modelVersion,
|
|
531
|
+
selectedAuthType,
|
|
532
|
+
gcpProject,
|
|
533
|
+
});
|
|
534
|
+
},
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
name: 'bug',
|
|
538
|
+
description: 'submit a bug report',
|
|
539
|
+
action: async (_mainCommand, _subCommand, args) => {
|
|
540
|
+
let bugDescription = _subCommand || '';
|
|
541
|
+
if (args) {
|
|
542
|
+
bugDescription += ` ${args}`;
|
|
543
|
+
}
|
|
544
|
+
bugDescription = bugDescription.trim();
|
|
545
|
+
const osVersion = `${process.platform} ${process.version}`;
|
|
546
|
+
let sandboxEnv = 'no sandbox';
|
|
547
|
+
if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
|
|
548
|
+
sandboxEnv = process.env.SANDBOX.replace(/^gemini-(?:code-)?/, '');
|
|
549
|
+
}
|
|
550
|
+
else if (process.env.SANDBOX === 'sandbox-exec') {
|
|
551
|
+
sandboxEnv = `sandbox-exec (${process.env.SEATBELT_PROFILE || 'unknown'})`;
|
|
552
|
+
}
|
|
553
|
+
const modelVersion = config?.getModel() || 'Unknown';
|
|
554
|
+
const cliVersion = await getCliVersion();
|
|
555
|
+
const memoryUsage = formatMemoryUsage(process.memoryUsage().rss);
|
|
556
|
+
const info = `
|
|
557
|
+
* **CLI Version:** ${cliVersion}
|
|
558
|
+
* **Git Commit:** ${GIT_COMMIT_INFO}
|
|
559
|
+
* **Operating System:** ${osVersion}
|
|
560
|
+
* **Sandbox Environment:** ${sandboxEnv}
|
|
561
|
+
* **Model Version:** ${modelVersion}
|
|
562
|
+
* **Memory Usage:** ${memoryUsage}
|
|
563
|
+
`;
|
|
564
|
+
let bugReportUrl = 'https://github.com/google-gemini/gemini-cli/issues/new?template=bug_report.yml&title={title}&info={info}';
|
|
565
|
+
const bugCommand = config?.getBugCommand();
|
|
566
|
+
if (bugCommand?.urlTemplate) {
|
|
567
|
+
bugReportUrl = bugCommand.urlTemplate;
|
|
568
|
+
}
|
|
569
|
+
bugReportUrl = bugReportUrl
|
|
570
|
+
.replace('{title}', encodeURIComponent(bugDescription))
|
|
571
|
+
.replace('{info}', encodeURIComponent(info));
|
|
572
|
+
addMessage({
|
|
573
|
+
type: MessageType.INFO,
|
|
574
|
+
content: `To submit your bug report, please open the following URL in your browser:\n${bugReportUrl}`,
|
|
575
|
+
timestamp: new Date(),
|
|
576
|
+
});
|
|
577
|
+
(async () => {
|
|
578
|
+
try {
|
|
579
|
+
await open(bugReportUrl);
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
583
|
+
addMessage({
|
|
584
|
+
type: MessageType.ERROR,
|
|
585
|
+
content: `Could not open URL in browser: ${errorMessage}`,
|
|
586
|
+
timestamp: new Date(),
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
})();
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
name: 'chat',
|
|
594
|
+
description: 'Manage conversation history. Usage: /chat <list|save|resume> <tag>',
|
|
595
|
+
action: async (_mainCommand, subCommand, args) => {
|
|
596
|
+
const tag = (args || '').trim();
|
|
597
|
+
const logger = new Logger(config?.getSessionId() || '');
|
|
598
|
+
await logger.initialize();
|
|
599
|
+
const chat = await config?.getGeminiClient()?.getChat();
|
|
600
|
+
if (!chat) {
|
|
601
|
+
addMessage({
|
|
602
|
+
type: MessageType.ERROR,
|
|
603
|
+
content: 'No chat client available for conversation status.',
|
|
604
|
+
timestamp: new Date(),
|
|
605
|
+
});
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (!subCommand) {
|
|
609
|
+
addMessage({
|
|
610
|
+
type: MessageType.ERROR,
|
|
611
|
+
content: 'Missing command\nUsage: /chat <list|save|resume> <tag>',
|
|
612
|
+
timestamp: new Date(),
|
|
613
|
+
});
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
switch (subCommand) {
|
|
617
|
+
case 'save': {
|
|
618
|
+
if (!tag) {
|
|
619
|
+
addMessage({
|
|
620
|
+
type: MessageType.ERROR,
|
|
621
|
+
content: 'Missing tag. Usage: /chat save <tag>',
|
|
622
|
+
timestamp: new Date(),
|
|
623
|
+
});
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
const history = chat.getHistory();
|
|
627
|
+
if (history.length > 0) {
|
|
628
|
+
await logger.saveCheckpoint(chat?.getHistory() || [], tag);
|
|
629
|
+
addMessage({
|
|
630
|
+
type: MessageType.INFO,
|
|
631
|
+
content: `Conversation checkpoint saved with tag: ${tag}.`,
|
|
632
|
+
timestamp: new Date(),
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
addMessage({
|
|
637
|
+
type: MessageType.INFO,
|
|
638
|
+
content: 'No conversation found to save.',
|
|
639
|
+
timestamp: new Date(),
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
case 'resume':
|
|
645
|
+
case 'restore':
|
|
646
|
+
case 'load': {
|
|
647
|
+
if (!tag) {
|
|
648
|
+
addMessage({
|
|
649
|
+
type: MessageType.ERROR,
|
|
650
|
+
content: 'Missing tag. Usage: /chat resume <tag>',
|
|
651
|
+
timestamp: new Date(),
|
|
652
|
+
});
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
const conversation = await logger.loadCheckpoint(tag);
|
|
656
|
+
if (conversation.length === 0) {
|
|
657
|
+
addMessage({
|
|
658
|
+
type: MessageType.INFO,
|
|
659
|
+
content: `No saved checkpoint found with tag: ${tag}.`,
|
|
660
|
+
timestamp: new Date(),
|
|
661
|
+
});
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
clearItems();
|
|
665
|
+
chat.clearHistory();
|
|
666
|
+
const rolemap = {
|
|
667
|
+
user: MessageType.USER,
|
|
668
|
+
model: MessageType.GEMINI,
|
|
669
|
+
};
|
|
670
|
+
let hasSystemPrompt = false;
|
|
671
|
+
let i = 0;
|
|
672
|
+
for (const item of conversation) {
|
|
673
|
+
i += 1;
|
|
674
|
+
// Add each item to history regardless of whether we display
|
|
675
|
+
// it.
|
|
676
|
+
chat.addHistory(item);
|
|
677
|
+
const text = item.parts
|
|
678
|
+
?.filter((m) => !!m.text)
|
|
679
|
+
.map((m) => m.text)
|
|
680
|
+
.join('') || '';
|
|
681
|
+
if (!text) {
|
|
682
|
+
// Parsing Part[] back to various non-text output not yet implemented.
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
if (i === 1 && text.match(/context for our chat/)) {
|
|
686
|
+
hasSystemPrompt = true;
|
|
687
|
+
}
|
|
688
|
+
if (i > 2 || !hasSystemPrompt) {
|
|
689
|
+
addItem({
|
|
690
|
+
type: (item.role && rolemap[item.role]) || MessageType.GEMINI,
|
|
691
|
+
text,
|
|
692
|
+
}, i);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
console.clear();
|
|
696
|
+
refreshStatic();
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
case 'list':
|
|
700
|
+
addMessage({
|
|
701
|
+
type: MessageType.INFO,
|
|
702
|
+
content: 'list of saved conversations: ' +
|
|
703
|
+
(await savedChatTags()).join(', '),
|
|
704
|
+
timestamp: new Date(),
|
|
705
|
+
});
|
|
706
|
+
return;
|
|
707
|
+
default:
|
|
708
|
+
addMessage({
|
|
709
|
+
type: MessageType.ERROR,
|
|
710
|
+
content: `Unknown /chat command: ${subCommand}. Available: list, save, resume`,
|
|
711
|
+
timestamp: new Date(),
|
|
712
|
+
});
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
completion: async () => (await savedChatTags()).map((tag) => 'resume ' + tag),
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
name: 'quit',
|
|
720
|
+
altName: 'exit',
|
|
721
|
+
description: 'exit the cli',
|
|
722
|
+
action: async (mainCommand, _subCommand, _args) => {
|
|
723
|
+
const now = new Date();
|
|
724
|
+
const { sessionStartTime } = session.stats;
|
|
725
|
+
const wallDuration = now.getTime() - sessionStartTime.getTime();
|
|
726
|
+
setQuittingMessages([
|
|
727
|
+
{
|
|
728
|
+
type: 'user',
|
|
729
|
+
text: `/${mainCommand}`,
|
|
730
|
+
id: now.getTime() - 1,
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
type: 'quit',
|
|
734
|
+
duration: formatDuration(wallDuration),
|
|
735
|
+
id: now.getTime(),
|
|
736
|
+
},
|
|
737
|
+
]);
|
|
738
|
+
setTimeout(() => {
|
|
739
|
+
process.exit(0);
|
|
740
|
+
}, 100);
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
name: 'compress',
|
|
745
|
+
altName: 'summarize',
|
|
746
|
+
description: 'Compresses the context by replacing it with a summary.',
|
|
747
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
|
748
|
+
if (pendingCompressionItemRef.current !== null) {
|
|
749
|
+
addMessage({
|
|
750
|
+
type: MessageType.ERROR,
|
|
751
|
+
content: 'Already compressing, wait for previous request to complete',
|
|
752
|
+
timestamp: new Date(),
|
|
753
|
+
});
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
setPendingCompressionItem({
|
|
757
|
+
type: MessageType.COMPRESSION,
|
|
758
|
+
compression: {
|
|
759
|
+
isPending: true,
|
|
760
|
+
originalTokenCount: null,
|
|
761
|
+
newTokenCount: null,
|
|
762
|
+
},
|
|
763
|
+
});
|
|
764
|
+
try {
|
|
765
|
+
const compressed = await config
|
|
766
|
+
.getGeminiClient()
|
|
767
|
+
.tryCompressChat(true);
|
|
768
|
+
if (compressed) {
|
|
769
|
+
addMessage({
|
|
770
|
+
type: MessageType.COMPRESSION,
|
|
771
|
+
compression: {
|
|
772
|
+
isPending: false,
|
|
773
|
+
originalTokenCount: compressed.originalTokenCount,
|
|
774
|
+
newTokenCount: compressed.newTokenCount,
|
|
775
|
+
},
|
|
776
|
+
timestamp: new Date(),
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
else {
|
|
780
|
+
addMessage({
|
|
781
|
+
type: MessageType.ERROR,
|
|
782
|
+
content: 'Failed to compress chat history.',
|
|
783
|
+
timestamp: new Date(),
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
catch (e) {
|
|
788
|
+
addMessage({
|
|
789
|
+
type: MessageType.ERROR,
|
|
790
|
+
content: `Failed to compress chat history: ${e instanceof Error ? e.message : String(e)}`,
|
|
791
|
+
timestamp: new Date(),
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
setPendingCompressionItem(null);
|
|
795
|
+
},
|
|
796
|
+
},
|
|
797
|
+
];
|
|
798
|
+
if (config?.getCheckpointingEnabled()) {
|
|
799
|
+
commands.push({
|
|
800
|
+
name: 'restore',
|
|
801
|
+
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',
|
|
802
|
+
completion: async () => {
|
|
803
|
+
const checkpointDir = config?.getProjectTempDir()
|
|
804
|
+
? path.join(config.getProjectTempDir(), 'checkpoints')
|
|
805
|
+
: undefined;
|
|
806
|
+
if (!checkpointDir) {
|
|
807
|
+
return [];
|
|
808
|
+
}
|
|
809
|
+
try {
|
|
810
|
+
const files = await fs.readdir(checkpointDir);
|
|
811
|
+
return files
|
|
812
|
+
.filter((file) => file.endsWith('.json'))
|
|
813
|
+
.map((file) => file.replace('.json', ''));
|
|
814
|
+
}
|
|
815
|
+
catch (_err) {
|
|
816
|
+
return [];
|
|
817
|
+
}
|
|
818
|
+
},
|
|
819
|
+
action: async (_mainCommand, subCommand, _args) => {
|
|
820
|
+
const checkpointDir = config?.getProjectTempDir()
|
|
821
|
+
? path.join(config.getProjectTempDir(), 'checkpoints')
|
|
822
|
+
: undefined;
|
|
823
|
+
if (!checkpointDir) {
|
|
824
|
+
addMessage({
|
|
825
|
+
type: MessageType.ERROR,
|
|
826
|
+
content: 'Could not determine the .gemini directory path.',
|
|
827
|
+
timestamp: new Date(),
|
|
828
|
+
});
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
try {
|
|
832
|
+
// Ensure the directory exists before trying to read it.
|
|
833
|
+
await fs.mkdir(checkpointDir, { recursive: true });
|
|
834
|
+
const files = await fs.readdir(checkpointDir);
|
|
835
|
+
const jsonFiles = files.filter((file) => file.endsWith('.json'));
|
|
836
|
+
if (!subCommand) {
|
|
837
|
+
if (jsonFiles.length === 0) {
|
|
838
|
+
addMessage({
|
|
839
|
+
type: MessageType.INFO,
|
|
840
|
+
content: 'No restorable tool calls found.',
|
|
841
|
+
timestamp: new Date(),
|
|
842
|
+
});
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
const truncatedFiles = jsonFiles.map((file) => {
|
|
846
|
+
const components = file.split('.');
|
|
847
|
+
if (components.length <= 1) {
|
|
848
|
+
return file;
|
|
849
|
+
}
|
|
850
|
+
components.pop();
|
|
851
|
+
return components.join('.');
|
|
852
|
+
});
|
|
853
|
+
const fileList = truncatedFiles.join('\n');
|
|
854
|
+
addMessage({
|
|
855
|
+
type: MessageType.INFO,
|
|
856
|
+
content: `Available tool calls to restore:\n\n${fileList}`,
|
|
857
|
+
timestamp: new Date(),
|
|
858
|
+
});
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
const selectedFile = subCommand.endsWith('.json')
|
|
862
|
+
? subCommand
|
|
863
|
+
: `${subCommand}.json`;
|
|
864
|
+
if (!jsonFiles.includes(selectedFile)) {
|
|
865
|
+
addMessage({
|
|
866
|
+
type: MessageType.ERROR,
|
|
867
|
+
content: `File not found: ${selectedFile}`,
|
|
868
|
+
timestamp: new Date(),
|
|
869
|
+
});
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
const filePath = path.join(checkpointDir, selectedFile);
|
|
873
|
+
const data = await fs.readFile(filePath, 'utf-8');
|
|
874
|
+
const toolCallData = JSON.parse(data);
|
|
875
|
+
if (toolCallData.history) {
|
|
876
|
+
loadHistory(toolCallData.history);
|
|
877
|
+
}
|
|
878
|
+
if (toolCallData.clientHistory) {
|
|
879
|
+
await config
|
|
880
|
+
?.getGeminiClient()
|
|
881
|
+
?.setHistory(toolCallData.clientHistory);
|
|
882
|
+
}
|
|
883
|
+
if (toolCallData.commitHash) {
|
|
884
|
+
await gitService?.restoreProjectFromSnapshot(toolCallData.commitHash);
|
|
885
|
+
addMessage({
|
|
886
|
+
type: MessageType.INFO,
|
|
887
|
+
content: `Restored project to the state before the tool call.`,
|
|
888
|
+
timestamp: new Date(),
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
return {
|
|
892
|
+
shouldScheduleTool: true,
|
|
893
|
+
toolName: toolCallData.toolCall.name,
|
|
894
|
+
toolArgs: toolCallData.toolCall.args,
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
catch (error) {
|
|
898
|
+
addMessage({
|
|
899
|
+
type: MessageType.ERROR,
|
|
900
|
+
content: `Could not read restorable tool calls. This is the error: ${error}`,
|
|
901
|
+
timestamp: new Date(),
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
return commands;
|
|
908
|
+
}, [
|
|
909
|
+
onDebugMessage,
|
|
910
|
+
setShowHelp,
|
|
911
|
+
refreshStatic,
|
|
912
|
+
openThemeDialog,
|
|
913
|
+
openAuthDialog,
|
|
914
|
+
openEditorDialog,
|
|
915
|
+
clearItems,
|
|
916
|
+
performMemoryRefresh,
|
|
917
|
+
showMemoryAction,
|
|
918
|
+
addMemoryAction,
|
|
919
|
+
addMessage,
|
|
920
|
+
toggleCorgiMode,
|
|
921
|
+
savedChatTags,
|
|
922
|
+
config,
|
|
923
|
+
settings,
|
|
924
|
+
showToolDescriptions,
|
|
925
|
+
session,
|
|
926
|
+
gitService,
|
|
927
|
+
loadHistory,
|
|
928
|
+
addItem,
|
|
929
|
+
setQuittingMessages,
|
|
930
|
+
pendingCompressionItemRef,
|
|
931
|
+
setPendingCompressionItem,
|
|
932
|
+
openPrivacyNotice,
|
|
933
|
+
]);
|
|
934
|
+
const handleSlashCommand = useCallback(async (rawQuery) => {
|
|
935
|
+
if (typeof rawQuery !== 'string') {
|
|
936
|
+
return false;
|
|
937
|
+
}
|
|
938
|
+
const trimmed = rawQuery.trim();
|
|
939
|
+
if (!trimmed.startsWith('/') && !trimmed.startsWith('?')) {
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
const userMessageTimestamp = Date.now();
|
|
943
|
+
if (trimmed !== '/quit' && trimmed !== '/exit') {
|
|
944
|
+
addItem({ type: MessageType.USER, text: trimmed }, userMessageTimestamp);
|
|
945
|
+
}
|
|
946
|
+
let subCommand;
|
|
947
|
+
let args;
|
|
948
|
+
const commandToMatch = (() => {
|
|
949
|
+
if (trimmed.startsWith('?')) {
|
|
950
|
+
return 'help';
|
|
951
|
+
}
|
|
952
|
+
const parts = trimmed.substring(1).trim().split(/\s+/);
|
|
953
|
+
if (parts.length > 1) {
|
|
954
|
+
subCommand = parts[1];
|
|
955
|
+
}
|
|
956
|
+
if (parts.length > 2) {
|
|
957
|
+
args = parts.slice(2).join(' ');
|
|
958
|
+
}
|
|
959
|
+
return parts[0];
|
|
960
|
+
})();
|
|
961
|
+
const mainCommand = commandToMatch;
|
|
962
|
+
for (const cmd of slashCommands) {
|
|
963
|
+
if (mainCommand === cmd.name || mainCommand === cmd.altName) {
|
|
964
|
+
const actionResult = await cmd.action(mainCommand, subCommand, args);
|
|
965
|
+
if (typeof actionResult === 'object' &&
|
|
966
|
+
actionResult?.shouldScheduleTool) {
|
|
967
|
+
return actionResult; // Return the object for useGeminiStream
|
|
968
|
+
}
|
|
969
|
+
return true; // Command was handled, but no tool to schedule
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
addMessage({
|
|
973
|
+
type: MessageType.ERROR,
|
|
974
|
+
content: `Unknown command: ${trimmed}`,
|
|
975
|
+
timestamp: new Date(),
|
|
976
|
+
});
|
|
977
|
+
return true; // Indicate command was processed (even if unknown)
|
|
978
|
+
}, [addItem, slashCommands, addMessage]);
|
|
979
|
+
return { handleSlashCommand, slashCommands, pendingHistoryItems };
|
|
980
|
+
};
|
|
981
|
+
//# sourceMappingURL=slashCommandProcessor.js.map
|