@vybestack/llxprt-code 0.1.12
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 +256 -0
- package/dist/.last_build +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +95 -0
- package/dist/src/config/auth.d.ts +6 -0
- package/dist/src/config/auth.js +42 -0
- package/dist/src/config/auth.js.map +1 -0
- package/dist/src/config/config.d.ts +41 -0
- package/dist/src/config/config.js +345 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/extension.d.ts +21 -0
- package/dist/src/config/extension.js +109 -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 +88 -0
- package/dist/src/config/settings.js +263 -0
- package/dist/src/config/settings.js.map +1 -0
- package/dist/src/gemini.d.ts +6 -0
- package/dist/src/gemini.js +420 -0
- package/dist/src/gemini.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 +131 -0
- package/dist/src/nonInteractiveCli.js.map +1 -0
- package/dist/src/providers/IMessage.d.ts +38 -0
- package/dist/src/providers/IMessage.js +17 -0
- package/dist/src/providers/IMessage.js.map +1 -0
- package/dist/src/providers/IModel.d.ts +23 -0
- package/dist/src/providers/IModel.js +17 -0
- package/dist/src/providers/IModel.js.map +1 -0
- package/dist/src/providers/IProvider.d.ts +32 -0
- package/dist/src/providers/IProvider.js +17 -0
- package/dist/src/providers/IProvider.js.map +1 -0
- package/dist/src/providers/ITool.d.ts +23 -0
- package/dist/src/providers/ITool.js +17 -0
- package/dist/src/providers/ITool.js.map +1 -0
- package/dist/src/providers/ProviderAwareContentGenerator.d.ts +6 -0
- package/dist/src/providers/ProviderAwareContentGenerator.js +9 -0
- package/dist/src/providers/ProviderAwareContentGenerator.js.map +1 -0
- package/dist/src/providers/ProviderManager.d.ts +19 -0
- package/dist/src/providers/ProviderManager.js +63 -0
- package/dist/src/providers/ProviderManager.js.map +1 -0
- package/dist/src/providers/ProviderManagerAdapter.d.ts +17 -0
- package/dist/src/providers/ProviderManagerAdapter.js +113 -0
- package/dist/src/providers/ProviderManagerAdapter.js.map +1 -0
- package/dist/src/providers/README-qwen3.md +60 -0
- package/dist/src/providers/README.md +203 -0
- package/dist/src/providers/adapters/IStreamAdapter.d.ts +18 -0
- package/dist/src/providers/adapters/IStreamAdapter.js +7 -0
- package/dist/src/providers/adapters/IStreamAdapter.js.map +1 -0
- package/dist/src/providers/anthropic/AnthropicProvider.d.ts +46 -0
- package/dist/src/providers/anthropic/AnthropicProvider.js +478 -0
- package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -0
- package/dist/src/providers/contentGeneratorProvider.d.ts +13 -0
- package/dist/src/providers/contentGeneratorProvider.js +17 -0
- package/dist/src/providers/contentGeneratorProvider.js.map +1 -0
- package/dist/src/providers/enhanceConfigWithProviders.d.ts +12 -0
- package/dist/src/providers/enhanceConfigWithProviders.js +16 -0
- package/dist/src/providers/enhanceConfigWithProviders.js.map +1 -0
- package/dist/src/providers/gemini/GeminiProvider.d.ts +72 -0
- package/dist/src/providers/gemini/GeminiProvider.js +454 -0
- package/dist/src/providers/gemini/GeminiProvider.js.map +1 -0
- package/dist/src/providers/index.d.ts +13 -0
- package/dist/src/providers/index.js +18 -0
- package/dist/src/providers/index.js.map +1 -0
- package/dist/src/providers/integration/TEST_INSTRUCTIONS.md +197 -0
- package/dist/src/providers/openai/ConversationCache.d.ts +20 -0
- package/dist/src/providers/openai/ConversationCache.js +109 -0
- package/dist/src/providers/openai/ConversationCache.js.map +1 -0
- package/dist/src/providers/openai/IChatGenerateParams.d.ts +11 -0
- package/dist/src/providers/openai/IChatGenerateParams.js +2 -0
- package/dist/src/providers/openai/IChatGenerateParams.js.map +1 -0
- package/dist/src/providers/openai/OpenAIProvider.d.ts +71 -0
- package/dist/src/providers/openai/OpenAIProvider.js +486 -0
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -0
- package/dist/src/providers/openai/Qwen3FireworksProvider.d.ts +39 -0
- package/dist/src/providers/openai/Qwen3FireworksProvider.js +209 -0
- package/dist/src/providers/openai/Qwen3FireworksProvider.js.map +1 -0
- package/dist/src/providers/openai/RESPONSES_API_MODELS.d.ts +2 -0
- package/dist/src/providers/openai/RESPONSES_API_MODELS.js +14 -0
- package/dist/src/providers/openai/RESPONSES_API_MODELS.js.map +1 -0
- package/dist/src/providers/openai/buildResponsesRequest.d.ts +67 -0
- package/dist/src/providers/openai/buildResponsesRequest.js +144 -0
- package/dist/src/providers/openai/buildResponsesRequest.js.map +1 -0
- package/dist/src/providers/openai/docs/accessing-provider-info.md +172 -0
- package/dist/src/providers/openai/docs/params-mapping.md +91 -0
- package/dist/src/providers/openai/docs/qwen3-fireworks.md +47 -0
- package/dist/src/providers/openai/docs/responses-api-tool-calls.md +96 -0
- package/dist/src/providers/openai/estimateRemoteTokens.d.ts +26 -0
- package/dist/src/providers/openai/estimateRemoteTokens.js +75 -0
- package/dist/src/providers/openai/estimateRemoteTokens.js.map +1 -0
- package/dist/src/providers/openai/getOpenAIProviderInfo.d.ts +46 -0
- package/dist/src/providers/openai/getOpenAIProviderInfo.js +74 -0
- package/dist/src/providers/openai/getOpenAIProviderInfo.js.map +1 -0
- package/dist/src/providers/openai/parseResponsesStream.d.ts +3 -0
- package/dist/src/providers/openai/parseResponsesStream.js +444 -0
- package/dist/src/providers/openai/parseResponsesStream.js.map +1 -0
- package/dist/src/providers/parsers/TextToolCallParser.d.ts +35 -0
- package/dist/src/providers/parsers/TextToolCallParser.js +248 -0
- package/dist/src/providers/parsers/TextToolCallParser.js.map +1 -0
- package/dist/src/providers/providerConfigUtils.d.ts +26 -0
- package/dist/src/providers/providerConfigUtils.js +173 -0
- package/dist/src/providers/providerConfigUtils.js.map +1 -0
- package/dist/src/providers/providerManagerInstance.d.ts +9 -0
- package/dist/src/providers/providerManagerInstance.js +109 -0
- package/dist/src/providers/providerManagerInstance.js.map +1 -0
- package/dist/src/providers/tokenizers/AnthropicTokenizer.d.ts +19 -0
- package/dist/src/providers/tokenizers/AnthropicTokenizer.js +37 -0
- package/dist/src/providers/tokenizers/AnthropicTokenizer.js.map +1 -0
- package/dist/src/providers/tokenizers/ITokenizer.d.ts +18 -0
- package/dist/src/providers/tokenizers/ITokenizer.js +17 -0
- package/dist/src/providers/tokenizers/ITokenizer.js.map +1 -0
- package/dist/src/providers/tokenizers/OpenAITokenizer.d.ts +24 -0
- package/dist/src/providers/tokenizers/OpenAITokenizer.js +56 -0
- package/dist/src/providers/tokenizers/OpenAITokenizer.js.map +1 -0
- package/dist/src/providers/types.d.ts +14 -0
- package/dist/src/providers/types.js +16 -0
- package/dist/src/providers/types.js.map +1 -0
- package/dist/src/services/CommandService.d.ts +13 -0
- package/dist/src/services/CommandService.js +38 -0
- package/dist/src/services/CommandService.js.map +1 -0
- package/dist/src/tools/IToolFormatter.d.ts +40 -0
- package/dist/src/tools/IToolFormatter.js +17 -0
- package/dist/src/tools/IToolFormatter.js.map +1 -0
- package/dist/src/tools/ToolFormatter.d.ts +45 -0
- package/dist/src/tools/ToolFormatter.js +216 -0
- package/dist/src/tools/ToolFormatter.js.map +1 -0
- package/dist/src/ui/App.d.ts +15 -0
- package/dist/src/ui/App.js +468 -0
- package/dist/src/ui/App.js.map +1 -0
- package/dist/src/ui/colors.d.ts +25 -0
- package/dist/src/ui/colors.js +126 -0
- package/dist/src/ui/colors.js.map +1 -0
- package/dist/src/ui/commands/aboutCommand.d.ts +7 -0
- package/dist/src/ui/commands/aboutCommand.js +61 -0
- package/dist/src/ui/commands/aboutCommand.js.map +1 -0
- package/dist/src/ui/commands/authCommand.d.ts +7 -0
- package/dist/src/ui/commands/authCommand.js +14 -0
- package/dist/src/ui/commands/authCommand.js.map +1 -0
- package/dist/src/ui/commands/clearCommand.d.ts +7 -0
- package/dist/src/ui/commands/clearCommand.js +15 -0
- package/dist/src/ui/commands/clearCommand.js.map +1 -0
- package/dist/src/ui/commands/helpCommand.d.ts +7 -0
- package/dist/src/ui/commands/helpCommand.js +18 -0
- package/dist/src/ui/commands/helpCommand.js.map +1 -0
- package/dist/src/ui/commands/memoryCommand.d.ts +7 -0
- package/dist/src/ui/commands/memoryCommand.js +81 -0
- package/dist/src/ui/commands/memoryCommand.js.map +1 -0
- package/dist/src/ui/commands/privacyCommand.d.ts +7 -0
- package/dist/src/ui/commands/privacyCommand.js +14 -0
- package/dist/src/ui/commands/privacyCommand.js.map +1 -0
- package/dist/src/ui/commands/themeCommand.d.ts +7 -0
- package/dist/src/ui/commands/themeCommand.js +14 -0
- package/dist/src/ui/commands/themeCommand.js.map +1 -0
- package/dist/src/ui/commands/types.d.ts +63 -0
- package/dist/src/ui/commands/types.js +7 -0
- package/dist/src/ui/commands/types.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 +24 -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 +102 -0
- package/dist/src/ui/components/AuthDialog.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/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/ErrorBoundary.d.ts +46 -0
- package/dist/src/ui/components/ErrorBoundary.js +115 -0
- package/dist/src/ui/components/ErrorBoundary.js.map +1 -0
- package/dist/src/ui/components/Footer.d.ts +22 -0
- package/dist/src/ui/components/Footer.js +32 -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 +14 -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 +10 -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/InputPrompt.d.ts +25 -0
- package/dist/src/ui/components/InputPrompt.js +350 -0
- package/dist/src/ui/components/InputPrompt.js.map +1 -0
- package/dist/src/ui/components/LayoutManager.d.ts +24 -0
- package/dist/src/ui/components/LayoutManager.js +58 -0
- package/dist/src/ui/components/LayoutManager.js.map +1 -0
- package/dist/src/ui/components/LoadingIndicator.d.ts +15 -0
- package/dist/src/ui/components/LoadingIndicator.js +20 -0
- package/dist/src/ui/components/LoadingIndicator.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/ProviderDialog.d.ts +9 -0
- package/dist/src/ui/components/ProviderDialog.js +54 -0
- package/dist/src/ui/components/ProviderDialog.js.map +1 -0
- package/dist/src/ui/components/ProviderModelDialog.d.ts +15 -0
- package/dist/src/ui/components/ProviderModelDialog.js +54 -0
- package/dist/src/ui/components/ProviderModelDialog.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/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/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 +127 -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/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/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 +15 -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 +117 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.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/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/RadioButtonSelect.d.ts +44 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.js +77 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
- package/dist/src/ui/components/shared/text-buffer.d.ts +184 -0
- package/dist/src/ui/components/shared/text-buffer.js +1021 -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/containers/SessionController.d.ts +26 -0
- package/dist/src/ui/containers/SessionController.js +314 -0
- package/dist/src/ui/containers/SessionController.js.map +1 -0
- package/dist/src/ui/containers/UIStateShell.d.ts +6 -0
- package/dist/src/ui/containers/UIStateShell.js +4 -0
- package/dist/src/ui/containers/UIStateShell.js.map +1 -0
- package/dist/src/ui/contexts/AppDispatchContext.d.ts +12 -0
- package/dist/src/ui/contexts/AppDispatchContext.js +17 -0
- package/dist/src/ui/contexts/AppDispatchContext.js.map +1 -0
- package/dist/src/ui/contexts/OpenAIProviderContext.d.ts +29 -0
- package/dist/src/ui/contexts/OpenAIProviderContext.js +63 -0
- package/dist/src/ui/contexts/OpenAIProviderContext.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 +36 -0
- package/dist/src/ui/contexts/SessionContext.js +66 -0
- package/dist/src/ui/contexts/SessionContext.js.map +1 -0
- package/dist/src/ui/contexts/SessionStateContext.d.ts +15 -0
- package/dist/src/ui/contexts/SessionStateContext.js +26 -0
- package/dist/src/ui/contexts/SessionStateContext.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 +310 -0
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
- package/dist/src/ui/hooks/index.d.ts +2 -0
- package/dist/src/ui/hooks/index.js +3 -0
- package/dist/src/ui/hooks/index.js.map +1 -0
- package/dist/src/ui/hooks/shellCommandProcessor.d.ts +16 -0
- package/dist/src/ui/hooks/shellCommandProcessor.js +263 -0
- package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +27 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js +1413 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
- package/dist/src/ui/hooks/useAuthCommand.d.ts +15 -0
- package/dist/src/ui/hooks/useAuthCommand.js +76 -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 +375 -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 +17 -0
- package/dist/src/ui/hooks/useEditorSettings.js +48 -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 +607 -0
- package/dist/src/ui/hooks/useGeminiStream.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 +74 -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 +162 -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/useOpenAIProviderInfo.d.ts +17 -0
- package/dist/src/ui/hooks/useOpenAIProviderInfo.js +43 -0
- package/dist/src/ui/hooks/useOpenAIProviderInfo.js.map +1 -0
- package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
- package/dist/src/ui/hooks/usePhraseCycler.js +197 -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/useProviderDialog.d.ts +25 -0
- package/dist/src/ui/hooks/useProviderDialog.js +61 -0
- package/dist/src/ui/hooks/useProviderDialog.js.map +1 -0
- package/dist/src/ui/hooks/useProviderModelDialog.d.ts +26 -0
- package/dist/src/ui/hooks/useProviderModelDialog.js +62 -0
- package/dist/src/ui/hooks/useProviderModelDialog.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/useSession.d.ts +11 -0
- package/dist/src/ui/hooks/useSession.js +19 -0
- package/dist/src/ui/hooks/useSession.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 +50 -0
- package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
- package/dist/src/ui/hooks/useStableCallback.d.ts +40 -0
- package/dist/src/ui/hooks/useStableCallback.js +58 -0
- package/dist/src/ui/hooks/useStableCallback.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 +16 -0
- package/dist/src/ui/hooks/useThemeCommand.js +94 -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 +42 -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/reducers/appReducer.d.ts +59 -0
- package/dist/src/ui/reducers/appReducer.js +91 -0
- package/dist/src/ui/reducers/appReducer.js.map +1 -0
- package/dist/src/ui/reducers/sessionReducer.d.ts +36 -0
- package/dist/src/ui/reducers/sessionReducer.js +30 -0
- package/dist/src/ui/reducers/sessionReducer.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/green-screen.d.ts +7 -0
- package/dist/src/ui/themes/green-screen.js +113 -0
- package/dist/src/ui/themes/green-screen.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 +111 -0
- package/dist/src/ui/themes/theme-manager.js.map +1 -0
- package/dist/src/ui/themes/theme.d.ts +83 -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 +174 -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/ConsolePatcher.d.ts +23 -0
- package/dist/src/ui/utils/ConsolePatcher.js +42 -0
- package/dist/src/ui/utils/ConsolePatcher.js.map +1 -0
- package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +16 -0
- package/dist/src/ui/utils/InlineMarkdownRenderer.js +104 -0
- package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -0
- package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
- package/dist/src/ui/utils/MarkdownDisplay.js +205 -0
- package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
- package/dist/src/ui/utils/TableRenderer.d.ts +17 -0
- package/dist/src/ui/utils/TableRenderer.js +84 -0
- package/dist/src/ui/utils/TableRenderer.js.map +1 -0
- package/dist/src/ui/utils/clipboardUtils.d.ts +22 -0
- package/dist/src/ui/utils/clipboardUtils.js +127 -0
- package/dist/src/ui/utils/clipboardUtils.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 +7 -0
- package/dist/src/ui/utils/errorParsing.js +106 -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/renderLoopDetector.d.ts +52 -0
- package/dist/src/ui/utils/renderLoopDetector.js +146 -0
- package/dist/src/ui/utils/renderLoopDetector.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 +50 -0
- package/dist/src/ui/utils/updateCheck.js.map +1 -0
- package/dist/src/utils/ConversationContext.d.ts +55 -0
- package/dist/src/utils/ConversationContext.js +85 -0
- package/dist/src/utils/ConversationContext.js.map +1 -0
- package/dist/src/utils/cleanup.d.ts +8 -0
- package/dist/src/utils/cleanup.js +34 -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/userStartupWarnings.d.ts +6 -0
- package/dist/src/utils/userStartupWarnings.js +48 -0
- package/dist/src/utils/userStartupWarnings.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/dist/vybestack-llxprt-code-0.1.12.tgz +0 -0
- package/package.json +95 -0
@@ -0,0 +1,1413 @@
|
|
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 { ansi } from '../colors.js';
|
10
|
+
import { useStateAndRef } from './useStateAndRef.js';
|
11
|
+
import { GitService, Logger, MCPDiscoveryState, MCPServerStatus, getMCPDiscoveryState, getMCPServerStatus, AuthType, } from '@vybestack/llxprt-code-core';
|
12
|
+
import { useSessionStats } from '../contexts/SessionContext.js';
|
13
|
+
import { MessageType, } from '../types.js';
|
14
|
+
import { promises as fs } from 'fs';
|
15
|
+
import path from 'path';
|
16
|
+
import { homedir } from 'os';
|
17
|
+
// import { createShowMemoryAction } from './useShowMemoryCommand.js';
|
18
|
+
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
|
19
|
+
import { formatDuration, formatMemoryUsage } from '../utils/formatters.js';
|
20
|
+
import { getCliVersion } from '../../utils/version.js';
|
21
|
+
import { SettingScope } from '../../config/settings.js';
|
22
|
+
import { CommandService } from '../../services/CommandService.js';
|
23
|
+
import { getProviderManager } from '../../providers/providerManagerInstance.js';
|
24
|
+
import { ConversationContext, } from '../../utils/ConversationContext.js';
|
25
|
+
import { setProviderApiKey, setProviderApiKeyFromFile, setProviderBaseUrl, } from '../../providers/providerConfigUtils.js';
|
26
|
+
/**
|
27
|
+
* Hook to define and process slash commands (e.g., /help, /clear).
|
28
|
+
*/
|
29
|
+
export const useSlashCommandProcessor = (config, settings, history, addItem, clearItems, loadHistory, refreshStatic, setShowHelp, onDebugMessage, openThemeDialog, openAuthDialog, openEditorDialog, openProviderDialog, openProviderModelDialog, performMemoryRefresh, toggleCorgiMode, showToolDescriptions = false, setQuittingMessages, openPrivacyNotice, checkPaymentModeChange) => {
|
30
|
+
const session = useSessionStats();
|
31
|
+
const [commands, setCommands] = useState([]);
|
32
|
+
const gitService = useMemo(() => {
|
33
|
+
if (!config?.getProjectRoot()) {
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
return new GitService(config.getProjectRoot());
|
37
|
+
}, [config]);
|
38
|
+
const logger = useMemo(() => {
|
39
|
+
const l = new Logger(config?.getSessionId() || '');
|
40
|
+
// The logger's initialize is async, but we can create the instance
|
41
|
+
// synchronously. Commands that use it will await its initialization.
|
42
|
+
return l;
|
43
|
+
}, [config]);
|
44
|
+
const [pendingCompressionItemRef, setPendingCompressionItem] = useStateAndRef(null);
|
45
|
+
const pendingHistoryItems = useMemo(() => {
|
46
|
+
const items = [];
|
47
|
+
if (pendingCompressionItemRef.current != null) {
|
48
|
+
items.push(pendingCompressionItemRef.current);
|
49
|
+
}
|
50
|
+
return items;
|
51
|
+
}, [pendingCompressionItemRef]);
|
52
|
+
const addMessage = useCallback((message) => {
|
53
|
+
// Convert Message to HistoryItemWithoutId
|
54
|
+
let historyItemContent;
|
55
|
+
if (message.type === MessageType.ABOUT) {
|
56
|
+
historyItemContent = {
|
57
|
+
type: 'about',
|
58
|
+
cliVersion: message.cliVersion,
|
59
|
+
osVersion: message.osVersion,
|
60
|
+
sandboxEnv: message.sandboxEnv,
|
61
|
+
modelVersion: message.modelVersion,
|
62
|
+
selectedAuthType: message.selectedAuthType,
|
63
|
+
gcpProject: message.gcpProject,
|
64
|
+
};
|
65
|
+
}
|
66
|
+
else if (message.type === MessageType.STATS) {
|
67
|
+
historyItemContent = {
|
68
|
+
type: 'stats',
|
69
|
+
duration: message.duration,
|
70
|
+
};
|
71
|
+
}
|
72
|
+
else if (message.type === MessageType.MODEL_STATS) {
|
73
|
+
historyItemContent = {
|
74
|
+
type: 'model_stats',
|
75
|
+
};
|
76
|
+
}
|
77
|
+
else if (message.type === MessageType.TOOL_STATS) {
|
78
|
+
historyItemContent = {
|
79
|
+
type: 'tool_stats',
|
80
|
+
};
|
81
|
+
}
|
82
|
+
else if (message.type === MessageType.QUIT) {
|
83
|
+
historyItemContent = {
|
84
|
+
type: 'quit',
|
85
|
+
duration: message.duration,
|
86
|
+
};
|
87
|
+
}
|
88
|
+
else if (message.type === MessageType.COMPRESSION) {
|
89
|
+
historyItemContent = {
|
90
|
+
type: 'compression',
|
91
|
+
compression: message.compression,
|
92
|
+
};
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
historyItemContent = {
|
96
|
+
type: message.type,
|
97
|
+
text: message.content,
|
98
|
+
};
|
99
|
+
}
|
100
|
+
addItem(historyItemContent, message.timestamp.getTime());
|
101
|
+
}, [addItem]);
|
102
|
+
// const showMemoryAction = useMemo(
|
103
|
+
// () => createShowMemoryAction(config, settings, addMessage),
|
104
|
+
// [config, settings, addMessage],
|
105
|
+
// );
|
106
|
+
const commandContext = useMemo(() => ({
|
107
|
+
services: {
|
108
|
+
config,
|
109
|
+
settings,
|
110
|
+
git: gitService,
|
111
|
+
logger,
|
112
|
+
},
|
113
|
+
ui: {
|
114
|
+
addItem,
|
115
|
+
clear: () => {
|
116
|
+
clearItems();
|
117
|
+
console.clear();
|
118
|
+
refreshStatic();
|
119
|
+
},
|
120
|
+
setDebugMessage: onDebugMessage,
|
121
|
+
},
|
122
|
+
session: {
|
123
|
+
stats: session.stats,
|
124
|
+
},
|
125
|
+
}), [
|
126
|
+
config,
|
127
|
+
settings,
|
128
|
+
gitService,
|
129
|
+
logger,
|
130
|
+
addItem,
|
131
|
+
clearItems,
|
132
|
+
refreshStatic,
|
133
|
+
session.stats,
|
134
|
+
onDebugMessage,
|
135
|
+
]);
|
136
|
+
const commandService = useMemo(() => new CommandService(), []);
|
137
|
+
useEffect(() => {
|
138
|
+
const load = async () => {
|
139
|
+
await commandService.loadCommands();
|
140
|
+
setCommands(commandService.getCommands());
|
141
|
+
};
|
142
|
+
load();
|
143
|
+
}, [commandService]);
|
144
|
+
const savedChatTags = useCallback(async () => {
|
145
|
+
const geminiDir = config?.getProjectTempDir();
|
146
|
+
if (!geminiDir) {
|
147
|
+
return [];
|
148
|
+
}
|
149
|
+
try {
|
150
|
+
const files = await fs.readdir(geminiDir);
|
151
|
+
return files
|
152
|
+
.filter((file) => file.startsWith('checkpoint-') && file.endsWith('.json'))
|
153
|
+
.map((file) => file.replace('checkpoint-', '').replace('.json', ''));
|
154
|
+
}
|
155
|
+
catch (_err) {
|
156
|
+
return [];
|
157
|
+
}
|
158
|
+
}, [config]);
|
159
|
+
// Define legacy commands
|
160
|
+
// This list contains all commands that have NOT YET been migrated to the
|
161
|
+
// new system. As commands are migrated, they are removed from this list.
|
162
|
+
const legacyCommands = useMemo(() => {
|
163
|
+
const commands = [
|
164
|
+
// `/help` and `/clear` have been migrated and REMOVED from this list.
|
165
|
+
{
|
166
|
+
name: 'docs',
|
167
|
+
description: 'open full LLxprt Code documentation in your browser',
|
168
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
169
|
+
const docsUrl = 'https://goo.gle/gemini-cli-docs';
|
170
|
+
if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
|
171
|
+
addMessage({
|
172
|
+
type: MessageType.INFO,
|
173
|
+
content: `Please open the following URL in your browser to view the documentation:\n${docsUrl}`,
|
174
|
+
timestamp: new Date(),
|
175
|
+
});
|
176
|
+
}
|
177
|
+
else {
|
178
|
+
addMessage({
|
179
|
+
type: MessageType.INFO,
|
180
|
+
content: `Opening documentation in your browser: ${docsUrl}`,
|
181
|
+
timestamp: new Date(),
|
182
|
+
});
|
183
|
+
await open(docsUrl);
|
184
|
+
}
|
185
|
+
},
|
186
|
+
},
|
187
|
+
{
|
188
|
+
name: 'auth',
|
189
|
+
description: 'change the auth method',
|
190
|
+
action: async (_mainCommand, authMode, _args) => {
|
191
|
+
const providerManager = getProviderManager();
|
192
|
+
// If no auth mode specified, open the dialog
|
193
|
+
if (!authMode) {
|
194
|
+
openAuthDialog();
|
195
|
+
return;
|
196
|
+
}
|
197
|
+
// Handle specific auth mode changes for Gemini provider
|
198
|
+
try {
|
199
|
+
const activeProvider = providerManager.getActiveProvider();
|
200
|
+
// Check if this is the Gemini provider
|
201
|
+
if (activeProvider.name === 'gemini' && config) {
|
202
|
+
const validModes = ['oauth', 'api-key', 'vertex'];
|
203
|
+
if (!validModes.includes(authMode)) {
|
204
|
+
addMessage({
|
205
|
+
type: MessageType.ERROR,
|
206
|
+
content: `Invalid auth mode. Valid modes: ${validModes.join(', ')}`,
|
207
|
+
timestamp: new Date(),
|
208
|
+
});
|
209
|
+
return;
|
210
|
+
}
|
211
|
+
// Map the auth mode to the appropriate AuthType
|
212
|
+
let authType;
|
213
|
+
switch (authMode) {
|
214
|
+
case 'oauth':
|
215
|
+
authType = AuthType.LOGIN_WITH_GOOGLE;
|
216
|
+
break;
|
217
|
+
case 'api-key':
|
218
|
+
authType = AuthType.USE_GEMINI;
|
219
|
+
break;
|
220
|
+
case 'vertex':
|
221
|
+
authType = AuthType.USE_VERTEX_AI;
|
222
|
+
break;
|
223
|
+
default:
|
224
|
+
authType = AuthType.LOGIN_WITH_GOOGLE;
|
225
|
+
}
|
226
|
+
// Refresh auth with the new type
|
227
|
+
await config.refreshAuth(authType);
|
228
|
+
addMessage({
|
229
|
+
type: MessageType.INFO,
|
230
|
+
content: `Switched to ${authMode} authentication mode`,
|
231
|
+
timestamp: new Date(),
|
232
|
+
});
|
233
|
+
}
|
234
|
+
else {
|
235
|
+
addMessage({
|
236
|
+
type: MessageType.ERROR,
|
237
|
+
content: 'Auth mode switching is only supported for the Gemini provider',
|
238
|
+
timestamp: new Date(),
|
239
|
+
});
|
240
|
+
}
|
241
|
+
}
|
242
|
+
catch (error) {
|
243
|
+
addMessage({
|
244
|
+
type: MessageType.ERROR,
|
245
|
+
content: `Failed to switch auth mode: ${error instanceof Error ? error.message : String(error)}`,
|
246
|
+
timestamp: new Date(),
|
247
|
+
});
|
248
|
+
}
|
249
|
+
},
|
250
|
+
},
|
251
|
+
{
|
252
|
+
name: 'editor',
|
253
|
+
description: 'set external editor preference',
|
254
|
+
action: (_mainCommand, _subCommand, _args) => openEditorDialog(),
|
255
|
+
},
|
256
|
+
{
|
257
|
+
name: 'stats',
|
258
|
+
altName: 'usage',
|
259
|
+
description: 'check session stats. Usage: /stats [model|tools]',
|
260
|
+
action: (_mainCommand, subCommand, _args) => {
|
261
|
+
if (subCommand === 'model') {
|
262
|
+
addMessage({
|
263
|
+
type: MessageType.MODEL_STATS,
|
264
|
+
timestamp: new Date(),
|
265
|
+
});
|
266
|
+
return;
|
267
|
+
}
|
268
|
+
else if (subCommand === 'tools') {
|
269
|
+
addMessage({
|
270
|
+
type: MessageType.TOOL_STATS,
|
271
|
+
timestamp: new Date(),
|
272
|
+
});
|
273
|
+
return;
|
274
|
+
}
|
275
|
+
const now = new Date();
|
276
|
+
const { sessionStartTime } = session.stats;
|
277
|
+
const wallDuration = now.getTime() - sessionStartTime.getTime();
|
278
|
+
addMessage({
|
279
|
+
type: MessageType.STATS,
|
280
|
+
duration: formatDuration(wallDuration),
|
281
|
+
timestamp: new Date(),
|
282
|
+
});
|
283
|
+
},
|
284
|
+
},
|
285
|
+
{
|
286
|
+
name: 'mcp',
|
287
|
+
description: 'list configured MCP servers and tools',
|
288
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
289
|
+
// Check if the _subCommand includes a specific flag to control description visibility
|
290
|
+
let useShowDescriptions = showToolDescriptions;
|
291
|
+
if (_subCommand === 'desc' || _subCommand === 'descriptions') {
|
292
|
+
useShowDescriptions = true;
|
293
|
+
}
|
294
|
+
else if (_subCommand === 'nodesc' ||
|
295
|
+
_subCommand === 'nodescriptions') {
|
296
|
+
useShowDescriptions = false;
|
297
|
+
}
|
298
|
+
else if (_args === 'desc' || _args === 'descriptions') {
|
299
|
+
useShowDescriptions = true;
|
300
|
+
}
|
301
|
+
else if (_args === 'nodesc' || _args === 'nodescriptions') {
|
302
|
+
useShowDescriptions = false;
|
303
|
+
}
|
304
|
+
// Check if the _subCommand includes a specific flag to show detailed tool schema
|
305
|
+
let useShowSchema = false;
|
306
|
+
if (_subCommand === 'schema' || _args === 'schema') {
|
307
|
+
useShowSchema = true;
|
308
|
+
}
|
309
|
+
const toolRegistry = await config?.getToolRegistry();
|
310
|
+
if (!toolRegistry) {
|
311
|
+
addMessage({
|
312
|
+
type: MessageType.ERROR,
|
313
|
+
content: 'Could not retrieve tool registry.',
|
314
|
+
timestamp: new Date(),
|
315
|
+
});
|
316
|
+
return;
|
317
|
+
}
|
318
|
+
const mcpServers = config?.getMcpServers() || {};
|
319
|
+
const serverNames = Object.keys(mcpServers);
|
320
|
+
if (serverNames.length === 0) {
|
321
|
+
const docsUrl = 'https://goo.gle/gemini-cli-docs-mcp';
|
322
|
+
if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
|
323
|
+
addMessage({
|
324
|
+
type: MessageType.INFO,
|
325
|
+
content: `No MCP servers configured. Please open the following URL in your browser to view documentation:\n${docsUrl}`,
|
326
|
+
timestamp: new Date(),
|
327
|
+
});
|
328
|
+
}
|
329
|
+
else {
|
330
|
+
addMessage({
|
331
|
+
type: MessageType.INFO,
|
332
|
+
content: `No MCP servers configured. Opening documentation in your browser: ${docsUrl}`,
|
333
|
+
timestamp: new Date(),
|
334
|
+
});
|
335
|
+
await open(docsUrl);
|
336
|
+
}
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
// Check if any servers are still connecting
|
340
|
+
const connectingServers = serverNames.filter((name) => getMCPServerStatus(name) === MCPServerStatus.CONNECTING);
|
341
|
+
const discoveryState = getMCPDiscoveryState();
|
342
|
+
let message = '';
|
343
|
+
// Add overall discovery status message if needed
|
344
|
+
if (discoveryState === MCPDiscoveryState.IN_PROGRESS ||
|
345
|
+
connectingServers.length > 0) {
|
346
|
+
message +=
|
347
|
+
ansi.accentYellow(`⏳ MCP servers are starting up (${connectingServers.length} initializing)...`) + '\n';
|
348
|
+
message +=
|
349
|
+
ansi.gray('Note: First startup may take longer. Tool availability will update automatically.') + '\n\n';
|
350
|
+
}
|
351
|
+
message += 'Configured MCP servers:\n\n';
|
352
|
+
for (const serverName of serverNames) {
|
353
|
+
const serverTools = toolRegistry.getToolsByServer(serverName);
|
354
|
+
const status = getMCPServerStatus(serverName);
|
355
|
+
// Add status indicator with descriptive text
|
356
|
+
let statusIndicator = '';
|
357
|
+
let statusText = '';
|
358
|
+
switch (status) {
|
359
|
+
case MCPServerStatus.CONNECTED:
|
360
|
+
statusIndicator = '🟢';
|
361
|
+
statusText = 'Ready';
|
362
|
+
break;
|
363
|
+
case MCPServerStatus.CONNECTING:
|
364
|
+
statusIndicator = '🔄';
|
365
|
+
statusText = 'Starting... (first startup may take longer)';
|
366
|
+
break;
|
367
|
+
case MCPServerStatus.DISCONNECTED:
|
368
|
+
default:
|
369
|
+
statusIndicator = '🔴';
|
370
|
+
statusText = 'Disconnected';
|
371
|
+
break;
|
372
|
+
}
|
373
|
+
// Get server description if available
|
374
|
+
const server = mcpServers[serverName];
|
375
|
+
// Format server header with bold formatting and status
|
376
|
+
message += `${statusIndicator} ${ansi.bold(serverName)} - ${statusText}`;
|
377
|
+
// Add tool count with conditional messaging
|
378
|
+
if (status === MCPServerStatus.CONNECTED) {
|
379
|
+
message += ` (${serverTools.length} tools)`;
|
380
|
+
}
|
381
|
+
else if (status === MCPServerStatus.CONNECTING) {
|
382
|
+
message += ` (tools will appear when ready)`;
|
383
|
+
}
|
384
|
+
else {
|
385
|
+
message += ` (${serverTools.length} tools cached)`;
|
386
|
+
}
|
387
|
+
// Add server description with proper handling of multi-line descriptions
|
388
|
+
if ((useShowDescriptions || useShowSchema) && server?.description) {
|
389
|
+
const descLines = server.description.trim().split('\n');
|
390
|
+
if (descLines) {
|
391
|
+
message += ':\n';
|
392
|
+
for (const descLine of descLines) {
|
393
|
+
message += ` ${ansi.accentGreen(descLine)}\n`;
|
394
|
+
}
|
395
|
+
}
|
396
|
+
else {
|
397
|
+
message += '\n';
|
398
|
+
}
|
399
|
+
}
|
400
|
+
else {
|
401
|
+
message += '\n';
|
402
|
+
}
|
403
|
+
if (serverTools.length > 0) {
|
404
|
+
serverTools.forEach((tool) => {
|
405
|
+
if ((useShowDescriptions || useShowSchema) &&
|
406
|
+
tool.description) {
|
407
|
+
// Format tool name in cyan using simple ANSI cyan color
|
408
|
+
message += ` - ${ansi.accentCyan(tool.name)}`;
|
409
|
+
// Handle multi-line descriptions by properly indenting and preserving formatting
|
410
|
+
const descLines = tool.description.trim().split('\n');
|
411
|
+
if (descLines) {
|
412
|
+
message += ':\n';
|
413
|
+
for (const descLine of descLines) {
|
414
|
+
message += ` ${ansi.accentGreen(descLine)}\n`;
|
415
|
+
}
|
416
|
+
}
|
417
|
+
else {
|
418
|
+
message += '\n';
|
419
|
+
}
|
420
|
+
}
|
421
|
+
else {
|
422
|
+
// Use cyan color for the tool name even when not showing descriptions
|
423
|
+
message += ` - ${ansi.accentCyan(tool.name)}\n`;
|
424
|
+
}
|
425
|
+
if (useShowSchema) {
|
426
|
+
// Prefix the parameters in cyan
|
427
|
+
message += ` ${ansi.accentCyan('Parameters')}:\n`;
|
428
|
+
const paramsLines = JSON.stringify(tool.schema.parameters, null, 2)
|
429
|
+
.trim()
|
430
|
+
.split('\n');
|
431
|
+
if (paramsLines) {
|
432
|
+
for (const paramsLine of paramsLines) {
|
433
|
+
message += ` ${ansi.accentGreen(paramsLine)}\n`;
|
434
|
+
}
|
435
|
+
}
|
436
|
+
}
|
437
|
+
});
|
438
|
+
}
|
439
|
+
else {
|
440
|
+
message += ' No tools available\n';
|
441
|
+
}
|
442
|
+
message += '\n';
|
443
|
+
}
|
444
|
+
addMessage({
|
445
|
+
type: MessageType.INFO,
|
446
|
+
content: message,
|
447
|
+
timestamp: new Date(),
|
448
|
+
});
|
449
|
+
},
|
450
|
+
},
|
451
|
+
{
|
452
|
+
name: 'extensions',
|
453
|
+
description: 'list active extensions',
|
454
|
+
action: async () => {
|
455
|
+
const activeExtensions = config?.getActiveExtensions();
|
456
|
+
if (!activeExtensions || activeExtensions.length === 0) {
|
457
|
+
addMessage({
|
458
|
+
type: MessageType.INFO,
|
459
|
+
content: 'No active extensions.',
|
460
|
+
timestamp: new Date(),
|
461
|
+
});
|
462
|
+
return;
|
463
|
+
}
|
464
|
+
let message = 'Active extensions:\n\n';
|
465
|
+
for (const ext of activeExtensions) {
|
466
|
+
message += ` - \u001b[36m${ext.name} (v${ext.version})\u001b[0m\n`;
|
467
|
+
}
|
468
|
+
// Make sure to reset any ANSI formatting at the end to prevent it from affecting the terminal
|
469
|
+
message += '\u001b[0m';
|
470
|
+
addMessage({
|
471
|
+
type: MessageType.INFO,
|
472
|
+
content: message,
|
473
|
+
timestamp: new Date(),
|
474
|
+
});
|
475
|
+
},
|
476
|
+
},
|
477
|
+
{
|
478
|
+
name: 'tools',
|
479
|
+
description: 'list available LLxprt Code tools',
|
480
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
481
|
+
// Check if the _subCommand includes a specific flag to control description visibility
|
482
|
+
let useShowDescriptions = showToolDescriptions;
|
483
|
+
if (_subCommand === 'desc' || _subCommand === 'descriptions') {
|
484
|
+
useShowDescriptions = true;
|
485
|
+
}
|
486
|
+
else if (_subCommand === 'nodesc' ||
|
487
|
+
_subCommand === 'nodescriptions') {
|
488
|
+
useShowDescriptions = false;
|
489
|
+
}
|
490
|
+
else if (_args === 'desc' || _args === 'descriptions') {
|
491
|
+
useShowDescriptions = true;
|
492
|
+
}
|
493
|
+
else if (_args === 'nodesc' || _args === 'nodescriptions') {
|
494
|
+
useShowDescriptions = false;
|
495
|
+
}
|
496
|
+
const toolRegistry = await config?.getToolRegistry();
|
497
|
+
const tools = toolRegistry?.getAllTools();
|
498
|
+
if (!tools) {
|
499
|
+
addMessage({
|
500
|
+
type: MessageType.ERROR,
|
501
|
+
content: 'Could not retrieve tools.',
|
502
|
+
timestamp: new Date(),
|
503
|
+
});
|
504
|
+
return;
|
505
|
+
}
|
506
|
+
// Filter out MCP tools by checking if they have a serverName property
|
507
|
+
const geminiTools = tools.filter((tool) => !('serverName' in tool));
|
508
|
+
let message = 'Available Gemini CLI tools:\n\n';
|
509
|
+
if (geminiTools.length > 0) {
|
510
|
+
geminiTools.forEach((tool) => {
|
511
|
+
if (useShowDescriptions && tool.description) {
|
512
|
+
// Format tool name in cyan using simple ANSI cyan color
|
513
|
+
message += ` - ${ansi.accentCyan(`${tool.displayName} (${tool.name})`)}:\n`;
|
514
|
+
// Handle multi-line descriptions by properly indenting and preserving formatting
|
515
|
+
const descLines = tool.description.trim().split('\n');
|
516
|
+
// If there are multiple lines, add proper indentation for each line
|
517
|
+
if (descLines) {
|
518
|
+
for (const descLine of descLines) {
|
519
|
+
message += ` ${ansi.accentGreen(descLine)}\n`;
|
520
|
+
}
|
521
|
+
}
|
522
|
+
}
|
523
|
+
else {
|
524
|
+
// Use cyan color for the tool name even when not showing descriptions
|
525
|
+
message += ` - ${ansi.accentCyan(tool.displayName)}\n`;
|
526
|
+
}
|
527
|
+
});
|
528
|
+
}
|
529
|
+
else {
|
530
|
+
message += ' No tools available\n';
|
531
|
+
}
|
532
|
+
message += '\n';
|
533
|
+
addMessage({
|
534
|
+
type: MessageType.INFO,
|
535
|
+
content: message,
|
536
|
+
timestamp: new Date(),
|
537
|
+
});
|
538
|
+
},
|
539
|
+
},
|
540
|
+
{
|
541
|
+
name: 'model',
|
542
|
+
description: 'select or switch model',
|
543
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
544
|
+
const modelName = _subCommand || _args;
|
545
|
+
const providerManager = getProviderManager();
|
546
|
+
// Always use provider model dialog
|
547
|
+
if (!modelName) {
|
548
|
+
openProviderModelDialog();
|
549
|
+
return;
|
550
|
+
}
|
551
|
+
// Switch model in provider
|
552
|
+
try {
|
553
|
+
const activeProvider = providerManager.getActiveProvider();
|
554
|
+
const currentModel = activeProvider.getCurrentModel
|
555
|
+
? activeProvider.getCurrentModel()
|
556
|
+
: 'unknown';
|
557
|
+
if (activeProvider.setModel) {
|
558
|
+
activeProvider.setModel(modelName);
|
559
|
+
// Keep config model in sync so /about shows correct model
|
560
|
+
if (config) {
|
561
|
+
config.setModel(modelName);
|
562
|
+
}
|
563
|
+
addMessage({
|
564
|
+
type: MessageType.INFO,
|
565
|
+
content: `Switched from ${currentModel} to ${modelName} in provider '${activeProvider.name}'`,
|
566
|
+
timestamp: new Date(),
|
567
|
+
});
|
568
|
+
}
|
569
|
+
else {
|
570
|
+
addMessage({
|
571
|
+
type: MessageType.ERROR,
|
572
|
+
content: `Provider '${activeProvider.name}' does not support model switching`,
|
573
|
+
timestamp: new Date(),
|
574
|
+
});
|
575
|
+
}
|
576
|
+
}
|
577
|
+
catch (error) {
|
578
|
+
addMessage({
|
579
|
+
type: MessageType.ERROR,
|
580
|
+
content: `Failed to switch model: ${error instanceof Error ? error.message : String(error)}`,
|
581
|
+
timestamp: new Date(),
|
582
|
+
});
|
583
|
+
}
|
584
|
+
},
|
585
|
+
},
|
586
|
+
{
|
587
|
+
name: 'provider',
|
588
|
+
description: 'switch between different AI providers (openai, anthropic, etc.)',
|
589
|
+
action: async (_mainCommand, providerName, _args) => {
|
590
|
+
const providerManager = getProviderManager();
|
591
|
+
if (!providerName) {
|
592
|
+
// Open interactive provider selection dialog
|
593
|
+
openProviderDialog();
|
594
|
+
return;
|
595
|
+
}
|
596
|
+
try {
|
597
|
+
const currentProvider = providerManager.getActiveProviderName();
|
598
|
+
// Handle switching to same provider
|
599
|
+
if (providerName === currentProvider) {
|
600
|
+
addMessage({
|
601
|
+
type: MessageType.INFO,
|
602
|
+
content: `Already using provider: ${currentProvider}`,
|
603
|
+
timestamp: new Date(),
|
604
|
+
});
|
605
|
+
return;
|
606
|
+
}
|
607
|
+
const fromProvider = currentProvider || 'none';
|
608
|
+
providerManager.setActiveProvider(providerName);
|
609
|
+
// Update config model to provider default
|
610
|
+
const newActiveProvider = providerManager.getActiveProvider();
|
611
|
+
if (config && newActiveProvider.getCurrentModel) {
|
612
|
+
config.setModel(newActiveProvider.getCurrentModel());
|
613
|
+
}
|
614
|
+
// Set the appropriate auth type based on provider
|
615
|
+
if (providerName === 'gemini') {
|
616
|
+
settings.setValue(SettingScope.User, 'selectedAuthType', AuthType.USE_GEMINI);
|
617
|
+
await config?.refreshAuth(AuthType.USE_GEMINI);
|
618
|
+
}
|
619
|
+
else {
|
620
|
+
settings.setValue(SettingScope.User, 'selectedAuthType', AuthType.USE_PROVIDER);
|
621
|
+
await config?.refreshAuth(AuthType.USE_PROVIDER);
|
622
|
+
}
|
623
|
+
addMessage({
|
624
|
+
type: MessageType.INFO,
|
625
|
+
content: `Switched from ${fromProvider} to ${providerName}`,
|
626
|
+
timestamp: new Date(),
|
627
|
+
});
|
628
|
+
// Trigger payment mode check to show banner when switching providers
|
629
|
+
// Pass the previous provider to ensure proper detection
|
630
|
+
if (checkPaymentModeChange) {
|
631
|
+
setTimeout(() => checkPaymentModeChange(fromProvider), 100);
|
632
|
+
}
|
633
|
+
}
|
634
|
+
catch (error) {
|
635
|
+
addMessage({
|
636
|
+
type: MessageType.ERROR,
|
637
|
+
content: `Failed to switch provider: ${error instanceof Error ? error.message : String(error)}`,
|
638
|
+
timestamp: new Date(),
|
639
|
+
});
|
640
|
+
}
|
641
|
+
},
|
642
|
+
},
|
643
|
+
{
|
644
|
+
name: 'corgi',
|
645
|
+
action: (_mainCommand, _subCommand, _args) => {
|
646
|
+
toggleCorgiMode();
|
647
|
+
},
|
648
|
+
},
|
649
|
+
{
|
650
|
+
name: 'bug',
|
651
|
+
description: 'submit a bug report',
|
652
|
+
action: async (_mainCommand, _subCommand, args) => {
|
653
|
+
let bugDescription = _subCommand || '';
|
654
|
+
if (args) {
|
655
|
+
bugDescription += ` ${args}`;
|
656
|
+
}
|
657
|
+
bugDescription = bugDescription.trim();
|
658
|
+
const osVersion = `${process.platform} ${process.version}`;
|
659
|
+
let sandboxEnv = 'no sandbox';
|
660
|
+
if (process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec') {
|
661
|
+
sandboxEnv = process.env.SANDBOX.replace(/^gemini-(?:code-)?/, '');
|
662
|
+
}
|
663
|
+
else if (process.env.SANDBOX === 'sandbox-exec') {
|
664
|
+
sandboxEnv = `sandbox-exec (${process.env.SEATBELT_PROFILE || 'unknown'})`;
|
665
|
+
}
|
666
|
+
const modelVersion = config?.getModel() || 'Unknown';
|
667
|
+
const cliVersion = await getCliVersion();
|
668
|
+
const memoryUsage = formatMemoryUsage(process.memoryUsage().rss);
|
669
|
+
const info = `
|
670
|
+
* **CLI Version:** ${cliVersion}
|
671
|
+
* **Git Commit:** ${GIT_COMMIT_INFO}
|
672
|
+
* **Operating System:** ${osVersion}
|
673
|
+
* **Sandbox Environment:** ${sandboxEnv}
|
674
|
+
* **Model Version:** ${modelVersion}
|
675
|
+
* **Memory Usage:** ${memoryUsage}
|
676
|
+
`;
|
677
|
+
let bugReportUrl = 'https://github.com/acoliver/llxprt-code/issues/new?template=bug_report.yml&title={title}&info={info}';
|
678
|
+
const bugCommand = config?.getBugCommand();
|
679
|
+
if (bugCommand?.urlTemplate) {
|
680
|
+
bugReportUrl = bugCommand.urlTemplate;
|
681
|
+
}
|
682
|
+
bugReportUrl = bugReportUrl
|
683
|
+
.replace('{title}', encodeURIComponent(bugDescription))
|
684
|
+
.replace('{info}', encodeURIComponent(info));
|
685
|
+
addMessage({
|
686
|
+
type: MessageType.INFO,
|
687
|
+
content: `To submit your bug report, please open the following URL in your browser:\n${bugReportUrl}`,
|
688
|
+
timestamp: new Date(),
|
689
|
+
});
|
690
|
+
(async () => {
|
691
|
+
try {
|
692
|
+
await open(bugReportUrl);
|
693
|
+
}
|
694
|
+
catch (error) {
|
695
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
696
|
+
addMessage({
|
697
|
+
type: MessageType.ERROR,
|
698
|
+
content: `Could not open URL in browser: ${errorMessage}`,
|
699
|
+
timestamp: new Date(),
|
700
|
+
});
|
701
|
+
}
|
702
|
+
})();
|
703
|
+
},
|
704
|
+
},
|
705
|
+
{
|
706
|
+
name: 'chat',
|
707
|
+
description: 'Manage conversation history. Usage: /chat <list|save|resume> <tag>',
|
708
|
+
action: async (_mainCommand, subCommand, args) => {
|
709
|
+
const tag = (args || '').trim();
|
710
|
+
const logger = new Logger(config?.getSessionId() || '');
|
711
|
+
await logger.initialize();
|
712
|
+
const chat = await config?.getGeminiClient()?.getChat();
|
713
|
+
if (!chat) {
|
714
|
+
addMessage({
|
715
|
+
type: MessageType.ERROR,
|
716
|
+
content: 'No chat client available for conversation status.',
|
717
|
+
timestamp: new Date(),
|
718
|
+
});
|
719
|
+
return;
|
720
|
+
}
|
721
|
+
if (!subCommand) {
|
722
|
+
addMessage({
|
723
|
+
type: MessageType.ERROR,
|
724
|
+
content: 'Missing command\nUsage: /chat <list|save|resume> <tag>',
|
725
|
+
timestamp: new Date(),
|
726
|
+
});
|
727
|
+
return;
|
728
|
+
}
|
729
|
+
switch (subCommand) {
|
730
|
+
case 'save': {
|
731
|
+
if (!tag) {
|
732
|
+
addMessage({
|
733
|
+
type: MessageType.ERROR,
|
734
|
+
content: 'Missing tag. Usage: /chat save <tag>',
|
735
|
+
timestamp: new Date(),
|
736
|
+
});
|
737
|
+
return;
|
738
|
+
}
|
739
|
+
const history = chat.getHistory();
|
740
|
+
if (history.length > 0) {
|
741
|
+
await logger.saveCheckpoint(chat?.getHistory() || [], tag, ConversationContext.getContext());
|
742
|
+
addMessage({
|
743
|
+
type: MessageType.INFO,
|
744
|
+
content: `Conversation checkpoint saved with tag: ${tag}.`,
|
745
|
+
timestamp: new Date(),
|
746
|
+
});
|
747
|
+
}
|
748
|
+
else {
|
749
|
+
addMessage({
|
750
|
+
type: MessageType.INFO,
|
751
|
+
content: 'No conversation found to save.',
|
752
|
+
timestamp: new Date(),
|
753
|
+
});
|
754
|
+
}
|
755
|
+
return;
|
756
|
+
}
|
757
|
+
case 'resume':
|
758
|
+
case 'restore':
|
759
|
+
case 'load': {
|
760
|
+
if (!tag) {
|
761
|
+
addMessage({
|
762
|
+
type: MessageType.ERROR,
|
763
|
+
content: 'Missing tag. Usage: /chat resume <tag>',
|
764
|
+
timestamp: new Date(),
|
765
|
+
});
|
766
|
+
return;
|
767
|
+
}
|
768
|
+
const { history: conversation, context } = await logger.loadCheckpoint(tag);
|
769
|
+
if (conversation.length === 0) {
|
770
|
+
addMessage({
|
771
|
+
type: MessageType.INFO,
|
772
|
+
content: `No saved checkpoint found with tag: ${tag}.`,
|
773
|
+
timestamp: new Date(),
|
774
|
+
});
|
775
|
+
return;
|
776
|
+
}
|
777
|
+
if (context) {
|
778
|
+
ConversationContext.setContext(context);
|
779
|
+
}
|
780
|
+
else {
|
781
|
+
// For old checkpoints, start a new context
|
782
|
+
ConversationContext.startNewConversation();
|
783
|
+
}
|
784
|
+
clearItems();
|
785
|
+
chat.clearHistory();
|
786
|
+
const rolemap = {
|
787
|
+
user: MessageType.USER,
|
788
|
+
model: MessageType.GEMINI,
|
789
|
+
};
|
790
|
+
let hasSystemPrompt = false;
|
791
|
+
let i = 0;
|
792
|
+
for (const item of conversation) {
|
793
|
+
i += 1;
|
794
|
+
// Add each item to history regardless of whether we display
|
795
|
+
// it.
|
796
|
+
chat.addHistory(item);
|
797
|
+
const text = item.parts
|
798
|
+
?.filter((m) => !!m.text)
|
799
|
+
.map((m) => m.text)
|
800
|
+
.join('') || '';
|
801
|
+
if (!text) {
|
802
|
+
// Parsing Part[] back to various non-text output not yet implemented.
|
803
|
+
continue;
|
804
|
+
}
|
805
|
+
if (i === 1 && text.match(/context for our chat/)) {
|
806
|
+
hasSystemPrompt = true;
|
807
|
+
}
|
808
|
+
if (i > 2 || !hasSystemPrompt) {
|
809
|
+
addItem({
|
810
|
+
type: (item.role && rolemap[item.role]) || MessageType.GEMINI,
|
811
|
+
text,
|
812
|
+
}, i);
|
813
|
+
}
|
814
|
+
}
|
815
|
+
console.clear();
|
816
|
+
refreshStatic();
|
817
|
+
return;
|
818
|
+
}
|
819
|
+
case 'list':
|
820
|
+
addMessage({
|
821
|
+
type: MessageType.INFO,
|
822
|
+
content: 'list of saved conversations: ' +
|
823
|
+
(await savedChatTags()).join(', '),
|
824
|
+
timestamp: new Date(),
|
825
|
+
});
|
826
|
+
return;
|
827
|
+
default:
|
828
|
+
addMessage({
|
829
|
+
type: MessageType.ERROR,
|
830
|
+
content: `Unknown /chat command: ${subCommand}. Available: list, save, resume`,
|
831
|
+
timestamp: new Date(),
|
832
|
+
});
|
833
|
+
return;
|
834
|
+
}
|
835
|
+
},
|
836
|
+
completion: async () => (await savedChatTags()).map((tag) => 'resume ' + tag),
|
837
|
+
},
|
838
|
+
{
|
839
|
+
name: 'quit',
|
840
|
+
altName: 'exit',
|
841
|
+
description: 'exit the cli',
|
842
|
+
action: async (mainCommand, _subCommand, _args) => {
|
843
|
+
const now = new Date();
|
844
|
+
const { sessionStartTime } = session.stats;
|
845
|
+
const wallDuration = now.getTime() - sessionStartTime.getTime();
|
846
|
+
setQuittingMessages([
|
847
|
+
{
|
848
|
+
type: 'user',
|
849
|
+
text: `/${mainCommand}`,
|
850
|
+
id: now.getTime() - 1,
|
851
|
+
},
|
852
|
+
{
|
853
|
+
type: 'quit',
|
854
|
+
duration: formatDuration(wallDuration),
|
855
|
+
id: now.getTime(),
|
856
|
+
},
|
857
|
+
]);
|
858
|
+
setTimeout(() => {
|
859
|
+
process.exit(0);
|
860
|
+
}, 100);
|
861
|
+
},
|
862
|
+
},
|
863
|
+
{
|
864
|
+
name: 'compress',
|
865
|
+
altName: 'summarize',
|
866
|
+
description: 'Compresses the context by replacing it with a summary.',
|
867
|
+
action: async (_mainCommand, _subCommand, _args) => {
|
868
|
+
if (pendingCompressionItemRef.current !== null) {
|
869
|
+
addMessage({
|
870
|
+
type: MessageType.ERROR,
|
871
|
+
content: 'Already compressing, wait for previous request to complete',
|
872
|
+
timestamp: new Date(),
|
873
|
+
});
|
874
|
+
return;
|
875
|
+
}
|
876
|
+
setPendingCompressionItem({
|
877
|
+
type: MessageType.COMPRESSION,
|
878
|
+
compression: {
|
879
|
+
isPending: true,
|
880
|
+
originalTokenCount: null,
|
881
|
+
newTokenCount: null,
|
882
|
+
},
|
883
|
+
});
|
884
|
+
try {
|
885
|
+
const compressed = await config
|
886
|
+
.getGeminiClient()
|
887
|
+
// TODO: Set Prompt id for CompressChat from SlashCommandProcessor.
|
888
|
+
.tryCompressChat('Prompt Id not set', true);
|
889
|
+
if (compressed) {
|
890
|
+
addMessage({
|
891
|
+
type: MessageType.COMPRESSION,
|
892
|
+
compression: {
|
893
|
+
isPending: false,
|
894
|
+
originalTokenCount: compressed.originalTokenCount,
|
895
|
+
newTokenCount: compressed.newTokenCount,
|
896
|
+
},
|
897
|
+
timestamp: new Date(),
|
898
|
+
});
|
899
|
+
}
|
900
|
+
else {
|
901
|
+
addMessage({
|
902
|
+
type: MessageType.ERROR,
|
903
|
+
content: 'Failed to compress chat history.',
|
904
|
+
timestamp: new Date(),
|
905
|
+
});
|
906
|
+
}
|
907
|
+
}
|
908
|
+
catch (e) {
|
909
|
+
addMessage({
|
910
|
+
type: MessageType.ERROR,
|
911
|
+
content: `Failed to compress chat history: ${e instanceof Error ? e.message : String(e)}`,
|
912
|
+
timestamp: new Date(),
|
913
|
+
});
|
914
|
+
}
|
915
|
+
setPendingCompressionItem(null);
|
916
|
+
},
|
917
|
+
},
|
918
|
+
{
|
919
|
+
name: 'key',
|
920
|
+
description: 'set or remove API key for the current provider',
|
921
|
+
action: async (_mainCommand, apiKey, _args) => {
|
922
|
+
const providerManager = getProviderManager();
|
923
|
+
const result = await setProviderApiKey(providerManager, settings, apiKey, config ?? undefined);
|
924
|
+
addMessage({
|
925
|
+
type: result.success ? MessageType.INFO : MessageType.ERROR,
|
926
|
+
content: result.message,
|
927
|
+
timestamp: new Date(),
|
928
|
+
});
|
929
|
+
// Trigger payment mode check to show banner if needed
|
930
|
+
if (result.success && checkPaymentModeChange) {
|
931
|
+
setTimeout(checkPaymentModeChange, 100);
|
932
|
+
}
|
933
|
+
},
|
934
|
+
},
|
935
|
+
{
|
936
|
+
name: 'keyfile',
|
937
|
+
description: 'manage API key file for the current provider',
|
938
|
+
action: async (_mainCommand, filePath, _args) => {
|
939
|
+
const providerManager = getProviderManager();
|
940
|
+
try {
|
941
|
+
const activeProvider = providerManager.getActiveProvider();
|
942
|
+
const providerName = activeProvider.name;
|
943
|
+
// If no path provided, check for existing keyfile
|
944
|
+
if (!filePath || filePath.trim() === '') {
|
945
|
+
// Check common keyfile locations
|
946
|
+
const keyfilePaths = [
|
947
|
+
path.join(homedir(), `.${providerName}_key`),
|
948
|
+
path.join(homedir(), `.${providerName}-key`),
|
949
|
+
path.join(homedir(), `.${providerName}_api_key`),
|
950
|
+
];
|
951
|
+
// For specific providers, check their known keyfile locations
|
952
|
+
if (providerName === 'openai') {
|
953
|
+
keyfilePaths.unshift(path.join(homedir(), '.openai_key'));
|
954
|
+
}
|
955
|
+
else if (providerName === 'anthropic') {
|
956
|
+
keyfilePaths.unshift(path.join(homedir(), '.anthropic_key'));
|
957
|
+
}
|
958
|
+
let foundKeyfile = null;
|
959
|
+
for (const keyfilePath of keyfilePaths) {
|
960
|
+
try {
|
961
|
+
await fs.access(keyfilePath);
|
962
|
+
foundKeyfile = keyfilePath;
|
963
|
+
break;
|
964
|
+
}
|
965
|
+
catch {
|
966
|
+
// File doesn't exist, continue checking
|
967
|
+
}
|
968
|
+
}
|
969
|
+
if (foundKeyfile) {
|
970
|
+
addMessage({
|
971
|
+
type: MessageType.INFO,
|
972
|
+
content: `Current keyfile for provider '${providerName}': ${foundKeyfile}\nTo remove: /keyfile none\nTo change: /keyfile <new_path>`,
|
973
|
+
timestamp: new Date(),
|
974
|
+
});
|
975
|
+
}
|
976
|
+
else {
|
977
|
+
addMessage({
|
978
|
+
type: MessageType.INFO,
|
979
|
+
content: `No keyfile found for provider '${providerName}'\nTo set: /keyfile <path>`,
|
980
|
+
timestamp: new Date(),
|
981
|
+
});
|
982
|
+
}
|
983
|
+
return;
|
984
|
+
}
|
985
|
+
// If 'none' is specified, remove the keyfile setting
|
986
|
+
if (filePath.trim().toLowerCase() === 'none') {
|
987
|
+
const result = await setProviderApiKey(providerManager, settings, undefined, // Clear the API key
|
988
|
+
config ?? undefined);
|
989
|
+
addMessage({
|
990
|
+
type: result.success ? MessageType.INFO : MessageType.ERROR,
|
991
|
+
content: result.message.replace('API key removed', 'Keyfile removed'),
|
992
|
+
timestamp: new Date(),
|
993
|
+
});
|
994
|
+
// Trigger payment mode check to show banner if needed
|
995
|
+
if (result.success && checkPaymentModeChange) {
|
996
|
+
setTimeout(checkPaymentModeChange, 100);
|
997
|
+
}
|
998
|
+
return;
|
999
|
+
}
|
1000
|
+
// Load API key from file
|
1001
|
+
const result = await setProviderApiKeyFromFile(providerManager, settings, filePath, config ?? undefined);
|
1002
|
+
addMessage({
|
1003
|
+
type: result.success ? MessageType.INFO : MessageType.ERROR,
|
1004
|
+
content: result.message,
|
1005
|
+
timestamp: new Date(),
|
1006
|
+
});
|
1007
|
+
// Trigger payment mode check to show banner if needed
|
1008
|
+
if (result.success && checkPaymentModeChange) {
|
1009
|
+
setTimeout(checkPaymentModeChange, 100);
|
1010
|
+
}
|
1011
|
+
}
|
1012
|
+
catch (error) {
|
1013
|
+
addMessage({
|
1014
|
+
type: MessageType.ERROR,
|
1015
|
+
content: `Failed to process keyfile: ${error instanceof Error ? error.message : String(error)}`,
|
1016
|
+
timestamp: new Date(),
|
1017
|
+
});
|
1018
|
+
}
|
1019
|
+
},
|
1020
|
+
},
|
1021
|
+
{
|
1022
|
+
name: 'baseurl',
|
1023
|
+
description: 'set base URL for the current provider',
|
1024
|
+
action: async (_mainCommand, baseUrl, _args) => {
|
1025
|
+
const providerManager = getProviderManager();
|
1026
|
+
const result = await setProviderBaseUrl(providerManager, settings, baseUrl);
|
1027
|
+
addMessage({
|
1028
|
+
type: result.success ? MessageType.INFO : MessageType.ERROR,
|
1029
|
+
content: result.message,
|
1030
|
+
timestamp: new Date(),
|
1031
|
+
});
|
1032
|
+
},
|
1033
|
+
},
|
1034
|
+
{
|
1035
|
+
name: 'toolformat',
|
1036
|
+
description: 'override the auto-detected tool calling format',
|
1037
|
+
action: async (_mainCommand, formatName, _args) => {
|
1038
|
+
const providerManager = getProviderManager();
|
1039
|
+
const activeProvider = providerManager.getActiveProvider();
|
1040
|
+
const providerName = activeProvider.name;
|
1041
|
+
// Supported formats
|
1042
|
+
const structuredFormats = ['openai', 'anthropic', 'deepseek', 'qwen'];
|
1043
|
+
const textFormats = ['hermes', 'xml', 'llama', 'gemma'];
|
1044
|
+
const allFormats = [...structuredFormats, ...textFormats];
|
1045
|
+
// Show current format
|
1046
|
+
if (!formatName) {
|
1047
|
+
const currentFormat = activeProvider.getToolFormat
|
1048
|
+
? activeProvider.getToolFormat()
|
1049
|
+
: 'unknown';
|
1050
|
+
const isAutoDetected = !(settings.merged.providerToolFormatOverrides &&
|
1051
|
+
settings.merged.providerToolFormatOverrides[providerName]);
|
1052
|
+
addMessage({
|
1053
|
+
type: MessageType.INFO,
|
1054
|
+
content: `Current tool format: ${currentFormat} (${isAutoDetected ? 'auto-detected' : 'manual override'})
|
1055
|
+
To override: /toolformat <format>
|
1056
|
+
To return to auto: /toolformat auto
|
1057
|
+
Supported formats:
|
1058
|
+
Structured: ${structuredFormats.join(', ')}
|
1059
|
+
Text-based: ${textFormats.join(', ')}`,
|
1060
|
+
timestamp: new Date(),
|
1061
|
+
});
|
1062
|
+
return;
|
1063
|
+
}
|
1064
|
+
// Return to auto-detection
|
1065
|
+
if (formatName === 'auto') {
|
1066
|
+
// Clear override in provider
|
1067
|
+
if (activeProvider.setToolFormatOverride) {
|
1068
|
+
activeProvider.setToolFormatOverride(null);
|
1069
|
+
}
|
1070
|
+
// Also clear from settings
|
1071
|
+
const currentOverrides = settings.merged.providerToolFormatOverrides || {};
|
1072
|
+
delete currentOverrides[providerName];
|
1073
|
+
settings.setValue(SettingScope.User, 'providerToolFormatOverrides', currentOverrides);
|
1074
|
+
addMessage({
|
1075
|
+
type: MessageType.INFO,
|
1076
|
+
content: `Tool format override cleared for provider '${providerName}'. Using auto-detection.`,
|
1077
|
+
timestamp: new Date(),
|
1078
|
+
});
|
1079
|
+
return;
|
1080
|
+
}
|
1081
|
+
// Validate format
|
1082
|
+
if (!allFormats.includes(formatName)) {
|
1083
|
+
addMessage({
|
1084
|
+
type: MessageType.ERROR,
|
1085
|
+
content: `Invalid format '${formatName}'. Supported formats:
|
1086
|
+
Structured: ${structuredFormats.join(', ')}
|
1087
|
+
Text-based: ${textFormats.join(', ')}`,
|
1088
|
+
timestamp: new Date(),
|
1089
|
+
});
|
1090
|
+
return;
|
1091
|
+
}
|
1092
|
+
// Set override
|
1093
|
+
try {
|
1094
|
+
// Update provider directly
|
1095
|
+
if (activeProvider.setToolFormatOverride) {
|
1096
|
+
activeProvider.setToolFormatOverride(formatName);
|
1097
|
+
}
|
1098
|
+
// Also save to settings for persistence
|
1099
|
+
const currentOverrides = settings.merged.providerToolFormatOverrides || {};
|
1100
|
+
currentOverrides[providerName] = formatName;
|
1101
|
+
settings.setValue(SettingScope.User, 'providerToolFormatOverrides', currentOverrides);
|
1102
|
+
addMessage({
|
1103
|
+
type: MessageType.INFO,
|
1104
|
+
content: `Tool format override set to '${formatName}' for provider '${providerName}'`,
|
1105
|
+
timestamp: new Date(),
|
1106
|
+
});
|
1107
|
+
}
|
1108
|
+
catch (error) {
|
1109
|
+
addMessage({
|
1110
|
+
type: MessageType.ERROR,
|
1111
|
+
content: `Failed to set tool format override: ${error instanceof Error ? error.message : String(error)}`,
|
1112
|
+
timestamp: new Date(),
|
1113
|
+
});
|
1114
|
+
}
|
1115
|
+
},
|
1116
|
+
},
|
1117
|
+
];
|
1118
|
+
if (config?.getCheckpointingEnabled()) {
|
1119
|
+
commands.push({
|
1120
|
+
name: 'restore',
|
1121
|
+
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',
|
1122
|
+
completion: async () => {
|
1123
|
+
const checkpointDir = config?.getProjectTempDir()
|
1124
|
+
? path.join(config.getProjectTempDir(), 'checkpoints')
|
1125
|
+
: undefined;
|
1126
|
+
if (!checkpointDir) {
|
1127
|
+
return [];
|
1128
|
+
}
|
1129
|
+
try {
|
1130
|
+
const files = await fs.readdir(checkpointDir);
|
1131
|
+
return files
|
1132
|
+
.filter((file) => file.endsWith('.json'))
|
1133
|
+
.map((file) => file.replace('.json', ''));
|
1134
|
+
}
|
1135
|
+
catch (_err) {
|
1136
|
+
return [];
|
1137
|
+
}
|
1138
|
+
},
|
1139
|
+
action: async (_mainCommand, subCommand, _args) => {
|
1140
|
+
const checkpointDir = config?.getProjectTempDir()
|
1141
|
+
? path.join(config.getProjectTempDir(), 'checkpoints')
|
1142
|
+
: undefined;
|
1143
|
+
if (!checkpointDir) {
|
1144
|
+
addMessage({
|
1145
|
+
type: MessageType.ERROR,
|
1146
|
+
content: 'Could not determine the .llxprt directory path.',
|
1147
|
+
timestamp: new Date(),
|
1148
|
+
});
|
1149
|
+
return;
|
1150
|
+
}
|
1151
|
+
try {
|
1152
|
+
// Ensure the directory exists before trying to read it.
|
1153
|
+
await fs.mkdir(checkpointDir, { recursive: true });
|
1154
|
+
const files = await fs.readdir(checkpointDir);
|
1155
|
+
const jsonFiles = files.filter((file) => file.endsWith('.json'));
|
1156
|
+
if (!subCommand) {
|
1157
|
+
if (jsonFiles.length === 0) {
|
1158
|
+
addMessage({
|
1159
|
+
type: MessageType.INFO,
|
1160
|
+
content: 'No restorable tool calls found.',
|
1161
|
+
timestamp: new Date(),
|
1162
|
+
});
|
1163
|
+
return;
|
1164
|
+
}
|
1165
|
+
const truncatedFiles = jsonFiles.map((file) => {
|
1166
|
+
const components = file.split('.');
|
1167
|
+
if (components.length <= 1) {
|
1168
|
+
return file;
|
1169
|
+
}
|
1170
|
+
components.pop();
|
1171
|
+
return components.join('.');
|
1172
|
+
});
|
1173
|
+
const fileList = truncatedFiles.join('\n');
|
1174
|
+
addMessage({
|
1175
|
+
type: MessageType.INFO,
|
1176
|
+
content: `Available tool calls to restore:\n\n${fileList}`,
|
1177
|
+
timestamp: new Date(),
|
1178
|
+
});
|
1179
|
+
return;
|
1180
|
+
}
|
1181
|
+
const selectedFile = subCommand.endsWith('.json')
|
1182
|
+
? subCommand
|
1183
|
+
: `${subCommand}.json`;
|
1184
|
+
if (!jsonFiles.includes(selectedFile)) {
|
1185
|
+
addMessage({
|
1186
|
+
type: MessageType.ERROR,
|
1187
|
+
content: `File not found: ${selectedFile}`,
|
1188
|
+
timestamp: new Date(),
|
1189
|
+
});
|
1190
|
+
return;
|
1191
|
+
}
|
1192
|
+
const filePath = path.join(checkpointDir, selectedFile);
|
1193
|
+
const data = await fs.readFile(filePath, 'utf-8');
|
1194
|
+
const toolCallData = JSON.parse(data);
|
1195
|
+
if (toolCallData.history) {
|
1196
|
+
loadHistory(toolCallData.history);
|
1197
|
+
}
|
1198
|
+
if (toolCallData.clientHistory) {
|
1199
|
+
await config
|
1200
|
+
?.getGeminiClient()
|
1201
|
+
?.setHistory(toolCallData.clientHistory);
|
1202
|
+
}
|
1203
|
+
if (toolCallData.commitHash) {
|
1204
|
+
await gitService?.restoreProjectFromSnapshot(toolCallData.commitHash);
|
1205
|
+
addMessage({
|
1206
|
+
type: MessageType.INFO,
|
1207
|
+
content: `Restored project to the state before the tool call.`,
|
1208
|
+
timestamp: new Date(),
|
1209
|
+
});
|
1210
|
+
}
|
1211
|
+
return {
|
1212
|
+
type: 'tool',
|
1213
|
+
toolName: toolCallData.toolCall.name,
|
1214
|
+
toolArgs: toolCallData.toolCall.args,
|
1215
|
+
};
|
1216
|
+
}
|
1217
|
+
catch (error) {
|
1218
|
+
addMessage({
|
1219
|
+
type: MessageType.ERROR,
|
1220
|
+
content: `Could not read restorable tool calls. This is the error: ${error}`,
|
1221
|
+
timestamp: new Date(),
|
1222
|
+
});
|
1223
|
+
}
|
1224
|
+
},
|
1225
|
+
});
|
1226
|
+
}
|
1227
|
+
return commands;
|
1228
|
+
}, [
|
1229
|
+
addMessage,
|
1230
|
+
openEditorDialog,
|
1231
|
+
openProviderModelDialog,
|
1232
|
+
openProviderDialog,
|
1233
|
+
clearItems,
|
1234
|
+
refreshStatic,
|
1235
|
+
toggleCorgiMode,
|
1236
|
+
savedChatTags,
|
1237
|
+
config,
|
1238
|
+
showToolDescriptions,
|
1239
|
+
session,
|
1240
|
+
gitService,
|
1241
|
+
loadHistory,
|
1242
|
+
addItem,
|
1243
|
+
setQuittingMessages,
|
1244
|
+
pendingCompressionItemRef,
|
1245
|
+
setPendingCompressionItem,
|
1246
|
+
checkPaymentModeChange,
|
1247
|
+
openAuthDialog,
|
1248
|
+
settings,
|
1249
|
+
]);
|
1250
|
+
const handleSlashCommand = useCallback(async (rawQuery) => {
|
1251
|
+
if (typeof rawQuery !== 'string') {
|
1252
|
+
return false;
|
1253
|
+
}
|
1254
|
+
const trimmed = rawQuery.trim();
|
1255
|
+
if (!trimmed.startsWith('/') && !trimmed.startsWith('?')) {
|
1256
|
+
return false;
|
1257
|
+
}
|
1258
|
+
const userMessageTimestamp = Date.now();
|
1259
|
+
if (trimmed !== '/quit' && trimmed !== '/exit') {
|
1260
|
+
addItem({ type: MessageType.USER, text: trimmed }, userMessageTimestamp);
|
1261
|
+
}
|
1262
|
+
const parts = trimmed.substring(1).trim().split(/\s+/);
|
1263
|
+
const commandPath = parts.filter((p) => p); // The parts of the command, e.g., ['memory', 'add']
|
1264
|
+
// --- Start of New Tree Traversal Logic ---
|
1265
|
+
let currentCommands = commands;
|
1266
|
+
let commandToExecute;
|
1267
|
+
let pathIndex = 0;
|
1268
|
+
for (const part of commandPath) {
|
1269
|
+
const foundCommand = currentCommands.find((cmd) => cmd.name === part || cmd.altName === part);
|
1270
|
+
if (foundCommand) {
|
1271
|
+
commandToExecute = foundCommand;
|
1272
|
+
pathIndex++;
|
1273
|
+
if (foundCommand.subCommands) {
|
1274
|
+
currentCommands = foundCommand.subCommands;
|
1275
|
+
}
|
1276
|
+
else {
|
1277
|
+
break;
|
1278
|
+
}
|
1279
|
+
}
|
1280
|
+
else {
|
1281
|
+
break;
|
1282
|
+
}
|
1283
|
+
}
|
1284
|
+
if (commandToExecute) {
|
1285
|
+
const args = parts.slice(pathIndex).join(' ');
|
1286
|
+
if (commandToExecute.action) {
|
1287
|
+
const result = await commandToExecute.action(commandContext, args);
|
1288
|
+
if (result) {
|
1289
|
+
switch (result.type) {
|
1290
|
+
case 'tool':
|
1291
|
+
return {
|
1292
|
+
type: 'schedule_tool',
|
1293
|
+
toolName: result.toolName,
|
1294
|
+
toolArgs: result.toolArgs,
|
1295
|
+
};
|
1296
|
+
case 'message':
|
1297
|
+
addItem({
|
1298
|
+
type: result.messageType === 'error'
|
1299
|
+
? MessageType.ERROR
|
1300
|
+
: MessageType.INFO,
|
1301
|
+
text: result.content,
|
1302
|
+
}, Date.now());
|
1303
|
+
return { type: 'handled' };
|
1304
|
+
case 'dialog':
|
1305
|
+
switch (result.dialog) {
|
1306
|
+
case 'help':
|
1307
|
+
setShowHelp(true);
|
1308
|
+
return { type: 'handled' };
|
1309
|
+
case 'auth':
|
1310
|
+
openAuthDialog();
|
1311
|
+
return { type: 'handled' };
|
1312
|
+
case 'theme':
|
1313
|
+
openThemeDialog();
|
1314
|
+
return { type: 'handled' };
|
1315
|
+
case 'privacy':
|
1316
|
+
openPrivacyNotice();
|
1317
|
+
return { type: 'handled' };
|
1318
|
+
default: {
|
1319
|
+
const unhandled = result.dialog;
|
1320
|
+
throw new Error(`Unhandled slash command result: ${unhandled}`);
|
1321
|
+
}
|
1322
|
+
}
|
1323
|
+
default: {
|
1324
|
+
const unhandled = result;
|
1325
|
+
throw new Error(`Unhandled slash command result: ${unhandled}`);
|
1326
|
+
}
|
1327
|
+
}
|
1328
|
+
}
|
1329
|
+
return { type: 'handled' };
|
1330
|
+
}
|
1331
|
+
else if (commandToExecute.subCommands) {
|
1332
|
+
const helpText = `Command '/${commandToExecute.name}' requires a subcommand. Available:\n${commandToExecute.subCommands
|
1333
|
+
.map((sc) => ` - ${sc.name}: ${sc.description || ''}`)
|
1334
|
+
.join('\n')}`;
|
1335
|
+
addMessage({
|
1336
|
+
type: MessageType.INFO,
|
1337
|
+
content: helpText,
|
1338
|
+
timestamp: new Date(),
|
1339
|
+
});
|
1340
|
+
return { type: 'handled' };
|
1341
|
+
}
|
1342
|
+
}
|
1343
|
+
// --- End of New Tree Traversal Logic ---
|
1344
|
+
// --- Legacy Fallback Logic (for commands not yet migrated) ---
|
1345
|
+
const mainCommand = parts[0];
|
1346
|
+
const subCommand = parts[1];
|
1347
|
+
const legacyArgs = parts.slice(2).join(' ');
|
1348
|
+
for (const cmd of legacyCommands) {
|
1349
|
+
if (mainCommand === cmd.name || mainCommand === cmd.altName) {
|
1350
|
+
const actionResult = await cmd.action(mainCommand, subCommand, legacyArgs);
|
1351
|
+
if (actionResult?.type === 'tool') {
|
1352
|
+
return {
|
1353
|
+
type: 'schedule_tool',
|
1354
|
+
toolName: actionResult.toolName,
|
1355
|
+
toolArgs: actionResult.toolArgs,
|
1356
|
+
};
|
1357
|
+
}
|
1358
|
+
if (actionResult?.type === 'message') {
|
1359
|
+
addItem({
|
1360
|
+
type: actionResult.messageType === 'error'
|
1361
|
+
? MessageType.ERROR
|
1362
|
+
: MessageType.INFO,
|
1363
|
+
text: actionResult.content,
|
1364
|
+
}, Date.now());
|
1365
|
+
}
|
1366
|
+
return { type: 'handled' };
|
1367
|
+
}
|
1368
|
+
}
|
1369
|
+
addMessage({
|
1370
|
+
type: MessageType.ERROR,
|
1371
|
+
content: `Unknown command: ${trimmed}`,
|
1372
|
+
timestamp: new Date(),
|
1373
|
+
});
|
1374
|
+
return { type: 'handled' };
|
1375
|
+
}, [
|
1376
|
+
addItem,
|
1377
|
+
setShowHelp,
|
1378
|
+
openAuthDialog,
|
1379
|
+
commands,
|
1380
|
+
legacyCommands,
|
1381
|
+
commandContext,
|
1382
|
+
addMessage,
|
1383
|
+
openThemeDialog,
|
1384
|
+
openPrivacyNotice,
|
1385
|
+
]);
|
1386
|
+
const allCommands = useMemo(() => {
|
1387
|
+
// Adapt legacy commands to the new SlashCommand interface
|
1388
|
+
const adaptedLegacyCommands = legacyCommands.map((legacyCmd) => ({
|
1389
|
+
name: legacyCmd.name,
|
1390
|
+
altName: legacyCmd.altName,
|
1391
|
+
description: legacyCmd.description,
|
1392
|
+
action: async (_context, args) => {
|
1393
|
+
const parts = args.split(/\s+/);
|
1394
|
+
const subCommand = parts[0] || undefined;
|
1395
|
+
const restOfArgs = parts.slice(1).join(' ') || undefined;
|
1396
|
+
return legacyCmd.action(legacyCmd.name, subCommand, restOfArgs);
|
1397
|
+
},
|
1398
|
+
completion: legacyCmd.completion
|
1399
|
+
? async (_context, _partialArg) => legacyCmd.completion()
|
1400
|
+
: undefined,
|
1401
|
+
}));
|
1402
|
+
const newCommandNames = new Set(commands.map((c) => c.name));
|
1403
|
+
const filteredAdaptedLegacy = adaptedLegacyCommands.filter((c) => !newCommandNames.has(c.name));
|
1404
|
+
return [...commands, ...filteredAdaptedLegacy];
|
1405
|
+
}, [commands, legacyCommands]);
|
1406
|
+
return {
|
1407
|
+
handleSlashCommand,
|
1408
|
+
slashCommands: allCommands,
|
1409
|
+
pendingHistoryItems,
|
1410
|
+
commandContext,
|
1411
|
+
};
|
1412
|
+
};
|
1413
|
+
//# sourceMappingURL=slashCommandProcessor.js.map
|