@machina.ai/cell-cli 1.11.0-rc1 → 1.13.0-rc2
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/dist/package.json +16 -10
- package/dist/src/commands/extensions/disable.d.ts +1 -1
- package/dist/src/commands/extensions/disable.js +15 -7
- package/dist/src/commands/extensions/disable.js.map +1 -1
- package/dist/src/commands/extensions/enable.d.ts +1 -1
- package/dist/src/commands/extensions/enable.js +15 -7
- package/dist/src/commands/extensions/enable.js.map +1 -1
- package/dist/src/commands/extensions/install.js +14 -3
- package/dist/src/commands/extensions/install.js.map +1 -1
- package/dist/src/commands/extensions/install.test.js +39 -19
- package/dist/src/commands/extensions/install.test.js.map +1 -1
- package/dist/src/commands/extensions/link.js +14 -3
- package/dist/src/commands/extensions/link.js.map +1 -1
- package/dist/src/commands/extensions/list.js +13 -4
- package/dist/src/commands/extensions/list.js.map +1 -1
- package/dist/src/commands/extensions/uninstall.js +13 -2
- package/dist/src/commands/extensions/uninstall.js.map +1 -1
- package/dist/src/commands/extensions/update.js +18 -13
- package/dist/src/commands/extensions/update.js.map +1 -1
- package/dist/src/commands/extensions/validate.d.ts +12 -0
- package/dist/src/commands/extensions/validate.js +83 -0
- package/dist/src/commands/extensions/validate.js.map +1 -0
- package/dist/src/commands/extensions/validate.test.js +93 -0
- package/dist/src/commands/extensions/validate.test.js.map +1 -0
- package/dist/src/commands/extensions.js +3 -0
- package/dist/src/commands/extensions.js.map +1 -1
- package/dist/src/commands/mcp/add.test.js +3 -0
- package/dist/src/commands/mcp/add.test.js.map +1 -1
- package/dist/src/commands/mcp/list.js +10 -3
- package/dist/src/commands/mcp/list.js.map +1 -1
- package/dist/src/commands/mcp/list.test.js +37 -27
- package/dist/src/commands/mcp/list.test.js.map +1 -1
- package/dist/src/config/auth.js +0 -5
- package/dist/src/config/auth.js.map +1 -1
- package/dist/src/config/config.d.ts +6 -3
- package/dist/src/config/config.js +65 -80
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +235 -212
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/extension-manager.d.ts +63 -0
- package/dist/src/config/extension-manager.js +450 -0
- package/dist/src/config/extension-manager.js.map +1 -0
- package/dist/src/config/extension.d.ts +4 -51
- package/dist/src/config/extension.js +1 -535
- package/dist/src/config/extension.js.map +1 -1
- package/dist/src/config/extension.test.js +525 -201
- package/dist/src/config/extension.test.js.map +1 -1
- package/dist/src/config/extensions/consent.d.ts +38 -0
- package/dist/src/config/extensions/consent.js +123 -0
- package/dist/src/config/extensions/consent.js.map +1 -0
- package/dist/src/config/extensions/extensionEnablement.d.ts +1 -1
- package/dist/src/config/extensions/extensionEnablement.js +4 -3
- package/dist/src/config/extensions/extensionEnablement.js.map +1 -1
- package/dist/src/config/extensions/extensionEnablement.test.js +10 -10
- package/dist/src/config/extensions/extensionEnablement.test.js.map +1 -1
- package/dist/src/config/extensions/extensionSettings.d.ts +15 -0
- package/dist/src/config/extensions/extensionSettings.js +113 -0
- package/dist/src/config/extensions/extensionSettings.js.map +1 -0
- package/dist/src/config/extensions/extensionSettings.test.d.ts +6 -0
- package/dist/src/config/extensions/extensionSettings.test.js +254 -0
- package/dist/src/config/extensions/extensionSettings.test.js.map +1 -0
- package/dist/src/config/extensions/github.d.ts +2 -2
- package/dist/src/config/extensions/github.js +5 -10
- package/dist/src/config/extensions/github.js.map +1 -1
- package/dist/src/config/extensions/github.test.js +153 -167
- package/dist/src/config/extensions/github.test.js.map +1 -1
- package/dist/src/config/extensions/github_fetch.d.ts +1 -1
- package/dist/src/config/extensions/github_fetch.js +13 -1
- package/dist/src/config/extensions/github_fetch.js.map +1 -1
- package/dist/src/config/extensions/github_fetch.test.d.ts +6 -0
- package/dist/src/config/extensions/github_fetch.test.js +169 -0
- package/dist/src/config/extensions/github_fetch.test.js.map +1 -0
- package/dist/src/config/extensions/storage.d.ts +14 -0
- package/dist/src/config/extensions/storage.js +32 -0
- package/dist/src/config/extensions/storage.js.map +1 -0
- package/dist/src/config/extensions/update.d.ts +4 -4
- package/dist/src/config/extensions/update.js +39 -39
- package/dist/src/config/extensions/update.js.map +1 -1
- package/dist/src/config/extensions/update.test.js +72 -74
- package/dist/src/config/extensions/update.test.js.map +1 -1
- package/dist/src/config/extensions/variableSchema.d.ts +0 -6
- package/dist/src/config/extensions/variableSchema.js.map +1 -1
- package/dist/src/config/extensions/variables.d.ts +4 -0
- package/dist/src/config/extensions/variables.js +6 -0
- package/dist/src/config/extensions/variables.js.map +1 -1
- package/dist/src/config/keyBindings.d.ts +3 -0
- package/dist/src/config/keyBindings.js +30 -8
- package/dist/src/config/keyBindings.js.map +1 -1
- package/dist/src/config/keyBindings.test.js +17 -0
- package/dist/src/config/keyBindings.test.js.map +1 -1
- package/dist/src/config/policies/read-only.toml +56 -0
- package/dist/src/config/policies/write.toml +63 -0
- package/dist/src/config/policies/yolo.toml +31 -0
- package/dist/src/config/policy-engine.integration.test.js +41 -38
- package/dist/src/config/policy-engine.integration.test.js.map +1 -1
- package/dist/src/config/policy.d.ts +2 -2
- package/dist/src/config/policy.js +10 -148
- package/dist/src/config/policy.js.map +1 -1
- package/dist/src/config/sandboxConfig.d.ts +1 -1
- package/dist/src/config/sandboxConfig.js +6 -3
- package/dist/src/config/sandboxConfig.js.map +1 -1
- package/dist/src/config/settings.d.ts +2 -1
- package/dist/src/config/settings.js +58 -18
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/settings.test.js +128 -69
- package/dist/src/config/settings.test.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +170 -28
- package/dist/src/config/settingsSchema.js +418 -27
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/config/settingsSchema.test.js +42 -1
- package/dist/src/config/settingsSchema.test.js.map +1 -1
- package/dist/src/config/trustedFolders.d.ts +1 -1
- package/dist/src/config/trustedFolders.js +4 -2
- package/dist/src/config/trustedFolders.js.map +1 -1
- package/dist/src/core/initializer.js +2 -1
- package/dist/src/core/initializer.js.map +1 -1
- package/dist/src/gemini.d.ts +1 -1
- package/dist/src/gemini.js +46 -16
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/gemini.test.js +88 -30
- 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/nonInteractiveCli.d.ts +9 -1
- package/dist/src/nonInteractiveCli.js +114 -7
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/nonInteractiveCli.test.js +355 -112
- package/dist/src/nonInteractiveCli.test.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +4 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.test.js +22 -0
- package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -1
- package/dist/src/services/FeedbackService.js +2 -2
- package/dist/src/services/FeedbackService.js.map +1 -1
- package/dist/src/services/McpPromptLoader.js +2 -2
- package/dist/src/services/McpPromptLoader.js.map +1 -1
- package/dist/src/services/McpPromptLoader.test.js +4 -2
- package/dist/src/services/McpPromptLoader.test.js.map +1 -1
- package/dist/src/test-utils/async.d.ts +9 -0
- package/dist/src/test-utils/async.js +29 -0
- package/dist/src/test-utils/async.js.map +1 -0
- package/dist/src/test-utils/createExtension.d.ts +3 -1
- package/dist/src/test-utils/createExtension.js +3 -3
- package/dist/src/test-utils/createExtension.js.map +1 -1
- package/dist/src/test-utils/render.d.ts +16 -2
- package/dist/src/test-utils/render.js +66 -4
- package/dist/src/test-utils/render.js.map +1 -1
- package/dist/src/test-utils/render.test.d.ts +6 -0
- package/dist/src/test-utils/render.test.js +79 -0
- package/dist/src/test-utils/render.test.js.map +1 -0
- package/dist/src/ui/App.test.js +1 -1
- package/dist/src/ui/App.test.js.map +1 -1
- package/dist/src/ui/AppContainer.js +181 -65
- package/dist/src/ui/AppContainer.js.map +1 -1
- package/dist/src/ui/AppContainer.test.js +505 -147
- package/dist/src/ui/AppContainer.test.js.map +1 -1
- package/dist/src/ui/IdeIntegrationNudge.js +1 -1
- package/dist/src/ui/IdeIntegrationNudge.js.map +1 -1
- package/dist/src/ui/auth/ApiAuthDialog.d.ts +14 -0
- package/dist/src/ui/auth/ApiAuthDialog.js +26 -0
- package/dist/src/ui/auth/ApiAuthDialog.js.map +1 -0
- package/dist/src/ui/auth/ApiAuthDialog.test.d.ts +6 -0
- package/dist/src/ui/auth/ApiAuthDialog.test.js +91 -0
- package/dist/src/ui/auth/ApiAuthDialog.test.js.map +1 -0
- package/dist/src/ui/auth/AuthDialog.js +7 -3
- package/dist/src/ui/auth/AuthDialog.js.map +1 -1
- package/dist/src/ui/auth/useAuth.d.ts +2 -0
- package/dist/src/ui/auth/useAuth.js +31 -2
- package/dist/src/ui/auth/useAuth.js.map +1 -1
- package/dist/src/ui/colors.js +3 -0
- package/dist/src/ui/colors.js.map +1 -1
- package/dist/src/ui/commands/directoryCommand.js +1 -1
- package/dist/src/ui/commands/directoryCommand.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.js +64 -11
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.test.js +72 -1
- package/dist/src/ui/commands/extensionsCommand.test.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.js +14 -14
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.test.js +4 -0
- package/dist/src/ui/commands/mcpCommand.test.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.js +1 -1
- package/dist/src/ui/commands/memoryCommand.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.test.js +3 -1
- package/dist/src/ui/commands/memoryCommand.test.js.map +1 -1
- package/dist/src/ui/commands/policiesCommand.d.ts +7 -0
- package/dist/src/ui/commands/policiesCommand.js +59 -0
- package/dist/src/ui/commands/policiesCommand.js.map +1 -0
- package/dist/src/ui/commands/policiesCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/policiesCommand.test.js +83 -0
- package/dist/src/ui/commands/policiesCommand.test.js.map +1 -0
- package/dist/src/ui/components/AnsiOutput.test.js +1 -1
- package/dist/src/ui/components/AnsiOutput.test.js.map +1 -1
- package/dist/src/ui/components/AsciiArt.d.ts +3 -3
- package/dist/src/ui/components/AsciiArt.js +3 -3
- package/dist/src/ui/components/Composer.js +1 -1
- package/dist/src/ui/components/Composer.js.map +1 -1
- package/dist/src/ui/components/Composer.test.js +5 -2
- package/dist/src/ui/components/Composer.test.js.map +1 -1
- package/dist/src/ui/components/ConfigInitDisplay.js +4 -6
- package/dist/src/ui/components/ConfigInitDisplay.js.map +1 -1
- package/dist/src/ui/components/ConsentPrompt.test.js +18 -8
- package/dist/src/ui/components/ConsentPrompt.test.js.map +1 -1
- package/dist/src/ui/components/ConsoleSummaryDisplay.js +1 -1
- package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/ContextSummaryDisplay.test.js +11 -6
- package/dist/src/ui/components/ContextSummaryDisplay.test.js.map +1 -1
- package/dist/src/ui/components/DetailedMessagesDisplay.js +1 -1
- package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -1
- package/dist/src/ui/components/DialogManager.js +4 -0
- package/dist/src/ui/components/DialogManager.js.map +1 -1
- package/dist/src/ui/components/FolderTrustDialog.test.js +2 -1
- package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -1
- package/dist/src/ui/components/Footer.js +4 -3
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/Footer.test.js +83 -0
- package/dist/src/ui/components/Footer.test.js.map +1 -1
- package/dist/src/ui/components/Header.test.js +13 -5
- package/dist/src/ui/components/Header.test.js.map +1 -1
- package/dist/src/ui/components/Help.test.js +5 -4
- package/dist/src/ui/components/Help.test.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.js +27 -8
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.test.js +776 -727
- package/dist/src/ui/components/InputPrompt.test.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.js +2 -2
- package/dist/src/ui/components/LoadingIndicator.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.test.js +28 -15
- package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -1
- package/dist/src/ui/components/LoopDetectionConfirmation.js +1 -1
- package/dist/src/ui/components/LoopDetectionConfirmation.js.map +1 -1
- package/dist/src/ui/components/LoopDetectionConfirmation.test.js +2 -2
- package/dist/src/ui/components/LoopDetectionConfirmation.test.js.map +1 -1
- package/dist/src/ui/components/MainContent.js +15 -4
- package/dist/src/ui/components/MainContent.js.map +1 -1
- package/dist/src/ui/components/ModelDialog.js +1 -1
- package/dist/src/ui/components/ModelDialog.js.map +1 -1
- package/dist/src/ui/components/ModelDialog.test.js +23 -13
- package/dist/src/ui/components/ModelDialog.test.js.map +1 -1
- package/dist/src/ui/components/ModelStatsDisplay.test.js +1 -1
- package/dist/src/ui/components/ModelStatsDisplay.test.js.map +1 -1
- package/dist/src/ui/components/Notifications.js +38 -5
- package/dist/src/ui/components/Notifications.js.map +1 -1
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js +2 -2
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js.map +1 -1
- package/dist/src/ui/components/PrepareLabel.test.js +14 -8
- package/dist/src/ui/components/PrepareLabel.test.js.map +1 -1
- package/dist/src/ui/components/ProQuotaDialog.test.js +14 -6
- package/dist/src/ui/components/ProQuotaDialog.test.js.map +1 -1
- package/dist/src/ui/components/QueuedMessageDisplay.test.js +11 -6
- package/dist/src/ui/components/QueuedMessageDisplay.test.js.map +1 -1
- package/dist/src/ui/components/SessionSummaryDisplay.test.js +1 -1
- package/dist/src/ui/components/SessionSummaryDisplay.test.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.js +32 -25
- package/dist/src/ui/components/SettingsDialog.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.test.js +428 -532
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.js +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.test.js +2 -2
- package/dist/src/ui/components/ShellConfirmationDialog.test.js.map +1 -1
- package/dist/src/ui/components/StatsDisplay.test.js +1 -1
- package/dist/src/ui/components/StatsDisplay.test.js.map +1 -1
- package/dist/src/ui/components/SuggestionsDisplay.js +1 -1
- package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.test.js +2 -2
- package/dist/src/ui/components/ThemeDialog.test.js.map +1 -1
- package/dist/src/ui/components/ToolStatsDisplay.test.js +1 -1
- package/dist/src/ui/components/ToolStatsDisplay.test.js.map +1 -1
- package/dist/src/ui/components/messages/CompressionMessage.test.js +25 -17
- package/dist/src/ui/components/messages/CompressionMessage.test.js.map +1 -1
- package/dist/src/ui/components/messages/DiffRenderer.test.js +1 -1
- package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -1
- package/dist/src/ui/components/messages/InfoMessage.js +1 -1
- package/dist/src/ui/components/messages/InfoMessage.js.map +1 -1
- package/dist/src/ui/components/messages/Todo.js +27 -5
- package/dist/src/ui/components/messages/Todo.js.map +1 -1
- package/dist/src/ui/components/messages/Todo.test.js +20 -8
- package/dist/src/ui/components/messages/Todo.test.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.test.js +29 -15
- package/dist/src/ui/components/messages/ToolGroupMessage.test.js.map +1 -1
- package/dist/src/ui/components/messages/WarningMessage.js +2 -2
- package/dist/src/ui/components/messages/WarningMessage.js.map +1 -1
- package/dist/src/ui/components/shared/BaseSelectionList.test.js +1 -1
- package/dist/src/ui/components/shared/BaseSelectionList.test.js.map +1 -1
- package/dist/src/ui/components/shared/MaxSizedBox.test.js +43 -22
- package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -1
- package/dist/src/ui/components/shared/TextInput.d.ts +15 -0
- package/dist/src/ui/components/shared/TextInput.js +38 -0
- package/dist/src/ui/components/shared/TextInput.js.map +1 -0
- package/dist/src/ui/components/shared/TextInput.test.d.ts +6 -0
- package/dist/src/ui/components/shared/TextInput.test.js +242 -0
- package/dist/src/ui/components/shared/TextInput.test.js.map +1 -0
- package/dist/src/ui/components/shared/text-buffer.d.ts +9 -2
- package/dist/src/ui/components/shared/text-buffer.js +51 -13
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.test.js +385 -202
- package/dist/src/ui/components/shared/text-buffer.test.js.map +1 -1
- package/dist/src/ui/components/views/ChatList.test.js +7 -4
- package/dist/src/ui/components/views/ChatList.test.js.map +1 -1
- package/dist/src/ui/components/views/ExtensionsList.d.ts +7 -1
- package/dist/src/ui/components/views/ExtensionsList.js +9 -11
- package/dist/src/ui/components/views/ExtensionsList.js.map +1 -1
- package/dist/src/ui/components/views/ExtensionsList.test.js +43 -22
- package/dist/src/ui/components/views/ExtensionsList.test.js.map +1 -1
- package/dist/src/ui/components/views/McpStatus.test.js +23 -12
- package/dist/src/ui/components/views/McpStatus.test.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.d.ts +3 -2
- package/dist/src/ui/contexts/KeypressContext.js +610 -540
- package/dist/src/ui/contexts/KeypressContext.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.test.js +438 -718
- package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -1
- package/dist/src/ui/contexts/MouseContext.d.ts +21 -0
- package/dist/src/ui/contexts/MouseContext.js +89 -0
- package/dist/src/ui/contexts/MouseContext.js.map +1 -0
- package/dist/src/ui/contexts/MouseContext.test.d.ts +6 -0
- package/dist/src/ui/contexts/MouseContext.test.js +164 -0
- package/dist/src/ui/contexts/MouseContext.test.js.map +1 -0
- package/dist/src/ui/contexts/SessionContext.test.js +35 -17
- package/dist/src/ui/contexts/SessionContext.test.js.map +1 -1
- 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 +2 -0
- package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.js +31 -9
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.test.js +163 -64
- package/dist/src/ui/hooks/atCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.test.js +64 -35
- package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.test.js +193 -165
- package/dist/src/ui/hooks/slashCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/useAtCompletion.test.js +16 -5
- package/dist/src/ui/hooks/useAtCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js +10 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +32 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -1
- package/dist/src/ui/hooks/useCommandCompletion.test.js +66 -64
- package/dist/src/ui/hooks/useCommandCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useConsoleMessages.test.js +26 -9
- package/dist/src/ui/hooks/useConsoleMessages.test.js.map +1 -1
- package/dist/src/ui/hooks/useEditorSettings.test.js +40 -34
- package/dist/src/ui/hooks/useEditorSettings.test.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.d.ts +14 -5
- package/dist/src/ui/hooks/useExtensionUpdates.js +18 -13
- package/dist/src/ui/hooks/useExtensionUpdates.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.test.js +49 -44
- package/dist/src/ui/hooks/useExtensionUpdates.test.js.map +1 -1
- package/dist/src/ui/hooks/useFlickerDetector.test.js +9 -5
- package/dist/src/ui/hooks/useFlickerDetector.test.js.map +1 -1
- package/dist/src/ui/hooks/useFocus.test.js +25 -9
- package/dist/src/ui/hooks/useFocus.test.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.test.js +46 -22
- package/dist/src/ui/hooks/useFolderTrust.test.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +56 -19
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.test.js +260 -411
- package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -1
- package/dist/src/ui/hooks/useGitBranchName.js +4 -0
- package/dist/src/ui/hooks/useGitBranchName.js.map +1 -1
- package/dist/src/ui/hooks/useGitBranchName.test.js +46 -34
- package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -1
- package/dist/src/ui/hooks/useHistoryManager.test.js +2 -1
- package/dist/src/ui/hooks/useHistoryManager.test.js.map +1 -1
- package/dist/src/ui/hooks/useIdeTrustListener.test.js +40 -9
- package/dist/src/ui/hooks/useIdeTrustListener.test.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistory.test.js +2 -1
- package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistoryStore.test.js +2 -1
- package/dist/src/ui/hooks/useInputHistoryStore.test.js.map +1 -1
- package/dist/src/ui/hooks/useKeypress.test.js +103 -114
- package/dist/src/ui/hooks/useKeypress.test.js.map +1 -1
- package/dist/src/ui/hooks/useLoadingIndicator.test.js +24 -6
- package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +1 -1
- package/dist/src/ui/hooks/useMemoryMonitor.test.js +10 -5
- package/dist/src/ui/hooks/useMemoryMonitor.test.js.map +1 -1
- package/dist/src/ui/hooks/useMessageQueue.test.js +62 -45
- package/dist/src/ui/hooks/useMessageQueue.test.js.map +1 -1
- package/dist/src/ui/hooks/useModelCommand.test.js +21 -11
- package/dist/src/ui/hooks/useModelCommand.test.js.map +1 -1
- package/dist/src/ui/hooks/useMouse.d.ts +17 -0
- package/dist/src/ui/hooks/useMouse.js +27 -0
- package/dist/src/ui/hooks/useMouse.js.map +1 -0
- package/dist/src/ui/hooks/useMouse.test.d.ts +6 -0
- package/dist/src/ui/hooks/useMouse.test.js +57 -0
- package/dist/src/ui/hooks/useMouse.test.js.map +1 -0
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js +2 -2
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.js +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.test.js +109 -106
- package/dist/src/ui/hooks/usePhraseCycler.test.js.map +1 -1
- package/dist/src/ui/hooks/usePrivacySettings.test.js +26 -6
- package/dist/src/ui/hooks/usePrivacySettings.test.js.map +1 -1
- package/dist/src/ui/hooks/usePromptCompletion.js +2 -2
- package/dist/src/ui/hooks/usePromptCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.js +13 -14
- package/dist/src/ui/hooks/useQuotaAndFallback.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js +55 -48
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js.map +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.d.ts +8 -1
- package/dist/src/ui/hooks/useReactToolScheduler.js +59 -34
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.test.d.ts +6 -0
- package/dist/src/ui/hooks/useReactToolScheduler.test.js +65 -0
- package/dist/src/ui/hooks/useReactToolScheduler.test.js.map +1 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +2 -2
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useSelectionList.js +5 -4
- package/dist/src/ui/hooks/useSelectionList.js.map +1 -1
- package/dist/src/ui/hooks/useSelectionList.test.js +272 -183
- package/dist/src/ui/hooks/useSelectionList.test.js.map +1 -1
- package/dist/src/ui/hooks/useShellHistory.test.js +52 -20
- package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.js +18 -7
- package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.test.js +275 -137
- package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useTimer.test.js +43 -14
- package/dist/src/ui/hooks/useTimer.test.js.map +1 -1
- package/dist/src/ui/hooks/useToolScheduler.test.js +226 -242
- package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -1
- package/dist/src/ui/hooks/vim.test.js +235 -355
- package/dist/src/ui/hooks/vim.test.js.map +1 -1
- package/dist/src/ui/keyMatchers.test.js +30 -3
- package/dist/src/ui/keyMatchers.test.js.map +1 -1
- package/dist/src/ui/state/extensions.d.ts +1 -0
- package/dist/src/ui/state/extensions.js +1 -0
- package/dist/src/ui/state/extensions.js.map +1 -1
- package/dist/src/ui/themes/ansi-light.js +1 -0
- package/dist/src/ui/themes/ansi-light.js.map +1 -1
- package/dist/src/ui/themes/ansi.js +1 -0
- package/dist/src/ui/themes/ansi.js.map +1 -1
- package/dist/src/ui/themes/atom-one-dark.js +2 -0
- package/dist/src/ui/themes/atom-one-dark.js.map +1 -1
- package/dist/src/ui/themes/ayu-light.js +2 -0
- package/dist/src/ui/themes/ayu-light.js.map +1 -1
- package/dist/src/ui/themes/ayu.js +2 -0
- package/dist/src/ui/themes/ayu.js.map +1 -1
- package/dist/src/ui/themes/color-utils.d.ts +1 -0
- package/dist/src/ui/themes/color-utils.js +6 -0
- package/dist/src/ui/themes/color-utils.js.map +1 -1
- package/dist/src/ui/themes/color-utils.test.js +13 -1
- package/dist/src/ui/themes/color-utils.test.js.map +1 -1
- package/dist/src/ui/themes/dracula.js +2 -0
- package/dist/src/ui/themes/dracula.js.map +1 -1
- package/dist/src/ui/themes/github-dark.js +2 -0
- package/dist/src/ui/themes/github-dark.js.map +1 -1
- package/dist/src/ui/themes/github-light.js +2 -0
- package/dist/src/ui/themes/github-light.js.map +1 -1
- package/dist/src/ui/themes/googlecode.js +2 -0
- package/dist/src/ui/themes/googlecode.js.map +1 -1
- package/dist/src/ui/themes/no-color.js +3 -0
- package/dist/src/ui/themes/no-color.js.map +1 -1
- package/dist/src/ui/themes/semantic-tokens.d.ts +2 -0
- package/dist/src/ui/themes/semantic-tokens.js +6 -0
- package/dist/src/ui/themes/semantic-tokens.js.map +1 -1
- package/dist/src/ui/themes/shades-of-purple.js +2 -0
- package/dist/src/ui/themes/shades-of-purple.js.map +1 -1
- package/dist/src/ui/themes/theme.d.ts +3 -0
- package/dist/src/ui/themes/theme.js +14 -3
- package/dist/src/ui/themes/theme.js.map +1 -1
- package/dist/src/ui/themes/theme.test.js +67 -1
- package/dist/src/ui/themes/theme.test.js.map +1 -1
- package/dist/src/ui/themes/xcode.js +2 -0
- package/dist/src/ui/themes/xcode.js.map +1 -1
- package/dist/src/ui/types.d.ts +3 -1
- package/dist/src/ui/types.js +2 -0
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/CodeColorizer.js +2 -1
- package/dist/src/ui/utils/CodeColorizer.js.map +1 -1
- package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +1 -0
- package/dist/src/ui/utils/InlineMarkdownRenderer.js +11 -10
- package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -1
- package/dist/src/ui/utils/MarkdownDisplay.js +11 -9
- package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -1
- package/dist/src/ui/utils/clipboardUtils.js +2 -2
- package/dist/src/ui/utils/clipboardUtils.js.map +1 -1
- package/dist/src/ui/utils/input.d.ts +17 -0
- package/dist/src/ui/utils/input.js +51 -0
- package/dist/src/ui/utils/input.js.map +1 -0
- package/dist/src/ui/utils/input.test.d.ts +6 -0
- package/dist/src/ui/utils/input.test.js +44 -0
- package/dist/src/ui/utils/input.test.js.map +1 -0
- package/dist/src/ui/utils/kittyProtocolDetector.js +13 -4
- package/dist/src/ui/utils/kittyProtocolDetector.js.map +1 -1
- package/dist/src/ui/utils/mouse.d.ts +31 -0
- package/dist/src/ui/utils/mouse.js +164 -0
- package/dist/src/ui/utils/mouse.js.map +1 -0
- package/dist/src/ui/utils/mouse.test.d.ts +6 -0
- package/dist/src/ui/utils/mouse.test.js +131 -0
- package/dist/src/ui/utils/mouse.test.js.map +1 -0
- package/dist/src/ui/utils/textOutput.d.ts +25 -0
- package/dist/src/ui/utils/textOutput.js +49 -0
- package/dist/src/ui/utils/textOutput.js.map +1 -0
- package/dist/src/ui/utils/textOutput.test.d.ts +6 -0
- package/dist/src/ui/utils/textOutput.test.js +79 -0
- package/dist/src/ui/utils/textOutput.test.js.map +1 -0
- package/dist/src/ui/utils/updateCheck.d.ts +7 -1
- package/dist/src/ui/utils/updateCheck.js +33 -29
- package/dist/src/ui/utils/updateCheck.js.map +1 -1
- package/dist/src/ui/utils/updateCheck.test.js +24 -50
- package/dist/src/ui/utils/updateCheck.test.js.map +1 -1
- package/dist/src/utils/commentJson.js +2 -2
- package/dist/src/utils/commentJson.js.map +1 -1
- package/dist/src/utils/commentJson.test.js +7 -6
- package/dist/src/utils/commentJson.test.js.map +1 -1
- package/dist/src/utils/envVarResolver.d.ts +2 -2
- package/dist/src/utils/envVarResolver.js +10 -7
- package/dist/src/utils/envVarResolver.js.map +1 -1
- package/dist/src/utils/events.d.ts +11 -2
- package/dist/src/utils/events.js +1 -0
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/handleAutoUpdate.js +9 -3
- package/dist/src/utils/handleAutoUpdate.js.map +1 -1
- package/dist/src/utils/sandbox.js +16 -18
- package/dist/src/utils/sandbox.js.map +1 -1
- package/dist/src/utils/version.js +6 -2
- package/dist/src/utils/version.js.map +1 -1
- package/dist/src/zed-integration/acp.js +2 -1
- package/dist/src/zed-integration/acp.js.map +1 -1
- package/dist/src/zed-integration/schema.d.ts +4 -4
- package/dist/src/zed-integration/zedIntegration.d.ts +2 -2
- package/dist/src/zed-integration/zedIntegration.js +12 -19
- package/dist/src/zed-integration/zedIntegration.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -14
- package/dist/src/config/policy.test.js +0 -360
- package/dist/src/config/policy.test.js.map +0 -1
- package/dist/src/utils/package.d.ts +0 -12
- package/dist/src/utils/package.js +0 -24
- package/dist/src/utils/package.js.map +0 -1
- /package/dist/src/{config/policy.test.d.ts → commands/extensions/validate.test.d.ts} +0 -0
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
7
7
|
import * as os from 'node:os';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
|
-
import { DEFAULT_GEMINI_MODEL, DEFAULT_GEMINI_MODEL_AUTO, OutputFormat, SHELL_TOOL_NAME, WRITE_FILE_TOOL_NAME, EDIT_TOOL_NAME, } from '@google/gemini-cli-core';
|
|
9
|
+
import { DEFAULT_FILE_FILTERING_OPTIONS, DEFAULT_GEMINI_MODEL, DEFAULT_GEMINI_MODEL_AUTO, OutputFormat, SHELL_TOOL_NAME, WRITE_FILE_TOOL_NAME, EDIT_TOOL_NAME, } from '@google/gemini-cli-core';
|
|
10
10
|
import { loadCliConfig, parseArguments } from './config.js';
|
|
11
11
|
import * as ServerConfig from '@google/gemini-cli-core';
|
|
12
12
|
import { isWorkspaceTrusted } from './trustedFolders.js';
|
|
13
|
+
import { ExtensionManager } from './extension-manager.js';
|
|
13
14
|
vi.mock('./trustedFolders.js', () => ({
|
|
14
15
|
isWorkspaceTrusted: vi
|
|
15
16
|
.fn()
|
|
@@ -72,10 +73,15 @@ vi.mock('@google/gemini-cli-core', async () => {
|
|
|
72
73
|
}),
|
|
73
74
|
},
|
|
74
75
|
loadEnvironment: vi.fn(),
|
|
75
|
-
loadServerHierarchicalMemory: vi.fn((cwd, dirs, debug, fileService,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
loadServerHierarchicalMemory: vi.fn((cwd, dirs, debug, fileService, extensionLoader, _maxDirs) => {
|
|
77
|
+
const extensionPaths = extensionLoader
|
|
78
|
+
.getExtensions()
|
|
79
|
+
.flatMap((e) => e.contextFiles);
|
|
80
|
+
return Promise.resolve({
|
|
81
|
+
memoryContent: extensionPaths.join(',') || '',
|
|
82
|
+
fileCount: extensionPaths?.length || 0,
|
|
83
|
+
});
|
|
84
|
+
}),
|
|
79
85
|
DEFAULT_MEMORY_FILE_FILTERING_OPTIONS: {
|
|
80
86
|
respectGitIgnore: false,
|
|
81
87
|
respectGeminiIgnore: true,
|
|
@@ -86,11 +92,23 @@ vi.mock('@google/gemini-cli-core', async () => {
|
|
|
86
92
|
},
|
|
87
93
|
};
|
|
88
94
|
});
|
|
95
|
+
vi.mock('./extension-manager.js');
|
|
96
|
+
// Global setup to ensure clean environment for all tests in this file
|
|
97
|
+
const originalArgv = process.argv;
|
|
98
|
+
const originalGeminiModel = process.env['GEMINI_MODEL'];
|
|
99
|
+
beforeEach(() => {
|
|
100
|
+
delete process.env['GEMINI_MODEL'];
|
|
101
|
+
});
|
|
102
|
+
afterEach(() => {
|
|
103
|
+
process.argv = originalArgv;
|
|
104
|
+
if (originalGeminiModel !== undefined) {
|
|
105
|
+
process.env['GEMINI_MODEL'] = originalGeminiModel;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
delete process.env['GEMINI_MODEL'];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
89
111
|
describe('parseArguments', () => {
|
|
90
|
-
const originalArgv = process.argv;
|
|
91
|
-
afterEach(() => {
|
|
92
|
-
process.argv = originalArgv;
|
|
93
|
-
});
|
|
94
112
|
it('should throw an error when both --prompt and --prompt-interactive are used together', async () => {
|
|
95
113
|
process.argv = [
|
|
96
114
|
'node',
|
|
@@ -176,13 +194,13 @@ describe('parseArguments', () => {
|
|
|
176
194
|
'@path',
|
|
177
195
|
'./file.md',
|
|
178
196
|
'--model',
|
|
179
|
-
'gemini-
|
|
197
|
+
'gemini-2.5-pro',
|
|
180
198
|
];
|
|
181
199
|
const argv = await parseArguments({});
|
|
182
200
|
expect(argv.query).toBe('@path ./file.md');
|
|
183
201
|
expect(argv.prompt).toBe('@path ./file.md'); // Should map to one-shot
|
|
184
202
|
expect(argv.promptInteractive).toBeUndefined();
|
|
185
|
-
expect(argv.model).toBe('gemini-
|
|
203
|
+
expect(argv.model).toBe('gemini-2.5-pro');
|
|
186
204
|
});
|
|
187
205
|
it('maps unquoted positional @path + arg to prompt (one-shot)', async () => {
|
|
188
206
|
// Simulate: gemini @path ./file.md
|
|
@@ -380,14 +398,13 @@ describe('parseArguments', () => {
|
|
|
380
398
|
});
|
|
381
399
|
});
|
|
382
400
|
describe('loadCliConfig', () => {
|
|
383
|
-
const originalArgv = process.argv;
|
|
384
401
|
beforeEach(() => {
|
|
385
402
|
vi.resetAllMocks();
|
|
386
403
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
387
404
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
405
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
388
406
|
});
|
|
389
407
|
afterEach(() => {
|
|
390
|
-
process.argv = originalArgv;
|
|
391
408
|
vi.unstubAllEnvs();
|
|
392
409
|
vi.restoreAllMocks();
|
|
393
410
|
});
|
|
@@ -419,7 +436,7 @@ describe('loadCliConfig', () => {
|
|
|
419
436
|
process.argv = ['node', 'script.js'];
|
|
420
437
|
const argv = await parseArguments({});
|
|
421
438
|
const settings = {};
|
|
422
|
-
const config = await loadCliConfig(settings,
|
|
439
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
423
440
|
expect(config.getProxy()).toBeFalsy();
|
|
424
441
|
});
|
|
425
442
|
const proxy_url = 'http://localhost:7890';
|
|
@@ -459,11 +476,19 @@ describe('loadCliConfig', () => {
|
|
|
459
476
|
process.argv = ['node', 'script.js'];
|
|
460
477
|
const argv = await parseArguments({});
|
|
461
478
|
const settings = {};
|
|
462
|
-
const config = await loadCliConfig(settings,
|
|
479
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
463
480
|
expect(config.getProxy()).toBe(expected);
|
|
464
481
|
});
|
|
465
482
|
});
|
|
466
483
|
});
|
|
484
|
+
it('should use default fileFilter options when unconfigured', async () => {
|
|
485
|
+
process.argv = ['node', 'script.js'];
|
|
486
|
+
const argv = await parseArguments({});
|
|
487
|
+
const settings = {};
|
|
488
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
489
|
+
expect(config.getFileFilteringRespectGitIgnore()).toBe(DEFAULT_FILE_FILTERING_OPTIONS.respectGitIgnore);
|
|
490
|
+
expect(config.getFileFilteringRespectGeminiIgnore()).toBe(DEFAULT_FILE_FILTERING_OPTIONS.respectGeminiIgnore);
|
|
491
|
+
});
|
|
467
492
|
});
|
|
468
493
|
describe('Hierarchical Memory Loading (config.ts) - Placeholder Suite', () => {
|
|
469
494
|
beforeEach(() => {
|
|
@@ -477,7 +502,7 @@ describe('Hierarchical Memory Loading (config.ts) - Placeholder Suite', () => {
|
|
|
477
502
|
it('should pass extension context file paths to loadServerHierarchicalMemory', async () => {
|
|
478
503
|
process.argv = ['node', 'script.js'];
|
|
479
504
|
const settings = {};
|
|
480
|
-
|
|
505
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([
|
|
481
506
|
{
|
|
482
507
|
path: '/path/to/ext1',
|
|
483
508
|
name: 'ext1',
|
|
@@ -505,10 +530,10 @@ describe('Hierarchical Memory Loading (config.ts) - Placeholder Suite', () => {
|
|
|
505
530
|
],
|
|
506
531
|
isActive: true,
|
|
507
532
|
},
|
|
508
|
-
];
|
|
533
|
+
]);
|
|
509
534
|
const argv = await parseArguments({});
|
|
510
|
-
await loadCliConfig(settings,
|
|
511
|
-
expect(ServerConfig.loadServerHierarchicalMemory).toHaveBeenCalledWith(expect.any(String), [], false, expect.any(Object),
|
|
535
|
+
await loadCliConfig(settings, 'session-id', argv);
|
|
536
|
+
expect(ServerConfig.loadServerHierarchicalMemory).toHaveBeenCalledWith(expect.any(String), [], false, expect.any(Object), expect.any(ExtensionManager), true, 'tree', {
|
|
512
537
|
respectGitIgnore: false,
|
|
513
538
|
respectGeminiIgnore: true,
|
|
514
539
|
}, undefined);
|
|
@@ -532,7 +557,7 @@ describe('mergeMcpServers', () => {
|
|
|
532
557
|
},
|
|
533
558
|
},
|
|
534
559
|
};
|
|
535
|
-
|
|
560
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([
|
|
536
561
|
{
|
|
537
562
|
path: '/path/to/ext1',
|
|
538
563
|
name: 'ext1',
|
|
@@ -546,11 +571,11 @@ describe('mergeMcpServers', () => {
|
|
|
546
571
|
contextFiles: [],
|
|
547
572
|
isActive: true,
|
|
548
573
|
},
|
|
549
|
-
];
|
|
574
|
+
]);
|
|
550
575
|
const originalSettings = JSON.parse(JSON.stringify(settings));
|
|
551
576
|
process.argv = ['node', 'script.js'];
|
|
552
577
|
const argv = await parseArguments({});
|
|
553
|
-
await loadCliConfig(settings,
|
|
578
|
+
await loadCliConfig(settings, 'test-session', argv);
|
|
554
579
|
expect(settings).toEqual(originalSettings);
|
|
555
580
|
});
|
|
556
581
|
});
|
|
@@ -562,6 +587,7 @@ describe('mergeExcludeTools', () => {
|
|
|
562
587
|
];
|
|
563
588
|
const originalIsTTY = process.stdin.isTTY;
|
|
564
589
|
beforeEach(() => {
|
|
590
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
565
591
|
process.stdin.isTTY = true;
|
|
566
592
|
});
|
|
567
593
|
afterEach(() => {
|
|
@@ -569,7 +595,7 @@ describe('mergeExcludeTools', () => {
|
|
|
569
595
|
});
|
|
570
596
|
it('should merge excludeTools from settings and extensions', async () => {
|
|
571
597
|
const settings = { tools: { exclude: ['tool1', 'tool2'] } };
|
|
572
|
-
|
|
598
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([
|
|
573
599
|
{
|
|
574
600
|
path: '/path/to/ext1',
|
|
575
601
|
name: 'ext1',
|
|
@@ -588,16 +614,16 @@ describe('mergeExcludeTools', () => {
|
|
|
588
614
|
contextFiles: [],
|
|
589
615
|
isActive: true,
|
|
590
616
|
},
|
|
591
|
-
];
|
|
617
|
+
]);
|
|
592
618
|
process.argv = ['node', 'script.js'];
|
|
593
619
|
const argv = await parseArguments({});
|
|
594
|
-
const config = await loadCliConfig(settings,
|
|
620
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
595
621
|
expect(config.getExcludeTools()).toEqual(expect.arrayContaining(['tool1', 'tool2', 'tool3', 'tool4', 'tool5']));
|
|
596
622
|
expect(config.getExcludeTools()).toHaveLength(5);
|
|
597
623
|
});
|
|
598
624
|
it('should handle overlapping excludeTools between settings and extensions', async () => {
|
|
599
625
|
const settings = { tools: { exclude: ['tool1', 'tool2'] } };
|
|
600
|
-
|
|
626
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([
|
|
601
627
|
{
|
|
602
628
|
path: '/path/to/ext1',
|
|
603
629
|
name: 'ext1',
|
|
@@ -607,16 +633,16 @@ describe('mergeExcludeTools', () => {
|
|
|
607
633
|
contextFiles: [],
|
|
608
634
|
isActive: true,
|
|
609
635
|
},
|
|
610
|
-
];
|
|
636
|
+
]);
|
|
611
637
|
process.argv = ['node', 'script.js'];
|
|
612
638
|
const argv = await parseArguments({});
|
|
613
|
-
const config = await loadCliConfig(settings,
|
|
639
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
614
640
|
expect(config.getExcludeTools()).toEqual(expect.arrayContaining(['tool1', 'tool2', 'tool3']));
|
|
615
641
|
expect(config.getExcludeTools()).toHaveLength(3);
|
|
616
642
|
});
|
|
617
643
|
it('should handle overlapping excludeTools between extensions', async () => {
|
|
618
644
|
const settings = { tools: { exclude: ['tool1'] } };
|
|
619
|
-
|
|
645
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([
|
|
620
646
|
{
|
|
621
647
|
path: '/path/to/ext1',
|
|
622
648
|
name: 'ext1',
|
|
@@ -635,43 +661,41 @@ describe('mergeExcludeTools', () => {
|
|
|
635
661
|
contextFiles: [],
|
|
636
662
|
isActive: true,
|
|
637
663
|
},
|
|
638
|
-
];
|
|
664
|
+
]);
|
|
639
665
|
process.argv = ['node', 'script.js'];
|
|
640
666
|
const argv = await parseArguments({});
|
|
641
|
-
const config = await loadCliConfig(settings,
|
|
667
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
642
668
|
expect(config.getExcludeTools()).toEqual(expect.arrayContaining(['tool1', 'tool2', 'tool3', 'tool4']));
|
|
643
669
|
expect(config.getExcludeTools()).toHaveLength(4);
|
|
644
670
|
});
|
|
645
671
|
it('should return an empty array when no excludeTools are specified and it is interactive', async () => {
|
|
646
672
|
process.stdin.isTTY = true;
|
|
647
673
|
const settings = {};
|
|
648
|
-
const extensions = [];
|
|
649
674
|
process.argv = ['node', 'script.js'];
|
|
650
675
|
const argv = await parseArguments({});
|
|
651
|
-
const config = await loadCliConfig(settings,
|
|
676
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
652
677
|
expect(config.getExcludeTools()).toEqual([]);
|
|
653
678
|
});
|
|
654
679
|
it('should return default excludes when no excludeTools are specified and it is not interactive', async () => {
|
|
655
680
|
process.stdin.isTTY = false;
|
|
656
681
|
const settings = {};
|
|
657
|
-
const extensions = [];
|
|
658
682
|
process.argv = ['node', 'script.js', '-p', 'test'];
|
|
659
683
|
const argv = await parseArguments({});
|
|
660
|
-
const config = await loadCliConfig(settings,
|
|
684
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
661
685
|
expect(config.getExcludeTools()).toEqual(defaultExcludes);
|
|
662
686
|
});
|
|
663
687
|
it('should handle settings with excludeTools but no extensions', async () => {
|
|
664
688
|
process.argv = ['node', 'script.js'];
|
|
665
689
|
const argv = await parseArguments({});
|
|
666
690
|
const settings = { tools: { exclude: ['tool1', 'tool2'] } };
|
|
667
|
-
|
|
668
|
-
const config = await loadCliConfig(settings,
|
|
691
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
692
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
669
693
|
expect(config.getExcludeTools()).toEqual(expect.arrayContaining(['tool1', 'tool2']));
|
|
670
694
|
expect(config.getExcludeTools()).toHaveLength(2);
|
|
671
695
|
});
|
|
672
696
|
it('should handle extensions with excludeTools but no settings', async () => {
|
|
673
697
|
const settings = {};
|
|
674
|
-
|
|
698
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([
|
|
675
699
|
{
|
|
676
700
|
path: '/path/to/ext',
|
|
677
701
|
name: 'ext1',
|
|
@@ -681,16 +705,16 @@ describe('mergeExcludeTools', () => {
|
|
|
681
705
|
contextFiles: [],
|
|
682
706
|
isActive: true,
|
|
683
707
|
},
|
|
684
|
-
];
|
|
708
|
+
]);
|
|
685
709
|
process.argv = ['node', 'script.js'];
|
|
686
710
|
const argv = await parseArguments({});
|
|
687
|
-
const config = await loadCliConfig(settings,
|
|
711
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
688
712
|
expect(config.getExcludeTools()).toEqual(expect.arrayContaining(['tool1', 'tool2']));
|
|
689
713
|
expect(config.getExcludeTools()).toHaveLength(2);
|
|
690
714
|
});
|
|
691
715
|
it('should not modify the original settings object', async () => {
|
|
692
716
|
const settings = { tools: { exclude: ['tool1'] } };
|
|
693
|
-
|
|
717
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([
|
|
694
718
|
{
|
|
695
719
|
path: '/path/to/ext',
|
|
696
720
|
name: 'ext1',
|
|
@@ -700,11 +724,11 @@ describe('mergeExcludeTools', () => {
|
|
|
700
724
|
contextFiles: [],
|
|
701
725
|
isActive: true,
|
|
702
726
|
},
|
|
703
|
-
];
|
|
727
|
+
]);
|
|
704
728
|
const originalSettings = JSON.parse(JSON.stringify(settings));
|
|
705
729
|
process.argv = ['node', 'script.js'];
|
|
706
730
|
const argv = await parseArguments({});
|
|
707
|
-
await loadCliConfig(settings,
|
|
731
|
+
await loadCliConfig(settings, 'test-session', argv);
|
|
708
732
|
expect(settings).toEqual(originalSettings);
|
|
709
733
|
});
|
|
710
734
|
});
|
|
@@ -716,6 +740,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|
|
716
740
|
isTrusted: true,
|
|
717
741
|
source: undefined,
|
|
718
742
|
});
|
|
743
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
719
744
|
});
|
|
720
745
|
afterEach(() => {
|
|
721
746
|
process.stdin.isTTY = originalIsTTY;
|
|
@@ -724,8 +749,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|
|
724
749
|
process.argv = ['node', 'script.js', '-p', 'test'];
|
|
725
750
|
const argv = await parseArguments({});
|
|
726
751
|
const settings = {};
|
|
727
|
-
const
|
|
728
|
-
const config = await loadCliConfig(settings, extensions, 'test-session', argv);
|
|
752
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
729
753
|
const excludedTools = config.getExcludeTools();
|
|
730
754
|
expect(excludedTools).toContain(SHELL_TOOL_NAME);
|
|
731
755
|
expect(excludedTools).toContain(EDIT_TOOL_NAME);
|
|
@@ -742,8 +766,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|
|
742
766
|
];
|
|
743
767
|
const argv = await parseArguments({});
|
|
744
768
|
const settings = {};
|
|
745
|
-
const
|
|
746
|
-
const config = await loadCliConfig(settings, extensions, 'test-session', argv);
|
|
769
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
747
770
|
const excludedTools = config.getExcludeTools();
|
|
748
771
|
expect(excludedTools).toContain(SHELL_TOOL_NAME);
|
|
749
772
|
expect(excludedTools).toContain(EDIT_TOOL_NAME);
|
|
@@ -760,8 +783,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|
|
760
783
|
];
|
|
761
784
|
const argv = await parseArguments({});
|
|
762
785
|
const settings = {};
|
|
763
|
-
const
|
|
764
|
-
const config = await loadCliConfig(settings, extensions, 'test-session', argv);
|
|
786
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
765
787
|
const excludedTools = config.getExcludeTools();
|
|
766
788
|
expect(excludedTools).toContain(SHELL_TOOL_NAME);
|
|
767
789
|
expect(excludedTools).not.toContain(EDIT_TOOL_NAME);
|
|
@@ -778,8 +800,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|
|
778
800
|
];
|
|
779
801
|
const argv = await parseArguments({});
|
|
780
802
|
const settings = {};
|
|
781
|
-
const
|
|
782
|
-
const config = await loadCliConfig(settings, extensions, 'test-session', argv);
|
|
803
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
783
804
|
const excludedTools = config.getExcludeTools();
|
|
784
805
|
expect(excludedTools).not.toContain(SHELL_TOOL_NAME);
|
|
785
806
|
expect(excludedTools).not.toContain(EDIT_TOOL_NAME);
|
|
@@ -789,8 +810,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|
|
789
810
|
process.argv = ['node', 'script.js', '--yolo', '-p', 'test'];
|
|
790
811
|
const argv = await parseArguments({});
|
|
791
812
|
const settings = {};
|
|
792
|
-
const
|
|
793
|
-
const config = await loadCliConfig(settings, extensions, 'test-session', argv);
|
|
813
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
794
814
|
const excludedTools = config.getExcludeTools();
|
|
795
815
|
expect(excludedTools).not.toContain(SHELL_TOOL_NAME);
|
|
796
816
|
expect(excludedTools).not.toContain(EDIT_TOOL_NAME);
|
|
@@ -809,8 +829,7 @@ describe('Approval mode tool exclusion logic', () => {
|
|
|
809
829
|
process.argv = testCase.args;
|
|
810
830
|
const argv = await parseArguments({});
|
|
811
831
|
const settings = {};
|
|
812
|
-
const
|
|
813
|
-
const config = await loadCliConfig(settings, extensions, 'test-session', argv);
|
|
832
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
814
833
|
const excludedTools = config.getExcludeTools();
|
|
815
834
|
expect(excludedTools).not.toContain(SHELL_TOOL_NAME);
|
|
816
835
|
expect(excludedTools).not.toContain(EDIT_TOOL_NAME);
|
|
@@ -828,14 +847,23 @@ describe('Approval mode tool exclusion logic', () => {
|
|
|
828
847
|
];
|
|
829
848
|
const argv = await parseArguments({});
|
|
830
849
|
const settings = { tools: { exclude: ['custom_tool'] } };
|
|
831
|
-
const
|
|
832
|
-
const config = await loadCliConfig(settings, extensions, 'test-session', argv);
|
|
850
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
833
851
|
const excludedTools = config.getExcludeTools();
|
|
834
852
|
expect(excludedTools).toContain('custom_tool'); // From settings
|
|
835
853
|
expect(excludedTools).toContain(SHELL_TOOL_NAME); // From approval mode
|
|
836
854
|
expect(excludedTools).not.toContain(EDIT_TOOL_NAME); // Should be allowed in auto_edit
|
|
837
855
|
expect(excludedTools).not.toContain(WRITE_FILE_TOOL_NAME); // Should be allowed in auto_edit
|
|
838
856
|
});
|
|
857
|
+
it('should throw an error if YOLO mode is attempted when disableYoloMode is true', async () => {
|
|
858
|
+
process.argv = ['node', 'script.js', '--yolo'];
|
|
859
|
+
const argv = await parseArguments({});
|
|
860
|
+
const settings = {
|
|
861
|
+
security: {
|
|
862
|
+
disableYoloMode: true,
|
|
863
|
+
},
|
|
864
|
+
};
|
|
865
|
+
await expect(loadCliConfig(settings, 'test-session', argv)).rejects.toThrow('Cannot start in YOLO mode when it is disabled by settings');
|
|
866
|
+
});
|
|
839
867
|
it('should throw an error for invalid approval mode values in loadCliConfig', async () => {
|
|
840
868
|
// Create a mock argv with an invalid approval mode that bypasses argument parsing validation
|
|
841
869
|
const invalidArgv = {
|
|
@@ -845,19 +873,17 @@ describe('Approval mode tool exclusion logic', () => {
|
|
|
845
873
|
yolo: false,
|
|
846
874
|
};
|
|
847
875
|
const settings = {};
|
|
848
|
-
|
|
849
|
-
await expect(loadCliConfig(settings, extensions, 'test-session', invalidArgv)).rejects.toThrow('Invalid approval mode: invalid_mode. Valid values are: yolo, auto_edit, default');
|
|
876
|
+
await expect(loadCliConfig(settings, 'test-session', invalidArgv)).rejects.toThrow('Invalid approval mode: invalid_mode. Valid values are: yolo, auto_edit, default');
|
|
850
877
|
});
|
|
851
878
|
});
|
|
852
879
|
describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
853
|
-
const originalArgv = process.argv;
|
|
854
880
|
beforeEach(() => {
|
|
855
881
|
vi.resetAllMocks();
|
|
856
882
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
857
883
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
884
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
858
885
|
});
|
|
859
886
|
afterEach(() => {
|
|
860
|
-
process.argv = originalArgv;
|
|
861
887
|
vi.unstubAllEnvs();
|
|
862
888
|
vi.restoreAllMocks();
|
|
863
889
|
});
|
|
@@ -871,7 +897,7 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
|
871
897
|
it('should allow all MCP servers if the flag is not provided', async () => {
|
|
872
898
|
process.argv = ['node', 'script.js'];
|
|
873
899
|
const argv = await parseArguments({});
|
|
874
|
-
const config = await loadCliConfig(baseSettings,
|
|
900
|
+
const config = await loadCliConfig(baseSettings, 'test-session', argv);
|
|
875
901
|
expect(config.getMcpServers()).toEqual(baseSettings.mcpServers);
|
|
876
902
|
});
|
|
877
903
|
it('should allow only the specified MCP server', async () => {
|
|
@@ -882,10 +908,8 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
|
882
908
|
'server1',
|
|
883
909
|
];
|
|
884
910
|
const argv = await parseArguments({});
|
|
885
|
-
const config = await loadCliConfig(baseSettings,
|
|
886
|
-
expect(config.
|
|
887
|
-
server1: { url: 'http://localhost:8080' },
|
|
888
|
-
});
|
|
911
|
+
const config = await loadCliConfig(baseSettings, 'test-session', argv);
|
|
912
|
+
expect(config.getAllowedMcpServers()).toEqual(['server1']);
|
|
889
913
|
});
|
|
890
914
|
it('should allow multiple specified MCP servers', async () => {
|
|
891
915
|
process.argv = [
|
|
@@ -897,11 +921,8 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
|
897
921
|
'server3',
|
|
898
922
|
];
|
|
899
923
|
const argv = await parseArguments({});
|
|
900
|
-
const config = await loadCliConfig(baseSettings,
|
|
901
|
-
expect(config.
|
|
902
|
-
server1: { url: 'http://localhost:8080' },
|
|
903
|
-
server3: { url: 'http://localhost:8082' },
|
|
904
|
-
});
|
|
924
|
+
const config = await loadCliConfig(baseSettings, 'test-session', argv);
|
|
925
|
+
expect(config.getAllowedMcpServers()).toEqual(['server1', 'server3']);
|
|
905
926
|
});
|
|
906
927
|
it('should handle server names that do not exist', async () => {
|
|
907
928
|
process.argv = [
|
|
@@ -913,16 +934,14 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
|
913
934
|
'server4',
|
|
914
935
|
];
|
|
915
936
|
const argv = await parseArguments({});
|
|
916
|
-
const config = await loadCliConfig(baseSettings,
|
|
917
|
-
expect(config.
|
|
918
|
-
server1: { url: 'http://localhost:8080' },
|
|
919
|
-
});
|
|
937
|
+
const config = await loadCliConfig(baseSettings, 'test-session', argv);
|
|
938
|
+
expect(config.getAllowedMcpServers()).toEqual(['server1', 'server4']);
|
|
920
939
|
});
|
|
921
940
|
it('should allow no MCP servers if the flag is provided but empty', async () => {
|
|
922
941
|
process.argv = ['node', 'script.js', '--allowed-mcp-server-names', ''];
|
|
923
942
|
const argv = await parseArguments({});
|
|
924
|
-
const config = await loadCliConfig(baseSettings,
|
|
925
|
-
expect(config.
|
|
943
|
+
const config = await loadCliConfig(baseSettings, 'test-session', argv);
|
|
944
|
+
expect(config.getAllowedMcpServers()).toEqual(['']);
|
|
926
945
|
});
|
|
927
946
|
it('should read allowMCPServers from settings', async () => {
|
|
928
947
|
process.argv = ['node', 'script.js'];
|
|
@@ -931,11 +950,8 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
|
931
950
|
...baseSettings,
|
|
932
951
|
mcp: { allowed: ['server1', 'server2'] },
|
|
933
952
|
};
|
|
934
|
-
const config = await loadCliConfig(settings,
|
|
935
|
-
expect(config.
|
|
936
|
-
server1: { url: 'http://localhost:8080' },
|
|
937
|
-
server2: { url: 'http://localhost:8081' },
|
|
938
|
-
});
|
|
953
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
954
|
+
expect(config.getAllowedMcpServers()).toEqual(['server1', 'server2']);
|
|
939
955
|
});
|
|
940
956
|
it('should read excludeMCPServers from settings', async () => {
|
|
941
957
|
process.argv = ['node', 'script.js'];
|
|
@@ -944,10 +960,8 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
|
944
960
|
...baseSettings,
|
|
945
961
|
mcp: { excluded: ['server1', 'server2'] },
|
|
946
962
|
};
|
|
947
|
-
const config = await loadCliConfig(settings,
|
|
948
|
-
expect(config.
|
|
949
|
-
server3: { url: 'http://localhost:8082' },
|
|
950
|
-
});
|
|
963
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
964
|
+
expect(config.getBlockedMcpServers()).toEqual(['server1', 'server2']);
|
|
951
965
|
});
|
|
952
966
|
it('should override allowMCPServers with excludeMCPServers if overlapping', async () => {
|
|
953
967
|
process.argv = ['node', 'script.js'];
|
|
@@ -959,10 +973,9 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
|
959
973
|
allowed: ['server1', 'server2'],
|
|
960
974
|
},
|
|
961
975
|
};
|
|
962
|
-
const config = await loadCliConfig(settings,
|
|
963
|
-
expect(config.
|
|
964
|
-
|
|
965
|
-
});
|
|
976
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
977
|
+
expect(config.getAllowedMcpServers()).toEqual(['server1', 'server2']);
|
|
978
|
+
expect(config.getBlockedMcpServers()).toEqual(['server1']);
|
|
966
979
|
});
|
|
967
980
|
it('should prioritize mcp server flag if set', async () => {
|
|
968
981
|
process.argv = [
|
|
@@ -979,10 +992,8 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
|
979
992
|
allowed: ['server2'],
|
|
980
993
|
},
|
|
981
994
|
};
|
|
982
|
-
const config = await loadCliConfig(settings,
|
|
983
|
-
expect(config.
|
|
984
|
-
server1: { url: 'http://localhost:8080' },
|
|
985
|
-
});
|
|
995
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
996
|
+
expect(config.getAllowedMcpServers()).toEqual(['server1']);
|
|
986
997
|
});
|
|
987
998
|
it('should prioritize CLI flag over both allowed and excluded settings', async () => {
|
|
988
999
|
process.argv = [
|
|
@@ -1001,52 +1012,62 @@ describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
|
1001
1012
|
excluded: ['server3'], // Should be ignored
|
|
1002
1013
|
},
|
|
1003
1014
|
};
|
|
1004
|
-
const config = await loadCliConfig(settings,
|
|
1005
|
-
expect(config.
|
|
1006
|
-
|
|
1007
|
-
server3: { url: 'http://localhost:8082' },
|
|
1008
|
-
});
|
|
1015
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1016
|
+
expect(config.getAllowedMcpServers()).toEqual(['server2', 'server3']);
|
|
1017
|
+
expect(config.getBlockedMcpServers()).toEqual([]);
|
|
1009
1018
|
});
|
|
1010
1019
|
});
|
|
1011
1020
|
describe('loadCliConfig model selection', () => {
|
|
1021
|
+
beforeEach(() => {
|
|
1022
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1023
|
+
});
|
|
1024
|
+
afterEach(() => {
|
|
1025
|
+
vi.resetAllMocks();
|
|
1026
|
+
});
|
|
1012
1027
|
it('selects a model from settings.json if provided', async () => {
|
|
1013
1028
|
process.argv = ['node', 'script.js'];
|
|
1014
1029
|
const argv = await parseArguments({});
|
|
1015
1030
|
const config = await loadCliConfig({
|
|
1016
1031
|
model: {
|
|
1017
|
-
name: 'gemini-
|
|
1032
|
+
name: 'gemini-2.5-pro',
|
|
1018
1033
|
},
|
|
1019
|
-
},
|
|
1020
|
-
expect(config.getModel()).toBe('gemini-
|
|
1034
|
+
}, 'test-session', argv);
|
|
1035
|
+
expect(config.getModel()).toBe('gemini-2.5-pro');
|
|
1021
1036
|
});
|
|
1022
1037
|
it('uses the default gemini model if nothing is set', async () => {
|
|
1023
1038
|
process.argv = ['node', 'script.js']; // No model set.
|
|
1024
1039
|
const argv = await parseArguments({});
|
|
1025
1040
|
const config = await loadCliConfig({
|
|
1026
1041
|
// No model set.
|
|
1027
|
-
},
|
|
1042
|
+
}, 'test-session', argv);
|
|
1028
1043
|
expect(config.getModel()).toBe(DEFAULT_GEMINI_MODEL);
|
|
1029
1044
|
});
|
|
1030
1045
|
it('always prefers model from argv', async () => {
|
|
1031
|
-
process.argv = ['node', 'script.js', '--model', 'gemini-
|
|
1046
|
+
process.argv = ['node', 'script.js', '--model', 'gemini-2.5-flash-preview'];
|
|
1032
1047
|
const argv = await parseArguments({});
|
|
1033
1048
|
const config = await loadCliConfig({
|
|
1034
1049
|
model: {
|
|
1035
|
-
name: 'gemini-
|
|
1050
|
+
name: 'gemini-2.5-pro',
|
|
1036
1051
|
},
|
|
1037
|
-
},
|
|
1038
|
-
expect(config.getModel()).toBe('gemini-
|
|
1052
|
+
}, 'test-session', argv);
|
|
1053
|
+
expect(config.getModel()).toBe('gemini-2.5-flash-preview');
|
|
1039
1054
|
});
|
|
1040
1055
|
it('selects the model from argv if provided', async () => {
|
|
1041
|
-
process.argv = ['node', 'script.js', '--model', 'gemini-
|
|
1056
|
+
process.argv = ['node', 'script.js', '--model', 'gemini-2.5-flash-preview'];
|
|
1042
1057
|
const argv = await parseArguments({});
|
|
1043
1058
|
const config = await loadCliConfig({
|
|
1044
1059
|
// No model provided via settings.
|
|
1045
|
-
},
|
|
1046
|
-
expect(config.getModel()).toBe('gemini-
|
|
1060
|
+
}, 'test-session', argv);
|
|
1061
|
+
expect(config.getModel()).toBe('gemini-2.5-flash-preview');
|
|
1047
1062
|
});
|
|
1048
1063
|
});
|
|
1049
1064
|
describe('loadCliConfig model selection with model router', () => {
|
|
1065
|
+
beforeEach(() => {
|
|
1066
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1067
|
+
});
|
|
1068
|
+
afterEach(() => {
|
|
1069
|
+
vi.resetAllMocks();
|
|
1070
|
+
});
|
|
1050
1071
|
it('should use auto model when useModelRouter is true and no model is provided', async () => {
|
|
1051
1072
|
process.argv = ['node', 'script.js'];
|
|
1052
1073
|
const argv = await parseArguments({});
|
|
@@ -1054,7 +1075,7 @@ describe('loadCliConfig model selection with model router', () => {
|
|
|
1054
1075
|
experimental: {
|
|
1055
1076
|
useModelRouter: true,
|
|
1056
1077
|
},
|
|
1057
|
-
},
|
|
1078
|
+
}, 'test-session', argv);
|
|
1058
1079
|
expect(config.getModel()).toBe(DEFAULT_GEMINI_MODEL_AUTO);
|
|
1059
1080
|
});
|
|
1060
1081
|
it('should use default model when useModelRouter is false and no model is provided', async () => {
|
|
@@ -1064,7 +1085,7 @@ describe('loadCliConfig model selection with model router', () => {
|
|
|
1064
1085
|
experimental: {
|
|
1065
1086
|
useModelRouter: false,
|
|
1066
1087
|
},
|
|
1067
|
-
},
|
|
1088
|
+
}, 'test-session', argv);
|
|
1068
1089
|
expect(config.getModel()).toBe(DEFAULT_GEMINI_MODEL);
|
|
1069
1090
|
});
|
|
1070
1091
|
it('should prioritize argv over useModelRouter', async () => {
|
|
@@ -1074,7 +1095,7 @@ describe('loadCliConfig model selection with model router', () => {
|
|
|
1074
1095
|
experimental: {
|
|
1075
1096
|
useModelRouter: true,
|
|
1076
1097
|
},
|
|
1077
|
-
},
|
|
1098
|
+
}, 'test-session', argv);
|
|
1078
1099
|
expect(config.getModel()).toBe('gemini-from-argv');
|
|
1079
1100
|
});
|
|
1080
1101
|
it('should prioritize settings over useModelRouter', async () => {
|
|
@@ -1087,7 +1108,7 @@ describe('loadCliConfig model selection with model router', () => {
|
|
|
1087
1108
|
model: {
|
|
1088
1109
|
name: 'gemini-from-settings',
|
|
1089
1110
|
},
|
|
1090
|
-
},
|
|
1111
|
+
}, 'test-session', argv);
|
|
1091
1112
|
expect(config.getModel()).toBe('gemini-from-settings');
|
|
1092
1113
|
});
|
|
1093
1114
|
it('should prioritize environment variable over useModelRouter', async () => {
|
|
@@ -1098,19 +1119,18 @@ describe('loadCliConfig model selection with model router', () => {
|
|
|
1098
1119
|
experimental: {
|
|
1099
1120
|
useModelRouter: true,
|
|
1100
1121
|
},
|
|
1101
|
-
},
|
|
1122
|
+
}, 'test-session', argv);
|
|
1102
1123
|
expect(config.getModel()).toBe('gemini-from-env');
|
|
1103
1124
|
});
|
|
1104
1125
|
});
|
|
1105
1126
|
describe('loadCliConfig folderTrust', () => {
|
|
1106
|
-
const originalArgv = process.argv;
|
|
1107
1127
|
beforeEach(() => {
|
|
1108
1128
|
vi.resetAllMocks();
|
|
1109
1129
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1110
1130
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1131
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1111
1132
|
});
|
|
1112
1133
|
afterEach(() => {
|
|
1113
|
-
process.argv = originalArgv;
|
|
1114
1134
|
vi.unstubAllEnvs();
|
|
1115
1135
|
vi.restoreAllMocks();
|
|
1116
1136
|
});
|
|
@@ -1124,7 +1144,7 @@ describe('loadCliConfig folderTrust', () => {
|
|
|
1124
1144
|
},
|
|
1125
1145
|
};
|
|
1126
1146
|
const argv = await parseArguments({});
|
|
1127
|
-
const config = await loadCliConfig(settings,
|
|
1147
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1128
1148
|
expect(config.getFolderTrust()).toBe(false);
|
|
1129
1149
|
});
|
|
1130
1150
|
it('should be true when folderTrust is true', async () => {
|
|
@@ -1137,28 +1157,26 @@ describe('loadCliConfig folderTrust', () => {
|
|
|
1137
1157
|
},
|
|
1138
1158
|
},
|
|
1139
1159
|
};
|
|
1140
|
-
const config = await loadCliConfig(settings,
|
|
1160
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1141
1161
|
expect(config.getFolderTrust()).toBe(true);
|
|
1142
1162
|
});
|
|
1143
1163
|
it('should be false by default', async () => {
|
|
1144
1164
|
process.argv = ['node', 'script.js'];
|
|
1145
1165
|
const argv = await parseArguments({});
|
|
1146
1166
|
const settings = {};
|
|
1147
|
-
const config = await loadCliConfig(settings,
|
|
1167
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1148
1168
|
expect(config.getFolderTrust()).toBe(false);
|
|
1149
1169
|
});
|
|
1150
1170
|
});
|
|
1151
1171
|
describe('loadCliConfig with includeDirectories', () => {
|
|
1152
|
-
const originalArgv = process.argv;
|
|
1153
1172
|
beforeEach(() => {
|
|
1154
1173
|
vi.resetAllMocks();
|
|
1155
1174
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1156
1175
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1157
1176
|
vi.spyOn(process, 'cwd').mockReturnValue(path.resolve(path.sep, 'home', 'user', 'project'));
|
|
1177
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1158
1178
|
});
|
|
1159
1179
|
afterEach(() => {
|
|
1160
|
-
process.argv = originalArgv;
|
|
1161
|
-
vi.unstubAllEnvs();
|
|
1162
1180
|
vi.restoreAllMocks();
|
|
1163
1181
|
});
|
|
1164
1182
|
it('should combine and resolve paths from settings and CLI arguments', async () => {
|
|
@@ -1179,7 +1197,7 @@ describe('loadCliConfig with includeDirectories', () => {
|
|
|
1179
1197
|
],
|
|
1180
1198
|
},
|
|
1181
1199
|
};
|
|
1182
|
-
const config = await loadCliConfig(settings,
|
|
1200
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1183
1201
|
const expected = [
|
|
1184
1202
|
mockCwd,
|
|
1185
1203
|
path.resolve(path.sep, 'cli', 'path1'),
|
|
@@ -1192,50 +1210,44 @@ describe('loadCliConfig with includeDirectories', () => {
|
|
|
1192
1210
|
expect(config.getWorkspaceContext().getDirectories()).toHaveLength(expected.length);
|
|
1193
1211
|
});
|
|
1194
1212
|
});
|
|
1195
|
-
describe('loadCliConfig
|
|
1196
|
-
const originalArgv = process.argv;
|
|
1213
|
+
describe('loadCliConfig compressionThreshold', () => {
|
|
1197
1214
|
beforeEach(() => {
|
|
1198
1215
|
vi.resetAllMocks();
|
|
1199
1216
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1200
1217
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1218
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1201
1219
|
});
|
|
1202
1220
|
afterEach(() => {
|
|
1203
|
-
process.argv = originalArgv;
|
|
1204
1221
|
vi.unstubAllEnvs();
|
|
1205
1222
|
vi.restoreAllMocks();
|
|
1206
1223
|
});
|
|
1207
|
-
it('should pass
|
|
1224
|
+
it('should pass settings to the core config', async () => {
|
|
1208
1225
|
process.argv = ['node', 'script.js'];
|
|
1209
1226
|
const argv = await parseArguments({});
|
|
1210
1227
|
const settings = {
|
|
1211
1228
|
model: {
|
|
1212
|
-
|
|
1213
|
-
contextPercentageThreshold: 0.5,
|
|
1214
|
-
},
|
|
1229
|
+
compressionThreshold: 0.5,
|
|
1215
1230
|
},
|
|
1216
1231
|
};
|
|
1217
|
-
const config = await loadCliConfig(settings,
|
|
1218
|
-
expect(config.
|
|
1219
|
-
contextPercentageThreshold: 0.5,
|
|
1220
|
-
});
|
|
1232
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1233
|
+
expect(await config.getCompressionThreshold()).toBe(0.5);
|
|
1221
1234
|
});
|
|
1222
|
-
it('should have undefined
|
|
1235
|
+
it('should have undefined compressionThreshold if not in settings', async () => {
|
|
1223
1236
|
process.argv = ['node', 'script.js'];
|
|
1224
1237
|
const argv = await parseArguments({});
|
|
1225
1238
|
const settings = {};
|
|
1226
|
-
const config = await loadCliConfig(settings,
|
|
1227
|
-
expect(config.
|
|
1239
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1240
|
+
expect(await config.getCompressionThreshold()).toBeUndefined();
|
|
1228
1241
|
});
|
|
1229
1242
|
});
|
|
1230
1243
|
describe('loadCliConfig useRipgrep', () => {
|
|
1231
|
-
const originalArgv = process.argv;
|
|
1232
1244
|
beforeEach(() => {
|
|
1233
1245
|
vi.resetAllMocks();
|
|
1234
1246
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1235
1247
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1248
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1236
1249
|
});
|
|
1237
1250
|
afterEach(() => {
|
|
1238
|
-
process.argv = originalArgv;
|
|
1239
1251
|
vi.unstubAllEnvs();
|
|
1240
1252
|
vi.restoreAllMocks();
|
|
1241
1253
|
});
|
|
@@ -1243,56 +1255,55 @@ describe('loadCliConfig useRipgrep', () => {
|
|
|
1243
1255
|
process.argv = ['node', 'script.js'];
|
|
1244
1256
|
const argv = await parseArguments({});
|
|
1245
1257
|
const settings = {};
|
|
1246
|
-
const config = await loadCliConfig(settings,
|
|
1258
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1247
1259
|
expect(config.getUseRipgrep()).toBe(true);
|
|
1248
1260
|
});
|
|
1249
1261
|
it('should be false when useRipgrep is set to false in settings', async () => {
|
|
1250
1262
|
process.argv = ['node', 'script.js'];
|
|
1251
1263
|
const argv = await parseArguments({});
|
|
1252
1264
|
const settings = { tools: { useRipgrep: false } };
|
|
1253
|
-
const config = await loadCliConfig(settings,
|
|
1265
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1254
1266
|
expect(config.getUseRipgrep()).toBe(false);
|
|
1255
1267
|
});
|
|
1256
1268
|
it('should be true when useRipgrep is explicitly set to true in settings', async () => {
|
|
1257
1269
|
process.argv = ['node', 'script.js'];
|
|
1258
1270
|
const argv = await parseArguments({});
|
|
1259
1271
|
const settings = { tools: { useRipgrep: true } };
|
|
1260
|
-
const config = await loadCliConfig(settings,
|
|
1272
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1261
1273
|
expect(config.getUseRipgrep()).toBe(true);
|
|
1262
1274
|
});
|
|
1263
1275
|
describe('loadCliConfig useModelRouter', () => {
|
|
1264
1276
|
it('should be false by default when useModelRouter is not set in settings', async () => {
|
|
1265
1277
|
process.argv = ['node', 'script.js'];
|
|
1266
|
-
const
|
|
1278
|
+
const _argv = await parseArguments({});
|
|
1267
1279
|
const settings = {};
|
|
1268
|
-
const config = await loadCliConfig(settings,
|
|
1280
|
+
const config = await loadCliConfig(settings, 'test-session', _argv);
|
|
1269
1281
|
expect(config.getUseModelRouter()).toBe(false);
|
|
1270
1282
|
});
|
|
1271
1283
|
it('should be true when useModelRouter is set to true in settings', async () => {
|
|
1272
1284
|
process.argv = ['node', 'script.js'];
|
|
1273
1285
|
const argv = await parseArguments({});
|
|
1274
1286
|
const settings = { experimental: { useModelRouter: true } };
|
|
1275
|
-
const config = await loadCliConfig(settings,
|
|
1287
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1276
1288
|
expect(config.getUseModelRouter()).toBe(true);
|
|
1277
1289
|
});
|
|
1278
1290
|
it('should be false when useModelRouter is explicitly set to false in settings', async () => {
|
|
1279
1291
|
process.argv = ['node', 'script.js'];
|
|
1280
1292
|
const argv = await parseArguments({});
|
|
1281
1293
|
const settings = { experimental: { useModelRouter: false } };
|
|
1282
|
-
const config = await loadCliConfig(settings,
|
|
1294
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1283
1295
|
expect(config.getUseModelRouter()).toBe(false);
|
|
1284
1296
|
});
|
|
1285
1297
|
});
|
|
1286
1298
|
});
|
|
1287
1299
|
describe('screenReader configuration', () => {
|
|
1288
|
-
const originalArgv = process.argv;
|
|
1289
1300
|
beforeEach(() => {
|
|
1290
1301
|
vi.resetAllMocks();
|
|
1291
1302
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1292
1303
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1304
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1293
1305
|
});
|
|
1294
1306
|
afterEach(() => {
|
|
1295
|
-
process.argv = originalArgv;
|
|
1296
1307
|
vi.unstubAllEnvs();
|
|
1297
1308
|
vi.restoreAllMocks();
|
|
1298
1309
|
});
|
|
@@ -1302,7 +1313,7 @@ describe('screenReader configuration', () => {
|
|
|
1302
1313
|
const settings = {
|
|
1303
1314
|
ui: { accessibility: { screenReader: true } },
|
|
1304
1315
|
};
|
|
1305
|
-
const config = await loadCliConfig(settings,
|
|
1316
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1306
1317
|
expect(config.getScreenReader()).toBe(true);
|
|
1307
1318
|
});
|
|
1308
1319
|
it('should use screenReader value from settings if CLI flag is not present (settings false)', async () => {
|
|
@@ -1311,7 +1322,7 @@ describe('screenReader configuration', () => {
|
|
|
1311
1322
|
const settings = {
|
|
1312
1323
|
ui: { accessibility: { screenReader: false } },
|
|
1313
1324
|
};
|
|
1314
|
-
const config = await loadCliConfig(settings,
|
|
1325
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1315
1326
|
expect(config.getScreenReader()).toBe(false);
|
|
1316
1327
|
});
|
|
1317
1328
|
it('should prioritize --screen-reader CLI flag (true) over settings (false)', async () => {
|
|
@@ -1320,19 +1331,18 @@ describe('screenReader configuration', () => {
|
|
|
1320
1331
|
const settings = {
|
|
1321
1332
|
ui: { accessibility: { screenReader: false } },
|
|
1322
1333
|
};
|
|
1323
|
-
const config = await loadCliConfig(settings,
|
|
1334
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1324
1335
|
expect(config.getScreenReader()).toBe(true);
|
|
1325
1336
|
});
|
|
1326
1337
|
it('should be false by default when no flag or setting is present', async () => {
|
|
1327
1338
|
process.argv = ['node', 'script.js'];
|
|
1328
1339
|
const argv = await parseArguments({});
|
|
1329
1340
|
const settings = {};
|
|
1330
|
-
const config = await loadCliConfig(settings,
|
|
1341
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1331
1342
|
expect(config.getScreenReader()).toBe(false);
|
|
1332
1343
|
});
|
|
1333
1344
|
});
|
|
1334
1345
|
describe('loadCliConfig tool exclusions', () => {
|
|
1335
|
-
const originalArgv = process.argv;
|
|
1336
1346
|
const originalIsTTY = process.stdin.isTTY;
|
|
1337
1347
|
beforeEach(() => {
|
|
1338
1348
|
vi.resetAllMocks();
|
|
@@ -1343,9 +1353,9 @@ describe('loadCliConfig tool exclusions', () => {
|
|
|
1343
1353
|
isTrusted: true,
|
|
1344
1354
|
source: undefined,
|
|
1345
1355
|
});
|
|
1356
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1346
1357
|
});
|
|
1347
1358
|
afterEach(() => {
|
|
1348
|
-
process.argv = originalArgv;
|
|
1349
1359
|
process.stdin.isTTY = originalIsTTY;
|
|
1350
1360
|
vi.unstubAllEnvs();
|
|
1351
1361
|
vi.restoreAllMocks();
|
|
@@ -1354,7 +1364,7 @@ describe('loadCliConfig tool exclusions', () => {
|
|
|
1354
1364
|
process.stdin.isTTY = true;
|
|
1355
1365
|
process.argv = ['node', 'script.js'];
|
|
1356
1366
|
const argv = await parseArguments({});
|
|
1357
|
-
const config = await loadCliConfig({},
|
|
1367
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1358
1368
|
expect(config.getExcludeTools()).not.toContain('run_shell_command');
|
|
1359
1369
|
expect(config.getExcludeTools()).not.toContain('replace');
|
|
1360
1370
|
expect(config.getExcludeTools()).not.toContain('write_file');
|
|
@@ -1363,7 +1373,7 @@ describe('loadCliConfig tool exclusions', () => {
|
|
|
1363
1373
|
process.stdin.isTTY = true;
|
|
1364
1374
|
process.argv = ['node', 'script.js', '--yolo'];
|
|
1365
1375
|
const argv = await parseArguments({});
|
|
1366
|
-
const config = await loadCliConfig({},
|
|
1376
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1367
1377
|
expect(config.getExcludeTools()).not.toContain('run_shell_command');
|
|
1368
1378
|
expect(config.getExcludeTools()).not.toContain('replace');
|
|
1369
1379
|
expect(config.getExcludeTools()).not.toContain('write_file');
|
|
@@ -1372,7 +1382,7 @@ describe('loadCliConfig tool exclusions', () => {
|
|
|
1372
1382
|
process.stdin.isTTY = false;
|
|
1373
1383
|
process.argv = ['node', 'script.js', '-p', 'test'];
|
|
1374
1384
|
const argv = await parseArguments({});
|
|
1375
|
-
const config = await loadCliConfig({},
|
|
1385
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1376
1386
|
expect(config.getExcludeTools()).toContain('run_shell_command');
|
|
1377
1387
|
expect(config.getExcludeTools()).toContain('replace');
|
|
1378
1388
|
expect(config.getExcludeTools()).toContain('write_file');
|
|
@@ -1381,7 +1391,7 @@ describe('loadCliConfig tool exclusions', () => {
|
|
|
1381
1391
|
process.stdin.isTTY = false;
|
|
1382
1392
|
process.argv = ['node', 'script.js', '-p', 'test', '--yolo'];
|
|
1383
1393
|
const argv = await parseArguments({});
|
|
1384
|
-
const config = await loadCliConfig({},
|
|
1394
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1385
1395
|
expect(config.getExcludeTools()).not.toContain('run_shell_command');
|
|
1386
1396
|
expect(config.getExcludeTools()).not.toContain('replace');
|
|
1387
1397
|
expect(config.getExcludeTools()).not.toContain('write_file');
|
|
@@ -1397,7 +1407,7 @@ describe('loadCliConfig tool exclusions', () => {
|
|
|
1397
1407
|
'ShellTool',
|
|
1398
1408
|
];
|
|
1399
1409
|
const argv = await parseArguments({});
|
|
1400
|
-
const config = await loadCliConfig({},
|
|
1410
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1401
1411
|
expect(config.getExcludeTools()).not.toContain(SHELL_TOOL_NAME);
|
|
1402
1412
|
});
|
|
1403
1413
|
it('should not exclude shell tool in non-interactive mode when --allowed-tools="run_shell_command" is set', async () => {
|
|
@@ -1411,7 +1421,7 @@ describe('loadCliConfig tool exclusions', () => {
|
|
|
1411
1421
|
'run_shell_command',
|
|
1412
1422
|
];
|
|
1413
1423
|
const argv = await parseArguments({});
|
|
1414
|
-
const config = await loadCliConfig({},
|
|
1424
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1415
1425
|
expect(config.getExcludeTools()).not.toContain(SHELL_TOOL_NAME);
|
|
1416
1426
|
});
|
|
1417
1427
|
it('should not exclude shell tool in non-interactive mode when --allowed-tools="ShellTool(wc)" is set', async () => {
|
|
@@ -1425,21 +1435,20 @@ describe('loadCliConfig tool exclusions', () => {
|
|
|
1425
1435
|
'ShellTool(wc)',
|
|
1426
1436
|
];
|
|
1427
1437
|
const argv = await parseArguments({});
|
|
1428
|
-
const config = await loadCliConfig({},
|
|
1438
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1429
1439
|
expect(config.getExcludeTools()).not.toContain(SHELL_TOOL_NAME);
|
|
1430
1440
|
});
|
|
1431
1441
|
});
|
|
1432
1442
|
describe('loadCliConfig interactive', () => {
|
|
1433
|
-
const originalArgv = process.argv;
|
|
1434
1443
|
const originalIsTTY = process.stdin.isTTY;
|
|
1435
1444
|
beforeEach(() => {
|
|
1436
1445
|
vi.resetAllMocks();
|
|
1437
1446
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1438
1447
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1439
1448
|
process.stdin.isTTY = true;
|
|
1449
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1440
1450
|
});
|
|
1441
1451
|
afterEach(() => {
|
|
1442
|
-
process.argv = originalArgv;
|
|
1443
1452
|
process.stdin.isTTY = originalIsTTY;
|
|
1444
1453
|
vi.unstubAllEnvs();
|
|
1445
1454
|
vi.restoreAllMocks();
|
|
@@ -1448,35 +1457,35 @@ describe('loadCliConfig interactive', () => {
|
|
|
1448
1457
|
process.stdin.isTTY = true;
|
|
1449
1458
|
process.argv = ['node', 'script.js'];
|
|
1450
1459
|
const argv = await parseArguments({});
|
|
1451
|
-
const config = await loadCliConfig({},
|
|
1460
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1452
1461
|
expect(config.isInteractive()).toBe(true);
|
|
1453
1462
|
});
|
|
1454
1463
|
it('should be interactive if prompt-interactive is set', async () => {
|
|
1455
1464
|
process.stdin.isTTY = false;
|
|
1456
1465
|
process.argv = ['node', 'script.js', '--prompt-interactive', 'test'];
|
|
1457
1466
|
const argv = await parseArguments({});
|
|
1458
|
-
const config = await loadCliConfig({},
|
|
1467
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1459
1468
|
expect(config.isInteractive()).toBe(true);
|
|
1460
1469
|
});
|
|
1461
1470
|
it('should not be interactive if not isTTY and no prompt', async () => {
|
|
1462
1471
|
process.stdin.isTTY = false;
|
|
1463
1472
|
process.argv = ['node', 'script.js'];
|
|
1464
1473
|
const argv = await parseArguments({});
|
|
1465
|
-
const config = await loadCliConfig({},
|
|
1474
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1466
1475
|
expect(config.isInteractive()).toBe(false);
|
|
1467
1476
|
});
|
|
1468
1477
|
it('should not be interactive if prompt is set', async () => {
|
|
1469
1478
|
process.stdin.isTTY = true;
|
|
1470
1479
|
process.argv = ['node', 'script.js', '--prompt', 'test'];
|
|
1471
1480
|
const argv = await parseArguments({});
|
|
1472
|
-
const config = await loadCliConfig({},
|
|
1481
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1473
1482
|
expect(config.isInteractive()).toBe(false);
|
|
1474
1483
|
});
|
|
1475
1484
|
it('should not be interactive if positional prompt words are provided with other flags', async () => {
|
|
1476
1485
|
process.stdin.isTTY = true;
|
|
1477
|
-
process.argv = ['node', 'script.js', '--model', 'gemini-
|
|
1486
|
+
process.argv = ['node', 'script.js', '--model', 'gemini-2.5-pro', 'Hello'];
|
|
1478
1487
|
const argv = await parseArguments({});
|
|
1479
|
-
const config = await loadCliConfig({},
|
|
1488
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1480
1489
|
expect(config.isInteractive()).toBe(false);
|
|
1481
1490
|
});
|
|
1482
1491
|
it('should not be interactive if positional prompt words are provided with multiple flags', async () => {
|
|
@@ -1485,12 +1494,12 @@ describe('loadCliConfig interactive', () => {
|
|
|
1485
1494
|
'node',
|
|
1486
1495
|
'script.js',
|
|
1487
1496
|
'--model',
|
|
1488
|
-
'gemini-
|
|
1497
|
+
'gemini-2.5-pro',
|
|
1489
1498
|
'--yolo',
|
|
1490
1499
|
'Hello world',
|
|
1491
1500
|
];
|
|
1492
1501
|
const argv = await parseArguments({});
|
|
1493
|
-
const config = await loadCliConfig({},
|
|
1502
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1494
1503
|
expect(config.isInteractive()).toBe(false);
|
|
1495
1504
|
// Verify the question is preserved for one-shot execution
|
|
1496
1505
|
expect(argv.prompt).toBe('Hello world');
|
|
@@ -1500,7 +1509,7 @@ describe('loadCliConfig interactive', () => {
|
|
|
1500
1509
|
process.stdin.isTTY = true;
|
|
1501
1510
|
process.argv = ['node', 'script.js', '-e', 'none', 'hello'];
|
|
1502
1511
|
const argv = await parseArguments({});
|
|
1503
|
-
const config = await loadCliConfig({},
|
|
1512
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1504
1513
|
expect(config.isInteractive()).toBe(false);
|
|
1505
1514
|
expect(argv.query).toBe('hello');
|
|
1506
1515
|
expect(argv.extensions).toEqual(['none']);
|
|
@@ -1509,7 +1518,7 @@ describe('loadCliConfig interactive', () => {
|
|
|
1509
1518
|
process.stdin.isTTY = true;
|
|
1510
1519
|
process.argv = ['node', 'script.js', 'hello world how are you'];
|
|
1511
1520
|
const argv = await parseArguments({});
|
|
1512
|
-
const config = await loadCliConfig({},
|
|
1521
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1513
1522
|
expect(config.isInteractive()).toBe(false);
|
|
1514
1523
|
expect(argv.query).toBe('hello world how are you');
|
|
1515
1524
|
expect(argv.prompt).toBe('hello world how are you');
|
|
@@ -1520,7 +1529,7 @@ describe('loadCliConfig interactive', () => {
|
|
|
1520
1529
|
'node',
|
|
1521
1530
|
'script.js',
|
|
1522
1531
|
'--model',
|
|
1523
|
-
'gemini-
|
|
1532
|
+
'gemini-2.5-pro',
|
|
1524
1533
|
'write',
|
|
1525
1534
|
'a',
|
|
1526
1535
|
'function',
|
|
@@ -1529,16 +1538,16 @@ describe('loadCliConfig interactive', () => {
|
|
|
1529
1538
|
'array',
|
|
1530
1539
|
];
|
|
1531
1540
|
const argv = await parseArguments({});
|
|
1532
|
-
const config = await loadCliConfig({},
|
|
1541
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1533
1542
|
expect(config.isInteractive()).toBe(false);
|
|
1534
1543
|
expect(argv.query).toBe('write a function to sort array');
|
|
1535
|
-
expect(argv.model).toBe('gemini-
|
|
1544
|
+
expect(argv.model).toBe('gemini-2.5-pro');
|
|
1536
1545
|
});
|
|
1537
1546
|
it('should handle empty positional arguments', async () => {
|
|
1538
1547
|
process.stdin.isTTY = true;
|
|
1539
1548
|
process.argv = ['node', 'script.js', ''];
|
|
1540
1549
|
const argv = await parseArguments({});
|
|
1541
|
-
const config = await loadCliConfig({},
|
|
1550
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1542
1551
|
expect(config.isInteractive()).toBe(true);
|
|
1543
1552
|
expect(argv.query).toBeUndefined();
|
|
1544
1553
|
});
|
|
@@ -1556,16 +1565,16 @@ describe('loadCliConfig interactive', () => {
|
|
|
1556
1565
|
'you',
|
|
1557
1566
|
];
|
|
1558
1567
|
const argv = await parseArguments({});
|
|
1559
|
-
const config = await loadCliConfig({},
|
|
1568
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1560
1569
|
expect(config.isInteractive()).toBe(false);
|
|
1561
1570
|
expect(argv.query).toBe('hello world how are you');
|
|
1562
1571
|
expect(argv.extensions).toEqual(['none']);
|
|
1563
1572
|
});
|
|
1564
1573
|
it('should be interactive if no positional prompt words are provided with flags', async () => {
|
|
1565
1574
|
process.stdin.isTTY = true;
|
|
1566
|
-
process.argv = ['node', 'script.js', '--model', 'gemini-
|
|
1575
|
+
process.argv = ['node', 'script.js', '--model', 'gemini-2.5-pro'];
|
|
1567
1576
|
const argv = await parseArguments({});
|
|
1568
|
-
const config = await loadCliConfig({},
|
|
1577
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1569
1578
|
expect(config.isInteractive()).toBe(true);
|
|
1570
1579
|
});
|
|
1571
1580
|
});
|
|
@@ -1580,6 +1589,7 @@ describe('loadCliConfig approval mode', () => {
|
|
|
1580
1589
|
isTrusted: true,
|
|
1581
1590
|
source: undefined,
|
|
1582
1591
|
});
|
|
1592
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1583
1593
|
});
|
|
1584
1594
|
afterEach(() => {
|
|
1585
1595
|
process.argv = originalArgv;
|
|
@@ -1589,37 +1599,37 @@ describe('loadCliConfig approval mode', () => {
|
|
|
1589
1599
|
it('should default to DEFAULT approval mode when no flags are set', async () => {
|
|
1590
1600
|
process.argv = ['node', 'script.js'];
|
|
1591
1601
|
const argv = await parseArguments({});
|
|
1592
|
-
const config = await loadCliConfig({},
|
|
1602
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1593
1603
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1594
1604
|
});
|
|
1595
1605
|
it('should set YOLO approval mode when --yolo flag is used', async () => {
|
|
1596
1606
|
process.argv = ['node', 'script.js', '--yolo'];
|
|
1597
1607
|
const argv = await parseArguments({});
|
|
1598
|
-
const config = await loadCliConfig({},
|
|
1608
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1599
1609
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.YOLO);
|
|
1600
1610
|
});
|
|
1601
1611
|
it('should set YOLO approval mode when -y flag is used', async () => {
|
|
1602
1612
|
process.argv = ['node', 'script.js', '-y'];
|
|
1603
1613
|
const argv = await parseArguments({});
|
|
1604
|
-
const config = await loadCliConfig({},
|
|
1614
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1605
1615
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.YOLO);
|
|
1606
1616
|
});
|
|
1607
1617
|
it('should set DEFAULT approval mode when --approval-mode=default', async () => {
|
|
1608
1618
|
process.argv = ['node', 'script.js', '--approval-mode', 'default'];
|
|
1609
1619
|
const argv = await parseArguments({});
|
|
1610
|
-
const config = await loadCliConfig({},
|
|
1620
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1611
1621
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1612
1622
|
});
|
|
1613
1623
|
it('should set AUTO_EDIT approval mode when --approval-mode=auto_edit', async () => {
|
|
1614
1624
|
process.argv = ['node', 'script.js', '--approval-mode', 'auto_edit'];
|
|
1615
1625
|
const argv = await parseArguments({});
|
|
1616
|
-
const config = await loadCliConfig({},
|
|
1626
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1617
1627
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.AUTO_EDIT);
|
|
1618
1628
|
});
|
|
1619
1629
|
it('should set YOLO approval mode when --approval-mode=yolo', async () => {
|
|
1620
1630
|
process.argv = ['node', 'script.js', '--approval-mode', 'yolo'];
|
|
1621
1631
|
const argv = await parseArguments({});
|
|
1622
|
-
const config = await loadCliConfig({},
|
|
1632
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1623
1633
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.YOLO);
|
|
1624
1634
|
});
|
|
1625
1635
|
it('should prioritize --approval-mode over --yolo when both would be valid (but validation prevents this)', async () => {
|
|
@@ -1629,13 +1639,13 @@ describe('loadCliConfig approval mode', () => {
|
|
|
1629
1639
|
const argv = await parseArguments({});
|
|
1630
1640
|
// Manually set yolo to true to simulate what would happen if validation didn't prevent it
|
|
1631
1641
|
argv.yolo = true;
|
|
1632
|
-
const config = await loadCliConfig({},
|
|
1642
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1633
1643
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1634
1644
|
});
|
|
1635
1645
|
it('should fall back to --yolo behavior when --approval-mode is not set', async () => {
|
|
1636
1646
|
process.argv = ['node', 'script.js', '--yolo'];
|
|
1637
1647
|
const argv = await parseArguments({});
|
|
1638
|
-
const config = await loadCliConfig({},
|
|
1648
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1639
1649
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.YOLO);
|
|
1640
1650
|
});
|
|
1641
1651
|
// --- Untrusted Folder Scenarios ---
|
|
@@ -1649,25 +1659,25 @@ describe('loadCliConfig approval mode', () => {
|
|
|
1649
1659
|
it('should override --approval-mode=yolo to DEFAULT', async () => {
|
|
1650
1660
|
process.argv = ['node', 'script.js', '--approval-mode', 'yolo'];
|
|
1651
1661
|
const argv = await parseArguments({});
|
|
1652
|
-
const config = await loadCliConfig({},
|
|
1662
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1653
1663
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1654
1664
|
});
|
|
1655
1665
|
it('should override --approval-mode=auto_edit to DEFAULT', async () => {
|
|
1656
1666
|
process.argv = ['node', 'script.js', '--approval-mode', 'auto_edit'];
|
|
1657
1667
|
const argv = await parseArguments({});
|
|
1658
|
-
const config = await loadCliConfig({},
|
|
1668
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1659
1669
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1660
1670
|
});
|
|
1661
1671
|
it('should override --yolo flag to DEFAULT', async () => {
|
|
1662
1672
|
process.argv = ['node', 'script.js', '--yolo'];
|
|
1663
1673
|
const argv = await parseArguments({});
|
|
1664
|
-
const config = await loadCliConfig({},
|
|
1674
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1665
1675
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1666
1676
|
});
|
|
1667
1677
|
it('should remain DEFAULT when --approval-mode=default', async () => {
|
|
1668
1678
|
process.argv = ['node', 'script.js', '--approval-mode', 'default'];
|
|
1669
1679
|
const argv = await parseArguments({});
|
|
1670
|
-
const config = await loadCliConfig({},
|
|
1680
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1671
1681
|
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1672
1682
|
});
|
|
1673
1683
|
});
|
|
@@ -1679,6 +1689,7 @@ describe('loadCliConfig fileFiltering', () => {
|
|
|
1679
1689
|
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1680
1690
|
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1681
1691
|
process.argv = ['node', 'script.js']; // Reset argv for each test
|
|
1692
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1682
1693
|
});
|
|
1683
1694
|
afterEach(() => {
|
|
1684
1695
|
process.argv = originalArgv;
|
|
@@ -1734,33 +1745,39 @@ describe('loadCliConfig fileFiltering', () => {
|
|
|
1734
1745
|
},
|
|
1735
1746
|
};
|
|
1736
1747
|
const argv = await parseArguments(settings);
|
|
1737
|
-
const config = await loadCliConfig(settings,
|
|
1748
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1738
1749
|
expect(getter(config)).toBe(value);
|
|
1739
1750
|
});
|
|
1740
1751
|
});
|
|
1741
1752
|
describe('Output format', () => {
|
|
1753
|
+
beforeEach(() => {
|
|
1754
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1755
|
+
});
|
|
1756
|
+
afterEach(() => {
|
|
1757
|
+
vi.resetAllMocks();
|
|
1758
|
+
});
|
|
1742
1759
|
it('should default to TEXT', async () => {
|
|
1743
1760
|
process.argv = ['node', 'script.js'];
|
|
1744
1761
|
const argv = await parseArguments({});
|
|
1745
|
-
const config = await loadCliConfig({},
|
|
1762
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1746
1763
|
expect(config.getOutputFormat()).toBe(OutputFormat.TEXT);
|
|
1747
1764
|
});
|
|
1748
1765
|
it('should use the format from settings', async () => {
|
|
1749
1766
|
process.argv = ['node', 'script.js'];
|
|
1750
1767
|
const argv = await parseArguments({});
|
|
1751
|
-
const config = await loadCliConfig({ output: { format: OutputFormat.JSON } },
|
|
1768
|
+
const config = await loadCliConfig({ output: { format: OutputFormat.JSON } }, 'test-session', argv);
|
|
1752
1769
|
expect(config.getOutputFormat()).toBe(OutputFormat.JSON);
|
|
1753
1770
|
});
|
|
1754
1771
|
it('should prioritize the format from argv', async () => {
|
|
1755
1772
|
process.argv = ['node', 'script.js', '--output-format', 'json'];
|
|
1756
1773
|
const argv = await parseArguments({});
|
|
1757
|
-
const config = await loadCliConfig({ output: { format: OutputFormat.JSON } },
|
|
1774
|
+
const config = await loadCliConfig({ output: { format: OutputFormat.JSON } }, 'test-session', argv);
|
|
1758
1775
|
expect(config.getOutputFormat()).toBe(OutputFormat.JSON);
|
|
1759
1776
|
});
|
|
1760
1777
|
it('should accept stream-json as a valid output format', async () => {
|
|
1761
1778
|
process.argv = ['node', 'script.js', '--output-format', 'stream-json'];
|
|
1762
1779
|
const argv = await parseArguments({});
|
|
1763
|
-
const config = await loadCliConfig({},
|
|
1780
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1764
1781
|
expect(config.getOutputFormat()).toBe(OutputFormat.STREAM_JSON);
|
|
1765
1782
|
});
|
|
1766
1783
|
it('should error on invalid --output-format argument', async () => {
|
|
@@ -1826,12 +1843,18 @@ describe('parseArguments with positional prompt', () => {
|
|
|
1826
1843
|
});
|
|
1827
1844
|
});
|
|
1828
1845
|
describe('Telemetry configuration via environment variables', () => {
|
|
1846
|
+
beforeEach(() => {
|
|
1847
|
+
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
1848
|
+
});
|
|
1849
|
+
afterEach(() => {
|
|
1850
|
+
vi.resetAllMocks();
|
|
1851
|
+
});
|
|
1829
1852
|
it('should prioritize CELL_TELEMETRY_ENABLED over settings', async () => {
|
|
1830
1853
|
vi.stubEnv('CELL_TELEMETRY_ENABLED', 'true');
|
|
1831
1854
|
process.argv = ['node', 'script.js'];
|
|
1832
1855
|
const argv = await parseArguments({});
|
|
1833
1856
|
const settings = { telemetry: { enabled: false } };
|
|
1834
|
-
const config = await loadCliConfig(settings,
|
|
1857
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1835
1858
|
expect(config.getTelemetryEnabled()).toBe(true);
|
|
1836
1859
|
});
|
|
1837
1860
|
it('should prioritize CELL_TELEMETRY_TARGET over settings', async () => {
|
|
@@ -1841,7 +1864,7 @@ describe('Telemetry configuration via environment variables', () => {
|
|
|
1841
1864
|
const settings = {
|
|
1842
1865
|
telemetry: { target: ServerConfig.TelemetryTarget.LOCAL },
|
|
1843
1866
|
};
|
|
1844
|
-
const config = await loadCliConfig(settings,
|
|
1867
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1845
1868
|
expect(config.getTelemetryTarget()).toBe('gcp');
|
|
1846
1869
|
});
|
|
1847
1870
|
it('should throw when CELL_TELEMETRY_TARGET is invalid', async () => {
|
|
@@ -1851,7 +1874,7 @@ describe('Telemetry configuration via environment variables', () => {
|
|
|
1851
1874
|
const settings = {
|
|
1852
1875
|
telemetry: { target: ServerConfig.TelemetryTarget.GCP },
|
|
1853
1876
|
};
|
|
1854
|
-
await expect(loadCliConfig(settings,
|
|
1877
|
+
await expect(loadCliConfig(settings, 'test-session', argv)).rejects.toThrow(/Invalid telemetry configuration: .*Invalid telemetry target/i);
|
|
1855
1878
|
vi.unstubAllEnvs();
|
|
1856
1879
|
});
|
|
1857
1880
|
it('should prioritize CELL_TELEMETRY_OTLP_ENDPOINT over settings and default env var', async () => {
|
|
@@ -1862,7 +1885,7 @@ describe('Telemetry configuration via environment variables', () => {
|
|
|
1862
1885
|
const settings = {
|
|
1863
1886
|
telemetry: { otlpEndpoint: 'http://settings.com' },
|
|
1864
1887
|
};
|
|
1865
|
-
const config = await loadCliConfig(settings,
|
|
1888
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1866
1889
|
expect(config.getTelemetryOtlpEndpoint()).toBe('http://gemini.env.com');
|
|
1867
1890
|
});
|
|
1868
1891
|
it('should prioritize CELL_TELEMETRY_OTLP_PROTOCOL over settings', async () => {
|
|
@@ -1870,7 +1893,7 @@ describe('Telemetry configuration via environment variables', () => {
|
|
|
1870
1893
|
process.argv = ['node', 'script.js'];
|
|
1871
1894
|
const argv = await parseArguments({});
|
|
1872
1895
|
const settings = { telemetry: { otlpProtocol: 'grpc' } };
|
|
1873
|
-
const config = await loadCliConfig(settings,
|
|
1896
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1874
1897
|
expect(config.getTelemetryOtlpProtocol()).toBe('http');
|
|
1875
1898
|
});
|
|
1876
1899
|
it('should prioritize CELL_TELEMETRY_LOG_PROMPTS over settings', async () => {
|
|
@@ -1878,7 +1901,7 @@ describe('Telemetry configuration via environment variables', () => {
|
|
|
1878
1901
|
process.argv = ['node', 'script.js'];
|
|
1879
1902
|
const argv = await parseArguments({});
|
|
1880
1903
|
const settings = { telemetry: { logPrompts: true } };
|
|
1881
|
-
const config = await loadCliConfig(settings,
|
|
1904
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1882
1905
|
expect(config.getTelemetryLogPromptsEnabled()).toBe(false);
|
|
1883
1906
|
});
|
|
1884
1907
|
it('should prioritize CELL_TELEMETRY_OUTFILE over settings', async () => {
|
|
@@ -1888,7 +1911,7 @@ describe('Telemetry configuration via environment variables', () => {
|
|
|
1888
1911
|
const settings = {
|
|
1889
1912
|
telemetry: { outfile: '/settings/telemetry.log' },
|
|
1890
1913
|
};
|
|
1891
|
-
const config = await loadCliConfig(settings,
|
|
1914
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1892
1915
|
expect(config.getTelemetryOutfile()).toBe('/gemini/env/telemetry.log');
|
|
1893
1916
|
});
|
|
1894
1917
|
it('should prioritize CELL_TELEMETRY_USE_COLLECTOR over settings', async () => {
|
|
@@ -1896,7 +1919,7 @@ describe('Telemetry configuration via environment variables', () => {
|
|
|
1896
1919
|
process.argv = ['node', 'script.js'];
|
|
1897
1920
|
const argv = await parseArguments({});
|
|
1898
1921
|
const settings = { telemetry: { useCollector: false } };
|
|
1899
|
-
const config = await loadCliConfig(settings,
|
|
1922
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1900
1923
|
expect(config.getTelemetryUseCollector()).toBe(true);
|
|
1901
1924
|
});
|
|
1902
1925
|
it('should use settings value when CELL_TELEMETRY_ENABLED is not set', async () => {
|
|
@@ -1904,7 +1927,7 @@ describe('Telemetry configuration via environment variables', () => {
|
|
|
1904
1927
|
process.argv = ['node', 'script.js'];
|
|
1905
1928
|
const argv = await parseArguments({});
|
|
1906
1929
|
const settings = { telemetry: { enabled: true } };
|
|
1907
|
-
const config = await loadCliConfig(settings,
|
|
1930
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1908
1931
|
expect(config.getTelemetryEnabled()).toBe(true);
|
|
1909
1932
|
});
|
|
1910
1933
|
it('should use settings value when CELL_TELEMETRY_TARGET is not set', async () => {
|
|
@@ -1914,35 +1937,35 @@ describe('Telemetry configuration via environment variables', () => {
|
|
|
1914
1937
|
const settings = {
|
|
1915
1938
|
telemetry: { target: ServerConfig.TelemetryTarget.LOCAL },
|
|
1916
1939
|
};
|
|
1917
|
-
const config = await loadCliConfig(settings,
|
|
1940
|
+
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
1918
1941
|
expect(config.getTelemetryTarget()).toBe('local');
|
|
1919
1942
|
});
|
|
1920
1943
|
it("should treat CELL_TELEMETRY_ENABLED='1' as true", async () => {
|
|
1921
1944
|
vi.stubEnv('CELL_TELEMETRY_ENABLED', '1');
|
|
1922
1945
|
process.argv = ['node', 'script.js'];
|
|
1923
1946
|
const argv = await parseArguments({});
|
|
1924
|
-
const config = await loadCliConfig({},
|
|
1947
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1925
1948
|
expect(config.getTelemetryEnabled()).toBe(true);
|
|
1926
1949
|
});
|
|
1927
1950
|
it("should treat CELL_TELEMETRY_ENABLED='0' as false", async () => {
|
|
1928
1951
|
vi.stubEnv('CELL_TELEMETRY_ENABLED', '0');
|
|
1929
1952
|
process.argv = ['node', 'script.js'];
|
|
1930
1953
|
const argv = await parseArguments({});
|
|
1931
|
-
const config = await loadCliConfig({ telemetry: { enabled: true } },
|
|
1954
|
+
const config = await loadCliConfig({ telemetry: { enabled: true } }, 'test-session', argv);
|
|
1932
1955
|
expect(config.getTelemetryEnabled()).toBe(false);
|
|
1933
1956
|
});
|
|
1934
1957
|
it("should treat CELL_TELEMETRY_LOG_PROMPTS='1' as true", async () => {
|
|
1935
1958
|
vi.stubEnv('CELL_TELEMETRY_LOG_PROMPTS', '1');
|
|
1936
1959
|
process.argv = ['node', 'script.js'];
|
|
1937
1960
|
const argv = await parseArguments({});
|
|
1938
|
-
const config = await loadCliConfig({},
|
|
1961
|
+
const config = await loadCliConfig({}, 'test-session', argv);
|
|
1939
1962
|
expect(config.getTelemetryLogPromptsEnabled()).toBe(true);
|
|
1940
1963
|
});
|
|
1941
1964
|
it("should treat CELL_TELEMETRY_LOG_PROMPTS='false' as false", async () => {
|
|
1942
1965
|
vi.stubEnv('CELL_TELEMETRY_LOG_PROMPTS', 'false');
|
|
1943
1966
|
process.argv = ['node', 'script.js'];
|
|
1944
1967
|
const argv = await parseArguments({});
|
|
1945
|
-
const config = await loadCliConfig({ telemetry: { logPrompts: true } },
|
|
1968
|
+
const config = await loadCliConfig({ telemetry: { logPrompts: true } }, 'test-session', argv);
|
|
1946
1969
|
expect(config.getTelemetryLogPromptsEnabled()).toBe(false);
|
|
1947
1970
|
});
|
|
1948
1971
|
});
|