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