@google/gemini-cli-core 0.0.3-preview.4 → 0.0.4
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/LICENSE +2 -2
- package/README.md +12 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/src/code_assist/codeAssist.d.ts +2 -0
- package/dist/src/code_assist/codeAssist.js +12 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/converter.d.ts +3 -1
- package/dist/src/code_assist/converter.js +2 -1
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +10 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/oauth-credential-storage.d.ts +25 -0
- package/dist/src/code_assist/oauth-credential-storage.js +109 -0
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js +136 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.js +92 -29
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +729 -339
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +1 -1
- package/dist/src/code_assist/server.js +24 -1
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +25 -0
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +17 -2
- package/dist/src/config/config.d.ts +72 -12
- package/dist/src/config/config.js +196 -64
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +305 -178
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/models.d.ts +16 -0
- package/dist/src/config/models.js +29 -0
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.d.ts +6 -0
- package/dist/src/config/models.test.js +55 -0
- package/dist/src/config/models.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +2 -0
- package/dist/src/config/storage.js +6 -1
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +4 -0
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/confirmation-bus/index.d.ts +7 -0
- package/dist/src/confirmation-bus/index.js +8 -0
- package/dist/src/confirmation-bus/index.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.d.ts +17 -0
- package/dist/src/confirmation-bus/message-bus.js +81 -0
- package/dist/src/confirmation-bus/message-bus.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.test.d.ts +6 -0
- package/dist/src/confirmation-bus/message-bus.test.js +164 -0
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +38 -0
- package/dist/src/confirmation-bus/types.js +15 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +46 -0
- package/dist/src/core/baseLlmClient.js +112 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/baseLlmClient.test.d.ts +6 -0
- package/dist/src/core/baseLlmClient.test.js +253 -0
- package/dist/src/core/baseLlmClient.test.js.map +1 -0
- package/dist/src/core/client.d.ts +16 -21
- package/dist/src/core/client.js +145 -232
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +393 -492
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +2 -3
- package/dist/src/core/contentGenerator.js +0 -4
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +1 -3
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +8 -3
- package/dist/src/core/coreToolScheduler.js +106 -5
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +233 -5
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +38 -32
- package/dist/src/core/geminiChat.js +209 -219
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +674 -386
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.js +13 -16
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +59 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.d.ts +5 -0
- package/dist/src/core/prompts.js +63 -42
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +130 -1
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/subagent.js +7 -10
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +32 -22
- package/dist/src/core/subagent.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +21 -5
- package/dist/src/core/turn.js +45 -11
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +340 -100
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.d.ts +7 -0
- package/dist/src/fallback/handler.js +51 -0
- package/dist/src/fallback/handler.js.map +1 -0
- package/dist/src/fallback/handler.test.d.ts +6 -0
- package/dist/src/fallback/handler.test.js +130 -0
- package/dist/src/fallback/handler.test.js.map +1 -0
- package/dist/src/fallback/types.d.ts +14 -0
- package/dist/src/fallback/types.js +7 -0
- package/dist/src/fallback/types.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/ide/constants.d.ts +3 -0
- package/dist/src/ide/constants.js +3 -0
- package/dist/src/ide/constants.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +42 -14
- package/dist/src/ide/detect-ide.js +22 -68
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +11 -51
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +60 -18
- package/dist/src/ide/ide-client.js +275 -53
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +239 -6
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.d.ts +2 -2
- package/dist/src/ide/ide-installer.js +15 -11
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +30 -12
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/ideContext.d.ts +35 -365
- package/dist/src/ide/ideContext.js +60 -106
- package/dist/src/ide/ideContext.js.map +1 -1
- package/dist/src/ide/ideContext.test.js +152 -24
- package/dist/src/ide/ideContext.test.js.map +1 -1
- package/dist/src/ide/process-utils.d.ts +0 -1
- package/dist/src/ide/process-utils.js +43 -25
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.js +90 -4
- package/dist/src/ide/process-utils.test.js.map +1 -1
- package/dist/src/ide/types.d.ts +486 -0
- package/dist/src/ide/types.js +138 -0
- package/dist/src/ide/types.js.map +1 -0
- package/dist/src/index.d.ts +10 -2
- package/dist/src/index.js +11 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +15 -12
- package/dist/src/mcp/oauth-provider.js +63 -56
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +74 -35
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.d.ts +14 -10
- package/dist/src/mcp/oauth-token-storage.js +52 -20
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +255 -162
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +1 -1
- package/dist/src/mcp/token-storage/base-token-storage.js +1 -1
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/base-token-storage.test.js +1 -1
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +144 -0
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js +235 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/index.d.ts +11 -0
- package/dist/src/mcp/token-storage/index.js +12 -0
- package/dist/src/mcp/token-storage/index.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +31 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +190 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +254 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +4 -0
- package/dist/src/mcp/token-storage/types.js +5 -1
- package/dist/src/mcp/token-storage/types.js.map +1 -1
- package/dist/src/output/json-formatter.d.ts +11 -0
- package/dist/src/output/json-formatter.js +30 -0
- package/dist/src/output/json-formatter.js.map +1 -0
- package/dist/src/output/json-formatter.test.d.ts +6 -0
- package/dist/src/output/json-formatter.test.js +266 -0
- package/dist/src/output/json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +20 -0
- package/dist/src/output/types.js +11 -0
- package/dist/src/output/types.js.map +1 -0
- package/dist/src/policy/index.d.ts +7 -0
- package/dist/src/policy/index.js +8 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/policy-engine.d.ts +30 -0
- package/dist/src/policy/policy-engine.js +92 -0
- package/dist/src/policy/policy-engine.js.map +1 -0
- package/dist/src/policy/policy-engine.test.d.ts +6 -0
- package/dist/src/policy/policy-engine.test.js +515 -0
- package/dist/src/policy/policy-engine.test.js.map +1 -0
- package/dist/src/policy/stable-stringify.d.ts +58 -0
- package/dist/src/policy/stable-stringify.js +122 -0
- package/dist/src/policy/stable-stringify.js.map +1 -0
- package/dist/src/policy/types.d.ts +47 -0
- package/dist/src/policy/types.js +12 -0
- package/dist/src/policy/types.js.map +1 -0
- package/dist/src/routing/modelRouterService.d.ts +23 -0
- package/dist/src/routing/modelRouterService.js +70 -0
- package/dist/src/routing/modelRouterService.js.map +1 -0
- package/dist/src/routing/modelRouterService.test.d.ts +6 -0
- package/dist/src/routing/modelRouterService.test.js +98 -0
- package/dist/src/routing/modelRouterService.test.js.map +1 -0
- package/dist/src/routing/routingStrategy.d.ts +62 -0
- package/dist/src/routing/routingStrategy.js +7 -0
- package/dist/src/routing/routingStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/classifierStrategy.js +173 -0
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js +192 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.d.ts +26 -0
- package/dist/src/routing/strategies/compositeStrategy.js +67 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js +123 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/defaultStrategy.js +20 -0
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js +26 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/fallbackStrategy.js +25 -0
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js +55 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +15 -0
- package/dist/src/routing/strategies/overrideStrategy.js +28 -0
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js +42 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +7 -13
- package/dist/src/services/chatRecordingService.js +28 -19
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +62 -20
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +10 -0
- package/dist/src/services/fileDiscoveryService.js +31 -17
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/gitService.js +9 -12
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +10 -20
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +5 -0
- package/dist/src/services/loopDetectionService.js +36 -20
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +41 -12
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +34 -2
- package/dist/src/services/shellExecutionService.js +192 -43
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +184 -55
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/activity-detector.d.ts +41 -0
- package/dist/src/telemetry/activity-detector.js +61 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.d.ts +6 -0
- package/dist/src/telemetry/activity-detector.test.js +136 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -0
- package/dist/src/telemetry/activity-types.d.ts +19 -0
- package/dist/src/telemetry/activity-types.js +21 -0
- package/dist/src/telemetry/activity-types.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +16 -2
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +143 -24
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +101 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +19 -2
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +48 -2
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +8 -0
- package/dist/src/telemetry/constants.js +8 -0
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.d.ts +34 -0
- package/dist/src/telemetry/gcp-exporters.js +117 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.test.d.ts +6 -0
- package/dist/src/telemetry/gcp-exporters.test.js +318 -0
- package/dist/src/telemetry/gcp-exporters.test.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.d.ts +43 -0
- package/dist/src/telemetry/high-water-mark-tracker.js +88 -0
- package/dist/src/telemetry/high-water-mark-tracker.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.d.ts +6 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js +152 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +7 -2
- package/dist/src/telemetry/index.js +7 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +8 -1
- package/dist/src/telemetry/loggers.js +140 -8
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +268 -39
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +4 -3
- package/dist/src/telemetry/metrics.js +33 -10
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +47 -25
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/rate-limiter.d.ts +48 -0
- package/dist/src/telemetry/rate-limiter.js +100 -0
- package/dist/src/telemetry/rate-limiter.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.test.d.ts +6 -0
- package/dist/src/telemetry/rate-limiter.test.js +207 -0
- package/dist/src/telemetry/rate-limiter.test.js.map +1 -0
- package/dist/src/telemetry/sdk.js +16 -1
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +95 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +70 -6
- package/dist/src/telemetry/types.js +112 -8
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +1 -1
- package/dist/src/telemetry/uiTelemetry.js +6 -7
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +15 -15
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/index.d.ts +6 -0
- package/dist/src/test-utils/index.js +7 -0
- package/dist/src/test-utils/index.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +41 -0
- package/dist/src/test-utils/mock-tool.js +51 -0
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/tools/diffOptions.js +21 -13
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/diffOptions.test.js +58 -22
- package/dist/src/tools/diffOptions.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +2 -2
- package/dist/src/tools/edit.js +35 -44
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +124 -13
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +5 -1
- package/dist/src/tools/glob.js +24 -17
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +51 -0
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/ls.js +19 -32
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +140 -280
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +5 -3
- package/dist/src/tools/mcp-client-manager.js +13 -4
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +20 -1
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +5 -5
- package/dist/src/tools/mcp-client.js +40 -35
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +3 -3
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +3 -2
- package/dist/src/tools/mcp-tool.js +9 -9
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +28 -7
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.js +5 -33
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/read-file.js +8 -3
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +29 -0
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +1 -1
- package/dist/src/tools/read-many-files.js +18 -50
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +4 -4
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +8 -0
- package/dist/src/tools/ripGrep.js +26 -1
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +107 -5
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +12 -2
- package/dist/src/tools/shell.js +20 -24
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +35 -70
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +72 -0
- package/dist/src/tools/smart-edit.js +594 -0
- package/dist/src/tools/smart-edit.js.map +1 -0
- package/dist/src/tools/smart-edit.test.d.ts +6 -0
- package/dist/src/tools/smart-edit.test.js +419 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +2 -1
- package/dist/src/tools/tool-registry.js +6 -5
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tools.d.ts +14 -7
- package/dist/src/tools/tools.js +9 -2
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.js +4 -3
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +1 -1
- package/dist/src/tools/web-search.js +3 -1
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/write-file.js +14 -19
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +99 -19
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.js +11 -5
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/editCorrector.d.ts +7 -6
- package/dist/src/utils/editCorrector.js +61 -18
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +30 -79
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.js +31 -44
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +61 -75
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/errorParsing.js +2 -2
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/errorParsing.test.js +7 -7
- package/dist/src/utils/errorParsing.test.js.map +1 -1
- package/dist/src/utils/errors.d.ts +6 -0
- package/dist/src/utils/errors.js +10 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +20 -3
- package/dist/src/utils/fileUtils.js +154 -32
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +347 -29
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.d.ts +6 -0
- package/dist/src/utils/{flashFallback.integration.test.js → flashFallback.test.js} +31 -27
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.d.ts +18 -0
- package/dist/src/utils/geminiIgnoreParser.js +61 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/geminiIgnoreParser.test.js +50 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.d.ts +3 -7
- package/dist/src/utils/gitIgnoreParser.js +125 -34
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +66 -35
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.d.ts +26 -0
- package/dist/src/utils/llm-edit-fixer.js +121 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.test.d.ts +6 -0
- package/dist/src/utils/llm-edit-fixer.test.js +105 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +5 -4
- package/dist/src/utils/memoryDiscovery.js +10 -9
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +50 -25
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.d.ts +2 -2
- package/dist/src/utils/nextSpeakerChecker.js +8 -2
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +75 -64
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/promptIdContext.d.ts +7 -0
- package/dist/src/utils/promptIdContext.js +8 -0
- package/dist/src/utils/promptIdContext.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +5 -0
- package/dist/src/utils/shell-utils.js +23 -0
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/terminalSerializer.d.ts +28 -0
- package/dist/src/utils/terminalSerializer.js +432 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -0
- package/dist/src/utils/terminalSerializer.test.d.ts +6 -0
- package/dist/src/utils/terminalSerializer.test.js +176 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +5 -0
- package/dist/src/utils/textUtils.js +14 -0
- package/dist/src/utils/textUtils.js.map +1 -1
- package/dist/src/utils/textUtils.test.d.ts +6 -0
- package/dist/src/utils/textUtils.test.js +59 -0
- package/dist/src/utils/textUtils.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -3
- package/dist/google-gemini-cli-core-0.3.0-preview.3.tgz +0 -0
- package/dist/src/utils/flashFallback.integration.test.js.map +0 -1
- /package/dist/src/{utils/flashFallback.integration.test.d.ts → code_assist/oauth-credential-storage.test.d.ts} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
6
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
7
7
|
import { Config, ApprovalMode } from './config.js';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
9
|
import { setGeminiMdFilename as mockSetGeminiMdFilename } from '../tools/memoryTool.js';
|
|
@@ -14,6 +14,11 @@ import { GitService } from '../services/gitService.js';
|
|
|
14
14
|
import { ClearcutLogger } from '../telemetry/clearcut-logger/clearcut-logger.js';
|
|
15
15
|
import { ShellTool } from '../tools/shell.js';
|
|
16
16
|
import { ReadFileTool } from '../tools/read-file.js';
|
|
17
|
+
import { GrepTool } from '../tools/grep.js';
|
|
18
|
+
import { RipGrepTool, canUseRipgrep } from '../tools/ripGrep.js';
|
|
19
|
+
import { logRipgrepFallback } from '../telemetry/loggers.js';
|
|
20
|
+
import { RipgrepFallbackEvent } from '../telemetry/types.js';
|
|
21
|
+
import { ToolRegistry } from '../tools/tool-registry.js';
|
|
17
22
|
vi.mock('fs', async (importOriginal) => {
|
|
18
23
|
const actual = await importOriginal();
|
|
19
24
|
return {
|
|
@@ -41,7 +46,12 @@ vi.mock('../utils/memoryDiscovery.js', () => ({
|
|
|
41
46
|
// Mock individual tools if their constructors are complex or have side effects
|
|
42
47
|
vi.mock('../tools/ls');
|
|
43
48
|
vi.mock('../tools/read-file');
|
|
44
|
-
vi.mock('../tools/grep');
|
|
49
|
+
vi.mock('../tools/grep.js');
|
|
50
|
+
vi.mock('../tools/ripGrep.js', () => ({
|
|
51
|
+
canUseRipgrep: vi.fn(),
|
|
52
|
+
RipGrepTool: class MockRipGrepTool {
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
45
55
|
vi.mock('../tools/glob');
|
|
46
56
|
vi.mock('../tools/edit');
|
|
47
57
|
vi.mock('../tools/shell');
|
|
@@ -55,16 +65,11 @@ vi.mock('../tools/memoryTool', () => ({
|
|
|
55
65
|
DEFAULT_CONTEXT_FILENAME: 'GEMINI.md',
|
|
56
66
|
GEMINI_CONFIG_DIR: '.gemini',
|
|
57
67
|
}));
|
|
58
|
-
vi.mock('../core/contentGenerator.js'
|
|
59
|
-
const actual = await importOriginal();
|
|
60
|
-
return {
|
|
61
|
-
...actual,
|
|
62
|
-
createContentGeneratorConfig: vi.fn(),
|
|
63
|
-
};
|
|
64
|
-
});
|
|
68
|
+
vi.mock('../core/contentGenerator.js');
|
|
65
69
|
vi.mock('../core/client.js', () => ({
|
|
66
70
|
GeminiClient: vi.fn().mockImplementation(() => ({
|
|
67
71
|
initialize: vi.fn().mockResolvedValue(undefined),
|
|
72
|
+
stripThoughtsFromHistory: vi.fn(),
|
|
68
73
|
})),
|
|
69
74
|
}));
|
|
70
75
|
vi.mock('../telemetry/index.js', async (importOriginal) => {
|
|
@@ -72,6 +77,16 @@ vi.mock('../telemetry/index.js', async (importOriginal) => {
|
|
|
72
77
|
return {
|
|
73
78
|
...actual,
|
|
74
79
|
initializeTelemetry: vi.fn(),
|
|
80
|
+
uiTelemetryService: {
|
|
81
|
+
getLastPromptTokenCount: vi.fn(),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
vi.mock('../telemetry/loggers.js', async (importOriginal) => {
|
|
86
|
+
const actual = await importOriginal();
|
|
87
|
+
return {
|
|
88
|
+
...actual,
|
|
89
|
+
logRipgrepFallback: vi.fn(),
|
|
75
90
|
};
|
|
76
91
|
});
|
|
77
92
|
vi.mock('../services/gitService.js', () => {
|
|
@@ -79,6 +94,22 @@ vi.mock('../services/gitService.js', () => {
|
|
|
79
94
|
GitServiceMock.prototype.initialize = vi.fn();
|
|
80
95
|
return { GitService: GitServiceMock };
|
|
81
96
|
});
|
|
97
|
+
vi.mock('../ide/ide-client.js', () => ({
|
|
98
|
+
IdeClient: {
|
|
99
|
+
getInstance: vi.fn().mockResolvedValue({
|
|
100
|
+
getConnectionStatus: vi.fn(),
|
|
101
|
+
initialize: vi.fn(),
|
|
102
|
+
shutdown: vi.fn(),
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
}));
|
|
106
|
+
import { BaseLlmClient } from '../core/baseLlmClient.js';
|
|
107
|
+
import { tokenLimit } from '../core/tokenLimits.js';
|
|
108
|
+
import { uiTelemetryService } from '../telemetry/index.js';
|
|
109
|
+
vi.mock('../core/baseLlmClient.js');
|
|
110
|
+
vi.mock('../core/tokenLimits.js', () => ({
|
|
111
|
+
tokenLimit: vi.fn(),
|
|
112
|
+
}));
|
|
82
113
|
describe('Server Config (config.ts)', () => {
|
|
83
114
|
const MODEL = 'gemini-pro';
|
|
84
115
|
const SANDBOX = {
|
|
@@ -144,144 +175,34 @@ describe('Server Config (config.ts)', () => {
|
|
|
144
175
|
it('should refresh auth and update config', async () => {
|
|
145
176
|
const config = new Config(baseParams);
|
|
146
177
|
const authType = AuthType.USE_GEMINI;
|
|
147
|
-
const newModel = 'gemini-flash';
|
|
148
178
|
const mockContentConfig = {
|
|
149
|
-
model: newModel,
|
|
150
179
|
apiKey: 'test-key',
|
|
151
180
|
};
|
|
152
|
-
createContentGeneratorConfig.mockReturnValue(mockContentConfig);
|
|
181
|
+
vi.mocked(createContentGeneratorConfig).mockReturnValue(mockContentConfig);
|
|
153
182
|
// Set fallback mode to true to ensure it gets reset
|
|
154
183
|
config.setFallbackMode(true);
|
|
155
184
|
expect(config.isInFallbackMode()).toBe(true);
|
|
156
185
|
await config.refreshAuth(authType);
|
|
157
186
|
expect(createContentGeneratorConfig).toHaveBeenCalledWith(config, authType);
|
|
158
|
-
// Verify that contentGeneratorConfig is updated
|
|
187
|
+
// Verify that contentGeneratorConfig is updated
|
|
159
188
|
expect(config.getContentGeneratorConfig()).toEqual(mockContentConfig);
|
|
160
|
-
expect(config.getContentGeneratorConfig().model).toBe(newModel);
|
|
161
|
-
expect(config.getModel()).toBe(newModel); // getModel() should return the updated model
|
|
162
189
|
expect(GeminiClient).toHaveBeenCalledWith(config);
|
|
163
190
|
// Verify that fallback mode is reset
|
|
164
191
|
expect(config.isInFallbackMode()).toBe(false);
|
|
165
192
|
});
|
|
166
|
-
it('should preserve conversation history when refreshing auth', async () => {
|
|
167
|
-
const config = new Config(baseParams);
|
|
168
|
-
const authType = AuthType.USE_GEMINI;
|
|
169
|
-
const mockContentConfig = {
|
|
170
|
-
model: 'gemini-pro',
|
|
171
|
-
apiKey: 'test-key',
|
|
172
|
-
};
|
|
173
|
-
createContentGeneratorConfig.mockReturnValue(mockContentConfig);
|
|
174
|
-
// Mock the existing client with some history
|
|
175
|
-
const mockExistingHistory = [
|
|
176
|
-
{ role: 'user', parts: [{ text: 'Hello' }] },
|
|
177
|
-
{ role: 'model', parts: [{ text: 'Hi there!' }] },
|
|
178
|
-
{ role: 'user', parts: [{ text: 'How are you?' }] },
|
|
179
|
-
];
|
|
180
|
-
const mockExistingClient = {
|
|
181
|
-
isInitialized: vi.fn().mockReturnValue(true),
|
|
182
|
-
getHistory: vi.fn().mockReturnValue(mockExistingHistory),
|
|
183
|
-
};
|
|
184
|
-
const mockNewClient = {
|
|
185
|
-
isInitialized: vi.fn().mockReturnValue(true),
|
|
186
|
-
getHistory: vi.fn().mockReturnValue([]),
|
|
187
|
-
setHistory: vi.fn(),
|
|
188
|
-
initialize: vi.fn().mockResolvedValue(undefined),
|
|
189
|
-
};
|
|
190
|
-
// Set the existing client
|
|
191
|
-
config.geminiClient = mockExistingClient;
|
|
192
|
-
GeminiClient.mockImplementation(() => mockNewClient);
|
|
193
|
-
await config.refreshAuth(authType);
|
|
194
|
-
// Verify that existing history was retrieved
|
|
195
|
-
expect(mockExistingClient.getHistory).toHaveBeenCalled();
|
|
196
|
-
// Verify that new client was created and initialized
|
|
197
|
-
expect(GeminiClient).toHaveBeenCalledWith(config);
|
|
198
|
-
expect(mockNewClient.initialize).toHaveBeenCalledWith(mockContentConfig);
|
|
199
|
-
// Verify that history was restored to the new client
|
|
200
|
-
expect(mockNewClient.setHistory).toHaveBeenCalledWith(mockExistingHistory, { stripThoughts: false });
|
|
201
|
-
});
|
|
202
|
-
it('should handle case when no existing client is initialized', async () => {
|
|
203
|
-
const config = new Config(baseParams);
|
|
204
|
-
const authType = AuthType.USE_GEMINI;
|
|
205
|
-
const mockContentConfig = {
|
|
206
|
-
model: 'gemini-pro',
|
|
207
|
-
apiKey: 'test-key',
|
|
208
|
-
};
|
|
209
|
-
createContentGeneratorConfig.mockReturnValue(mockContentConfig);
|
|
210
|
-
const mockNewClient = {
|
|
211
|
-
isInitialized: vi.fn().mockReturnValue(true),
|
|
212
|
-
getHistory: vi.fn().mockReturnValue([]),
|
|
213
|
-
setHistory: vi.fn(),
|
|
214
|
-
initialize: vi.fn().mockResolvedValue(undefined),
|
|
215
|
-
};
|
|
216
|
-
// No existing client
|
|
217
|
-
config.geminiClient = null;
|
|
218
|
-
GeminiClient.mockImplementation(() => mockNewClient);
|
|
219
|
-
await config.refreshAuth(authType);
|
|
220
|
-
// Verify that new client was created and initialized
|
|
221
|
-
expect(GeminiClient).toHaveBeenCalledWith(config);
|
|
222
|
-
expect(mockNewClient.initialize).toHaveBeenCalledWith(mockContentConfig);
|
|
223
|
-
// Verify that setHistory was not called since there was no existing history
|
|
224
|
-
expect(mockNewClient.setHistory).not.toHaveBeenCalled();
|
|
225
|
-
});
|
|
226
193
|
it('should strip thoughts when switching from GenAI to Vertex', async () => {
|
|
227
194
|
const config = new Config(baseParams);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
apiKey: 'test-key',
|
|
231
|
-
authType: AuthType.USE_GEMINI,
|
|
232
|
-
};
|
|
233
|
-
config.contentGeneratorConfig = mockContentConfig;
|
|
234
|
-
createContentGeneratorConfig.mockReturnValue({
|
|
235
|
-
...mockContentConfig,
|
|
236
|
-
authType: AuthType.LOGIN_WITH_GOOGLE,
|
|
237
|
-
});
|
|
238
|
-
const mockExistingHistory = [
|
|
239
|
-
{ role: 'user', parts: [{ text: 'Hello' }] },
|
|
240
|
-
];
|
|
241
|
-
const mockExistingClient = {
|
|
242
|
-
isInitialized: vi.fn().mockReturnValue(true),
|
|
243
|
-
getHistory: vi.fn().mockReturnValue(mockExistingHistory),
|
|
244
|
-
};
|
|
245
|
-
const mockNewClient = {
|
|
246
|
-
isInitialized: vi.fn().mockReturnValue(true),
|
|
247
|
-
getHistory: vi.fn().mockReturnValue([]),
|
|
248
|
-
setHistory: vi.fn(),
|
|
249
|
-
initialize: vi.fn().mockResolvedValue(undefined),
|
|
250
|
-
};
|
|
251
|
-
config.geminiClient = mockExistingClient;
|
|
252
|
-
GeminiClient.mockImplementation(() => mockNewClient);
|
|
195
|
+
vi.mocked(createContentGeneratorConfig).mockImplementation((_, authType) => ({ authType }));
|
|
196
|
+
await config.refreshAuth(AuthType.USE_GEMINI);
|
|
253
197
|
await config.refreshAuth(AuthType.LOGIN_WITH_GOOGLE);
|
|
254
|
-
expect(
|
|
198
|
+
expect(config.getGeminiClient().stripThoughtsFromHistory).toHaveBeenCalledWith();
|
|
255
199
|
});
|
|
256
200
|
it('should not strip thoughts when switching from Vertex to GenAI', async () => {
|
|
257
201
|
const config = new Config(baseParams);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
apiKey: 'test-key',
|
|
261
|
-
authType: AuthType.LOGIN_WITH_GOOGLE,
|
|
262
|
-
};
|
|
263
|
-
config.contentGeneratorConfig = mockContentConfig;
|
|
264
|
-
createContentGeneratorConfig.mockReturnValue({
|
|
265
|
-
...mockContentConfig,
|
|
266
|
-
authType: AuthType.USE_GEMINI,
|
|
267
|
-
});
|
|
268
|
-
const mockExistingHistory = [
|
|
269
|
-
{ role: 'user', parts: [{ text: 'Hello' }] },
|
|
270
|
-
];
|
|
271
|
-
const mockExistingClient = {
|
|
272
|
-
isInitialized: vi.fn().mockReturnValue(true),
|
|
273
|
-
getHistory: vi.fn().mockReturnValue(mockExistingHistory),
|
|
274
|
-
};
|
|
275
|
-
const mockNewClient = {
|
|
276
|
-
isInitialized: vi.fn().mockReturnValue(true),
|
|
277
|
-
getHistory: vi.fn().mockReturnValue([]),
|
|
278
|
-
setHistory: vi.fn(),
|
|
279
|
-
initialize: vi.fn().mockResolvedValue(undefined),
|
|
280
|
-
};
|
|
281
|
-
config.geminiClient = mockExistingClient;
|
|
282
|
-
GeminiClient.mockImplementation(() => mockNewClient);
|
|
202
|
+
vi.mocked(createContentGeneratorConfig).mockImplementation((_, authType) => ({ authType }));
|
|
203
|
+
await config.refreshAuth(AuthType.USE_VERTEX_AI);
|
|
283
204
|
await config.refreshAuth(AuthType.USE_GEMINI);
|
|
284
|
-
expect(
|
|
205
|
+
expect(config.getGeminiClient().stripThoughtsFromHistory).not.toHaveBeenCalledWith();
|
|
285
206
|
});
|
|
286
207
|
});
|
|
287
208
|
it('Config constructor should store userMemory correctly', () => {
|
|
@@ -360,6 +281,30 @@ describe('Server Config (config.ts)', () => {
|
|
|
360
281
|
const config = new Config(paramsWithoutTelemetry);
|
|
361
282
|
expect(config.getTelemetryEnabled()).toBe(TELEMETRY_SETTINGS.enabled);
|
|
362
283
|
});
|
|
284
|
+
it('Config constructor should set telemetry useCollector to true when provided', () => {
|
|
285
|
+
const paramsWithTelemetry = {
|
|
286
|
+
...baseParams,
|
|
287
|
+
telemetry: { enabled: true, useCollector: true },
|
|
288
|
+
};
|
|
289
|
+
const config = new Config(paramsWithTelemetry);
|
|
290
|
+
expect(config.getTelemetryUseCollector()).toBe(true);
|
|
291
|
+
});
|
|
292
|
+
it('Config constructor should set telemetry useCollector to false when provided', () => {
|
|
293
|
+
const paramsWithTelemetry = {
|
|
294
|
+
...baseParams,
|
|
295
|
+
telemetry: { enabled: true, useCollector: false },
|
|
296
|
+
};
|
|
297
|
+
const config = new Config(paramsWithTelemetry);
|
|
298
|
+
expect(config.getTelemetryUseCollector()).toBe(false);
|
|
299
|
+
});
|
|
300
|
+
it('Config constructor should default telemetry useCollector to false if not provided', () => {
|
|
301
|
+
const paramsWithTelemetry = {
|
|
302
|
+
...baseParams,
|
|
303
|
+
telemetry: { enabled: true },
|
|
304
|
+
};
|
|
305
|
+
const config = new Config(paramsWithTelemetry);
|
|
306
|
+
expect(config.getTelemetryUseCollector()).toBe(false);
|
|
307
|
+
});
|
|
363
308
|
it('should have a getFileService method that returns FileDiscoveryService', () => {
|
|
364
309
|
const config = new Config(baseParams);
|
|
365
310
|
const fileService = config.getFileService();
|
|
@@ -385,7 +330,7 @@ describe('Server Config (config.ts)', () => {
|
|
|
385
330
|
...baseParams,
|
|
386
331
|
usageStatisticsEnabled: true,
|
|
387
332
|
});
|
|
388
|
-
await config.
|
|
333
|
+
await config.refreshAuth(AuthType.USE_GEMINI);
|
|
389
334
|
expect(ClearcutLogger.prototype.logStartSessionEvent).toHaveBeenCalledOnce();
|
|
390
335
|
});
|
|
391
336
|
});
|
|
@@ -473,33 +418,55 @@ describe('Server Config (config.ts)', () => {
|
|
|
473
418
|
});
|
|
474
419
|
});
|
|
475
420
|
describe('UseRipgrep Configuration', () => {
|
|
476
|
-
it('should default useRipgrep to
|
|
421
|
+
it('should default useRipgrep to true when not provided', () => {
|
|
477
422
|
const config = new Config(baseParams);
|
|
478
|
-
expect(config.getUseRipgrep()).toBe(
|
|
423
|
+
expect(config.getUseRipgrep()).toBe(true);
|
|
479
424
|
});
|
|
480
|
-
it('should set useRipgrep to
|
|
425
|
+
it('should set useRipgrep to false when provided as false', () => {
|
|
481
426
|
const paramsWithRipgrep = {
|
|
482
427
|
...baseParams,
|
|
483
|
-
useRipgrep:
|
|
428
|
+
useRipgrep: false,
|
|
484
429
|
};
|
|
485
430
|
const config = new Config(paramsWithRipgrep);
|
|
486
|
-
expect(config.getUseRipgrep()).toBe(
|
|
431
|
+
expect(config.getUseRipgrep()).toBe(false);
|
|
487
432
|
});
|
|
488
|
-
it('should set useRipgrep to
|
|
433
|
+
it('should set useRipgrep to true when explicitly provided as true', () => {
|
|
489
434
|
const paramsWithRipgrep = {
|
|
490
435
|
...baseParams,
|
|
491
|
-
useRipgrep:
|
|
436
|
+
useRipgrep: true,
|
|
492
437
|
};
|
|
493
438
|
const config = new Config(paramsWithRipgrep);
|
|
494
|
-
expect(config.getUseRipgrep()).toBe(
|
|
439
|
+
expect(config.getUseRipgrep()).toBe(true);
|
|
495
440
|
});
|
|
496
|
-
it('should default useRipgrep to
|
|
441
|
+
it('should default useRipgrep to true when undefined', () => {
|
|
497
442
|
const paramsWithUndefinedRipgrep = {
|
|
498
443
|
...baseParams,
|
|
499
444
|
useRipgrep: undefined,
|
|
500
445
|
};
|
|
501
446
|
const config = new Config(paramsWithUndefinedRipgrep);
|
|
502
|
-
expect(config.getUseRipgrep()).toBe(
|
|
447
|
+
expect(config.getUseRipgrep()).toBe(true);
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
describe('UseModelRouter Configuration', () => {
|
|
451
|
+
it('should default useModelRouter to false when not provided', () => {
|
|
452
|
+
const config = new Config(baseParams);
|
|
453
|
+
expect(config.getUseModelRouter()).toBe(false);
|
|
454
|
+
});
|
|
455
|
+
it('should set useModelRouter to true when provided as true', () => {
|
|
456
|
+
const paramsWithModelRouter = {
|
|
457
|
+
...baseParams,
|
|
458
|
+
useModelRouter: true,
|
|
459
|
+
};
|
|
460
|
+
const config = new Config(paramsWithModelRouter);
|
|
461
|
+
expect(config.getUseModelRouter()).toBe(true);
|
|
462
|
+
});
|
|
463
|
+
it('should set useModelRouter to false when explicitly provided as false', () => {
|
|
464
|
+
const paramsWithModelRouter = {
|
|
465
|
+
...baseParams,
|
|
466
|
+
useModelRouter: false,
|
|
467
|
+
};
|
|
468
|
+
const config = new Config(paramsWithModelRouter);
|
|
469
|
+
expect(config.getUseModelRouter()).toBe(false);
|
|
503
470
|
});
|
|
504
471
|
});
|
|
505
472
|
describe('createToolRegistry', () => {
|
|
@@ -519,67 +486,227 @@ describe('Server Config (config.ts)', () => {
|
|
|
519
486
|
const wasReadFileToolRegistered = registerToolMock.mock.calls.some((call) => call[0] instanceof vi.mocked(ReadFileTool));
|
|
520
487
|
expect(wasReadFileToolRegistered).toBe(false);
|
|
521
488
|
});
|
|
489
|
+
describe('with minified tool class names', () => {
|
|
490
|
+
beforeEach(() => {
|
|
491
|
+
Object.defineProperty(vi.mocked(ShellTool).prototype.constructor, 'name', {
|
|
492
|
+
value: '_ShellTool',
|
|
493
|
+
configurable: true,
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
afterEach(() => {
|
|
497
|
+
Object.defineProperty(vi.mocked(ShellTool).prototype.constructor, 'name', {
|
|
498
|
+
value: 'ShellTool',
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
it('should register a tool if coreTools contains the non-minified class name', async () => {
|
|
502
|
+
const params = {
|
|
503
|
+
...baseParams,
|
|
504
|
+
coreTools: ['ShellTool'],
|
|
505
|
+
};
|
|
506
|
+
const config = new Config(params);
|
|
507
|
+
await config.initialize();
|
|
508
|
+
const registerToolMock = (await vi.importMock('../tools/tool-registry')).ToolRegistry.prototype.registerTool;
|
|
509
|
+
const wasShellToolRegistered = registerToolMock.mock.calls.some((call) => call[0] instanceof vi.mocked(ShellTool));
|
|
510
|
+
expect(wasShellToolRegistered).toBe(true);
|
|
511
|
+
});
|
|
512
|
+
it('should not register a tool if excludeTools contains the non-minified class name', async () => {
|
|
513
|
+
const params = {
|
|
514
|
+
...baseParams,
|
|
515
|
+
coreTools: undefined, // all tools enabled by default
|
|
516
|
+
excludeTools: ['ShellTool'],
|
|
517
|
+
};
|
|
518
|
+
const config = new Config(params);
|
|
519
|
+
await config.initialize();
|
|
520
|
+
const registerToolMock = (await vi.importMock('../tools/tool-registry')).ToolRegistry.prototype.registerTool;
|
|
521
|
+
const wasShellToolRegistered = registerToolMock.mock.calls.some((call) => call[0] instanceof vi.mocked(ShellTool));
|
|
522
|
+
expect(wasShellToolRegistered).toBe(false);
|
|
523
|
+
});
|
|
524
|
+
it('should register a tool if coreTools contains an argument-specific pattern with the non-minified class name', async () => {
|
|
525
|
+
const params = {
|
|
526
|
+
...baseParams,
|
|
527
|
+
coreTools: ['ShellTool(git status)'],
|
|
528
|
+
};
|
|
529
|
+
const config = new Config(params);
|
|
530
|
+
await config.initialize();
|
|
531
|
+
const registerToolMock = (await vi.importMock('../tools/tool-registry')).ToolRegistry.prototype.registerTool;
|
|
532
|
+
const wasShellToolRegistered = registerToolMock.mock.calls.some((call) => call[0] instanceof vi.mocked(ShellTool));
|
|
533
|
+
expect(wasShellToolRegistered).toBe(true);
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
describe('getTruncateToolOutputThreshold', () => {
|
|
538
|
+
beforeEach(() => {
|
|
539
|
+
vi.clearAllMocks();
|
|
540
|
+
});
|
|
541
|
+
it('should return the calculated threshold when it is smaller than the default', () => {
|
|
542
|
+
const config = new Config(baseParams);
|
|
543
|
+
vi.mocked(tokenLimit).mockReturnValue(32000);
|
|
544
|
+
vi.mocked(uiTelemetryService.getLastPromptTokenCount).mockReturnValue(1000);
|
|
545
|
+
// 4 * (32000 - 1000) = 4 * 31000 = 124000
|
|
546
|
+
// default is 4_000_000
|
|
547
|
+
expect(config.getTruncateToolOutputThreshold()).toBe(124000);
|
|
548
|
+
});
|
|
549
|
+
it('should return the default threshold when the calculated value is larger', () => {
|
|
550
|
+
const config = new Config(baseParams);
|
|
551
|
+
vi.mocked(tokenLimit).mockReturnValue(2_000_000);
|
|
552
|
+
vi.mocked(uiTelemetryService.getLastPromptTokenCount).mockReturnValue(500_000);
|
|
553
|
+
// 4 * (2_000_000 - 500_000) = 4 * 1_500_000 = 6_000_000
|
|
554
|
+
// default is 4_000_000
|
|
555
|
+
expect(config.getTruncateToolOutputThreshold()).toBe(4_000_000);
|
|
556
|
+
});
|
|
557
|
+
it('should use a custom truncateToolOutputThreshold if provided', () => {
|
|
558
|
+
const customParams = {
|
|
559
|
+
...baseParams,
|
|
560
|
+
truncateToolOutputThreshold: 50000,
|
|
561
|
+
};
|
|
562
|
+
const config = new Config(customParams);
|
|
563
|
+
vi.mocked(tokenLimit).mockReturnValue(8000);
|
|
564
|
+
vi.mocked(uiTelemetryService.getLastPromptTokenCount).mockReturnValue(2000);
|
|
565
|
+
// 4 * (8000 - 2000) = 4 * 6000 = 24000
|
|
566
|
+
// custom threshold is 50000
|
|
567
|
+
expect(config.getTruncateToolOutputThreshold()).toBe(24000);
|
|
568
|
+
vi.mocked(tokenLimit).mockReturnValue(32000);
|
|
569
|
+
vi.mocked(uiTelemetryService.getLastPromptTokenCount).mockReturnValue(1000);
|
|
570
|
+
// 4 * (32000 - 1000) = 124000
|
|
571
|
+
// custom threshold is 50000
|
|
572
|
+
expect(config.getTruncateToolOutputThreshold()).toBe(50000);
|
|
573
|
+
});
|
|
522
574
|
});
|
|
523
575
|
});
|
|
524
576
|
describe('setApprovalMode with folder trust', () => {
|
|
577
|
+
const baseParams = {
|
|
578
|
+
sessionId: 'test',
|
|
579
|
+
targetDir: '.',
|
|
580
|
+
debugMode: false,
|
|
581
|
+
model: 'test-model',
|
|
582
|
+
cwd: '.',
|
|
583
|
+
};
|
|
525
584
|
it('should throw an error when setting YOLO mode in an untrusted folder', () => {
|
|
526
|
-
const config = new Config(
|
|
527
|
-
|
|
528
|
-
targetDir: '.',
|
|
529
|
-
debugMode: false,
|
|
530
|
-
model: 'test-model',
|
|
531
|
-
cwd: '.',
|
|
532
|
-
trustedFolder: false, // Untrusted
|
|
533
|
-
});
|
|
585
|
+
const config = new Config(baseParams);
|
|
586
|
+
vi.spyOn(config, 'isTrustedFolder').mockReturnValue(false);
|
|
534
587
|
expect(() => config.setApprovalMode(ApprovalMode.YOLO)).toThrow('Cannot enable privileged approval modes in an untrusted folder.');
|
|
535
588
|
});
|
|
536
589
|
it('should throw an error when setting AUTO_EDIT mode in an untrusted folder', () => {
|
|
537
|
-
const config = new Config(
|
|
538
|
-
|
|
539
|
-
targetDir: '.',
|
|
540
|
-
debugMode: false,
|
|
541
|
-
model: 'test-model',
|
|
542
|
-
cwd: '.',
|
|
543
|
-
trustedFolder: false, // Untrusted
|
|
544
|
-
});
|
|
590
|
+
const config = new Config(baseParams);
|
|
591
|
+
vi.spyOn(config, 'isTrustedFolder').mockReturnValue(false);
|
|
545
592
|
expect(() => config.setApprovalMode(ApprovalMode.AUTO_EDIT)).toThrow('Cannot enable privileged approval modes in an untrusted folder.');
|
|
546
593
|
});
|
|
547
594
|
it('should NOT throw an error when setting DEFAULT mode in an untrusted folder', () => {
|
|
548
|
-
const config = new Config(
|
|
549
|
-
|
|
550
|
-
targetDir: '.',
|
|
551
|
-
debugMode: false,
|
|
552
|
-
model: 'test-model',
|
|
553
|
-
cwd: '.',
|
|
554
|
-
trustedFolder: false, // Untrusted
|
|
555
|
-
});
|
|
595
|
+
const config = new Config(baseParams);
|
|
596
|
+
vi.spyOn(config, 'isTrustedFolder').mockReturnValue(false);
|
|
556
597
|
expect(() => config.setApprovalMode(ApprovalMode.DEFAULT)).not.toThrow();
|
|
557
598
|
});
|
|
558
599
|
it('should NOT throw an error when setting any mode in a trusted folder', () => {
|
|
559
|
-
const config = new Config(
|
|
560
|
-
|
|
561
|
-
targetDir: '.',
|
|
562
|
-
debugMode: false,
|
|
563
|
-
model: 'test-model',
|
|
564
|
-
cwd: '.',
|
|
565
|
-
trustedFolder: true, // Trusted
|
|
566
|
-
});
|
|
600
|
+
const config = new Config(baseParams);
|
|
601
|
+
vi.spyOn(config, 'isTrustedFolder').mockReturnValue(true);
|
|
567
602
|
expect(() => config.setApprovalMode(ApprovalMode.YOLO)).not.toThrow();
|
|
568
603
|
expect(() => config.setApprovalMode(ApprovalMode.AUTO_EDIT)).not.toThrow();
|
|
569
604
|
expect(() => config.setApprovalMode(ApprovalMode.DEFAULT)).not.toThrow();
|
|
570
605
|
});
|
|
571
606
|
it('should NOT throw an error when setting any mode if trustedFolder is undefined', () => {
|
|
572
|
-
const config = new Config(
|
|
573
|
-
|
|
574
|
-
targetDir: '.',
|
|
575
|
-
debugMode: false,
|
|
576
|
-
model: 'test-model',
|
|
577
|
-
cwd: '.',
|
|
578
|
-
trustedFolder: undefined, // Undefined
|
|
579
|
-
});
|
|
607
|
+
const config = new Config(baseParams);
|
|
608
|
+
vi.spyOn(config, 'isTrustedFolder').mockReturnValue(true); // isTrustedFolder defaults to true
|
|
580
609
|
expect(() => config.setApprovalMode(ApprovalMode.YOLO)).not.toThrow();
|
|
581
610
|
expect(() => config.setApprovalMode(ApprovalMode.AUTO_EDIT)).not.toThrow();
|
|
582
611
|
expect(() => config.setApprovalMode(ApprovalMode.DEFAULT)).not.toThrow();
|
|
583
612
|
});
|
|
613
|
+
describe('registerCoreTools', () => {
|
|
614
|
+
beforeEach(() => {
|
|
615
|
+
vi.clearAllMocks();
|
|
616
|
+
});
|
|
617
|
+
it('should register RipGrepTool when useRipgrep is true and it is available', async () => {
|
|
618
|
+
canUseRipgrep.mockResolvedValue(true);
|
|
619
|
+
const config = new Config({ ...baseParams, useRipgrep: true });
|
|
620
|
+
await config.initialize();
|
|
621
|
+
const calls = ToolRegistry.prototype.registerTool.mock.calls;
|
|
622
|
+
const wasRipGrepRegistered = calls.some((call) => call[0] instanceof vi.mocked(RipGrepTool));
|
|
623
|
+
const wasGrepRegistered = calls.some((call) => call[0] instanceof vi.mocked(GrepTool));
|
|
624
|
+
expect(wasRipGrepRegistered).toBe(true);
|
|
625
|
+
expect(wasGrepRegistered).toBe(false);
|
|
626
|
+
expect(logRipgrepFallback).not.toHaveBeenCalled();
|
|
627
|
+
});
|
|
628
|
+
it('should register GrepTool as a fallback when useRipgrep is true but it is not available', async () => {
|
|
629
|
+
canUseRipgrep.mockResolvedValue(false);
|
|
630
|
+
const config = new Config({ ...baseParams, useRipgrep: true });
|
|
631
|
+
await config.initialize();
|
|
632
|
+
const calls = ToolRegistry.prototype.registerTool.mock.calls;
|
|
633
|
+
const wasRipGrepRegistered = calls.some((call) => call[0] instanceof vi.mocked(RipGrepTool));
|
|
634
|
+
const wasGrepRegistered = calls.some((call) => call[0] instanceof vi.mocked(GrepTool));
|
|
635
|
+
expect(wasRipGrepRegistered).toBe(false);
|
|
636
|
+
expect(wasGrepRegistered).toBe(true);
|
|
637
|
+
expect(logRipgrepFallback).toHaveBeenCalledWith(config, expect.any(RipgrepFallbackEvent));
|
|
638
|
+
const event = logRipgrepFallback.mock.calls[0][1];
|
|
639
|
+
expect(event.error).toBeUndefined();
|
|
640
|
+
});
|
|
641
|
+
it('should register GrepTool as a fallback when canUseRipgrep throws an error', async () => {
|
|
642
|
+
const error = new Error('ripGrep check failed');
|
|
643
|
+
canUseRipgrep.mockRejectedValue(error);
|
|
644
|
+
const config = new Config({ ...baseParams, useRipgrep: true });
|
|
645
|
+
await config.initialize();
|
|
646
|
+
const calls = ToolRegistry.prototype.registerTool.mock.calls;
|
|
647
|
+
const wasRipGrepRegistered = calls.some((call) => call[0] instanceof vi.mocked(RipGrepTool));
|
|
648
|
+
const wasGrepRegistered = calls.some((call) => call[0] instanceof vi.mocked(GrepTool));
|
|
649
|
+
expect(wasRipGrepRegistered).toBe(false);
|
|
650
|
+
expect(wasGrepRegistered).toBe(true);
|
|
651
|
+
expect(logRipgrepFallback).toHaveBeenCalledWith(config, expect.any(RipgrepFallbackEvent));
|
|
652
|
+
const event = logRipgrepFallback.mock.calls[0][1];
|
|
653
|
+
expect(event.error).toBe(String(error));
|
|
654
|
+
});
|
|
655
|
+
it('should register GrepTool when useRipgrep is false', async () => {
|
|
656
|
+
const config = new Config({ ...baseParams, useRipgrep: false });
|
|
657
|
+
await config.initialize();
|
|
658
|
+
const calls = ToolRegistry.prototype.registerTool.mock.calls;
|
|
659
|
+
const wasRipGrepRegistered = calls.some((call) => call[0] instanceof vi.mocked(RipGrepTool));
|
|
660
|
+
const wasGrepRegistered = calls.some((call) => call[0] instanceof vi.mocked(GrepTool));
|
|
661
|
+
expect(wasRipGrepRegistered).toBe(false);
|
|
662
|
+
expect(wasGrepRegistered).toBe(true);
|
|
663
|
+
expect(canUseRipgrep).not.toHaveBeenCalled();
|
|
664
|
+
expect(logRipgrepFallback).not.toHaveBeenCalled();
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
describe('BaseLlmClient Lifecycle', () => {
|
|
669
|
+
const MODEL = 'gemini-pro';
|
|
670
|
+
const SANDBOX = {
|
|
671
|
+
command: 'docker',
|
|
672
|
+
image: 'gemini-cli-sandbox',
|
|
673
|
+
};
|
|
674
|
+
const TARGET_DIR = '/path/to/target';
|
|
675
|
+
const DEBUG_MODE = false;
|
|
676
|
+
const QUESTION = 'test question';
|
|
677
|
+
const FULL_CONTEXT = false;
|
|
678
|
+
const USER_MEMORY = 'Test User Memory';
|
|
679
|
+
const TELEMETRY_SETTINGS = { enabled: false };
|
|
680
|
+
const EMBEDDING_MODEL = 'gemini-embedding';
|
|
681
|
+
const SESSION_ID = 'test-session-id';
|
|
682
|
+
const baseParams = {
|
|
683
|
+
cwd: '/tmp',
|
|
684
|
+
embeddingModel: EMBEDDING_MODEL,
|
|
685
|
+
sandbox: SANDBOX,
|
|
686
|
+
targetDir: TARGET_DIR,
|
|
687
|
+
debugMode: DEBUG_MODE,
|
|
688
|
+
question: QUESTION,
|
|
689
|
+
fullContext: FULL_CONTEXT,
|
|
690
|
+
userMemory: USER_MEMORY,
|
|
691
|
+
telemetry: TELEMETRY_SETTINGS,
|
|
692
|
+
sessionId: SESSION_ID,
|
|
693
|
+
model: MODEL,
|
|
694
|
+
usageStatisticsEnabled: false,
|
|
695
|
+
};
|
|
696
|
+
it('should throw an error if getBaseLlmClient is called before refreshAuth', () => {
|
|
697
|
+
const config = new Config(baseParams);
|
|
698
|
+
expect(() => config.getBaseLlmClient()).toThrow('BaseLlmClient not initialized. Ensure authentication has occurred and ContentGenerator is ready.');
|
|
699
|
+
});
|
|
700
|
+
it('should successfully initialize BaseLlmClient after refreshAuth is called', async () => {
|
|
701
|
+
const config = new Config(baseParams);
|
|
702
|
+
const authType = AuthType.USE_GEMINI;
|
|
703
|
+
const mockContentConfig = { model: 'gemini-flash', apiKey: 'test-key' };
|
|
704
|
+
vi.mocked(createContentGeneratorConfig).mockReturnValue(mockContentConfig);
|
|
705
|
+
await config.refreshAuth(authType);
|
|
706
|
+
// Should not throw
|
|
707
|
+
const llmService = config.getBaseLlmClient();
|
|
708
|
+
expect(llmService).toBeDefined();
|
|
709
|
+
expect(BaseLlmClient).toHaveBeenCalledWith(config.getContentGenerator(), config);
|
|
710
|
+
});
|
|
584
711
|
});
|
|
585
712
|
//# sourceMappingURL=config.test.js.map
|