@machina.ai/cell-cli 1.10.0-rc1 → 1.13.0-rc1
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 +5 -5
- package/dist/index.js.map +1 -1
- package/dist/package.json +14 -12
- package/dist/src/commands/extensions/disable.d.ts +1 -1
- package/dist/src/commands/extensions/disable.js +19 -8
- package/dist/src/commands/extensions/disable.js.map +1 -1
- package/dist/src/commands/extensions/enable.d.ts +1 -1
- package/dist/src/commands/extensions/enable.js +19 -9
- package/dist/src/commands/extensions/enable.js.map +1 -1
- package/dist/src/commands/extensions/examples/mcp-server/example.js +46 -0
- package/dist/src/commands/extensions/examples/mcp-server/example.js.map +1 -0
- package/dist/src/commands/extensions/install.d.ts +1 -0
- package/dist/src/commands/extensions/install.js +29 -4
- package/dist/src/commands/extensions/install.js.map +1 -1
- package/dist/src/commands/extensions/install.test.js +39 -19
- package/dist/src/commands/extensions/install.test.js.map +1 -1
- package/dist/src/commands/extensions/link.js +16 -4
- package/dist/src/commands/extensions/link.js.map +1 -1
- package/dist/src/commands/extensions/list.js +17 -6
- package/dist/src/commands/extensions/list.js.map +1 -1
- package/dist/src/commands/extensions/new.js +14 -20
- package/dist/src/commands/extensions/new.js.map +1 -1
- package/dist/src/commands/extensions/uninstall.js +16 -4
- package/dist/src/commands/extensions/uninstall.js.map +1 -1
- package/dist/src/commands/extensions/update.js +28 -23
- package/dist/src/commands/extensions/update.js.map +1 -1
- package/dist/src/commands/extensions/validate.d.ts +12 -0
- package/dist/src/commands/extensions/validate.js +83 -0
- package/dist/src/commands/extensions/validate.js.map +1 -0
- package/dist/src/commands/extensions/validate.test.d.ts +6 -0
- package/dist/src/commands/extensions/validate.test.js +93 -0
- package/dist/src/commands/extensions/validate.test.js.map +1 -0
- package/dist/src/commands/extensions.js +3 -0
- package/dist/src/commands/extensions.js.map +1 -1
- package/dist/src/commands/mcp/add.js +7 -4
- package/dist/src/commands/mcp/add.js.map +1 -1
- package/dist/src/commands/mcp/add.test.d.ts +6 -0
- package/dist/src/commands/mcp/add.test.js +247 -0
- package/dist/src/commands/mcp/add.test.js.map +1 -0
- package/dist/src/commands/mcp/list.js +18 -9
- package/dist/src/commands/mcp/list.js.map +1 -1
- package/dist/src/commands/mcp/list.test.d.ts +6 -0
- package/dist/src/commands/mcp/list.test.js +128 -0
- package/dist/src/commands/mcp/list.test.js.map +1 -0
- package/dist/src/commands/mcp/remove.js +3 -2
- package/dist/src/commands/mcp/remove.js.map +1 -1
- package/dist/src/commands/mcp/remove.test.d.ts +6 -0
- package/dist/src/commands/mcp/remove.test.js +175 -0
- package/dist/src/commands/mcp/remove.test.js.map +1 -0
- package/dist/src/commands/mcp.test.d.ts +6 -0
- package/dist/src/commands/mcp.test.js +62 -0
- package/dist/src/commands/mcp.test.js.map +1 -0
- package/dist/src/config/auth.js +0 -3
- package/dist/src/config/auth.js.map +1 -1
- package/dist/src/config/config.d.ts +6 -15
- package/dist/src/config/config.integration.test.d.ts +6 -0
- package/dist/src/config/config.integration.test.js +321 -0
- package/dist/src/config/config.integration.test.js.map +1 -0
- package/dist/src/config/config.js +85 -164
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.d.ts +6 -0
- package/dist/src/config/config.test.js +1972 -0
- package/dist/src/config/config.test.js.map +1 -0
- package/dist/src/config/extension-manager.d.ts +63 -0
- package/dist/src/config/extension-manager.js +450 -0
- package/dist/src/config/extension-manager.js.map +1 -0
- package/dist/src/config/extension.d.ts +4 -61
- package/dist/src/config/extension.js +1 -538
- package/dist/src/config/extension.js.map +1 -1
- package/dist/src/config/extension.test.d.ts +6 -0
- package/dist/src/config/extension.test.js +1412 -0
- package/dist/src/config/extension.test.js.map +1 -0
- package/dist/src/config/extensions/consent.d.ts +38 -0
- package/dist/src/config/extensions/consent.js +123 -0
- package/dist/src/config/extensions/consent.js.map +1 -0
- package/dist/src/config/extensions/extensionEnablement.d.ts +2 -2
- package/dist/src/config/extensions/extensionEnablement.js +7 -5
- package/dist/src/config/extensions/extensionEnablement.js.map +1 -1
- package/dist/src/config/extensions/extensionEnablement.test.js +31 -28
- package/dist/src/config/extensions/extensionEnablement.test.js.map +1 -1
- package/dist/src/config/extensions/extensionSettings.d.ts +15 -0
- package/dist/src/config/extensions/extensionSettings.js +113 -0
- package/dist/src/config/extensions/extensionSettings.js.map +1 -0
- package/dist/src/config/extensions/extensionSettings.test.d.ts +6 -0
- package/dist/src/config/extensions/extensionSettings.test.js +254 -0
- package/dist/src/config/extensions/extensionSettings.test.js.map +1 -0
- package/dist/src/config/extensions/github.d.ts +18 -9
- package/dist/src/config/extensions/github.js +108 -36
- package/dist/src/config/extensions/github.js.map +1 -1
- package/dist/src/config/extensions/github.test.js +158 -164
- package/dist/src/config/extensions/github.test.js.map +1 -1
- package/dist/src/config/extensions/github_fetch.d.ts +1 -1
- package/dist/src/config/extensions/github_fetch.js +13 -1
- package/dist/src/config/extensions/github_fetch.js.map +1 -1
- package/dist/src/config/extensions/github_fetch.test.d.ts +6 -0
- package/dist/src/config/extensions/github_fetch.test.js +169 -0
- package/dist/src/config/extensions/github_fetch.test.js.map +1 -0
- package/dist/src/config/extensions/storage.d.ts +14 -0
- package/dist/src/config/extensions/storage.js +32 -0
- package/dist/src/config/extensions/storage.js.map +1 -0
- package/dist/src/config/extensions/update.d.ts +5 -4
- package/dist/src/config/extensions/update.js +41 -37
- package/dist/src/config/extensions/update.js.map +1 -1
- package/dist/src/config/extensions/update.test.js +72 -74
- package/dist/src/config/extensions/update.test.js.map +1 -1
- package/dist/src/config/extensions/variableSchema.d.ts +0 -4
- package/dist/src/config/extensions/variableSchema.js.map +1 -1
- package/dist/src/config/extensions/variables.d.ts +4 -0
- package/dist/src/config/extensions/variables.js +6 -0
- package/dist/src/config/extensions/variables.js.map +1 -1
- package/dist/src/config/keyBindings.d.ts +5 -1
- package/dist/src/config/keyBindings.js +34 -10
- package/dist/src/config/keyBindings.js.map +1 -1
- package/dist/src/config/keyBindings.test.js +17 -0
- package/dist/src/config/keyBindings.test.js.map +1 -1
- package/dist/src/config/policies/read-only.toml +56 -0
- package/dist/src/config/policies/write.toml +63 -0
- package/dist/src/config/policies/yolo.toml +31 -0
- package/dist/src/config/policy-engine.integration.test.js +41 -38
- package/dist/src/config/policy-engine.integration.test.js.map +1 -1
- package/dist/src/config/policy.d.ts +4 -3
- package/dist/src/config/policy.js +13 -142
- package/dist/src/config/policy.js.map +1 -1
- package/dist/src/config/sandboxConfig.d.ts +1 -2
- package/dist/src/config/sandboxConfig.js +7 -6
- package/dist/src/config/sandboxConfig.js.map +1 -1
- package/dist/src/config/settings.d.ts +2 -1
- package/dist/src/config/settings.js +59 -15
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/settings.test.d.ts +6 -0
- package/dist/src/config/settings.test.js +2000 -0
- package/dist/src/config/settings.test.js.map +1 -0
- package/dist/src/config/settingsSchema.d.ts +170 -28
- package/dist/src/config/settingsSchema.js +418 -27
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/config/settingsSchema.test.js +42 -1
- package/dist/src/config/settingsSchema.test.js.map +1 -1
- package/dist/src/config/trustedFolders.d.ts +1 -1
- package/dist/src/config/trustedFolders.js +4 -2
- package/dist/src/config/trustedFolders.js.map +1 -1
- package/dist/src/core/initializer.js +2 -1
- package/dist/src/core/initializer.js.map +1 -1
- package/dist/src/gemini.d.ts +1 -1
- package/dist/src/gemini.js +63 -27
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/gemini.test.js +123 -34
- package/dist/src/gemini.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/nonInteractiveCli.d.ts +9 -1
- package/dist/src/nonInteractiveCli.js +205 -10
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/nonInteractiveCli.test.d.ts +6 -0
- package/dist/src/nonInteractiveCli.test.js +984 -0
- package/dist/src/nonInteractiveCli.test.js.map +1 -0
- package/dist/src/nonInteractiveCliCommands.js +2 -2
- package/dist/src/nonInteractiveCliCommands.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +4 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.test.js +22 -0
- package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -1
- package/dist/src/services/CommandService.js +2 -1
- package/dist/src/services/CommandService.js.map +1 -1
- package/dist/src/services/FeedbackService.js +2 -2
- package/dist/src/services/FeedbackService.js.map +1 -1
- package/dist/src/services/FileCommandLoader.test.d.ts +6 -0
- package/dist/src/services/FileCommandLoader.test.js +971 -0
- package/dist/src/services/FileCommandLoader.test.js.map +1 -0
- package/dist/src/services/McpPromptLoader.js +2 -2
- package/dist/src/services/McpPromptLoader.js.map +1 -1
- package/dist/src/services/McpPromptLoader.test.js +4 -2
- package/dist/src/services/McpPromptLoader.test.js.map +1 -1
- package/dist/src/services/prompt-processors/argumentProcessor.test.d.ts +6 -0
- package/dist/src/services/prompt-processors/argumentProcessor.test.js +40 -0
- package/dist/src/services/prompt-processors/argumentProcessor.test.js.map +1 -0
- package/dist/src/services/prompt-processors/atFileProcessor.js +3 -2
- package/dist/src/services/prompt-processors/atFileProcessor.js.map +1 -1
- package/dist/src/services/prompt-processors/shellProcessor.test.d.ts +6 -0
- package/dist/src/services/prompt-processors/shellProcessor.test.js +482 -0
- package/dist/src/services/prompt-processors/shellProcessor.test.js.map +1 -0
- package/dist/src/test-utils/async.d.ts +9 -0
- package/dist/src/test-utils/async.js +29 -0
- package/dist/src/test-utils/async.js.map +1 -0
- package/dist/src/test-utils/createExtension.d.ts +3 -1
- package/dist/src/test-utils/createExtension.js +3 -3
- package/dist/src/test-utils/createExtension.js.map +1 -1
- package/dist/src/test-utils/render.d.ts +17 -2
- package/dist/src/test-utils/render.js +69 -4
- package/dist/src/test-utils/render.js.map +1 -1
- package/dist/src/test-utils/render.test.d.ts +6 -0
- package/dist/src/test-utils/render.test.js +79 -0
- package/dist/src/test-utils/render.test.js.map +1 -0
- package/dist/src/ui/App.test.d.ts +6 -0
- package/dist/src/ui/App.test.js +110 -0
- package/dist/src/ui/App.test.js.map +1 -0
- package/dist/src/ui/AppContainer.js +223 -92
- package/dist/src/ui/AppContainer.js.map +1 -1
- package/dist/src/ui/AppContainer.test.js +531 -147
- package/dist/src/ui/AppContainer.test.js.map +1 -1
- package/dist/src/ui/IdeIntegrationNudge.js +1 -1
- package/dist/src/ui/IdeIntegrationNudge.js.map +1 -1
- package/dist/src/ui/auth/ApiAuthDialog.d.ts +14 -0
- package/dist/src/ui/auth/ApiAuthDialog.js +26 -0
- package/dist/src/ui/auth/ApiAuthDialog.js.map +1 -0
- package/dist/src/ui/auth/ApiAuthDialog.test.d.ts +6 -0
- package/dist/src/ui/auth/ApiAuthDialog.test.js +91 -0
- package/dist/src/ui/auth/ApiAuthDialog.test.js.map +1 -0
- package/dist/src/ui/auth/AuthDialog.d.ts +1 -1
- package/dist/src/ui/auth/AuthDialog.js +9 -3
- package/dist/src/ui/auth/AuthDialog.js.map +1 -1
- package/dist/src/ui/auth/useAuth.d.ts +3 -1
- package/dist/src/ui/auth/useAuth.js +35 -4
- package/dist/src/ui/auth/useAuth.js.map +1 -1
- package/dist/src/ui/colors.js +3 -0
- package/dist/src/ui/colors.js.map +1 -1
- package/dist/src/ui/commands/aboutCommand.js +1 -1
- package/dist/src/ui/commands/aboutCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/aboutCommand.test.js +130 -0
- package/dist/src/ui/commands/aboutCommand.test.js.map +1 -0
- package/dist/src/ui/commands/authCommand.js +1 -1
- package/dist/src/ui/commands/authCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/authCommand.test.js +30 -0
- package/dist/src/ui/commands/authCommand.test.js.map +1 -0
- package/dist/src/ui/commands/bugCommand.js +1 -1
- package/dist/src/ui/commands/bugCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/bugCommand.test.js +105 -0
- package/dist/src/ui/commands/bugCommand.test.js.map +1 -0
- package/dist/src/ui/commands/chatCommand.js +1 -1
- package/dist/src/ui/commands/chatCommand.js.map +1 -1
- package/dist/src/ui/commands/chatCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/chatCommand.test.js +555 -0
- package/dist/src/ui/commands/chatCommand.test.js.map +1 -0
- package/dist/src/ui/commands/clearCommand.js +1 -1
- package/dist/src/ui/commands/clearCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/clearCommand.test.js +76 -0
- package/dist/src/ui/commands/clearCommand.test.js.map +1 -0
- package/dist/src/ui/commands/compressCommand.js +1 -1
- package/dist/src/ui/commands/compressCommand.js.map +1 -1
- package/dist/src/ui/commands/compressCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/compressCommand.test.js +98 -0
- package/dist/src/ui/commands/compressCommand.test.js.map +1 -0
- package/dist/src/ui/commands/copyCommand.js +2 -1
- package/dist/src/ui/commands/copyCommand.js.map +1 -1
- package/dist/src/ui/commands/copyCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/copyCommand.test.js +242 -0
- package/dist/src/ui/commands/copyCommand.test.js.map +1 -0
- package/dist/src/ui/commands/corgiCommand.js +1 -1
- package/dist/src/ui/commands/corgiCommand.js.map +1 -1
- package/dist/src/ui/commands/corgiCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/corgiCommand.test.js +28 -0
- package/dist/src/ui/commands/corgiCommand.test.js.map +1 -0
- package/dist/src/ui/commands/directoryCommand.js +1 -1
- package/dist/src/ui/commands/directoryCommand.js.map +1 -1
- package/dist/src/ui/commands/directoryCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/directoryCommand.test.js +144 -0
- package/dist/src/ui/commands/directoryCommand.test.js.map +1 -0
- package/dist/src/ui/commands/docsCommand.js +1 -1
- package/dist/src/ui/commands/docsCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/docsCommand.test.js +72 -0
- package/dist/src/ui/commands/docsCommand.test.js.map +1 -0
- package/dist/src/ui/commands/editorCommand.js +1 -1
- package/dist/src/ui/commands/editorCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/editorCommand.test.js +27 -0
- package/dist/src/ui/commands/editorCommand.test.js.map +1 -0
- package/dist/src/ui/commands/extensionsCommand.js +64 -11
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/extensionsCommand.test.js +315 -0
- package/dist/src/ui/commands/extensionsCommand.test.js.map +1 -0
- package/dist/src/ui/commands/helpCommand.js +1 -1
- package/dist/src/ui/commands/helpCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/helpCommand.test.js +42 -0
- package/dist/src/ui/commands/helpCommand.test.js.map +1 -0
- package/dist/src/ui/commands/ideCommand.js +6 -6
- package/dist/src/ui/commands/ideCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/ideCommand.test.js +205 -0
- package/dist/src/ui/commands/ideCommand.test.js.map +1 -0
- package/dist/src/ui/commands/initCommand.js +1 -1
- package/dist/src/ui/commands/initCommand.js.map +1 -1
- package/dist/src/ui/commands/initCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/initCommand.test.js +80 -0
- package/dist/src/ui/commands/initCommand.test.js.map +1 -0
- package/dist/src/ui/commands/mcpCommand.js +110 -100
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/mcpCommand.test.js +152 -0
- package/dist/src/ui/commands/mcpCommand.test.js.map +1 -0
- package/dist/src/ui/commands/memoryCommand.js +6 -6
- package/dist/src/ui/commands/memoryCommand.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/memoryCommand.test.js +268 -0
- package/dist/src/ui/commands/memoryCommand.test.js.map +1 -0
- package/dist/src/ui/commands/policiesCommand.d.ts +7 -0
- package/dist/src/ui/commands/policiesCommand.js +59 -0
- package/dist/src/ui/commands/policiesCommand.js.map +1 -0
- package/dist/src/ui/commands/policiesCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/policiesCommand.test.js +83 -0
- package/dist/src/ui/commands/policiesCommand.test.js.map +1 -0
- package/dist/src/ui/commands/privacyCommand.js +1 -1
- package/dist/src/ui/commands/privacyCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/privacyCommand.test.js +32 -0
- package/dist/src/ui/commands/privacyCommand.test.js.map +1 -0
- package/dist/src/ui/commands/quitCommand.js +1 -1
- package/dist/src/ui/commands/quitCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/quitCommand.test.js +50 -0
- package/dist/src/ui/commands/quitCommand.test.js.map +1 -0
- package/dist/src/ui/commands/restoreCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/restoreCommand.test.js +190 -0
- package/dist/src/ui/commands/restoreCommand.test.js.map +1 -0
- package/dist/src/ui/commands/settingsCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/settingsCommand.test.js +30 -0
- package/dist/src/ui/commands/settingsCommand.test.js.map +1 -0
- package/dist/src/ui/commands/setupGithubCommand.js +4 -3
- package/dist/src/ui/commands/setupGithubCommand.js.map +1 -1
- package/dist/src/ui/commands/setupGithubCommand.test.js +1 -2
- package/dist/src/ui/commands/setupGithubCommand.test.js.map +1 -1
- package/dist/src/ui/commands/statsCommand.js +3 -3
- package/dist/src/ui/commands/statsCommand.js.map +1 -1
- package/dist/src/ui/commands/statsCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/statsCommand.test.js +53 -0
- package/dist/src/ui/commands/statsCommand.test.js.map +1 -0
- package/dist/src/ui/commands/terminalSetupCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/terminalSetupCommand.test.js +66 -0
- package/dist/src/ui/commands/terminalSetupCommand.test.js.map +1 -0
- package/dist/src/ui/commands/themeCommand.js +1 -1
- package/dist/src/ui/commands/themeCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/themeCommand.test.js +32 -0
- package/dist/src/ui/commands/themeCommand.test.js.map +1 -0
- package/dist/src/ui/commands/toolsCommand.js +1 -1
- package/dist/src/ui/commands/toolsCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/toolsCommand.test.js +100 -0
- package/dist/src/ui/commands/toolsCommand.test.js.map +1 -0
- package/dist/src/ui/commands/types.d.ts +1 -0
- package/dist/src/ui/commands/vimCommand.js +1 -1
- package/dist/src/ui/components/AnsiOutput.test.js +1 -1
- package/dist/src/ui/components/AnsiOutput.test.js.map +1 -1
- package/dist/src/ui/components/AsciiArt.d.ts +3 -3
- package/dist/src/ui/components/AsciiArt.js +3 -3
- package/dist/src/ui/components/Composer.js +6 -4
- package/dist/src/ui/components/Composer.js.map +1 -1
- package/dist/src/ui/components/Composer.test.js +21 -3
- package/dist/src/ui/components/Composer.test.js.map +1 -1
- package/dist/src/ui/components/ConfigInitDisplay.js +4 -6
- package/dist/src/ui/components/ConfigInitDisplay.js.map +1 -1
- package/dist/src/ui/components/ConsentPrompt.test.js +18 -8
- package/dist/src/ui/components/ConsentPrompt.test.js.map +1 -1
- package/dist/src/ui/components/ConsoleSummaryDisplay.js +1 -1
- package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/ContextSummaryDisplay.d.ts +0 -1
- package/dist/src/ui/components/ContextSummaryDisplay.js +2 -12
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/ContextSummaryDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/ContextSummaryDisplay.test.js +71 -0
- package/dist/src/ui/components/ContextSummaryDisplay.test.js.map +1 -0
- package/dist/src/ui/components/DetailedMessagesDisplay.js +1 -1
- package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -1
- package/dist/src/ui/components/DialogManager.js +5 -5
- package/dist/src/ui/components/DialogManager.js.map +1 -1
- package/dist/src/ui/components/EditorSettingsDialog.js +1 -1
- package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -1
- package/dist/src/ui/components/FolderTrustDialog.test.js +8 -3
- package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -1
- package/dist/src/ui/components/Footer.js +4 -3
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/Footer.test.d.ts +6 -0
- package/dist/src/ui/components/Footer.test.js +314 -0
- package/dist/src/ui/components/Footer.test.js.map +1 -0
- package/dist/src/ui/components/Header.test.js +13 -5
- package/dist/src/ui/components/Header.test.js.map +1 -1
- package/dist/src/ui/components/Help.test.js +5 -4
- package/dist/src/ui/components/Help.test.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.d.ts +4 -0
- package/dist/src/ui/components/InputPrompt.js +80 -12
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.test.d.ts +6 -0
- package/dist/src/ui/components/InputPrompt.test.js +1786 -0
- package/dist/src/ui/components/InputPrompt.test.js.map +1 -0
- package/dist/src/ui/components/LoadingIndicator.js +2 -2
- package/dist/src/ui/components/LoadingIndicator.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.test.js +28 -15
- package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -1
- package/dist/src/ui/components/LoopDetectionConfirmation.js +1 -1
- package/dist/src/ui/components/LoopDetectionConfirmation.js.map +1 -1
- package/dist/src/ui/components/LoopDetectionConfirmation.test.js +2 -2
- package/dist/src/ui/components/LoopDetectionConfirmation.test.js.map +1 -1
- package/dist/src/ui/components/MainContent.js +15 -4
- package/dist/src/ui/components/MainContent.js.map +1 -1
- package/dist/src/ui/components/ModelDialog.js +1 -1
- package/dist/src/ui/components/ModelDialog.js.map +1 -1
- package/dist/src/ui/components/ModelDialog.test.js +23 -13
- package/dist/src/ui/components/ModelDialog.test.js.map +1 -1
- package/dist/src/ui/components/ModelStatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.js +285 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/Notifications.js +38 -5
- package/dist/src/ui/components/Notifications.js.map +1 -1
- package/dist/src/ui/components/PermissionsModifyTrustDialog.js +22 -18
- package/dist/src/ui/components/PermissionsModifyTrustDialog.js.map +1 -1
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js +12 -4
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js.map +1 -1
- package/dist/src/ui/components/PrepareLabel.test.js +14 -8
- package/dist/src/ui/components/PrepareLabel.test.js.map +1 -1
- package/dist/src/ui/components/ProQuotaDialog.test.js +14 -6
- package/dist/src/ui/components/ProQuotaDialog.test.js.map +1 -1
- package/dist/src/ui/components/QueuedMessageDisplay.js +3 -3
- package/dist/src/ui/components/QueuedMessageDisplay.js.map +1 -1
- package/dist/src/ui/components/QueuedMessageDisplay.test.js +15 -6
- package/dist/src/ui/components/QueuedMessageDisplay.test.js.map +1 -1
- package/dist/src/ui/components/RawMarkdownIndicator.d.ts +7 -0
- package/dist/src/ui/components/RawMarkdownIndicator.js +8 -0
- package/dist/src/ui/components/RawMarkdownIndicator.js.map +1 -0
- package/dist/src/ui/components/SessionSummaryDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/SessionSummaryDisplay.test.js +74 -0
- package/dist/src/ui/components/SessionSummaryDisplay.test.js.map +1 -0
- package/dist/src/ui/components/SettingsDialog.js +43 -35
- package/dist/src/ui/components/SettingsDialog.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.test.js +554 -545
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.js +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.test.js +2 -2
- package/dist/src/ui/components/ShellConfirmationDialog.test.js.map +1 -1
- package/dist/src/ui/components/StatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/StatsDisplay.test.js +351 -0
- package/dist/src/ui/components/StatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/SuggestionsDisplay.js +1 -1
- package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.d.ts +4 -2
- package/dist/src/ui/components/ThemeDialog.js +3 -3
- package/dist/src/ui/components/ThemeDialog.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.test.js +14 -1
- package/dist/src/ui/components/ThemeDialog.test.js.map +1 -1
- package/dist/src/ui/components/ToolStatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.js +227 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/messages/CompressionMessage.test.js +25 -17
- package/dist/src/ui/components/messages/CompressionMessage.test.js.map +1 -1
- package/dist/src/ui/components/messages/DiffRenderer.test.js +1 -1
- package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -1
- package/dist/src/ui/components/messages/GeminiMessage.js +3 -1
- package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -1
- package/dist/src/ui/components/messages/GeminiMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/GeminiMessage.test.js +35 -0
- package/dist/src/ui/components/messages/GeminiMessage.test.js.map +1 -0
- package/dist/src/ui/components/messages/GeminiMessageContent.js +3 -1
- package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -1
- package/dist/src/ui/components/messages/InfoMessage.js +1 -1
- package/dist/src/ui/components/messages/InfoMessage.js.map +1 -1
- package/dist/src/ui/components/messages/Todo.d.ts +7 -0
- package/dist/src/ui/components/messages/Todo.js +91 -0
- package/dist/src/ui/components/messages/Todo.js.map +1 -0
- package/dist/src/ui/components/messages/Todo.test.d.ts +6 -0
- package/dist/src/ui/components/messages/Todo.test.js +114 -0
- package/dist/src/ui/components/messages/Todo.test.js.map +1 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.js +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.test.js +29 -15
- package/dist/src/ui/components/messages/ToolGroupMessage.test.js.map +1 -1
- package/dist/src/ui/components/messages/ToolMessage.js +8 -3
- package/dist/src/ui/components/messages/ToolMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolMessage.test.js +2 -2
- package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -1
- package/dist/src/ui/components/messages/ToolMessageRawMarkdown.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolMessageRawMarkdown.test.js +30 -0
- package/dist/src/ui/components/messages/ToolMessageRawMarkdown.test.js.map +1 -0
- package/dist/src/ui/components/messages/UserShellMessage.js +1 -1
- package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -1
- package/dist/src/ui/components/messages/WarningMessage.js +2 -2
- package/dist/src/ui/components/messages/WarningMessage.js.map +1 -1
- package/dist/src/ui/components/shared/BaseSelectionList.test.js +34 -25
- package/dist/src/ui/components/shared/BaseSelectionList.test.js.map +1 -1
- package/dist/src/ui/components/shared/MaxSizedBox.test.js +43 -22
- package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -1
- package/dist/src/ui/components/shared/TextInput.d.ts +15 -0
- package/dist/src/ui/components/shared/TextInput.js +38 -0
- package/dist/src/ui/components/shared/TextInput.js.map +1 -0
- package/dist/src/ui/components/shared/TextInput.test.d.ts +6 -0
- package/dist/src/ui/components/shared/TextInput.test.js +242 -0
- package/dist/src/ui/components/shared/TextInput.test.js.map +1 -0
- package/dist/src/ui/components/shared/text-buffer.d.ts +9 -2
- package/dist/src/ui/components/shared/text-buffer.js +52 -14
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.test.d.ts +6 -0
- package/dist/src/ui/components/shared/text-buffer.test.js +1761 -0
- package/dist/src/ui/components/shared/text-buffer.test.js.map +1 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.test.d.ts +6 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.test.js +951 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.test.js.map +1 -0
- package/dist/src/ui/components/views/ChatList.test.js +7 -4
- package/dist/src/ui/components/views/ChatList.test.js.map +1 -1
- package/dist/src/ui/components/views/ExtensionsList.d.ts +7 -1
- package/dist/src/ui/components/views/ExtensionsList.js +12 -15
- package/dist/src/ui/components/views/ExtensionsList.js.map +1 -1
- package/dist/src/ui/components/views/ExtensionsList.test.js +43 -29
- package/dist/src/ui/components/views/ExtensionsList.test.js.map +1 -1
- package/dist/src/ui/components/views/McpStatus.d.ts +0 -1
- package/dist/src/ui/components/views/McpStatus.js +4 -4
- package/dist/src/ui/components/views/McpStatus.js.map +1 -1
- package/dist/src/ui/components/views/McpStatus.test.js +23 -17
- package/dist/src/ui/components/views/McpStatus.test.js.map +1 -1
- package/dist/src/ui/components/views/ToolsList.test.js +4 -4
- package/dist/src/ui/components/views/ToolsList.test.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.d.ts +4 -2
- package/dist/src/ui/contexts/KeypressContext.js +635 -439
- package/dist/src/ui/contexts/KeypressContext.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.test.js +634 -515
- package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -1
- package/dist/src/ui/contexts/MouseContext.d.ts +21 -0
- package/dist/src/ui/contexts/MouseContext.js +89 -0
- package/dist/src/ui/contexts/MouseContext.js.map +1 -0
- package/dist/src/ui/contexts/MouseContext.test.d.ts +6 -0
- package/dist/src/ui/contexts/MouseContext.test.js +164 -0
- package/dist/src/ui/contexts/MouseContext.test.js.map +1 -0
- package/dist/src/ui/contexts/SessionContext.test.d.ts +6 -0
- package/dist/src/ui/contexts/SessionContext.test.js +195 -0
- package/dist/src/ui/contexts/SessionContext.test.js.map +1 -0
- package/dist/src/ui/contexts/UIActionsContext.d.ts +7 -4
- package/dist/src/ui/contexts/UIStateContext.d.ts +5 -3
- package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.js +33 -11
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.test.js +163 -64
- package/dist/src/ui/hooks/atCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.js +0 -1
- package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.test.js +64 -35
- package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.js +2 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.test.d.ts +6 -0
- package/dist/src/ui/hooks/slashCommandProcessor.test.js +807 -0
- package/dist/src/ui/hooks/slashCommandProcessor.test.js.map +1 -0
- package/dist/src/ui/hooks/useAtCompletion.js +2 -2
- package/dist/src/ui/hooks/useAtCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useAtCompletion.test.d.ts +6 -0
- package/dist/src/ui/hooks/useAtCompletion.test.js +396 -0
- package/dist/src/ui/hooks/useAtCompletion.test.js.map +1 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js +10 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +32 -2
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -1
- package/dist/src/ui/hooks/useCommandCompletion.d.ts +1 -1
- package/dist/src/ui/hooks/useCommandCompletion.js +5 -3
- package/dist/src/ui/hooks/useCommandCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useCommandCompletion.test.d.ts +6 -0
- package/dist/src/ui/hooks/useCommandCompletion.test.js +377 -0
- package/dist/src/ui/hooks/useCommandCompletion.test.js.map +1 -0
- package/dist/src/ui/hooks/useConsoleMessages.test.d.ts +6 -0
- package/dist/src/ui/hooks/useConsoleMessages.test.js +127 -0
- package/dist/src/ui/hooks/useConsoleMessages.test.js.map +1 -0
- package/dist/src/ui/hooks/useEditorSettings.test.js +40 -34
- package/dist/src/ui/hooks/useEditorSettings.test.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.d.ts +14 -4
- package/dist/src/ui/hooks/useExtensionUpdates.js +18 -11
- package/dist/src/ui/hooks/useExtensionUpdates.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.test.js +52 -35
- package/dist/src/ui/hooks/useExtensionUpdates.test.js.map +1 -1
- package/dist/src/ui/hooks/useFlickerDetector.test.js +9 -5
- package/dist/src/ui/hooks/useFlickerDetector.test.js.map +1 -1
- package/dist/src/ui/hooks/useFocus.test.d.ts +6 -0
- package/dist/src/ui/hooks/useFocus.test.js +131 -0
- package/dist/src/ui/hooks/useFocus.test.js.map +1 -0
- package/dist/src/ui/hooks/useFolderTrust.test.d.ts +6 -0
- package/dist/src/ui/hooks/useFolderTrust.test.js +188 -0
- package/dist/src/ui/hooks/useFolderTrust.test.js.map +1 -0
- package/dist/src/ui/hooks/useGeminiStream.js +119 -74
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.test.d.ts +6 -0
- package/dist/src/ui/hooks/useGeminiStream.test.js +1820 -0
- package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -0
- package/dist/src/ui/hooks/useGitBranchName.js +4 -0
- package/dist/src/ui/hooks/useGitBranchName.js.map +1 -1
- package/dist/src/ui/hooks/useGitBranchName.test.js +46 -34
- package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -1
- package/dist/src/ui/hooks/useHistoryManager.test.js +2 -1
- package/dist/src/ui/hooks/useHistoryManager.test.js.map +1 -1
- package/dist/src/ui/hooks/useIdeTrustListener.test.js +40 -9
- package/dist/src/ui/hooks/useIdeTrustListener.test.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistory.test.js +2 -1
- package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistoryStore.js +2 -1
- package/dist/src/ui/hooks/useInputHistoryStore.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistoryStore.test.js +2 -1
- package/dist/src/ui/hooks/useInputHistoryStore.test.js.map +1 -1
- package/dist/src/ui/hooks/useKeypress.test.d.ts +6 -0
- package/dist/src/ui/hooks/useKeypress.test.js +223 -0
- package/dist/src/ui/hooks/useKeypress.test.js.map +1 -0
- package/dist/src/ui/hooks/useLoadingIndicator.test.js +29 -6
- package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +1 -1
- package/dist/src/ui/hooks/useMemoryMonitor.test.js +10 -5
- package/dist/src/ui/hooks/useMemoryMonitor.test.js.map +1 -1
- package/dist/src/ui/hooks/useMessageQueue.d.ts +1 -0
- package/dist/src/ui/hooks/useMessageQueue.js +14 -0
- package/dist/src/ui/hooks/useMessageQueue.js.map +1 -1
- package/dist/src/ui/hooks/useMessageQueue.test.js +173 -35
- package/dist/src/ui/hooks/useMessageQueue.test.js.map +1 -1
- package/dist/src/ui/hooks/useModelCommand.test.js +21 -11
- package/dist/src/ui/hooks/useModelCommand.test.js.map +1 -1
- package/dist/src/ui/hooks/useMouse.d.ts +17 -0
- package/dist/src/ui/hooks/useMouse.js +27 -0
- package/dist/src/ui/hooks/useMouse.js.map +1 -0
- package/dist/src/ui/hooks/useMouse.test.d.ts +6 -0
- package/dist/src/ui/hooks/useMouse.test.js +57 -0
- package/dist/src/ui/hooks/useMouse.test.js.map +1 -0
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js +2 -2
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.d.ts +1 -0
- package/dist/src/ui/hooks/usePhraseCycler.js +156 -5
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.test.d.ts +6 -0
- package/dist/src/ui/hooks/usePhraseCycler.test.js +158 -0
- package/dist/src/ui/hooks/usePhraseCycler.test.js.map +1 -0
- package/dist/src/ui/hooks/usePrivacySettings.test.js +26 -6
- package/dist/src/ui/hooks/usePrivacySettings.test.js.map +1 -1
- package/dist/src/ui/hooks/usePromptCompletion.js +2 -2
- package/dist/src/ui/hooks/usePromptCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.js +13 -14
- package/dist/src/ui/hooks/useQuotaAndFallback.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js +55 -48
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js.map +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.d.ts +8 -1
- package/dist/src/ui/hooks/useReactToolScheduler.js +61 -36
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.test.d.ts +6 -0
- package/dist/src/ui/hooks/useReactToolScheduler.test.js +65 -0
- package/dist/src/ui/hooks/useReactToolScheduler.test.js.map +1 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +2 -2
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useSelectionList.js +5 -4
- package/dist/src/ui/hooks/useSelectionList.js.map +1 -1
- package/dist/src/ui/hooks/useSelectionList.test.js +272 -183
- package/dist/src/ui/hooks/useSelectionList.test.js.map +1 -1
- package/dist/src/ui/hooks/useShellHistory.test.js +52 -20
- package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +1 -1
- package/dist/src/ui/hooks/useShowMemoryCommand.js +4 -3
- package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.js +20 -8
- package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.test.js +275 -137
- package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useThemeCommand.d.ts +2 -1
- package/dist/src/ui/hooks/useThemeCommand.js +6 -0
- package/dist/src/ui/hooks/useThemeCommand.js.map +1 -1
- package/dist/src/ui/hooks/useTimer.test.js +43 -14
- package/dist/src/ui/hooks/useTimer.test.js.map +1 -1
- package/dist/src/ui/hooks/useToolScheduler.test.js +229 -242
- package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -1
- package/dist/src/ui/hooks/vim.js +2 -1
- package/dist/src/ui/hooks/vim.js.map +1 -1
- package/dist/src/ui/hooks/vim.test.d.ts +6 -0
- package/dist/src/ui/hooks/vim.test.js +1269 -0
- package/dist/src/ui/hooks/vim.test.js.map +1 -0
- package/dist/src/ui/keyMatchers.test.js +39 -6
- package/dist/src/ui/keyMatchers.test.js.map +1 -1
- package/dist/src/ui/state/extensions.d.ts +1 -0
- package/dist/src/ui/state/extensions.js +1 -0
- package/dist/src/ui/state/extensions.js.map +1 -1
- package/dist/src/ui/themes/ansi-light.js +1 -0
- package/dist/src/ui/themes/ansi-light.js.map +1 -1
- package/dist/src/ui/themes/ansi.js +1 -0
- package/dist/src/ui/themes/ansi.js.map +1 -1
- package/dist/src/ui/themes/atom-one-dark.js +2 -0
- package/dist/src/ui/themes/atom-one-dark.js.map +1 -1
- package/dist/src/ui/themes/ayu-light.js +2 -0
- package/dist/src/ui/themes/ayu-light.js.map +1 -1
- package/dist/src/ui/themes/ayu.js +2 -0
- package/dist/src/ui/themes/ayu.js.map +1 -1
- package/dist/src/ui/themes/color-utils.d.ts +1 -0
- package/dist/src/ui/themes/color-utils.js +8 -1
- package/dist/src/ui/themes/color-utils.js.map +1 -1
- package/dist/src/ui/themes/color-utils.test.js +13 -1
- package/dist/src/ui/themes/color-utils.test.js.map +1 -1
- package/dist/src/ui/themes/dracula.js +2 -0
- package/dist/src/ui/themes/dracula.js.map +1 -1
- package/dist/src/ui/themes/github-dark.js +2 -0
- package/dist/src/ui/themes/github-dark.js.map +1 -1
- package/dist/src/ui/themes/github-light.js +2 -0
- package/dist/src/ui/themes/github-light.js.map +1 -1
- package/dist/src/ui/themes/googlecode.js +2 -0
- package/dist/src/ui/themes/googlecode.js.map +1 -1
- package/dist/src/ui/themes/no-color.js +3 -0
- package/dist/src/ui/themes/no-color.js.map +1 -1
- package/dist/src/ui/themes/semantic-tokens.d.ts +2 -0
- package/dist/src/ui/themes/semantic-tokens.js +6 -0
- package/dist/src/ui/themes/semantic-tokens.js.map +1 -1
- package/dist/src/ui/themes/shades-of-purple.js +2 -0
- package/dist/src/ui/themes/shades-of-purple.js.map +1 -1
- package/dist/src/ui/themes/theme-manager.js +8 -7
- package/dist/src/ui/themes/theme-manager.js.map +1 -1
- package/dist/src/ui/themes/theme.d.ts +3 -0
- package/dist/src/ui/themes/theme.js +14 -3
- package/dist/src/ui/themes/theme.js.map +1 -1
- package/dist/src/ui/themes/theme.test.d.ts +6 -0
- package/dist/src/ui/themes/theme.test.js +151 -0
- package/dist/src/ui/themes/theme.test.js.map +1 -0
- package/dist/src/ui/themes/xcode.js +2 -0
- package/dist/src/ui/themes/xcode.js.map +1 -1
- package/dist/src/ui/types.d.ts +3 -2
- package/dist/src/ui/types.js +2 -0
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/CodeColorizer.d.ts +1 -1
- package/dist/src/ui/utils/CodeColorizer.js +6 -3
- package/dist/src/ui/utils/CodeColorizer.js.map +1 -1
- package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +1 -0
- package/dist/src/ui/utils/InlineMarkdownRenderer.js +11 -10
- package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -1
- package/dist/src/ui/utils/MarkdownDisplay.d.ts +1 -0
- package/dist/src/ui/utils/MarkdownDisplay.js +19 -10
- package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -1
- package/dist/src/ui/utils/clipboardUtils.js +2 -2
- package/dist/src/ui/utils/clipboardUtils.js.map +1 -1
- package/dist/src/ui/utils/commandUtils.js +20 -3
- package/dist/src/ui/utils/commandUtils.js.map +1 -1
- package/dist/src/ui/utils/commandUtils.test.js +61 -6
- package/dist/src/ui/utils/commandUtils.test.js.map +1 -1
- package/dist/src/ui/utils/computeStats.js +5 -2
- package/dist/src/ui/utils/computeStats.js.map +1 -1
- package/dist/src/ui/utils/computeStats.test.d.ts +6 -0
- package/dist/src/ui/utils/computeStats.test.js +262 -0
- package/dist/src/ui/utils/computeStats.test.js.map +1 -0
- package/dist/src/ui/utils/input.d.ts +17 -0
- package/dist/src/ui/utils/input.js +51 -0
- package/dist/src/ui/utils/input.js.map +1 -0
- package/dist/src/ui/utils/input.test.d.ts +6 -0
- package/dist/src/ui/utils/input.test.js +44 -0
- package/dist/src/ui/utils/input.test.js.map +1 -0
- package/dist/src/ui/utils/kittyProtocolDetector.js +13 -4
- package/dist/src/ui/utils/kittyProtocolDetector.js.map +1 -1
- package/dist/src/ui/utils/mouse.d.ts +31 -0
- package/dist/src/ui/utils/mouse.js +164 -0
- package/dist/src/ui/utils/mouse.js.map +1 -0
- package/dist/src/ui/utils/mouse.test.d.ts +6 -0
- package/dist/src/ui/utils/mouse.test.js +131 -0
- package/dist/src/ui/utils/mouse.test.js.map +1 -0
- package/dist/src/ui/utils/terminalSetup.js +3 -2
- package/dist/src/ui/utils/terminalSetup.js.map +1 -1
- package/dist/src/ui/utils/textOutput.d.ts +25 -0
- package/dist/src/ui/utils/textOutput.js +49 -0
- package/dist/src/ui/utils/textOutput.js.map +1 -0
- package/dist/src/ui/utils/textOutput.test.d.ts +6 -0
- package/dist/src/ui/utils/textOutput.test.js +79 -0
- package/dist/src/ui/utils/textOutput.test.js.map +1 -0
- package/dist/src/ui/utils/updateCheck.d.ts +9 -2
- package/dist/src/ui/utils/updateCheck.js +38 -30
- package/dist/src/ui/utils/updateCheck.js.map +1 -1
- package/dist/src/ui/utils/updateCheck.test.js +48 -59
- package/dist/src/ui/utils/updateCheck.test.js.map +1 -1
- package/dist/src/utils/cleanup.test.d.ts +6 -0
- package/dist/src/utils/cleanup.test.js +49 -0
- package/dist/src/utils/cleanup.test.js.map +1 -0
- package/dist/src/utils/commentJson.js +2 -2
- package/dist/src/utils/commentJson.js.map +1 -1
- package/dist/src/utils/commentJson.test.js +7 -6
- package/dist/src/utils/commentJson.test.js.map +1 -1
- package/dist/src/utils/envVarResolver.d.ts +2 -2
- package/dist/src/utils/envVarResolver.js +10 -7
- package/dist/src/utils/envVarResolver.js.map +1 -1
- package/dist/src/utils/errors.d.ts +1 -0
- package/dist/src/utils/errors.js +66 -5
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/events.d.ts +11 -2
- package/dist/src/utils/events.js +1 -0
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/gitUtils.js +3 -2
- package/dist/src/utils/gitUtils.js.map +1 -1
- package/dist/src/utils/handleAutoUpdate.js +9 -3
- package/dist/src/utils/handleAutoUpdate.js.map +1 -1
- package/dist/src/utils/handleAutoUpdate.test.d.ts +6 -0
- package/dist/src/utils/handleAutoUpdate.test.js +225 -0
- package/dist/src/utils/handleAutoUpdate.test.js.map +1 -0
- package/dist/src/utils/installationInfo.js +2 -2
- package/dist/src/utils/installationInfo.js.map +1 -1
- package/dist/src/utils/installationInfo.test.js +8 -4
- package/dist/src/utils/installationInfo.test.js.map +1 -1
- package/dist/src/utils/readStdin.js +2 -1
- package/dist/src/utils/readStdin.js.map +1 -1
- package/dist/src/utils/sandbox-macos-permissive-open.sb +2 -0
- package/dist/src/utils/sandbox.js +28 -30
- package/dist/src/utils/sandbox.js.map +1 -1
- package/dist/src/utils/sessionCleanup.js +4 -4
- package/dist/src/utils/sessionCleanup.js.map +1 -1
- package/dist/src/utils/startupWarnings.test.d.ts +6 -0
- package/dist/src/utils/startupWarnings.test.js +61 -0
- package/dist/src/utils/startupWarnings.test.js.map +1 -0
- package/dist/src/utils/version.js +6 -2
- package/dist/src/utils/version.js.map +1 -1
- package/dist/src/validateNonInterActiveAuth.js +2 -2
- package/dist/src/validateNonInterActiveAuth.js.map +1 -1
- package/dist/src/zed-integration/acp.js +2 -1
- package/dist/src/zed-integration/acp.js.map +1 -1
- package/dist/src/zed-integration/schema.d.ts +4 -4
- package/dist/src/zed-integration/zedIntegration.d.ts +2 -2
- package/dist/src/zed-integration/zedIntegration.js +16 -25
- package/dist/src/zed-integration/zedIntegration.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/dist/src/config/policy.test.js +0 -336
- package/dist/src/config/policy.test.js.map +0 -1
- package/dist/src/ui/components/WorkspaceMigrationDialog.d.ts +0 -11
- package/dist/src/ui/components/WorkspaceMigrationDialog.js +0 -44
- package/dist/src/ui/components/WorkspaceMigrationDialog.js.map +0 -1
- package/dist/src/ui/hooks/useWorkspaceMigration.d.ts +0 -13
- package/dist/src/ui/hooks/useWorkspaceMigration.js +0 -59
- package/dist/src/ui/hooks/useWorkspaceMigration.js.map +0 -1
- package/dist/src/utils/package.d.ts +0 -12
- package/dist/src/utils/package.js +0 -24
- package/dist/src/utils/package.js.map +0 -1
- /package/dist/src/{config/policy.test.d.ts → commands/extensions/examples/mcp-server/example.d.ts} +0 -0
|
@@ -0,0 +1,807 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
7
|
+
import { act } from 'react';
|
|
8
|
+
import { renderHook } from '../../test-utils/render.js';
|
|
9
|
+
import { waitFor } from '../../test-utils/async.js';
|
|
10
|
+
import { useSlashCommandProcessor } from './slashCommandProcessor.js';
|
|
11
|
+
import { CommandKind } from '../commands/types.js';
|
|
12
|
+
import { MessageType } from '../types.js';
|
|
13
|
+
import { BuiltinCommandLoader } from '../../services/BuiltinCommandLoader.js';
|
|
14
|
+
import { FileCommandLoader } from '../../services/FileCommandLoader.js';
|
|
15
|
+
import { McpPromptLoader } from '../../services/McpPromptLoader.js';
|
|
16
|
+
import { SlashCommandStatus, ToolConfirmationOutcome, makeFakeConfig, } from '@google/gemini-cli-core';
|
|
17
|
+
const { logSlashCommand } = vi.hoisted(() => ({
|
|
18
|
+
logSlashCommand: vi.fn(),
|
|
19
|
+
}));
|
|
20
|
+
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
|
21
|
+
const original = await importOriginal();
|
|
22
|
+
return {
|
|
23
|
+
...original,
|
|
24
|
+
logSlashCommand,
|
|
25
|
+
getIdeInstaller: vi.fn().mockReturnValue(null),
|
|
26
|
+
IdeClient: {
|
|
27
|
+
getInstance: vi.fn().mockResolvedValue({
|
|
28
|
+
addStatusChangeListener: vi.fn(),
|
|
29
|
+
removeStatusChangeListener: vi.fn(),
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
const { mockProcessExit } = vi.hoisted(() => ({
|
|
35
|
+
mockProcessExit: vi.fn((_code) => undefined),
|
|
36
|
+
}));
|
|
37
|
+
vi.mock('node:process', () => {
|
|
38
|
+
const mockProcess = {
|
|
39
|
+
exit: mockProcessExit,
|
|
40
|
+
platform: 'sunos',
|
|
41
|
+
cwd: () => '/fake/dir',
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
...mockProcess,
|
|
45
|
+
default: mockProcess,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
const mockBuiltinLoadCommands = vi.fn();
|
|
49
|
+
vi.mock('../../services/BuiltinCommandLoader.js', () => ({
|
|
50
|
+
BuiltinCommandLoader: vi.fn().mockImplementation(() => ({
|
|
51
|
+
loadCommands: mockBuiltinLoadCommands,
|
|
52
|
+
})),
|
|
53
|
+
}));
|
|
54
|
+
const mockFileLoadCommands = vi.fn();
|
|
55
|
+
vi.mock('../../services/FileCommandLoader.js', () => ({
|
|
56
|
+
FileCommandLoader: vi.fn().mockImplementation(() => ({
|
|
57
|
+
loadCommands: mockFileLoadCommands,
|
|
58
|
+
})),
|
|
59
|
+
}));
|
|
60
|
+
const mockMcpLoadCommands = vi.fn();
|
|
61
|
+
vi.mock('../../services/McpPromptLoader.js', () => ({
|
|
62
|
+
McpPromptLoader: vi.fn().mockImplementation(() => ({
|
|
63
|
+
loadCommands: mockMcpLoadCommands,
|
|
64
|
+
})),
|
|
65
|
+
}));
|
|
66
|
+
vi.mock('../contexts/SessionContext.js', () => ({
|
|
67
|
+
useSessionStats: vi.fn(() => ({ stats: {} })),
|
|
68
|
+
}));
|
|
69
|
+
const { mockRunExitCleanup } = vi.hoisted(() => ({
|
|
70
|
+
mockRunExitCleanup: vi.fn(),
|
|
71
|
+
}));
|
|
72
|
+
vi.mock('../../utils/cleanup.js', () => ({
|
|
73
|
+
runExitCleanup: mockRunExitCleanup,
|
|
74
|
+
}));
|
|
75
|
+
function createTestCommand(overrides, kind = CommandKind.BUILT_IN) {
|
|
76
|
+
return {
|
|
77
|
+
name: 'test',
|
|
78
|
+
description: 'a test command',
|
|
79
|
+
kind,
|
|
80
|
+
...overrides,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
describe('useSlashCommandProcessor', () => {
|
|
84
|
+
const mockAddItem = vi.fn();
|
|
85
|
+
const mockClearItems = vi.fn();
|
|
86
|
+
const mockLoadHistory = vi.fn();
|
|
87
|
+
const mockOpenThemeDialog = vi.fn();
|
|
88
|
+
const mockOpenAuthDialog = vi.fn();
|
|
89
|
+
const mockOpenModelDialog = vi.fn();
|
|
90
|
+
const mockSetQuittingMessages = vi.fn();
|
|
91
|
+
const mockConfig = makeFakeConfig({});
|
|
92
|
+
const mockSettings = {};
|
|
93
|
+
let unmountHook;
|
|
94
|
+
beforeEach(() => {
|
|
95
|
+
vi.clearAllMocks();
|
|
96
|
+
vi.mocked(BuiltinCommandLoader).mockClear();
|
|
97
|
+
mockBuiltinLoadCommands.mockResolvedValue([]);
|
|
98
|
+
mockFileLoadCommands.mockResolvedValue([]);
|
|
99
|
+
mockMcpLoadCommands.mockResolvedValue([]);
|
|
100
|
+
});
|
|
101
|
+
afterEach(async () => {
|
|
102
|
+
if (unmountHook) {
|
|
103
|
+
await unmountHook();
|
|
104
|
+
unmountHook = undefined;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
const setupProcessorHook = async (builtinCommands = [], fileCommands = [], mcpCommands = [], setIsProcessing = vi.fn()) => {
|
|
108
|
+
mockBuiltinLoadCommands.mockResolvedValue(Object.freeze(builtinCommands));
|
|
109
|
+
mockFileLoadCommands.mockResolvedValue(Object.freeze(fileCommands));
|
|
110
|
+
mockMcpLoadCommands.mockResolvedValue(Object.freeze(mcpCommands));
|
|
111
|
+
let result;
|
|
112
|
+
let unmount;
|
|
113
|
+
let rerender;
|
|
114
|
+
await act(async () => {
|
|
115
|
+
const hook = renderHook(() => useSlashCommandProcessor(mockConfig, mockSettings, mockAddItem, mockClearItems, mockLoadHistory, vi.fn(), // refreshStatic
|
|
116
|
+
vi.fn(), // toggleVimEnabled
|
|
117
|
+
setIsProcessing, vi.fn(), // setGeminiMdFileCount
|
|
118
|
+
{
|
|
119
|
+
openAuthDialog: mockOpenAuthDialog,
|
|
120
|
+
openThemeDialog: mockOpenThemeDialog,
|
|
121
|
+
openEditorDialog: vi.fn(),
|
|
122
|
+
openPrivacyNotice: vi.fn(),
|
|
123
|
+
openSettingsDialog: vi.fn(),
|
|
124
|
+
openModelDialog: mockOpenModelDialog,
|
|
125
|
+
openPermissionsDialog: vi.fn(),
|
|
126
|
+
quit: mockSetQuittingMessages,
|
|
127
|
+
setDebugMessage: vi.fn(),
|
|
128
|
+
toggleCorgiMode: vi.fn(),
|
|
129
|
+
toggleDebugProfiler: vi.fn(),
|
|
130
|
+
dispatchExtensionStateUpdate: vi.fn(),
|
|
131
|
+
addConfirmUpdateExtensionRequest: vi.fn(),
|
|
132
|
+
}, new Map(), // extensionsUpdateState
|
|
133
|
+
true));
|
|
134
|
+
result = hook.result;
|
|
135
|
+
unmount = hook.unmount;
|
|
136
|
+
rerender = hook.rerender;
|
|
137
|
+
});
|
|
138
|
+
unmountHook = async () => unmount();
|
|
139
|
+
await waitFor(() => {
|
|
140
|
+
expect(result.current.slashCommands).toBeDefined();
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
get current() {
|
|
144
|
+
return result.current;
|
|
145
|
+
},
|
|
146
|
+
unmount,
|
|
147
|
+
rerender: async () => {
|
|
148
|
+
rerender();
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
describe('Initialization and Command Loading', () => {
|
|
153
|
+
it('should initialize CommandService with all required loaders', async () => {
|
|
154
|
+
await setupProcessorHook();
|
|
155
|
+
expect(BuiltinCommandLoader).toHaveBeenCalledWith(mockConfig);
|
|
156
|
+
expect(FileCommandLoader).toHaveBeenCalledWith(mockConfig);
|
|
157
|
+
expect(McpPromptLoader).toHaveBeenCalledWith(mockConfig);
|
|
158
|
+
});
|
|
159
|
+
it('should call loadCommands and populate state after mounting', async () => {
|
|
160
|
+
const testCommand = createTestCommand({ name: 'test' });
|
|
161
|
+
const result = await setupProcessorHook([testCommand]);
|
|
162
|
+
await waitFor(() => {
|
|
163
|
+
expect(result.current.slashCommands).toHaveLength(1);
|
|
164
|
+
});
|
|
165
|
+
expect(result.current.slashCommands?.[0]?.name).toBe('test');
|
|
166
|
+
expect(mockBuiltinLoadCommands).toHaveBeenCalledTimes(1);
|
|
167
|
+
expect(mockFileLoadCommands).toHaveBeenCalledTimes(1);
|
|
168
|
+
expect(mockMcpLoadCommands).toHaveBeenCalledTimes(1);
|
|
169
|
+
});
|
|
170
|
+
it('should provide an immutable array of commands to consumers', async () => {
|
|
171
|
+
const testCommand = createTestCommand({ name: 'test' });
|
|
172
|
+
const result = await setupProcessorHook([testCommand]);
|
|
173
|
+
await waitFor(() => {
|
|
174
|
+
expect(result.current.slashCommands).toHaveLength(1);
|
|
175
|
+
});
|
|
176
|
+
const commands = result.current.slashCommands;
|
|
177
|
+
expect(() => {
|
|
178
|
+
// @ts-expect-error - We are intentionally testing a violation of the readonly type.
|
|
179
|
+
commands.push(createTestCommand({ name: 'rogue' }));
|
|
180
|
+
}).toThrow(TypeError);
|
|
181
|
+
});
|
|
182
|
+
it('should override built-in commands with file-based commands of the same name', async () => {
|
|
183
|
+
const builtinAction = vi.fn();
|
|
184
|
+
const fileAction = vi.fn();
|
|
185
|
+
const builtinCommand = createTestCommand({
|
|
186
|
+
name: 'override',
|
|
187
|
+
description: 'builtin',
|
|
188
|
+
action: builtinAction,
|
|
189
|
+
});
|
|
190
|
+
const fileCommand = createTestCommand({ name: 'override', description: 'file', action: fileAction }, CommandKind.FILE);
|
|
191
|
+
const result = await setupProcessorHook([builtinCommand], [fileCommand]);
|
|
192
|
+
await waitFor(() => {
|
|
193
|
+
// The service should only return one command with the name 'override'
|
|
194
|
+
expect(result.current.slashCommands).toHaveLength(1);
|
|
195
|
+
});
|
|
196
|
+
await act(async () => {
|
|
197
|
+
await result.current.handleSlashCommand('/override');
|
|
198
|
+
});
|
|
199
|
+
// Only the file-based command's action should be called.
|
|
200
|
+
expect(fileAction).toHaveBeenCalledTimes(1);
|
|
201
|
+
expect(builtinAction).not.toHaveBeenCalled();
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
describe('Command Execution Logic', () => {
|
|
205
|
+
it('should display an error for an unknown command', async () => {
|
|
206
|
+
const result = await setupProcessorHook();
|
|
207
|
+
await waitFor(() => expect(result.current.slashCommands).toBeDefined());
|
|
208
|
+
await act(async () => {
|
|
209
|
+
await result.current.handleSlashCommand('/nonexistent');
|
|
210
|
+
});
|
|
211
|
+
// Expect 2 calls: one for the user's input, one for the error message.
|
|
212
|
+
expect(mockAddItem).toHaveBeenCalledTimes(2);
|
|
213
|
+
expect(mockAddItem).toHaveBeenLastCalledWith({
|
|
214
|
+
type: MessageType.ERROR,
|
|
215
|
+
text: 'Unknown command: /nonexistent',
|
|
216
|
+
}, expect.any(Number));
|
|
217
|
+
});
|
|
218
|
+
it('should display help for a parent command invoked without a subcommand', async () => {
|
|
219
|
+
const parentCommand = {
|
|
220
|
+
name: 'parent',
|
|
221
|
+
description: 'a parent command',
|
|
222
|
+
kind: CommandKind.BUILT_IN,
|
|
223
|
+
subCommands: [
|
|
224
|
+
{
|
|
225
|
+
name: 'child1',
|
|
226
|
+
description: 'First child.',
|
|
227
|
+
kind: CommandKind.BUILT_IN,
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
const result = await setupProcessorHook([parentCommand]);
|
|
232
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
233
|
+
await act(async () => {
|
|
234
|
+
await result.current.handleSlashCommand('/parent');
|
|
235
|
+
});
|
|
236
|
+
expect(mockAddItem).toHaveBeenCalledTimes(2);
|
|
237
|
+
expect(mockAddItem).toHaveBeenLastCalledWith({
|
|
238
|
+
type: MessageType.INFO,
|
|
239
|
+
text: expect.stringContaining("Command '/parent' requires a subcommand."),
|
|
240
|
+
}, expect.any(Number));
|
|
241
|
+
});
|
|
242
|
+
it('should correctly find and execute a nested subcommand', async () => {
|
|
243
|
+
const childAction = vi.fn();
|
|
244
|
+
const parentCommand = {
|
|
245
|
+
name: 'parent',
|
|
246
|
+
description: 'a parent command',
|
|
247
|
+
kind: CommandKind.BUILT_IN,
|
|
248
|
+
subCommands: [
|
|
249
|
+
{
|
|
250
|
+
name: 'child',
|
|
251
|
+
description: 'a child command',
|
|
252
|
+
kind: CommandKind.BUILT_IN,
|
|
253
|
+
action: childAction,
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
};
|
|
257
|
+
const result = await setupProcessorHook([parentCommand]);
|
|
258
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
259
|
+
await act(async () => {
|
|
260
|
+
await result.current.handleSlashCommand('/parent child with args');
|
|
261
|
+
});
|
|
262
|
+
expect(childAction).toHaveBeenCalledTimes(1);
|
|
263
|
+
expect(childAction).toHaveBeenCalledWith(expect.objectContaining({
|
|
264
|
+
services: expect.objectContaining({
|
|
265
|
+
config: mockConfig,
|
|
266
|
+
}),
|
|
267
|
+
ui: expect.objectContaining({
|
|
268
|
+
addItem: mockAddItem,
|
|
269
|
+
}),
|
|
270
|
+
}), 'with args');
|
|
271
|
+
});
|
|
272
|
+
it('sets isProcessing to false if the the input is not a command', async () => {
|
|
273
|
+
const setMockIsProcessing = vi.fn();
|
|
274
|
+
const result = await setupProcessorHook([], [], [], setMockIsProcessing);
|
|
275
|
+
await act(async () => {
|
|
276
|
+
await result.current.handleSlashCommand('imnotacommand');
|
|
277
|
+
});
|
|
278
|
+
expect(setMockIsProcessing).not.toHaveBeenCalled();
|
|
279
|
+
});
|
|
280
|
+
it('sets isProcessing to false if the command has an error', async () => {
|
|
281
|
+
const setMockIsProcessing = vi.fn();
|
|
282
|
+
const failCommand = createTestCommand({
|
|
283
|
+
name: 'fail',
|
|
284
|
+
action: vi.fn().mockRejectedValue(new Error('oh no!')),
|
|
285
|
+
});
|
|
286
|
+
const result = await setupProcessorHook([failCommand], [], [], setMockIsProcessing);
|
|
287
|
+
await waitFor(() => expect(result.current.slashCommands).toBeDefined());
|
|
288
|
+
await act(async () => {
|
|
289
|
+
await result.current.handleSlashCommand('/fail');
|
|
290
|
+
});
|
|
291
|
+
expect(setMockIsProcessing).toHaveBeenNthCalledWith(1, true);
|
|
292
|
+
expect(setMockIsProcessing).toHaveBeenNthCalledWith(2, false);
|
|
293
|
+
});
|
|
294
|
+
it('should set isProcessing to true during execution and false afterwards', async () => {
|
|
295
|
+
const mockSetIsProcessing = vi.fn();
|
|
296
|
+
const command = createTestCommand({
|
|
297
|
+
name: 'long-running',
|
|
298
|
+
action: () => new Promise((resolve) => setTimeout(resolve, 50)),
|
|
299
|
+
});
|
|
300
|
+
const result = await setupProcessorHook([command], [], [], mockSetIsProcessing);
|
|
301
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
302
|
+
const executionPromise = act(async () => {
|
|
303
|
+
await result.current.handleSlashCommand('/long-running');
|
|
304
|
+
});
|
|
305
|
+
// It should be true immediately after starting
|
|
306
|
+
expect(mockSetIsProcessing).toHaveBeenNthCalledWith(1, true);
|
|
307
|
+
// It should not have been called with false yet
|
|
308
|
+
expect(mockSetIsProcessing).not.toHaveBeenCalledWith(false);
|
|
309
|
+
await executionPromise;
|
|
310
|
+
// After the promise resolves, it should be called with false
|
|
311
|
+
expect(mockSetIsProcessing).toHaveBeenNthCalledWith(2, false);
|
|
312
|
+
expect(mockSetIsProcessing).toHaveBeenCalledTimes(2);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
describe('Action Result Handling', () => {
|
|
316
|
+
describe('Dialog actions', () => {
|
|
317
|
+
it.each([
|
|
318
|
+
{
|
|
319
|
+
dialogType: 'theme',
|
|
320
|
+
commandName: 'themecmd',
|
|
321
|
+
mockFn: mockOpenThemeDialog,
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
dialogType: 'model',
|
|
325
|
+
commandName: 'modelcmd',
|
|
326
|
+
mockFn: mockOpenModelDialog,
|
|
327
|
+
},
|
|
328
|
+
])('should handle "dialog: $dialogType" action', async ({ dialogType, commandName, mockFn }) => {
|
|
329
|
+
const command = createTestCommand({
|
|
330
|
+
name: commandName,
|
|
331
|
+
action: vi
|
|
332
|
+
.fn()
|
|
333
|
+
.mockResolvedValue({ type: 'dialog', dialog: dialogType }),
|
|
334
|
+
});
|
|
335
|
+
const result = await setupProcessorHook([command]);
|
|
336
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
337
|
+
await act(async () => {
|
|
338
|
+
await result.current.handleSlashCommand(`/${commandName}`);
|
|
339
|
+
});
|
|
340
|
+
expect(mockFn).toHaveBeenCalled();
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
it('should handle "load_history" action', async () => {
|
|
344
|
+
const mockClient = {
|
|
345
|
+
setHistory: vi.fn(),
|
|
346
|
+
stripThoughtsFromHistory: vi.fn(),
|
|
347
|
+
};
|
|
348
|
+
vi.spyOn(mockConfig, 'getGeminiClient').mockReturnValue(mockClient);
|
|
349
|
+
const command = createTestCommand({
|
|
350
|
+
name: 'load',
|
|
351
|
+
action: vi.fn().mockResolvedValue({
|
|
352
|
+
type: 'load_history',
|
|
353
|
+
history: [{ type: MessageType.USER, text: 'old prompt' }],
|
|
354
|
+
clientHistory: [{ role: 'user', parts: [{ text: 'old prompt' }] }],
|
|
355
|
+
}),
|
|
356
|
+
});
|
|
357
|
+
const result = await setupProcessorHook([command]);
|
|
358
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
359
|
+
await act(async () => {
|
|
360
|
+
await result.current.handleSlashCommand('/load');
|
|
361
|
+
});
|
|
362
|
+
expect(mockClearItems).toHaveBeenCalledTimes(1);
|
|
363
|
+
expect(mockAddItem).toHaveBeenCalledWith({ type: 'user', text: 'old prompt' }, expect.any(Number));
|
|
364
|
+
});
|
|
365
|
+
it('should strip thoughts when handling "load_history" action', async () => {
|
|
366
|
+
const mockClient = {
|
|
367
|
+
setHistory: vi.fn(),
|
|
368
|
+
stripThoughtsFromHistory: vi.fn(),
|
|
369
|
+
};
|
|
370
|
+
vi.spyOn(mockConfig, 'getGeminiClient').mockReturnValue(mockClient);
|
|
371
|
+
const historyWithThoughts = [
|
|
372
|
+
{
|
|
373
|
+
role: 'model',
|
|
374
|
+
parts: [{ text: 'response', thoughtSignature: 'CikB...' }],
|
|
375
|
+
},
|
|
376
|
+
];
|
|
377
|
+
const command = createTestCommand({
|
|
378
|
+
name: 'loadwiththoughts',
|
|
379
|
+
action: vi.fn().mockResolvedValue({
|
|
380
|
+
type: 'load_history',
|
|
381
|
+
history: [{ type: MessageType.GEMINI, text: 'response' }],
|
|
382
|
+
clientHistory: historyWithThoughts,
|
|
383
|
+
}),
|
|
384
|
+
});
|
|
385
|
+
const result = await setupProcessorHook([command]);
|
|
386
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
387
|
+
await act(async () => {
|
|
388
|
+
await result.current.handleSlashCommand('/loadwiththoughts');
|
|
389
|
+
});
|
|
390
|
+
expect(mockClient.setHistory).toHaveBeenCalledTimes(1);
|
|
391
|
+
expect(mockClient.stripThoughtsFromHistory).toHaveBeenCalledWith();
|
|
392
|
+
});
|
|
393
|
+
it('should handle a "quit" action', async () => {
|
|
394
|
+
const quitAction = vi
|
|
395
|
+
.fn()
|
|
396
|
+
.mockResolvedValue({ type: 'quit', messages: ['bye'] });
|
|
397
|
+
const command = createTestCommand({
|
|
398
|
+
name: 'exit',
|
|
399
|
+
action: quitAction,
|
|
400
|
+
});
|
|
401
|
+
const result = await setupProcessorHook([command]);
|
|
402
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
403
|
+
await act(async () => {
|
|
404
|
+
await result.current.handleSlashCommand('/exit');
|
|
405
|
+
});
|
|
406
|
+
expect(mockSetQuittingMessages).toHaveBeenCalledWith(['bye']);
|
|
407
|
+
});
|
|
408
|
+
it('should handle "submit_prompt" action returned from a file-based command', async () => {
|
|
409
|
+
const fileCommand = createTestCommand({
|
|
410
|
+
name: 'filecmd',
|
|
411
|
+
description: 'A command from a file',
|
|
412
|
+
action: async () => ({
|
|
413
|
+
type: 'submit_prompt',
|
|
414
|
+
content: [{ text: 'The actual prompt from the TOML file.' }],
|
|
415
|
+
}),
|
|
416
|
+
}, CommandKind.FILE);
|
|
417
|
+
const result = await setupProcessorHook([], [fileCommand]);
|
|
418
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
419
|
+
let actionResult;
|
|
420
|
+
await act(async () => {
|
|
421
|
+
actionResult = await result.current.handleSlashCommand('/filecmd');
|
|
422
|
+
});
|
|
423
|
+
expect(actionResult).toEqual({
|
|
424
|
+
type: 'submit_prompt',
|
|
425
|
+
content: [{ text: 'The actual prompt from the TOML file.' }],
|
|
426
|
+
});
|
|
427
|
+
expect(mockAddItem).toHaveBeenCalledWith({ type: MessageType.USER, text: '/filecmd' }, expect.any(Number));
|
|
428
|
+
});
|
|
429
|
+
it('should handle "submit_prompt" action returned from a mcp-based command', async () => {
|
|
430
|
+
const mcpCommand = createTestCommand({
|
|
431
|
+
name: 'mcpcmd',
|
|
432
|
+
description: 'A command from mcp',
|
|
433
|
+
action: async () => ({
|
|
434
|
+
type: 'submit_prompt',
|
|
435
|
+
content: [{ text: 'The actual prompt from the mcp command.' }],
|
|
436
|
+
}),
|
|
437
|
+
}, CommandKind.MCP_PROMPT);
|
|
438
|
+
const result = await setupProcessorHook([], [], [mcpCommand]);
|
|
439
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
440
|
+
let actionResult;
|
|
441
|
+
await act(async () => {
|
|
442
|
+
actionResult = await result.current.handleSlashCommand('/mcpcmd');
|
|
443
|
+
});
|
|
444
|
+
expect(actionResult).toEqual({
|
|
445
|
+
type: 'submit_prompt',
|
|
446
|
+
content: [{ text: 'The actual prompt from the mcp command.' }],
|
|
447
|
+
});
|
|
448
|
+
expect(mockAddItem).toHaveBeenCalledWith({ type: MessageType.USER, text: '/mcpcmd' }, expect.any(Number));
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
describe('Shell Command Confirmation Flow', () => {
|
|
452
|
+
// Use a generic vi.fn() for the action. We will change its behavior in each test.
|
|
453
|
+
const mockCommandAction = vi.fn();
|
|
454
|
+
const shellCommand = createTestCommand({
|
|
455
|
+
name: 'shellcmd',
|
|
456
|
+
action: mockCommandAction,
|
|
457
|
+
});
|
|
458
|
+
beforeEach(() => {
|
|
459
|
+
// Reset the mock before each test
|
|
460
|
+
mockCommandAction.mockClear();
|
|
461
|
+
// Default behavior: request confirmation
|
|
462
|
+
mockCommandAction.mockResolvedValue({
|
|
463
|
+
type: 'confirm_shell_commands',
|
|
464
|
+
commandsToConfirm: ['rm -rf /'],
|
|
465
|
+
originalInvocation: { raw: '/shellcmd' },
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
it('should set confirmation request when action returns confirm_shell_commands', async () => {
|
|
469
|
+
const result = await setupProcessorHook([shellCommand]);
|
|
470
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
471
|
+
// Trigger command, don't await it yet as it suspends for confirmation
|
|
472
|
+
await act(async () => {
|
|
473
|
+
void result.current.handleSlashCommand('/shellcmd');
|
|
474
|
+
});
|
|
475
|
+
// We now wait for the state to be updated with the request.
|
|
476
|
+
await act(async () => {
|
|
477
|
+
await waitFor(() => {
|
|
478
|
+
expect(result.current.shellConfirmationRequest).not.toBeNull();
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
expect(result.current.shellConfirmationRequest?.commands).toEqual([
|
|
482
|
+
'rm -rf /',
|
|
483
|
+
]);
|
|
484
|
+
});
|
|
485
|
+
it('should do nothing if user cancels confirmation', async () => {
|
|
486
|
+
const result = await setupProcessorHook([shellCommand]);
|
|
487
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
488
|
+
await act(async () => {
|
|
489
|
+
void result.current.handleSlashCommand('/shellcmd');
|
|
490
|
+
});
|
|
491
|
+
// Wait for the confirmation dialog to be set
|
|
492
|
+
await act(async () => {
|
|
493
|
+
await waitFor(() => {
|
|
494
|
+
expect(result.current.shellConfirmationRequest).not.toBeNull();
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
const onConfirm = result.current.shellConfirmationRequest?.onConfirm;
|
|
498
|
+
expect(onConfirm).toBeDefined();
|
|
499
|
+
// Change the mock action's behavior for a potential second run.
|
|
500
|
+
// If the test is flawed, this will be called, and we can detect it.
|
|
501
|
+
mockCommandAction.mockResolvedValue({
|
|
502
|
+
type: 'message',
|
|
503
|
+
messageType: 'info',
|
|
504
|
+
content: 'This should not be called',
|
|
505
|
+
});
|
|
506
|
+
await act(async () => {
|
|
507
|
+
onConfirm(ToolConfirmationOutcome.Cancel, []); // Pass empty array for safety
|
|
508
|
+
});
|
|
509
|
+
expect(result.current.shellConfirmationRequest).toBeNull();
|
|
510
|
+
// Verify the action was only called the initial time.
|
|
511
|
+
expect(mockCommandAction).toHaveBeenCalledTimes(1);
|
|
512
|
+
});
|
|
513
|
+
it('should re-run command with one-time allowlist on "Proceed Once"', async () => {
|
|
514
|
+
const result = await setupProcessorHook([shellCommand]);
|
|
515
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
516
|
+
let commandPromise;
|
|
517
|
+
await act(async () => {
|
|
518
|
+
commandPromise = result.current.handleSlashCommand('/shellcmd');
|
|
519
|
+
});
|
|
520
|
+
await act(async () => {
|
|
521
|
+
await waitFor(() => {
|
|
522
|
+
expect(result.current.shellConfirmationRequest).not.toBeNull();
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
const onConfirm = result.current.shellConfirmationRequest?.onConfirm;
|
|
526
|
+
// **Change the mock's behavior for the SECOND run.**
|
|
527
|
+
// This is the key to testing the outcome.
|
|
528
|
+
mockCommandAction.mockResolvedValue({
|
|
529
|
+
type: 'message',
|
|
530
|
+
messageType: 'info',
|
|
531
|
+
content: 'Success!',
|
|
532
|
+
});
|
|
533
|
+
await act(async () => {
|
|
534
|
+
onConfirm(ToolConfirmationOutcome.ProceedOnce, ['rm -rf /']);
|
|
535
|
+
});
|
|
536
|
+
await act(async () => {
|
|
537
|
+
await commandPromise;
|
|
538
|
+
});
|
|
539
|
+
expect(result.current.shellConfirmationRequest).toBeNull();
|
|
540
|
+
// The action should have been called twice (initial + re-run).
|
|
541
|
+
await waitFor(() => {
|
|
542
|
+
expect(mockCommandAction).toHaveBeenCalledTimes(2);
|
|
543
|
+
});
|
|
544
|
+
// We can inspect the context of the second call to ensure the one-time list was used.
|
|
545
|
+
const secondCallContext = mockCommandAction.mock
|
|
546
|
+
.calls[1][0];
|
|
547
|
+
expect(secondCallContext.session.sessionShellAllowlist.has('rm -rf /')).toBe(true);
|
|
548
|
+
// Verify the final success message was added.
|
|
549
|
+
expect(mockAddItem).toHaveBeenCalledWith({ type: MessageType.INFO, text: 'Success!' }, expect.any(Number));
|
|
550
|
+
// Verify the session-wide allowlist was NOT permanently updated.
|
|
551
|
+
// Re-render the hook by calling a no-op command to get the latest context.
|
|
552
|
+
await act(async () => {
|
|
553
|
+
await result.current.handleSlashCommand('/no-op');
|
|
554
|
+
});
|
|
555
|
+
const finalContext = result.current.commandContext;
|
|
556
|
+
expect(finalContext.session.sessionShellAllowlist.size).toBe(0);
|
|
557
|
+
});
|
|
558
|
+
it('should re-run command and update session allowlist on "Proceed Always"', async () => {
|
|
559
|
+
const result = await setupProcessorHook([shellCommand]);
|
|
560
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
561
|
+
let commandPromise;
|
|
562
|
+
await act(async () => {
|
|
563
|
+
commandPromise = result.current.handleSlashCommand('/shellcmd');
|
|
564
|
+
});
|
|
565
|
+
await act(async () => {
|
|
566
|
+
await waitFor(() => {
|
|
567
|
+
expect(result.current.shellConfirmationRequest).not.toBeNull();
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
const onConfirm = result.current.shellConfirmationRequest?.onConfirm;
|
|
571
|
+
mockCommandAction.mockResolvedValue({
|
|
572
|
+
type: 'message',
|
|
573
|
+
messageType: 'info',
|
|
574
|
+
content: 'Success!',
|
|
575
|
+
});
|
|
576
|
+
await act(async () => {
|
|
577
|
+
onConfirm(ToolConfirmationOutcome.ProceedAlways, ['rm -rf /']);
|
|
578
|
+
});
|
|
579
|
+
await act(async () => {
|
|
580
|
+
await commandPromise;
|
|
581
|
+
});
|
|
582
|
+
expect(result.current.shellConfirmationRequest).toBeNull();
|
|
583
|
+
await waitFor(() => {
|
|
584
|
+
expect(mockCommandAction).toHaveBeenCalledTimes(2);
|
|
585
|
+
});
|
|
586
|
+
expect(mockAddItem).toHaveBeenCalledWith({ type: MessageType.INFO, text: 'Success!' }, expect.any(Number));
|
|
587
|
+
// Check that the session-wide allowlist WAS updated.
|
|
588
|
+
await waitFor(() => {
|
|
589
|
+
const finalContext = result.current.commandContext;
|
|
590
|
+
expect(finalContext.session.sessionShellAllowlist.has('rm -rf /')).toBe(true);
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
describe('Command Parsing and Matching', () => {
|
|
595
|
+
it('should be case-sensitive', async () => {
|
|
596
|
+
const command = createTestCommand({ name: 'test' });
|
|
597
|
+
const result = await setupProcessorHook([command]);
|
|
598
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
599
|
+
await act(async () => {
|
|
600
|
+
// Use uppercase when command is lowercase
|
|
601
|
+
await result.current.handleSlashCommand('/Test');
|
|
602
|
+
});
|
|
603
|
+
// It should fail and call addItem with an error
|
|
604
|
+
expect(mockAddItem).toHaveBeenCalledWith({
|
|
605
|
+
type: MessageType.ERROR,
|
|
606
|
+
text: 'Unknown command: /Test',
|
|
607
|
+
}, expect.any(Number));
|
|
608
|
+
});
|
|
609
|
+
it('should correctly match an altName', async () => {
|
|
610
|
+
const action = vi.fn();
|
|
611
|
+
const command = createTestCommand({
|
|
612
|
+
name: 'main',
|
|
613
|
+
altNames: ['alias'],
|
|
614
|
+
description: 'a command with an alias',
|
|
615
|
+
action,
|
|
616
|
+
});
|
|
617
|
+
const result = await setupProcessorHook([command]);
|
|
618
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
619
|
+
await act(async () => {
|
|
620
|
+
await result.current.handleSlashCommand('/alias');
|
|
621
|
+
});
|
|
622
|
+
expect(action).toHaveBeenCalledTimes(1);
|
|
623
|
+
expect(mockAddItem).not.toHaveBeenCalledWith(expect.objectContaining({ type: MessageType.ERROR }));
|
|
624
|
+
});
|
|
625
|
+
it('should handle extra whitespace around the command', async () => {
|
|
626
|
+
const action = vi.fn();
|
|
627
|
+
const command = createTestCommand({ name: 'test', action });
|
|
628
|
+
const result = await setupProcessorHook([command]);
|
|
629
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
630
|
+
await act(async () => {
|
|
631
|
+
await result.current.handleSlashCommand(' /test with-args ');
|
|
632
|
+
});
|
|
633
|
+
expect(action).toHaveBeenCalledWith(expect.anything(), 'with-args');
|
|
634
|
+
});
|
|
635
|
+
it('should handle `?` as a command prefix', async () => {
|
|
636
|
+
const action = vi.fn();
|
|
637
|
+
const command = createTestCommand({ name: 'help', action });
|
|
638
|
+
const result = await setupProcessorHook([command]);
|
|
639
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(1));
|
|
640
|
+
await act(async () => {
|
|
641
|
+
await result.current.handleSlashCommand('?help');
|
|
642
|
+
});
|
|
643
|
+
expect(action).toHaveBeenCalledTimes(1);
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
describe('Command Precedence', () => {
|
|
647
|
+
it('should override mcp-based commands with file-based commands of the same name', async () => {
|
|
648
|
+
const mcpAction = vi.fn();
|
|
649
|
+
const fileAction = vi.fn();
|
|
650
|
+
const mcpCommand = createTestCommand({
|
|
651
|
+
name: 'override',
|
|
652
|
+
description: 'mcp',
|
|
653
|
+
action: mcpAction,
|
|
654
|
+
}, CommandKind.MCP_PROMPT);
|
|
655
|
+
const fileCommand = createTestCommand({ name: 'override', description: 'file', action: fileAction }, CommandKind.FILE);
|
|
656
|
+
const result = await setupProcessorHook([], [fileCommand], [mcpCommand]);
|
|
657
|
+
await waitFor(() => {
|
|
658
|
+
// The service should only return one command with the name 'override'
|
|
659
|
+
expect(result.current.slashCommands).toHaveLength(1);
|
|
660
|
+
});
|
|
661
|
+
await act(async () => {
|
|
662
|
+
await result.current.handleSlashCommand('/override');
|
|
663
|
+
});
|
|
664
|
+
// Only the file-based command's action should be called.
|
|
665
|
+
expect(fileAction).toHaveBeenCalledTimes(1);
|
|
666
|
+
expect(mcpAction).not.toHaveBeenCalled();
|
|
667
|
+
});
|
|
668
|
+
it('should prioritize a command with a primary name over a command with a matching alias', async () => {
|
|
669
|
+
const quitAction = vi.fn();
|
|
670
|
+
const exitAction = vi.fn();
|
|
671
|
+
const quitCommand = createTestCommand({
|
|
672
|
+
name: 'quit',
|
|
673
|
+
altNames: ['exit'],
|
|
674
|
+
action: quitAction,
|
|
675
|
+
});
|
|
676
|
+
const exitCommand = createTestCommand({
|
|
677
|
+
name: 'exit',
|
|
678
|
+
action: exitAction,
|
|
679
|
+
}, CommandKind.FILE);
|
|
680
|
+
// The order of commands in the final loaded array is not guaranteed,
|
|
681
|
+
// so the test must work regardless of which comes first.
|
|
682
|
+
const result = await setupProcessorHook([quitCommand], [exitCommand]);
|
|
683
|
+
await waitFor(() => {
|
|
684
|
+
expect(result.current.slashCommands).toHaveLength(2);
|
|
685
|
+
});
|
|
686
|
+
await act(async () => {
|
|
687
|
+
await result.current.handleSlashCommand('/exit');
|
|
688
|
+
});
|
|
689
|
+
// The action for the command whose primary name is 'exit' should be called.
|
|
690
|
+
expect(exitAction).toHaveBeenCalledTimes(1);
|
|
691
|
+
// The action for the command that has 'exit' as an alias should NOT be called.
|
|
692
|
+
expect(quitAction).not.toHaveBeenCalled();
|
|
693
|
+
});
|
|
694
|
+
it('should add an overridden command to the history', async () => {
|
|
695
|
+
const quitCommand = createTestCommand({
|
|
696
|
+
name: 'quit',
|
|
697
|
+
altNames: ['exit'],
|
|
698
|
+
action: vi.fn(),
|
|
699
|
+
});
|
|
700
|
+
const exitCommand = createTestCommand({ name: 'exit', action: vi.fn() }, CommandKind.FILE);
|
|
701
|
+
const result = await setupProcessorHook([quitCommand], [exitCommand]);
|
|
702
|
+
await waitFor(() => expect(result.current.slashCommands).toHaveLength(2));
|
|
703
|
+
await act(async () => {
|
|
704
|
+
await result.current.handleSlashCommand('/exit');
|
|
705
|
+
});
|
|
706
|
+
// It should be added to the history.
|
|
707
|
+
expect(mockAddItem).toHaveBeenCalledWith({ type: MessageType.USER, text: '/exit' }, expect.any(Number));
|
|
708
|
+
});
|
|
709
|
+
});
|
|
710
|
+
describe('Lifecycle', () => {
|
|
711
|
+
it('should abort command loading when the hook unmounts', async () => {
|
|
712
|
+
const abortSpy = vi.spyOn(AbortController.prototype, 'abort');
|
|
713
|
+
const { unmount } = await setupProcessorHook();
|
|
714
|
+
unmount();
|
|
715
|
+
expect(abortSpy).toHaveBeenCalledTimes(1);
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
describe('Slash Command Logging', () => {
|
|
719
|
+
const mockCommandAction = vi.fn().mockResolvedValue({ type: 'handled' });
|
|
720
|
+
const loggingTestCommands = [
|
|
721
|
+
createTestCommand({
|
|
722
|
+
name: 'logtest',
|
|
723
|
+
action: vi
|
|
724
|
+
.fn()
|
|
725
|
+
.mockResolvedValue({ type: 'message', content: 'hello world' }),
|
|
726
|
+
}),
|
|
727
|
+
createTestCommand({
|
|
728
|
+
name: 'logwithsub',
|
|
729
|
+
subCommands: [
|
|
730
|
+
createTestCommand({
|
|
731
|
+
name: 'sub',
|
|
732
|
+
action: mockCommandAction,
|
|
733
|
+
}),
|
|
734
|
+
],
|
|
735
|
+
}),
|
|
736
|
+
createTestCommand({
|
|
737
|
+
name: 'fail',
|
|
738
|
+
action: vi.fn().mockRejectedValue(new Error('oh no!')),
|
|
739
|
+
}),
|
|
740
|
+
createTestCommand({
|
|
741
|
+
name: 'logalias',
|
|
742
|
+
altNames: ['la'],
|
|
743
|
+
action: mockCommandAction,
|
|
744
|
+
}),
|
|
745
|
+
];
|
|
746
|
+
beforeEach(() => {
|
|
747
|
+
mockCommandAction.mockClear();
|
|
748
|
+
vi.mocked(logSlashCommand).mockClear();
|
|
749
|
+
});
|
|
750
|
+
it.each([
|
|
751
|
+
{
|
|
752
|
+
command: '/logtest',
|
|
753
|
+
expectedLog: {
|
|
754
|
+
command: 'logtest',
|
|
755
|
+
subcommand: undefined,
|
|
756
|
+
status: SlashCommandStatus.SUCCESS,
|
|
757
|
+
},
|
|
758
|
+
desc: 'simple slash command',
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
command: '/fail',
|
|
762
|
+
expectedLog: {
|
|
763
|
+
command: 'fail',
|
|
764
|
+
status: 'error',
|
|
765
|
+
subcommand: undefined,
|
|
766
|
+
},
|
|
767
|
+
desc: 'failure event for failed command',
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
command: '/logwithsub sub',
|
|
771
|
+
expectedLog: {
|
|
772
|
+
command: 'logwithsub',
|
|
773
|
+
subcommand: 'sub',
|
|
774
|
+
},
|
|
775
|
+
desc: 'slash command with subcommand',
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
command: '/la',
|
|
779
|
+
expectedLog: {
|
|
780
|
+
command: 'logalias',
|
|
781
|
+
},
|
|
782
|
+
desc: 'command path when alias is used',
|
|
783
|
+
},
|
|
784
|
+
])('should log $desc', async ({ command, expectedLog }) => {
|
|
785
|
+
const result = await setupProcessorHook(loggingTestCommands);
|
|
786
|
+
await waitFor(() => expect(result.current.slashCommands).toBeDefined());
|
|
787
|
+
await act(async () => {
|
|
788
|
+
await result.current.handleSlashCommand(command);
|
|
789
|
+
});
|
|
790
|
+
await waitFor(() => {
|
|
791
|
+
expect(logSlashCommand).toHaveBeenCalledWith(mockConfig, expect.objectContaining(expectedLog));
|
|
792
|
+
});
|
|
793
|
+
});
|
|
794
|
+
it.each([
|
|
795
|
+
{ command: '/bogusbogusbogus', desc: 'bogus command' },
|
|
796
|
+
{ command: '/unknown', desc: 'unknown command' },
|
|
797
|
+
])('should not log for $desc', async ({ command }) => {
|
|
798
|
+
const result = await setupProcessorHook(loggingTestCommands);
|
|
799
|
+
await waitFor(() => expect(result.current.slashCommands).toBeDefined());
|
|
800
|
+
await act(async () => {
|
|
801
|
+
await result.current.handleSlashCommand(command);
|
|
802
|
+
});
|
|
803
|
+
expect(logSlashCommand).not.toHaveBeenCalled();
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
});
|
|
807
|
+
//# sourceMappingURL=slashCommandProcessor.test.js.map
|