@vybestack/llxprt-code-core 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.last_build +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -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 +9 -0
- package/dist/src/code_assist/codeAssist.js +19 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +68 -0
- package/dist/src/code_assist/converter.js +125 -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 +229 -0
- package/dist/src/code_assist/converter.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +20 -0
- package/dist/src/code_assist/oauth2.js +339 -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 +249 -0
- package/dist/src/code_assist/oauth2.test.js.map +1 -0
- package/dist/src/code_assist/server.d.ts +39 -0
- package/dist/src/code_assist/server.js +191 -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 +123 -0
- package/dist/src/code_assist/server.test.js.map +1 -0
- package/dist/src/code_assist/setup.d.ts +15 -0
- package/dist/src/code_assist/setup.js +67 -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 +62 -0
- package/dist/src/code_assist/setup.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +148 -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 +212 -0
- package/dist/src/config/config.js +454 -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 +291 -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 +115 -0
- package/dist/src/config/flashFallback.test.js.map +1 -0
- package/dist/src/config/models.d.ts +8 -0
- package/dist/src/config/models.js +9 -0
- package/dist/src/config/models.js.map +1 -0
- package/dist/src/core/client.d.ts +59 -0
- package/dist/src/core/client.js +503 -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 +1006 -0
- package/dist/src/core/client.test.js.map +1 -0
- package/dist/src/core/contentGenerator.d.ts +36 -0
- package/dist/src/core/contentGenerator.js +79 -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 +92 -0
- package/dist/src/core/contentGenerator.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +104 -0
- package/dist/src/core/coreToolScheduler.js +413 -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 +347 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +116 -0
- package/dist/src/core/geminiChat.js +513 -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 +424 -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 +45 -0
- package/dist/src/core/geminiRequest.js.map +1 -0
- package/dist/src/core/geminiRequest.test.d.ts +6 -0
- package/dist/src/core/geminiRequest.test.js +72 -0
- package/dist/src/core/geminiRequest.test.js.map +1 -0
- package/dist/src/core/logger.d.ts +38 -0
- package/dist/src/core/logger.js +237 -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 +387 -0
- package/dist/src/core/logger.test.js.map +1 -0
- package/dist/src/core/modelCheck.d.ts +14 -0
- package/dist/src/core/modelCheck.js +55 -0
- package/dist/src/core/modelCheck.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +12 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +93 -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 +180 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -0
- package/dist/src/core/prompts.d.ts +12 -0
- package/dist/src/core/prompts.js +418 -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 +97 -0
- package/dist/src/core/prompts.test.js.map +1 -0
- package/dist/src/core/tokenLimits.d.ts +10 -0
- package/dist/src/core/tokenLimits.js +75 -0
- package/dist/src/core/tokenLimits.js.map +1 -0
- package/dist/src/core/tokenLimits.test.d.ts +6 -0
- package/dist/src/core/tokenLimits.test.js +66 -0
- package/dist/src/core/tokenLimits.test.js.map +1 -0
- package/dist/src/core/turn.d.ts +116 -0
- package/dist/src/core/turn.js +131 -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 +237 -0
- package/dist/src/core/turn.test.js.map +1 -0
- package/dist/src/index.d.ts +57 -0
- package/dist/src/index.js +64 -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/providers/ProviderContentGenerator.d.ts +21 -0
- package/dist/src/providers/ProviderContentGenerator.js +52 -0
- package/dist/src/providers/ProviderContentGenerator.js.map +1 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.d.ts +68 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.js +549 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.js.map +1 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.d.ts +6 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js +253 -0
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js.map +1 -0
- package/dist/src/providers/types.d.ts +82 -0
- package/dist/src/providers/types.js +7 -0
- package/dist/src/providers/types.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.d.ts +35 -0
- package/dist/src/services/fileDiscoveryService.js +91 -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 +102 -0
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -0
- package/dist/src/services/gitService.d.ts +21 -0
- package/dist/src/services/gitService.js +102 -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 +246 -0
- package/dist/src/services/gitService.test.js.map +1 -0
- package/dist/src/services/ideContext.d.ts +124 -0
- package/dist/src/services/ideContext.js +90 -0
- package/dist/src/services/ideContext.js.map +1 -0
- package/dist/src/services/ideContext.test.d.ts +6 -0
- package/dist/src/services/ideContext.test.js +101 -0
- package/dist/src/services/ideContext.test.js.map +1 -0
- package/dist/src/services/loopDetectionService.d.ts +35 -0
- package/dist/src/services/loopDetectionService.js +117 -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 +232 -0
- package/dist/src/services/loopDetectionService.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +35 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +424 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +47 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +123 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +20 -0
- package/dist/src/telemetry/constants.js +21 -0
- package/dist/src/telemetry/constants.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +18 -0
- package/dist/src/telemetry/index.js +20 -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 +53 -0
- package/dist/src/telemetry/integration.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +15 -0
- package/dist/src/telemetry/loggers.js +229 -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 +100 -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 +558 -0
- package/dist/src/telemetry/loggers.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +19 -0
- package/dist/src/telemetry/metrics.js +144 -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 +162 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +9 -0
- package/dist/src/telemetry/sdk.js +120 -0
- package/dist/src/telemetry/sdk.js.map +1 -0
- package/dist/src/telemetry/telemetry.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry.test.js +52 -0
- package/dist/src/telemetry/telemetry.test.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +115 -0
- package/dist/src/telemetry/types.js +217 -0
- package/dist/src/telemetry/types.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.d.ts +67 -0
- package/dist/src/telemetry/uiTelemetry.js +131 -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 +412 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +7 -0
- package/dist/src/tools/diffOptions.js +10 -0
- package/dist/src/tools/diffOptions.js.map +1 -0
- package/dist/src/tools/edit.d.ts +73 -0
- package/dist/src/tools/edit.js +343 -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 +500 -0
- package/dist/src/tools/edit.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +58 -0
- package/dist/src/tools/glob.js +193 -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 +294 -0
- package/dist/src/tools/glob.test.js.map +1 -0
- package/dist/src/tools/grep.d.ts +78 -0
- package/dist/src/tools/grep.js +422 -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 +188 -0
- package/dist/src/tools/grep.test.js.map +1 -0
- package/dist/src/tools/ls.d.ts +83 -0
- package/dist/src/tools/ls.js +194 -0
- package/dist/src/tools/ls.js.map +1 -0
- package/dist/src/tools/mcp-client.d.ts +112 -0
- package/dist/src/tools/mcp-client.js +332 -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 +227 -0
- package/dist/src/tools/mcp-client.test.js.map +1 -0
- package/dist/src/tools/mcp-tool.d.ts +23 -0
- package/dist/src/tools/mcp-tool.js +119 -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 +173 -0
- package/dist/src/tools/mcp-tool.test.js.map +1 -0
- package/dist/src/tools/memoryTool.d.ts +28 -0
- package/dist/src/tools/memoryTool.js +172 -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 +181 -0
- package/dist/src/tools/memoryTool.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +29 -0
- package/dist/src/tools/modifiable-tool.js +85 -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 +204 -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 +106 -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 +181 -0
- package/dist/src/tools/read-file.test.js.map +1 -0
- package/dist/src/tools/read-many-files.d.ts +59 -0
- package/dist/src/tools/read-many-files.js +321 -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 +312 -0
- package/dist/src/tools/read-many-files.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +43 -0
- package/dist/src/tools/shell.js +435 -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 +407 -0
- package/dist/src/tools/shell.test.js.map +1 -0
- package/dist/src/tools/todo-read.d.ts +15 -0
- package/dist/src/tools/todo-read.js +66 -0
- package/dist/src/tools/todo-read.js.map +1 -0
- package/dist/src/tools/todo-read.test.d.ts +6 -0
- package/dist/src/tools/todo-read.test.js +158 -0
- package/dist/src/tools/todo-read.test.js.map +1 -0
- package/dist/src/tools/todo-schemas.d.ts +43 -0
- package/dist/src/tools/todo-schemas.js +16 -0
- package/dist/src/tools/todo-schemas.js.map +1 -0
- package/dist/src/tools/todo-schemas.test.d.ts +6 -0
- package/dist/src/tools/todo-schemas.test.js +152 -0
- package/dist/src/tools/todo-schemas.test.js.map +1 -0
- package/dist/src/tools/todo-store.d.ts +15 -0
- package/dist/src/tools/todo-store.js +59 -0
- package/dist/src/tools/todo-store.js.map +1 -0
- package/dist/src/tools/todo-store.test.d.ts +6 -0
- package/dist/src/tools/todo-store.test.js +175 -0
- package/dist/src/tools/todo-store.test.js.map +1 -0
- package/dist/src/tools/todo-write.d.ts +17 -0
- package/dist/src/tools/todo-write.js +98 -0
- package/dist/src/tools/todo-write.js.map +1 -0
- package/dist/src/tools/todo-write.test.d.ts +6 -0
- package/dist/src/tools/todo-write.test.js +208 -0
- package/dist/src/tools/todo-write.test.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +67 -0
- package/dist/src/tools/tool-registry.js +326 -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 +398 -0
- package/dist/src/tools/tool-registry.test.js.map +1 -0
- package/dist/src/tools/tools.d.ts +184 -0
- package/dist/src/tools/tools.js +88 -0
- package/dist/src/tools/tools.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +29 -0
- package/dist/src/tools/web-fetch.js +243 -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 +70 -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 +120 -0
- package/dist/src/tools/web-search.js.map +1 -0
- package/dist/src/tools/write-file.d.ts +42 -0
- package/dist/src/tools/write-file.js +248 -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 +413 -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 +22 -0
- package/dist/src/utils/bfsFileSearch.js +62 -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 +129 -0
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +53 -0
- package/dist/src/utils/editCorrector.js +546 -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 +564 -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 +163 -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 +293 -0
- package/dist/src/utils/editor.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 +124 -0
- package/dist/src/utils/errorReporting.test.js.map +1 -0
- package/dist/src/utils/errors.d.ts +14 -0
- package/dist/src/utils/errors.js +54 -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 +49 -0
- package/dist/src/utils/fileUtils.js +286 -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 +321 -0
- package/dist/src/utils/fileUtils.test.js.map +1 -0
- package/dist/src/utils/flashFallback.integration.test.d.ts +6 -0
- package/dist/src/utils/flashFallback.integration.test.js +112 -0
- package/dist/src/utils/flashFallback.integration.test.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +14 -0
- package/dist/src/utils/generateContentResponseUtilities.js +92 -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 +273 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.d.ts +30 -0
- package/dist/src/utils/getFolderStructure.js +247 -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 +298 -0
- package/dist/src/utils/getFolderStructure.test.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.d.ts +20 -0
- package/dist/src/utils/gitIgnoreParser.js +64 -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 +145 -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/memoryDiscovery.d.ts +14 -0
- package/dist/src/utils/memoryDiscovery.js +219 -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 +432 -0
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.d.ts +35 -0
- package/dist/src/utils/memoryImportProcessor.js +141 -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 +170 -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 +113 -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 +168 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +49 -0
- package/dist/src/utils/paths.js +145 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +22 -0
- package/dist/src/utils/quotaErrorDetection.js +67 -0
- package/dist/src/utils/quotaErrorDetection.js.map +1 -0
- package/dist/src/utils/retry.d.ts +21 -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 +322 -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 +23 -0
- package/dist/src/utils/schemaValidator.js +142 -0
- package/dist/src/utils/schemaValidator.js.map +1 -0
- package/dist/src/utils/schemaValidator.test.d.ts +6 -0
- package/dist/src/utils/schemaValidator.test.js +146 -0
- package/dist/src/utils/schemaValidator.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/summarizer.d.ts +25 -0
- package/dist/src/utils/summarizer.js +80 -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/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/user_account.d.ts +9 -0
- package/dist/src/utils/user_account.js +99 -0
- package/dist/src/utils/user_account.js.map +1 -0
- package/dist/src/utils/user_account.test.d.ts +6 -0
- package/dist/src/utils/user_account.test.js +153 -0
- package/dist/src/utils/user_account.test.js.map +1 -0
- package/dist/src/utils/user_id.d.ts +11 -0
- package/dist/src/utils/user_id.js +49 -0
- package/dist/src/utils/user_id.js.map +1 -0
- package/dist/src/utils/user_id.test.d.ts +6 -0
- package/dist/src/utils/user_id.test.js +21 -0
- package/dist/src/utils/user_id.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/vybestack-llxprt-code-core-0.1.12.tgz +0 -0
- package/package.json +62 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { glob } from 'glob';
|
|
9
|
+
import { SchemaValidator } from '../utils/schemaValidator.js';
|
|
10
|
+
import { BaseTool } from './tools.js';
|
|
11
|
+
import { Type } from '@google/genai';
|
|
12
|
+
import { shortenPath, makeRelative } from '../utils/paths.js';
|
|
13
|
+
import { isWithinRoot } from '../utils/fileUtils.js';
|
|
14
|
+
/**
|
|
15
|
+
* Sorts file entries based on recency and then alphabetically.
|
|
16
|
+
* Recent files (modified within recencyThresholdMs) are listed first, newest to oldest.
|
|
17
|
+
* Older files are listed after recent ones, sorted alphabetically by path.
|
|
18
|
+
*/
|
|
19
|
+
export function sortFileEntries(entries, nowTimestamp, recencyThresholdMs) {
|
|
20
|
+
const sortedEntries = [...entries];
|
|
21
|
+
sortedEntries.sort((a, b) => {
|
|
22
|
+
const mtimeA = a.mtimeMs ?? 0;
|
|
23
|
+
const mtimeB = b.mtimeMs ?? 0;
|
|
24
|
+
const aIsRecent = nowTimestamp - mtimeA < recencyThresholdMs;
|
|
25
|
+
const bIsRecent = nowTimestamp - mtimeB < recencyThresholdMs;
|
|
26
|
+
if (aIsRecent && bIsRecent) {
|
|
27
|
+
return mtimeB - mtimeA;
|
|
28
|
+
}
|
|
29
|
+
else if (aIsRecent) {
|
|
30
|
+
return -1;
|
|
31
|
+
}
|
|
32
|
+
else if (bIsRecent) {
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return a.fullpath().localeCompare(b.fullpath());
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return sortedEntries;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Implementation of the Glob tool logic
|
|
43
|
+
*/
|
|
44
|
+
export class GlobTool extends BaseTool {
|
|
45
|
+
config;
|
|
46
|
+
static Name = 'glob';
|
|
47
|
+
constructor(config) {
|
|
48
|
+
super(GlobTool.Name, 'FindFiles', 'Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Ideal for quickly locating files based on their name or path structure, especially in large codebases.', {
|
|
49
|
+
properties: {
|
|
50
|
+
pattern: {
|
|
51
|
+
description: "The glob pattern to match against (e.g., '**/*.py', 'docs/*.md').",
|
|
52
|
+
type: Type.STRING,
|
|
53
|
+
},
|
|
54
|
+
path: {
|
|
55
|
+
description: 'Optional: The absolute path to the directory to search within. If omitted, searches the root directory.',
|
|
56
|
+
type: Type.STRING,
|
|
57
|
+
},
|
|
58
|
+
case_sensitive: {
|
|
59
|
+
description: 'Optional: Whether the search should be case-sensitive. Defaults to false.',
|
|
60
|
+
type: Type.BOOLEAN,
|
|
61
|
+
},
|
|
62
|
+
respect_git_ignore: {
|
|
63
|
+
description: 'Optional: Whether to respect .gitignore patterns when finding files. Only available in git repositories. Defaults to true.',
|
|
64
|
+
type: Type.BOOLEAN,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
required: ['pattern'],
|
|
68
|
+
type: Type.OBJECT,
|
|
69
|
+
});
|
|
70
|
+
this.config = config;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Validates the parameters for the tool.
|
|
74
|
+
*/
|
|
75
|
+
validateToolParams(params) {
|
|
76
|
+
const errors = SchemaValidator.validate(this.schema.parameters, params);
|
|
77
|
+
if (errors) {
|
|
78
|
+
return errors;
|
|
79
|
+
}
|
|
80
|
+
const searchDirAbsolute = path.resolve(this.config.getTargetDir(), params.path || '.');
|
|
81
|
+
if (!isWithinRoot(searchDirAbsolute, this.config.getTargetDir())) {
|
|
82
|
+
return `Search path ("${searchDirAbsolute}") resolves outside the tool's root directory ("${this.config.getTargetDir()}").`;
|
|
83
|
+
}
|
|
84
|
+
const targetDir = searchDirAbsolute || this.config.getTargetDir();
|
|
85
|
+
try {
|
|
86
|
+
if (!fs.existsSync(targetDir)) {
|
|
87
|
+
return `Search path does not exist ${targetDir}`;
|
|
88
|
+
}
|
|
89
|
+
if (!fs.statSync(targetDir).isDirectory()) {
|
|
90
|
+
return `Search path is not a directory: ${targetDir}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
return `Error accessing search path: ${e}`;
|
|
95
|
+
}
|
|
96
|
+
if (!params.pattern ||
|
|
97
|
+
typeof params.pattern !== 'string' ||
|
|
98
|
+
params.pattern.trim() === '') {
|
|
99
|
+
return "The 'pattern' parameter cannot be empty.";
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gets a description of the glob operation.
|
|
105
|
+
*/
|
|
106
|
+
getDescription(params) {
|
|
107
|
+
let description = `'${params.pattern}'`;
|
|
108
|
+
if (params.path) {
|
|
109
|
+
const searchDir = path.resolve(this.config.getTargetDir(), params.path || '.');
|
|
110
|
+
const relativePath = makeRelative(searchDir, this.config.getTargetDir());
|
|
111
|
+
description += ` within ${shortenPath(relativePath)}`;
|
|
112
|
+
}
|
|
113
|
+
return description;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Executes the glob search with the given parameters
|
|
117
|
+
*/
|
|
118
|
+
async execute(params, signal) {
|
|
119
|
+
const validationError = this.validateToolParams(params);
|
|
120
|
+
if (validationError) {
|
|
121
|
+
return {
|
|
122
|
+
llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`,
|
|
123
|
+
returnDisplay: validationError,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const searchDirAbsolute = path.resolve(this.config.getTargetDir(), params.path || '.');
|
|
128
|
+
// Get centralized file discovery service
|
|
129
|
+
const respectGitIgnore = params.respect_git_ignore ??
|
|
130
|
+
this.config.getFileFilteringRespectGitIgnore();
|
|
131
|
+
const fileDiscovery = this.config.getFileService();
|
|
132
|
+
const entries = (await glob(params.pattern, {
|
|
133
|
+
cwd: searchDirAbsolute,
|
|
134
|
+
withFileTypes: true,
|
|
135
|
+
nodir: true,
|
|
136
|
+
stat: true,
|
|
137
|
+
nocase: !params.case_sensitive,
|
|
138
|
+
dot: true,
|
|
139
|
+
ignore: ['**/node_modules/**', '**/.git/**'],
|
|
140
|
+
follow: false,
|
|
141
|
+
signal,
|
|
142
|
+
}));
|
|
143
|
+
// Apply git-aware filtering if enabled and in git repository
|
|
144
|
+
let filteredEntries = entries;
|
|
145
|
+
let gitIgnoredCount = 0;
|
|
146
|
+
if (respectGitIgnore) {
|
|
147
|
+
const relativePaths = entries.map((p) => path.relative(this.config.getTargetDir(), p.fullpath()));
|
|
148
|
+
const filteredRelativePaths = fileDiscovery.filterFiles(relativePaths, {
|
|
149
|
+
respectGitIgnore,
|
|
150
|
+
});
|
|
151
|
+
const filteredAbsolutePaths = new Set(filteredRelativePaths.map((p) => path.resolve(this.config.getTargetDir(), p)));
|
|
152
|
+
filteredEntries = entries.filter((entry) => filteredAbsolutePaths.has(entry.fullpath()));
|
|
153
|
+
gitIgnoredCount = entries.length - filteredEntries.length;
|
|
154
|
+
}
|
|
155
|
+
if (!filteredEntries || filteredEntries.length === 0) {
|
|
156
|
+
let message = `No files found matching pattern "${params.pattern}" within ${searchDirAbsolute}.`;
|
|
157
|
+
if (gitIgnoredCount > 0) {
|
|
158
|
+
message += ` (${gitIgnoredCount} files were git-ignored)`;
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
llmContent: message,
|
|
162
|
+
returnDisplay: `No files found`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// Set filtering such that we first show the most recent files
|
|
166
|
+
const oneDayInMs = 24 * 60 * 60 * 1000;
|
|
167
|
+
const nowTimestamp = new Date().getTime();
|
|
168
|
+
// Sort the filtered entries using the new helper function
|
|
169
|
+
const sortedEntries = sortFileEntries(filteredEntries, nowTimestamp, oneDayInMs);
|
|
170
|
+
const sortedAbsolutePaths = sortedEntries.map((entry) => entry.fullpath());
|
|
171
|
+
const fileListDescription = sortedAbsolutePaths.join('\n');
|
|
172
|
+
const fileCount = sortedAbsolutePaths.length;
|
|
173
|
+
let resultMessage = `Found ${fileCount} file(s) matching "${params.pattern}" within ${searchDirAbsolute}`;
|
|
174
|
+
if (gitIgnoredCount > 0) {
|
|
175
|
+
resultMessage += ` (${gitIgnoredCount} additional files were git-ignored)`;
|
|
176
|
+
}
|
|
177
|
+
resultMessage += `, sorted by modification time (newest first):\n${fileListDescription}`;
|
|
178
|
+
return {
|
|
179
|
+
llmContent: resultMessage,
|
|
180
|
+
returnDisplay: `Found ${fileCount} matching file(s)`,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
185
|
+
console.error(`GlobLogic execute Error: ${errorMessage}`, error);
|
|
186
|
+
return {
|
|
187
|
+
llmContent: `Error during glob search operation: ${errorMessage}`,
|
|
188
|
+
returnDisplay: `Error: An unexpected error occurred.`,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=glob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/tools/glob.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAc,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AASrD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAmB,EACnB,YAAoB,EACpB,kBAA0B;IAE1B,MAAM,aAAa,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;IACnC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC;QAC9B,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC;QAC9B,MAAM,SAAS,GAAG,YAA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AC;IACH,CAAC"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { GlobTool, sortFileEntries } from './glob.js';
|
|
7
|
+
import { partListUnionToString } from '../core/geminiRequest.js';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import fs from 'fs/promises';
|
|
10
|
+
import os from 'os';
|
|
11
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest'; // Removed vi
|
|
12
|
+
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
|
13
|
+
describe('GlobTool', () => {
|
|
14
|
+
let tempRootDir; // This will be the rootDirectory for the GlobTool instance
|
|
15
|
+
let globTool;
|
|
16
|
+
const abortSignal = new AbortController().signal;
|
|
17
|
+
// Mock config for testing
|
|
18
|
+
const mockConfig = {
|
|
19
|
+
getFileService: () => new FileDiscoveryService(tempRootDir),
|
|
20
|
+
getFileFilteringRespectGitIgnore: () => true,
|
|
21
|
+
getTargetDir: () => tempRootDir,
|
|
22
|
+
};
|
|
23
|
+
beforeEach(async () => {
|
|
24
|
+
// Create a unique root directory for each test run
|
|
25
|
+
tempRootDir = await fs.mkdtemp(path.join(os.tmpdir(), 'glob-tool-root-'));
|
|
26
|
+
globTool = new GlobTool(mockConfig);
|
|
27
|
+
// Create some test files and directories within this root
|
|
28
|
+
// Top-level files
|
|
29
|
+
await fs.writeFile(path.join(tempRootDir, 'fileA.txt'), 'contentA');
|
|
30
|
+
await fs.writeFile(path.join(tempRootDir, 'FileB.TXT'), 'contentB'); // Different case for testing
|
|
31
|
+
// Subdirectory and files within it
|
|
32
|
+
await fs.mkdir(path.join(tempRootDir, 'sub'));
|
|
33
|
+
await fs.writeFile(path.join(tempRootDir, 'sub', 'fileC.md'), 'contentC');
|
|
34
|
+
await fs.writeFile(path.join(tempRootDir, 'sub', 'FileD.MD'), 'contentD'); // Different case
|
|
35
|
+
// Deeper subdirectory
|
|
36
|
+
await fs.mkdir(path.join(tempRootDir, 'sub', 'deep'));
|
|
37
|
+
await fs.writeFile(path.join(tempRootDir, 'sub', 'deep', 'fileE.log'), 'contentE');
|
|
38
|
+
// Files for mtime sorting test
|
|
39
|
+
await fs.writeFile(path.join(tempRootDir, 'older.sortme'), 'older_content');
|
|
40
|
+
// Ensure a noticeable difference in modification time
|
|
41
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
42
|
+
await fs.writeFile(path.join(tempRootDir, 'newer.sortme'), 'newer_content');
|
|
43
|
+
});
|
|
44
|
+
afterEach(async () => {
|
|
45
|
+
// Clean up the temporary root directory
|
|
46
|
+
await fs.rm(tempRootDir, { recursive: true, force: true });
|
|
47
|
+
});
|
|
48
|
+
describe('execute', () => {
|
|
49
|
+
it('should find files matching a simple pattern in the root', async () => {
|
|
50
|
+
const params = { pattern: '*.txt' };
|
|
51
|
+
const result = await globTool.execute(params, abortSignal);
|
|
52
|
+
expect(result.llmContent).toContain('Found 2 file(s)');
|
|
53
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'fileA.txt'));
|
|
54
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'FileB.TXT'));
|
|
55
|
+
expect(result.returnDisplay).toBe('Found 2 matching file(s)');
|
|
56
|
+
});
|
|
57
|
+
it('should find files case-sensitively when case_sensitive is true', async () => {
|
|
58
|
+
const params = { pattern: '*.txt', case_sensitive: true };
|
|
59
|
+
const result = await globTool.execute(params, abortSignal);
|
|
60
|
+
expect(result.llmContent).toContain('Found 1 file(s)');
|
|
61
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'fileA.txt'));
|
|
62
|
+
expect(result.llmContent).not.toContain(path.join(tempRootDir, 'FileB.TXT'));
|
|
63
|
+
});
|
|
64
|
+
it('should find files case-insensitively by default (pattern: *.TXT)', async () => {
|
|
65
|
+
const params = { pattern: '*.TXT' };
|
|
66
|
+
const result = await globTool.execute(params, abortSignal);
|
|
67
|
+
expect(result.llmContent).toContain('Found 2 file(s)');
|
|
68
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'fileA.txt'));
|
|
69
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'FileB.TXT'));
|
|
70
|
+
});
|
|
71
|
+
it('should find files case-insensitively when case_sensitive is false (pattern: *.TXT)', async () => {
|
|
72
|
+
const params = {
|
|
73
|
+
pattern: '*.TXT',
|
|
74
|
+
case_sensitive: false,
|
|
75
|
+
};
|
|
76
|
+
const result = await globTool.execute(params, abortSignal);
|
|
77
|
+
expect(result.llmContent).toContain('Found 2 file(s)');
|
|
78
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'fileA.txt'));
|
|
79
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'FileB.TXT'));
|
|
80
|
+
});
|
|
81
|
+
it('should find files using a pattern that includes a subdirectory', async () => {
|
|
82
|
+
const params = { pattern: 'sub/*.md' };
|
|
83
|
+
const result = await globTool.execute(params, abortSignal);
|
|
84
|
+
expect(result.llmContent).toContain('Found 2 file(s)');
|
|
85
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'fileC.md'));
|
|
86
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'FileD.MD'));
|
|
87
|
+
});
|
|
88
|
+
it('should find files in a specified relative path (relative to rootDir)', async () => {
|
|
89
|
+
const params = { pattern: '*.md', path: 'sub' };
|
|
90
|
+
const result = await globTool.execute(params, abortSignal);
|
|
91
|
+
expect(result.llmContent).toContain('Found 2 file(s)');
|
|
92
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'fileC.md'));
|
|
93
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'FileD.MD'));
|
|
94
|
+
});
|
|
95
|
+
it('should find files using a deep globstar pattern (e.g., **/*.log)', async () => {
|
|
96
|
+
const params = { pattern: '**/*.log' };
|
|
97
|
+
const result = await globTool.execute(params, abortSignal);
|
|
98
|
+
expect(result.llmContent).toContain('Found 1 file(s)');
|
|
99
|
+
expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'deep', 'fileE.log'));
|
|
100
|
+
});
|
|
101
|
+
it('should return "No files found" message when pattern matches nothing', async () => {
|
|
102
|
+
const params = { pattern: '*.nonexistent' };
|
|
103
|
+
const result = await globTool.execute(params, abortSignal);
|
|
104
|
+
expect(result.llmContent).toContain('No files found matching pattern "*.nonexistent"');
|
|
105
|
+
expect(result.returnDisplay).toBe('No files found');
|
|
106
|
+
});
|
|
107
|
+
it('should correctly sort files by modification time (newest first)', async () => {
|
|
108
|
+
const params = { pattern: '*.sortme' };
|
|
109
|
+
const result = await globTool.execute(params, abortSignal);
|
|
110
|
+
const llmContent = partListUnionToString(result.llmContent);
|
|
111
|
+
expect(llmContent).toContain('Found 2 file(s)');
|
|
112
|
+
// Ensure llmContent is a string for TypeScript type checking
|
|
113
|
+
expect(typeof llmContent).toBe('string');
|
|
114
|
+
const filesListed = llmContent
|
|
115
|
+
.substring(llmContent.indexOf(':') + 1)
|
|
116
|
+
.trim()
|
|
117
|
+
.split('\n');
|
|
118
|
+
expect(filesListed[0]).toContain(path.join(tempRootDir, 'newer.sortme'));
|
|
119
|
+
expect(filesListed[1]).toContain(path.join(tempRootDir, 'older.sortme'));
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
describe('validateToolParams', () => {
|
|
123
|
+
it('should return null for valid parameters (pattern only)', () => {
|
|
124
|
+
const params = { pattern: '*.js' };
|
|
125
|
+
expect(globTool.validateToolParams(params)).toBeNull();
|
|
126
|
+
});
|
|
127
|
+
it('should return null for valid parameters (pattern and path)', () => {
|
|
128
|
+
const params = { pattern: '*.js', path: 'sub' };
|
|
129
|
+
expect(globTool.validateToolParams(params)).toBeNull();
|
|
130
|
+
});
|
|
131
|
+
it('should return null for valid parameters (pattern, path, and case_sensitive)', () => {
|
|
132
|
+
const params = {
|
|
133
|
+
pattern: '*.js',
|
|
134
|
+
path: 'sub',
|
|
135
|
+
case_sensitive: true,
|
|
136
|
+
};
|
|
137
|
+
expect(globTool.validateToolParams(params)).toBeNull();
|
|
138
|
+
});
|
|
139
|
+
it('should return error if pattern is missing (schema validation)', () => {
|
|
140
|
+
// Need to correctly define this as an object without pattern
|
|
141
|
+
const params = { path: '.' };
|
|
142
|
+
// @ts-expect-error - We're intentionally creating invalid params for testing
|
|
143
|
+
expect(globTool.validateToolParams(params)).toBe(`params must have required property 'pattern'`);
|
|
144
|
+
});
|
|
145
|
+
it('should return error if pattern is an empty string', () => {
|
|
146
|
+
const params = { pattern: '' };
|
|
147
|
+
expect(globTool.validateToolParams(params)).toContain("The 'pattern' parameter cannot be empty.");
|
|
148
|
+
});
|
|
149
|
+
it('should return error if pattern is only whitespace', () => {
|
|
150
|
+
const params = { pattern: ' ' };
|
|
151
|
+
expect(globTool.validateToolParams(params)).toContain("The 'pattern' parameter cannot be empty.");
|
|
152
|
+
});
|
|
153
|
+
it('should return error if path is provided but is not a string (schema validation)', () => {
|
|
154
|
+
const params = {
|
|
155
|
+
pattern: '*.ts',
|
|
156
|
+
path: 123,
|
|
157
|
+
};
|
|
158
|
+
// @ts-expect-error - We're intentionally creating invalid params for testing
|
|
159
|
+
expect(globTool.validateToolParams(params)).toBe('params/path must be string');
|
|
160
|
+
});
|
|
161
|
+
it('should return error if case_sensitive is provided but is not a boolean (schema validation)', () => {
|
|
162
|
+
const params = {
|
|
163
|
+
pattern: '*.ts',
|
|
164
|
+
case_sensitive: 'true',
|
|
165
|
+
};
|
|
166
|
+
// @ts-expect-error - We're intentionally creating invalid params for testing
|
|
167
|
+
expect(globTool.validateToolParams(params)).toBe('params/case_sensitive must be boolean');
|
|
168
|
+
});
|
|
169
|
+
it("should return error if search path resolves outside the tool's root directory", () => {
|
|
170
|
+
// Create a globTool instance specifically for this test, with a deeper root
|
|
171
|
+
tempRootDir = path.join(tempRootDir, 'sub');
|
|
172
|
+
const specificGlobTool = new GlobTool(mockConfig);
|
|
173
|
+
// const params: GlobToolParams = { pattern: '*.txt', path: '..' }; // This line is unused and will be removed.
|
|
174
|
+
// This should be fine as tempRootDir is still within the original tempRootDir (the parent of deeperRootDir)
|
|
175
|
+
// Let's try to go further up.
|
|
176
|
+
const paramsOutside = {
|
|
177
|
+
pattern: '*.txt',
|
|
178
|
+
path: '../../../../../../../../../../tmp',
|
|
179
|
+
}; // Definitely outside
|
|
180
|
+
expect(specificGlobTool.validateToolParams(paramsOutside)).toContain("resolves outside the tool's root directory");
|
|
181
|
+
});
|
|
182
|
+
it('should return error if specified search path does not exist', async () => {
|
|
183
|
+
const params = {
|
|
184
|
+
pattern: '*.txt',
|
|
185
|
+
path: 'nonexistent_subdir',
|
|
186
|
+
};
|
|
187
|
+
expect(globTool.validateToolParams(params)).toContain('Search path does not exist');
|
|
188
|
+
});
|
|
189
|
+
it('should return error if specified search path is a file, not a directory', async () => {
|
|
190
|
+
const params = { pattern: '*.txt', path: 'fileA.txt' };
|
|
191
|
+
expect(globTool.validateToolParams(params)).toContain('Search path is not a directory');
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
describe('sortFileEntries', () => {
|
|
196
|
+
const nowTimestamp = new Date('2024-01-15T12:00:00.000Z').getTime();
|
|
197
|
+
const oneDayInMs = 24 * 60 * 60 * 1000;
|
|
198
|
+
const createFileEntry = (fullpath, mtimeDate) => ({
|
|
199
|
+
fullpath: () => fullpath,
|
|
200
|
+
mtimeMs: mtimeDate.getTime(),
|
|
201
|
+
});
|
|
202
|
+
it('should sort a mix of recent and older files correctly', () => {
|
|
203
|
+
const recentTime1 = new Date(nowTimestamp - 1 * 60 * 60 * 1000); // 1 hour ago
|
|
204
|
+
const recentTime2 = new Date(nowTimestamp - 2 * 60 * 60 * 1000); // 2 hours ago
|
|
205
|
+
const olderTime1 = new Date(nowTimestamp - (oneDayInMs + 1 * 60 * 60 * 1000)); // 25 hours ago
|
|
206
|
+
const olderTime2 = new Date(nowTimestamp - (oneDayInMs + 2 * 60 * 60 * 1000)); // 26 hours ago
|
|
207
|
+
const entries = [
|
|
208
|
+
createFileEntry('older_zebra.txt', olderTime2),
|
|
209
|
+
createFileEntry('recent_alpha.txt', recentTime1),
|
|
210
|
+
createFileEntry('older_apple.txt', olderTime1),
|
|
211
|
+
createFileEntry('recent_beta.txt', recentTime2),
|
|
212
|
+
createFileEntry('older_banana.txt', olderTime1), // Same mtime as apple
|
|
213
|
+
];
|
|
214
|
+
const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
|
|
215
|
+
const sortedPaths = sorted.map((e) => e.fullpath());
|
|
216
|
+
expect(sortedPaths).toEqual([
|
|
217
|
+
'recent_alpha.txt', // Recent, newest
|
|
218
|
+
'recent_beta.txt', // Recent, older
|
|
219
|
+
'older_apple.txt', // Older, alphabetical
|
|
220
|
+
'older_banana.txt', // Older, alphabetical
|
|
221
|
+
'older_zebra.txt', // Older, alphabetical
|
|
222
|
+
]);
|
|
223
|
+
});
|
|
224
|
+
it('should sort only recent files by mtime descending', () => {
|
|
225
|
+
const recentTime1 = new Date(nowTimestamp - 1000); // Newest
|
|
226
|
+
const recentTime2 = new Date(nowTimestamp - 2000);
|
|
227
|
+
const recentTime3 = new Date(nowTimestamp - 3000); // Oldest recent
|
|
228
|
+
const entries = [
|
|
229
|
+
createFileEntry('c.txt', recentTime2),
|
|
230
|
+
createFileEntry('a.txt', recentTime3),
|
|
231
|
+
createFileEntry('b.txt', recentTime1),
|
|
232
|
+
];
|
|
233
|
+
const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
|
|
234
|
+
expect(sorted.map((e) => e.fullpath())).toEqual([
|
|
235
|
+
'b.txt',
|
|
236
|
+
'c.txt',
|
|
237
|
+
'a.txt',
|
|
238
|
+
]);
|
|
239
|
+
});
|
|
240
|
+
it('should sort only older files alphabetically by path', () => {
|
|
241
|
+
const olderTime = new Date(nowTimestamp - 2 * oneDayInMs); // All equally old
|
|
242
|
+
const entries = [
|
|
243
|
+
createFileEntry('zebra.txt', olderTime),
|
|
244
|
+
createFileEntry('apple.txt', olderTime),
|
|
245
|
+
createFileEntry('banana.txt', olderTime),
|
|
246
|
+
];
|
|
247
|
+
const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
|
|
248
|
+
expect(sorted.map((e) => e.fullpath())).toEqual([
|
|
249
|
+
'apple.txt',
|
|
250
|
+
'banana.txt',
|
|
251
|
+
'zebra.txt',
|
|
252
|
+
]);
|
|
253
|
+
});
|
|
254
|
+
it('should handle an empty array', () => {
|
|
255
|
+
const entries = [];
|
|
256
|
+
const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
|
|
257
|
+
expect(sorted).toEqual([]);
|
|
258
|
+
});
|
|
259
|
+
it('should correctly sort files when mtimes are identical for older files', () => {
|
|
260
|
+
const olderTime = new Date(nowTimestamp - 2 * oneDayInMs);
|
|
261
|
+
const entries = [
|
|
262
|
+
createFileEntry('b.txt', olderTime),
|
|
263
|
+
createFileEntry('a.txt', olderTime),
|
|
264
|
+
];
|
|
265
|
+
const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
|
|
266
|
+
expect(sorted.map((e) => e.fullpath())).toEqual(['a.txt', 'b.txt']);
|
|
267
|
+
});
|
|
268
|
+
it('should correctly sort files when mtimes are identical for recent files (maintaining mtime sort)', () => {
|
|
269
|
+
const recentTime = new Date(nowTimestamp - 1000);
|
|
270
|
+
const entries = [
|
|
271
|
+
createFileEntry('b.txt', recentTime),
|
|
272
|
+
createFileEntry('a.txt', recentTime),
|
|
273
|
+
];
|
|
274
|
+
const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
|
|
275
|
+
expect(sorted.map((e) => e.fullpath())).toContain('a.txt');
|
|
276
|
+
expect(sorted.map((e) => e.fullpath())).toContain('b.txt');
|
|
277
|
+
expect(sorted.length).toBe(2);
|
|
278
|
+
});
|
|
279
|
+
it('should use recencyThresholdMs parameter correctly', () => {
|
|
280
|
+
const justOverThreshold = new Date(nowTimestamp - (1000 + 1)); // Barely older
|
|
281
|
+
const justUnderThreshold = new Date(nowTimestamp - (1000 - 1)); // Barely recent
|
|
282
|
+
const customThresholdMs = 1000; // 1 second
|
|
283
|
+
const entries = [
|
|
284
|
+
createFileEntry('older_file.txt', justOverThreshold),
|
|
285
|
+
createFileEntry('recent_file.txt', justUnderThreshold),
|
|
286
|
+
];
|
|
287
|
+
const sorted = sortFileEntries(entries, nowTimestamp, customThresholdMs);
|
|
288
|
+
expect(sorted.map((e) => e.fullpath())).toEqual([
|
|
289
|
+
'recent_file.txt',
|
|
290
|
+
'older_file.txt',
|
|
291
|
+
]);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
//# sourceMappingURL=glob.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.test.js","sourceRoot":"","sources":["../../../src/tools/glob.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAA4B,eAAe,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC,CAAC,aAAa;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAG3E,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAI,WAAmB,CAAC,CAAC,2DAA2D;IACpF,IAAI,QAAkB,CAAC;IACvB,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC,MAAM,CAAC;IAEjD,0BAA0B;IAC1B,MAAM,UAAU,GAAG;QACjB,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,oBAAoB,CAAC,WAAW,CA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AC,eAAe;QAC9E,MAAM,kBAAkB,GAAG,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB;QAChF,MAAM,iBAAiB,GAAG,IAAI,CAAC,CAAC,WAAW;QAE3C,MAAM,OAAO,GAAe;YAC1B,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;YACpD,eAAe,CAAC,iBAAiB,EAAE,kBAAkB,CAAC;SACvD,CAAC;QACF,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;QACzE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YAC9C,iBAAiB;YACjB,gBAAgB;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { BaseTool, ToolResult } from './tools.js';
|
|
7
|
+
import { Config } from '../config/config.js';
|
|
8
|
+
/**
|
|
9
|
+
* Parameters for the GrepTool
|
|
10
|
+
*/
|
|
11
|
+
export interface GrepToolParams {
|
|
12
|
+
/**
|
|
13
|
+
* The regular expression pattern to search for in file contents
|
|
14
|
+
*/
|
|
15
|
+
pattern: string;
|
|
16
|
+
/**
|
|
17
|
+
* The directory to search in (optional, defaults to current directory relative to root)
|
|
18
|
+
*/
|
|
19
|
+
path?: string;
|
|
20
|
+
/**
|
|
21
|
+
* File pattern to include in the search (e.g. "*.js", "*.{ts,tsx}")
|
|
22
|
+
*/
|
|
23
|
+
include?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Implementation of the Grep tool logic (moved from CLI)
|
|
27
|
+
*/
|
|
28
|
+
export declare class GrepTool extends BaseTool<GrepToolParams, ToolResult> {
|
|
29
|
+
private readonly config;
|
|
30
|
+
static readonly Name = "search_file_content";
|
|
31
|
+
constructor(config: Config);
|
|
32
|
+
/**
|
|
33
|
+
* Checks if a path is within the root directory and resolves it.
|
|
34
|
+
* @param relativePath Path relative to the root directory (or undefined for root).
|
|
35
|
+
* @returns The absolute path if valid and exists.
|
|
36
|
+
* @throws {Error} If path is outside root, doesn't exist, or isn't a directory.
|
|
37
|
+
*/
|
|
38
|
+
private resolveAndValidatePath;
|
|
39
|
+
/**
|
|
40
|
+
* Validates the parameters for the tool
|
|
41
|
+
* @param params Parameters to validate
|
|
42
|
+
* @returns An error message string if invalid, null otherwise
|
|
43
|
+
*/
|
|
44
|
+
validateToolParams(params: GrepToolParams): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Executes the grep search with the given parameters
|
|
47
|
+
* @param params Parameters for the grep search
|
|
48
|
+
* @returns Result of the grep search
|
|
49
|
+
*/
|
|
50
|
+
execute(params: GrepToolParams, signal: AbortSignal): Promise<ToolResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Checks if a command is available in the system's PATH.
|
|
53
|
+
* @param {string} command The command name (e.g., 'git', 'grep').
|
|
54
|
+
* @returns {Promise<boolean>} True if the command is available, false otherwise.
|
|
55
|
+
*/
|
|
56
|
+
private isCommandAvailable;
|
|
57
|
+
/**
|
|
58
|
+
* Parses the standard output of grep-like commands (git grep, system grep).
|
|
59
|
+
* Expects format: filePath:lineNumber:lineContent
|
|
60
|
+
* Handles colons within file paths and line content correctly.
|
|
61
|
+
* @param {string} output The raw stdout string.
|
|
62
|
+
* @param {string} basePath The absolute directory the search was run from, for relative paths.
|
|
63
|
+
* @returns {GrepMatch[]} Array of match objects.
|
|
64
|
+
*/
|
|
65
|
+
private parseGrepOutput;
|
|
66
|
+
/**
|
|
67
|
+
* Gets a description of the grep operation
|
|
68
|
+
* @param params Parameters for the grep operation
|
|
69
|
+
* @returns A string describing the grep
|
|
70
|
+
*/
|
|
71
|
+
getDescription(params: GrepToolParams): string;
|
|
72
|
+
/**
|
|
73
|
+
* Performs the actual search using the prioritized strategies.
|
|
74
|
+
* @param options Search options including pattern, absolute path, and include glob.
|
|
75
|
+
* @returns A promise resolving to an array of match objects.
|
|
76
|
+
*/
|
|
77
|
+
private performGrepSearch;
|
|
78
|
+
}
|