centaurus-cli 2.5.2 → 2.6.0
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/cli-adapter.d.ts +6 -0
- package/dist/cli-adapter.d.ts.map +1 -1
- package/dist/cli-adapter.js +215 -29
- package/dist/cli-adapter.js.map +1 -1
- package/dist/commands/CommandParser.js +2 -2
- package/dist/commands/CommandParser.js.map +1 -1
- package/dist/config/defaultConfig.js +1 -1
- package/dist/config/defaultConfig.js.map +1 -1
- package/dist/config/models.d.ts +50 -5
- package/dist/config/models.d.ts.map +1 -1
- package/dist/config/models.js +144 -20
- package/dist/config/models.js.map +1 -1
- package/dist/config/types.d.ts +3 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +3 -1
- package/dist/config/types.js.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/services/ai-service-client.d.ts +8 -2
- package/dist/services/ai-service-client.d.ts.map +1 -1
- package/dist/services/ai-service-client.js +2 -1
- package/dist/services/ai-service-client.js.map +1 -1
- package/dist/services/environment-context-injector.d.ts +69 -0
- package/dist/services/environment-context-injector.d.ts.map +1 -0
- package/dist/services/environment-context-injector.js +198 -0
- package/dist/services/environment-context-injector.js.map +1 -0
- package/dist/tools/ToolRegistry.d.ts.map +1 -1
- package/dist/tools/ToolRegistry.js +120 -26
- package/dist/tools/ToolRegistry.js.map +1 -1
- package/dist/tools/command.d.ts.map +1 -1
- package/dist/tools/command.js +30 -6
- package/dist/tools/command.js.map +1 -1
- package/dist/tools/file-ops.d.ts.map +1 -1
- package/dist/tools/file-ops.js +70 -23
- package/dist/tools/file-ops.js.map +1 -1
- package/dist/tools/find-files.d.ts +47 -0
- package/dist/tools/find-files.d.ts.map +1 -0
- package/dist/tools/find-files.js +190 -0
- package/dist/tools/find-files.js.map +1 -0
- package/dist/tools/get-diff.d.ts +45 -0
- package/dist/tools/get-diff.d.ts.map +1 -0
- package/dist/tools/get-diff.js +138 -0
- package/dist/tools/get-diff.js.map +1 -0
- package/dist/tools/grep-search.d.ts +85 -0
- package/dist/tools/grep-search.d.ts.map +1 -0
- package/dist/tools/grep-search.js +497 -0
- package/dist/tools/grep-search.js.map +1 -0
- package/dist/tools/inspect-symbol.d.ts +27 -0
- package/dist/tools/inspect-symbol.d.ts.map +1 -0
- package/dist/tools/inspect-symbol.js +259 -0
- package/dist/tools/inspect-symbol.js.map +1 -0
- package/dist/tools/validation.d.ts +49 -0
- package/dist/tools/validation.d.ts.map +1 -0
- package/dist/tools/validation.js +125 -0
- package/dist/tools/validation.js.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/components/App.d.ts +3 -0
- package/dist/ui/components/App.d.ts.map +1 -1
- package/dist/ui/components/App.js +272 -72
- package/dist/ui/components/App.js.map +1 -1
- package/dist/ui/components/ContextWindowIndicator.d.ts +8 -0
- package/dist/ui/components/ContextWindowIndicator.d.ts.map +1 -0
- package/dist/ui/components/ContextWindowIndicator.js +34 -0
- package/dist/ui/components/ContextWindowIndicator.js.map +1 -0
- package/dist/ui/components/FontRecommendation.d.ts +1 -0
- package/dist/ui/components/FontRecommendation.d.ts.map +1 -0
- package/dist/ui/components/FontRecommendation.js +1 -0
- package/dist/ui/components/FontRecommendation.js.map +1 -0
- package/dist/ui/components/InputBox.d.ts +2 -0
- package/dist/ui/components/InputBox.d.ts.map +1 -1
- package/dist/ui/components/InputBox.js +9 -4
- package/dist/ui/components/InputBox.js.map +1 -1
- package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/ui/components/MarkdownRenderer.js +34 -9
- package/dist/ui/components/MarkdownRenderer.js.map +1 -1
- package/dist/ui/components/MessageDisplay.d.ts.map +1 -1
- package/dist/ui/components/MessageDisplay.js +9 -2
- package/dist/ui/components/MessageDisplay.js.map +1 -1
- package/dist/ui/components/StreamingMessageDisplay.d.ts.map +1 -1
- package/dist/ui/components/StreamingMessageDisplay.js +11 -3
- package/dist/ui/components/StreamingMessageDisplay.js.map +1 -1
- package/dist/ui/components/ThinkingDisplay.d.ts +12 -0
- package/dist/ui/components/ThinkingDisplay.d.ts.map +1 -0
- package/dist/ui/components/ThinkingDisplay.js +41 -0
- package/dist/ui/components/ThinkingDisplay.js.map +1 -0
- package/dist/utils/markdown-parser.d.ts +4 -0
- package/dist/utils/markdown-parser.d.ts.map +1 -1
- package/dist/utils/markdown-parser.js +15 -1
- package/dist/utils/markdown-parser.js.map +1 -1
- package/dist/utils/version-checker.d.ts.map +1 -1
- package/dist/utils/version-checker.js +3 -31
- package/dist/utils/version-checker.js.map +1 -1
- package/package.json +6 -5
- package/README.md +0 -501
- package/dist/ai/provider-factory.d.ts +0 -6
- package/dist/ai/provider-factory.d.ts.map +0 -1
- package/dist/ai/provider-factory.js +0 -27
- package/dist/ai/provider-factory.js.map +0 -1
- package/dist/ai/providers/base.d.ts +0 -25
- package/dist/ai/providers/base.d.ts.map +0 -1
- package/dist/ai/providers/base.js +0 -9
- package/dist/ai/providers/base.js.map +0 -1
- package/dist/ai/providers/gemini.d.ts +0 -34
- package/dist/ai/providers/gemini.d.ts.map +0 -1
- package/dist/ai/providers/gemini.js +0 -146
- package/dist/ai/providers/gemini.js.map +0 -1
- package/dist/commands/view-duplication-logs.d.ts +0 -5
- package/dist/commands/view-duplication-logs.d.ts.map +0 -1
- package/dist/commands/view-duplication-logs.js +0 -14
- package/dist/commands/view-duplication-logs.js.map +0 -1
- package/dist/context/__tests__/command-detector.test.d.ts +0 -14
- package/dist/context/__tests__/command-detector.test.d.ts.map +0 -1
- package/dist/context/__tests__/command-detector.test.js +0 -318
- package/dist/context/__tests__/command-detector.test.js.map +0 -1
- package/dist/context/__tests__/context-manager.test.d.ts +0 -16
- package/dist/context/__tests__/context-manager.test.d.ts.map +0 -1
- package/dist/context/__tests__/context-manager.test.js +0 -375
- package/dist/context/__tests__/context-manager.test.js.map +0 -1
- package/dist/context/__tests__/error-handling.test.d.ts +0 -15
- package/dist/context/__tests__/error-handling.test.d.ts.map +0 -1
- package/dist/context/__tests__/error-handling.test.js +0 -447
- package/dist/context/__tests__/error-handling.test.js.map +0 -1
- package/dist/context/handlers/__tests__/docker-handler.test.d.ts +0 -13
- package/dist/context/handlers/__tests__/docker-handler.test.d.ts.map +0 -1
- package/dist/context/handlers/__tests__/docker-handler.test.js +0 -285
- package/dist/context/handlers/__tests__/docker-handler.test.js.map +0 -1
- package/dist/context/handlers/__tests__/ssh-handler.test.d.ts +0 -13
- package/dist/context/handlers/__tests__/ssh-handler.test.d.ts.map +0 -1
- package/dist/context/handlers/__tests__/ssh-handler.test.js +0 -251
- package/dist/context/handlers/__tests__/ssh-handler.test.js.map +0 -1
- package/dist/context/handlers/__tests__/wsl-handler.test.d.ts +0 -7
- package/dist/context/handlers/__tests__/wsl-handler.test.d.ts.map +0 -1
- package/dist/context/handlers/__tests__/wsl-handler.test.js +0 -331
- package/dist/context/handlers/__tests__/wsl-handler.test.js.map +0 -1
- package/dist/index-custom.d.ts +0 -3
- package/dist/index-custom.d.ts.map +0 -1
- package/dist/index-custom.js +0 -65
- package/dist/index-custom.js.map +0 -1
- package/dist/prompts/system-prompt.d.ts +0 -47
- package/dist/prompts/system-prompt.d.ts.map +0 -1
- package/dist/prompts/system-prompt.js +0 -377
- package/dist/prompts/system-prompt.js.map +0 -1
- package/dist/providers/GoogleProvider.d.ts +0 -26
- package/dist/providers/GoogleProvider.d.ts.map +0 -1
- package/dist/providers/GoogleProvider.js +0 -313
- package/dist/providers/GoogleProvider.js.map +0 -1
- package/dist/providers/Provider.d.ts +0 -114
- package/dist/providers/Provider.d.ts.map +0 -1
- package/dist/providers/Provider.js +0 -44
- package/dist/providers/Provider.js.map +0 -1
- package/dist/services/__tests__/ai-context-injector.test.d.ts +0 -15
- package/dist/services/__tests__/ai-context-injector.test.d.ts.map +0 -1
- package/dist/services/__tests__/ai-context-injector.test.js +0 -326
- package/dist/services/__tests__/ai-context-injector.test.js.map +0 -1
- package/dist/src/context/types.js +0 -27
- package/dist/src/services/ai-context-injector.js +0 -96
- package/dist/src/services/ai-service-client.js +0 -270
- package/dist/src/services/api-client.js +0 -349
- package/dist/src/tools/types.js +0 -1
- package/dist/src/types/index.js +0 -1
- package/dist/test/context/types.js +0 -27
- package/dist/test/services/__tests__/ai-context-injector.test.js +0 -325
- package/dist/test/services/ai-context-injector.js +0 -96
- package/dist/test/services/ai-service-client.js +0 -270
- package/dist/test/services/api-client.js +0 -349
- package/dist/test/tools/types.js +0 -1
- package/dist/test/types/index.js +0 -1
- package/dist/test-ai-context-injector.js +0 -97
- package/dist/tests/automated-verification.d.ts +0 -27
- package/dist/tests/automated-verification.d.ts.map +0 -1
- package/dist/tests/automated-verification.js +0 -359
- package/dist/tests/automated-verification.js.map +0 -1
- package/dist/tests/integration-tests.d.ts +0 -50
- package/dist/tests/integration-tests.d.ts.map +0 -1
- package/dist/tests/integration-tests.js +0 -648
- package/dist/tests/integration-tests.js.map +0 -1
- package/dist/tools/file-ops-test.d.ts +0 -6
- package/dist/tools/file-ops-test.d.ts.map +0 -1
- package/dist/tools/file-ops-test.js +0 -197
- package/dist/tools/file-ops-test.js.map +0 -1
- package/dist/ui/DisplayHistory.d.ts +0 -53
- package/dist/ui/DisplayHistory.d.ts.map +0 -1
- package/dist/ui/DisplayHistory.js +0 -82
- package/dist/ui/DisplayHistory.js.map +0 -1
- package/dist/ui/clack-ui.d.ts +0 -83
- package/dist/ui/clack-ui.d.ts.map +0 -1
- package/dist/ui/clack-ui.js +0 -304
- package/dist/ui/clack-ui.js.map +0 -1
- package/dist/ui/components/DisplayItemRenderer.d.ts +0 -18
- package/dist/ui/components/DisplayItemRenderer.d.ts.map +0 -1
- package/dist/ui/components/DisplayItemRenderer.js +0 -53
- package/dist/ui/components/DisplayItemRenderer.js.map +0 -1
- package/dist/ui/components/DynamicMessage.d.ts +0 -13
- package/dist/ui/components/DynamicMessage.d.ts.map +0 -1
- package/dist/ui/components/DynamicMessage.js +0 -27
- package/dist/ui/components/DynamicMessage.js.map +0 -1
- package/dist/ui/components/FileViewerScreen.d.ts +0 -14
- package/dist/ui/components/FileViewerScreen.d.ts.map +0 -1
- package/dist/ui/components/FileViewerScreen.js +0 -74
- package/dist/ui/components/FileViewerScreen.js.map +0 -1
- package/dist/ui/components/ScrollableContent.d.ts +0 -7
- package/dist/ui/components/ScrollableContent.d.ts.map +0 -1
- package/dist/ui/components/ScrollableContent.js +0 -6
- package/dist/ui/components/ScrollableContent.js.map +0 -1
- package/dist/ui/components/ScrollableMessageList.d.ts +0 -10
- package/dist/ui/components/ScrollableMessageList.d.ts.map +0 -1
- package/dist/ui/components/ScrollableMessageList.js +0 -133
- package/dist/ui/components/ScrollableMessageList.js.map +0 -1
- package/dist/ui/components/ScrollableScreen.d.ts +0 -9
- package/dist/ui/components/ScrollableScreen.d.ts.map +0 -1
- package/dist/ui/components/ScrollableScreen.js +0 -22
- package/dist/ui/components/ScrollableScreen.js.map +0 -1
- package/dist/ui/components/StaticMessageHistory.d.ts +0 -14
- package/dist/ui/components/StaticMessageHistory.d.ts.map +0 -1
- package/dist/ui/components/StaticMessageHistory.js +0 -19
- package/dist/ui/components/StaticMessageHistory.js.map +0 -1
- package/dist/ui/components/code-block.d.ts +0 -10
- package/dist/ui/components/code-block.d.ts.map +0 -1
- package/dist/ui/components/code-block.js +0 -74
- package/dist/ui/components/code-block.js.map +0 -1
- package/dist/ui/components/confirm-prompt.d.ts +0 -12
- package/dist/ui/components/confirm-prompt.d.ts.map +0 -1
- package/dist/ui/components/confirm-prompt.js +0 -104
- package/dist/ui/components/confirm-prompt.js.map +0 -1
- package/dist/ui/components/diff-viewer.d.ts +0 -9
- package/dist/ui/components/diff-viewer.d.ts.map +0 -1
- package/dist/ui/components/diff-viewer.js +0 -57
- package/dist/ui/components/diff-viewer.js.map +0 -1
- package/dist/ui/components/input-box.d.ts +0 -18
- package/dist/ui/components/input-box.d.ts.map +0 -1
- package/dist/ui/components/input-box.js +0 -157
- package/dist/ui/components/input-box.js.map +0 -1
- package/dist/ui/components/keyboard-help.d.ts +0 -7
- package/dist/ui/components/keyboard-help.d.ts.map +0 -1
- package/dist/ui/components/keyboard-help.js +0 -43
- package/dist/ui/components/keyboard-help.js.map +0 -1
- package/dist/ui/components/loading-indicator.d.ts +0 -3
- package/dist/ui/components/loading-indicator.d.ts.map +0 -1
- package/dist/ui/components/loading-indicator.js +0 -42
- package/dist/ui/components/loading-indicator.js.map +0 -1
- package/dist/ui/components/message-display.d.ts +0 -7
- package/dist/ui/components/message-display.d.ts.map +0 -1
- package/dist/ui/components/message-display.js +0 -104
- package/dist/ui/components/message-display.js.map +0 -1
- package/dist/ui/components/misc.d.ts +0 -28
- package/dist/ui/components/misc.d.ts.map +0 -1
- package/dist/ui/components/misc.js +0 -128
- package/dist/ui/components/misc.js.map +0 -1
- package/dist/ui/components/select-prompt.d.ts +0 -13
- package/dist/ui/components/select-prompt.d.ts.map +0 -1
- package/dist/ui/components/select-prompt.js +0 -42
- package/dist/ui/components/select-prompt.js.map +0 -1
- package/dist/ui/components/status-bar.d.ts +0 -11
- package/dist/ui/components/status-bar.d.ts.map +0 -1
- package/dist/ui/components/status-bar.js +0 -47
- package/dist/ui/components/status-bar.js.map +0 -1
- package/dist/ui/components/tool-execution.d.ts +0 -3
- package/dist/ui/components/tool-execution.d.ts.map +0 -1
- package/dist/ui/components/tool-execution.js +0 -374
- package/dist/ui/components/tool-execution.js.map +0 -1
- package/dist/ui/components/tool-result.d.ts +0 -11
- package/dist/ui/components/tool-result.d.ts.map +0 -1
- package/dist/ui/components/tool-result.js +0 -58
- package/dist/ui/components/tool-result.js.map +0 -1
- package/dist/ui/components/welcome-banner.d.ts +0 -3
- package/dist/ui/components/welcome-banner.d.ts.map +0 -1
- package/dist/ui/components/welcome-banner.js +0 -46
- package/dist/ui/components/welcome-banner.js.map +0 -1
- package/dist/ui/hooks/useDisplayHistory.d.ts +0 -13
- package/dist/ui/hooks/useDisplayHistory.d.ts.map +0 -1
- package/dist/ui/hooks/useDisplayHistory.js +0 -45
- package/dist/ui/hooks/useDisplayHistory.js.map +0 -1
- package/dist/ui/render-engine.d.ts +0 -69
- package/dist/ui/render-engine.d.ts.map +0 -1
- package/dist/ui/render-engine.js +0 -197
- package/dist/ui/render-engine.js.map +0 -1
- package/dist/ui/terminal/TerminalRenderer.d.ts +0 -84
- package/dist/ui/terminal/TerminalRenderer.d.ts.map +0 -1
- package/dist/ui/terminal/TerminalRenderer.js +0 -154
- package/dist/ui/terminal/TerminalRenderer.js.map +0 -1
- package/dist/ui/terminal/TerminalUI.d.ts +0 -139
- package/dist/ui/terminal/TerminalUI.d.ts.map +0 -1
- package/dist/ui/terminal/TerminalUI.js +0 -430
- package/dist/ui/terminal/TerminalUI.js.map +0 -1
- package/dist/ui/terminal/VirtualChatBuffer.d.ts +0 -32
- package/dist/ui/terminal/VirtualChatBuffer.d.ts.map +0 -1
- package/dist/ui/terminal/VirtualChatBuffer.js +0 -37
- package/dist/ui/terminal/VirtualChatBuffer.js.map +0 -1
- package/dist/ui/terminal-kit-base.d.ts +0 -117
- package/dist/ui/terminal-kit-base.d.ts.map +0 -1
- package/dist/ui/terminal-kit-base.js +0 -188
- package/dist/ui/terminal-kit-base.js.map +0 -1
- package/dist/ui/utils/duplication-detector.d.ts +0 -32
- package/dist/ui/utils/duplication-detector.d.ts.map +0 -1
- package/dist/ui/utils/duplication-detector.js +0 -227
- package/dist/ui/utils/duplication-detector.js.map +0 -1
- package/dist/ui/utils/duplication-logger.d.ts +0 -21
- package/dist/ui/utils/duplication-logger.d.ts.map +0 -1
- package/dist/ui/utils/duplication-logger.js +0 -85
- package/dist/ui/utils/duplication-logger.js.map +0 -1
- package/dist/ui/utils/terminal-scanner.d.ts +0 -19
- package/dist/ui/utils/terminal-scanner.d.ts.map +0 -1
- package/dist/ui/utils/terminal-scanner.js +0 -217
- package/dist/ui/utils/terminal-scanner.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -3
- package/dist/version.js.map +0 -1
- package/scripts/generate-version.js +0 -25
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-factory.d.ts","sourceRoot":"","sources":["../../src/ai/provider-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,qBAAa,eAAe;IAC1B,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;CAuBlD"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { GeminiProvider } from './providers/gemini.js';
|
|
2
|
-
export class ProviderFactory {
|
|
3
|
-
static createProvider(config) {
|
|
4
|
-
if (config.provider === 'google') {
|
|
5
|
-
if (!config.googleApiKey) {
|
|
6
|
-
throw new Error('Google API key not configured. Please set it using: /config set googleApiKey YOUR_API_KEY');
|
|
7
|
-
}
|
|
8
|
-
// Parse comma-separated keys to validate
|
|
9
|
-
const keys = config.googleApiKey.split(',').map(k => k.trim()).filter(k => k.length > 0);
|
|
10
|
-
if (keys.length === 0) {
|
|
11
|
-
throw new Error('No valid Google API keys provided');
|
|
12
|
-
}
|
|
13
|
-
return new GeminiProvider(config.googleApiKey, config.model);
|
|
14
|
-
}
|
|
15
|
-
else if (config.provider === 'openrouter') {
|
|
16
|
-
if (!config.openrouterApiKey) {
|
|
17
|
-
throw new Error('OpenRouter API key not configured. Please set it using: /config set openrouterApiKey YOUR_API_KEY');
|
|
18
|
-
}
|
|
19
|
-
// OpenRouter provider will be implemented later for full version
|
|
20
|
-
throw new Error('OpenRouter provider not yet implemented in MVP. Use Google provider for now.');
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
throw new Error(`Unknown provider: ${config.provider}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=provider-factory.js.map
|
|
@@ -1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
|
-
import { Message, StreamChunk } from '../types.js';
|
|
2
|
-
export interface Tool {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
parameters: Record<string, any>;
|
|
6
|
-
}
|
|
7
|
-
export interface ChatOptions {
|
|
8
|
-
messages: Message[];
|
|
9
|
-
tools?: Tool[] | any[];
|
|
10
|
-
temperature?: number;
|
|
11
|
-
}
|
|
12
|
-
export declare abstract class AIProvider {
|
|
13
|
-
protected apiKey: string;
|
|
14
|
-
protected model: string;
|
|
15
|
-
constructor(apiKey: string, model: string);
|
|
16
|
-
/**
|
|
17
|
-
* Send a chat request and stream the response
|
|
18
|
-
*/
|
|
19
|
-
abstract stream(options: ChatOptions): AsyncGenerator<StreamChunk, void, unknown>;
|
|
20
|
-
/**
|
|
21
|
-
* List available models
|
|
22
|
-
*/
|
|
23
|
-
abstract listModels(): Promise<string[]>;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ai/providers/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,8BAAsB,UAAU;IAC9B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAKzC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC;IAEjF;;OAEG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CACzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/ai/providers/base.ts"],"names":[],"mappings":"AAcA,MAAM,OAAgB,UAAU;IACpB,MAAM,CAAS;IACf,KAAK,CAAS;IAExB,YAAY,MAAc,EAAE,KAAa;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CAWF"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { AIProvider, ChatOptions } from './base.js';
|
|
2
|
-
import { StreamChunk } from '../types.js';
|
|
3
|
-
export declare class GeminiProvider extends AIProvider {
|
|
4
|
-
private apiKeys;
|
|
5
|
-
private currentKeyIndex;
|
|
6
|
-
private genAI;
|
|
7
|
-
private generativeModel;
|
|
8
|
-
constructor(apiKey: string, model?: string);
|
|
9
|
-
/**
|
|
10
|
-
* Rotate to the next API key
|
|
11
|
-
*/
|
|
12
|
-
private rotateApiKey;
|
|
13
|
-
/**
|
|
14
|
-
* Convert our Message format to Gemini Content format
|
|
15
|
-
*/
|
|
16
|
-
private convertMessagesToContents;
|
|
17
|
-
/**
|
|
18
|
-
* Convert our Tool format to Gemini Function Declaration format
|
|
19
|
-
*/
|
|
20
|
-
private convertToolsToFunctions;
|
|
21
|
-
/**
|
|
22
|
-
* Get or create the generative model
|
|
23
|
-
*/
|
|
24
|
-
private getModel;
|
|
25
|
-
/**
|
|
26
|
-
* Stream chat response
|
|
27
|
-
*/
|
|
28
|
-
stream(options: ChatOptions): AsyncGenerator<StreamChunk, void, unknown>;
|
|
29
|
-
/**
|
|
30
|
-
* List available models
|
|
31
|
-
*/
|
|
32
|
-
listModels(): Promise<string[]>;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=gemini.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../src/ai/providers/gemini.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAQ,WAAW,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAW,WAAW,EAAY,MAAM,aAAa,CAAC;AAE7D,qBAAa,cAAe,SAAQ,UAAU;IAC5C,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,eAAe,CAAgC;gBAE3C,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAA+B;IAalE;;OAEG;IACH,OAAO,CAAC,YAAY;IAMpB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAkBjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAiB/B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAchB;;OAEG;IACI,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC;IAgE/E;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAYtC"}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { GoogleGenerativeAI, SchemaType } from '@google/generative-ai';
|
|
2
|
-
import { AIProvider } from './base.js';
|
|
3
|
-
export class GeminiProvider extends AIProvider {
|
|
4
|
-
apiKeys;
|
|
5
|
-
currentKeyIndex = 0;
|
|
6
|
-
genAI;
|
|
7
|
-
generativeModel = null;
|
|
8
|
-
constructor(apiKey, model = 'gemini-2.0-flash-exp') {
|
|
9
|
-
super(apiKey, model);
|
|
10
|
-
// Parse comma-separated keys
|
|
11
|
-
this.apiKeys = apiKey.split(',').map(key => key.trim()).filter(key => key.length > 0);
|
|
12
|
-
if (this.apiKeys.length === 0) {
|
|
13
|
-
throw new Error('No valid API keys provided');
|
|
14
|
-
}
|
|
15
|
-
// Initialize with first key
|
|
16
|
-
this.genAI = new GoogleGenerativeAI(this.apiKeys[0]);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Rotate to the next API key
|
|
20
|
-
*/
|
|
21
|
-
rotateApiKey() {
|
|
22
|
-
this.currentKeyIndex = (this.currentKeyIndex + 1) % this.apiKeys.length;
|
|
23
|
-
const currentKey = this.apiKeys[this.currentKeyIndex];
|
|
24
|
-
this.genAI = new GoogleGenerativeAI(currentKey);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Convert our Message format to Gemini Content format
|
|
28
|
-
*/
|
|
29
|
-
convertMessagesToContents(messages) {
|
|
30
|
-
const contents = [];
|
|
31
|
-
for (const message of messages) {
|
|
32
|
-
if (message.role === 'system') {
|
|
33
|
-
// System messages are handled separately in Gemini
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
contents.push({
|
|
37
|
-
role: message.role === 'assistant' ? 'model' : 'user',
|
|
38
|
-
parts: [{ text: message.content }],
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return contents;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Convert our Tool format to Gemini Function Declaration format
|
|
45
|
-
*/
|
|
46
|
-
convertToolsToFunctions(tools) {
|
|
47
|
-
return tools.map(tool => {
|
|
48
|
-
// Handle both formats: direct tool schema or wrapped in schema property
|
|
49
|
-
const schema = tool.schema || tool;
|
|
50
|
-
return {
|
|
51
|
-
name: schema.name,
|
|
52
|
-
description: schema.description,
|
|
53
|
-
parameters: {
|
|
54
|
-
type: SchemaType.OBJECT,
|
|
55
|
-
properties: schema.parameters?.properties || {},
|
|
56
|
-
required: schema.parameters?.required || [],
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get or create the generative model
|
|
63
|
-
*/
|
|
64
|
-
getModel(tools) {
|
|
65
|
-
const modelConfig = {
|
|
66
|
-
model: this.model,
|
|
67
|
-
};
|
|
68
|
-
if (tools && tools.length > 0) {
|
|
69
|
-
modelConfig.tools = [{
|
|
70
|
-
functionDeclarations: this.convertToolsToFunctions(tools),
|
|
71
|
-
}];
|
|
72
|
-
}
|
|
73
|
-
return this.genAI.getGenerativeModel(modelConfig);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Stream chat response
|
|
77
|
-
*/
|
|
78
|
-
async *stream(options) {
|
|
79
|
-
// Rotate API key before each request
|
|
80
|
-
this.rotateApiKey();
|
|
81
|
-
try {
|
|
82
|
-
const model = this.getModel(options.tools);
|
|
83
|
-
const contents = this.convertMessagesToContents(options.messages);
|
|
84
|
-
// Find system message for system instruction
|
|
85
|
-
const systemMessage = options.messages.find(m => m.role === 'system');
|
|
86
|
-
// Create chat with history
|
|
87
|
-
// Gemini uses a simplified system instruction - just pass the text
|
|
88
|
-
const chatConfig = {
|
|
89
|
-
history: contents.slice(0, -1), // All messages except the last one
|
|
90
|
-
};
|
|
91
|
-
if (systemMessage) {
|
|
92
|
-
chatConfig.systemInstruction = {
|
|
93
|
-
role: 'user',
|
|
94
|
-
parts: [{ text: systemMessage.content }],
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
const chat = model.startChat(chatConfig);
|
|
98
|
-
// Get the last user message
|
|
99
|
-
const lastMessage = contents[contents.length - 1];
|
|
100
|
-
const lastMessageText = lastMessage.parts[0].text || '';
|
|
101
|
-
// Stream the response
|
|
102
|
-
const result = await chat.sendMessageStream(lastMessageText);
|
|
103
|
-
for await (const chunk of result.stream) {
|
|
104
|
-
const chunkText = chunk.text();
|
|
105
|
-
const functionCalls = chunk.functionCalls();
|
|
106
|
-
if (chunkText) {
|
|
107
|
-
yield {
|
|
108
|
-
text: chunkText,
|
|
109
|
-
done: false,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
if (functionCalls && functionCalls.length > 0) {
|
|
113
|
-
const toolCalls = functionCalls.map((fc, index) => ({
|
|
114
|
-
id: `call_${Date.now()}_${index}`,
|
|
115
|
-
name: fc.name,
|
|
116
|
-
arguments: fc.args,
|
|
117
|
-
}));
|
|
118
|
-
yield {
|
|
119
|
-
toolCalls,
|
|
120
|
-
done: false,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
yield { done: true };
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
throw new Error(`Gemini API Error: ${error.message || error}`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* List available models
|
|
132
|
-
*/
|
|
133
|
-
async listModels() {
|
|
134
|
-
// Gemini doesn't provide a public API to list models easily
|
|
135
|
-
// Return commonly available models
|
|
136
|
-
return [
|
|
137
|
-
'gemini-2.5-flash',
|
|
138
|
-
'gemini-2.5-pro',
|
|
139
|
-
'gemini-2.0-flash-exp',
|
|
140
|
-
'gemini-2.0-flash-thinking-exp',
|
|
141
|
-
'gemini-1.5-pro',
|
|
142
|
-
'gemini-1.5-flash',
|
|
143
|
-
];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=gemini.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../src/ai/providers/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAkC,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACvG,OAAO,EAAE,UAAU,EAAqB,MAAM,WAAW,CAAC;AAG1D,MAAM,OAAO,cAAe,SAAQ,UAAU;IACpC,OAAO,CAAW;IAClB,eAAe,GAAW,CAAC,CAAC;IAC5B,KAAK,CAAqB;IAC1B,eAAe,GAA2B,IAAI,CAAC;IAEvD,YAAY,MAAc,EAAE,QAAgB,sBAAsB;QAChE,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,MAAM,SAAS,GAAe,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;wBAC9D,EAAE,EAAE,QAAQ,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK,EAAE;wBACjC,IAAI,EAAE,EAAE,CAAC,IAAI;wBACb,SAAS,EAAE,EAAE,CAAC,IAAI;qBACnB,CAAC,CAAC,CAAC;oBAEJ,MAAM;wBACJ,SAAS;wBACT,IAAI,EAAE,KAAK;qBACZ,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,4DAA4D;QAC5D,mCAAmC;QACnC,OAAO;YACL,kBAAkB;YAClB,gBAAgB;YAChB,sBAAsB;YACtB,+BAA+B;YAC/B,gBAAgB;YAChB,kBAAkB;SACnB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-duplication-logs.d.ts","sourceRoot":"","sources":["../../src/commands/view-duplication-logs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAgB,mBAAmB,CAAC,KAAK,GAAE,MAAW,GAAG,IAAI,CAQ5D"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Command to view duplication detection logs
|
|
3
|
-
*/
|
|
4
|
-
import { getLogFilePath, readLastLogLines } from '../ui/utils/duplication-logger.js';
|
|
5
|
-
export function viewDuplicationLogs(lines = 50) {
|
|
6
|
-
const logPath = getLogFilePath();
|
|
7
|
-
console.log(`\n📋 Duplication Detection Logs (last ${lines} lines)`);
|
|
8
|
-
console.log(`📁 Log file: ${logPath}\n`);
|
|
9
|
-
console.log('─'.repeat(80));
|
|
10
|
-
console.log(readLastLogLines(lines));
|
|
11
|
-
console.log('─'.repeat(80));
|
|
12
|
-
console.log(`\nTo view full log: cat "${logPath}"\n`);
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=view-duplication-logs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-duplication-logs.js","sourceRoot":"","sources":["../../src/commands/view-duplication-logs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErF,MAAM,UAAU,mBAAmB,CAAC,QAAgB,EAAE;IACpD,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,OAAO,CAAC,GAAG,CAAC,yCAAyC,KAAK,SAAS,CAAC,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,IAAI,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,4BAA4B,OAAO,KAAK,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit tests for Command Detector
|
|
3
|
-
*
|
|
4
|
-
* These tests verify:
|
|
5
|
-
* - Pattern matching for SSH, WSL, Docker commands
|
|
6
|
-
* - Handler registration and lookup
|
|
7
|
-
* - Detection result accuracy
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Run all tests
|
|
11
|
-
*/
|
|
12
|
-
declare function runTests(): void;
|
|
13
|
-
export { runTests };
|
|
14
|
-
//# sourceMappingURL=command-detector.test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"command-detector.test.d.ts","sourceRoot":"","sources":["../../../src/context/__tests__/command-detector.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsVH;;GAEG;AACH,iBAAS,QAAQ,SAgBhB;AAOD,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit tests for Command Detector
|
|
3
|
-
*
|
|
4
|
-
* These tests verify:
|
|
5
|
-
* - Pattern matching for SSH, WSL, Docker commands
|
|
6
|
-
* - Handler registration and lookup
|
|
7
|
-
* - Detection result accuracy
|
|
8
|
-
*/
|
|
9
|
-
import { CommandDetector } from '../command-detector';
|
|
10
|
-
/**
|
|
11
|
-
* Mock SSH Handler for testing
|
|
12
|
-
*/
|
|
13
|
-
class MockSSHHandler {
|
|
14
|
-
type = 'ssh';
|
|
15
|
-
detectionPatterns = [
|
|
16
|
-
/^ssh\s+/,
|
|
17
|
-
/^ssh\s+-[^\s]+\s+/,
|
|
18
|
-
];
|
|
19
|
-
detect(command) {
|
|
20
|
-
return this.detectionPatterns.some(pattern => pattern.test(command));
|
|
21
|
-
}
|
|
22
|
-
async connect(command, cwd) {
|
|
23
|
-
return {
|
|
24
|
-
type: 'ssh',
|
|
25
|
-
handler: this,
|
|
26
|
-
metadata: {
|
|
27
|
-
hostname: 'example.com',
|
|
28
|
-
username: 'testuser',
|
|
29
|
-
workingDirectory: '/home/user',
|
|
30
|
-
shell: 'bash',
|
|
31
|
-
os: 'linux',
|
|
32
|
-
},
|
|
33
|
-
connectionState: 'connected',
|
|
34
|
-
sessionId: 'test-session',
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
async disconnect() { }
|
|
38
|
-
async executeCommand(command) {
|
|
39
|
-
return { stdout: '', stderr: '', exitCode: 0 };
|
|
40
|
-
}
|
|
41
|
-
async readFile(path) { return ''; }
|
|
42
|
-
async writeFile(path, content) { }
|
|
43
|
-
async listDirectory(path) { return []; }
|
|
44
|
-
async searchFiles(pattern, directory) { return []; }
|
|
45
|
-
async getCurrentWorkingDirectory() { return '/home/user'; }
|
|
46
|
-
async getShellType() { return 'bash'; }
|
|
47
|
-
async getOSType() { return 'linux'; }
|
|
48
|
-
getBreadcrumbs() { return []; }
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Mock WSL Handler for testing
|
|
52
|
-
*/
|
|
53
|
-
class MockWSLHandler {
|
|
54
|
-
type = 'wsl';
|
|
55
|
-
detectionPatterns = [
|
|
56
|
-
/^wsl$/,
|
|
57
|
-
/^wsl\s+/,
|
|
58
|
-
/^wsl\.exe\s+/,
|
|
59
|
-
];
|
|
60
|
-
detect(command) {
|
|
61
|
-
return this.detectionPatterns.some(pattern => pattern.test(command));
|
|
62
|
-
}
|
|
63
|
-
async connect(command, cwd) {
|
|
64
|
-
return {
|
|
65
|
-
type: 'wsl',
|
|
66
|
-
handler: this,
|
|
67
|
-
metadata: {
|
|
68
|
-
distroName: 'Ubuntu',
|
|
69
|
-
workingDirectory: '/home/user',
|
|
70
|
-
shell: 'bash',
|
|
71
|
-
os: 'linux',
|
|
72
|
-
},
|
|
73
|
-
connectionState: 'connected',
|
|
74
|
-
sessionId: 'test-session',
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
async disconnect() { }
|
|
78
|
-
async executeCommand(command) {
|
|
79
|
-
return { stdout: '', stderr: '', exitCode: 0 };
|
|
80
|
-
}
|
|
81
|
-
async readFile(path) { return ''; }
|
|
82
|
-
async writeFile(path, content) { }
|
|
83
|
-
async listDirectory(path) { return []; }
|
|
84
|
-
async searchFiles(pattern, directory) { return []; }
|
|
85
|
-
async getCurrentWorkingDirectory() { return '/home/user'; }
|
|
86
|
-
async getShellType() { return 'bash'; }
|
|
87
|
-
async getOSType() { return 'linux'; }
|
|
88
|
-
getBreadcrumbs() { return []; }
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Mock Docker Handler for testing
|
|
92
|
-
*/
|
|
93
|
-
class MockDockerHandler {
|
|
94
|
-
type = 'docker';
|
|
95
|
-
detectionPatterns = [
|
|
96
|
-
/^docker\s+exec\s+/,
|
|
97
|
-
/^docker\s+exec\s+-it\s+/,
|
|
98
|
-
];
|
|
99
|
-
detect(command) {
|
|
100
|
-
return this.detectionPatterns.some(pattern => pattern.test(command));
|
|
101
|
-
}
|
|
102
|
-
async connect(command, cwd) {
|
|
103
|
-
return {
|
|
104
|
-
type: 'docker',
|
|
105
|
-
handler: this,
|
|
106
|
-
metadata: {
|
|
107
|
-
containerId: 'abc123',
|
|
108
|
-
workingDirectory: '/app',
|
|
109
|
-
shell: 'bash',
|
|
110
|
-
os: 'linux',
|
|
111
|
-
},
|
|
112
|
-
connectionState: 'connected',
|
|
113
|
-
sessionId: 'test-session',
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
async disconnect() { }
|
|
117
|
-
async executeCommand(command) {
|
|
118
|
-
return { stdout: '', stderr: '', exitCode: 0 };
|
|
119
|
-
}
|
|
120
|
-
async readFile(path) { return ''; }
|
|
121
|
-
async writeFile(path, content) { }
|
|
122
|
-
async listDirectory(path) { return []; }
|
|
123
|
-
async searchFiles(pattern, directory) { return []; }
|
|
124
|
-
async getCurrentWorkingDirectory() { return '/app'; }
|
|
125
|
-
async getShellType() { return 'bash'; }
|
|
126
|
-
async getOSType() { return 'linux'; }
|
|
127
|
-
getBreadcrumbs() { return []; }
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Test: SSH command detection
|
|
131
|
-
*/
|
|
132
|
-
function testSSHDetection() {
|
|
133
|
-
console.log('Test: SSH command detection');
|
|
134
|
-
const detector = new CommandDetector();
|
|
135
|
-
const handler = new MockSSHHandler();
|
|
136
|
-
detector.registerHandler(handler);
|
|
137
|
-
// Test basic SSH command
|
|
138
|
-
let result = detector.detect('ssh user@host');
|
|
139
|
-
if (!result || result.handler.type !== 'ssh') {
|
|
140
|
-
throw new Error('Expected to detect SSH command');
|
|
141
|
-
}
|
|
142
|
-
// Test SSH with options
|
|
143
|
-
result = detector.detect('ssh -i key.pem user@host');
|
|
144
|
-
if (!result || result.handler.type !== 'ssh') {
|
|
145
|
-
throw new Error('Expected to detect SSH command with options');
|
|
146
|
-
}
|
|
147
|
-
// Test non-SSH command
|
|
148
|
-
result = detector.detect('ls -la');
|
|
149
|
-
if (result !== null) {
|
|
150
|
-
throw new Error('Expected not to detect non-SSH command');
|
|
151
|
-
}
|
|
152
|
-
console.log('✓ SSH command detection works correctly');
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Test: WSL command detection
|
|
156
|
-
*/
|
|
157
|
-
function testWSLDetection() {
|
|
158
|
-
console.log('\nTest: WSL command detection');
|
|
159
|
-
const detector = new CommandDetector();
|
|
160
|
-
const handler = new MockWSLHandler();
|
|
161
|
-
detector.registerHandler(handler);
|
|
162
|
-
// Test basic WSL command
|
|
163
|
-
let result = detector.detect('wsl');
|
|
164
|
-
if (!result || result.handler.type !== 'wsl') {
|
|
165
|
-
throw new Error('Expected to detect WSL command');
|
|
166
|
-
}
|
|
167
|
-
// Test WSL with distribution
|
|
168
|
-
result = detector.detect('wsl -d Ubuntu');
|
|
169
|
-
if (!result || result.handler.type !== 'wsl') {
|
|
170
|
-
throw new Error('Expected to detect WSL command with distribution');
|
|
171
|
-
}
|
|
172
|
-
// Test wsl.exe
|
|
173
|
-
result = detector.detect('wsl.exe --cd /home/user');
|
|
174
|
-
if (!result || result.handler.type !== 'wsl') {
|
|
175
|
-
throw new Error('Expected to detect wsl.exe command');
|
|
176
|
-
}
|
|
177
|
-
console.log('✓ WSL command detection works correctly');
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Test: Docker command detection
|
|
181
|
-
*/
|
|
182
|
-
function testDockerDetection() {
|
|
183
|
-
console.log('\nTest: Docker command detection');
|
|
184
|
-
const detector = new CommandDetector();
|
|
185
|
-
const handler = new MockDockerHandler();
|
|
186
|
-
detector.registerHandler(handler);
|
|
187
|
-
// Test docker exec
|
|
188
|
-
let result = detector.detect('docker exec container_name bash');
|
|
189
|
-
if (!result || result.handler.type !== 'docker') {
|
|
190
|
-
throw new Error('Expected to detect docker exec command');
|
|
191
|
-
}
|
|
192
|
-
// Test docker exec with -it
|
|
193
|
-
result = detector.detect('docker exec -it container_name bash');
|
|
194
|
-
if (!result || result.handler.type !== 'docker') {
|
|
195
|
-
throw new Error('Expected to detect docker exec -it command');
|
|
196
|
-
}
|
|
197
|
-
// Test non-docker exec command
|
|
198
|
-
result = detector.detect('docker ps');
|
|
199
|
-
if (result !== null) {
|
|
200
|
-
throw new Error('Expected not to detect docker ps command');
|
|
201
|
-
}
|
|
202
|
-
console.log('✓ Docker command detection works correctly');
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Test: Multiple handlers
|
|
206
|
-
*/
|
|
207
|
-
function testMultipleHandlers() {
|
|
208
|
-
console.log('\nTest: Multiple handlers');
|
|
209
|
-
const detector = new CommandDetector();
|
|
210
|
-
detector.registerHandler(new MockSSHHandler());
|
|
211
|
-
detector.registerHandler(new MockWSLHandler());
|
|
212
|
-
detector.registerHandler(new MockDockerHandler());
|
|
213
|
-
// Test SSH detection
|
|
214
|
-
let result = detector.detect('ssh user@host');
|
|
215
|
-
if (!result || result.handler.type !== 'ssh') {
|
|
216
|
-
throw new Error('Expected to detect SSH with multiple handlers');
|
|
217
|
-
}
|
|
218
|
-
// Test WSL detection
|
|
219
|
-
result = detector.detect('wsl');
|
|
220
|
-
if (!result || result.handler.type !== 'wsl') {
|
|
221
|
-
throw new Error('Expected to detect WSL with multiple handlers');
|
|
222
|
-
}
|
|
223
|
-
// Test Docker detection
|
|
224
|
-
result = detector.detect('docker exec -it container bash');
|
|
225
|
-
if (!result || result.handler.type !== 'docker') {
|
|
226
|
-
throw new Error('Expected to detect Docker with multiple handlers');
|
|
227
|
-
}
|
|
228
|
-
console.log('✓ Multiple handlers work correctly');
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Test: Handler management
|
|
232
|
-
*/
|
|
233
|
-
function testHandlerManagement() {
|
|
234
|
-
console.log('\nTest: Handler management');
|
|
235
|
-
const detector = new CommandDetector();
|
|
236
|
-
const sshHandler = new MockSSHHandler();
|
|
237
|
-
const wslHandler = new MockWSLHandler();
|
|
238
|
-
// Register handlers
|
|
239
|
-
detector.registerHandler(sshHandler);
|
|
240
|
-
detector.registerHandler(wslHandler);
|
|
241
|
-
// Check handlers
|
|
242
|
-
const handlers = detector.getHandlers();
|
|
243
|
-
if (handlers.length !== 2) {
|
|
244
|
-
throw new Error('Expected 2 registered handlers');
|
|
245
|
-
}
|
|
246
|
-
// Check hasHandler
|
|
247
|
-
if (!detector.hasHandler('ssh')) {
|
|
248
|
-
throw new Error('Expected to have SSH handler');
|
|
249
|
-
}
|
|
250
|
-
// Get handler by type
|
|
251
|
-
const retrieved = detector.getHandlerByType('ssh');
|
|
252
|
-
if (retrieved !== sshHandler) {
|
|
253
|
-
throw new Error('Expected to retrieve SSH handler');
|
|
254
|
-
}
|
|
255
|
-
// Remove handler
|
|
256
|
-
const removed = detector.removeHandler('ssh');
|
|
257
|
-
if (!removed) {
|
|
258
|
-
throw new Error('Expected to remove SSH handler');
|
|
259
|
-
}
|
|
260
|
-
if (detector.hasHandler('ssh')) {
|
|
261
|
-
throw new Error('Expected SSH handler to be removed');
|
|
262
|
-
}
|
|
263
|
-
// Clear handlers
|
|
264
|
-
detector.clearHandlers();
|
|
265
|
-
if (detector.getHandlers().length !== 0) {
|
|
266
|
-
throw new Error('Expected all handlers to be cleared');
|
|
267
|
-
}
|
|
268
|
-
console.log('✓ Handler management works correctly');
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Test: Empty and whitespace commands
|
|
272
|
-
*/
|
|
273
|
-
function testEdgeCases() {
|
|
274
|
-
console.log('\nTest: Edge cases');
|
|
275
|
-
const detector = new CommandDetector();
|
|
276
|
-
detector.registerHandler(new MockSSHHandler());
|
|
277
|
-
// Test empty command
|
|
278
|
-
let result = detector.detect('');
|
|
279
|
-
if (result !== null) {
|
|
280
|
-
throw new Error('Expected null for empty command');
|
|
281
|
-
}
|
|
282
|
-
// Test whitespace command
|
|
283
|
-
result = detector.detect(' ');
|
|
284
|
-
if (result !== null) {
|
|
285
|
-
throw new Error('Expected null for whitespace command');
|
|
286
|
-
}
|
|
287
|
-
// Test command with leading/trailing whitespace
|
|
288
|
-
result = detector.detect(' ssh user@host ');
|
|
289
|
-
if (!result || result.handler.type !== 'ssh') {
|
|
290
|
-
throw new Error('Expected to detect SSH command with whitespace');
|
|
291
|
-
}
|
|
292
|
-
console.log('✓ Edge cases handled correctly');
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Run all tests
|
|
296
|
-
*/
|
|
297
|
-
function runTests() {
|
|
298
|
-
console.log('=== Command Detector Tests ===\n');
|
|
299
|
-
try {
|
|
300
|
-
testSSHDetection();
|
|
301
|
-
testWSLDetection();
|
|
302
|
-
testDockerDetection();
|
|
303
|
-
testMultipleHandlers();
|
|
304
|
-
testHandlerManagement();
|
|
305
|
-
testEdgeCases();
|
|
306
|
-
console.log('\n=== All tests passed! ===');
|
|
307
|
-
}
|
|
308
|
-
catch (error) {
|
|
309
|
-
console.error('\n❌ Test failed:', error);
|
|
310
|
-
process.exit(1);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
// Run tests if this file is executed directly
|
|
314
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
315
|
-
runTests();
|
|
316
|
-
}
|
|
317
|
-
export { runTests };
|
|
318
|
-
//# sourceMappingURL=command-detector.test.js.map
|