fss-link 1.0.49 → 1.0.51
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/index.js +0 -0
- package/dist/package.json +2 -2
- package/dist/src/config/auth.js +8 -5
- package/dist/src/config/auth.js.map +1 -1
- package/dist/src/config/database.d.ts +103 -11
- package/dist/src/config/database.js +301 -59
- package/dist/src/config/database.js.map +1 -1
- package/dist/src/config/databaseBackup.d.ts +114 -0
- package/dist/src/config/databaseBackup.js +334 -0
- package/dist/src/config/databaseBackup.js.map +1 -0
- package/dist/src/config/databaseMigrations.d.ts +63 -0
- package/dist/src/config/databaseMigrations.js +379 -0
- package/dist/src/config/databaseMigrations.js.map +1 -0
- package/dist/src/config/databasePool.d.ts +70 -0
- package/dist/src/config/databasePool.js +193 -0
- package/dist/src/config/databasePool.js.map +1 -0
- package/dist/src/config/queryOptimizer.d.ts +127 -0
- package/dist/src/config/queryOptimizer.js +309 -0
- package/dist/src/config/queryOptimizer.js.map +1 -0
- package/dist/src/utils/sandbox.js +2 -8
- package/dist/src/utils/sandbox.js.map +1 -1
- package/dist/src/validateNonInterActiveAuth.js +3 -7
- package/dist/src/validateNonInterActiveAuth.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/commands/mcp/add.test.ts +0 -122
- package/dist/commands/mcp/add.ts +0 -222
- package/dist/commands/mcp/list.test.ts +0 -154
- package/dist/commands/mcp/list.ts +0 -139
- package/dist/commands/mcp/remove.test.ts +0 -69
- package/dist/commands/mcp/remove.ts +0 -60
- package/dist/commands/mcp.test.ts +0 -55
- package/dist/commands/mcp.ts +0 -27
- package/dist/config/apiValidation.test.ts +0 -118
- package/dist/config/auth.test.ts +0 -79
- package/dist/config/auth.ts +0 -100
- package/dist/config/config.integration.test.ts +0 -407
- package/dist/config/config.test.ts +0 -1952
- package/dist/config/config.ts +0 -690
- package/dist/config/database.test.ts +0 -96
- package/dist/config/database.ts +0 -824
- package/dist/config/extension.test.ts +0 -236
- package/dist/config/extension.ts +0 -180
- package/dist/config/keyBindings.test.ts +0 -62
- package/dist/config/keyBindings.ts +0 -184
- package/dist/config/modelManager.ts +0 -326
- package/dist/config/providerManager.ts +0 -244
- package/dist/config/providerPersistence.test.ts +0 -377
- package/dist/config/providerPersistence.ts +0 -105
- package/dist/config/sandboxConfig.ts +0 -107
- package/dist/config/settings.test.ts +0 -1424
- package/dist/config/settings.ts +0 -517
- package/dist/config/settingsSchema.test.ts +0 -252
- package/dist/config/settingsSchema.ts +0 -728
- package/dist/config/trustedFolders.test.ts +0 -208
- package/dist/config/trustedFolders.ts +0 -167
- package/dist/gemini.test.tsx +0 -252
- package/dist/gemini.tsx +0 -357
- package/dist/generated/git-commit.ts +0 -10
- package/dist/index.ts +0 -21
- package/dist/nonInteractiveCli.test.ts +0 -276
- package/dist/nonInteractiveCli.ts +0 -143
- package/dist/patches/is-in-ci.ts +0 -17
- package/dist/services/BuiltinCommandLoader.test.ts +0 -127
- package/dist/services/BuiltinCommandLoader.ts +0 -95
- package/dist/services/CommandService.test.ts +0 -352
- package/dist/services/CommandService.ts +0 -103
- package/dist/services/FileCommandLoader.test.ts +0 -1002
- package/dist/services/FileCommandLoader.ts +0 -289
- package/dist/services/McpPromptLoader.ts +0 -231
- package/dist/services/SearchEngineConfigProvider.ts +0 -100
- package/dist/services/prompt-processors/argumentProcessor.test.ts +0 -41
- package/dist/services/prompt-processors/argumentProcessor.ts +0 -23
- package/dist/services/prompt-processors/shellProcessor.test.ts +0 -709
- package/dist/services/prompt-processors/shellProcessor.ts +0 -248
- package/dist/services/prompt-processors/types.ts +0 -44
- package/dist/services/types.ts +0 -24
- package/dist/src/config/apiValidation.test.d.ts +0 -6
- package/dist/src/config/apiValidation.test.js +0 -99
- package/dist/src/config/apiValidation.test.js.map +0 -1
- package/dist/src/config/database.test.d.ts +0 -6
- package/dist/src/config/database.test.js +0 -80
- package/dist/src/config/database.test.js.map +0 -1
- package/dist/src/config/providerManager.d.ts +0 -74
- package/dist/src/config/providerManager.js +0 -203
- package/dist/src/config/providerManager.js.map +0 -1
- package/dist/src/config/providerPersistence.test.d.ts +0 -6
- package/dist/src/config/providerPersistence.test.js +0 -283
- package/dist/src/config/providerPersistence.test.js.map +0 -1
- package/dist/src/ui/components/GeminiKeyDialog.d.ts +0 -11
- package/dist/src/ui/components/GeminiKeyDialog.js +0 -156
- package/dist/src/ui/components/GeminiKeyDialog.js.map +0 -1
- package/dist/src/ui/components/OpenAIEndpointDialog.d.ts +0 -19
- package/dist/src/ui/components/OpenAIEndpointDialog.js +0 -163
- package/dist/src/ui/components/OpenAIEndpointDialog.js.map +0 -1
- package/dist/test-setup.ts +0 -12
- package/dist/test-utils/customMatchers.ts +0 -65
- package/dist/test-utils/mockCommandContext.test.ts +0 -62
- package/dist/test-utils/mockCommandContext.ts +0 -105
- package/dist/test-utils/render.tsx +0 -18
- package/dist/ui/App.test.tsx +0 -2181
- package/dist/ui/App.tsx +0 -1344
- package/dist/ui/IdeIntegrationNudge.tsx +0 -98
- package/dist/ui/__snapshots__/App.test.tsx.snap +0 -124
- package/dist/ui/colors.ts +0 -56
- package/dist/ui/commands/aboutCommand.test.ts +0 -153
- package/dist/ui/commands/aboutCommand.ts +0 -49
- package/dist/ui/commands/authCommand.test.ts +0 -36
- package/dist/ui/commands/authCommand.ts +0 -17
- package/dist/ui/commands/bugCommand.test.ts +0 -114
- package/dist/ui/commands/bugCommand.ts +0 -92
- package/dist/ui/commands/chatCommand.test.ts +0 -414
- package/dist/ui/commands/chatCommand.ts +0 -280
- package/dist/ui/commands/clearCommand.test.ts +0 -100
- package/dist/ui/commands/clearCommand.ts +0 -29
- package/dist/ui/commands/compressCommand.test.ts +0 -129
- package/dist/ui/commands/compressCommand.ts +0 -78
- package/dist/ui/commands/contextCommand.ts +0 -132
- package/dist/ui/commands/copyCommand.test.ts +0 -296
- package/dist/ui/commands/copyCommand.ts +0 -67
- package/dist/ui/commands/corgiCommand.test.ts +0 -34
- package/dist/ui/commands/corgiCommand.ts +0 -16
- package/dist/ui/commands/directoryCommand.test.tsx +0 -185
- package/dist/ui/commands/directoryCommand.tsx +0 -179
- package/dist/ui/commands/docsCommand.test.ts +0 -99
- package/dist/ui/commands/docsCommand.ts +0 -42
- package/dist/ui/commands/editorCommand.test.ts +0 -30
- package/dist/ui/commands/editorCommand.ts +0 -21
- package/dist/ui/commands/extensionsCommand.test.ts +0 -67
- package/dist/ui/commands/extensionsCommand.ts +0 -46
- package/dist/ui/commands/helpCommand.test.ts +0 -52
- package/dist/ui/commands/helpCommand.ts +0 -23
- package/dist/ui/commands/ideCommand.test.ts +0 -255
- package/dist/ui/commands/ideCommand.ts +0 -283
- package/dist/ui/commands/initCommand.test.ts +0 -127
- package/dist/ui/commands/initCommand.ts +0 -117
- package/dist/ui/commands/mcpCommand.test.ts +0 -1057
- package/dist/ui/commands/mcpCommand.ts +0 -531
- package/dist/ui/commands/memoryCommand.test.ts +0 -344
- package/dist/ui/commands/memoryCommand.ts +0 -305
- package/dist/ui/commands/privacyCommand.test.ts +0 -38
- package/dist/ui/commands/privacyCommand.ts +0 -17
- package/dist/ui/commands/quitCommand.test.ts +0 -55
- package/dist/ui/commands/quitCommand.ts +0 -36
- package/dist/ui/commands/restoreCommand.test.ts +0 -250
- package/dist/ui/commands/restoreCommand.ts +0 -157
- package/dist/ui/commands/searchEngineSetupCommand.ts +0 -18
- package/dist/ui/commands/settingsCommand.test.ts +0 -36
- package/dist/ui/commands/settingsCommand.ts +0 -17
- package/dist/ui/commands/setupGithubCommand.test.ts +0 -238
- package/dist/ui/commands/setupGithubCommand.ts +0 -212
- package/dist/ui/commands/speakCommand.ts +0 -175
- package/dist/ui/commands/statsCommand.test.ts +0 -78
- package/dist/ui/commands/statsCommand.ts +0 -70
- package/dist/ui/commands/terminalSetupCommand.test.ts +0 -85
- package/dist/ui/commands/terminalSetupCommand.ts +0 -45
- package/dist/ui/commands/themeCommand.test.ts +0 -38
- package/dist/ui/commands/themeCommand.ts +0 -17
- package/dist/ui/commands/toolsCommand.test.ts +0 -105
- package/dist/ui/commands/toolsCommand.ts +0 -71
- package/dist/ui/commands/ttsCommand.ts +0 -143
- package/dist/ui/commands/types.ts +0 -204
- package/dist/ui/commands/vimCommand.ts +0 -25
- package/dist/ui/commands/voiceCommand.ts +0 -125
- package/dist/ui/components/AboutBox.tsx +0 -133
- package/dist/ui/components/AsciiArt.ts +0 -54
- package/dist/ui/components/AuthDialog.test.tsx +0 -334
- package/dist/ui/components/AuthDialog.tsx +0 -289
- package/dist/ui/components/AuthInProgress.tsx +0 -62
- package/dist/ui/components/AutoAcceptIndicator.tsx +0 -47
- package/dist/ui/components/ConsoleSummaryDisplay.tsx +0 -35
- package/dist/ui/components/ContextSummaryDisplay.test.tsx +0 -85
- package/dist/ui/components/ContextSummaryDisplay.tsx +0 -120
- package/dist/ui/components/ContextUsageDisplay.tsx +0 -77
- package/dist/ui/components/DebugProfiler.tsx +0 -36
- package/dist/ui/components/DetailedMessagesDisplay.tsx +0 -82
- package/dist/ui/components/EditorSettingsDialog.tsx +0 -172
- package/dist/ui/components/FolderTrustDialog.test.tsx +0 -36
- package/dist/ui/components/FolderTrustDialog.tsx +0 -74
- package/dist/ui/components/Footer.test.tsx +0 -159
- package/dist/ui/components/Footer.tsx +0 -158
- package/dist/ui/components/GeminiKeyDialog.tsx +0 -252
- package/dist/ui/components/GeminiRespondingSpinner.tsx +0 -34
- package/dist/ui/components/Header.test.tsx +0 -44
- package/dist/ui/components/Header.tsx +0 -70
- package/dist/ui/components/Help.tsx +0 -174
- package/dist/ui/components/HistoryItemDisplay.test.tsx +0 -125
- package/dist/ui/components/HistoryItemDisplay.tsx +0 -98
- package/dist/ui/components/InputPrompt.test.tsx +0 -1467
- package/dist/ui/components/InputPrompt.tsx +0 -641
- package/dist/ui/components/LMStudioModelPrompt.tsx +0 -215
- package/dist/ui/components/LoadingIndicator.test.tsx +0 -296
- package/dist/ui/components/LoadingIndicator.tsx +0 -82
- package/dist/ui/components/MemoryUsageDisplay.tsx +0 -36
- package/dist/ui/components/ModelStatsDisplay.test.tsx +0 -252
- package/dist/ui/components/ModelStatsDisplay.tsx +0 -197
- package/dist/ui/components/OllamaModelPrompt.tsx +0 -206
- package/dist/ui/components/OpenAIEndpointDialog.tsx +0 -261
- package/dist/ui/components/OpenAIKeyPrompt.test.tsx +0 -64
- package/dist/ui/components/OpenAIKeyPrompt.tsx +0 -197
- package/dist/ui/components/PrepareLabel.tsx +0 -48
- package/dist/ui/components/SearchEngineConfigDialog.tsx +0 -280
- package/dist/ui/components/SessionSummaryDisplay.test.tsx +0 -75
- package/dist/ui/components/SessionSummaryDisplay.tsx +0 -18
- package/dist/ui/components/SettingsDialog.test.tsx +0 -865
- package/dist/ui/components/SettingsDialog.tsx +0 -753
- package/dist/ui/components/ShellConfirmationDialog.test.tsx +0 -53
- package/dist/ui/components/ShellConfirmationDialog.tsx +0 -103
- package/dist/ui/components/ShellModeIndicator.tsx +0 -18
- package/dist/ui/components/ShowMoreLines.tsx +0 -40
- package/dist/ui/components/StatsDisplay.test.tsx +0 -401
- package/dist/ui/components/StatsDisplay.tsx +0 -273
- package/dist/ui/components/SuggestionsDisplay.tsx +0 -102
- package/dist/ui/components/ThemeDialog.tsx +0 -310
- package/dist/ui/components/Tips.tsx +0 -45
- package/dist/ui/components/TodoDisplay.test.tsx +0 -97
- package/dist/ui/components/TodoDisplay.tsx +0 -72
- package/dist/ui/components/ToolStatsDisplay.test.tsx +0 -180
- package/dist/ui/components/ToolStatsDisplay.tsx +0 -208
- package/dist/ui/components/UpdateNotification.tsx +0 -23
- package/dist/ui/components/WelcomeBackDialog.tsx +0 -290
- package/dist/ui/components/__snapshots__/IDEContextDetailDisplay.test.tsx.snap +0 -24
- package/dist/ui/components/__snapshots__/ModelStatsDisplay.test.tsx.snap +0 -121
- package/dist/ui/components/__snapshots__/SessionSummaryDisplay.test.tsx.snap +0 -30
- package/dist/ui/components/__snapshots__/ShellConfirmationDialog.test.tsx.snap +0 -21
- package/dist/ui/components/__snapshots__/StatsDisplay.test.tsx.snap +0 -264
- package/dist/ui/components/__snapshots__/ToolStatsDisplay.test.tsx.snap +0 -91
- package/dist/ui/components/messages/CompressionMessage.tsx +0 -49
- package/dist/ui/components/messages/DiffRenderer.test.tsx +0 -365
- package/dist/ui/components/messages/DiffRenderer.tsx +0 -358
- package/dist/ui/components/messages/ErrorMessage.tsx +0 -31
- package/dist/ui/components/messages/GeminiMessage.tsx +0 -43
- package/dist/ui/components/messages/GeminiMessageContent.tsx +0 -43
- package/dist/ui/components/messages/InfoMessage.tsx +0 -32
- package/dist/ui/components/messages/ToolConfirmationMessage.test.tsx +0 -58
- package/dist/ui/components/messages/ToolConfirmationMessage.tsx +0 -297
- package/dist/ui/components/messages/ToolGroupMessage.tsx +0 -126
- package/dist/ui/components/messages/ToolMessage.test.tsx +0 -183
- package/dist/ui/components/messages/ToolMessage.tsx +0 -296
- package/dist/ui/components/messages/UserMessage.tsx +0 -43
- package/dist/ui/components/messages/UserShellMessage.tsx +0 -25
- package/dist/ui/components/shared/MaxSizedBox.test.tsx +0 -425
- package/dist/ui/components/shared/MaxSizedBox.tsx +0 -624
- package/dist/ui/components/shared/RadioButtonSelect.test.tsx +0 -181
- package/dist/ui/components/shared/RadioButtonSelect.tsx +0 -234
- package/dist/ui/components/shared/__snapshots__/RadioButtonSelect.test.tsx.snap +0 -47
- package/dist/ui/components/shared/text-buffer.test.ts +0 -1728
- package/dist/ui/components/shared/text-buffer.ts +0 -2227
- package/dist/ui/components/shared/vim-buffer-actions.test.ts +0 -1119
- package/dist/ui/components/shared/vim-buffer-actions.ts +0 -814
- package/dist/ui/constants.ts +0 -17
- package/dist/ui/contexts/KeypressContext.test.tsx +0 -391
- package/dist/ui/contexts/KeypressContext.tsx +0 -440
- package/dist/ui/contexts/OverflowContext.tsx +0 -87
- package/dist/ui/contexts/SessionContext.test.tsx +0 -132
- package/dist/ui/contexts/SessionContext.tsx +0 -143
- package/dist/ui/contexts/SettingsContext.tsx +0 -20
- package/dist/ui/contexts/StreamingContext.tsx +0 -22
- package/dist/ui/contexts/VimModeContext.tsx +0 -79
- package/dist/ui/editors/editorSettingsManager.ts +0 -66
- package/dist/ui/hooks/atCommandProcessor.test.ts +0 -1102
- package/dist/ui/hooks/atCommandProcessor.ts +0 -485
- package/dist/ui/hooks/shellCommandProcessor.test.ts +0 -481
- package/dist/ui/hooks/shellCommandProcessor.ts +0 -314
- package/dist/ui/hooks/slashCommandProcessor.test.ts +0 -1044
- package/dist/ui/hooks/slashCommandProcessor.ts +0 -595
- package/dist/ui/hooks/useAtCompletion.test.ts +0 -497
- package/dist/ui/hooks/useAtCompletion.ts +0 -244
- package/dist/ui/hooks/useAuthCommand.ts +0 -129
- package/dist/ui/hooks/useAutoAcceptIndicator.test.ts +0 -300
- package/dist/ui/hooks/useAutoAcceptIndicator.ts +0 -52
- package/dist/ui/hooks/useBracketedPaste.ts +0 -37
- package/dist/ui/hooks/useCommandCompletion.test.ts +0 -518
- package/dist/ui/hooks/useCommandCompletion.tsx +0 -238
- package/dist/ui/hooks/useCompletion.ts +0 -128
- package/dist/ui/hooks/useConsoleMessages.test.ts +0 -147
- package/dist/ui/hooks/useConsoleMessages.ts +0 -110
- package/dist/ui/hooks/useEditorSettings.test.ts +0 -283
- package/dist/ui/hooks/useEditorSettings.ts +0 -75
- package/dist/ui/hooks/useFocus.test.ts +0 -119
- package/dist/ui/hooks/useFocus.ts +0 -48
- package/dist/ui/hooks/useFolderTrust.test.ts +0 -159
- package/dist/ui/hooks/useFolderTrust.ts +0 -72
- package/dist/ui/hooks/useGeminiStream.test.tsx +0 -1998
- package/dist/ui/hooks/useGeminiStream.ts +0 -1017
- package/dist/ui/hooks/useGitBranchName.test.ts +0 -280
- package/dist/ui/hooks/useGitBranchName.ts +0 -79
- package/dist/ui/hooks/useHistoryManager.test.ts +0 -202
- package/dist/ui/hooks/useHistoryManager.ts +0 -111
- package/dist/ui/hooks/useInputHistory.test.ts +0 -261
- package/dist/ui/hooks/useInputHistory.ts +0 -111
- package/dist/ui/hooks/useKeypress.test.ts +0 -280
- package/dist/ui/hooks/useKeypress.ts +0 -39
- package/dist/ui/hooks/useKittyKeyboardProtocol.ts +0 -31
- package/dist/ui/hooks/useLoadingIndicator.test.ts +0 -139
- package/dist/ui/hooks/useLoadingIndicator.ts +0 -57
- package/dist/ui/hooks/useLogger.ts +0 -32
- package/dist/ui/hooks/useMessageQueue.test.ts +0 -226
- package/dist/ui/hooks/useMessageQueue.ts +0 -69
- package/dist/ui/hooks/usePhraseCycler.test.ts +0 -145
- package/dist/ui/hooks/usePhraseCycler.ts +0 -198
- package/dist/ui/hooks/usePrivacySettings.test.ts +0 -242
- package/dist/ui/hooks/usePrivacySettings.ts +0 -150
- package/dist/ui/hooks/useReactToolScheduler.ts +0 -309
- package/dist/ui/hooks/useRefreshMemoryCommand.ts +0 -7
- package/dist/ui/hooks/useReverseSearchCompletion.test.tsx +0 -260
- package/dist/ui/hooks/useReverseSearchCompletion.tsx +0 -95
- package/dist/ui/hooks/useSettingsCommand.ts +0 -25
- package/dist/ui/hooks/useShellHistory.test.ts +0 -219
- package/dist/ui/hooks/useShellHistory.ts +0 -133
- package/dist/ui/hooks/useShowMemoryCommand.ts +0 -75
- package/dist/ui/hooks/useSlashCompletion.test.ts +0 -434
- package/dist/ui/hooks/useSlashCompletion.ts +0 -187
- package/dist/ui/hooks/useStateAndRef.ts +0 -36
- package/dist/ui/hooks/useTerminalSize.ts +0 -32
- package/dist/ui/hooks/useThemeCommand.ts +0 -110
- package/dist/ui/hooks/useTimer.test.ts +0 -120
- package/dist/ui/hooks/useTimer.ts +0 -65
- package/dist/ui/hooks/useToolScheduler.test.ts +0 -1123
- package/dist/ui/hooks/useWelcomeBack.ts +0 -253
- package/dist/ui/hooks/vim.test.ts +0 -1691
- package/dist/ui/hooks/vim.ts +0 -784
- package/dist/ui/keyMatchers.test.ts +0 -337
- package/dist/ui/keyMatchers.ts +0 -105
- package/dist/ui/privacy/CloudFreePrivacyNotice.tsx +0 -117
- package/dist/ui/privacy/CloudPaidPrivacyNotice.tsx +0 -59
- package/dist/ui/privacy/GeminiPrivacyNotice.tsx +0 -62
- package/dist/ui/privacy/PrivacyNotice.tsx +0 -42
- package/dist/ui/semantic-colors.ts +0 -26
- package/dist/ui/themes/ansi-light.ts +0 -150
- package/dist/ui/themes/ansi.ts +0 -159
- package/dist/ui/themes/atom-one-dark.ts +0 -147
- package/dist/ui/themes/ayu-light.ts +0 -139
- package/dist/ui/themes/ayu.ts +0 -113
- package/dist/ui/themes/color-utils.test.ts +0 -221
- package/dist/ui/themes/color-utils.ts +0 -231
- package/dist/ui/themes/default-light.ts +0 -108
- package/dist/ui/themes/default.ts +0 -151
- package/dist/ui/themes/dracula.ts +0 -124
- package/dist/ui/themes/fss-code-dark.ts +0 -156
- package/dist/ui/themes/fss-dark.ts +0 -113
- package/dist/ui/themes/fss-light.ts +0 -139
- package/dist/ui/themes/github-dark.ts +0 -147
- package/dist/ui/themes/github-light.ts +0 -149
- package/dist/ui/themes/googlecode.ts +0 -146
- package/dist/ui/themes/no-color.ts +0 -125
- package/dist/ui/themes/qwen-dark.ts +0 -118
- package/dist/ui/themes/qwen-light.ts +0 -144
- package/dist/ui/themes/semantic-tokens.ts +0 -127
- package/dist/ui/themes/shades-of-purple.ts +0 -352
- package/dist/ui/themes/theme-manager.test.ts +0 -99
- package/dist/ui/themes/theme-manager.ts +0 -257
- package/dist/ui/themes/theme.test.ts +0 -97
- package/dist/ui/themes/theme.ts +0 -451
- package/dist/ui/themes/xcode.ts +0 -154
- package/dist/ui/types.ts +0 -255
- package/dist/ui/utils/CodeColorizer.tsx +0 -217
- package/dist/ui/utils/ConsolePatcher.ts +0 -71
- package/dist/ui/utils/InlineMarkdownRenderer.tsx +0 -173
- package/dist/ui/utils/MarkdownDisplay.test.tsx +0 -244
- package/dist/ui/utils/MarkdownDisplay.tsx +0 -415
- package/dist/ui/utils/TableRenderer.tsx +0 -159
- package/dist/ui/utils/__snapshots__/MarkdownDisplay.test.tsx.snap +0 -93
- package/dist/ui/utils/clipboardUtils.test.ts +0 -76
- package/dist/ui/utils/clipboardUtils.ts +0 -149
- package/dist/ui/utils/commandUtils.test.ts +0 -384
- package/dist/ui/utils/commandUtils.ts +0 -106
- package/dist/ui/utils/computeStats.test.ts +0 -292
- package/dist/ui/utils/computeStats.ts +0 -86
- package/dist/ui/utils/displayUtils.test.ts +0 -58
- package/dist/ui/utils/displayUtils.ts +0 -32
- package/dist/ui/utils/formatters.test.ts +0 -72
- package/dist/ui/utils/formatters.ts +0 -63
- package/dist/ui/utils/isNarrowWidth.ts +0 -9
- package/dist/ui/utils/kittyProtocolDetector.ts +0 -105
- package/dist/ui/utils/markdownUtilities.test.ts +0 -50
- package/dist/ui/utils/markdownUtilities.ts +0 -125
- package/dist/ui/utils/platformConstants.ts +0 -52
- package/dist/ui/utils/terminalSetup.ts +0 -342
- package/dist/ui/utils/textUtils.ts +0 -40
- package/dist/ui/utils/updateCheck.test.ts +0 -163
- package/dist/ui/utils/updateCheck.ts +0 -100
- package/dist/utils/checks.ts +0 -28
- package/dist/utils/cleanup.test.ts +0 -68
- package/dist/utils/cleanup.ts +0 -36
- package/dist/utils/dialogScopeUtils.ts +0 -64
- package/dist/utils/events.ts +0 -14
- package/dist/utils/gitUtils.test.ts +0 -149
- package/dist/utils/gitUtils.ts +0 -116
- package/dist/utils/handleAutoUpdate.test.ts +0 -272
- package/dist/utils/handleAutoUpdate.ts +0 -145
- package/dist/utils/installationInfo.test.ts +0 -315
- package/dist/utils/installationInfo.ts +0 -176
- package/dist/utils/package.ts +0 -38
- package/dist/utils/readStdin.ts +0 -51
- package/dist/utils/resolvePath.ts +0 -21
- package/dist/utils/sandbox-macos-permissive-closed.sb +0 -32
- package/dist/utils/sandbox-macos-permissive-open.sb +0 -25
- package/dist/utils/sandbox-macos-permissive-proxied.sb +0 -37
- package/dist/utils/sandbox-macos-restrictive-closed.sb +0 -93
- package/dist/utils/sandbox-macos-restrictive-open.sb +0 -96
- package/dist/utils/sandbox-macos-restrictive-proxied.sb +0 -98
- package/dist/utils/sandbox.ts +0 -962
- package/dist/utils/settingsUtils.test.ts +0 -797
- package/dist/utils/settingsUtils.ts +0 -489
- package/dist/utils/spawnWrapper.ts +0 -9
- package/dist/utils/startupWarnings.test.ts +0 -83
- package/dist/utils/startupWarnings.ts +0 -40
- package/dist/utils/updateEventEmitter.ts +0 -13
- package/dist/utils/userStartupWarnings.test.ts +0 -87
- package/dist/utils/userStartupWarnings.ts +0 -69
- package/dist/utils/version.ts +0 -12
- package/dist/validateNonInterActiveAuth.test.ts +0 -260
- package/dist/validateNonInterActiveAuth.ts +0 -51
- package/dist/vitest.config.ts +0 -37
- package/dist/zed-integration/acp.ts +0 -366
- package/dist/zed-integration/fileSystemService.ts +0 -47
- package/dist/zed-integration/schema.ts +0 -466
- package/dist/zed-integration/zedIntegration.ts +0 -944
|
@@ -1,1952 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
8
|
-
import * as os from 'os';
|
|
9
|
-
import * as fs from 'fs';
|
|
10
|
-
import * as path from 'path';
|
|
11
|
-
import { ShellTool, EditTool, WriteFileTool } from 'fss-link-core';
|
|
12
|
-
import { loadCliConfig, parseArguments, CliArgs } from './config.js';
|
|
13
|
-
import { Settings } from './settings.js';
|
|
14
|
-
import { Extension } from './extension.js';
|
|
15
|
-
import * as ServerConfig from 'fss-link-core';
|
|
16
|
-
import { isWorkspaceTrusted } from './trustedFolders.js';
|
|
17
|
-
|
|
18
|
-
vi.mock('./trustedFolders.js', () => ({
|
|
19
|
-
isWorkspaceTrusted: vi.fn(),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
vi.mock('os', async (importOriginal) => {
|
|
23
|
-
const actualOs = await importOriginal<typeof os>();
|
|
24
|
-
return {
|
|
25
|
-
...actualOs,
|
|
26
|
-
homedir: vi.fn(() => '/mock/home/user'),
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
vi.mock('open', () => ({
|
|
31
|
-
default: vi.fn(),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
vi.mock('read-package-up', () => ({
|
|
35
|
-
readPackageUp: vi.fn(() =>
|
|
36
|
-
Promise.resolve({ packageJson: { version: 'test-version' } }),
|
|
37
|
-
),
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
vi.mock('fss-link-core', async () => {
|
|
41
|
-
const actualServer = await vi.importActual<typeof ServerConfig>(
|
|
42
|
-
'fss-link-core',
|
|
43
|
-
);
|
|
44
|
-
return {
|
|
45
|
-
...actualServer,
|
|
46
|
-
IdeClient: {
|
|
47
|
-
getInstance: vi.fn().mockReturnValue({
|
|
48
|
-
getConnectionStatus: vi.fn(),
|
|
49
|
-
initialize: vi.fn(),
|
|
50
|
-
shutdown: vi.fn(),
|
|
51
|
-
}),
|
|
52
|
-
},
|
|
53
|
-
loadEnvironment: vi.fn(),
|
|
54
|
-
loadServerHierarchicalMemory: vi.fn(
|
|
55
|
-
(cwd, dirs, debug, fileService, extensionPaths, _maxDirs) =>
|
|
56
|
-
Promise.resolve({
|
|
57
|
-
memoryContent: extensionPaths?.join(',') || '',
|
|
58
|
-
fileCount: extensionPaths?.length || 0,
|
|
59
|
-
}),
|
|
60
|
-
),
|
|
61
|
-
DEFAULT_MEMORY_FILE_FILTERING_OPTIONS: {
|
|
62
|
-
respectGitIgnore: false,
|
|
63
|
-
respectFssLinkIgnore: true,
|
|
64
|
-
},
|
|
65
|
-
DEFAULT_FILE_FILTERING_OPTIONS: {
|
|
66
|
-
respectGitIgnore: true,
|
|
67
|
-
respectFssLinkIgnore: true,
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('parseArguments', () => {
|
|
73
|
-
const originalArgv = process.argv;
|
|
74
|
-
|
|
75
|
-
afterEach(() => {
|
|
76
|
-
process.argv = originalArgv;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should throw an error when both --prompt and --prompt-interactive are used together', async () => {
|
|
80
|
-
process.argv = [
|
|
81
|
-
'node',
|
|
82
|
-
'script.js',
|
|
83
|
-
'--prompt',
|
|
84
|
-
'test prompt',
|
|
85
|
-
'--prompt-interactive',
|
|
86
|
-
'interactive prompt',
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
90
|
-
throw new Error('process.exit called');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const mockConsoleError = vi
|
|
94
|
-
.spyOn(console, 'error')
|
|
95
|
-
.mockImplementation(() => {});
|
|
96
|
-
|
|
97
|
-
await expect(parseArguments()).rejects.toThrow('process.exit called');
|
|
98
|
-
|
|
99
|
-
expect(mockConsoleError).toHaveBeenCalledWith(
|
|
100
|
-
expect.stringContaining(
|
|
101
|
-
'Cannot use both --prompt (-p) and --prompt-interactive (-i) together',
|
|
102
|
-
),
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
mockExit.mockRestore();
|
|
106
|
-
mockConsoleError.mockRestore();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('should throw an error when using short flags -p and -i together', async () => {
|
|
110
|
-
process.argv = [
|
|
111
|
-
'node',
|
|
112
|
-
'script.js',
|
|
113
|
-
'-p',
|
|
114
|
-
'test prompt',
|
|
115
|
-
'-i',
|
|
116
|
-
'interactive prompt',
|
|
117
|
-
];
|
|
118
|
-
|
|
119
|
-
const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
120
|
-
throw new Error('process.exit called');
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
const mockConsoleError = vi
|
|
124
|
-
.spyOn(console, 'error')
|
|
125
|
-
.mockImplementation(() => {});
|
|
126
|
-
|
|
127
|
-
await expect(parseArguments()).rejects.toThrow('process.exit called');
|
|
128
|
-
|
|
129
|
-
expect(mockConsoleError).toHaveBeenCalledWith(
|
|
130
|
-
expect.stringContaining(
|
|
131
|
-
'Cannot use both --prompt (-p) and --prompt-interactive (-i) together',
|
|
132
|
-
),
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
mockExit.mockRestore();
|
|
136
|
-
mockConsoleError.mockRestore();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should allow --prompt without --prompt-interactive', async () => {
|
|
140
|
-
process.argv = ['node', 'script.js', '--prompt', 'test prompt'];
|
|
141
|
-
const argv = await parseArguments();
|
|
142
|
-
expect(argv.prompt).toBe('test prompt');
|
|
143
|
-
expect(argv.promptInteractive).toBeUndefined();
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('should allow --prompt-interactive without --prompt', async () => {
|
|
147
|
-
process.argv = [
|
|
148
|
-
'node',
|
|
149
|
-
'script.js',
|
|
150
|
-
'--prompt-interactive',
|
|
151
|
-
'interactive prompt',
|
|
152
|
-
];
|
|
153
|
-
const argv = await parseArguments();
|
|
154
|
-
expect(argv.promptInteractive).toBe('interactive prompt');
|
|
155
|
-
expect(argv.prompt).toBeUndefined();
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('should allow -i flag as alias for --prompt-interactive', async () => {
|
|
159
|
-
process.argv = ['node', 'script.js', '-i', 'interactive prompt'];
|
|
160
|
-
const argv = await parseArguments();
|
|
161
|
-
expect(argv.promptInteractive).toBe('interactive prompt');
|
|
162
|
-
expect(argv.prompt).toBeUndefined();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('should throw an error when both --yolo and --approval-mode are used together', async () => {
|
|
166
|
-
process.argv = [
|
|
167
|
-
'node',
|
|
168
|
-
'script.js',
|
|
169
|
-
'--yolo',
|
|
170
|
-
'--approval-mode',
|
|
171
|
-
'default',
|
|
172
|
-
];
|
|
173
|
-
|
|
174
|
-
const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
175
|
-
throw new Error('process.exit called');
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
const mockConsoleError = vi
|
|
179
|
-
.spyOn(console, 'error')
|
|
180
|
-
.mockImplementation(() => {});
|
|
181
|
-
|
|
182
|
-
await expect(parseArguments()).rejects.toThrow('process.exit called');
|
|
183
|
-
|
|
184
|
-
expect(mockConsoleError).toHaveBeenCalledWith(
|
|
185
|
-
expect.stringContaining(
|
|
186
|
-
'Cannot use both --yolo (-y) and --approval-mode together. Use --approval-mode=yolo instead.',
|
|
187
|
-
),
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
mockExit.mockRestore();
|
|
191
|
-
mockConsoleError.mockRestore();
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('should throw an error when using short flags -y and --approval-mode together', async () => {
|
|
195
|
-
process.argv = ['node', 'script.js', '-y', '--approval-mode', 'yolo'];
|
|
196
|
-
|
|
197
|
-
const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
198
|
-
throw new Error('process.exit called');
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const mockConsoleError = vi
|
|
202
|
-
.spyOn(console, 'error')
|
|
203
|
-
.mockImplementation(() => {});
|
|
204
|
-
|
|
205
|
-
await expect(parseArguments()).rejects.toThrow('process.exit called');
|
|
206
|
-
|
|
207
|
-
expect(mockConsoleError).toHaveBeenCalledWith(
|
|
208
|
-
expect.stringContaining(
|
|
209
|
-
'Cannot use both --yolo (-y) and --approval-mode together. Use --approval-mode=yolo instead.',
|
|
210
|
-
),
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
mockExit.mockRestore();
|
|
214
|
-
mockConsoleError.mockRestore();
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('should allow --approval-mode without --yolo', async () => {
|
|
218
|
-
process.argv = ['node', 'script.js', '--approval-mode', 'auto_edit'];
|
|
219
|
-
const argv = await parseArguments();
|
|
220
|
-
expect(argv.approvalMode).toBe('auto_edit');
|
|
221
|
-
expect(argv.yolo).toBe(false);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it('should allow --yolo without --approval-mode', async () => {
|
|
225
|
-
process.argv = ['node', 'script.js', '--yolo'];
|
|
226
|
-
const argv = await parseArguments();
|
|
227
|
-
expect(argv.yolo).toBe(true);
|
|
228
|
-
expect(argv.approvalMode).toBeUndefined();
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it('should reject invalid --approval-mode values', async () => {
|
|
232
|
-
process.argv = ['node', 'script.js', '--approval-mode', 'invalid'];
|
|
233
|
-
|
|
234
|
-
const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
235
|
-
throw new Error('process.exit called');
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
const mockConsoleError = vi
|
|
239
|
-
.spyOn(console, 'error')
|
|
240
|
-
.mockImplementation(() => {});
|
|
241
|
-
|
|
242
|
-
await expect(parseArguments()).rejects.toThrow('process.exit called');
|
|
243
|
-
|
|
244
|
-
expect(mockConsoleError).toHaveBeenCalledWith(
|
|
245
|
-
expect.stringContaining('Invalid values:'),
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
mockExit.mockRestore();
|
|
249
|
-
mockConsoleError.mockRestore();
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
describe('loadCliConfig', () => {
|
|
254
|
-
const originalArgv = process.argv;
|
|
255
|
-
|
|
256
|
-
beforeEach(() => {
|
|
257
|
-
vi.resetAllMocks();
|
|
258
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
259
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
afterEach(() => {
|
|
263
|
-
process.argv = originalArgv;
|
|
264
|
-
vi.unstubAllEnvs();
|
|
265
|
-
vi.restoreAllMocks();
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('should set showMemoryUsage to true when --show-memory-usage flag is present', async () => {
|
|
269
|
-
process.argv = ['node', 'script.js', '--show-memory-usage'];
|
|
270
|
-
const argv = await parseArguments();
|
|
271
|
-
const settings: Settings = {};
|
|
272
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
273
|
-
expect(config.getShowMemoryUsage()).toBe(true);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it('should set showMemoryUsage to false when --memory flag is not present', async () => {
|
|
277
|
-
process.argv = ['node', 'script.js'];
|
|
278
|
-
const argv = await parseArguments();
|
|
279
|
-
const settings: Settings = {};
|
|
280
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
281
|
-
expect(config.getShowMemoryUsage()).toBe(false);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it('should set showMemoryUsage to false by default from settings if CLI flag is not present', async () => {
|
|
285
|
-
process.argv = ['node', 'script.js'];
|
|
286
|
-
const argv = await parseArguments();
|
|
287
|
-
const settings: Settings = { showMemoryUsage: false };
|
|
288
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
289
|
-
expect(config.getShowMemoryUsage()).toBe(false);
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it('should prioritize CLI flag over settings for showMemoryUsage (CLI true, settings false)', async () => {
|
|
293
|
-
process.argv = ['node', 'script.js', '--show-memory-usage'];
|
|
294
|
-
const argv = await parseArguments();
|
|
295
|
-
const settings: Settings = { showMemoryUsage: false };
|
|
296
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
297
|
-
expect(config.getShowMemoryUsage()).toBe(true);
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
it(`should leave proxy to empty by default`, async () => {
|
|
301
|
-
// Clear all proxy environment variables to ensure clean test
|
|
302
|
-
delete process.env['https_proxy'];
|
|
303
|
-
delete process.env['http_proxy'];
|
|
304
|
-
delete process.env['HTTPS_PROXY'];
|
|
305
|
-
delete process.env['HTTP_PROXY'];
|
|
306
|
-
|
|
307
|
-
process.argv = ['node', 'script.js'];
|
|
308
|
-
const argv = await parseArguments();
|
|
309
|
-
const settings: Settings = {};
|
|
310
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
311
|
-
expect(config.getProxy()).toBeFalsy();
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
const proxy_url = 'http://localhost:7890';
|
|
315
|
-
const testCases = [
|
|
316
|
-
{
|
|
317
|
-
input: {
|
|
318
|
-
env_name: 'https_proxy',
|
|
319
|
-
proxy_url,
|
|
320
|
-
},
|
|
321
|
-
expected: proxy_url,
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
input: {
|
|
325
|
-
env_name: 'http_proxy',
|
|
326
|
-
proxy_url,
|
|
327
|
-
},
|
|
328
|
-
expected: proxy_url,
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
input: {
|
|
332
|
-
env_name: 'HTTPS_PROXY',
|
|
333
|
-
proxy_url,
|
|
334
|
-
},
|
|
335
|
-
expected: proxy_url,
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
input: {
|
|
339
|
-
env_name: 'HTTP_PROXY',
|
|
340
|
-
proxy_url,
|
|
341
|
-
},
|
|
342
|
-
expected: proxy_url,
|
|
343
|
-
},
|
|
344
|
-
];
|
|
345
|
-
testCases.forEach(({ input, expected }) => {
|
|
346
|
-
it(`should set proxy to ${expected} according to environment variable [${input.env_name}]`, async () => {
|
|
347
|
-
// Clear all proxy environment variables first
|
|
348
|
-
delete process.env['https_proxy'];
|
|
349
|
-
delete process.env['http_proxy'];
|
|
350
|
-
delete process.env['HTTPS_PROXY'];
|
|
351
|
-
delete process.env['HTTP_PROXY'];
|
|
352
|
-
|
|
353
|
-
vi.stubEnv(input.env_name, input.proxy_url);
|
|
354
|
-
process.argv = ['node', 'script.js'];
|
|
355
|
-
const argv = await parseArguments();
|
|
356
|
-
const settings: Settings = {};
|
|
357
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
358
|
-
expect(config.getProxy()).toBe(expected);
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
it('should set proxy when --proxy flag is present', async () => {
|
|
363
|
-
process.argv = ['node', 'script.js', '--proxy', 'http://localhost:7890'];
|
|
364
|
-
const argv = await parseArguments();
|
|
365
|
-
const settings: Settings = {};
|
|
366
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
367
|
-
expect(config.getProxy()).toBe('http://localhost:7890');
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
it('should prioritize CLI flag over environment variable for proxy (CLI http://localhost:7890, environment variable http://localhost:7891)', async () => {
|
|
371
|
-
vi.stubEnv('http_proxy', 'http://localhost:7891');
|
|
372
|
-
process.argv = ['node', 'script.js', '--proxy', 'http://localhost:7890'];
|
|
373
|
-
const argv = await parseArguments();
|
|
374
|
-
const settings: Settings = {};
|
|
375
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
376
|
-
expect(config.getProxy()).toBe('http://localhost:7890');
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
describe('loadCliConfig telemetry', () => {
|
|
381
|
-
const originalArgv = process.argv;
|
|
382
|
-
|
|
383
|
-
beforeEach(() => {
|
|
384
|
-
vi.resetAllMocks();
|
|
385
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
386
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
afterEach(() => {
|
|
390
|
-
process.argv = originalArgv;
|
|
391
|
-
vi.unstubAllEnvs();
|
|
392
|
-
vi.restoreAllMocks();
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
it('should set telemetry to false by default when no flag or setting is present', async () => {
|
|
396
|
-
process.argv = ['node', 'script.js'];
|
|
397
|
-
const argv = await parseArguments();
|
|
398
|
-
const settings: Settings = {};
|
|
399
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
400
|
-
expect(config.getTelemetryEnabled()).toBe(false);
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
it('should set telemetry to true when --telemetry flag is present', async () => {
|
|
404
|
-
process.argv = ['node', 'script.js', '--telemetry'];
|
|
405
|
-
const argv = await parseArguments();
|
|
406
|
-
const settings: Settings = {};
|
|
407
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
408
|
-
expect(config.getTelemetryEnabled()).toBe(true);
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
it('should set telemetry to false when --no-telemetry flag is present', async () => {
|
|
412
|
-
process.argv = ['node', 'script.js', '--no-telemetry'];
|
|
413
|
-
const argv = await parseArguments();
|
|
414
|
-
const settings: Settings = {};
|
|
415
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
416
|
-
expect(config.getTelemetryEnabled()).toBe(false);
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
it('should use telemetry value from settings if CLI flag is not present (settings true)', async () => {
|
|
420
|
-
process.argv = ['node', 'script.js'];
|
|
421
|
-
const argv = await parseArguments();
|
|
422
|
-
const settings: Settings = { telemetry: { enabled: true } };
|
|
423
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
424
|
-
expect(config.getTelemetryEnabled()).toBe(true);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
it('should use telemetry value from settings if CLI flag is not present (settings false)', async () => {
|
|
428
|
-
process.argv = ['node', 'script.js'];
|
|
429
|
-
const argv = await parseArguments();
|
|
430
|
-
const settings: Settings = { telemetry: { enabled: false } };
|
|
431
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
432
|
-
expect(config.getTelemetryEnabled()).toBe(false);
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
it('should prioritize --telemetry CLI flag (true) over settings (false)', async () => {
|
|
436
|
-
process.argv = ['node', 'script.js', '--telemetry'];
|
|
437
|
-
const argv = await parseArguments();
|
|
438
|
-
const settings: Settings = { telemetry: { enabled: false } };
|
|
439
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
440
|
-
expect(config.getTelemetryEnabled()).toBe(true);
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
it('should prioritize --no-telemetry CLI flag (false) over settings (true)', async () => {
|
|
444
|
-
process.argv = ['node', 'script.js', '--no-telemetry'];
|
|
445
|
-
const argv = await parseArguments();
|
|
446
|
-
const settings: Settings = { telemetry: { enabled: true } };
|
|
447
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
448
|
-
expect(config.getTelemetryEnabled()).toBe(false);
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
it('should use telemetry OTLP endpoint from settings if CLI flag is not present', async () => {
|
|
452
|
-
process.argv = ['node', 'script.js'];
|
|
453
|
-
const argv = await parseArguments();
|
|
454
|
-
const settings: Settings = {
|
|
455
|
-
telemetry: { otlpEndpoint: 'http://settings.example.com' },
|
|
456
|
-
};
|
|
457
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
458
|
-
expect(config.getTelemetryOtlpEndpoint()).toBe(
|
|
459
|
-
'http://settings.example.com',
|
|
460
|
-
);
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
it('should prioritize --telemetry-otlp-endpoint CLI flag over settings', async () => {
|
|
464
|
-
process.argv = [
|
|
465
|
-
'node',
|
|
466
|
-
'script.js',
|
|
467
|
-
'--telemetry-otlp-endpoint',
|
|
468
|
-
'http://cli.example.com',
|
|
469
|
-
];
|
|
470
|
-
const argv = await parseArguments();
|
|
471
|
-
const settings: Settings = {
|
|
472
|
-
telemetry: { otlpEndpoint: 'http://settings.example.com' },
|
|
473
|
-
};
|
|
474
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
475
|
-
expect(config.getTelemetryOtlpEndpoint()).toBe('http://cli.example.com');
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
it('should use default endpoint if no OTLP endpoint is provided via CLI or settings', async () => {
|
|
479
|
-
process.argv = ['node', 'script.js'];
|
|
480
|
-
const argv = await parseArguments();
|
|
481
|
-
const settings: Settings = { telemetry: { enabled: true } };
|
|
482
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
483
|
-
expect(config.getTelemetryOtlpEndpoint()).toBe('http://localhost:4317');
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
it('should use telemetry target from settings if CLI flag is not present', async () => {
|
|
487
|
-
process.argv = ['node', 'script.js'];
|
|
488
|
-
const argv = await parseArguments();
|
|
489
|
-
const settings: Settings = {
|
|
490
|
-
telemetry: { target: ServerConfig.DEFAULT_TELEMETRY_TARGET },
|
|
491
|
-
};
|
|
492
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
493
|
-
expect(config.getTelemetryTarget()).toBe(
|
|
494
|
-
ServerConfig.DEFAULT_TELEMETRY_TARGET,
|
|
495
|
-
);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
it('should prioritize --telemetry-target CLI flag over settings', async () => {
|
|
499
|
-
process.argv = ['node', 'script.js', '--telemetry-target', 'gcp'];
|
|
500
|
-
const argv = await parseArguments();
|
|
501
|
-
const settings: Settings = {
|
|
502
|
-
telemetry: { target: ServerConfig.DEFAULT_TELEMETRY_TARGET },
|
|
503
|
-
};
|
|
504
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
505
|
-
expect(config.getTelemetryTarget()).toBe('gcp');
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
it('should use default target if no target is provided via CLI or settings', async () => {
|
|
509
|
-
process.argv = ['node', 'script.js'];
|
|
510
|
-
const argv = await parseArguments();
|
|
511
|
-
const settings: Settings = { telemetry: { enabled: true } };
|
|
512
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
513
|
-
expect(config.getTelemetryTarget()).toBe(
|
|
514
|
-
ServerConfig.DEFAULT_TELEMETRY_TARGET,
|
|
515
|
-
);
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
it('should use telemetry log prompts from settings if CLI flag is not present', async () => {
|
|
519
|
-
process.argv = ['node', 'script.js'];
|
|
520
|
-
const argv = await parseArguments();
|
|
521
|
-
const settings: Settings = { telemetry: { logPrompts: false } };
|
|
522
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
523
|
-
expect(config.getTelemetryLogPromptsEnabled()).toBe(false);
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
it('should prioritize --telemetry-log-prompts CLI flag (true) over settings (false)', async () => {
|
|
527
|
-
process.argv = ['node', 'script.js', '--telemetry-log-prompts'];
|
|
528
|
-
const argv = await parseArguments();
|
|
529
|
-
const settings: Settings = { telemetry: { logPrompts: false } };
|
|
530
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
531
|
-
expect(config.getTelemetryLogPromptsEnabled()).toBe(true);
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
it('should prioritize --no-telemetry-log-prompts CLI flag (false) over settings (true)', async () => {
|
|
535
|
-
process.argv = ['node', 'script.js', '--no-telemetry-log-prompts'];
|
|
536
|
-
const argv = await parseArguments();
|
|
537
|
-
const settings: Settings = { telemetry: { logPrompts: true } };
|
|
538
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
539
|
-
expect(config.getTelemetryLogPromptsEnabled()).toBe(false);
|
|
540
|
-
});
|
|
541
|
-
|
|
542
|
-
it('should use default log prompts (true) if no value is provided via CLI or settings', async () => {
|
|
543
|
-
process.argv = ['node', 'script.js'];
|
|
544
|
-
const argv = await parseArguments();
|
|
545
|
-
const settings: Settings = { telemetry: { enabled: true } };
|
|
546
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
547
|
-
expect(config.getTelemetryLogPromptsEnabled()).toBe(true);
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
it('should use telemetry OTLP protocol from settings if CLI flag is not present', async () => {
|
|
551
|
-
process.argv = ['node', 'script.js'];
|
|
552
|
-
const argv = await parseArguments();
|
|
553
|
-
const settings: Settings = {
|
|
554
|
-
telemetry: { otlpProtocol: 'http' },
|
|
555
|
-
};
|
|
556
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
557
|
-
expect(config.getTelemetryOtlpProtocol()).toBe('http');
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
it('should prioritize --telemetry-otlp-protocol CLI flag over settings', async () => {
|
|
561
|
-
process.argv = ['node', 'script.js', '--telemetry-otlp-protocol', 'http'];
|
|
562
|
-
const argv = await parseArguments();
|
|
563
|
-
const settings: Settings = {
|
|
564
|
-
telemetry: { otlpProtocol: 'grpc' },
|
|
565
|
-
};
|
|
566
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
567
|
-
expect(config.getTelemetryOtlpProtocol()).toBe('http');
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
it('should use default protocol if no OTLP protocol is provided via CLI or settings', async () => {
|
|
571
|
-
process.argv = ['node', 'script.js'];
|
|
572
|
-
const argv = await parseArguments();
|
|
573
|
-
const settings: Settings = { telemetry: { enabled: true } };
|
|
574
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
575
|
-
expect(config.getTelemetryOtlpProtocol()).toBe('grpc');
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
it('should reject invalid --telemetry-otlp-protocol values', async () => {
|
|
579
|
-
process.argv = [
|
|
580
|
-
'node',
|
|
581
|
-
'script.js',
|
|
582
|
-
'--telemetry-otlp-protocol',
|
|
583
|
-
'invalid',
|
|
584
|
-
];
|
|
585
|
-
|
|
586
|
-
const mockExit = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
587
|
-
throw new Error('process.exit called');
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
const mockConsoleError = vi
|
|
591
|
-
.spyOn(console, 'error')
|
|
592
|
-
.mockImplementation(() => {});
|
|
593
|
-
|
|
594
|
-
await expect(parseArguments()).rejects.toThrow('process.exit called');
|
|
595
|
-
|
|
596
|
-
expect(mockConsoleError).toHaveBeenCalledWith(
|
|
597
|
-
expect.stringContaining('Invalid values:'),
|
|
598
|
-
);
|
|
599
|
-
|
|
600
|
-
mockExit.mockRestore();
|
|
601
|
-
mockConsoleError.mockRestore();
|
|
602
|
-
});
|
|
603
|
-
});
|
|
604
|
-
|
|
605
|
-
describe('Hierarchical Memory Loading (config.ts) - Placeholder Suite', () => {
|
|
606
|
-
beforeEach(() => {
|
|
607
|
-
vi.resetAllMocks();
|
|
608
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
609
|
-
// Other common mocks would be reset here.
|
|
610
|
-
});
|
|
611
|
-
|
|
612
|
-
afterEach(() => {
|
|
613
|
-
vi.restoreAllMocks();
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
it('should pass extension context file paths to loadServerHierarchicalMemory', async () => {
|
|
617
|
-
process.argv = ['node', 'script.js'];
|
|
618
|
-
const settings: Settings = {};
|
|
619
|
-
const extensions: Extension[] = [
|
|
620
|
-
{
|
|
621
|
-
path: '/path/to/ext1',
|
|
622
|
-
config: {
|
|
623
|
-
name: 'ext1',
|
|
624
|
-
version: '1.0.0',
|
|
625
|
-
},
|
|
626
|
-
contextFiles: ['/path/to/ext1/LINK.md'],
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
path: '/path/to/ext2',
|
|
630
|
-
config: {
|
|
631
|
-
name: 'ext2',
|
|
632
|
-
version: '1.0.0',
|
|
633
|
-
},
|
|
634
|
-
contextFiles: [],
|
|
635
|
-
},
|
|
636
|
-
{
|
|
637
|
-
path: '/path/to/ext3',
|
|
638
|
-
config: {
|
|
639
|
-
name: 'ext3',
|
|
640
|
-
version: '1.0.0',
|
|
641
|
-
},
|
|
642
|
-
contextFiles: [
|
|
643
|
-
'/path/to/ext3/context1.md',
|
|
644
|
-
'/path/to/ext3/context2.md',
|
|
645
|
-
],
|
|
646
|
-
},
|
|
647
|
-
];
|
|
648
|
-
const argv = await parseArguments();
|
|
649
|
-
await loadCliConfig(settings, extensions, 'session-id', argv);
|
|
650
|
-
expect(ServerConfig.loadServerHierarchicalMemory).toHaveBeenCalledWith(
|
|
651
|
-
expect.any(String),
|
|
652
|
-
[],
|
|
653
|
-
false,
|
|
654
|
-
expect.any(Object),
|
|
655
|
-
[
|
|
656
|
-
'/path/to/ext1/LINK.md',
|
|
657
|
-
'/path/to/ext3/context1.md',
|
|
658
|
-
'/path/to/ext3/context2.md',
|
|
659
|
-
],
|
|
660
|
-
'tree',
|
|
661
|
-
{
|
|
662
|
-
respectGitIgnore: false,
|
|
663
|
-
respectFssLinkIgnore: true,
|
|
664
|
-
},
|
|
665
|
-
undefined, // maxDirs
|
|
666
|
-
);
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
// NOTE TO FUTURE DEVELOPERS:
|
|
670
|
-
// To re-enable tests for loadHierarchicalGeminiMemory, ensure that:
|
|
671
|
-
// 1. os.homedir() is reliably mocked *before* the config.ts module is loaded
|
|
672
|
-
// and its functions (which use os.homedir()) are called.
|
|
673
|
-
// 2. fs/promises and fs mocks correctly simulate file/directory existence,
|
|
674
|
-
// readability, and content based on paths derived from the mocked os.homedir().
|
|
675
|
-
// 3. Spies on console functions (for logger output) are correctly set up if needed.
|
|
676
|
-
// Example of a previously failing test structure:
|
|
677
|
-
/*
|
|
678
|
-
it('should correctly use mocked homedir for global path', async () => {
|
|
679
|
-
const MOCK_GEMINI_DIR_LOCAL = path.join('/mock/home/user', '.fss-link');
|
|
680
|
-
const MOCK_GLOBAL_PATH_LOCAL = path.join(MOCK_GEMINI_DIR_LOCAL, 'LINK.md');
|
|
681
|
-
mockFs({
|
|
682
|
-
[MOCK_GLOBAL_PATH_LOCAL]: { type: 'file', content: 'GlobalContentOnly' }
|
|
683
|
-
});
|
|
684
|
-
const memory = await loadHierarchicalGeminiMemory("/some/other/cwd", false);
|
|
685
|
-
expect(memory).toBe('GlobalContentOnly');
|
|
686
|
-
expect(vi.mocked(os.homedir)).toHaveBeenCalled();
|
|
687
|
-
expect(fsPromises.readFile).toHaveBeenCalledWith(MOCK_GLOBAL_PATH_LOCAL, 'utf-8');
|
|
688
|
-
});
|
|
689
|
-
*/
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
describe('mergeMcpServers', () => {
|
|
693
|
-
it('should not modify the original settings object', async () => {
|
|
694
|
-
const settings: Settings = {
|
|
695
|
-
mcpServers: {
|
|
696
|
-
'test-server': {
|
|
697
|
-
url: 'http://localhost:8080',
|
|
698
|
-
},
|
|
699
|
-
},
|
|
700
|
-
};
|
|
701
|
-
const extensions: Extension[] = [
|
|
702
|
-
{
|
|
703
|
-
path: '/path/to/ext1',
|
|
704
|
-
config: {
|
|
705
|
-
name: 'ext1',
|
|
706
|
-
version: '1.0.0',
|
|
707
|
-
mcpServers: {
|
|
708
|
-
'ext1-server': {
|
|
709
|
-
url: 'http://localhost:8081',
|
|
710
|
-
},
|
|
711
|
-
},
|
|
712
|
-
},
|
|
713
|
-
contextFiles: [],
|
|
714
|
-
},
|
|
715
|
-
];
|
|
716
|
-
const originalSettings = JSON.parse(JSON.stringify(settings));
|
|
717
|
-
process.argv = ['node', 'script.js'];
|
|
718
|
-
const argv = await parseArguments();
|
|
719
|
-
await loadCliConfig(settings, extensions, 'test-session', argv);
|
|
720
|
-
expect(settings).toEqual(originalSettings);
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
|
|
724
|
-
describe('loadCliConfig systemPromptMappings', () => {
|
|
725
|
-
it('should use default systemPromptMappings when not provided in settings', async () => {
|
|
726
|
-
const mockSettings: Settings = {
|
|
727
|
-
theme: 'dark',
|
|
728
|
-
};
|
|
729
|
-
const mockExtensions: Extension[] = [];
|
|
730
|
-
const mockSessionId = 'test-session';
|
|
731
|
-
const mockArgv: CliArgs = {
|
|
732
|
-
model: 'test-model',
|
|
733
|
-
} as CliArgs;
|
|
734
|
-
|
|
735
|
-
const config = await loadCliConfig(
|
|
736
|
-
mockSettings,
|
|
737
|
-
mockExtensions,
|
|
738
|
-
mockSessionId,
|
|
739
|
-
mockArgv,
|
|
740
|
-
);
|
|
741
|
-
|
|
742
|
-
expect(config.getSystemPromptMappings()).toEqual([
|
|
743
|
-
{
|
|
744
|
-
baseUrls: [
|
|
745
|
-
'https://dashscope.aliyuncs.com/compatible-mode/v1/',
|
|
746
|
-
'https://dashscope-intl.aliyuncs.com/compatible-mode/v1/',
|
|
747
|
-
],
|
|
748
|
-
modelNames: ['qwen3-coder-plus'],
|
|
749
|
-
template:
|
|
750
|
-
'SYSTEM_TEMPLATE:{"name":"qwen3_coder","params":{"is_git_repository":{RUNTIME_VARS_IS_GIT_REPO},"sandbox":"{RUNTIME_VARS_SANDBOX}"}}',
|
|
751
|
-
},
|
|
752
|
-
]);
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
it('should use custom systemPromptMappings when provided in settings', async () => {
|
|
756
|
-
const customSystemPromptMappings = [
|
|
757
|
-
{
|
|
758
|
-
baseUrls: ['https://custom-api.com'],
|
|
759
|
-
modelNames: ['custom-model'],
|
|
760
|
-
template: 'Custom template',
|
|
761
|
-
},
|
|
762
|
-
];
|
|
763
|
-
const mockSettings: Settings = {
|
|
764
|
-
theme: 'dark',
|
|
765
|
-
systemPromptMappings: customSystemPromptMappings,
|
|
766
|
-
};
|
|
767
|
-
const mockExtensions: Extension[] = [];
|
|
768
|
-
const mockSessionId = 'test-session';
|
|
769
|
-
const mockArgv: CliArgs = {
|
|
770
|
-
model: 'test-model',
|
|
771
|
-
} as CliArgs;
|
|
772
|
-
|
|
773
|
-
const config = await loadCliConfig(
|
|
774
|
-
mockSettings,
|
|
775
|
-
mockExtensions,
|
|
776
|
-
mockSessionId,
|
|
777
|
-
mockArgv,
|
|
778
|
-
);
|
|
779
|
-
|
|
780
|
-
expect(config.getSystemPromptMappings()).toEqual(
|
|
781
|
-
customSystemPromptMappings,
|
|
782
|
-
);
|
|
783
|
-
});
|
|
784
|
-
});
|
|
785
|
-
|
|
786
|
-
describe('mergeExcludeTools', () => {
|
|
787
|
-
const defaultExcludes = [ShellTool.Name, EditTool.Name, WriteFileTool.Name];
|
|
788
|
-
const originalIsTTY = process.stdin.isTTY;
|
|
789
|
-
|
|
790
|
-
beforeEach(() => {
|
|
791
|
-
process.stdin.isTTY = true;
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
afterEach(() => {
|
|
795
|
-
process.stdin.isTTY = originalIsTTY;
|
|
796
|
-
});
|
|
797
|
-
|
|
798
|
-
it('should merge excludeTools from settings and extensions', async () => {
|
|
799
|
-
const settings: Settings = { excludeTools: ['tool1', 'tool2'] };
|
|
800
|
-
const extensions: Extension[] = [
|
|
801
|
-
{
|
|
802
|
-
path: '/path/to/ext1',
|
|
803
|
-
config: {
|
|
804
|
-
name: 'ext1',
|
|
805
|
-
version: '1.0.0',
|
|
806
|
-
excludeTools: ['tool3', 'tool4'],
|
|
807
|
-
},
|
|
808
|
-
contextFiles: [],
|
|
809
|
-
},
|
|
810
|
-
{
|
|
811
|
-
path: '/path/to/ext2',
|
|
812
|
-
config: {
|
|
813
|
-
name: 'ext2',
|
|
814
|
-
version: '1.0.0',
|
|
815
|
-
excludeTools: ['tool5'],
|
|
816
|
-
},
|
|
817
|
-
contextFiles: [],
|
|
818
|
-
},
|
|
819
|
-
];
|
|
820
|
-
process.argv = ['node', 'script.js'];
|
|
821
|
-
const argv = await parseArguments();
|
|
822
|
-
const config = await loadCliConfig(
|
|
823
|
-
settings,
|
|
824
|
-
extensions,
|
|
825
|
-
'test-session',
|
|
826
|
-
argv,
|
|
827
|
-
);
|
|
828
|
-
expect(config.getExcludeTools()).toEqual(
|
|
829
|
-
expect.arrayContaining(['tool1', 'tool2', 'tool3', 'tool4', 'tool5']),
|
|
830
|
-
);
|
|
831
|
-
expect(config.getExcludeTools()).toHaveLength(5);
|
|
832
|
-
});
|
|
833
|
-
|
|
834
|
-
it('should handle overlapping excludeTools between settings and extensions', async () => {
|
|
835
|
-
const settings: Settings = { excludeTools: ['tool1', 'tool2'] };
|
|
836
|
-
const extensions: Extension[] = [
|
|
837
|
-
{
|
|
838
|
-
path: '/path/to/ext1',
|
|
839
|
-
config: {
|
|
840
|
-
name: 'ext1',
|
|
841
|
-
version: '1.0.0',
|
|
842
|
-
excludeTools: ['tool2', 'tool3'],
|
|
843
|
-
},
|
|
844
|
-
contextFiles: [],
|
|
845
|
-
},
|
|
846
|
-
];
|
|
847
|
-
process.argv = ['node', 'script.js'];
|
|
848
|
-
const argv = await parseArguments();
|
|
849
|
-
const config = await loadCliConfig(
|
|
850
|
-
settings,
|
|
851
|
-
extensions,
|
|
852
|
-
'test-session',
|
|
853
|
-
argv,
|
|
854
|
-
);
|
|
855
|
-
expect(config.getExcludeTools()).toEqual(
|
|
856
|
-
expect.arrayContaining(['tool1', 'tool2', 'tool3']),
|
|
857
|
-
);
|
|
858
|
-
expect(config.getExcludeTools()).toHaveLength(3);
|
|
859
|
-
});
|
|
860
|
-
|
|
861
|
-
it('should handle overlapping excludeTools between extensions', async () => {
|
|
862
|
-
const settings: Settings = { excludeTools: ['tool1'] };
|
|
863
|
-
const extensions: Extension[] = [
|
|
864
|
-
{
|
|
865
|
-
config: {
|
|
866
|
-
name: 'ext1',
|
|
867
|
-
version: '1.0.0',
|
|
868
|
-
excludeTools: ['tool2', 'tool3'],
|
|
869
|
-
},
|
|
870
|
-
contextFiles: [],
|
|
871
|
-
},
|
|
872
|
-
{
|
|
873
|
-
config: {
|
|
874
|
-
name: 'ext2',
|
|
875
|
-
version: '1.0.0',
|
|
876
|
-
excludeTools: ['tool3', 'tool4'],
|
|
877
|
-
},
|
|
878
|
-
contextFiles: [],
|
|
879
|
-
},
|
|
880
|
-
];
|
|
881
|
-
process.argv = ['node', 'script.js'];
|
|
882
|
-
const argv = await parseArguments();
|
|
883
|
-
const config = await loadCliConfig(
|
|
884
|
-
settings,
|
|
885
|
-
extensions,
|
|
886
|
-
'test-session',
|
|
887
|
-
argv,
|
|
888
|
-
);
|
|
889
|
-
expect(config.getExcludeTools()).toEqual(
|
|
890
|
-
expect.arrayContaining(['tool1', 'tool2', 'tool3', 'tool4']),
|
|
891
|
-
);
|
|
892
|
-
expect(config.getExcludeTools()).toHaveLength(4);
|
|
893
|
-
});
|
|
894
|
-
|
|
895
|
-
it('should return an empty array when no excludeTools are specified and it is interactive', async () => {
|
|
896
|
-
process.stdin.isTTY = true;
|
|
897
|
-
const settings: Settings = {};
|
|
898
|
-
const extensions: Extension[] = [];
|
|
899
|
-
process.argv = ['node', 'script.js'];
|
|
900
|
-
const argv = await parseArguments();
|
|
901
|
-
const config = await loadCliConfig(
|
|
902
|
-
settings,
|
|
903
|
-
extensions,
|
|
904
|
-
'test-session',
|
|
905
|
-
argv,
|
|
906
|
-
);
|
|
907
|
-
expect(config.getExcludeTools()).toEqual([]);
|
|
908
|
-
});
|
|
909
|
-
|
|
910
|
-
it('should return default excludes when no excludeTools are specified and it is not interactive', async () => {
|
|
911
|
-
process.stdin.isTTY = false;
|
|
912
|
-
const settings: Settings = {};
|
|
913
|
-
const extensions: Extension[] = [];
|
|
914
|
-
process.argv = ['node', 'script.js', '-p', 'test'];
|
|
915
|
-
const argv = await parseArguments();
|
|
916
|
-
const config = await loadCliConfig(
|
|
917
|
-
settings,
|
|
918
|
-
extensions,
|
|
919
|
-
'test-session',
|
|
920
|
-
argv,
|
|
921
|
-
);
|
|
922
|
-
expect(config.getExcludeTools()).toEqual(defaultExcludes);
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
it('should handle settings with excludeTools but no extensions', async () => {
|
|
926
|
-
process.argv = ['node', 'script.js'];
|
|
927
|
-
const argv = await parseArguments();
|
|
928
|
-
const settings: Settings = { excludeTools: ['tool1', 'tool2'] };
|
|
929
|
-
const extensions: Extension[] = [];
|
|
930
|
-
const config = await loadCliConfig(
|
|
931
|
-
settings,
|
|
932
|
-
extensions,
|
|
933
|
-
'test-session',
|
|
934
|
-
argv,
|
|
935
|
-
);
|
|
936
|
-
expect(config.getExcludeTools()).toEqual(
|
|
937
|
-
expect.arrayContaining(['tool1', 'tool2']),
|
|
938
|
-
);
|
|
939
|
-
expect(config.getExcludeTools()).toHaveLength(2);
|
|
940
|
-
});
|
|
941
|
-
|
|
942
|
-
it('should handle extensions with excludeTools but no settings', async () => {
|
|
943
|
-
const settings: Settings = {};
|
|
944
|
-
const extensions: Extension[] = [
|
|
945
|
-
{
|
|
946
|
-
config: {
|
|
947
|
-
name: 'ext1',
|
|
948
|
-
version: '1.0.0',
|
|
949
|
-
excludeTools: ['tool1', 'tool2'],
|
|
950
|
-
},
|
|
951
|
-
contextFiles: [],
|
|
952
|
-
},
|
|
953
|
-
];
|
|
954
|
-
process.argv = ['node', 'script.js'];
|
|
955
|
-
const argv = await parseArguments();
|
|
956
|
-
const config = await loadCliConfig(
|
|
957
|
-
settings,
|
|
958
|
-
extensions,
|
|
959
|
-
'test-session',
|
|
960
|
-
argv,
|
|
961
|
-
);
|
|
962
|
-
expect(config.getExcludeTools()).toEqual(
|
|
963
|
-
expect.arrayContaining(['tool1', 'tool2']),
|
|
964
|
-
);
|
|
965
|
-
expect(config.getExcludeTools()).toHaveLength(2);
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
it('should not modify the original settings object', async () => {
|
|
969
|
-
const settings: Settings = { excludeTools: ['tool1'] };
|
|
970
|
-
const extensions: Extension[] = [
|
|
971
|
-
{
|
|
972
|
-
config: {
|
|
973
|
-
name: 'ext1',
|
|
974
|
-
version: '1.0.0',
|
|
975
|
-
excludeTools: ['tool2'],
|
|
976
|
-
},
|
|
977
|
-
contextFiles: [],
|
|
978
|
-
},
|
|
979
|
-
];
|
|
980
|
-
const originalSettings = JSON.parse(JSON.stringify(settings));
|
|
981
|
-
process.argv = ['node', 'script.js'];
|
|
982
|
-
const argv = await parseArguments();
|
|
983
|
-
await loadCliConfig(settings, extensions, 'test-session', argv);
|
|
984
|
-
expect(settings).toEqual(originalSettings);
|
|
985
|
-
});
|
|
986
|
-
});
|
|
987
|
-
|
|
988
|
-
describe('Approval mode tool exclusion logic', () => {
|
|
989
|
-
const originalIsTTY = process.stdin.isTTY;
|
|
990
|
-
|
|
991
|
-
beforeEach(() => {
|
|
992
|
-
process.stdin.isTTY = false; // Ensure non-interactive mode
|
|
993
|
-
});
|
|
994
|
-
|
|
995
|
-
afterEach(() => {
|
|
996
|
-
process.stdin.isTTY = originalIsTTY;
|
|
997
|
-
});
|
|
998
|
-
|
|
999
|
-
it('should exclude all interactive tools in non-interactive mode with default approval mode', async () => {
|
|
1000
|
-
process.argv = ['node', 'script.js', '-p', 'test'];
|
|
1001
|
-
const argv = await parseArguments();
|
|
1002
|
-
const settings: Settings = {};
|
|
1003
|
-
const extensions: Extension[] = [];
|
|
1004
|
-
|
|
1005
|
-
const config = await loadCliConfig(
|
|
1006
|
-
settings,
|
|
1007
|
-
extensions,
|
|
1008
|
-
'test-session',
|
|
1009
|
-
argv,
|
|
1010
|
-
);
|
|
1011
|
-
|
|
1012
|
-
const excludedTools = config.getExcludeTools();
|
|
1013
|
-
expect(excludedTools).toContain(ShellTool.Name);
|
|
1014
|
-
expect(excludedTools).toContain(EditTool.Name);
|
|
1015
|
-
expect(excludedTools).toContain(WriteFileTool.Name);
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
it('should exclude all interactive tools in non-interactive mode with explicit default approval mode', async () => {
|
|
1019
|
-
process.argv = [
|
|
1020
|
-
'node',
|
|
1021
|
-
'script.js',
|
|
1022
|
-
'--approval-mode',
|
|
1023
|
-
'default',
|
|
1024
|
-
'-p',
|
|
1025
|
-
'test',
|
|
1026
|
-
];
|
|
1027
|
-
const argv = await parseArguments();
|
|
1028
|
-
const settings: Settings = {};
|
|
1029
|
-
const extensions: Extension[] = [];
|
|
1030
|
-
|
|
1031
|
-
const config = await loadCliConfig(
|
|
1032
|
-
settings,
|
|
1033
|
-
extensions,
|
|
1034
|
-
'test-session',
|
|
1035
|
-
argv,
|
|
1036
|
-
);
|
|
1037
|
-
|
|
1038
|
-
const excludedTools = config.getExcludeTools();
|
|
1039
|
-
expect(excludedTools).toContain(ShellTool.Name);
|
|
1040
|
-
expect(excludedTools).toContain(EditTool.Name);
|
|
1041
|
-
expect(excludedTools).toContain(WriteFileTool.Name);
|
|
1042
|
-
});
|
|
1043
|
-
|
|
1044
|
-
it('should exclude only shell tools in non-interactive mode with auto_edit approval mode', async () => {
|
|
1045
|
-
process.argv = [
|
|
1046
|
-
'node',
|
|
1047
|
-
'script.js',
|
|
1048
|
-
'--approval-mode',
|
|
1049
|
-
'auto_edit',
|
|
1050
|
-
'-p',
|
|
1051
|
-
'test',
|
|
1052
|
-
];
|
|
1053
|
-
const argv = await parseArguments();
|
|
1054
|
-
const settings: Settings = {};
|
|
1055
|
-
const extensions: Extension[] = [];
|
|
1056
|
-
|
|
1057
|
-
const config = await loadCliConfig(
|
|
1058
|
-
settings,
|
|
1059
|
-
extensions,
|
|
1060
|
-
'test-session',
|
|
1061
|
-
argv,
|
|
1062
|
-
);
|
|
1063
|
-
|
|
1064
|
-
const excludedTools = config.getExcludeTools();
|
|
1065
|
-
expect(excludedTools).toContain(ShellTool.Name);
|
|
1066
|
-
expect(excludedTools).not.toContain(EditTool.Name);
|
|
1067
|
-
expect(excludedTools).not.toContain(WriteFileTool.Name);
|
|
1068
|
-
});
|
|
1069
|
-
|
|
1070
|
-
it('should exclude no interactive tools in non-interactive mode with yolo approval mode', async () => {
|
|
1071
|
-
process.argv = [
|
|
1072
|
-
'node',
|
|
1073
|
-
'script.js',
|
|
1074
|
-
'--approval-mode',
|
|
1075
|
-
'yolo',
|
|
1076
|
-
'-p',
|
|
1077
|
-
'test',
|
|
1078
|
-
];
|
|
1079
|
-
const argv = await parseArguments();
|
|
1080
|
-
const settings: Settings = {};
|
|
1081
|
-
const extensions: Extension[] = [];
|
|
1082
|
-
|
|
1083
|
-
const config = await loadCliConfig(
|
|
1084
|
-
settings,
|
|
1085
|
-
extensions,
|
|
1086
|
-
'test-session',
|
|
1087
|
-
argv,
|
|
1088
|
-
);
|
|
1089
|
-
|
|
1090
|
-
const excludedTools = config.getExcludeTools();
|
|
1091
|
-
expect(excludedTools).not.toContain(ShellTool.Name);
|
|
1092
|
-
expect(excludedTools).not.toContain(EditTool.Name);
|
|
1093
|
-
expect(excludedTools).not.toContain(WriteFileTool.Name);
|
|
1094
|
-
});
|
|
1095
|
-
|
|
1096
|
-
it('should exclude no interactive tools in non-interactive mode with legacy yolo flag', async () => {
|
|
1097
|
-
process.argv = ['node', 'script.js', '--yolo', '-p', 'test'];
|
|
1098
|
-
const argv = await parseArguments();
|
|
1099
|
-
const settings: Settings = {};
|
|
1100
|
-
const extensions: Extension[] = [];
|
|
1101
|
-
|
|
1102
|
-
const config = await loadCliConfig(
|
|
1103
|
-
settings,
|
|
1104
|
-
extensions,
|
|
1105
|
-
'test-session',
|
|
1106
|
-
argv,
|
|
1107
|
-
);
|
|
1108
|
-
|
|
1109
|
-
const excludedTools = config.getExcludeTools();
|
|
1110
|
-
expect(excludedTools).not.toContain(ShellTool.Name);
|
|
1111
|
-
expect(excludedTools).not.toContain(EditTool.Name);
|
|
1112
|
-
expect(excludedTools).not.toContain(WriteFileTool.Name);
|
|
1113
|
-
});
|
|
1114
|
-
|
|
1115
|
-
it('should not exclude interactive tools in interactive mode regardless of approval mode', async () => {
|
|
1116
|
-
process.stdin.isTTY = true; // Interactive mode
|
|
1117
|
-
|
|
1118
|
-
const testCases = [
|
|
1119
|
-
{ args: ['node', 'script.js'] }, // default
|
|
1120
|
-
{ args: ['node', 'script.js', '--approval-mode', 'default'] },
|
|
1121
|
-
{ args: ['node', 'script.js', '--approval-mode', 'auto_edit'] },
|
|
1122
|
-
{ args: ['node', 'script.js', '--approval-mode', 'yolo'] },
|
|
1123
|
-
{ args: ['node', 'script.js', '--yolo'] },
|
|
1124
|
-
];
|
|
1125
|
-
|
|
1126
|
-
for (const testCase of testCases) {
|
|
1127
|
-
process.argv = testCase.args;
|
|
1128
|
-
const argv = await parseArguments();
|
|
1129
|
-
const settings: Settings = {};
|
|
1130
|
-
const extensions: Extension[] = [];
|
|
1131
|
-
|
|
1132
|
-
const config = await loadCliConfig(
|
|
1133
|
-
settings,
|
|
1134
|
-
extensions,
|
|
1135
|
-
'test-session',
|
|
1136
|
-
argv,
|
|
1137
|
-
);
|
|
1138
|
-
|
|
1139
|
-
const excludedTools = config.getExcludeTools();
|
|
1140
|
-
expect(excludedTools).not.toContain(ShellTool.Name);
|
|
1141
|
-
expect(excludedTools).not.toContain(EditTool.Name);
|
|
1142
|
-
expect(excludedTools).not.toContain(WriteFileTool.Name);
|
|
1143
|
-
}
|
|
1144
|
-
});
|
|
1145
|
-
|
|
1146
|
-
it('should merge approval mode exclusions with settings exclusions in auto_edit mode', async () => {
|
|
1147
|
-
process.argv = [
|
|
1148
|
-
'node',
|
|
1149
|
-
'script.js',
|
|
1150
|
-
'--approval-mode',
|
|
1151
|
-
'auto_edit',
|
|
1152
|
-
'-p',
|
|
1153
|
-
'test',
|
|
1154
|
-
];
|
|
1155
|
-
const argv = await parseArguments();
|
|
1156
|
-
const settings: Settings = { excludeTools: ['custom_tool'] };
|
|
1157
|
-
const extensions: Extension[] = [];
|
|
1158
|
-
|
|
1159
|
-
const config = await loadCliConfig(
|
|
1160
|
-
settings,
|
|
1161
|
-
extensions,
|
|
1162
|
-
'test-session',
|
|
1163
|
-
argv,
|
|
1164
|
-
);
|
|
1165
|
-
|
|
1166
|
-
const excludedTools = config.getExcludeTools();
|
|
1167
|
-
expect(excludedTools).toContain('custom_tool'); // From settings
|
|
1168
|
-
expect(excludedTools).toContain(ShellTool.Name); // From approval mode
|
|
1169
|
-
expect(excludedTools).not.toContain(EditTool.Name); // Should be allowed in auto_edit
|
|
1170
|
-
expect(excludedTools).not.toContain(WriteFileTool.Name); // Should be allowed in auto_edit
|
|
1171
|
-
});
|
|
1172
|
-
|
|
1173
|
-
it('should throw an error for invalid approval mode values in loadCliConfig', async () => {
|
|
1174
|
-
// Create a mock argv with an invalid approval mode that bypasses argument parsing validation
|
|
1175
|
-
const invalidArgv: Partial<CliArgs> & { approvalMode: string } = {
|
|
1176
|
-
approvalMode: 'invalid_mode',
|
|
1177
|
-
promptInteractive: '',
|
|
1178
|
-
prompt: '',
|
|
1179
|
-
yolo: false,
|
|
1180
|
-
};
|
|
1181
|
-
|
|
1182
|
-
const settings: Settings = {};
|
|
1183
|
-
const extensions: Extension[] = [];
|
|
1184
|
-
|
|
1185
|
-
await expect(
|
|
1186
|
-
loadCliConfig(settings, extensions, 'test-session', invalidArgv),
|
|
1187
|
-
).rejects.toThrow(
|
|
1188
|
-
'Invalid approval mode: invalid_mode. Valid values are: yolo, auto_edit, default',
|
|
1189
|
-
);
|
|
1190
|
-
});
|
|
1191
|
-
});
|
|
1192
|
-
|
|
1193
|
-
describe('loadCliConfig with allowed-mcp-server-names', () => {
|
|
1194
|
-
const originalArgv = process.argv;
|
|
1195
|
-
|
|
1196
|
-
beforeEach(() => {
|
|
1197
|
-
vi.resetAllMocks();
|
|
1198
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1199
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1200
|
-
});
|
|
1201
|
-
|
|
1202
|
-
afterEach(() => {
|
|
1203
|
-
process.argv = originalArgv;
|
|
1204
|
-
vi.unstubAllEnvs();
|
|
1205
|
-
vi.restoreAllMocks();
|
|
1206
|
-
});
|
|
1207
|
-
|
|
1208
|
-
const baseSettings: Settings = {
|
|
1209
|
-
mcpServers: {
|
|
1210
|
-
server1: { url: 'http://localhost:8080' },
|
|
1211
|
-
server2: { url: 'http://localhost:8081' },
|
|
1212
|
-
server3: { url: 'http://localhost:8082' },
|
|
1213
|
-
},
|
|
1214
|
-
};
|
|
1215
|
-
|
|
1216
|
-
it('should allow all MCP servers if the flag is not provided', async () => {
|
|
1217
|
-
process.argv = ['node', 'script.js'];
|
|
1218
|
-
const argv = await parseArguments();
|
|
1219
|
-
const config = await loadCliConfig(baseSettings, [], 'test-session', argv);
|
|
1220
|
-
expect(config.getMcpServers()).toEqual(baseSettings.mcpServers);
|
|
1221
|
-
});
|
|
1222
|
-
|
|
1223
|
-
it('should allow only the specified MCP server', async () => {
|
|
1224
|
-
process.argv = [
|
|
1225
|
-
'node',
|
|
1226
|
-
'script.js',
|
|
1227
|
-
'--allowed-mcp-server-names',
|
|
1228
|
-
'server1',
|
|
1229
|
-
];
|
|
1230
|
-
const argv = await parseArguments();
|
|
1231
|
-
const config = await loadCliConfig(baseSettings, [], 'test-session', argv);
|
|
1232
|
-
expect(config.getMcpServers()).toEqual({
|
|
1233
|
-
server1: { url: 'http://localhost:8080' },
|
|
1234
|
-
});
|
|
1235
|
-
});
|
|
1236
|
-
|
|
1237
|
-
it('should allow multiple specified MCP servers', async () => {
|
|
1238
|
-
process.argv = [
|
|
1239
|
-
'node',
|
|
1240
|
-
'script.js',
|
|
1241
|
-
'--allowed-mcp-server-names',
|
|
1242
|
-
'server1',
|
|
1243
|
-
'--allowed-mcp-server-names',
|
|
1244
|
-
'server3',
|
|
1245
|
-
];
|
|
1246
|
-
const argv = await parseArguments();
|
|
1247
|
-
const config = await loadCliConfig(baseSettings, [], 'test-session', argv);
|
|
1248
|
-
expect(config.getMcpServers()).toEqual({
|
|
1249
|
-
server1: { url: 'http://localhost:8080' },
|
|
1250
|
-
server3: { url: 'http://localhost:8082' },
|
|
1251
|
-
});
|
|
1252
|
-
});
|
|
1253
|
-
|
|
1254
|
-
it('should handle server names that do not exist', async () => {
|
|
1255
|
-
process.argv = [
|
|
1256
|
-
'node',
|
|
1257
|
-
'script.js',
|
|
1258
|
-
'--allowed-mcp-server-names',
|
|
1259
|
-
'server1',
|
|
1260
|
-
'--allowed-mcp-server-names',
|
|
1261
|
-
'server4',
|
|
1262
|
-
];
|
|
1263
|
-
const argv = await parseArguments();
|
|
1264
|
-
const config = await loadCliConfig(baseSettings, [], 'test-session', argv);
|
|
1265
|
-
expect(config.getMcpServers()).toEqual({
|
|
1266
|
-
server1: { url: 'http://localhost:8080' },
|
|
1267
|
-
});
|
|
1268
|
-
});
|
|
1269
|
-
|
|
1270
|
-
it('should allow no MCP servers if the flag is provided but empty', async () => {
|
|
1271
|
-
process.argv = ['node', 'script.js', '--allowed-mcp-server-names', ''];
|
|
1272
|
-
const argv = await parseArguments();
|
|
1273
|
-
const config = await loadCliConfig(baseSettings, [], 'test-session', argv);
|
|
1274
|
-
expect(config.getMcpServers()).toEqual({});
|
|
1275
|
-
});
|
|
1276
|
-
|
|
1277
|
-
it('should read allowMCPServers from settings', async () => {
|
|
1278
|
-
process.argv = ['node', 'script.js'];
|
|
1279
|
-
const argv = await parseArguments();
|
|
1280
|
-
const settings: Settings = {
|
|
1281
|
-
...baseSettings,
|
|
1282
|
-
allowMCPServers: ['server1', 'server2'],
|
|
1283
|
-
};
|
|
1284
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1285
|
-
expect(config.getMcpServers()).toEqual({
|
|
1286
|
-
server1: { url: 'http://localhost:8080' },
|
|
1287
|
-
server2: { url: 'http://localhost:8081' },
|
|
1288
|
-
});
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
|
-
it('should read excludeMCPServers from settings', async () => {
|
|
1292
|
-
process.argv = ['node', 'script.js'];
|
|
1293
|
-
const argv = await parseArguments();
|
|
1294
|
-
const settings: Settings = {
|
|
1295
|
-
...baseSettings,
|
|
1296
|
-
excludeMCPServers: ['server1', 'server2'],
|
|
1297
|
-
};
|
|
1298
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1299
|
-
expect(config.getMcpServers()).toEqual({
|
|
1300
|
-
server3: { url: 'http://localhost:8082' },
|
|
1301
|
-
});
|
|
1302
|
-
});
|
|
1303
|
-
|
|
1304
|
-
it('should override allowMCPServers with excludeMCPServers if overlapping ', async () => {
|
|
1305
|
-
process.argv = ['node', 'script.js'];
|
|
1306
|
-
const argv = await parseArguments();
|
|
1307
|
-
const settings: Settings = {
|
|
1308
|
-
...baseSettings,
|
|
1309
|
-
excludeMCPServers: ['server1'],
|
|
1310
|
-
allowMCPServers: ['server1', 'server2'],
|
|
1311
|
-
};
|
|
1312
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1313
|
-
expect(config.getMcpServers()).toEqual({
|
|
1314
|
-
server2: { url: 'http://localhost:8081' },
|
|
1315
|
-
});
|
|
1316
|
-
});
|
|
1317
|
-
|
|
1318
|
-
it('should prioritize mcp server flag if set ', async () => {
|
|
1319
|
-
process.argv = [
|
|
1320
|
-
'node',
|
|
1321
|
-
'script.js',
|
|
1322
|
-
'--allowed-mcp-server-names',
|
|
1323
|
-
'server1',
|
|
1324
|
-
];
|
|
1325
|
-
const argv = await parseArguments();
|
|
1326
|
-
const settings: Settings = {
|
|
1327
|
-
...baseSettings,
|
|
1328
|
-
excludeMCPServers: ['server1'],
|
|
1329
|
-
allowMCPServers: ['server2'],
|
|
1330
|
-
};
|
|
1331
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1332
|
-
expect(config.getMcpServers()).toEqual({
|
|
1333
|
-
server1: { url: 'http://localhost:8080' },
|
|
1334
|
-
});
|
|
1335
|
-
});
|
|
1336
|
-
});
|
|
1337
|
-
|
|
1338
|
-
describe('loadCliConfig extensions', () => {
|
|
1339
|
-
const mockExtensions: Extension[] = [
|
|
1340
|
-
{
|
|
1341
|
-
config: { name: 'ext1', version: '1.0.0' },
|
|
1342
|
-
contextFiles: ['/path/to/ext1.md'],
|
|
1343
|
-
},
|
|
1344
|
-
{
|
|
1345
|
-
config: { name: 'ext2', version: '1.0.0' },
|
|
1346
|
-
contextFiles: ['/path/to/ext2.md'],
|
|
1347
|
-
},
|
|
1348
|
-
];
|
|
1349
|
-
|
|
1350
|
-
it('should not filter extensions if --extensions flag is not used', async () => {
|
|
1351
|
-
process.argv = ['node', 'script.js'];
|
|
1352
|
-
const argv = await parseArguments();
|
|
1353
|
-
const settings: Settings = {};
|
|
1354
|
-
const config = await loadCliConfig(
|
|
1355
|
-
settings,
|
|
1356
|
-
mockExtensions,
|
|
1357
|
-
'test-session',
|
|
1358
|
-
argv,
|
|
1359
|
-
);
|
|
1360
|
-
expect(config.getExtensionContextFilePaths()).toEqual([
|
|
1361
|
-
'/path/to/ext1.md',
|
|
1362
|
-
'/path/to/ext2.md',
|
|
1363
|
-
]);
|
|
1364
|
-
});
|
|
1365
|
-
|
|
1366
|
-
it('should filter extensions if --extensions flag is used', async () => {
|
|
1367
|
-
process.argv = ['node', 'script.js', '--extensions', 'ext1'];
|
|
1368
|
-
const argv = await parseArguments();
|
|
1369
|
-
const settings: Settings = {};
|
|
1370
|
-
const config = await loadCliConfig(
|
|
1371
|
-
settings,
|
|
1372
|
-
mockExtensions,
|
|
1373
|
-
'test-session',
|
|
1374
|
-
argv,
|
|
1375
|
-
);
|
|
1376
|
-
expect(config.getExtensionContextFilePaths()).toEqual(['/path/to/ext1.md']);
|
|
1377
|
-
});
|
|
1378
|
-
});
|
|
1379
|
-
|
|
1380
|
-
describe('loadCliConfig model selection', () => {
|
|
1381
|
-
it('selects a model from settings.json if provided', async () => {
|
|
1382
|
-
process.argv = ['node', 'script.js'];
|
|
1383
|
-
const argv = await parseArguments();
|
|
1384
|
-
const config = await loadCliConfig(
|
|
1385
|
-
{
|
|
1386
|
-
model: 'qwen3-coder-plus',
|
|
1387
|
-
},
|
|
1388
|
-
[],
|
|
1389
|
-
'test-session',
|
|
1390
|
-
argv,
|
|
1391
|
-
);
|
|
1392
|
-
|
|
1393
|
-
expect(config.getModel()).toBe('qwen3-coder-plus');
|
|
1394
|
-
});
|
|
1395
|
-
|
|
1396
|
-
it('uses the default gemini model if nothing is set', async () => {
|
|
1397
|
-
process.argv = ['node', 'script.js']; // No model set.
|
|
1398
|
-
const argv = await parseArguments();
|
|
1399
|
-
const config = await loadCliConfig(
|
|
1400
|
-
{
|
|
1401
|
-
// No model set.
|
|
1402
|
-
},
|
|
1403
|
-
[],
|
|
1404
|
-
'test-session',
|
|
1405
|
-
argv,
|
|
1406
|
-
);
|
|
1407
|
-
|
|
1408
|
-
expect(config.getModel()).toBe('qwen3-coder-plus');
|
|
1409
|
-
});
|
|
1410
|
-
|
|
1411
|
-
it('always prefers model from argvs', async () => {
|
|
1412
|
-
process.argv = ['node', 'script.js', '--model', 'qwen3-coder-plus'];
|
|
1413
|
-
const argv = await parseArguments();
|
|
1414
|
-
const config = await loadCliConfig(
|
|
1415
|
-
{
|
|
1416
|
-
model: 'qwen3-coder-plus',
|
|
1417
|
-
},
|
|
1418
|
-
[],
|
|
1419
|
-
'test-session',
|
|
1420
|
-
argv,
|
|
1421
|
-
);
|
|
1422
|
-
|
|
1423
|
-
expect(config.getModel()).toBe('qwen3-coder-plus');
|
|
1424
|
-
});
|
|
1425
|
-
|
|
1426
|
-
it('selects the model from argvs if provided', async () => {
|
|
1427
|
-
process.argv = ['node', 'script.js', '--model', 'qwen3-coder-plus'];
|
|
1428
|
-
const argv = await parseArguments();
|
|
1429
|
-
const config = await loadCliConfig(
|
|
1430
|
-
{
|
|
1431
|
-
// No model provided via settings.
|
|
1432
|
-
},
|
|
1433
|
-
[],
|
|
1434
|
-
'test-session',
|
|
1435
|
-
argv,
|
|
1436
|
-
);
|
|
1437
|
-
|
|
1438
|
-
expect(config.getModel()).toBe('qwen3-coder-plus');
|
|
1439
|
-
});
|
|
1440
|
-
});
|
|
1441
|
-
|
|
1442
|
-
describe('loadCliConfig folderTrustFeature', () => {
|
|
1443
|
-
const originalArgv = process.argv;
|
|
1444
|
-
|
|
1445
|
-
beforeEach(() => {
|
|
1446
|
-
vi.resetAllMocks();
|
|
1447
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1448
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1449
|
-
});
|
|
1450
|
-
|
|
1451
|
-
afterEach(() => {
|
|
1452
|
-
process.argv = originalArgv;
|
|
1453
|
-
vi.unstubAllEnvs();
|
|
1454
|
-
vi.restoreAllMocks();
|
|
1455
|
-
});
|
|
1456
|
-
|
|
1457
|
-
it('should be false by default', async () => {
|
|
1458
|
-
process.argv = ['node', 'script.js'];
|
|
1459
|
-
const settings: Settings = {};
|
|
1460
|
-
const argv = await parseArguments();
|
|
1461
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1462
|
-
expect(config.getFolderTrustFeature()).toBe(false);
|
|
1463
|
-
});
|
|
1464
|
-
|
|
1465
|
-
it('should be true when settings.folderTrustFeature is true', async () => {
|
|
1466
|
-
process.argv = ['node', 'script.js'];
|
|
1467
|
-
const argv = await parseArguments();
|
|
1468
|
-
const settings: Settings = { folderTrustFeature: true };
|
|
1469
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1470
|
-
expect(config.getFolderTrustFeature()).toBe(true);
|
|
1471
|
-
});
|
|
1472
|
-
});
|
|
1473
|
-
|
|
1474
|
-
describe('loadCliConfig folderTrust', () => {
|
|
1475
|
-
const originalArgv = process.argv;
|
|
1476
|
-
|
|
1477
|
-
beforeEach(() => {
|
|
1478
|
-
vi.resetAllMocks();
|
|
1479
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1480
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1481
|
-
});
|
|
1482
|
-
|
|
1483
|
-
afterEach(() => {
|
|
1484
|
-
process.argv = originalArgv;
|
|
1485
|
-
vi.unstubAllEnvs();
|
|
1486
|
-
vi.restoreAllMocks();
|
|
1487
|
-
});
|
|
1488
|
-
|
|
1489
|
-
it('should be false if folderTrustFeature is false and folderTrust is false', async () => {
|
|
1490
|
-
process.argv = ['node', 'script.js'];
|
|
1491
|
-
const settings: Settings = {
|
|
1492
|
-
folderTrustFeature: false,
|
|
1493
|
-
folderTrust: false,
|
|
1494
|
-
};
|
|
1495
|
-
const argv = await parseArguments();
|
|
1496
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1497
|
-
expect(config.getFolderTrust()).toBe(false);
|
|
1498
|
-
});
|
|
1499
|
-
|
|
1500
|
-
it('should be false if folderTrustFeature is true and folderTrust is false', async () => {
|
|
1501
|
-
process.argv = ['node', 'script.js'];
|
|
1502
|
-
const argv = await parseArguments();
|
|
1503
|
-
const settings: Settings = { folderTrustFeature: true, folderTrust: false };
|
|
1504
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1505
|
-
expect(config.getFolderTrust()).toBe(false);
|
|
1506
|
-
});
|
|
1507
|
-
|
|
1508
|
-
it('should be false if folderTrustFeature is false and folderTrust is true', async () => {
|
|
1509
|
-
process.argv = ['node', 'script.js'];
|
|
1510
|
-
const argv = await parseArguments();
|
|
1511
|
-
const settings: Settings = { folderTrustFeature: false, folderTrust: true };
|
|
1512
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1513
|
-
expect(config.getFolderTrust()).toBe(false);
|
|
1514
|
-
});
|
|
1515
|
-
|
|
1516
|
-
it('should be true when folderTrustFeature is true and folderTrust is true', async () => {
|
|
1517
|
-
process.argv = ['node', 'script.js'];
|
|
1518
|
-
const argv = await parseArguments();
|
|
1519
|
-
const settings: Settings = { folderTrustFeature: true, folderTrust: true };
|
|
1520
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1521
|
-
expect(config.getFolderTrust()).toBe(true);
|
|
1522
|
-
});
|
|
1523
|
-
});
|
|
1524
|
-
|
|
1525
|
-
vi.mock('fs', async () => {
|
|
1526
|
-
const actualFs = await vi.importActual<typeof fs>('fs');
|
|
1527
|
-
const MOCK_CWD1 = process.cwd();
|
|
1528
|
-
const MOCK_CWD2 = path.resolve(path.sep, 'home', 'user', 'project');
|
|
1529
|
-
|
|
1530
|
-
const mockPaths = new Set([
|
|
1531
|
-
MOCK_CWD1,
|
|
1532
|
-
MOCK_CWD2,
|
|
1533
|
-
path.resolve(path.sep, 'cli', 'path1'),
|
|
1534
|
-
path.resolve(path.sep, 'settings', 'path1'),
|
|
1535
|
-
path.join(os.homedir(), 'settings', 'path2'),
|
|
1536
|
-
path.join(MOCK_CWD2, 'cli', 'path2'),
|
|
1537
|
-
path.join(MOCK_CWD2, 'settings', 'path3'),
|
|
1538
|
-
]);
|
|
1539
|
-
|
|
1540
|
-
return {
|
|
1541
|
-
...actualFs,
|
|
1542
|
-
existsSync: vi.fn((p) => mockPaths.has(p.toString())),
|
|
1543
|
-
statSync: vi.fn((p) => {
|
|
1544
|
-
if (mockPaths.has(p.toString())) {
|
|
1545
|
-
return { isDirectory: () => true };
|
|
1546
|
-
}
|
|
1547
|
-
// Fallback for other paths if needed, though the test should be specific.
|
|
1548
|
-
return actualFs.statSync(p);
|
|
1549
|
-
}),
|
|
1550
|
-
realpathSync: vi.fn((p) => p),
|
|
1551
|
-
};
|
|
1552
|
-
});
|
|
1553
|
-
|
|
1554
|
-
describe('loadCliConfig with includeDirectories', () => {
|
|
1555
|
-
const originalArgv = process.argv;
|
|
1556
|
-
|
|
1557
|
-
beforeEach(() => {
|
|
1558
|
-
vi.resetAllMocks();
|
|
1559
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1560
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1561
|
-
vi.spyOn(process, 'cwd').mockReturnValue(
|
|
1562
|
-
path.resolve(path.sep, 'home', 'user', 'project'),
|
|
1563
|
-
);
|
|
1564
|
-
});
|
|
1565
|
-
|
|
1566
|
-
afterEach(() => {
|
|
1567
|
-
process.argv = originalArgv;
|
|
1568
|
-
vi.unstubAllEnvs();
|
|
1569
|
-
vi.restoreAllMocks();
|
|
1570
|
-
});
|
|
1571
|
-
|
|
1572
|
-
it('should combine and resolve paths from settings and CLI arguments', async () => {
|
|
1573
|
-
const mockCwd = path.resolve(path.sep, 'home', 'user', 'project');
|
|
1574
|
-
process.argv = [
|
|
1575
|
-
'node',
|
|
1576
|
-
'script.js',
|
|
1577
|
-
'--include-directories',
|
|
1578
|
-
`${path.resolve(path.sep, 'cli', 'path1')},${path.join(mockCwd, 'cli', 'path2')}`,
|
|
1579
|
-
];
|
|
1580
|
-
const argv = await parseArguments();
|
|
1581
|
-
const settings: Settings = {
|
|
1582
|
-
includeDirectories: [
|
|
1583
|
-
path.resolve(path.sep, 'settings', 'path1'),
|
|
1584
|
-
path.join(os.homedir(), 'settings', 'path2'),
|
|
1585
|
-
path.join(mockCwd, 'settings', 'path3'),
|
|
1586
|
-
],
|
|
1587
|
-
};
|
|
1588
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1589
|
-
const expected = [
|
|
1590
|
-
mockCwd,
|
|
1591
|
-
path.resolve(path.sep, 'cli', 'path1'),
|
|
1592
|
-
path.join(mockCwd, 'cli', 'path2'),
|
|
1593
|
-
path.resolve(path.sep, 'settings', 'path1'),
|
|
1594
|
-
path.join(os.homedir(), 'settings', 'path2'),
|
|
1595
|
-
path.join(mockCwd, 'settings', 'path3'),
|
|
1596
|
-
];
|
|
1597
|
-
expect(config.getWorkspaceContext().getDirectories()).toEqual(
|
|
1598
|
-
expect.arrayContaining(expected),
|
|
1599
|
-
);
|
|
1600
|
-
expect(config.getWorkspaceContext().getDirectories()).toHaveLength(
|
|
1601
|
-
expected.length,
|
|
1602
|
-
);
|
|
1603
|
-
});
|
|
1604
|
-
});
|
|
1605
|
-
|
|
1606
|
-
describe('loadCliConfig chatCompression', () => {
|
|
1607
|
-
const originalArgv = process.argv;
|
|
1608
|
-
|
|
1609
|
-
beforeEach(() => {
|
|
1610
|
-
vi.resetAllMocks();
|
|
1611
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1612
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1613
|
-
});
|
|
1614
|
-
|
|
1615
|
-
afterEach(() => {
|
|
1616
|
-
process.argv = originalArgv;
|
|
1617
|
-
vi.unstubAllEnvs();
|
|
1618
|
-
vi.restoreAllMocks();
|
|
1619
|
-
});
|
|
1620
|
-
|
|
1621
|
-
it('should pass chatCompression settings to the core config', async () => {
|
|
1622
|
-
process.argv = ['node', 'script.js'];
|
|
1623
|
-
const argv = await parseArguments();
|
|
1624
|
-
const settings: Settings = {
|
|
1625
|
-
chatCompression: {
|
|
1626
|
-
contextPercentageThreshold: 0.5,
|
|
1627
|
-
},
|
|
1628
|
-
};
|
|
1629
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1630
|
-
expect(config.getChatCompression()).toEqual({
|
|
1631
|
-
contextPercentageThreshold: 0.5,
|
|
1632
|
-
});
|
|
1633
|
-
});
|
|
1634
|
-
|
|
1635
|
-
it('should have undefined chatCompression if not in settings', async () => {
|
|
1636
|
-
process.argv = ['node', 'script.js'];
|
|
1637
|
-
const argv = await parseArguments();
|
|
1638
|
-
const settings: Settings = {};
|
|
1639
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1640
|
-
expect(config.getChatCompression()).toBeUndefined();
|
|
1641
|
-
});
|
|
1642
|
-
});
|
|
1643
|
-
|
|
1644
|
-
describe('loadCliConfig tool exclusions', () => {
|
|
1645
|
-
const originalArgv = process.argv;
|
|
1646
|
-
const originalIsTTY = process.stdin.isTTY;
|
|
1647
|
-
|
|
1648
|
-
beforeEach(() => {
|
|
1649
|
-
vi.resetAllMocks();
|
|
1650
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1651
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1652
|
-
process.stdin.isTTY = true;
|
|
1653
|
-
});
|
|
1654
|
-
|
|
1655
|
-
afterEach(() => {
|
|
1656
|
-
process.argv = originalArgv;
|
|
1657
|
-
process.stdin.isTTY = originalIsTTY;
|
|
1658
|
-
vi.unstubAllEnvs();
|
|
1659
|
-
vi.restoreAllMocks();
|
|
1660
|
-
});
|
|
1661
|
-
|
|
1662
|
-
it('should not exclude interactive tools in interactive mode without YOLO', async () => {
|
|
1663
|
-
process.stdin.isTTY = true;
|
|
1664
|
-
process.argv = ['node', 'script.js'];
|
|
1665
|
-
const argv = await parseArguments();
|
|
1666
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1667
|
-
expect(config.getExcludeTools()).not.toContain('run_shell_command');
|
|
1668
|
-
expect(config.getExcludeTools()).not.toContain('replace');
|
|
1669
|
-
expect(config.getExcludeTools()).not.toContain('write_file');
|
|
1670
|
-
});
|
|
1671
|
-
|
|
1672
|
-
it('should not exclude interactive tools in interactive mode with YOLO', async () => {
|
|
1673
|
-
process.stdin.isTTY = true;
|
|
1674
|
-
process.argv = ['node', 'script.js', '--yolo'];
|
|
1675
|
-
const argv = await parseArguments();
|
|
1676
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1677
|
-
expect(config.getExcludeTools()).not.toContain('run_shell_command');
|
|
1678
|
-
expect(config.getExcludeTools()).not.toContain('replace');
|
|
1679
|
-
expect(config.getExcludeTools()).not.toContain('write_file');
|
|
1680
|
-
});
|
|
1681
|
-
|
|
1682
|
-
it('should exclude interactive tools in non-interactive mode without YOLO', async () => {
|
|
1683
|
-
process.stdin.isTTY = false;
|
|
1684
|
-
process.argv = ['node', 'script.js', '-p', 'test'];
|
|
1685
|
-
const argv = await parseArguments();
|
|
1686
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1687
|
-
expect(config.getExcludeTools()).toContain('run_shell_command');
|
|
1688
|
-
expect(config.getExcludeTools()).toContain('replace');
|
|
1689
|
-
expect(config.getExcludeTools()).toContain('write_file');
|
|
1690
|
-
});
|
|
1691
|
-
|
|
1692
|
-
it('should not exclude interactive tools in non-interactive mode with YOLO', async () => {
|
|
1693
|
-
process.stdin.isTTY = false;
|
|
1694
|
-
process.argv = ['node', 'script.js', '-p', 'test', '--yolo'];
|
|
1695
|
-
const argv = await parseArguments();
|
|
1696
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1697
|
-
expect(config.getExcludeTools()).not.toContain('run_shell_command');
|
|
1698
|
-
expect(config.getExcludeTools()).not.toContain('replace');
|
|
1699
|
-
expect(config.getExcludeTools()).not.toContain('write_file');
|
|
1700
|
-
});
|
|
1701
|
-
});
|
|
1702
|
-
|
|
1703
|
-
describe('loadCliConfig interactive', () => {
|
|
1704
|
-
const originalArgv = process.argv;
|
|
1705
|
-
const originalIsTTY = process.stdin.isTTY;
|
|
1706
|
-
|
|
1707
|
-
beforeEach(() => {
|
|
1708
|
-
vi.resetAllMocks();
|
|
1709
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1710
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1711
|
-
process.stdin.isTTY = true;
|
|
1712
|
-
});
|
|
1713
|
-
|
|
1714
|
-
afterEach(() => {
|
|
1715
|
-
process.argv = originalArgv;
|
|
1716
|
-
process.stdin.isTTY = originalIsTTY;
|
|
1717
|
-
vi.unstubAllEnvs();
|
|
1718
|
-
vi.restoreAllMocks();
|
|
1719
|
-
});
|
|
1720
|
-
|
|
1721
|
-
it('should be interactive if isTTY and no prompt', async () => {
|
|
1722
|
-
process.stdin.isTTY = true;
|
|
1723
|
-
process.argv = ['node', 'script.js'];
|
|
1724
|
-
const argv = await parseArguments();
|
|
1725
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1726
|
-
expect(config.isInteractive()).toBe(true);
|
|
1727
|
-
});
|
|
1728
|
-
|
|
1729
|
-
it('should be interactive if prompt-interactive is set', async () => {
|
|
1730
|
-
process.stdin.isTTY = false;
|
|
1731
|
-
process.argv = ['node', 'script.js', '--prompt-interactive', 'test'];
|
|
1732
|
-
const argv = await parseArguments();
|
|
1733
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1734
|
-
expect(config.isInteractive()).toBe(true);
|
|
1735
|
-
});
|
|
1736
|
-
|
|
1737
|
-
it('should not be interactive if not isTTY and no prompt', async () => {
|
|
1738
|
-
process.stdin.isTTY = false;
|
|
1739
|
-
process.argv = ['node', 'script.js'];
|
|
1740
|
-
const argv = await parseArguments();
|
|
1741
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1742
|
-
expect(config.isInteractive()).toBe(false);
|
|
1743
|
-
});
|
|
1744
|
-
|
|
1745
|
-
it('should not be interactive if prompt is set', async () => {
|
|
1746
|
-
process.stdin.isTTY = true;
|
|
1747
|
-
process.argv = ['node', 'script.js', '--prompt', 'test'];
|
|
1748
|
-
const argv = await parseArguments();
|
|
1749
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1750
|
-
expect(config.isInteractive()).toBe(false);
|
|
1751
|
-
});
|
|
1752
|
-
});
|
|
1753
|
-
|
|
1754
|
-
describe('loadCliConfig approval mode', () => {
|
|
1755
|
-
const originalArgv = process.argv;
|
|
1756
|
-
|
|
1757
|
-
beforeEach(() => {
|
|
1758
|
-
vi.resetAllMocks();
|
|
1759
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1760
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1761
|
-
process.argv = ['node', 'script.js']; // Reset argv for each test
|
|
1762
|
-
});
|
|
1763
|
-
|
|
1764
|
-
afterEach(() => {
|
|
1765
|
-
process.argv = originalArgv;
|
|
1766
|
-
vi.unstubAllEnvs();
|
|
1767
|
-
vi.restoreAllMocks();
|
|
1768
|
-
});
|
|
1769
|
-
|
|
1770
|
-
it('should default to DEFAULT approval mode when no flags are set', async () => {
|
|
1771
|
-
process.argv = ['node', 'script.js'];
|
|
1772
|
-
const argv = await parseArguments();
|
|
1773
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1774
|
-
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1775
|
-
});
|
|
1776
|
-
|
|
1777
|
-
it('should set YOLO approval mode when --yolo flag is used', async () => {
|
|
1778
|
-
process.argv = ['node', 'script.js', '--yolo'];
|
|
1779
|
-
const argv = await parseArguments();
|
|
1780
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1781
|
-
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.YOLO);
|
|
1782
|
-
});
|
|
1783
|
-
|
|
1784
|
-
it('should set YOLO approval mode when -y flag is used', async () => {
|
|
1785
|
-
process.argv = ['node', 'script.js', '-y'];
|
|
1786
|
-
const argv = await parseArguments();
|
|
1787
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1788
|
-
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.YOLO);
|
|
1789
|
-
});
|
|
1790
|
-
|
|
1791
|
-
it('should set DEFAULT approval mode when --approval-mode=default', async () => {
|
|
1792
|
-
process.argv = ['node', 'script.js', '--approval-mode', 'default'];
|
|
1793
|
-
const argv = await parseArguments();
|
|
1794
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1795
|
-
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1796
|
-
});
|
|
1797
|
-
|
|
1798
|
-
it('should set AUTO_EDIT approval mode when --approval-mode=auto_edit', async () => {
|
|
1799
|
-
process.argv = ['node', 'script.js', '--approval-mode', 'auto_edit'];
|
|
1800
|
-
const argv = await parseArguments();
|
|
1801
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1802
|
-
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.AUTO_EDIT);
|
|
1803
|
-
});
|
|
1804
|
-
|
|
1805
|
-
it('should set YOLO approval mode when --approval-mode=yolo', async () => {
|
|
1806
|
-
process.argv = ['node', 'script.js', '--approval-mode', 'yolo'];
|
|
1807
|
-
const argv = await parseArguments();
|
|
1808
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1809
|
-
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.YOLO);
|
|
1810
|
-
});
|
|
1811
|
-
|
|
1812
|
-
it('should prioritize --approval-mode over --yolo when both would be valid (but validation prevents this)', async () => {
|
|
1813
|
-
// Note: This test documents the intended behavior, but in practice the validation
|
|
1814
|
-
// prevents both flags from being used together
|
|
1815
|
-
process.argv = ['node', 'script.js', '--approval-mode', 'default'];
|
|
1816
|
-
const argv = await parseArguments();
|
|
1817
|
-
// Manually set yolo to true to simulate what would happen if validation didn't prevent it
|
|
1818
|
-
argv.yolo = true;
|
|
1819
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1820
|
-
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.DEFAULT);
|
|
1821
|
-
});
|
|
1822
|
-
|
|
1823
|
-
it('should fall back to --yolo behavior when --approval-mode is not set', async () => {
|
|
1824
|
-
process.argv = ['node', 'script.js', '--yolo'];
|
|
1825
|
-
const argv = await parseArguments();
|
|
1826
|
-
const config = await loadCliConfig({}, [], 'test-session', argv);
|
|
1827
|
-
expect(config.getApprovalMode()).toBe(ServerConfig.ApprovalMode.YOLO);
|
|
1828
|
-
});
|
|
1829
|
-
});
|
|
1830
|
-
|
|
1831
|
-
describe('loadCliConfig trustedFolder', () => {
|
|
1832
|
-
const originalArgv = process.argv;
|
|
1833
|
-
|
|
1834
|
-
beforeEach(() => {
|
|
1835
|
-
vi.resetAllMocks();
|
|
1836
|
-
vi.mocked(os.homedir).mockReturnValue('/mock/home/user');
|
|
1837
|
-
vi.stubEnv('GEMINI_API_KEY', 'test-api-key');
|
|
1838
|
-
process.argv = ['node', 'script.js']; // Reset argv for each test
|
|
1839
|
-
});
|
|
1840
|
-
|
|
1841
|
-
afterEach(() => {
|
|
1842
|
-
process.argv = originalArgv;
|
|
1843
|
-
vi.unstubAllEnvs();
|
|
1844
|
-
vi.restoreAllMocks();
|
|
1845
|
-
});
|
|
1846
|
-
|
|
1847
|
-
const testCases = [
|
|
1848
|
-
// Cases where folderTrustFeature is false (feature disabled)
|
|
1849
|
-
{
|
|
1850
|
-
folderTrustFeature: false,
|
|
1851
|
-
folderTrust: true,
|
|
1852
|
-
isWorkspaceTrusted: true,
|
|
1853
|
-
expectedFolderTrust: false,
|
|
1854
|
-
expectedIsTrustedFolder: true,
|
|
1855
|
-
description:
|
|
1856
|
-
'feature disabled, folderTrust true, workspace trusted -> behave as trusted',
|
|
1857
|
-
},
|
|
1858
|
-
{
|
|
1859
|
-
folderTrustFeature: false,
|
|
1860
|
-
folderTrust: true,
|
|
1861
|
-
isWorkspaceTrusted: false,
|
|
1862
|
-
expectedFolderTrust: false,
|
|
1863
|
-
expectedIsTrustedFolder: true,
|
|
1864
|
-
description:
|
|
1865
|
-
'feature disabled, folderTrust true, workspace not trusted -> behave as trusted',
|
|
1866
|
-
},
|
|
1867
|
-
{
|
|
1868
|
-
folderTrustFeature: false,
|
|
1869
|
-
folderTrust: false,
|
|
1870
|
-
isWorkspaceTrusted: true,
|
|
1871
|
-
expectedFolderTrust: false,
|
|
1872
|
-
expectedIsTrustedFolder: true,
|
|
1873
|
-
description:
|
|
1874
|
-
'feature disabled, folderTrust false, workspace trusted -> behave as trusted',
|
|
1875
|
-
},
|
|
1876
|
-
|
|
1877
|
-
// Cases where folderTrustFeature is true but folderTrust setting is false
|
|
1878
|
-
{
|
|
1879
|
-
folderTrustFeature: true,
|
|
1880
|
-
folderTrust: false,
|
|
1881
|
-
isWorkspaceTrusted: true,
|
|
1882
|
-
expectedFolderTrust: false,
|
|
1883
|
-
expectedIsTrustedFolder: true,
|
|
1884
|
-
description:
|
|
1885
|
-
'feature on, folderTrust false, workspace trusted -> behave as trusted',
|
|
1886
|
-
},
|
|
1887
|
-
{
|
|
1888
|
-
folderTrustFeature: true,
|
|
1889
|
-
folderTrust: false,
|
|
1890
|
-
isWorkspaceTrusted: false,
|
|
1891
|
-
expectedFolderTrust: false,
|
|
1892
|
-
expectedIsTrustedFolder: true,
|
|
1893
|
-
description:
|
|
1894
|
-
'feature on, folderTrust false, workspace not trusted -> behave as trusted',
|
|
1895
|
-
},
|
|
1896
|
-
|
|
1897
|
-
// Cases where feature is fully enabled (folderTrustFeature and folderTrust are true)
|
|
1898
|
-
{
|
|
1899
|
-
folderTrustFeature: true,
|
|
1900
|
-
folderTrust: true,
|
|
1901
|
-
isWorkspaceTrusted: true,
|
|
1902
|
-
expectedFolderTrust: true,
|
|
1903
|
-
expectedIsTrustedFolder: true,
|
|
1904
|
-
description:
|
|
1905
|
-
'feature on, folderTrust on, workspace trusted -> is trusted',
|
|
1906
|
-
},
|
|
1907
|
-
{
|
|
1908
|
-
folderTrustFeature: true,
|
|
1909
|
-
folderTrust: true,
|
|
1910
|
-
isWorkspaceTrusted: false,
|
|
1911
|
-
expectedFolderTrust: true,
|
|
1912
|
-
expectedIsTrustedFolder: false,
|
|
1913
|
-
description:
|
|
1914
|
-
'feature on, folderTrust on, workspace NOT trusted -> is NOT trusted',
|
|
1915
|
-
},
|
|
1916
|
-
{
|
|
1917
|
-
folderTrustFeature: true,
|
|
1918
|
-
folderTrust: true,
|
|
1919
|
-
isWorkspaceTrusted: undefined,
|
|
1920
|
-
expectedFolderTrust: true,
|
|
1921
|
-
expectedIsTrustedFolder: undefined,
|
|
1922
|
-
description:
|
|
1923
|
-
'feature on, folderTrust on, workspace trust unknown -> is unknown',
|
|
1924
|
-
},
|
|
1925
|
-
];
|
|
1926
|
-
|
|
1927
|
-
for (const {
|
|
1928
|
-
folderTrustFeature,
|
|
1929
|
-
folderTrust,
|
|
1930
|
-
isWorkspaceTrusted: mockTrustValue,
|
|
1931
|
-
expectedFolderTrust,
|
|
1932
|
-
expectedIsTrustedFolder,
|
|
1933
|
-
description,
|
|
1934
|
-
} of testCases) {
|
|
1935
|
-
it(`should be correct for: ${description}`, async () => {
|
|
1936
|
-
(isWorkspaceTrusted as vi.Mock).mockImplementation(
|
|
1937
|
-
(settings: Settings) => {
|
|
1938
|
-
const featureIsEnabled =
|
|
1939
|
-
(settings.folderTrustFeature ?? false) &&
|
|
1940
|
-
(settings.folderTrust ?? true);
|
|
1941
|
-
return featureIsEnabled ? mockTrustValue : true;
|
|
1942
|
-
},
|
|
1943
|
-
);
|
|
1944
|
-
const argv = await parseArguments();
|
|
1945
|
-
const settings: Settings = { folderTrustFeature, folderTrust };
|
|
1946
|
-
const config = await loadCliConfig(settings, [], 'test-session', argv);
|
|
1947
|
-
|
|
1948
|
-
expect(config.getFolderTrust()).toBe(expectedFolderTrust);
|
|
1949
|
-
expect(config.isTrustedFolder()).toBe(expectedIsTrustedFolder);
|
|
1950
|
-
});
|
|
1951
|
-
}
|
|
1952
|
-
});
|