@google/gemini-cli 0.0.8999999 → 0.0.77777773
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/README.md +105 -62
- package/dist/package.json +13 -5
- package/dist/src/commands/extensions/examples/context/GEMINI.md +9 -3
- package/dist/src/commands/extensions/examples/context/gemini-extension.json +1 -2
- package/dist/src/commands/extensions/examples/mcp-server/gemini-extension.json +3 -2
- package/dist/src/commands/extensions/examples/mcp-server/package.json +18 -0
- package/dist/src/commands/extensions/examples/mcp-server/tsconfig.json +13 -0
- package/dist/src/commands/extensions/install.d.ts +2 -2
- package/dist/src/commands/extensions/install.js +35 -36
- package/dist/src/commands/extensions/install.js.map +1 -1
- package/dist/src/commands/extensions/install.test.js +25 -25
- package/dist/src/commands/extensions/install.test.js.map +1 -1
- package/dist/src/commands/extensions/link.js +2 -2
- package/dist/src/commands/extensions/link.js.map +1 -1
- package/dist/src/commands/extensions/list.js +1 -1
- package/dist/src/commands/extensions/list.js.map +1 -1
- package/dist/src/commands/extensions/new.js +28 -8
- package/dist/src/commands/extensions/new.js.map +1 -1
- package/dist/src/commands/extensions/new.test.js +14 -5
- package/dist/src/commands/extensions/new.test.js.map +1 -1
- package/dist/src/commands/extensions/uninstall.js +1 -1
- package/dist/src/commands/extensions/uninstall.js.map +1 -1
- package/dist/src/commands/extensions/uninstall.test.js +4 -1
- package/dist/src/commands/extensions/uninstall.test.js.map +1 -1
- package/dist/src/commands/extensions/update.js +35 -24
- package/dist/src/commands/extensions/update.js.map +1 -1
- package/dist/src/commands/mcp/add.js +6 -1
- package/dist/src/commands/mcp/add.js.map +1 -1
- package/dist/src/commands/mcp/list.js +5 -4
- package/dist/src/commands/mcp/list.js.map +1 -1
- package/dist/src/config/config.d.ts +7 -4
- package/dist/src/config/config.js +125 -39
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/extension.d.ts +44 -18
- package/dist/src/config/extension.js +250 -143
- package/dist/src/config/extension.js.map +1 -1
- package/dist/src/config/extensions/extensionEnablement.d.ts +12 -9
- package/dist/src/config/extensions/extensionEnablement.js +36 -9
- package/dist/src/config/extensions/extensionEnablement.js.map +1 -1
- package/dist/src/config/extensions/extensionEnablement.test.js +74 -1
- package/dist/src/config/extensions/extensionEnablement.test.js.map +1 -1
- package/dist/src/config/extensions/github.d.ts +14 -2
- package/dist/src/config/extensions/github.js +111 -89
- package/dist/src/config/extensions/github.js.map +1 -1
- package/dist/src/config/extensions/github.test.js +124 -13
- package/dist/src/config/extensions/github.test.js.map +1 -1
- package/dist/src/config/extensions/github_fetch.d.ts +7 -0
- package/dist/src/config/extensions/github_fetch.js +34 -0
- package/dist/src/config/extensions/github_fetch.js.map +1 -0
- package/dist/src/config/extensions/update.d.ts +4 -5
- package/dist/src/config/extensions/update.js +64 -42
- package/dist/src/config/extensions/update.js.map +1 -1
- package/dist/src/config/extensions/update.test.js +121 -71
- package/dist/src/config/extensions/update.test.js.map +1 -1
- package/dist/src/config/keyBindings.js +1 -1
- package/dist/src/config/keyBindings.js.map +1 -1
- package/dist/src/config/policy.js +2 -2
- package/dist/src/config/policy.js.map +1 -1
- package/dist/src/config/settings.d.ts +10 -1
- package/dist/src/config/settings.js +21 -6
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +97 -5
- package/dist/src/config/settingsSchema.js +96 -4
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/config/settingsSchema.test.js +8 -0
- package/dist/src/config/settingsSchema.test.js.map +1 -1
- package/dist/src/config/trustedFolders.d.ts +10 -2
- package/dist/src/config/trustedFolders.js +41 -16
- package/dist/src/config/trustedFolders.js.map +1 -1
- package/dist/src/config/trustedFolders.test.js +95 -14
- package/dist/src/config/trustedFolders.test.js.map +1 -1
- package/dist/src/gemini.js +114 -132
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/gemini.test.js +95 -14
- package/dist/src/gemini.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +7 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.test.js +87 -1
- package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -1
- package/dist/src/services/FileCommandLoader.d.ts +1 -1
- package/dist/src/services/FileCommandLoader.js +4 -4
- package/dist/src/services/FileCommandLoader.js.map +1 -1
- package/dist/src/services/prompt-processors/shellProcessor.js +1 -1
- package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -1
- package/dist/src/test-utils/render.d.ts +12 -1
- package/dist/src/test-utils/render.js +56 -1
- package/dist/src/test-utils/render.js.map +1 -1
- package/dist/src/ui/App.js +7 -9
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/AppContainer.js +99 -27
- package/dist/src/ui/AppContainer.js.map +1 -1
- package/dist/src/ui/AppContainer.test.js +300 -7
- package/dist/src/ui/AppContainer.test.js.map +1 -1
- package/dist/src/ui/IdeIntegrationNudge.js +3 -0
- package/dist/src/ui/IdeIntegrationNudge.js.map +1 -1
- package/dist/src/ui/auth/AuthDialog.js +8 -1
- package/dist/src/ui/auth/AuthDialog.js.map +1 -1
- package/dist/src/ui/auth/AuthDialog.test.js +1 -0
- package/dist/src/ui/auth/AuthDialog.test.js.map +1 -1
- package/dist/src/ui/auth/AuthInProgress.js +2 -2
- package/dist/src/ui/auth/AuthInProgress.js.map +1 -1
- package/dist/src/ui/commands/chatCommand.js +21 -27
- package/dist/src/ui/commands/chatCommand.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.js +39 -34
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.js +78 -260
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.js +23 -5
- package/dist/src/ui/commands/memoryCommand.js.map +1 -1
- package/dist/src/ui/commands/modelCommand.d.ts +7 -0
- package/dist/src/ui/commands/modelCommand.js +16 -0
- package/dist/src/ui/commands/modelCommand.js.map +1 -0
- package/dist/src/ui/commands/modelCommand.test.js +30 -0
- package/dist/src/ui/commands/modelCommand.test.js.map +1 -0
- package/dist/src/ui/commands/permissionsCommand.d.ts +7 -0
- package/dist/src/ui/commands/permissionsCommand.js +16 -0
- package/dist/src/ui/commands/permissionsCommand.js.map +1 -0
- package/dist/src/ui/commands/permissionsCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/permissionsCommand.test.js +30 -0
- package/dist/src/ui/commands/permissionsCommand.test.js.map +1 -0
- package/dist/src/ui/commands/profileCommand.d.ts +7 -0
- package/dist/src/ui/commands/profileCommand.js +23 -0
- package/dist/src/ui/commands/profileCommand.js.map +1 -0
- package/dist/src/ui/commands/setupGithubCommand.test.js +2 -1
- package/dist/src/ui/commands/setupGithubCommand.test.js.map +1 -1
- package/dist/src/ui/commands/toolsCommand.js +10 -24
- package/dist/src/ui/commands/toolsCommand.js.map +1 -1
- package/dist/src/ui/commands/types.d.ts +8 -6
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/components/AnsiOutput.d.ts +1 -0
- package/dist/src/ui/components/AnsiOutput.js +5 -5
- package/dist/src/ui/components/AnsiOutput.js.map +1 -1
- package/dist/src/ui/components/AnsiOutput.test.js +6 -6
- package/dist/src/ui/components/AnsiOutput.test.js.map +1 -1
- package/dist/src/ui/components/AppHeader.js +2 -5
- package/dist/src/ui/components/AppHeader.js.map +1 -1
- package/dist/src/ui/components/CliSpinner.d.ts +10 -0
- package/dist/src/ui/components/CliSpinner.js +20 -0
- package/dist/src/ui/components/CliSpinner.js.map +1 -0
- package/dist/src/ui/components/Composer.js +7 -29
- package/dist/src/ui/components/Composer.js.map +1 -1
- package/dist/src/ui/components/ConsentPrompt.d.ts +13 -0
- package/dist/src/ui/components/ConsentPrompt.js +19 -0
- package/dist/src/ui/components/ConsentPrompt.js.map +1 -0
- package/dist/src/ui/components/ConsentPrompt.test.d.ts +6 -0
- package/dist/src/ui/components/ConsentPrompt.test.js +67 -0
- package/dist/src/ui/components/ConsentPrompt.test.js.map +1 -0
- package/dist/src/ui/components/ContextSummaryDisplay.js +2 -2
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/ContextUsageDisplay.d.ts +2 -1
- package/dist/src/ui/components/ContextUsageDisplay.js +4 -2
- package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -1
- package/dist/src/ui/components/DebugProfiler.d.ts +18 -0
- package/dist/src/ui/components/DebugProfiler.js +158 -12
- package/dist/src/ui/components/DebugProfiler.js.map +1 -1
- package/dist/src/ui/components/DebugProfiler.test.d.ts +6 -0
- package/dist/src/ui/components/DebugProfiler.test.js +140 -0
- package/dist/src/ui/components/DebugProfiler.test.js.map +1 -0
- package/dist/src/ui/components/DialogManager.d.ts +7 -1
- package/dist/src/ui/components/DialogManager.js +18 -9
- package/dist/src/ui/components/DialogManager.js.map +1 -1
- package/dist/src/ui/components/EditorSettingsDialog.js +11 -2
- package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -1
- package/dist/src/ui/components/ExitWarning.d.ts +7 -0
- package/dist/src/ui/components/ExitWarning.js +9 -0
- package/dist/src/ui/components/ExitWarning.js.map +1 -0
- package/dist/src/ui/components/FolderTrustDialog.js +3 -0
- package/dist/src/ui/components/FolderTrustDialog.js.map +1 -1
- package/dist/src/ui/components/FolderTrustDialog.test.js +2 -2
- package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -1
- package/dist/src/ui/components/Footer.d.ts +1 -19
- package/dist/src/ui/components/Footer.js +35 -17
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/GeminiRespondingSpinner.js +2 -2
- package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -1
- package/dist/src/ui/components/Help.js +1 -1
- package/dist/src/ui/components/Help.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.d.ts +2 -1
- package/dist/src/ui/components/HistoryItemDisplay.js +10 -1
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.test.js +90 -9
- package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -1
- package/dist/src/ui/components/IdeTrustChangeDialog.d.ts +11 -0
- package/dist/src/ui/components/IdeTrustChangeDialog.js +32 -0
- package/dist/src/ui/components/IdeTrustChangeDialog.js.map +1 -0
- package/dist/src/ui/components/IdeTrustChangeDialog.test.d.ts +6 -0
- package/dist/src/ui/components/IdeTrustChangeDialog.test.js +57 -0
- package/dist/src/ui/components/IdeTrustChangeDialog.test.js.map +1 -0
- package/dist/src/ui/components/InputPrompt.d.ts +8 -2
- package/dist/src/ui/components/InputPrompt.js +66 -32
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.js +1 -1
- package/dist/src/ui/components/LoadingIndicator.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.test.js +4 -0
- package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -1
- package/dist/src/ui/components/LoopDetectionConfirmation.js +2 -0
- package/dist/src/ui/components/LoopDetectionConfirmation.js.map +1 -1
- package/dist/src/ui/components/MainContent.js +7 -2
- package/dist/src/ui/components/MainContent.js.map +1 -1
- package/dist/src/ui/components/ModelDialog.d.ts +11 -0
- package/dist/src/ui/components/ModelDialog.js +57 -0
- package/dist/src/ui/components/ModelDialog.js.map +1 -0
- package/dist/src/ui/components/ModelDialog.test.d.ts +6 -0
- package/dist/src/ui/components/ModelDialog.test.js +153 -0
- package/dist/src/ui/components/ModelDialog.test.js.map +1 -0
- package/dist/src/ui/components/Notifications.js +12 -4
- package/dist/src/ui/components/Notifications.js.map +1 -1
- package/dist/src/ui/components/PermissionsModifyTrustDialog.d.ts +13 -0
- package/dist/src/ui/components/PermissionsModifyTrustDialog.js +48 -0
- package/dist/src/ui/components/PermissionsModifyTrustDialog.js.map +1 -0
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.d.ts +6 -0
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js +154 -0
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js.map +1 -0
- package/dist/src/ui/components/ProQuotaDialog.js +2 -0
- package/dist/src/ui/components/ProQuotaDialog.js.map +1 -1
- package/dist/src/ui/components/ProQuotaDialog.test.js +2 -0
- package/dist/src/ui/components/ProQuotaDialog.test.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.js +6 -3
- package/dist/src/ui/components/SettingsDialog.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.test.js +47 -13
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.js +3 -0
- package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.js +2 -0
- package/dist/src/ui/components/ThemeDialog.js.map +1 -1
- package/dist/src/ui/components/WorkspaceMigrationDialog.d.ts +2 -2
- package/dist/src/ui/components/WorkspaceMigrationDialog.js +7 -5
- package/dist/src/ui/components/WorkspaceMigrationDialog.js.map +1 -1
- package/dist/src/ui/components/messages/CompressionMessage.js +2 -2
- package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +15 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.js +5 -5
- package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolMessage.d.ts +1 -1
- package/dist/src/ui/components/messages/ToolMessage.js +28 -5
- package/dist/src/ui/components/messages/ToolMessage.js.map +1 -1
- package/dist/src/ui/components/messages/UserMessage.js +1 -2
- package/dist/src/ui/components/messages/UserMessage.js.map +1 -1
- package/dist/src/ui/components/shared/BaseSelectionList.d.ts +38 -0
- package/dist/src/ui/components/shared/BaseSelectionList.js +72 -0
- package/dist/src/ui/components/shared/BaseSelectionList.js.map +1 -0
- package/dist/src/ui/components/shared/BaseSelectionList.test.d.ts +6 -0
- package/dist/src/ui/components/shared/BaseSelectionList.test.js +376 -0
- package/dist/src/ui/components/shared/BaseSelectionList.test.js.map +1 -0
- package/dist/src/ui/components/shared/DescriptiveRadioButtonSelect.d.ts +35 -0
- package/dist/src/ui/components/shared/DescriptiveRadioButtonSelect.js +13 -0
- package/dist/src/ui/components/shared/DescriptiveRadioButtonSelect.js.map +1 -0
- package/dist/src/ui/components/shared/DescriptiveRadioButtonSelect.test.d.ts +6 -0
- package/dist/src/ui/components/shared/DescriptiveRadioButtonSelect.test.js +79 -0
- package/dist/src/ui/components/shared/DescriptiveRadioButtonSelect.test.js.map +1 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +2 -3
- package/dist/src/ui/components/shared/RadioButtonSelect.js +9 -104
- package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -1
- package/dist/src/ui/components/shared/RadioButtonSelect.test.js +115 -92
- package/dist/src/ui/components/shared/RadioButtonSelect.test.js.map +1 -1
- package/dist/src/ui/components/shared/ScopeSelector.js +4 -1
- package/dist/src/ui/components/shared/ScopeSelector.js.map +1 -1
- package/dist/src/ui/components/views/ChatList.d.ts +12 -0
- package/dist/src/ui/components/views/ChatList.js +17 -0
- package/dist/src/ui/components/views/ChatList.js.map +1 -0
- package/dist/src/ui/components/views/ChatList.test.d.ts +6 -0
- package/dist/src/ui/components/views/ChatList.test.js +42 -0
- package/dist/src/ui/components/views/ChatList.test.js.map +1 -0
- package/dist/src/ui/components/views/ExtensionsList.test.js +1 -1
- package/dist/src/ui/components/views/ExtensionsList.test.js.map +1 -1
- package/dist/src/ui/components/views/McpStatus.d.ts +27 -0
- package/dist/src/ui/components/views/McpStatus.js +77 -0
- package/dist/src/ui/components/views/McpStatus.js.map +1 -0
- package/dist/src/ui/components/views/McpStatus.test.d.ts +6 -0
- package/dist/src/ui/components/views/McpStatus.test.js +117 -0
- package/dist/src/ui/components/views/McpStatus.test.js.map +1 -0
- package/dist/src/ui/components/views/ToolsList.d.ts +14 -0
- package/dist/src/ui/components/views/ToolsList.js +7 -0
- package/dist/src/ui/components/views/ToolsList.js.map +1 -0
- package/dist/src/ui/components/views/ToolsList.test.d.ts +6 -0
- package/dist/src/ui/components/views/ToolsList.test.js +45 -0
- package/dist/src/ui/components/views/ToolsList.test.js.map +1 -0
- package/dist/src/ui/contexts/KeypressContext.js +3 -0
- package/dist/src/ui/contexts/KeypressContext.js.map +1 -1
- package/dist/src/ui/contexts/ShellFocusContext.d.ts +7 -0
- package/dist/src/ui/contexts/ShellFocusContext.js +9 -0
- package/dist/src/ui/contexts/ShellFocusContext.js.map +1 -0
- package/dist/src/ui/contexts/UIActionsContext.d.ts +2 -0
- package/dist/src/ui/contexts/UIActionsContext.js.map +1 -1
- package/dist/src/ui/contexts/UIStateContext.d.ts +11 -2
- package/dist/src/ui/contexts/UIStateContext.js +2 -0
- package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.js +5 -6
- package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.test.js +19 -32
- package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +8 -5
- package/dist/src/ui/hooks/slashCommandProcessor.js +11 -2
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.d.ts +10 -1
- package/dist/src/ui/hooks/useExtensionUpdates.js +140 -38
- package/dist/src/ui/hooks/useExtensionUpdates.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.test.js +163 -84
- package/dist/src/ui/hooks/useExtensionUpdates.test.js.map +1 -1
- package/dist/src/ui/hooks/useFlickerDetector.d.ts +14 -0
- package/dist/src/ui/hooks/useFlickerDetector.js +37 -0
- package/dist/src/ui/hooks/useFlickerDetector.js.map +1 -0
- package/dist/src/ui/hooks/useFlickerDetector.test.d.ts +6 -0
- package/dist/src/ui/hooks/useFlickerDetector.test.js +102 -0
- package/dist/src/ui/hooks/useFlickerDetector.test.js.map +1 -0
- package/dist/src/ui/hooks/useFocus.js +10 -0
- package/dist/src/ui/hooks/useFocus.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.d.ts +2 -1
- package/dist/src/ui/hooks/useFolderTrust.js +13 -9
- package/dist/src/ui/hooks/useFolderTrust.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +38 -3
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -1
- package/dist/src/ui/hooks/useHistoryManager.js +3 -3
- package/dist/src/ui/hooks/useHistoryManager.js.map +1 -1
- package/dist/src/ui/hooks/useIdeTrustListener.d.ts +4 -2
- package/dist/src/ui/hooks/useIdeTrustListener.js +40 -14
- package/dist/src/ui/hooks/useIdeTrustListener.js.map +1 -1
- package/dist/src/ui/hooks/useIdeTrustListener.test.d.ts +6 -0
- package/dist/src/ui/hooks/useIdeTrustListener.test.js +183 -0
- package/dist/src/ui/hooks/useIdeTrustListener.test.js.map +1 -0
- package/dist/src/ui/hooks/useModelCommand.d.ts +12 -0
- package/dist/src/ui/hooks/useModelCommand.js +21 -0
- package/dist/src/ui/hooks/useModelCommand.js.map +1 -0
- package/dist/src/ui/hooks/useModelCommand.test.d.ts +6 -0
- package/dist/src/ui/hooks/useModelCommand.test.js +35 -0
- package/dist/src/ui/hooks/useModelCommand.test.js.map +1 -0
- package/dist/src/ui/hooks/usePermissionsModifyTrust.d.ts +17 -0
- package/dist/src/ui/hooks/usePermissionsModifyTrust.js +78 -0
- package/dist/src/ui/hooks/usePermissionsModifyTrust.js.map +1 -0
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.d.ts +6 -0
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js +182 -0
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js.map +1 -0
- package/dist/src/ui/hooks/usePhraseCycler.js +1 -0
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.js +3 -17
- package/dist/src/ui/hooks/useQuotaAndFallback.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js +13 -43
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js.map +1 -1
- package/dist/src/ui/hooks/useSelectionList.d.ts +34 -0
- package/dist/src/ui/hooks/useSelectionList.js +272 -0
- package/dist/src/ui/hooks/useSelectionList.js.map +1 -0
- package/dist/src/ui/hooks/useSelectionList.test.d.ts +6 -0
- package/dist/src/ui/hooks/useSelectionList.test.js +725 -0
- package/dist/src/ui/hooks/useSelectionList.test.js.map +1 -0
- package/dist/src/ui/hooks/useShellHistory.test.js +12 -8
- package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.js +7 -2
- package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.test.js +33 -0
- package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useTerminalSize.js +2 -3
- package/dist/src/ui/hooks/useTerminalSize.js.map +1 -1
- package/dist/src/ui/hooks/useToolScheduler.test.js +2 -2
- package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -1
- package/dist/src/ui/hooks/useWorkspaceMigration.d.ts +2 -2
- package/dist/src/ui/hooks/useWorkspaceMigration.js +13 -8
- package/dist/src/ui/hooks/useWorkspaceMigration.js.map +1 -1
- package/dist/src/ui/layouts/DefaultAppLayout.d.ts +7 -0
- package/dist/src/ui/layouts/DefaultAppLayout.js +16 -0
- package/dist/src/ui/layouts/DefaultAppLayout.js.map +1 -0
- package/dist/src/ui/layouts/ScreenReaderAppLayout.d.ts +7 -0
- package/dist/src/ui/layouts/ScreenReaderAppLayout.js +17 -0
- package/dist/src/ui/layouts/ScreenReaderAppLayout.js.map +1 -0
- package/dist/src/ui/noninteractive/nonInteractiveUi.js +3 -1
- package/dist/src/ui/noninteractive/nonInteractiveUi.js.map +1 -1
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +5 -5
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -1
- package/dist/src/ui/state/extensions.d.ts +47 -1
- package/dist/src/ui/state/extensions.js +68 -1
- package/dist/src/ui/state/extensions.js.map +1 -1
- package/dist/src/ui/themes/theme.js +2 -2
- package/dist/src/ui/themes/theme.js.map +1 -1
- package/dist/src/ui/types.d.ts +54 -3
- package/dist/src/ui/types.js +3 -0
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/MarkdownDisplay.js +1 -2
- package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -1
- package/dist/src/ui/utils/MarkdownDisplay.test.js +94 -91
- package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -1
- package/dist/src/ui/utils/displayUtils.d.ts +1 -0
- package/dist/src/ui/utils/displayUtils.js +4 -1
- package/dist/src/ui/utils/displayUtils.js.map +1 -1
- package/dist/src/ui/utils/displayUtils.test.js +36 -17
- package/dist/src/ui/utils/displayUtils.test.js.map +1 -1
- package/dist/src/ui/utils/textUtils.d.ts +1 -0
- package/dist/src/ui/utils/textUtils.js +56 -0
- package/dist/src/ui/utils/textUtils.js.map +1 -1
- package/dist/src/ui/utils/textUtils.test.d.ts +6 -0
- package/dist/src/ui/utils/textUtils.test.js +132 -0
- package/dist/src/ui/utils/textUtils.test.js.map +1 -0
- package/dist/src/ui/utils/ui-sizing.d.ts +7 -0
- package/dist/src/ui/utils/ui-sizing.js +23 -0
- package/dist/src/ui/utils/ui-sizing.js.map +1 -0
- package/dist/src/utils/commentJson.js +95 -13
- package/dist/src/utils/commentJson.js.map +1 -1
- package/dist/src/utils/commentJson.test.js +161 -0
- package/dist/src/utils/commentJson.test.js.map +1 -1
- package/dist/src/utils/deepMerge.d.ts +2 -3
- package/dist/src/utils/errors.d.ts +8 -3
- package/dist/src/utils/errors.js +23 -13
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/errors.test.js +40 -46
- package/dist/src/utils/errors.test.js.map +1 -1
- package/dist/src/utils/events.d.ts +2 -1
- package/dist/src/utils/events.js +1 -0
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/handleAutoUpdate.js +4 -1
- package/dist/src/utils/handleAutoUpdate.js.map +1 -1
- package/dist/src/utils/installationInfo.d.ts +1 -0
- package/dist/src/utils/installationInfo.js +2 -0
- package/dist/src/utils/installationInfo.js.map +1 -1
- package/dist/src/utils/math.d.ts +13 -0
- package/dist/src/utils/math.js +14 -0
- package/dist/src/utils/math.js.map +1 -0
- package/dist/src/utils/relaunch.d.ts +7 -0
- package/dist/src/utils/relaunch.js +57 -0
- package/dist/src/utils/relaunch.js.map +1 -0
- package/dist/src/utils/relaunch.test.d.ts +6 -0
- package/dist/src/utils/relaunch.test.js +273 -0
- package/dist/src/utils/relaunch.test.js.map +1 -0
- package/dist/src/utils/sandbox.js +31 -17
- package/dist/src/utils/sandbox.js.map +1 -1
- package/dist/src/utils/sessionCleanup.d.ts +22 -0
- package/dist/src/utils/sessionCleanup.integration.test.d.ts +6 -0
- package/dist/src/utils/sessionCleanup.integration.test.js +182 -0
- package/dist/src/utils/sessionCleanup.integration.test.js.map +1 -0
- package/dist/src/utils/sessionCleanup.js +214 -0
- package/dist/src/utils/sessionCleanup.js.map +1 -0
- package/dist/src/utils/sessionCleanup.test.d.ts +6 -0
- package/dist/src/utils/sessionCleanup.test.js +1232 -0
- package/dist/src/utils/sessionCleanup.test.js.map +1 -0
- package/dist/src/utils/sessionUtils.d.ts +37 -0
- package/dist/src/utils/sessionUtils.js +71 -0
- package/dist/src/utils/sessionUtils.js.map +1 -0
- package/dist/src/utils/windowTitle.d.ts +12 -0
- package/dist/src/utils/windowTitle.js +19 -0
- package/dist/src/utils/windowTitle.js.map +1 -0
- package/dist/src/utils/windowTitle.test.d.ts +6 -0
- package/dist/src/utils/windowTitle.test.js +49 -0
- package/dist/src/utils/windowTitle.test.js.map +1 -0
- package/dist/src/validateNonInterActiveAuth.js +6 -7
- package/dist/src/validateNonInterActiveAuth.js.map +1 -1
- package/dist/src/zed-integration/acp.js +1 -2
- package/dist/src/zed-integration/acp.js.map +1 -1
- package/dist/src/zed-integration/fileSystemService.d.ts +1 -0
- package/dist/src/zed-integration/fileSystemService.js +3 -0
- package/dist/src/zed-integration/fileSystemService.js.map +1 -1
- package/dist/src/zed-integration/schema.d.ts +70 -70
- package/dist/src/zed-integration/zedIntegration.d.ts +9 -3
- package/dist/src/zed-integration/zedIntegration.js +23 -28
- package/dist/src/zed-integration/zedIntegration.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -5
- package/dist/src/commands/extensions/examples/mcp-server/example.js +0 -46
- package/dist/src/commands/extensions/examples/mcp-server/example.js.map +0 -1
- package/dist/src/ui/contexts/FocusContext.d.ts +0 -7
- package/dist/src/ui/contexts/FocusContext.js +0 -9
- package/dist/src/ui/contexts/FocusContext.js.map +0 -1
- /package/dist/src/{commands/extensions/examples/mcp-server/example.d.ts → ui/commands/modelCommand.test.d.ts} +0 -0
|
@@ -4,121 +4,123 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
* Copyright 2025 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
6
|
*/
|
|
7
|
-
import { render } from 'ink-testing-library';
|
|
8
7
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
9
8
|
import { MarkdownDisplay } from './MarkdownDisplay.js';
|
|
10
9
|
import { LoadedSettings } from '../../config/settings.js';
|
|
11
|
-
import {
|
|
12
|
-
import { EOL } from 'node:os';
|
|
10
|
+
import { renderWithProviders } from '../../test-utils/render.js';
|
|
13
11
|
describe('<MarkdownDisplay />', () => {
|
|
14
12
|
const baseProps = {
|
|
15
13
|
isPending: false,
|
|
16
14
|
terminalWidth: 80,
|
|
17
15
|
availableTerminalHeight: 40,
|
|
18
16
|
};
|
|
19
|
-
const mockSettings = new LoadedSettings({ path: '', settings: {}, originalSettings: {} }, { path: '', settings: {}, originalSettings: {} }, { path: '', settings: {}, originalSettings: {} }, { path: '', settings: {}, originalSettings: {} }, true, new Set());
|
|
20
17
|
beforeEach(() => {
|
|
21
18
|
vi.clearAllMocks();
|
|
22
19
|
});
|
|
23
20
|
it('renders nothing for empty text', () => {
|
|
24
|
-
const { lastFrame } =
|
|
21
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: "" }));
|
|
25
22
|
expect(lastFrame()).toMatchSnapshot();
|
|
26
23
|
});
|
|
27
24
|
it('renders a simple paragraph', () => {
|
|
28
25
|
const text = 'Hello, world.';
|
|
29
|
-
const { lastFrame } =
|
|
26
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
30
27
|
expect(lastFrame()).toMatchSnapshot();
|
|
31
28
|
});
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const lineEndings = [
|
|
30
|
+
{ name: 'Windows', eol: '\r\n' },
|
|
31
|
+
{ name: 'Unix', eol: '\n' },
|
|
32
|
+
];
|
|
33
|
+
describe.each(lineEndings)('with $name line endings', ({ eol }) => {
|
|
34
|
+
it('renders headers with correct levels', () => {
|
|
35
|
+
const text = `
|
|
34
36
|
# Header 1
|
|
35
37
|
## Header 2
|
|
36
38
|
### Header 3
|
|
37
39
|
#### Header 4
|
|
38
|
-
`.replace(/\n/g,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
`.replace(/\n/g, eol);
|
|
41
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
42
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
it('renders a fenced code block with a language', () => {
|
|
45
|
+
const text = '```javascript\nconst x = 1;\nconsole.log(x);\n```'.replace(/\n/g, eol);
|
|
46
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
47
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
it('renders a fenced code block without a language', () => {
|
|
50
|
+
const text = '```\nplain text\n```'.replace(/\n/g, eol);
|
|
51
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
52
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
it('handles unclosed (pending) code blocks', () => {
|
|
55
|
+
const text = '```typescript\nlet y = 2;'.replace(/\n/g, eol);
|
|
56
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text, isPending: true }));
|
|
57
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
58
|
+
});
|
|
59
|
+
it('renders unordered lists with different markers', () => {
|
|
60
|
+
const text = `
|
|
59
61
|
- item A
|
|
60
62
|
* item B
|
|
61
63
|
+ item C
|
|
62
|
-
`.replace(/\n/g,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
`.replace(/\n/g, eol);
|
|
65
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
66
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
67
|
+
});
|
|
68
|
+
it('renders nested unordered lists', () => {
|
|
69
|
+
const text = `
|
|
68
70
|
* Level 1
|
|
69
71
|
* Level 2
|
|
70
72
|
* Level 3
|
|
71
|
-
`.replace(/\n/g,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
`.replace(/\n/g, eol);
|
|
74
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
75
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
76
|
+
});
|
|
77
|
+
it('renders ordered lists', () => {
|
|
78
|
+
const text = `
|
|
77
79
|
1. First item
|
|
78
80
|
2. Second item
|
|
79
|
-
`.replace(/\n/g,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
`.replace(/\n/g, eol);
|
|
82
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
83
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
84
|
+
});
|
|
85
|
+
it('renders horizontal rules', () => {
|
|
86
|
+
const text = `
|
|
85
87
|
Hello
|
|
86
88
|
---
|
|
87
89
|
World
|
|
88
90
|
***
|
|
89
91
|
Test
|
|
90
|
-
`.replace(/\n/g,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
`.replace(/\n/g, eol);
|
|
93
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
94
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
95
|
+
});
|
|
96
|
+
it('renders tables correctly', () => {
|
|
97
|
+
const text = `
|
|
96
98
|
| Header 1 | Header 2 |
|
|
97
99
|
|----------|:--------:|
|
|
98
100
|
| Cell 1 | Cell 2 |
|
|
99
101
|
| Cell 3 | Cell 4 |
|
|
100
|
-
`.replace(/\n/g,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
`.replace(/\n/g, eol);
|
|
103
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
104
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
105
|
+
});
|
|
106
|
+
it('handles a table at the end of the input', () => {
|
|
107
|
+
const text = `
|
|
106
108
|
Some text before.
|
|
107
109
|
| A | B |
|
|
108
110
|
|---|
|
|
109
|
-
| 1 | 2 |`.replace(/\n/g,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
| 1 | 2 |`.replace(/\n/g, eol);
|
|
112
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
113
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
114
|
+
});
|
|
115
|
+
it('inserts a single space between paragraphs', () => {
|
|
116
|
+
const text = `Paragraph 1.
|
|
115
117
|
|
|
116
|
-
Paragraph 2.`.replace(/\n/g,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
Paragraph 2.`.replace(/\n/g, eol);
|
|
119
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
120
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
121
|
+
});
|
|
122
|
+
it('correctly parses a mix of markdown elements', () => {
|
|
123
|
+
const text = `
|
|
122
124
|
# Main Title
|
|
123
125
|
|
|
124
126
|
Here is a paragraph.
|
|
@@ -131,26 +133,27 @@ some code
|
|
|
131
133
|
\`\`\`
|
|
132
134
|
|
|
133
135
|
Another paragraph.
|
|
134
|
-
`.replace(/\n/g,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
136
|
+
`.replace(/\n/g, eol);
|
|
137
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
138
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
139
|
+
});
|
|
140
|
+
it('hides line numbers in code blocks when showLineNumbers is false', () => {
|
|
141
|
+
const text = '```javascript\nconst x = 1;\n```'.replace(/\n/g, eol);
|
|
142
|
+
const settings = new LoadedSettings({ path: '', settings: {}, originalSettings: {} }, { path: '', settings: {}, originalSettings: {} }, {
|
|
143
|
+
path: '',
|
|
144
|
+
settings: { ui: { showLineNumbers: false } },
|
|
145
|
+
originalSettings: { ui: { showLineNumbers: false } },
|
|
146
|
+
}, { path: '', settings: {}, originalSettings: {} }, true, new Set());
|
|
147
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }), { settings });
|
|
148
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
149
|
+
expect(lastFrame()).not.toContain(' 1 ');
|
|
150
|
+
});
|
|
151
|
+
it('shows line numbers in code blocks by default', () => {
|
|
152
|
+
const text = '```javascript\nconst x = 1;\n```'.replace(/\n/g, eol);
|
|
153
|
+
const { lastFrame } = renderWithProviders(_jsx(MarkdownDisplay, { ...baseProps, text: text }));
|
|
154
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
155
|
+
expect(lastFrame()).toContain(' 1 ');
|
|
156
|
+
});
|
|
154
157
|
});
|
|
155
158
|
});
|
|
156
159
|
//# sourceMappingURL=MarkdownDisplay.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownDisplay.test.js","sourceRoot":"","sources":["../../../../src/ui/utils/MarkdownDisplay.test.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"MarkdownDisplay.test.js","sourceRoot":"","sources":["../../../../src/ui/utils/MarkdownDisplay.test.tsx"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AC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;YACtD,MAAM,IAAI,GAAG,kCAAkC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACpE,MAAM,EAAE,SAAS,EAAE,GAAG,mBAAmB,CACvC,KAAC,eAAe,OAAK,SAAS,EAAE,IAAI,EAAE,IAAI,GAAI,CAC/C,CAAC;YACF,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;YACtC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -19,6 +19,9 @@ export const getStatusColor = (value, thresholds, options = {}) => {
|
|
|
19
19
|
if (value >= thresholds.yellow) {
|
|
20
20
|
return theme.status.warning;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
if (thresholds.red != null && value >= thresholds.red) {
|
|
23
|
+
return theme.status.error;
|
|
24
|
+
}
|
|
25
|
+
return options.defaultColor ?? theme.status.error;
|
|
23
26
|
};
|
|
24
27
|
//# sourceMappingURL=displayUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"displayUtils.js","sourceRoot":"","sources":["../../../../src/ui/utils/displayUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,qBAAqB;AACrB,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAA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,CAAC"}
|
|
@@ -8,24 +8,43 @@ import { getStatusColor, TOOL_SUCCESS_RATE_HIGH, TOOL_SUCCESS_RATE_MEDIUM, USER_
|
|
|
8
8
|
import { Colors } from '../colors.js';
|
|
9
9
|
describe('displayUtils', () => {
|
|
10
10
|
describe('getStatusColor', () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
describe('with red threshold', () => {
|
|
12
|
+
const thresholds = {
|
|
13
|
+
green: 80,
|
|
14
|
+
yellow: 50,
|
|
15
|
+
red: 20,
|
|
16
|
+
};
|
|
17
|
+
it('should return green for values >= green threshold', () => {
|
|
18
|
+
expect(getStatusColor(90, thresholds)).toBe(Colors.AccentGreen);
|
|
19
|
+
expect(getStatusColor(80, thresholds)).toBe(Colors.AccentGreen);
|
|
20
|
+
});
|
|
21
|
+
it('should return yellow for values < green and >= yellow threshold', () => {
|
|
22
|
+
expect(getStatusColor(79, thresholds)).toBe(Colors.AccentYellow);
|
|
23
|
+
expect(getStatusColor(50, thresholds)).toBe(Colors.AccentYellow);
|
|
24
|
+
});
|
|
25
|
+
it('should return red for values < yellow and >= red threshold', () => {
|
|
26
|
+
expect(getStatusColor(49, thresholds)).toBe(Colors.AccentRed);
|
|
27
|
+
expect(getStatusColor(20, thresholds)).toBe(Colors.AccentRed);
|
|
28
|
+
});
|
|
29
|
+
it('should return error for values < red threshold', () => {
|
|
30
|
+
expect(getStatusColor(19, thresholds)).toBe(Colors.AccentRed);
|
|
31
|
+
expect(getStatusColor(0, thresholds)).toBe(Colors.AccentRed);
|
|
32
|
+
});
|
|
33
|
+
it('should return defaultColor for values < red threshold when provided', () => {
|
|
34
|
+
expect(getStatusColor(19, thresholds, { defaultColor: Colors.Foreground })).toBe(Colors.Foreground);
|
|
35
|
+
});
|
|
18
36
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
describe('when red threshold is not provided', () => {
|
|
38
|
+
const thresholds = {
|
|
39
|
+
green: 80,
|
|
40
|
+
yellow: 50,
|
|
41
|
+
};
|
|
42
|
+
it('should return error color for values < yellow threshold', () => {
|
|
43
|
+
expect(getStatusColor(49, thresholds)).toBe(Colors.AccentRed);
|
|
44
|
+
});
|
|
45
|
+
it('should return defaultColor for values < yellow threshold when provided', () => {
|
|
46
|
+
expect(getStatusColor(49, thresholds, { defaultColor: Colors.Foreground })).toBe(Colors.Foreground);
|
|
47
|
+
});
|
|
29
48
|
});
|
|
30
49
|
});
|
|
31
50
|
describe('Threshold Constants', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"displayUtils.test.js","sourceRoot":"","sources":["../../../../src/ui/utils/displayUtils.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,MAAM,UAAU,GAAG;
|
|
1
|
+
{"version":3,"file":"displayUtils.test.js","sourceRoot":"","sources":["../../../../src/ui/utils/displayUtils.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,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AI,CAAC,EAAE,CAAC,CAAC;YACxC,MAAM,CAAC,wBAAwB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1C,MAAM,CAAC,wBAAwB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1C,MAAM,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5C,MAAM,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACvC,MAAM,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import stripAnsi from 'strip-ansi';
|
|
7
|
+
import ansiRegex from 'ansi-regex';
|
|
7
8
|
import { stripVTControlCharacters } from 'node:util';
|
|
8
9
|
import stringWidth from 'string-width';
|
|
9
10
|
/**
|
|
@@ -126,4 +127,59 @@ export const getCachedStringWidth = (str) => {
|
|
|
126
127
|
export const clearStringWidthCache = () => {
|
|
127
128
|
stringWidthCache.clear();
|
|
128
129
|
};
|
|
130
|
+
const regex = ansiRegex();
|
|
131
|
+
/* Recursively traverses a JSON-like structure (objects, arrays, primitives)
|
|
132
|
+
* and escapes all ANSI control characters found in any string values.
|
|
133
|
+
*
|
|
134
|
+
* This function is designed to be robust, handling deeply nested objects and
|
|
135
|
+
* arrays. It applies a regex-based replacement to all string values to
|
|
136
|
+
* safely escape control characters.
|
|
137
|
+
*
|
|
138
|
+
* To optimize performance, this function uses a "copy-on-write" strategy.
|
|
139
|
+
* It avoids allocating new objects or arrays if no nested string values
|
|
140
|
+
* required escaping, returning the original object reference in such cases.
|
|
141
|
+
*
|
|
142
|
+
* @param obj The JSON-like value (object, array, string, etc.) to traverse.
|
|
143
|
+
* @returns A new value with all nested string fields escaped, or the
|
|
144
|
+
* original `obj` reference if no changes were necessary.
|
|
145
|
+
*/
|
|
146
|
+
export function escapeAnsiCtrlCodes(obj) {
|
|
147
|
+
if (typeof obj === 'string') {
|
|
148
|
+
if (obj.search(regex) === -1) {
|
|
149
|
+
return obj; // No changes return original string
|
|
150
|
+
}
|
|
151
|
+
regex.lastIndex = 0; // needed for global regex
|
|
152
|
+
return obj.replace(regex, (match) => JSON.stringify(match).slice(1, -1));
|
|
153
|
+
}
|
|
154
|
+
if (obj === null || typeof obj !== 'object') {
|
|
155
|
+
return obj;
|
|
156
|
+
}
|
|
157
|
+
if (Array.isArray(obj)) {
|
|
158
|
+
let newArr = null;
|
|
159
|
+
for (let i = 0; i < obj.length; i++) {
|
|
160
|
+
const value = obj[i];
|
|
161
|
+
const escapedValue = escapeAnsiCtrlCodes(value);
|
|
162
|
+
if (escapedValue !== value) {
|
|
163
|
+
if (newArr === null) {
|
|
164
|
+
newArr = [...obj];
|
|
165
|
+
}
|
|
166
|
+
newArr[i] = escapedValue;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return (newArr !== null ? newArr : obj);
|
|
170
|
+
}
|
|
171
|
+
let newObj = null;
|
|
172
|
+
const keys = Object.keys(obj);
|
|
173
|
+
for (const key of keys) {
|
|
174
|
+
const value = obj[key];
|
|
175
|
+
const escapedValue = escapeAnsiCtrlCodes(value);
|
|
176
|
+
if (escapedValue !== value) {
|
|
177
|
+
if (newObj === null) {
|
|
178
|
+
newObj = { ...obj };
|
|
179
|
+
}
|
|
180
|
+
newObj[key] = escapedValue;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return newObj !== null ? newObj : obj;
|
|
184
|
+
}
|
|
129
185
|
//# sourceMappingURL=textUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textUtils.js","sourceRoot":"","sources":["../../../../src/ui/utils/textUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,O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;AACxC,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect } from 'vitest';
|
|
7
|
+
import { escapeAnsiCtrlCodes } from './textUtils.js';
|
|
8
|
+
describe('textUtils', () => {
|
|
9
|
+
describe('escapeAnsiCtrlCodes', () => {
|
|
10
|
+
describe('escapeAnsiCtrlCodes string case study', () => {
|
|
11
|
+
it('should replace ANSI escape codes with a visible representation', () => {
|
|
12
|
+
const text = '\u001b[31mHello\u001b[0m';
|
|
13
|
+
const expected = '\\u001b[31mHello\\u001b[0m';
|
|
14
|
+
expect(escapeAnsiCtrlCodes(text)).toBe(expected);
|
|
15
|
+
const text2 = "sh -e 'good && bad# \u001b[9D\u001b[K && good";
|
|
16
|
+
const expected2 = "sh -e 'good && bad# \\u001b[9D\\u001b[K && good";
|
|
17
|
+
expect(escapeAnsiCtrlCodes(text2)).toBe(expected2);
|
|
18
|
+
});
|
|
19
|
+
it('should not change a string with no ANSI codes', () => {
|
|
20
|
+
const text = 'Hello, world!';
|
|
21
|
+
expect(escapeAnsiCtrlCodes(text)).toBe(text);
|
|
22
|
+
});
|
|
23
|
+
it('should handle an empty string', () => {
|
|
24
|
+
expect(escapeAnsiCtrlCodes('')).toBe('');
|
|
25
|
+
});
|
|
26
|
+
describe('toolConfirmationDetails case study', () => {
|
|
27
|
+
it('should sanitize command and rootCommand for exec type', () => {
|
|
28
|
+
const details = {
|
|
29
|
+
title: '\u001b[34mfake-title\u001b[0m',
|
|
30
|
+
type: 'exec',
|
|
31
|
+
command: '\u001b[31mmls -l\u001b[0m',
|
|
32
|
+
rootCommand: '\u001b[32msudo apt-get update\u001b[0m',
|
|
33
|
+
onConfirm: async () => { },
|
|
34
|
+
};
|
|
35
|
+
const sanitized = escapeAnsiCtrlCodes(details);
|
|
36
|
+
if (sanitized.type === 'exec') {
|
|
37
|
+
expect(sanitized.title).toBe('\\u001b[34mfake-title\\u001b[0m');
|
|
38
|
+
expect(sanitized.command).toBe('\\u001b[31mmls -l\\u001b[0m');
|
|
39
|
+
expect(sanitized.rootCommand).toBe('\\u001b[32msudo apt-get update\\u001b[0m');
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
it('should sanitize properties for edit type', () => {
|
|
43
|
+
const details = {
|
|
44
|
+
type: 'edit',
|
|
45
|
+
title: '\u001b[34mEdit File\u001b[0m',
|
|
46
|
+
fileName: '\u001b[31mfile.txt\u001b[0m',
|
|
47
|
+
filePath: '/path/to/\u001b[32mfile.txt\u001b[0m',
|
|
48
|
+
fileDiff: 'diff --git a/file.txt b/file.txt\n--- a/\u001b[33mfile.txt\u001b[0m\n+++ b/file.txt',
|
|
49
|
+
onConfirm: async () => { },
|
|
50
|
+
};
|
|
51
|
+
const sanitized = escapeAnsiCtrlCodes(details);
|
|
52
|
+
if (sanitized.type === 'edit') {
|
|
53
|
+
expect(sanitized.title).toBe('\\u001b[34mEdit File\\u001b[0m');
|
|
54
|
+
expect(sanitized.fileName).toBe('\\u001b[31mfile.txt\\u001b[0m');
|
|
55
|
+
expect(sanitized.filePath).toBe('/path/to/\\u001b[32mfile.txt\\u001b[0m');
|
|
56
|
+
expect(sanitized.fileDiff).toBe('diff --git a/file.txt b/file.txt\n--- a/\\u001b[33mfile.txt\\u001b[0m\n+++ b/file.txt');
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
it('should sanitize properties for mcp type', () => {
|
|
60
|
+
const details = {
|
|
61
|
+
type: 'mcp',
|
|
62
|
+
title: '\u001b[34mCloud Run\u001b[0m',
|
|
63
|
+
serverName: '\u001b[31mmy-server\u001b[0m',
|
|
64
|
+
toolName: '\u001b[32mdeploy\u001b[0m',
|
|
65
|
+
toolDisplayName: '\u001b[33mDeploy Service\u001b[0m',
|
|
66
|
+
onConfirm: async () => { },
|
|
67
|
+
};
|
|
68
|
+
const sanitized = escapeAnsiCtrlCodes(details);
|
|
69
|
+
if (sanitized.type === 'mcp') {
|
|
70
|
+
expect(sanitized.title).toBe('\\u001b[34mCloud Run\\u001b[0m');
|
|
71
|
+
expect(sanitized.serverName).toBe('\\u001b[31mmy-server\\u001b[0m');
|
|
72
|
+
expect(sanitized.toolName).toBe('\\u001b[32mdeploy\\u001b[0m');
|
|
73
|
+
expect(sanitized.toolDisplayName).toBe('\\u001b[33mDeploy Service\\u001b[0m');
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
it('should sanitize properties for info type', () => {
|
|
77
|
+
const details = {
|
|
78
|
+
type: 'info',
|
|
79
|
+
title: '\u001b[34mWeb Search\u001b[0m',
|
|
80
|
+
prompt: '\u001b[31mSearch for cats\u001b[0m',
|
|
81
|
+
urls: ['https://\u001b[32mgoogle.com\u001b[0m'],
|
|
82
|
+
onConfirm: async () => { },
|
|
83
|
+
};
|
|
84
|
+
const sanitized = escapeAnsiCtrlCodes(details);
|
|
85
|
+
if (sanitized.type === 'info') {
|
|
86
|
+
expect(sanitized.title).toBe('\\u001b[34mWeb Search\\u001b[0m');
|
|
87
|
+
expect(sanitized.prompt).toBe('\\u001b[31mSearch for cats\\u001b[0m');
|
|
88
|
+
expect(sanitized.urls?.[0]).toBe('https://\\u001b[32mgoogle.com\\u001b[0m');
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
it('should not change the object if no sanitization is needed', () => {
|
|
93
|
+
const details = {
|
|
94
|
+
type: 'info',
|
|
95
|
+
title: 'Web Search',
|
|
96
|
+
prompt: 'Search for cats',
|
|
97
|
+
urls: ['https://google.com'],
|
|
98
|
+
onConfirm: async () => { },
|
|
99
|
+
};
|
|
100
|
+
const sanitized = escapeAnsiCtrlCodes(details);
|
|
101
|
+
expect(sanitized).toBe(details);
|
|
102
|
+
});
|
|
103
|
+
it('should handle nested objects and arrays', () => {
|
|
104
|
+
const details = {
|
|
105
|
+
a: '\u001b[31mred\u001b[0m',
|
|
106
|
+
b: {
|
|
107
|
+
c: '\u001b[32mgreen\u001b[0m',
|
|
108
|
+
d: ['\u001b[33myellow\u001b[0m', { e: '\u001b[34mblue\u001b[0m' }],
|
|
109
|
+
},
|
|
110
|
+
f: 123,
|
|
111
|
+
g: null,
|
|
112
|
+
h: () => '\u001b[35mpurple\u001b[0m',
|
|
113
|
+
};
|
|
114
|
+
const sanitized = escapeAnsiCtrlCodes(details);
|
|
115
|
+
expect(sanitized.a).toBe('\\u001b[31mred\\u001b[0m');
|
|
116
|
+
if (typeof sanitized.b === 'object' && sanitized.b !== null) {
|
|
117
|
+
const b = sanitized.b;
|
|
118
|
+
expect(b.c).toBe('\\u001b[32mgreen\\u001b[0m');
|
|
119
|
+
expect(b.d[0]).toBe('\\u001b[33myellow\\u001b[0m');
|
|
120
|
+
if (typeof b.d[1] === 'object' && b.d[1] !== null) {
|
|
121
|
+
const e = b.d[1];
|
|
122
|
+
expect(e.e).toBe('\\u001b[34mblue\\u001b[0m');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
expect(sanitized.f).toBe(123);
|
|
126
|
+
expect(sanitized.g).toBe(null);
|
|
127
|
+
expect(sanitized.h()).toBe('\u001b[35mpurple\u001b[0m');
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=textUtils.test.js.map
|