@google/gemini-cli-core 0.0.1
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 +202 -0
- package/README.md +320 -0
- package/dist/.last_build +0 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/src/__mocks__/fs/promises.d.ts +11 -0
- package/dist/src/__mocks__/fs/promises.js +17 -0
- package/dist/src/__mocks__/fs/promises.js.map +1 -0
- package/dist/src/code_assist/codeAssist.d.ts +12 -0
- package/dist/src/code_assist/codeAssist.js +31 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +74 -0
- package/dist/src/code_assist/converter.js +160 -0
- package/dist/src/code_assist/converter.js.map +1 -0
- package/dist/src/code_assist/converter.test.d.ts +6 -0
- package/dist/src/code_assist/converter.test.js +372 -0
- package/dist/src/code_assist/converter.test.js.map +1 -0
- 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.d.ts +6 -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.d.ts +22 -0
- package/dist/src/code_assist/oauth2.js +416 -0
- package/dist/src/code_assist/oauth2.js.map +1 -0
- package/dist/src/code_assist/oauth2.test.d.ts +6 -0
- package/dist/src/code_assist/oauth2.test.js +817 -0
- package/dist/src/code_assist/oauth2.test.js.map +1 -0
- package/dist/src/code_assist/server.d.ts +37 -0
- package/dist/src/code_assist/server.js +148 -0
- package/dist/src/code_assist/server.js.map +1 -0
- package/dist/src/code_assist/server.test.d.ts +6 -0
- package/dist/src/code_assist/server.test.js +159 -0
- package/dist/src/code_assist/server.test.js.map +1 -0
- package/dist/src/code_assist/setup.d.ts +20 -0
- package/dist/src/code_assist/setup.js +101 -0
- package/dist/src/code_assist/setup.js.map +1 -0
- package/dist/src/code_assist/setup.test.d.ts +6 -0
- package/dist/src/code_assist/setup.test.js +171 -0
- package/dist/src/code_assist/setup.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +163 -0
- package/dist/src/code_assist/types.js +46 -0
- package/dist/src/code_assist/types.js.map +1 -0
- package/dist/src/config/config.d.ts +378 -0
- package/dist/src/config/config.js +765 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/config.test.d.ts +6 -0
- package/dist/src/config/config.test.js +712 -0
- package/dist/src/config/config.test.js.map +1 -0
- package/dist/src/config/flashFallback.test.d.ts +6 -0
- package/dist/src/config/flashFallback.test.js +87 -0
- package/dist/src/config/flashFallback.test.js.map +1 -0
- package/dist/src/config/models.d.ts +25 -0
- package/dist/src/config/models.js +39 -0
- package/dist/src/config/models.js.map +1 -0
- 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 +34 -0
- package/dist/src/config/storage.js +95 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.d.ts +6 -0
- package/dist/src/config/storage.test.js +47 -0
- package/dist/src/config/storage.test.js.map +1 -0
- 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 +60 -0
- package/dist/src/core/client.js +602 -0
- package/dist/src/core/client.js.map +1 -0
- package/dist/src/core/client.test.d.ts +6 -0
- package/dist/src/core/client.test.js +1758 -0
- package/dist/src/core/client.test.js.map +1 -0
- package/dist/src/core/contentGenerator.d.ts +32 -0
- package/dist/src/core/contentGenerator.js +76 -0
- package/dist/src/core/contentGenerator.js.map +1 -0
- package/dist/src/core/contentGenerator.test.d.ts +6 -0
- package/dist/src/core/contentGenerator.test.js +122 -0
- package/dist/src/core/contentGenerator.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +131 -0
- package/dist/src/core/coreToolScheduler.js +706 -0
- package/dist/src/core/coreToolScheduler.js.map +1 -0
- package/dist/src/core/coreToolScheduler.test.d.ts +6 -0
- package/dist/src/core/coreToolScheduler.test.js +1151 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +128 -0
- package/dist/src/core/geminiChat.js +537 -0
- package/dist/src/core/geminiChat.js.map +1 -0
- package/dist/src/core/geminiChat.test.d.ts +6 -0
- package/dist/src/core/geminiChat.test.js +1163 -0
- package/dist/src/core/geminiChat.test.js.map +1 -0
- package/dist/src/core/geminiRequest.d.ts +13 -0
- package/dist/src/core/geminiRequest.js +11 -0
- package/dist/src/core/geminiRequest.js.map +1 -0
- package/dist/src/core/logger.d.ts +60 -0
- package/dist/src/core/logger.js +360 -0
- package/dist/src/core/logger.js.map +1 -0
- package/dist/src/core/logger.test.d.ts +6 -0
- package/dist/src/core/logger.test.js +534 -0
- package/dist/src/core/logger.test.js.map +1 -0
- package/dist/src/core/loggingContentGenerator.d.ts +25 -0
- package/dist/src/core/loggingContentGenerator.js +94 -0
- package/dist/src/core/loggingContentGenerator.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +10 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +24 -0
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.d.ts +6 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js +294 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -0
- package/dist/src/core/prompts.d.ts +17 -0
- package/dist/src/core/prompts.js +380 -0
- package/dist/src/core/prompts.js.map +1 -0
- package/dist/src/core/prompts.test.d.ts +6 -0
- package/dist/src/core/prompts.test.js +343 -0
- package/dist/src/core/prompts.test.js.map +1 -0
- package/dist/src/core/subagent.d.ts +236 -0
- package/dist/src/core/subagent.js +482 -0
- package/dist/src/core/subagent.js.map +1 -0
- package/dist/src/core/subagent.test.d.ts +6 -0
- package/dist/src/core/subagent.test.js +530 -0
- package/dist/src/core/subagent.test.js.map +1 -0
- package/dist/src/core/tokenLimits.d.ts +10 -0
- package/dist/src/core/tokenLimits.js +28 -0
- package/dist/src/core/tokenLimits.js.map +1 -0
- package/dist/src/core/turn.d.ts +141 -0
- package/dist/src/core/turn.js +188 -0
- package/dist/src/core/turn.js.map +1 -0
- package/dist/src/core/turn.test.d.ts +6 -0
- package/dist/src/core/turn.test.js +628 -0
- package/dist/src/core/turn.test.js.map +1 -0
- 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 +7 -0
- package/dist/src/generated/git-commit.js +10 -0
- package/dist/src/generated/git-commit.js.map +1 -0
- package/dist/src/ide/constants.d.ts +9 -0
- package/dist/src/ide/constants.js +10 -0
- package/dist/src/ide/constants.js.map +1 -0
- package/dist/src/ide/detect-ide.d.ts +53 -0
- package/dist/src/ide/detect-ide.js +58 -0
- package/dist/src/ide/detect-ide.js.map +1 -0
- package/dist/src/ide/detect-ide.test.d.ts +6 -0
- package/dist/src/ide/detect-ide.test.js +69 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -0
- package/dist/src/ide/ide-client.d.ts +109 -0
- package/dist/src/ide/ide-client.js +640 -0
- package/dist/src/ide/ide-client.js.map +1 -0
- package/dist/src/ide/ide-client.test.d.ts +6 -0
- package/dist/src/ide/ide-client.test.js +388 -0
- package/dist/src/ide/ide-client.test.js.map +1 -0
- package/dist/src/ide/ide-installer.d.ts +14 -0
- package/dist/src/ide/ide-installer.js +111 -0
- package/dist/src/ide/ide-installer.js.map +1 -0
- package/dist/src/ide/ide-installer.test.d.ts +6 -0
- package/dist/src/ide/ide-installer.test.js +131 -0
- package/dist/src/ide/ide-installer.test.js.map +1 -0
- package/dist/src/ide/ideContext.d.ts +44 -0
- package/dist/src/ide/ideContext.js +101 -0
- package/dist/src/ide/ideContext.js.map +1 -0
- package/dist/src/ide/ideContext.test.d.ts +6 -0
- package/dist/src/ide/ideContext.test.js +393 -0
- package/dist/src/ide/ideContext.test.js.map +1 -0
- package/dist/src/ide/process-utils.d.ts +21 -0
- package/dist/src/ide/process-utils.js +171 -0
- package/dist/src/ide/process-utils.js.map +1 -0
- package/dist/src/ide/process-utils.test.d.ts +6 -0
- package/dist/src/ide/process-utils.test.js +158 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- 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 +87 -0
- package/dist/src/index.js +97 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.test.d.ts +6 -0
- package/dist/src/index.test.js +12 -0
- package/dist/src/index.test.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.d.ts +23 -0
- package/dist/src/mcp/google-auth-provider.js +72 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.test.d.ts +6 -0
- package/dist/src/mcp/google-auth-provider.test.js +89 -0
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -0
- package/dist/src/mcp/oauth-provider.d.ts +149 -0
- package/dist/src/mcp/oauth-provider.js +608 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-provider.test.d.ts +6 -0
- package/dist/src/mcp/oauth-provider.test.js +711 -0
- package/dist/src/mcp/oauth-provider.test.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.d.ts +65 -0
- package/dist/src/mcp/oauth-token-storage.js +180 -0
- package/dist/src/mcp/oauth-token-storage.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/oauth-token-storage.test.js +299 -0
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -0
- package/dist/src/mcp/oauth-utils.d.ts +119 -0
- package/dist/src/mcp/oauth-utils.js +235 -0
- package/dist/src/mcp/oauth-utils.js.map +1 -0
- package/dist/src/mcp/oauth-utils.test.d.ts +6 -0
- package/dist/src/mcp/oauth-utils.test.js +199 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
- package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js +160 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
- 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 +38 -0
- package/dist/src/mcp/token-storage/types.js +11 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/mocks/msw.d.ts +6 -0
- package/dist/src/mocks/msw.js +8 -0
- package/dist/src/mocks/msw.js.map +1 -0
- 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 +83 -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 +470 -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/prompts/mcp-prompts.d.ts +8 -0
- package/dist/src/prompts/mcp-prompts.js +13 -0
- package/dist/src/prompts/mcp-prompts.js.map +1 -0
- package/dist/src/prompts/prompt-registry.d.ts +34 -0
- package/dist/src/prompts/prompt-registry.js +63 -0
- package/dist/src/prompts/prompt-registry.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 +144 -0
- package/dist/src/services/chatRecordingService.js +330 -0
- package/dist/src/services/chatRecordingService.js.map +1 -0
- package/dist/src/services/chatRecordingService.test.d.ts +6 -0
- package/dist/src/services/chatRecordingService.test.js +332 -0
- package/dist/src/services/chatRecordingService.test.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.d.ts +45 -0
- package/dist/src/services/fileDiscoveryService.js +105 -0
- package/dist/src/services/fileDiscoveryService.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.test.d.ts +6 -0
- package/dist/src/services/fileDiscoveryService.test.js +143 -0
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -0
- package/dist/src/services/fileSystemService.d.ts +31 -0
- package/dist/src/services/fileSystemService.js +18 -0
- package/dist/src/services/fileSystemService.js.map +1 -0
- package/dist/src/services/fileSystemService.test.d.ts +6 -0
- package/dist/src/services/fileSystemService.test.js +41 -0
- package/dist/src/services/fileSystemService.test.js.map +1 -0
- package/dist/src/services/gitService.d.ts +23 -0
- package/dist/src/services/gitService.js +107 -0
- package/dist/src/services/gitService.js.map +1 -0
- package/dist/src/services/gitService.test.d.ts +6 -0
- package/dist/src/services/gitService.test.js +202 -0
- package/dist/src/services/gitService.test.js.map +1 -0
- package/dist/src/services/loopDetectionService.d.ts +103 -0
- package/dist/src/services/loopDetectionService.js +379 -0
- package/dist/src/services/loopDetectionService.js.map +1 -0
- package/dist/src/services/loopDetectionService.test.d.ts +6 -0
- package/dist/src/services/loopDetectionService.test.js +587 -0
- package/dist/src/services/loopDetectionService.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +100 -0
- package/dist/src/services/shellExecutionService.js +466 -0
- package/dist/src/services/shellExecutionService.js.map +1 -0
- package/dist/src/services/shellExecutionService.test.d.ts +6 -0
- package/dist/src/services/shellExecutionService.test.js +614 -0
- package/dist/src/services/shellExecutionService.test.js.map +1 -0
- 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 +135 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +892 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +17 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +507 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +107 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +275 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +40 -0
- package/dist/src/telemetry/constants.js +41 -0
- package/dist/src/telemetry/constants.js.map +1 -0
- package/dist/src/telemetry/file-exporters.d.ts +29 -0
- package/dist/src/telemetry/file-exporters.js +62 -0
- package/dist/src/telemetry/file-exporters.js.map +1 -0
- 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 +26 -0
- package/dist/src/telemetry/index.js +26 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/integration.test.circular.d.ts +6 -0
- package/dist/src/telemetry/integration.test.circular.js +54 -0
- package/dist/src/telemetry/integration.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +33 -0
- package/dist/src/telemetry/loggers.js +536 -0
- package/dist/src/telemetry/loggers.js.map +1 -0
- package/dist/src/telemetry/loggers.test.circular.d.ts +6 -0
- package/dist/src/telemetry/loggers.test.circular.js +107 -0
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.test.d.ts +6 -0
- package/dist/src/telemetry/loggers.test.js +887 -0
- package/dist/src/telemetry/loggers.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +37 -0
- package/dist/src/telemetry/metrics.js +231 -0
- package/dist/src/telemetry/metrics.js.map +1 -0
- package/dist/src/telemetry/metrics.test.d.ts +6 -0
- package/dist/src/telemetry/metrics.test.js +264 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -0
- 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.d.ts +9 -0
- package/dist/src/telemetry/sdk.js +178 -0
- package/dist/src/telemetry/sdk.js.map +1 -0
- package/dist/src/telemetry/sdk.test.d.ts +6 -0
- package/dist/src/telemetry/sdk.test.js +177 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.js +14 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.test.js +40 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- package/dist/src/telemetry/telemetry.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry.test.js +50 -0
- package/dist/src/telemetry/telemetry.test.js.map +1 -0
- package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
- package/dist/src/telemetry/tool-call-decision.js +29 -0
- package/dist/src/telemetry/tool-call-decision.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +284 -0
- package/dist/src/telemetry/types.js +487 -0
- package/dist/src/telemetry/types.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.d.ts +75 -0
- package/dist/src/telemetry/uiTelemetry.js +152 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.test.d.ts +6 -0
- package/dist/src/telemetry/uiTelemetry.test.js +558 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -0
- package/dist/src/test-utils/config.d.ts +17 -0
- package/dist/src/test-utils/config.js +32 -0
- package/dist/src/test-utils/config.js.map +1 -0
- 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/test-utils/mockWorkspaceContext.d.ts +13 -0
- package/dist/src/test-utils/mockWorkspaceContext.js +24 -0
- package/dist/src/test-utils/mockWorkspaceContext.js.map +1 -0
- package/dist/src/test-utils/tools.d.ts +45 -0
- package/dist/src/test-utils/tools.js +105 -0
- package/dist/src/test-utils/tools.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +9 -0
- package/dist/src/tools/diffOptions.js +46 -0
- package/dist/src/tools/diffOptions.js.map +1 -0
- package/dist/src/tools/diffOptions.test.d.ts +6 -0
- package/dist/src/tools/diffOptions.test.js +155 -0
- package/dist/src/tools/diffOptions.test.js.map +1 -0
- package/dist/src/tools/edit.d.ts +56 -0
- package/dist/src/tools/edit.js +414 -0
- package/dist/src/tools/edit.js.map +1 -0
- package/dist/src/tools/edit.test.d.ts +6 -0
- package/dist/src/tools/edit.test.js +824 -0
- package/dist/src/tools/edit.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +56 -0
- package/dist/src/tools/glob.js +243 -0
- package/dist/src/tools/glob.js.map +1 -0
- package/dist/src/tools/glob.test.d.ts +6 -0
- package/dist/src/tools/glob.test.js +426 -0
- package/dist/src/tools/glob.test.js.map +1 -0
- package/dist/src/tools/grep.d.ts +47 -0
- package/dist/src/tools/grep.js +517 -0
- package/dist/src/tools/grep.js.map +1 -0
- package/dist/src/tools/grep.test.d.ts +6 -0
- package/dist/src/tools/grep.test.js +295 -0
- package/dist/src/tools/grep.test.js.map +1 -0
- package/dist/src/tools/ls.d.ts +68 -0
- package/dist/src/tools/ls.js +214 -0
- package/dist/src/tools/ls.js.map +1 -0
- package/dist/src/tools/ls.test.d.ts +6 -0
- package/dist/src/tools/ls.test.js +249 -0
- package/dist/src/tools/ls.test.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.d.ts +40 -0
- package/dist/src/tools/mcp-client-manager.js +83 -0
- package/dist/src/tools/mcp-client-manager.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.test.d.ts +6 -0
- package/dist/src/tools/mcp-client-manager.test.js +58 -0
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -0
- package/dist/src/tools/mcp-client.d.ts +199 -0
- package/dist/src/tools/mcp-client.js +1000 -0
- package/dist/src/tools/mcp-client.js.map +1 -0
- package/dist/src/tools/mcp-client.test.d.ts +6 -0
- package/dist/src/tools/mcp-client.test.js +454 -0
- package/dist/src/tools/mcp-client.test.js.map +1 -0
- package/dist/src/tools/mcp-tool.d.ts +24 -0
- package/dist/src/tools/mcp-tool.js +240 -0
- package/dist/src/tools/mcp-tool.js.map +1 -0
- package/dist/src/tools/mcp-tool.test.d.ts +6 -0
- package/dist/src/tools/mcp-tool.test.js +597 -0
- package/dist/src/tools/mcp-tool.test.js.map +1 -0
- package/dist/src/tools/memoryTool.d.ts +40 -0
- package/dist/src/tools/memoryTool.js +268 -0
- package/dist/src/tools/memoryTool.js.map +1 -0
- package/dist/src/tools/memoryTool.test.d.ts +6 -0
- package/dist/src/tools/memoryTool.test.js +298 -0
- package/dist/src/tools/memoryTool.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +32 -0
- package/dist/src/tools/modifiable-tool.js +88 -0
- package/dist/src/tools/modifiable-tool.js.map +1 -0
- package/dist/src/tools/modifiable-tool.test.d.ts +6 -0
- package/dist/src/tools/modifiable-tool.test.js +193 -0
- package/dist/src/tools/modifiable-tool.test.js.map +1 -0
- package/dist/src/tools/read-file.d.ts +35 -0
- package/dist/src/tools/read-file.js +132 -0
- package/dist/src/tools/read-file.js.map +1 -0
- package/dist/src/tools/read-file.test.d.ts +6 -0
- package/dist/src/tools/read-file.test.js +340 -0
- package/dist/src/tools/read-file.test.js.map +1 -0
- package/dist/src/tools/read-many-files.d.ts +60 -0
- package/dist/src/tools/read-many-files.js +382 -0
- package/dist/src/tools/read-many-files.js.map +1 -0
- package/dist/src/tools/read-many-files.test.d.ts +6 -0
- package/dist/src/tools/read-many-files.test.js +565 -0
- package/dist/src/tools/read-many-files.test.js.map +1 -0
- package/dist/src/tools/ripGrep.d.ts +55 -0
- package/dist/src/tools/ripGrep.js +393 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/ripGrep.test.d.ts +6 -0
- package/dist/src/tools/ripGrep.test.js +976 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +32 -0
- package/dist/src/tools/shell.js +316 -0
- package/dist/src/tools/shell.js.map +1 -0
- package/dist/src/tools/shell.test.d.ts +6 -0
- package/dist/src/tools/shell.test.js +301 -0
- package/dist/src/tools/shell.test.js.map +1 -0
- 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-error.d.ts +43 -0
- package/dist/src/tools/tool-error.js +58 -0
- package/dist/src/tools/tool-error.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +87 -0
- package/dist/src/tools/tool-registry.js +370 -0
- package/dist/src/tools/tool-registry.js.map +1 -0
- package/dist/src/tools/tool-registry.test.d.ts +6 -0
- package/dist/src/tools/tool-registry.test.js +332 -0
- package/dist/src/tools/tool-registry.test.js.map +1 -0
- package/dist/src/tools/tools.d.ts +281 -0
- package/dist/src/tools/tools.js +257 -0
- package/dist/src/tools/tools.js.map +1 -0
- package/dist/src/tools/tools.test.d.ts +6 -0
- package/dist/src/tools/tools.test.js +205 -0
- package/dist/src/tools/tools.test.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +27 -0
- package/dist/src/tools/web-fetch.js +244 -0
- package/dist/src/tools/web-fetch.js.map +1 -0
- package/dist/src/tools/web-fetch.test.d.ts +6 -0
- package/dist/src/tools/web-fetch.test.js +114 -0
- package/dist/src/tools/web-fetch.test.js.map +1 -0
- package/dist/src/tools/web-search.d.ts +49 -0
- package/dist/src/tools/web-search.js +139 -0
- package/dist/src/tools/web-search.js.map +1 -0
- package/dist/src/tools/web-search.test.d.ts +6 -0
- package/dist/src/tools/web-search.test.js +207 -0
- package/dist/src/tools/web-search.test.js.map +1 -0
- package/dist/src/tools/write-file.d.ts +52 -0
- package/dist/src/tools/write-file.js +309 -0
- package/dist/src/tools/write-file.js.map +1 -0
- package/dist/src/tools/write-file.test.d.ts +6 -0
- package/dist/src/tools/write-file.test.js +611 -0
- package/dist/src/tools/write-file.test.js.map +1 -0
- package/dist/src/utils/LruCache.d.ts +13 -0
- package/dist/src/utils/LruCache.js +38 -0
- package/dist/src/utils/LruCache.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +24 -0
- package/dist/src/utils/bfsFileSearch.js +95 -0
- package/dist/src/utils/bfsFileSearch.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.test.d.ts +6 -0
- package/dist/src/utils/bfsFileSearch.test.js +163 -0
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -0
- package/dist/src/utils/browser.d.ts +13 -0
- package/dist/src/utils/browser.js +50 -0
- package/dist/src/utils/browser.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +54 -0
- package/dist/src/utils/editCorrector.js +588 -0
- package/dist/src/utils/editCorrector.js.map +1 -0
- package/dist/src/utils/editCorrector.test.d.ts +6 -0
- package/dist/src/utils/editCorrector.test.js +515 -0
- package/dist/src/utils/editCorrector.test.js.map +1 -0
- package/dist/src/utils/editor.d.ts +28 -0
- package/dist/src/utils/editor.js +173 -0
- package/dist/src/utils/editor.js.map +1 -0
- package/dist/src/utils/editor.test.d.ts +6 -0
- package/dist/src/utils/editor.test.js +431 -0
- package/dist/src/utils/editor.test.js.map +1 -0
- package/dist/src/utils/environmentContext.d.ts +21 -0
- package/dist/src/utils/environmentContext.js +90 -0
- package/dist/src/utils/environmentContext.js.map +1 -0
- package/dist/src/utils/environmentContext.test.d.ts +6 -0
- package/dist/src/utils/environmentContext.test.js +140 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -0
- package/dist/src/utils/errorParsing.d.ts +8 -0
- package/dist/src/utils/errorParsing.js +93 -0
- package/dist/src/utils/errorParsing.js.map +1 -0
- package/dist/src/utils/errorParsing.test.d.ts +6 -0
- package/dist/src/utils/errorParsing.test.js +172 -0
- package/dist/src/utils/errorParsing.test.js.map +1 -0
- package/dist/src/utils/errorReporting.d.ts +14 -0
- package/dist/src/utils/errorReporting.js +88 -0
- package/dist/src/utils/errorReporting.js.map +1 -0
- package/dist/src/utils/errorReporting.test.d.ts +6 -0
- package/dist/src/utils/errorReporting.test.js +130 -0
- package/dist/src/utils/errorReporting.test.js.map +1 -0
- package/dist/src/utils/errors.d.ts +39 -0
- package/dist/src/utils/errors.js +96 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +11 -0
- package/dist/src/utils/fetch.js +51 -0
- package/dist/src/utils/fetch.js.map +1 -0
- package/dist/src/utils/fileUtils.d.ts +69 -0
- package/dist/src/utils/fileUtils.js +405 -0
- package/dist/src/utils/fileUtils.js.map +1 -0
- package/dist/src/utils/fileUtils.test.d.ts +6 -0
- package/dist/src/utils/fileUtils.test.js +682 -0
- package/dist/src/utils/fileUtils.test.js.map +1 -0
- package/dist/src/utils/filesearch/crawlCache.d.ts +25 -0
- package/dist/src/utils/filesearch/crawlCache.js +57 -0
- package/dist/src/utils/filesearch/crawlCache.js.map +1 -0
- package/dist/src/utils/filesearch/crawlCache.test.d.ts +6 -0
- package/dist/src/utils/filesearch/crawlCache.test.js +103 -0
- package/dist/src/utils/filesearch/crawlCache.test.js.map +1 -0
- package/dist/src/utils/filesearch/crawler.d.ts +15 -0
- package/dist/src/utils/filesearch/crawler.js +50 -0
- package/dist/src/utils/filesearch/crawler.js.map +1 -0
- package/dist/src/utils/filesearch/crawler.test.d.ts +6 -0
- package/dist/src/utils/filesearch/crawler.test.js +468 -0
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.d.ts +38 -0
- package/dist/src/utils/filesearch/fileSearch.js +191 -0
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.test.d.ts +6 -0
- package/dist/src/utils/filesearch/fileSearch.test.js +642 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -0
- package/dist/src/utils/filesearch/ignore.d.ts +42 -0
- package/dist/src/utils/filesearch/ignore.js +106 -0
- package/dist/src/utils/filesearch/ignore.js.map +1 -0
- package/dist/src/utils/filesearch/ignore.test.d.ts +6 -0
- package/dist/src/utils/filesearch/ignore.test.js +144 -0
- package/dist/src/utils/filesearch/ignore.test.js.map +1 -0
- package/dist/src/utils/filesearch/result-cache.d.ts +33 -0
- package/dist/src/utils/filesearch/result-cache.js +59 -0
- package/dist/src/utils/filesearch/result-cache.js.map +1 -0
- package/dist/src/utils/filesearch/result-cache.test.d.ts +6 -0
- package/dist/src/utils/filesearch/result-cache.test.js +46 -0
- package/dist/src/utils/filesearch/result-cache.test.js.map +1 -0
- package/dist/src/utils/flashFallback.test.d.ts +6 -0
- package/dist/src/utils/flashFallback.test.js +122 -0
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- package/dist/src/utils/formatters.d.ts +6 -0
- package/dist/src/utils/formatters.js +16 -0
- package/dist/src/utils/formatters.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/generateContentResponseUtilities.d.ts +13 -0
- package/dist/src/utils/generateContentResponseUtilities.js +80 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.test.d.ts +6 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js +235 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.d.ts +31 -0
- package/dist/src/utils/getFolderStructure.js +246 -0
- package/dist/src/utils/getFolderStructure.js.map +1 -0
- package/dist/src/utils/getFolderStructure.test.d.ts +6 -0
- package/dist/src/utils/getFolderStructure.test.js +282 -0
- package/dist/src/utils/getFolderStructure.test.js.map +1 -0
- package/dist/src/utils/getPty.d.ts +19 -0
- package/dist/src/utils/getPty.js +23 -0
- package/dist/src/utils/getPty.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.d.ts +16 -0
- package/dist/src/utils/gitIgnoreParser.js +152 -0
- package/dist/src/utils/gitIgnoreParser.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/gitIgnoreParser.test.js +185 -0
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/gitUtils.d.ts +17 -0
- package/dist/src/utils/gitUtils.js +61 -0
- package/dist/src/utils/gitUtils.js.map +1 -0
- package/dist/src/utils/ignorePatterns.d.ts +103 -0
- package/dist/src/utils/ignorePatterns.js +220 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
- package/dist/src/utils/ignorePatterns.test.js +250 -0
- package/dist/src/utils/ignorePatterns.test.js.map +1 -0
- package/dist/src/utils/installationManager.d.ts +16 -0
- package/dist/src/utils/installationManager.js +50 -0
- package/dist/src/utils/installationManager.js.map +1 -0
- package/dist/src/utils/installationManager.test.d.ts +6 -0
- package/dist/src/utils/installationManager.test.js +83 -0
- package/dist/src/utils/installationManager.test.js.map +1 -0
- package/dist/src/utils/language-detection.d.ts +6 -0
- package/dist/src/utils/language-detection.js +101 -0
- package/dist/src/utils/language-detection.js.map +1 -0
- 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 +16 -0
- package/dist/src/utils/memoryDiscovery.js +254 -0
- package/dist/src/utils/memoryDiscovery.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.test.d.ts +6 -0
- package/dist/src/utils/memoryDiscovery.test.js +244 -0
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.d.ts +42 -0
- package/dist/src/utils/memoryImportProcessor.js +296 -0
- package/dist/src/utils/memoryImportProcessor.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.test.d.ts +6 -0
- package/dist/src/utils/memoryImportProcessor.test.js +573 -0
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -0
- package/dist/src/utils/messageInspectors.d.ts +8 -0
- package/dist/src/utils/messageInspectors.js +16 -0
- package/dist/src/utils/messageInspectors.js.map +1 -0
- package/dist/src/utils/nextSpeakerChecker.d.ts +12 -0
- package/dist/src/utils/nextSpeakerChecker.js +97 -0
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -0
- package/dist/src/utils/nextSpeakerChecker.test.d.ts +6 -0
- package/dist/src/utils/nextSpeakerChecker.test.js +179 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -0
- package/dist/src/utils/partUtils.d.ts +35 -0
- package/dist/src/utils/partUtils.js +133 -0
- package/dist/src/utils/partUtils.js.map +1 -0
- package/dist/src/utils/partUtils.test.d.ts +6 -0
- package/dist/src/utils/partUtils.test.js +241 -0
- package/dist/src/utils/partUtils.test.js.map +1 -0
- package/dist/src/utils/pathReader.d.ts +17 -0
- package/dist/src/utils/pathReader.js +92 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/pathReader.test.d.ts +6 -0
- package/dist/src/utils/pathReader.test.js +363 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +58 -0
- package/dist/src/utils/paths.js +159 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/paths.test.d.ts +6 -0
- package/dist/src/utils/paths.test.js +225 -0
- package/dist/src/utils/paths.test.js.map +1 -0
- 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/quotaErrorDetection.d.ts +18 -0
- package/dist/src/utils/quotaErrorDetection.js +65 -0
- package/dist/src/utils/quotaErrorDetection.js.map +1 -0
- package/dist/src/utils/retry.d.ts +30 -0
- package/dist/src/utils/retry.js +276 -0
- package/dist/src/utils/retry.js.map +1 -0
- package/dist/src/utils/retry.test.d.ts +6 -0
- package/dist/src/utils/retry.test.js +325 -0
- package/dist/src/utils/retry.test.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.d.ts +13 -0
- package/dist/src/utils/safeJsonStringify.js +25 -0
- package/dist/src/utils/safeJsonStringify.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.test.d.ts +6 -0
- package/dist/src/utils/safeJsonStringify.test.js +61 -0
- package/dist/src/utils/safeJsonStringify.test.js.map +1 -0
- package/dist/src/utils/schemaValidator.d.ts +15 -0
- package/dist/src/utils/schemaValidator.js +38 -0
- package/dist/src/utils/schemaValidator.js.map +1 -0
- package/dist/src/utils/secure-browser-launcher.d.ts +23 -0
- package/dist/src/utils/secure-browser-launcher.js +165 -0
- package/dist/src/utils/secure-browser-launcher.js.map +1 -0
- package/dist/src/utils/secure-browser-launcher.test.d.ts +6 -0
- package/dist/src/utils/secure-browser-launcher.test.js +149 -0
- package/dist/src/utils/secure-browser-launcher.test.js.map +1 -0
- package/dist/src/utils/session.d.ts +6 -0
- package/dist/src/utils/session.js +8 -0
- package/dist/src/utils/session.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +122 -0
- package/dist/src/utils/shell-utils.js +393 -0
- package/dist/src/utils/shell-utils.js.map +1 -0
- package/dist/src/utils/shell-utils.test.d.ts +6 -0
- package/dist/src/utils/shell-utils.test.js +332 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +25 -0
- package/dist/src/utils/summarizer.js +51 -0
- package/dist/src/utils/summarizer.js.map +1 -0
- package/dist/src/utils/summarizer.test.d.ts +6 -0
- package/dist/src/utils/summarizer.test.js +131 -0
- package/dist/src/utils/summarizer.test.js.map +1 -0
- package/dist/src/utils/systemEncoding.d.ts +40 -0
- package/dist/src/utils/systemEncoding.js +149 -0
- package/dist/src/utils/systemEncoding.js.map +1 -0
- package/dist/src/utils/systemEncoding.test.d.ts +6 -0
- package/dist/src/utils/systemEncoding.test.js +368 -0
- package/dist/src/utils/systemEncoding.test.js.map +1 -0
- 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/testUtils.d.ts +29 -0
- package/dist/src/utils/testUtils.js +70 -0
- package/dist/src/utils/testUtils.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +18 -0
- package/dist/src/utils/textUtils.js +42 -0
- package/dist/src/utils/textUtils.js.map +1 -0
- 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/src/utils/tool-utils.d.ts +19 -0
- package/dist/src/utils/tool-utils.js +58 -0
- package/dist/src/utils/tool-utils.js.map +1 -0
- package/dist/src/utils/tool-utils.test.d.ts +6 -0
- package/dist/src/utils/tool-utils.test.js +61 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.d.ts +20 -0
- package/dist/src/utils/userAccountManager.js +114 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/userAccountManager.test.d.ts +6 -0
- package/dist/src/utils/userAccountManager.test.js +223 -0
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.d.ts +66 -0
- package/dist/src/utils/workspaceContext.js +171 -0
- package/dist/src/utils/workspaceContext.js.map +1 -0
- package/dist/src/utils/workspaceContext.test.d.ts +6 -0
- package/dist/src/utils/workspaceContext.test.js +318 -0
- package/dist/src/utils/workspaceContext.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect, vi, beforeEach, afterEach, } from 'vitest';
|
|
7
|
+
import * as actualNodeFs from 'node:fs'; // For setup/teardown
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import fsPromises from 'node:fs/promises';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import os from 'node:os';
|
|
12
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
13
|
+
import mime from 'mime/lite';
|
|
14
|
+
import { isWithinRoot, isBinaryFile, detectFileType, processSingleFileContent, detectBOM, readFileWithEncoding, fileExists, } from './fileUtils.js';
|
|
15
|
+
import { StandardFileSystemService } from '../services/fileSystemService.js';
|
|
16
|
+
vi.mock('mime/lite', () => ({
|
|
17
|
+
default: { getType: vi.fn() },
|
|
18
|
+
getType: vi.fn(),
|
|
19
|
+
}));
|
|
20
|
+
const mockMimeGetType = mime.getType;
|
|
21
|
+
describe('fileUtils', () => {
|
|
22
|
+
let tempRootDir;
|
|
23
|
+
const originalProcessCwd = process.cwd;
|
|
24
|
+
let testTextFilePath;
|
|
25
|
+
let testImageFilePath;
|
|
26
|
+
let testPdfFilePath;
|
|
27
|
+
let testBinaryFilePath;
|
|
28
|
+
let nonexistentFilePath;
|
|
29
|
+
let directoryPath;
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
vi.resetAllMocks(); // Reset all mocks, including mime.getType
|
|
32
|
+
tempRootDir = actualNodeFs.mkdtempSync(path.join(os.tmpdir(), 'fileUtils-test-'));
|
|
33
|
+
process.cwd = vi.fn(() => tempRootDir); // Mock cwd if necessary for relative path logic within tests
|
|
34
|
+
testTextFilePath = path.join(tempRootDir, 'test.txt');
|
|
35
|
+
testImageFilePath = path.join(tempRootDir, 'image.png');
|
|
36
|
+
testPdfFilePath = path.join(tempRootDir, 'document.pdf');
|
|
37
|
+
testBinaryFilePath = path.join(tempRootDir, 'app.exe');
|
|
38
|
+
nonexistentFilePath = path.join(tempRootDir, 'nonexistent.txt');
|
|
39
|
+
directoryPath = path.join(tempRootDir, 'subdir');
|
|
40
|
+
actualNodeFs.mkdirSync(directoryPath, { recursive: true }); // Ensure subdir exists
|
|
41
|
+
});
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
if (actualNodeFs.existsSync(tempRootDir)) {
|
|
44
|
+
actualNodeFs.rmSync(tempRootDir, { recursive: true, force: true });
|
|
45
|
+
}
|
|
46
|
+
process.cwd = originalProcessCwd;
|
|
47
|
+
vi.restoreAllMocks(); // Restore any spies
|
|
48
|
+
});
|
|
49
|
+
describe('isWithinRoot', () => {
|
|
50
|
+
const root = path.resolve('/project/root');
|
|
51
|
+
it('should return true for paths directly within the root', () => {
|
|
52
|
+
expect(isWithinRoot(path.join(root, 'file.txt'), root)).toBe(true);
|
|
53
|
+
expect(isWithinRoot(path.join(root, 'subdir', 'file.txt'), root)).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
it('should return true for the root path itself', () => {
|
|
56
|
+
expect(isWithinRoot(root, root)).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
it('should return false for paths outside the root', () => {
|
|
59
|
+
expect(isWithinRoot(path.resolve('/project/other', 'file.txt'), root)).toBe(false);
|
|
60
|
+
expect(isWithinRoot(path.resolve('/unrelated', 'file.txt'), root)).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
it('should return false for paths that only partially match the root prefix', () => {
|
|
63
|
+
expect(isWithinRoot(path.resolve('/project/root-but-actually-different'), root)).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
it('should handle paths with trailing slashes correctly', () => {
|
|
66
|
+
expect(isWithinRoot(path.join(root, 'file.txt') + path.sep, root)).toBe(true);
|
|
67
|
+
expect(isWithinRoot(root + path.sep, root)).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
it('should handle different path separators (POSIX vs Windows)', () => {
|
|
70
|
+
const posixRoot = '/project/root';
|
|
71
|
+
const posixPathInside = '/project/root/file.txt';
|
|
72
|
+
const posixPathOutside = '/project/other/file.txt';
|
|
73
|
+
expect(isWithinRoot(posixPathInside, posixRoot)).toBe(true);
|
|
74
|
+
expect(isWithinRoot(posixPathOutside, posixRoot)).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
it('should return false for a root path that is a sub-path of the path to check', () => {
|
|
77
|
+
const pathToCheck = path.resolve('/project/root/sub');
|
|
78
|
+
const rootSub = path.resolve('/project/root');
|
|
79
|
+
expect(isWithinRoot(pathToCheck, rootSub)).toBe(true);
|
|
80
|
+
const pathToCheckSuper = path.resolve('/project/root');
|
|
81
|
+
const rootSuper = path.resolve('/project/root/sub');
|
|
82
|
+
expect(isWithinRoot(pathToCheckSuper, rootSuper)).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
describe('fileExists', () => {
|
|
86
|
+
it('should return true if the file exists', async () => {
|
|
87
|
+
const testFile = path.join(tempRootDir, 'exists.txt');
|
|
88
|
+
actualNodeFs.writeFileSync(testFile, 'content');
|
|
89
|
+
await expect(fileExists(testFile)).resolves.toBe(true);
|
|
90
|
+
});
|
|
91
|
+
it('should return false if the file does not exist', async () => {
|
|
92
|
+
const testFile = path.join(tempRootDir, 'does-not-exist.txt');
|
|
93
|
+
await expect(fileExists(testFile)).resolves.toBe(false);
|
|
94
|
+
});
|
|
95
|
+
it('should return true for a directory that exists', async () => {
|
|
96
|
+
const testDir = path.join(tempRootDir, 'exists-dir');
|
|
97
|
+
actualNodeFs.mkdirSync(testDir);
|
|
98
|
+
await expect(fileExists(testDir)).resolves.toBe(true);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
describe('isBinaryFile', () => {
|
|
102
|
+
let filePathForBinaryTest;
|
|
103
|
+
beforeEach(() => {
|
|
104
|
+
filePathForBinaryTest = path.join(tempRootDir, 'binaryCheck.tmp');
|
|
105
|
+
});
|
|
106
|
+
afterEach(() => {
|
|
107
|
+
if (actualNodeFs.existsSync(filePathForBinaryTest)) {
|
|
108
|
+
actualNodeFs.unlinkSync(filePathForBinaryTest);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
it('should return false for an empty file', async () => {
|
|
112
|
+
actualNodeFs.writeFileSync(filePathForBinaryTest, '');
|
|
113
|
+
expect(await isBinaryFile(filePathForBinaryTest)).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
it('should return false for a typical text file', async () => {
|
|
116
|
+
actualNodeFs.writeFileSync(filePathForBinaryTest, 'Hello, world!\nThis is a test file with normal text content.');
|
|
117
|
+
expect(await isBinaryFile(filePathForBinaryTest)).toBe(false);
|
|
118
|
+
});
|
|
119
|
+
it('should return true for a file with many null bytes', async () => {
|
|
120
|
+
const binaryContent = Buffer.from([
|
|
121
|
+
0x48, 0x65, 0x00, 0x6c, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
122
|
+
]); // "He\0llo\0\0\0\0\0"
|
|
123
|
+
actualNodeFs.writeFileSync(filePathForBinaryTest, binaryContent);
|
|
124
|
+
expect(await isBinaryFile(filePathForBinaryTest)).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
it('should return true for a file with high percentage of non-printable ASCII', async () => {
|
|
127
|
+
const binaryContent = Buffer.from([
|
|
128
|
+
0x41, 0x42, 0x01, 0x02, 0x03, 0x04, 0x05, 0x43, 0x44, 0x06,
|
|
129
|
+
]); // AB\x01\x02\x03\x04\x05CD\x06
|
|
130
|
+
actualNodeFs.writeFileSync(filePathForBinaryTest, binaryContent);
|
|
131
|
+
expect(await isBinaryFile(filePathForBinaryTest)).toBe(true);
|
|
132
|
+
});
|
|
133
|
+
it('should return false if file access fails (e.g., ENOENT)', async () => {
|
|
134
|
+
// Ensure the file does not exist
|
|
135
|
+
if (actualNodeFs.existsSync(filePathForBinaryTest)) {
|
|
136
|
+
actualNodeFs.unlinkSync(filePathForBinaryTest);
|
|
137
|
+
}
|
|
138
|
+
expect(await isBinaryFile(filePathForBinaryTest)).toBe(false);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
describe('BOM detection and encoding', () => {
|
|
142
|
+
let testDir;
|
|
143
|
+
beforeEach(async () => {
|
|
144
|
+
testDir = await fsPromises.mkdtemp(path.join(await fsPromises.realpath(os.tmpdir()), 'fileUtils-bom-test-'));
|
|
145
|
+
});
|
|
146
|
+
afterEach(async () => {
|
|
147
|
+
if (testDir) {
|
|
148
|
+
await fsPromises.rm(testDir, { recursive: true, force: true });
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
describe('detectBOM', () => {
|
|
152
|
+
it('should detect UTF-8 BOM', () => {
|
|
153
|
+
const buf = Buffer.from([
|
|
154
|
+
0xef, 0xbb, 0xbf, 0x48, 0x65, 0x6c, 0x6c, 0x6f,
|
|
155
|
+
]);
|
|
156
|
+
const result = detectBOM(buf);
|
|
157
|
+
expect(result).toEqual({ encoding: 'utf8', bomLength: 3 });
|
|
158
|
+
});
|
|
159
|
+
it('should detect UTF-16 LE BOM', () => {
|
|
160
|
+
const buf = Buffer.from([0xff, 0xfe, 0x48, 0x00, 0x65, 0x00]);
|
|
161
|
+
const result = detectBOM(buf);
|
|
162
|
+
expect(result).toEqual({ encoding: 'utf16le', bomLength: 2 });
|
|
163
|
+
});
|
|
164
|
+
it('should detect UTF-16 BE BOM', () => {
|
|
165
|
+
const buf = Buffer.from([0xfe, 0xff, 0x00, 0x48, 0x00, 0x65]);
|
|
166
|
+
const result = detectBOM(buf);
|
|
167
|
+
expect(result).toEqual({ encoding: 'utf16be', bomLength: 2 });
|
|
168
|
+
});
|
|
169
|
+
it('should detect UTF-32 LE BOM', () => {
|
|
170
|
+
const buf = Buffer.from([
|
|
171
|
+
0xff, 0xfe, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
|
|
172
|
+
]);
|
|
173
|
+
const result = detectBOM(buf);
|
|
174
|
+
expect(result).toEqual({ encoding: 'utf32le', bomLength: 4 });
|
|
175
|
+
});
|
|
176
|
+
it('should detect UTF-32 BE BOM', () => {
|
|
177
|
+
const buf = Buffer.from([
|
|
178
|
+
0x00, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x48,
|
|
179
|
+
]);
|
|
180
|
+
const result = detectBOM(buf);
|
|
181
|
+
expect(result).toEqual({ encoding: 'utf32be', bomLength: 4 });
|
|
182
|
+
});
|
|
183
|
+
it('should return null for no BOM', () => {
|
|
184
|
+
const buf = Buffer.from([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
|
|
185
|
+
const result = detectBOM(buf);
|
|
186
|
+
expect(result).toBeNull();
|
|
187
|
+
});
|
|
188
|
+
it('should return null for empty buffer', () => {
|
|
189
|
+
const buf = Buffer.alloc(0);
|
|
190
|
+
const result = detectBOM(buf);
|
|
191
|
+
expect(result).toBeNull();
|
|
192
|
+
});
|
|
193
|
+
it('should return null for partial BOM', () => {
|
|
194
|
+
const buf = Buffer.from([0xef, 0xbb]); // Incomplete UTF-8 BOM
|
|
195
|
+
const result = detectBOM(buf);
|
|
196
|
+
expect(result).toBeNull();
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
describe('readFileWithEncoding', () => {
|
|
200
|
+
it('should read UTF-8 BOM file correctly', async () => {
|
|
201
|
+
const content = 'Hello, 世界! 🌍';
|
|
202
|
+
const utf8Bom = Buffer.from([0xef, 0xbb, 0xbf]);
|
|
203
|
+
const utf8Content = Buffer.from(content, 'utf8');
|
|
204
|
+
const fullBuffer = Buffer.concat([utf8Bom, utf8Content]);
|
|
205
|
+
const filePath = path.join(testDir, 'utf8-bom.txt');
|
|
206
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
207
|
+
const result = await readFileWithEncoding(filePath);
|
|
208
|
+
expect(result).toBe(content);
|
|
209
|
+
});
|
|
210
|
+
it('should read UTF-16 LE BOM file correctly', async () => {
|
|
211
|
+
const content = 'Hello, 世界! 🌍';
|
|
212
|
+
const utf16leBom = Buffer.from([0xff, 0xfe]);
|
|
213
|
+
const utf16leContent = Buffer.from(content, 'utf16le');
|
|
214
|
+
const fullBuffer = Buffer.concat([utf16leBom, utf16leContent]);
|
|
215
|
+
const filePath = path.join(testDir, 'utf16le-bom.txt');
|
|
216
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
217
|
+
const result = await readFileWithEncoding(filePath);
|
|
218
|
+
expect(result).toBe(content);
|
|
219
|
+
});
|
|
220
|
+
it('should read UTF-16 BE BOM file correctly', async () => {
|
|
221
|
+
const content = 'Hello, 世界! 🌍';
|
|
222
|
+
// Manually encode UTF-16 BE: each char as big-endian 16-bit
|
|
223
|
+
const utf16beBom = Buffer.from([0xfe, 0xff]);
|
|
224
|
+
const chars = Array.from(content);
|
|
225
|
+
const utf16beBytes = [];
|
|
226
|
+
for (const char of chars) {
|
|
227
|
+
const code = char.codePointAt(0);
|
|
228
|
+
if (code > 0xffff) {
|
|
229
|
+
// Surrogate pair for emoji
|
|
230
|
+
const surrogate1 = 0xd800 + ((code - 0x10000) >> 10);
|
|
231
|
+
const surrogate2 = 0xdc00 + ((code - 0x10000) & 0x3ff);
|
|
232
|
+
utf16beBytes.push((surrogate1 >> 8) & 0xff, surrogate1 & 0xff);
|
|
233
|
+
utf16beBytes.push((surrogate2 >> 8) & 0xff, surrogate2 & 0xff);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
utf16beBytes.push((code >> 8) & 0xff, code & 0xff);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const utf16beContent = Buffer.from(utf16beBytes);
|
|
240
|
+
const fullBuffer = Buffer.concat([utf16beBom, utf16beContent]);
|
|
241
|
+
const filePath = path.join(testDir, 'utf16be-bom.txt');
|
|
242
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
243
|
+
const result = await readFileWithEncoding(filePath);
|
|
244
|
+
expect(result).toBe(content);
|
|
245
|
+
});
|
|
246
|
+
it('should read UTF-32 LE BOM file correctly', async () => {
|
|
247
|
+
const content = 'Hello, 世界! 🌍';
|
|
248
|
+
const utf32leBom = Buffer.from([0xff, 0xfe, 0x00, 0x00]);
|
|
249
|
+
const utf32leBytes = [];
|
|
250
|
+
for (const char of Array.from(content)) {
|
|
251
|
+
const code = char.codePointAt(0);
|
|
252
|
+
utf32leBytes.push(code & 0xff, (code >> 8) & 0xff, (code >> 16) & 0xff, (code >> 24) & 0xff);
|
|
253
|
+
}
|
|
254
|
+
const utf32leContent = Buffer.from(utf32leBytes);
|
|
255
|
+
const fullBuffer = Buffer.concat([utf32leBom, utf32leContent]);
|
|
256
|
+
const filePath = path.join(testDir, 'utf32le-bom.txt');
|
|
257
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
258
|
+
const result = await readFileWithEncoding(filePath);
|
|
259
|
+
expect(result).toBe(content);
|
|
260
|
+
});
|
|
261
|
+
it('should read UTF-32 BE BOM file correctly', async () => {
|
|
262
|
+
const content = 'Hello, 世界! 🌍';
|
|
263
|
+
const utf32beBom = Buffer.from([0x00, 0x00, 0xfe, 0xff]);
|
|
264
|
+
const utf32beBytes = [];
|
|
265
|
+
for (const char of Array.from(content)) {
|
|
266
|
+
const code = char.codePointAt(0);
|
|
267
|
+
utf32beBytes.push((code >> 24) & 0xff, (code >> 16) & 0xff, (code >> 8) & 0xff, code & 0xff);
|
|
268
|
+
}
|
|
269
|
+
const utf32beContent = Buffer.from(utf32beBytes);
|
|
270
|
+
const fullBuffer = Buffer.concat([utf32beBom, utf32beContent]);
|
|
271
|
+
const filePath = path.join(testDir, 'utf32be-bom.txt');
|
|
272
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
273
|
+
const result = await readFileWithEncoding(filePath);
|
|
274
|
+
expect(result).toBe(content);
|
|
275
|
+
});
|
|
276
|
+
it('should read file without BOM as UTF-8', async () => {
|
|
277
|
+
const content = 'Hello, 世界!';
|
|
278
|
+
const filePath = path.join(testDir, 'no-bom.txt');
|
|
279
|
+
await fsPromises.writeFile(filePath, content, 'utf8');
|
|
280
|
+
const result = await readFileWithEncoding(filePath);
|
|
281
|
+
expect(result).toBe(content);
|
|
282
|
+
});
|
|
283
|
+
it('should handle empty file', async () => {
|
|
284
|
+
const filePath = path.join(testDir, 'empty.txt');
|
|
285
|
+
await fsPromises.writeFile(filePath, '');
|
|
286
|
+
const result = await readFileWithEncoding(filePath);
|
|
287
|
+
expect(result).toBe('');
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
describe('isBinaryFile with BOM awareness', () => {
|
|
291
|
+
it('should not treat UTF-8 BOM file as binary', async () => {
|
|
292
|
+
const content = 'Hello, world!';
|
|
293
|
+
const utf8Bom = Buffer.from([0xef, 0xbb, 0xbf]);
|
|
294
|
+
const utf8Content = Buffer.from(content, 'utf8');
|
|
295
|
+
const fullBuffer = Buffer.concat([utf8Bom, utf8Content]);
|
|
296
|
+
const filePath = path.join(testDir, 'utf8-bom-test.txt');
|
|
297
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
298
|
+
const result = await isBinaryFile(filePath);
|
|
299
|
+
expect(result).toBe(false);
|
|
300
|
+
});
|
|
301
|
+
it('should not treat UTF-16 LE BOM file as binary', async () => {
|
|
302
|
+
const content = 'Hello, world!';
|
|
303
|
+
const utf16leBom = Buffer.from([0xff, 0xfe]);
|
|
304
|
+
const utf16leContent = Buffer.from(content, 'utf16le');
|
|
305
|
+
const fullBuffer = Buffer.concat([utf16leBom, utf16leContent]);
|
|
306
|
+
const filePath = path.join(testDir, 'utf16le-bom-test.txt');
|
|
307
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
308
|
+
const result = await isBinaryFile(filePath);
|
|
309
|
+
expect(result).toBe(false);
|
|
310
|
+
});
|
|
311
|
+
it('should not treat UTF-16 BE BOM file as binary', async () => {
|
|
312
|
+
const utf16beBom = Buffer.from([0xfe, 0xff]);
|
|
313
|
+
// Simple ASCII in UTF-16 BE
|
|
314
|
+
const utf16beContent = Buffer.from([
|
|
315
|
+
0x00,
|
|
316
|
+
0x48, // H
|
|
317
|
+
0x00,
|
|
318
|
+
0x65, // e
|
|
319
|
+
0x00,
|
|
320
|
+
0x6c, // l
|
|
321
|
+
0x00,
|
|
322
|
+
0x6c, // l
|
|
323
|
+
0x00,
|
|
324
|
+
0x6f, // o
|
|
325
|
+
0x00,
|
|
326
|
+
0x2c, // ,
|
|
327
|
+
0x00,
|
|
328
|
+
0x20, // space
|
|
329
|
+
0x00,
|
|
330
|
+
0x77, // w
|
|
331
|
+
0x00,
|
|
332
|
+
0x6f, // o
|
|
333
|
+
0x00,
|
|
334
|
+
0x72, // r
|
|
335
|
+
0x00,
|
|
336
|
+
0x6c, // l
|
|
337
|
+
0x00,
|
|
338
|
+
0x64, // d
|
|
339
|
+
0x00,
|
|
340
|
+
0x21, // !
|
|
341
|
+
]);
|
|
342
|
+
const fullBuffer = Buffer.concat([utf16beBom, utf16beContent]);
|
|
343
|
+
const filePath = path.join(testDir, 'utf16be-bom-test.txt');
|
|
344
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
345
|
+
const result = await isBinaryFile(filePath);
|
|
346
|
+
expect(result).toBe(false);
|
|
347
|
+
});
|
|
348
|
+
it('should not treat UTF-32 LE BOM file as binary', async () => {
|
|
349
|
+
const utf32leBom = Buffer.from([0xff, 0xfe, 0x00, 0x00]);
|
|
350
|
+
const utf32leContent = Buffer.from([
|
|
351
|
+
0x48,
|
|
352
|
+
0x00,
|
|
353
|
+
0x00,
|
|
354
|
+
0x00, // H
|
|
355
|
+
0x65,
|
|
356
|
+
0x00,
|
|
357
|
+
0x00,
|
|
358
|
+
0x00, // e
|
|
359
|
+
0x6c,
|
|
360
|
+
0x00,
|
|
361
|
+
0x00,
|
|
362
|
+
0x00, // l
|
|
363
|
+
0x6c,
|
|
364
|
+
0x00,
|
|
365
|
+
0x00,
|
|
366
|
+
0x00, // l
|
|
367
|
+
0x6f,
|
|
368
|
+
0x00,
|
|
369
|
+
0x00,
|
|
370
|
+
0x00, // o
|
|
371
|
+
]);
|
|
372
|
+
const fullBuffer = Buffer.concat([utf32leBom, utf32leContent]);
|
|
373
|
+
const filePath = path.join(testDir, 'utf32le-bom-test.txt');
|
|
374
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
375
|
+
const result = await isBinaryFile(filePath);
|
|
376
|
+
expect(result).toBe(false);
|
|
377
|
+
});
|
|
378
|
+
it('should not treat UTF-32 BE BOM file as binary', async () => {
|
|
379
|
+
const utf32beBom = Buffer.from([0x00, 0x00, 0xfe, 0xff]);
|
|
380
|
+
const utf32beContent = Buffer.from([
|
|
381
|
+
0x00,
|
|
382
|
+
0x00,
|
|
383
|
+
0x00,
|
|
384
|
+
0x48, // H
|
|
385
|
+
0x00,
|
|
386
|
+
0x00,
|
|
387
|
+
0x00,
|
|
388
|
+
0x65, // e
|
|
389
|
+
0x00,
|
|
390
|
+
0x00,
|
|
391
|
+
0x00,
|
|
392
|
+
0x6c, // l
|
|
393
|
+
0x00,
|
|
394
|
+
0x00,
|
|
395
|
+
0x00,
|
|
396
|
+
0x6c, // l
|
|
397
|
+
0x00,
|
|
398
|
+
0x00,
|
|
399
|
+
0x00,
|
|
400
|
+
0x6f, // o
|
|
401
|
+
]);
|
|
402
|
+
const fullBuffer = Buffer.concat([utf32beBom, utf32beContent]);
|
|
403
|
+
const filePath = path.join(testDir, 'utf32be-bom-test.txt');
|
|
404
|
+
await fsPromises.writeFile(filePath, fullBuffer);
|
|
405
|
+
const result = await isBinaryFile(filePath);
|
|
406
|
+
expect(result).toBe(false);
|
|
407
|
+
});
|
|
408
|
+
it('should still treat actual binary file as binary', async () => {
|
|
409
|
+
// PNG header + some binary data with null bytes
|
|
410
|
+
const pngHeader = Buffer.from([
|
|
411
|
+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
|
|
412
|
+
]);
|
|
413
|
+
const binaryData = Buffer.from([
|
|
414
|
+
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
|
415
|
+
]); // IHDR chunk with nulls
|
|
416
|
+
const fullContent = Buffer.concat([pngHeader, binaryData]);
|
|
417
|
+
const filePath = path.join(testDir, 'test.png');
|
|
418
|
+
await fsPromises.writeFile(filePath, fullContent);
|
|
419
|
+
const result = await isBinaryFile(filePath);
|
|
420
|
+
expect(result).toBe(true);
|
|
421
|
+
});
|
|
422
|
+
it('should treat file with null bytes (no BOM) as binary', async () => {
|
|
423
|
+
const content = Buffer.from([
|
|
424
|
+
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x77, 0x6f, 0x72, 0x6c, 0x64,
|
|
425
|
+
]);
|
|
426
|
+
const filePath = path.join(testDir, 'null-bytes.bin');
|
|
427
|
+
await fsPromises.writeFile(filePath, content);
|
|
428
|
+
const result = await isBinaryFile(filePath);
|
|
429
|
+
expect(result).toBe(true);
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
describe('detectFileType', () => {
|
|
434
|
+
let filePathForDetectTest;
|
|
435
|
+
beforeEach(() => {
|
|
436
|
+
filePathForDetectTest = path.join(tempRootDir, 'detectType.tmp');
|
|
437
|
+
// Default: create as a text file for isBinaryFile fallback
|
|
438
|
+
actualNodeFs.writeFileSync(filePathForDetectTest, 'Plain text content');
|
|
439
|
+
});
|
|
440
|
+
afterEach(() => {
|
|
441
|
+
if (actualNodeFs.existsSync(filePathForDetectTest)) {
|
|
442
|
+
actualNodeFs.unlinkSync(filePathForDetectTest);
|
|
443
|
+
}
|
|
444
|
+
vi.restoreAllMocks(); // Restore spies on actualNodeFs
|
|
445
|
+
});
|
|
446
|
+
it('should detect typescript type by extension (ts, mts, cts, tsx)', async () => {
|
|
447
|
+
expect(await detectFileType('file.ts')).toBe('text');
|
|
448
|
+
expect(await detectFileType('file.test.ts')).toBe('text');
|
|
449
|
+
expect(await detectFileType('file.mts')).toBe('text');
|
|
450
|
+
expect(await detectFileType('vite.config.mts')).toBe('text');
|
|
451
|
+
expect(await detectFileType('file.cts')).toBe('text');
|
|
452
|
+
expect(await detectFileType('component.tsx')).toBe('text');
|
|
453
|
+
});
|
|
454
|
+
it('should detect image type by extension (png)', async () => {
|
|
455
|
+
mockMimeGetType.mockReturnValueOnce('image/png');
|
|
456
|
+
expect(await detectFileType('file.png')).toBe('image');
|
|
457
|
+
});
|
|
458
|
+
it('should detect image type by extension (jpeg)', async () => {
|
|
459
|
+
mockMimeGetType.mockReturnValueOnce('image/jpeg');
|
|
460
|
+
expect(await detectFileType('file.jpg')).toBe('image');
|
|
461
|
+
});
|
|
462
|
+
it('should detect svg type by extension', async () => {
|
|
463
|
+
expect(await detectFileType('image.svg')).toBe('svg');
|
|
464
|
+
expect(await detectFileType('image.icon.svg')).toBe('svg');
|
|
465
|
+
});
|
|
466
|
+
it('should detect pdf type by extension', async () => {
|
|
467
|
+
mockMimeGetType.mockReturnValueOnce('application/pdf');
|
|
468
|
+
expect(await detectFileType('file.pdf')).toBe('pdf');
|
|
469
|
+
});
|
|
470
|
+
it('should detect audio type by extension', async () => {
|
|
471
|
+
mockMimeGetType.mockReturnValueOnce('audio/mpeg');
|
|
472
|
+
expect(await detectFileType('song.mp3')).toBe('audio');
|
|
473
|
+
});
|
|
474
|
+
it('should detect video type by extension', async () => {
|
|
475
|
+
mockMimeGetType.mockReturnValueOnce('video/mp4');
|
|
476
|
+
expect(await detectFileType('movie.mp4')).toBe('video');
|
|
477
|
+
});
|
|
478
|
+
it('should detect known binary extensions as binary (e.g. .zip)', async () => {
|
|
479
|
+
mockMimeGetType.mockReturnValueOnce('application/zip');
|
|
480
|
+
expect(await detectFileType('archive.zip')).toBe('binary');
|
|
481
|
+
});
|
|
482
|
+
it('should detect known binary extensions as binary (e.g. .exe)', async () => {
|
|
483
|
+
mockMimeGetType.mockReturnValueOnce('application/octet-stream'); // Common for .exe
|
|
484
|
+
expect(await detectFileType('app.exe')).toBe('binary');
|
|
485
|
+
});
|
|
486
|
+
it('should use isBinaryFile for unknown extensions and detect as binary', async () => {
|
|
487
|
+
mockMimeGetType.mockReturnValueOnce(false); // Unknown mime type
|
|
488
|
+
// Create a file that isBinaryFile will identify as binary
|
|
489
|
+
const binaryContent = Buffer.from([
|
|
490
|
+
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
|
|
491
|
+
]);
|
|
492
|
+
actualNodeFs.writeFileSync(filePathForDetectTest, binaryContent);
|
|
493
|
+
expect(await detectFileType(filePathForDetectTest)).toBe('binary');
|
|
494
|
+
});
|
|
495
|
+
it('should default to text if mime type is unknown and content is not binary', async () => {
|
|
496
|
+
mockMimeGetType.mockReturnValueOnce(false); // Unknown mime type
|
|
497
|
+
// filePathForDetectTest is already a text file by default from beforeEach
|
|
498
|
+
expect(await detectFileType(filePathForDetectTest)).toBe('text');
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
describe('processSingleFileContent', () => {
|
|
502
|
+
beforeEach(() => {
|
|
503
|
+
// Ensure files exist for statSync checks before readFile might be mocked
|
|
504
|
+
if (actualNodeFs.existsSync(testTextFilePath))
|
|
505
|
+
actualNodeFs.unlinkSync(testTextFilePath);
|
|
506
|
+
if (actualNodeFs.existsSync(testImageFilePath))
|
|
507
|
+
actualNodeFs.unlinkSync(testImageFilePath);
|
|
508
|
+
if (actualNodeFs.existsSync(testPdfFilePath))
|
|
509
|
+
actualNodeFs.unlinkSync(testPdfFilePath);
|
|
510
|
+
if (actualNodeFs.existsSync(testBinaryFilePath))
|
|
511
|
+
actualNodeFs.unlinkSync(testBinaryFilePath);
|
|
512
|
+
});
|
|
513
|
+
it('should read a text file successfully', async () => {
|
|
514
|
+
const content = 'Line 1\\nLine 2\\nLine 3';
|
|
515
|
+
actualNodeFs.writeFileSync(testTextFilePath, content);
|
|
516
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService());
|
|
517
|
+
expect(result.llmContent).toBe(content);
|
|
518
|
+
expect(result.returnDisplay).toBe('');
|
|
519
|
+
expect(result.error).toBeUndefined();
|
|
520
|
+
});
|
|
521
|
+
it('should handle file not found', async () => {
|
|
522
|
+
const result = await processSingleFileContent(nonexistentFilePath, tempRootDir, new StandardFileSystemService());
|
|
523
|
+
expect(result.error).toContain('File not found');
|
|
524
|
+
expect(result.returnDisplay).toContain('File not found');
|
|
525
|
+
});
|
|
526
|
+
it('should handle read errors for text files', async () => {
|
|
527
|
+
actualNodeFs.writeFileSync(testTextFilePath, 'content'); // File must exist for initial statSync
|
|
528
|
+
const readError = new Error('Simulated read error');
|
|
529
|
+
vi.spyOn(fsPromises, 'readFile').mockRejectedValueOnce(readError);
|
|
530
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService());
|
|
531
|
+
expect(result.error).toContain('Simulated read error');
|
|
532
|
+
expect(result.returnDisplay).toContain('Simulated read error');
|
|
533
|
+
});
|
|
534
|
+
it('should handle read errors for image/pdf files', async () => {
|
|
535
|
+
actualNodeFs.writeFileSync(testImageFilePath, 'content'); // File must exist
|
|
536
|
+
mockMimeGetType.mockReturnValue('image/png');
|
|
537
|
+
const readError = new Error('Simulated image read error');
|
|
538
|
+
vi.spyOn(fsPromises, 'readFile').mockRejectedValueOnce(readError);
|
|
539
|
+
const result = await processSingleFileContent(testImageFilePath, tempRootDir, new StandardFileSystemService());
|
|
540
|
+
expect(result.error).toContain('Simulated image read error');
|
|
541
|
+
expect(result.returnDisplay).toContain('Simulated image read error');
|
|
542
|
+
});
|
|
543
|
+
it('should process an image file', async () => {
|
|
544
|
+
const fakePngData = Buffer.from('fake png data');
|
|
545
|
+
actualNodeFs.writeFileSync(testImageFilePath, fakePngData);
|
|
546
|
+
mockMimeGetType.mockReturnValue('image/png');
|
|
547
|
+
const result = await processSingleFileContent(testImageFilePath, tempRootDir, new StandardFileSystemService());
|
|
548
|
+
expect(result.llmContent.inlineData).toBeDefined();
|
|
549
|
+
expect(result.llmContent.inlineData
|
|
550
|
+
.mimeType).toBe('image/png');
|
|
551
|
+
expect(result.llmContent.inlineData.data).toBe(fakePngData.toString('base64'));
|
|
552
|
+
expect(result.returnDisplay).toContain('Read image file: image.png');
|
|
553
|
+
});
|
|
554
|
+
it('should process a PDF file', async () => {
|
|
555
|
+
const fakePdfData = Buffer.from('fake pdf data');
|
|
556
|
+
actualNodeFs.writeFileSync(testPdfFilePath, fakePdfData);
|
|
557
|
+
mockMimeGetType.mockReturnValue('application/pdf');
|
|
558
|
+
const result = await processSingleFileContent(testPdfFilePath, tempRootDir, new StandardFileSystemService());
|
|
559
|
+
expect(result.llmContent.inlineData).toBeDefined();
|
|
560
|
+
expect(result.llmContent.inlineData
|
|
561
|
+
.mimeType).toBe('application/pdf');
|
|
562
|
+
expect(result.llmContent.inlineData.data).toBe(fakePdfData.toString('base64'));
|
|
563
|
+
expect(result.returnDisplay).toContain('Read pdf file: document.pdf');
|
|
564
|
+
});
|
|
565
|
+
it('should read an SVG file as text when under 1MB', async () => {
|
|
566
|
+
const svgContent = `
|
|
567
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
|
|
568
|
+
<rect width="100" height="100" fill="blue" />
|
|
569
|
+
</svg>
|
|
570
|
+
`;
|
|
571
|
+
const testSvgFilePath = path.join(tempRootDir, 'test.svg');
|
|
572
|
+
actualNodeFs.writeFileSync(testSvgFilePath, svgContent, 'utf-8');
|
|
573
|
+
mockMimeGetType.mockReturnValue('image/svg+xml');
|
|
574
|
+
const result = await processSingleFileContent(testSvgFilePath, tempRootDir, new StandardFileSystemService());
|
|
575
|
+
expect(result.llmContent).toBe(svgContent);
|
|
576
|
+
expect(result.returnDisplay).toContain('Read SVG as text');
|
|
577
|
+
});
|
|
578
|
+
it('should skip binary files', async () => {
|
|
579
|
+
actualNodeFs.writeFileSync(testBinaryFilePath, Buffer.from([0x00, 0x01, 0x02]));
|
|
580
|
+
mockMimeGetType.mockReturnValueOnce('application/octet-stream');
|
|
581
|
+
// isBinaryFile will operate on the real file.
|
|
582
|
+
const result = await processSingleFileContent(testBinaryFilePath, tempRootDir, new StandardFileSystemService());
|
|
583
|
+
expect(result.llmContent).toContain('Cannot display content of binary file');
|
|
584
|
+
expect(result.returnDisplay).toContain('Skipped binary file: app.exe');
|
|
585
|
+
});
|
|
586
|
+
it('should handle path being a directory', async () => {
|
|
587
|
+
const result = await processSingleFileContent(directoryPath, tempRootDir, new StandardFileSystemService());
|
|
588
|
+
expect(result.error).toContain('Path is a directory');
|
|
589
|
+
expect(result.returnDisplay).toContain('Path is a directory');
|
|
590
|
+
});
|
|
591
|
+
it('should paginate text files correctly (offset and limit)', async () => {
|
|
592
|
+
const lines = Array.from({ length: 20 }, (_, i) => `Line ${i + 1}`);
|
|
593
|
+
actualNodeFs.writeFileSync(testTextFilePath, lines.join('\n'));
|
|
594
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService(), 5, 5); // Read lines 6-10
|
|
595
|
+
const expectedContent = lines.slice(5, 10).join('\n');
|
|
596
|
+
expect(result.llmContent).toBe(expectedContent);
|
|
597
|
+
expect(result.returnDisplay).toBe('Read lines 6-10 of 20 from test.txt');
|
|
598
|
+
expect(result.isTruncated).toBe(true);
|
|
599
|
+
expect(result.originalLineCount).toBe(20);
|
|
600
|
+
expect(result.linesShown).toEqual([6, 10]);
|
|
601
|
+
});
|
|
602
|
+
it('should identify truncation when reading the end of a file', async () => {
|
|
603
|
+
const lines = Array.from({ length: 20 }, (_, i) => `Line ${i + 1}`);
|
|
604
|
+
actualNodeFs.writeFileSync(testTextFilePath, lines.join('\n'));
|
|
605
|
+
// Read from line 11 to 20. The start is not 0, so it's truncated.
|
|
606
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService(), 10, 10);
|
|
607
|
+
const expectedContent = lines.slice(10, 20).join('\n');
|
|
608
|
+
expect(result.llmContent).toContain(expectedContent);
|
|
609
|
+
expect(result.returnDisplay).toBe('Read lines 11-20 of 20 from test.txt');
|
|
610
|
+
expect(result.isTruncated).toBe(true); // This is the key check for the bug
|
|
611
|
+
expect(result.originalLineCount).toBe(20);
|
|
612
|
+
expect(result.linesShown).toEqual([11, 20]);
|
|
613
|
+
});
|
|
614
|
+
it('should handle limit exceeding file length', async () => {
|
|
615
|
+
const lines = ['Line 1', 'Line 2'];
|
|
616
|
+
actualNodeFs.writeFileSync(testTextFilePath, lines.join('\n'));
|
|
617
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService(), 0, 10);
|
|
618
|
+
const expectedContent = lines.join('\n');
|
|
619
|
+
expect(result.llmContent).toBe(expectedContent);
|
|
620
|
+
expect(result.returnDisplay).toBe('');
|
|
621
|
+
expect(result.isTruncated).toBe(false);
|
|
622
|
+
expect(result.originalLineCount).toBe(2);
|
|
623
|
+
expect(result.linesShown).toEqual([1, 2]);
|
|
624
|
+
});
|
|
625
|
+
it('should truncate long lines in text files', async () => {
|
|
626
|
+
const longLine = 'a'.repeat(2500);
|
|
627
|
+
actualNodeFs.writeFileSync(testTextFilePath, `Short line\n${longLine}\nAnother short line`);
|
|
628
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService());
|
|
629
|
+
expect(result.llmContent).toContain('Short line');
|
|
630
|
+
expect(result.llmContent).toContain(longLine.substring(0, 2000) + '... [truncated]');
|
|
631
|
+
expect(result.llmContent).toContain('Another short line');
|
|
632
|
+
expect(result.returnDisplay).toBe('Read all 3 lines from test.txt (some lines were shortened)');
|
|
633
|
+
expect(result.isTruncated).toBe(true);
|
|
634
|
+
});
|
|
635
|
+
it('should truncate when line count exceeds the limit', async () => {
|
|
636
|
+
const lines = Array.from({ length: 11 }, (_, i) => `Line ${i + 1}`);
|
|
637
|
+
actualNodeFs.writeFileSync(testTextFilePath, lines.join('\n'));
|
|
638
|
+
// Read 5 lines, but there are 11 total
|
|
639
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService(), 0, 5);
|
|
640
|
+
expect(result.isTruncated).toBe(true);
|
|
641
|
+
expect(result.returnDisplay).toBe('Read lines 1-5 of 11 from test.txt');
|
|
642
|
+
});
|
|
643
|
+
it('should truncate when a line length exceeds the character limit', async () => {
|
|
644
|
+
const longLine = 'b'.repeat(2500);
|
|
645
|
+
const lines = Array.from({ length: 10 }, (_, i) => `Line ${i + 1}`);
|
|
646
|
+
lines.push(longLine); // Total 11 lines
|
|
647
|
+
actualNodeFs.writeFileSync(testTextFilePath, lines.join('\n'));
|
|
648
|
+
// Read all 11 lines, including the long one
|
|
649
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService(), 0, 11);
|
|
650
|
+
expect(result.isTruncated).toBe(true);
|
|
651
|
+
expect(result.returnDisplay).toBe('Read all 11 lines from test.txt (some lines were shortened)');
|
|
652
|
+
});
|
|
653
|
+
it('should truncate both line count and line length when both exceed limits', async () => {
|
|
654
|
+
const linesWithLongInMiddle = Array.from({ length: 20 }, (_, i) => `Line ${i + 1}`);
|
|
655
|
+
linesWithLongInMiddle[4] = 'c'.repeat(2500);
|
|
656
|
+
actualNodeFs.writeFileSync(testTextFilePath, linesWithLongInMiddle.join('\n'));
|
|
657
|
+
// Read 10 lines out of 20, including the long line
|
|
658
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService(), 0, 10);
|
|
659
|
+
expect(result.isTruncated).toBe(true);
|
|
660
|
+
expect(result.returnDisplay).toBe('Read lines 1-10 of 20 from test.txt (some lines were shortened)');
|
|
661
|
+
});
|
|
662
|
+
it('should return an error if the file size exceeds 20MB', async () => {
|
|
663
|
+
// Create a small test file
|
|
664
|
+
actualNodeFs.writeFileSync(testTextFilePath, 'test content');
|
|
665
|
+
// Spy on fs.promises.stat to return a large file size
|
|
666
|
+
const statSpy = vi.spyOn(fs.promises, 'stat').mockResolvedValueOnce({
|
|
667
|
+
size: 21 * 1024 * 1024,
|
|
668
|
+
isDirectory: () => false,
|
|
669
|
+
});
|
|
670
|
+
try {
|
|
671
|
+
const result = await processSingleFileContent(testTextFilePath, tempRootDir, new StandardFileSystemService());
|
|
672
|
+
expect(result.error).toContain('File size exceeds the 20MB limit');
|
|
673
|
+
expect(result.returnDisplay).toContain('File size exceeds the 20MB limit');
|
|
674
|
+
expect(result.llmContent).toContain('File size exceeds the 20MB limit');
|
|
675
|
+
}
|
|
676
|
+
finally {
|
|
677
|
+
statSpy.mockRestore();
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
//# sourceMappingURL=fileUtils.test.js.map
|