@office-ai/aioncli-core 0.26.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/CONTRIBUTING.md +19 -10
- package/dist/docs/admin/enterprise-controls.md +115 -0
- package/dist/docs/architecture.md +3 -3
- package/dist/docs/assets/monitoring-dashboard-logs.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-metrics.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-overview.png +0 -0
- package/dist/docs/bedrock-integration-plan.md +595 -0
- package/dist/docs/changelogs/index.md +187 -0
- package/dist/docs/changelogs/latest.md +299 -209
- package/dist/docs/changelogs/preview.md +353 -115
- package/dist/docs/cli/checkpointing.md +2 -3
- package/dist/docs/cli/cli-reference.md +115 -0
- package/dist/docs/cli/commands.md +360 -247
- package/dist/docs/cli/creating-skills.md +80 -0
- package/dist/docs/cli/custom-commands.md +12 -9
- package/dist/docs/cli/enterprise.md +25 -5
- package/dist/docs/cli/gemini-md.md +20 -12
- package/dist/docs/cli/headless.md +34 -372
- package/dist/docs/cli/index.md +123 -63
- package/dist/docs/cli/keyboard-shortcuts.md +95 -84
- package/dist/docs/cli/model-routing.md +7 -2
- package/dist/docs/cli/model.md +1 -1
- package/dist/docs/cli/plan-mode.md +190 -0
- package/dist/docs/cli/rewind.md +51 -0
- package/dist/docs/cli/sandbox.md +4 -3
- package/dist/docs/cli/session-management.md +61 -44
- package/dist/docs/cli/settings.md +95 -61
- package/dist/docs/cli/skills.md +49 -71
- package/dist/docs/cli/system-prompt.md +32 -0
- package/dist/docs/cli/telemetry.md +75 -4
- package/dist/docs/cli/themes.md +85 -53
- package/dist/docs/cli/tutorials/automation.md +187 -0
- package/dist/docs/cli/tutorials/file-management.md +142 -0
- package/dist/docs/cli/tutorials/mcp-setup.md +105 -0
- package/dist/docs/cli/tutorials/memory-management.md +126 -0
- package/dist/docs/cli/tutorials/session-management.md +105 -0
- package/dist/docs/cli/tutorials/shell-commands.md +107 -0
- package/dist/docs/cli/tutorials/skills-getting-started.md +36 -58
- package/dist/docs/cli/tutorials/task-planning.md +93 -0
- package/dist/docs/cli/tutorials/web-tools.md +78 -0
- package/dist/docs/cli/uninstall.md +18 -0
- package/dist/docs/core/concepts.md +137 -0
- package/dist/docs/core/index.md +6 -0
- package/dist/docs/core/memport.md +2 -0
- package/dist/docs/core/policy-engine.md +57 -7
- package/dist/docs/core/remote-agents.md +84 -0
- package/dist/docs/core/subagents.md +191 -0
- package/dist/docs/extensions/best-practices.md +188 -0
- package/dist/docs/extensions/index.md +38 -270
- package/dist/docs/extensions/reference.md +265 -0
- package/dist/docs/extensions/releasing.md +154 -0
- package/dist/docs/extensions/writing-extensions.md +292 -0
- package/dist/docs/get-started/authentication.md +162 -0
- package/dist/docs/get-started/configuration-v1.md +5 -11
- package/dist/docs/get-started/configuration.md +228 -99
- package/dist/docs/get-started/examples.md +39 -119
- package/dist/docs/get-started/gemini-3.md +2 -17
- package/dist/docs/get-started/index.md +6 -4
- package/dist/docs/get-started/installation.md +110 -77
- package/dist/docs/hooks/best-practices.md +219 -398
- package/dist/docs/hooks/index.md +99 -622
- package/dist/docs/hooks/reference.md +269 -115
- package/dist/docs/hooks/writing-hooks.md +203 -779
- package/dist/docs/index.md +146 -147
- package/dist/docs/local-development.md +1 -1
- package/dist/docs/releases.md +3 -3
- package/dist/docs/sidebar.json +105 -217
- package/dist/docs/tools/activate-skill.md +43 -0
- package/dist/docs/tools/ask-user.md +95 -0
- package/dist/docs/tools/file-system.md +48 -139
- package/dist/docs/tools/index.md +92 -85
- package/dist/docs/tools/internal-docs.md +46 -0
- package/dist/docs/tools/mcp-server.md +29 -5
- package/dist/docs/tools/memory.md +21 -40
- package/dist/docs/tools/planning.md +55 -0
- package/dist/docs/tools/shell.md +45 -89
- package/dist/docs/tools/todos.md +22 -44
- package/dist/docs/tools/web-fetch.md +22 -46
- package/dist/docs/tools/web-search.md +19 -29
- package/dist/docs/tos-privacy.md +1 -1
- package/dist/docs/troubleshooting.md +20 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/src/agents/a2a-client-manager.d.ts +4 -5
- package/dist/src/agents/a2a-client-manager.js +9 -131
- package/dist/src/agents/a2a-client-manager.js.map +1 -1
- package/dist/src/agents/a2a-client-manager.test.js +10 -27
- package/dist/src/agents/a2a-client-manager.test.js.map +1 -1
- package/dist/src/agents/a2aUtils.d.ts +3 -2
- package/dist/src/agents/a2aUtils.js +28 -26
- package/dist/src/agents/a2aUtils.js.map +1 -1
- package/dist/src/agents/a2aUtils.test.js +9 -9
- package/dist/src/agents/a2aUtils.test.js.map +1 -1
- package/dist/src/agents/acknowledgedAgents.d.ts +18 -0
- package/dist/src/agents/acknowledgedAgents.js +58 -0
- package/dist/src/agents/acknowledgedAgents.js.map +1 -0
- package/dist/src/agents/acknowledgedAgents.test.d.ts +6 -0
- package/dist/src/agents/acknowledgedAgents.test.js +70 -0
- package/dist/src/agents/acknowledgedAgents.test.js.map +1 -0
- package/dist/src/agents/agent-scheduler.d.ts +35 -0
- package/dist/src/agents/agent-scheduler.js +30 -0
- package/dist/src/agents/agent-scheduler.js.map +1 -0
- package/dist/src/agents/agent-scheduler.test.d.ts +6 -0
- package/dist/src/agents/agent-scheduler.test.js +56 -0
- package/dist/src/agents/agent-scheduler.test.js.map +1 -0
- package/dist/src/agents/agentLoader.d.ts +88 -0
- package/dist/src/agents/agentLoader.js +394 -0
- package/dist/src/agents/agentLoader.js.map +1 -0
- package/dist/src/agents/agentLoader.test.d.ts +6 -0
- package/dist/src/agents/agentLoader.test.js +458 -0
- package/dist/src/agents/agentLoader.test.js.map +1 -0
- package/dist/src/agents/auth-provider/base-provider.d.ts +40 -0
- package/dist/src/agents/auth-provider/base-provider.js +43 -0
- package/dist/src/agents/auth-provider/base-provider.js.map +1 -0
- package/dist/src/agents/auth-provider/base-provider.test.d.ts +6 -0
- package/dist/src/agents/auth-provider/base-provider.test.js +107 -0
- package/dist/src/agents/auth-provider/base-provider.test.js.map +1 -0
- package/dist/src/agents/auth-provider/factory.d.ts +27 -0
- package/dist/src/agents/auth-provider/factory.js +161 -0
- package/dist/src/agents/auth-provider/factory.js.map +1 -0
- package/dist/src/agents/auth-provider/factory.test.d.ts +6 -0
- package/dist/src/agents/auth-provider/factory.test.js +344 -0
- package/dist/src/agents/auth-provider/factory.test.js.map +1 -0
- package/dist/src/agents/auth-provider/types.d.ts +74 -0
- package/dist/src/agents/auth-provider/types.js +7 -0
- package/dist/src/agents/auth-provider/types.js.map +1 -0
- package/dist/src/agents/auth-provider/value-resolver.d.ts +29 -0
- package/dist/src/agents/auth-provider/value-resolver.js +85 -0
- package/dist/src/agents/auth-provider/value-resolver.js.map +1 -0
- package/dist/src/agents/auth-provider/value-resolver.test.d.ts +6 -0
- package/dist/src/agents/auth-provider/value-resolver.test.js +100 -0
- package/dist/src/agents/auth-provider/value-resolver.test.js.map +1 -0
- package/dist/src/agents/cli-help-agent.d.ts +24 -0
- package/dist/src/agents/cli-help-agent.js +80 -0
- package/dist/src/agents/cli-help-agent.js.map +1 -0
- package/dist/src/agents/cli-help-agent.test.d.ts +6 -0
- package/dist/src/agents/cli-help-agent.test.js +53 -0
- package/dist/src/agents/cli-help-agent.test.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +2 -1
- package/dist/src/agents/codebase-investigator.js +68 -39
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/codebase-investigator.test.js +37 -9
- package/dist/src/agents/codebase-investigator.test.js.map +1 -1
- package/dist/src/agents/generalist-agent.d.ts +21 -0
- package/dist/src/agents/generalist-agent.js +60 -0
- package/dist/src/agents/generalist-agent.js.map +1 -0
- package/dist/src/agents/generalist-agent.test.d.ts +6 -0
- package/dist/src/agents/generalist-agent.test.js +32 -0
- package/dist/src/agents/generalist-agent.test.js.map +1 -0
- package/dist/src/agents/introspection-agent.d.ts +2 -2
- package/dist/src/agents/local-executor.d.ts +2 -0
- package/dist/src/agents/local-executor.js +186 -90
- package/dist/src/agents/local-executor.js.map +1 -1
- package/dist/src/agents/local-executor.test.js +431 -256
- package/dist/src/agents/local-executor.test.js.map +1 -1
- package/dist/src/agents/local-invocation.test.js +15 -5
- package/dist/src/agents/local-invocation.test.js.map +1 -1
- package/dist/src/agents/registry.d.ts +24 -8
- package/dist/src/agents/registry.js +193 -96
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +509 -58
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/registry_acknowledgement.test.d.ts +6 -0
- package/dist/src/agents/registry_acknowledgement.test.js +130 -0
- package/dist/src/agents/registry_acknowledgement.test.js.map +1 -0
- package/dist/src/agents/remote-invocation.js +12 -14
- package/dist/src/agents/remote-invocation.js.map +1 -1
- package/dist/src/agents/remote-invocation.test.js +16 -4
- package/dist/src/agents/remote-invocation.test.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.js +1 -3
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +18 -27
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/subagent-tool.d.ts +15 -0
- package/dist/src/agents/subagent-tool.js +57 -0
- package/dist/src/agents/subagent-tool.js.map +1 -0
- package/dist/src/agents/subagent-tool.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool.test.js +97 -0
- package/dist/src/agents/subagent-tool.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +37 -22
- package/dist/src/agents/types.js +12 -0
- package/dist/src/agents/types.js.map +1 -1
- package/dist/src/availability/fallbackIntegration.test.d.ts +6 -0
- package/dist/src/availability/fallbackIntegration.test.js +57 -0
- package/dist/src/availability/fallbackIntegration.test.js.map +1 -0
- package/dist/src/availability/policyCatalog.d.ts +3 -0
- package/dist/src/availability/policyCatalog.js +29 -5
- package/dist/src/availability/policyCatalog.js.map +1 -1
- package/dist/src/availability/policyCatalog.test.js +20 -1
- package/dist/src/availability/policyCatalog.test.js.map +1 -1
- package/dist/src/availability/policyHelpers.js +40 -11
- package/dist/src/availability/policyHelpers.js.map +1 -1
- package/dist/src/availability/policyHelpers.test.js +72 -2
- package/dist/src/availability/policyHelpers.test.js.map +1 -1
- package/dist/src/availability/testUtils.js +1 -0
- package/dist/src/availability/testUtils.js.map +1 -1
- package/dist/src/code_assist/admin/admin_controls.d.ts +49 -0
- package/dist/src/code_assist/admin/admin_controls.js +197 -0
- package/dist/src/code_assist/admin/admin_controls.js.map +1 -0
- package/dist/src/code_assist/admin/admin_controls.test.d.ts +6 -0
- package/dist/src/code_assist/admin/admin_controls.test.js +589 -0
- package/dist/src/code_assist/admin/admin_controls.test.js.map +1 -0
- package/dist/src/code_assist/admin/mcpUtils.d.ts +22 -0
- package/dist/src/code_assist/admin/mcpUtils.js +53 -0
- package/dist/src/code_assist/admin/mcpUtils.js.map +1 -0
- package/dist/src/code_assist/admin/mcpUtils.test.d.ts +6 -0
- package/dist/src/code_assist/admin/mcpUtils.test.js +101 -0
- package/dist/src/code_assist/admin/mcpUtils.test.js.map +1 -0
- package/dist/src/code_assist/codeAssist.js +2 -2
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/codeAssist.test.d.ts +1 -1
- package/dist/src/code_assist/codeAssist.test.js +10 -6
- package/dist/src/code_assist/codeAssist.test.js.map +1 -1
- package/dist/src/code_assist/converter.js +8 -3
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +8 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments.d.ts +1 -1
- package/dist/src/code_assist/experiments/experiments.js +22 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments.test.js +1 -0
- package/dist/src/code_assist/experiments/experiments.test.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments_local.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/experiments_local.test.js +115 -0
- package/dist/src/code_assist/experiments/experiments_local.test.js.map +1 -0
- package/dist/src/code_assist/experiments/flagNames.d.ts +7 -0
- package/dist/src/code_assist/experiments/flagNames.js +7 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -1
- package/dist/src/code_assist/oauth-credential-storage.js +4 -4
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +10 -3
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +7 -4
- package/dist/src/code_assist/server.js +20 -4
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +18 -5
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +35 -3
- package/dist/src/code_assist/setup.js +98 -16
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js +322 -5
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/telemetry.js +2 -1
- package/dist/src/code_assist/telemetry.js.map +1 -1
- package/dist/src/code_assist/telemetry.test.js +2 -1
- package/dist/src/code_assist/telemetry.test.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +255 -24
- package/dist/src/code_assist/types.js +57 -7
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/memory.d.ts +11 -0
- package/dist/src/commands/memory.js +81 -0
- package/dist/src/commands/memory.js.map +1 -0
- package/dist/src/commands/memory.test.d.ts +6 -0
- package/dist/src/commands/memory.test.js +155 -0
- package/dist/src/commands/memory.test.js.map +1 -0
- package/dist/src/commands/restore.js +1 -0
- package/dist/src/commands/restore.js.map +1 -1
- package/dist/src/config/config.d.ts +267 -58
- package/dist/src/config/config.js +663 -164
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.d.ts +1 -1
- package/dist/src/config/config.test.js +585 -166
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/constants.d.ts +4 -0
- package/dist/src/config/constants.js +8 -0
- package/dist/src/config/constants.js.map +1 -1
- package/dist/src/config/defaultModelConfigs.js +27 -8
- package/dist/src/config/defaultModelConfigs.js.map +1 -1
- package/dist/src/config/memory.d.ts +14 -0
- package/dist/src/config/memory.js +28 -0
- package/dist/src/config/memory.js.map +1 -0
- package/dist/src/config/memory.test.d.ts +6 -0
- package/dist/src/config/memory.test.js +82 -0
- package/dist/src/config/memory.test.js.map +1 -0
- package/dist/src/config/models.d.ts +77 -6
- package/dist/src/config/models.js +240 -23
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +153 -47
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/projectRegistry.d.ts +36 -0
- package/dist/src/config/projectRegistry.js +262 -0
- package/dist/src/config/projectRegistry.js.map +1 -0
- package/dist/src/config/projectRegistry.test.d.ts +6 -0
- package/dist/src/config/projectRegistry.test.js +219 -0
- package/dist/src/config/projectRegistry.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +23 -1
- package/dist/src/config/storage.js +104 -15
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +118 -2
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/config/storageMigration.d.ts +16 -0
- package/dist/src/config/storageMigration.js +42 -0
- package/dist/src/config/storageMigration.js.map +1 -0
- package/dist/src/config/storageMigration.test.d.ts +6 -0
- package/dist/src/config/storageMigration.test.js +70 -0
- package/dist/src/config/storageMigration.test.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.js +3 -33
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +95 -20
- package/dist/src/confirmation-bus/types.js +9 -3
- package/dist/src/confirmation-bus/types.js.map +1 -1
- package/dist/src/core/anthropicContentGenerator.d.ts +3 -2
- package/dist/src/core/anthropicContentGenerator.js +2 -2
- package/dist/src/core/anthropicContentGenerator.js.map +1 -1
- package/dist/src/core/baseLlmClient.d.ts +9 -0
- package/dist/src/core/baseLlmClient.js +9 -8
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +17 -7
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/bedrockContentGenerator.d.ts +73 -0
- package/dist/src/core/bedrockContentGenerator.js +628 -0
- package/dist/src/core/bedrockContentGenerator.js.map +1 -0
- package/dist/src/core/client.d.ts +13 -4
- package/dist/src/core/client.js +132 -41
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +333 -79
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +16 -3
- package/dist/src/core/contentGenerator.js +56 -2
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.d.ts +1 -1
- package/dist/src/core/contentGenerator.test.js +127 -24
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +4 -36
- package/dist/src/core/coreToolHookTriggers.js +42 -150
- package/dist/src/core/coreToolHookTriggers.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.test.js +62 -94
- package/dist/src/core/coreToolHookTriggers.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +1 -8
- package/dist/src/core/coreToolScheduler.js +160 -125
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +480 -62
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.d.ts +4 -2
- package/dist/src/core/fakeContentGenerator.js +9 -2
- package/dist/src/core/fakeContentGenerator.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.test.js +8 -7
- package/dist/src/core/fakeContentGenerator.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +31 -3
- package/dist/src/core/geminiChat.js +144 -34
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +175 -50
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChat_network_retry.test.js +146 -16
- package/dist/src/core/geminiChat_network_retry.test.js.map +1 -1
- package/dist/src/core/logger.js +11 -0
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +2 -4
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +7 -3
- package/dist/src/core/loggingContentGenerator.js +40 -21
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.d.ts +1 -1
- package/dist/src/core/loggingContentGenerator.test.js +50 -8
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +3 -2
- package/dist/src/core/openaiContentGenerator.js +18 -10
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.test.js +57 -4
- package/dist/src/core/openaiContentGenerator.test.js.map +1 -1
- package/dist/src/core/prompts-substitution.test.d.ts +6 -0
- package/dist/src/core/prompts-substitution.test.js +109 -0
- package/dist/src/core/prompts-substitution.test.js.map +1 -0
- package/dist/src/core/prompts.d.ts +11 -9
- package/dist/src/core/prompts.js +14 -405
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +290 -56
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.d.ts +5 -3
- package/dist/src/core/recordingContentGenerator.js +12 -5
- package/dist/src/core/recordingContentGenerator.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.test.js +5 -4
- package/dist/src/core/recordingContentGenerator.test.js.map +1 -1
- package/dist/src/core/tokenLimits.js +6 -10
- package/dist/src/core/tokenLimits.js.map +1 -1
- package/dist/src/core/tokenLimits.test.js +8 -4
- package/dist/src/core/tokenLimits.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +10 -2
- package/dist/src/core/turn.js +36 -17
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +82 -2
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +1 -1
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +10 -12
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/fallback/types.d.ts +9 -0
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/hooks/hookAggregator.js +16 -4
- package/dist/src/hooks/hookAggregator.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.d.ts +10 -16
- package/dist/src/hooks/hookEventHandler.js +35 -281
- package/dist/src/hooks/hookEventHandler.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.test.js +189 -4
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
- package/dist/src/hooks/hookRegistry.js +8 -3
- package/dist/src/hooks/hookRegistry.js.map +1 -1
- package/dist/src/hooks/hookRegistry.test.js +31 -2
- package/dist/src/hooks/hookRegistry.test.js.map +1 -1
- package/dist/src/hooks/hookRunner.js +21 -18
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +59 -0
- package/dist/src/hooks/hookSystem.js +206 -6
- package/dist/src/hooks/hookSystem.js.map +1 -1
- package/dist/src/hooks/hookSystem.test.js +20 -9
- package/dist/src/hooks/hookSystem.test.js.map +1 -1
- package/dist/src/hooks/hookTranslator.js +13 -6
- package/dist/src/hooks/hookTranslator.js.map +1 -1
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/hooks/index.js +0 -2
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/trustedHooks.js +2 -0
- package/dist/src/hooks/trustedHooks.js.map +1 -1
- package/dist/src/hooks/types.d.ts +49 -1
- package/dist/src/hooks/types.js +43 -19
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/hooks/types.test.js +13 -29
- package/dist/src/hooks/types.test.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +49 -0
- package/dist/src/ide/detect-ide.js +56 -3
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +70 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +0 -10
- package/dist/src/ide/ide-client.js +31 -199
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +39 -191
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-connection-utils.d.ts +27 -0
- package/dist/src/ide/ide-connection-utils.js +195 -0
- package/dist/src/ide/ide-connection-utils.js.map +1 -0
- package/dist/src/ide/ide-connection-utils.test.d.ts +6 -0
- package/dist/src/ide/ide-connection-utils.test.js +372 -0
- package/dist/src/ide/ide-connection-utils.test.js.map +1 -0
- package/dist/src/ide/ide-installer.js +76 -5
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +40 -2
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/types.d.ts +46 -46
- package/dist/src/index.d.ts +30 -2
- package/dist/src/index.js +31 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +10 -3
- package/dist/src/mcp/oauth-provider.js +49 -14
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +180 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.js +3 -0
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +13 -4
- package/dist/src/mcp/oauth-utils.js +25 -19
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +13 -8
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.js +3 -1
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.js +6 -2
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +4 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +12 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js +8 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +10 -5
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -1
- package/dist/src/output/json-formatter.test.js +2 -0
- package/dist/src/output/json-formatter.test.js.map +1 -1
- package/dist/src/output/stream-json-formatter.test.js +4 -0
- package/dist/src/output/stream-json-formatter.test.js.map +1 -1
- package/dist/src/policy/config.d.ts +5 -3
- package/dist/src/policy/config.js +137 -64
- package/dist/src/policy/config.js.map +1 -1
- package/dist/src/policy/config.test.js +218 -12
- package/dist/src/policy/config.test.js.map +1 -1
- package/dist/src/policy/persistence.test.js +31 -11
- package/dist/src/policy/persistence.test.js.map +1 -1
- package/dist/src/policy/policies/plan.toml +56 -0
- package/dist/src/policy/policies/read-only.toml +1 -11
- package/dist/src/policy/policies/yolo.toml +13 -2
- package/dist/src/policy/policy-engine.d.ts +16 -11
- package/dist/src/policy/policy-engine.js +208 -101
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +538 -199
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/policy/policy-updater.test.js +20 -6
- package/dist/src/policy/policy-updater.test.js.map +1 -1
- package/dist/src/policy/shell-safety.test.js +371 -8
- package/dist/src/policy/shell-safety.test.js.map +1 -1
- package/dist/src/policy/stable-stringify.js +1 -0
- package/dist/src/policy/stable-stringify.js.map +1 -1
- package/dist/src/policy/toml-loader.d.ts +5 -5
- package/dist/src/policy/toml-loader.js +65 -22
- package/dist/src/policy/toml-loader.js.map +1 -1
- package/dist/src/policy/toml-loader.test.js +88 -9
- package/dist/src/policy/toml-loader.test.js.map +1 -1
- package/dist/src/policy/types.d.ts +26 -1
- package/dist/src/policy/types.js +8 -0
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/policy/utils.d.ts +5 -0
- package/dist/src/policy/utils.js +32 -1
- package/dist/src/policy/utils.js.map +1 -1
- package/dist/src/policy/utils.test.js +67 -7
- package/dist/src/policy/utils.test.js.map +1 -1
- package/dist/src/prompts/promptProvider.d.ts +19 -0
- package/dist/src/prompts/promptProvider.js +174 -0
- package/dist/src/prompts/promptProvider.js.map +1 -0
- package/dist/src/prompts/promptProvider.test.d.ts +6 -0
- package/dist/src/prompts/promptProvider.test.js +71 -0
- package/dist/src/prompts/promptProvider.test.js.map +1 -0
- package/dist/src/prompts/snippets.d.ts +86 -0
- package/dist/src/prompts/snippets.js +573 -0
- package/dist/src/prompts/snippets.js.map +1 -0
- package/dist/src/prompts/snippets.legacy.d.ts +91 -0
- package/dist/src/prompts/snippets.legacy.js +573 -0
- package/dist/src/prompts/snippets.legacy.js.map +1 -0
- package/dist/src/prompts/utils.d.ts +23 -0
- package/dist/src/prompts/utils.js +82 -0
- package/dist/src/prompts/utils.js.map +1 -0
- package/dist/src/routing/modelRouterService.js +18 -8
- package/dist/src/routing/modelRouterService.js.map +1 -1
- package/dist/src/routing/modelRouterService.test.js +14 -6
- package/dist/src/routing/modelRouterService.test.js.map +1 -1
- package/dist/src/routing/routingStrategy.d.ts +2 -0
- package/dist/src/routing/strategies/classifierStrategy.js +14 -9
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +72 -7
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.js +1 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/routing/strategies/defaultStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/defaultStrategy.js +5 -4
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -1
- package/dist/src/routing/strategies/defaultStrategy.test.js +58 -4
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +3 -3
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +13 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/numericalClassifierStrategy.d.ts +13 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.js +188 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.js +401 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +6 -6
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.test.js +13 -3
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -1
- package/dist/src/safety/built-in.js +1 -0
- package/dist/src/safety/built-in.js.map +1 -1
- package/dist/src/safety/context-builder.js +3 -1
- package/dist/src/safety/context-builder.js.map +1 -1
- package/dist/src/scheduler/confirmation.d.ts +50 -0
- package/dist/src/scheduler/confirmation.js +204 -0
- package/dist/src/scheduler/confirmation.js.map +1 -0
- package/dist/src/scheduler/confirmation.test.d.ts +6 -0
- package/dist/src/scheduler/confirmation.test.js +310 -0
- package/dist/src/scheduler/confirmation.test.js.map +1 -0
- package/dist/src/scheduler/policy.d.ts +33 -0
- package/dist/src/scheduler/policy.js +119 -0
- package/dist/src/scheduler/policy.js.map +1 -0
- package/dist/src/scheduler/policy.test.d.ts +6 -0
- package/dist/src/scheduler/policy.test.js +419 -0
- package/dist/src/scheduler/policy.test.js.map +1 -0
- package/dist/src/scheduler/scheduler.d.ts +63 -0
- package/dist/src/scheduler/scheduler.js +371 -0
- package/dist/src/scheduler/scheduler.js.map +1 -0
- package/dist/src/scheduler/scheduler.test.d.ts +6 -0
- package/dist/src/scheduler/scheduler.test.js +937 -0
- package/dist/src/scheduler/scheduler.test.js.map +1 -0
- package/dist/src/scheduler/scheduler_waiting_callback.test.d.ts +6 -0
- package/dist/src/scheduler/scheduler_waiting_callback.test.js +62 -0
- package/dist/src/scheduler/scheduler_waiting_callback.test.js.map +1 -0
- package/dist/src/scheduler/state-manager.d.ts +74 -0
- package/dist/src/scheduler/state-manager.js +368 -0
- package/dist/src/scheduler/state-manager.js.map +1 -0
- package/dist/src/scheduler/state-manager.test.d.ts +6 -0
- package/dist/src/scheduler/state-manager.test.js +433 -0
- package/dist/src/scheduler/state-manager.test.js.map +1 -0
- package/dist/src/scheduler/tool-executor.js +25 -27
- package/dist/src/scheduler/tool-executor.js.map +1 -1
- package/dist/src/scheduler/tool-executor.test.js +26 -25
- package/dist/src/scheduler/tool-executor.test.js.map +1 -1
- package/dist/src/scheduler/tool-modifier.d.ts +23 -0
- package/dist/src/scheduler/tool-modifier.js +53 -0
- package/dist/src/scheduler/tool-modifier.js.map +1 -0
- package/dist/src/scheduler/tool-modifier.test.d.ts +6 -0
- package/dist/src/scheduler/tool-modifier.test.js +179 -0
- package/dist/src/scheduler/tool-modifier.test.js.map +1 -0
- package/dist/src/scheduler/types.d.ts +51 -8
- package/dist/src/scheduler/types.js +15 -1
- package/dist/src/scheduler/types.js.map +1 -1
- package/dist/src/services/chatCompressionService.d.ts +5 -1
- package/dist/src/services/chatCompressionService.js +169 -23
- package/dist/src/services/chatCompressionService.js.map +1 -1
- package/dist/src/services/chatCompressionService.test.js +382 -18
- package/dist/src/services/chatCompressionService.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +23 -3
- package/dist/src/services/chatRecordingService.js +137 -7
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +450 -186
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +7 -4
- package/dist/src/services/contextManager.js +43 -18
- package/dist/src/services/contextManager.js.map +1 -1
- package/dist/src/services/contextManager.test.js +54 -27
- package/dist/src/services/contextManager.test.js.map +1 -1
- package/dist/src/services/environmentSanitization.js +4 -3
- package/dist/src/services/environmentSanitization.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +14 -2
- package/dist/src/services/fileDiscoveryService.js +79 -7
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +142 -10
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/gitService.d.ts +2 -1
- package/dist/src/services/gitService.js +16 -6
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +26 -10
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.js +23 -4
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +24 -0
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.integration.test.js +2 -2
- package/dist/src/services/modelConfig.integration.test.js.map +1 -1
- package/dist/src/services/modelConfigService.d.ts +39 -4
- package/dist/src/services/modelConfigService.js +153 -76
- package/dist/src/services/modelConfigService.js.map +1 -1
- package/dist/src/services/modelConfigService.test.js +175 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -1
- package/dist/src/services/modelConfigServiceTestUtils.js +3 -1
- package/dist/src/services/modelConfigServiceTestUtils.js.map +1 -1
- package/dist/src/services/sessionSummaryService.js +2 -0
- package/dist/src/services/sessionSummaryService.js.map +1 -1
- package/dist/src/services/sessionSummaryService.test.js +1 -1
- package/dist/src/services/sessionSummaryService.test.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +48 -0
- package/dist/src/services/shellExecutionService.js +339 -97
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +132 -17
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases-retry.golden.json +26 -8
- package/dist/src/services/test-data/resolved-aliases.golden.json +26 -8
- package/dist/src/services/toolOutputMaskingService.d.ts +43 -0
- package/dist/src/services/toolOutputMaskingService.js +286 -0
- package/dist/src/services/toolOutputMaskingService.js.map +1 -0
- package/dist/src/services/toolOutputMaskingService.test.d.ts +6 -0
- package/dist/src/services/toolOutputMaskingService.test.js +546 -0
- package/dist/src/services/toolOutputMaskingService.test.js.map +1 -0
- package/dist/src/skills/builtin/skill-creator/SKILL.md +382 -0
- package/dist/src/skills/builtin/skill-creator/scripts/init_skill.cjs +239 -0
- package/dist/src/skills/builtin/skill-creator/scripts/package_skill.cjs +106 -0
- package/dist/src/skills/builtin/skill-creator/scripts/validate_skill.cjs +131 -0
- package/dist/src/skills/skillLoader.d.ts +3 -0
- package/dist/src/skills/skillLoader.js +73 -12
- package/dist/src/skills/skillLoader.js.map +1 -1
- package/dist/src/skills/skillLoader.test.d.ts +5 -0
- package/dist/src/skills/skillLoader.test.js +195 -1
- package/dist/src/skills/skillLoader.test.js.map +1 -1
- package/dist/src/skills/skillManager.d.ts +25 -3
- package/dist/src/skills/skillManager.js +76 -11
- package/dist/src/skills/skillManager.js.map +1 -1
- package/dist/src/skills/skillManager.test.js +209 -9
- package/dist/src/skills/skillManager.test.js.map +1 -1
- package/dist/src/skills/skillManagerAlias.test.d.ts +6 -0
- package/dist/src/skills/skillManagerAlias.test.js +140 -0
- package/dist/src/skills/skillManagerAlias.test.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.js +1 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +25 -4
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +207 -12
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +210 -6
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +23 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +61 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/file-exporters.js +2 -1
- package/dist/src/telemetry/file-exporters.js.map +1 -1
- package/dist/src/telemetry/file-exporters.test.d.ts +6 -0
- package/dist/src/telemetry/file-exporters.test.js +142 -0
- package/dist/src/telemetry/file-exporters.test.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.js +1 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +3 -2
- package/dist/src/telemetry/index.js +3 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/integration.test.circular.js +2 -1
- package/dist/src/telemetry/integration.test.circular.js.map +1 -1
- package/dist/src/telemetry/llmRole.d.ts +18 -0
- package/dist/src/telemetry/llmRole.js +20 -0
- package/dist/src/telemetry/llmRole.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +8 -1
- package/dist/src/telemetry/loggers.js +113 -10
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +5 -2
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +169 -19
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.test.js +1 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +39 -1
- package/dist/src/telemetry/metrics.js +105 -4
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +84 -4
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sanitize.test.js +2 -0
- package/dist/src/telemetry/sanitize.test.js.map +1 -1
- package/dist/src/telemetry/sdk.js +24 -0
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +5 -1
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/semantic.js +92 -0
- package/dist/src/telemetry/semantic.js.map +1 -1
- package/dist/src/telemetry/semantic.truncation.test.d.ts +1 -0
- package/dist/src/telemetry/semantic.truncation.test.js +92 -0
- package/dist/src/telemetry/semantic.truncation.test.js.map +1 -0
- package/dist/src/telemetry/telemetryAttributes.js +5 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +98 -15
- package/dist/src/telemetry/types.js +227 -16
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +16 -0
- package/dist/src/telemetry/uiTelemetry.js +39 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +29 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/mock-message-bus.d.ts +1 -19
- package/dist/src/test-utils/mock-message-bus.js +5 -65
- package/dist/src/test-utils/mock-message-bus.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +1 -0
- package/dist/src/test-utils/mock-tool.js +1 -0
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/test-utils/mockWorkspaceContext.js +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.js.map +1 -1
- package/dist/src/tools/activate-skill.d.ts +1 -0
- package/dist/src/tools/activate-skill.js +28 -25
- package/dist/src/tools/activate-skill.js.map +1 -1
- package/dist/src/tools/activate-skill.test.js +24 -6
- package/dist/src/tools/activate-skill.test.js.map +1 -1
- package/dist/src/tools/ask-user.d.ts +29 -0
- package/dist/src/tools/ask-user.js +141 -0
- package/dist/src/tools/ask-user.js.map +1 -0
- package/dist/src/tools/ask-user.test.d.ts +6 -0
- package/dist/src/tools/ask-user.test.js +446 -0
- package/dist/src/tools/ask-user.test.js.map +1 -0
- package/dist/src/tools/confirmation-policy.test.js +21 -0
- package/dist/src/tools/confirmation-policy.test.js.map +1 -1
- package/dist/src/tools/constants.d.ts +7 -0
- package/dist/src/tools/constants.js +8 -0
- package/dist/src/tools/constants.js.map +1 -0
- package/dist/src/tools/definitions/base-declarations.d.ts +26 -0
- package/dist/src/tools/definitions/base-declarations.js +30 -0
- package/dist/src/tools/definitions/base-declarations.js.map +1 -0
- package/dist/src/tools/definitions/coreTools.d.ts +36 -0
- package/dist/src/tools/definitions/coreTools.js +143 -0
- package/dist/src/tools/definitions/coreTools.js.map +1 -0
- package/dist/src/tools/definitions/coreToolsModelSnapshots.test.d.ts +6 -0
- package/dist/src/tools/definitions/coreToolsModelSnapshots.test.js +82 -0
- package/dist/src/tools/definitions/coreToolsModelSnapshots.test.js.map +1 -0
- package/dist/src/tools/definitions/dynamic-declaration-helpers.d.ts +30 -0
- package/dist/src/tools/definitions/dynamic-declaration-helpers.js +135 -0
- package/dist/src/tools/definitions/dynamic-declaration-helpers.js.map +1 -0
- package/dist/src/tools/definitions/model-family-sets/default-legacy.d.ts +11 -0
- package/dist/src/tools/definitions/model-family-sets/default-legacy.js +575 -0
- package/dist/src/tools/definitions/model-family-sets/default-legacy.js.map +1 -0
- package/dist/src/tools/definitions/model-family-sets/gemini-3.d.ts +14 -0
- package/dist/src/tools/definitions/model-family-sets/gemini-3.js +578 -0
- package/dist/src/tools/definitions/model-family-sets/gemini-3.js.map +1 -0
- package/dist/src/tools/definitions/modelFamilyService.d.ts +14 -0
- package/dist/src/tools/definitions/modelFamilyService.js +29 -0
- package/dist/src/tools/definitions/modelFamilyService.js.map +1 -0
- package/dist/src/tools/definitions/resolver.d.ts +15 -0
- package/dist/src/tools/definitions/resolver.js +27 -0
- package/dist/src/tools/definitions/resolver.js.map +1 -0
- package/dist/src/tools/definitions/resolver.test.d.ts +6 -0
- package/dist/src/tools/definitions/resolver.test.js +58 -0
- package/dist/src/tools/definitions/resolver.test.js.map +1 -0
- package/dist/src/tools/definitions/types.d.ts +44 -0
- package/dist/src/tools/definitions/types.js +7 -0
- package/dist/src/tools/definitions/types.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +1 -1
- package/dist/src/tools/diffOptions.js +7 -3
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/diffOptions.test.js +17 -0
- package/dist/src/tools/diffOptions.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +1 -0
- package/dist/src/tools/edit.js +52 -82
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +96 -1
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/enter-plan-mode.d.ts +25 -0
- package/dist/src/tools/enter-plan-mode.js +69 -0
- package/dist/src/tools/enter-plan-mode.js.map +1 -0
- package/dist/src/tools/enter-plan-mode.test.d.ts +6 -0
- package/dist/src/tools/enter-plan-mode.test.js +102 -0
- package/dist/src/tools/enter-plan-mode.test.js.map +1 -0
- package/dist/src/tools/exit-plan-mode.d.ts +33 -0
- package/dist/src/tools/exit-plan-mode.js +173 -0
- package/dist/src/tools/exit-plan-mode.js.map +1 -0
- package/dist/src/tools/exit-plan-mode.test.d.ts +6 -0
- package/dist/src/tools/exit-plan-mode.test.js +311 -0
- package/dist/src/tools/exit-plan-mode.test.js.map +1 -0
- package/dist/src/tools/get-internal-docs.d.ts +1 -0
- package/dist/src/tools/get-internal-docs.js +17 -27
- package/dist/src/tools/get-internal-docs.js.map +1 -1
- package/dist/src/tools/glob.d.ts +1 -0
- package/dist/src/tools/glob.js +15 -36
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +219 -280
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +18 -8
- package/dist/src/tools/grep.js +273 -247
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +165 -16
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/line-endings.test.d.ts +6 -0
- package/dist/src/tools/line-endings.test.js +209 -0
- package/dist/src/tools/line-endings.test.js.map +1 -0
- package/dist/src/tools/ls.d.ts +1 -0
- package/dist/src/tools/ls.js +18 -37
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +25 -3
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +18 -5
- package/dist/src/tools/mcp-client-manager.js +118 -37
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +124 -16
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +18 -7
- package/dist/src/tools/mcp-client.js +137 -42
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +248 -29
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +26 -4
- package/dist/src/tools/mcp-tool.js +17 -5
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +5 -5
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +2 -7
- package/dist/src/tools/memoryTool.js +54 -80
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +62 -114
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +3 -3
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +2 -0
- package/dist/src/tools/read-file.js +26 -30
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +90 -3
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +1 -0
- package/dist/src/tools/read-many-files.js +21 -63
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +43 -1
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +20 -3
- package/dist/src/tools/ripGrep.js +217 -189
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +745 -567
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +1 -0
- package/dist/src/tools/shell.js +8 -3
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +248 -11
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +4 -0
- package/dist/src/tools/tool-error.js +4 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +27 -17
- package/dist/src/tools/tool-names.js +59 -20
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tool-names.test.js +55 -2
- package/dist/src/tools/tool-names.test.js.map +1 -1
- package/dist/src/tools/tool-registry.d.ts +10 -2
- package/dist/src/tools/tool-registry.js +58 -11
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +113 -1
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +52 -5
- package/dist/src/tools/tools.js +35 -18
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +1 -0
- package/dist/src/tools/web-fetch.js +12 -12
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +1 -0
- package/dist/src/tools/web-search.js +9 -11
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +1 -4
- package/dist/src/tools/write-file.js +42 -35
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +105 -18
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +1 -30
- package/dist/src/tools/write-todos.js +5 -123
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/tools/xcode-mcp-fix-transport.d.ts +30 -0
- package/dist/src/tools/xcode-mcp-fix-transport.js +82 -0
- package/dist/src/tools/xcode-mcp-fix-transport.js.map +1 -0
- package/dist/src/tools/xcode-mcp-fix-transport.test.d.ts +1 -0
- package/dist/src/tools/xcode-mcp-fix-transport.test.js +98 -0
- package/dist/src/tools/xcode-mcp-fix-transport.test.js.map +1 -0
- package/dist/src/utils/apiConversionUtils.d.ts +12 -0
- package/dist/src/utils/apiConversionUtils.js +46 -0
- package/dist/src/utils/apiConversionUtils.js.map +1 -0
- package/dist/src/utils/apiConversionUtils.test.d.ts +6 -0
- package/dist/src/utils/apiConversionUtils.test.js +150 -0
- package/dist/src/utils/apiConversionUtils.test.js.map +1 -0
- package/dist/src/utils/authConsent.d.ts +10 -0
- package/dist/src/utils/authConsent.js +52 -0
- package/dist/src/utils/authConsent.js.map +1 -0
- package/dist/src/utils/authConsent.test.d.ts +6 -0
- package/dist/src/utils/authConsent.test.js +74 -0
- package/dist/src/utils/authConsent.test.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.js +2 -0
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +6 -1
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/checkpointUtils.d.ts +2 -2
- package/dist/src/utils/checkpointUtils.js +2 -0
- package/dist/src/utils/checkpointUtils.js.map +1 -1
- package/dist/src/utils/checks.d.ts +19 -0
- package/dist/src/utils/checks.js +24 -0
- package/dist/src/utils/checks.js.map +1 -0
- package/dist/src/utils/checks.test.d.ts +6 -0
- package/dist/src/utils/checks.test.js +29 -0
- package/dist/src/utils/checks.test.js.map +1 -0
- package/dist/src/utils/constants.d.ts +7 -0
- package/dist/src/utils/constants.js +8 -0
- package/dist/src/utils/constants.js.map +1 -0
- package/dist/src/utils/deadlineTimer.d.ts +36 -0
- package/dist/src/utils/deadlineTimer.js +87 -0
- package/dist/src/utils/deadlineTimer.js.map +1 -0
- package/dist/src/utils/deadlineTimer.test.d.ts +6 -0
- package/dist/src/utils/deadlineTimer.test.js +64 -0
- package/dist/src/utils/deadlineTimer.test.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +3 -3
- package/dist/src/utils/editCorrector.js +37 -10
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +49 -20
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +17 -3
- package/dist/src/utils/editor.js +84 -15
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +160 -17
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.js +9 -20
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +31 -14
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +13 -3
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/errors.test.js +23 -1
- package/dist/src/utils/errors.test.js.map +1 -1
- package/dist/src/utils/events.d.ts +107 -3
- package/dist/src/utils/events.js +65 -1
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/events.test.js +43 -0
- package/dist/src/utils/events.test.js.map +1 -1
- package/dist/src/utils/extensionLoader.js +2 -0
- package/dist/src/utils/extensionLoader.js.map +1 -1
- package/dist/src/utils/extensionLoader.test.js +21 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -1
- package/dist/src/utils/fastAckHelper.d.ts +30 -0
- package/dist/src/utils/fastAckHelper.js +142 -0
- package/dist/src/utils/fastAckHelper.js.map +1 -0
- package/dist/src/utils/fastAckHelper.test.d.ts +6 -0
- package/dist/src/utils/fastAckHelper.test.js +115 -0
- package/dist/src/utils/fastAckHelper.test.js.map +1 -0
- package/dist/src/utils/fileDiffUtils.d.ts +18 -0
- package/dist/src/utils/fileDiffUtils.js +37 -0
- package/dist/src/utils/fileDiffUtils.js.map +1 -0
- package/dist/src/utils/fileDiffUtils.test.d.ts +6 -0
- package/dist/src/utils/fileDiffUtils.test.js +84 -0
- package/dist/src/utils/fileDiffUtils.test.js.map +1 -0
- package/dist/src/utils/fileUtils.d.ts +27 -3
- package/dist/src/utils/fileUtils.js +104 -60
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +129 -109
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.d.ts +1 -0
- package/dist/src/utils/filesearch/crawler.js +18 -1
- package/dist/src/utils/filesearch/crawler.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.test.js +101 -82
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +4 -3
- package/dist/src/utils/filesearch/fileSearch.js +5 -4
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.test.js +172 -84
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
- package/dist/src/utils/filesearch/ignore.d.ts +2 -7
- package/dist/src/utils/filesearch/ignore.js +7 -14
- package/dist/src/utils/filesearch/ignore.js.map +1 -1
- package/dist/src/utils/filesearch/ignore.test.js +30 -32
- package/dist/src/utils/filesearch/ignore.test.js.map +1 -1
- package/dist/src/utils/formatters.d.ts +1 -1
- package/dist/src/utils/formatters.js +1 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.js +5 -5
- package/dist/src/utils/formatters.test.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.js +3 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +5 -2
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/getPty.js +3 -0
- package/dist/src/utils/getPty.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.js +10 -11
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/googleErrors.js +4 -0
- package/dist/src/utils/googleErrors.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.d.ts +23 -9
- package/dist/src/utils/googleQuotaErrors.js +90 -23
- package/dist/src/utils/googleQuotaErrors.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.test.js +168 -23
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -1
- package/dist/src/utils/headless.d.ts +26 -0
- package/dist/src/utils/headless.js +33 -0
- package/dist/src/utils/headless.js.map +1 -0
- package/dist/src/utils/headless.test.d.ts +6 -0
- package/dist/src/utils/headless.test.js +167 -0
- package/dist/src/utils/headless.test.js.map +1 -0
- package/dist/src/utils/httpErrors.js +4 -1
- package/dist/src/utils/httpErrors.js.map +1 -1
- package/dist/src/utils/ignoreFileParser.d.ts +30 -0
- package/dist/src/utils/ignoreFileParser.js +100 -0
- package/dist/src/utils/ignoreFileParser.js.map +1 -0
- package/dist/src/utils/ignoreFileParser.test.d.ts +6 -0
- package/dist/src/utils/ignoreFileParser.test.js +167 -0
- package/dist/src/utils/ignoreFileParser.test.js.map +1 -0
- package/dist/src/utils/installationManager.test.js +11 -3
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.js +9 -9
- package/dist/src/utils/llm-edit-fixer.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.test.js +2 -2
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +11 -3
- package/dist/src/utils/memoryDiscovery.js +122 -102
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +163 -109
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +7 -24
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.js +3 -0
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/package.js +10 -3
- package/dist/src/utils/package.js.map +1 -1
- package/dist/src/utils/package.test.d.ts +6 -0
- package/dist/src/utils/package.test.js +57 -0
- package/dist/src/utils/package.test.js.map +1 -0
- package/dist/src/utils/partUtils.js +2 -1
- package/dist/src/utils/partUtils.js.map +1 -1
- package/dist/src/utils/paths.d.ts +33 -9
- package/dist/src/utils/paths.js +88 -29
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/paths.test.js +206 -110
- package/dist/src/utils/paths.test.js.map +1 -1
- package/dist/src/utils/planUtils.d.ts +29 -0
- package/dist/src/utils/planUtils.js +55 -0
- package/dist/src/utils/planUtils.js.map +1 -0
- package/dist/src/utils/planUtils.test.d.ts +6 -0
- package/dist/src/utils/planUtils.test.js +76 -0
- package/dist/src/utils/planUtils.test.js.map +1 -0
- package/dist/src/utils/process-utils.d.ts +32 -0
- package/dist/src/utils/process-utils.js +88 -0
- package/dist/src/utils/process-utils.js.map +1 -0
- package/dist/src/utils/process-utils.test.d.ts +6 -0
- package/dist/src/utils/process-utils.test.js +103 -0
- package/dist/src/utils/process-utils.test.js.map +1 -0
- package/dist/src/utils/promptIdContext.d.ts +6 -0
- package/dist/src/utils/promptIdContext.js +15 -0
- package/dist/src/utils/promptIdContext.js.map +1 -1
- package/dist/src/utils/quotaErrorDetection.js +3 -0
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +4 -0
- package/dist/src/utils/retry.js +84 -5
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +70 -3
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/safeJsonStringify.js +1 -0
- package/dist/src/utils/safeJsonStringify.js.map +1 -1
- package/dist/src/utils/schemaValidator.d.ts +8 -1
- package/dist/src/utils/schemaValidator.js +78 -11
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/schemaValidator.test.js +77 -0
- package/dist/src/utils/schemaValidator.test.js.map +1 -1
- package/dist/src/utils/security.d.ts +16 -0
- package/dist/src/utils/security.js +91 -0
- package/dist/src/utils/security.js.map +1 -0
- package/dist/src/utils/security.test.d.ts +1 -0
- package/dist/src/utils/security.test.js +121 -0
- package/dist/src/utils/security.test.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +14 -0
- package/dist/src/utils/shell-utils.integration.test.d.ts +1 -0
- package/dist/src/utils/shell-utils.integration.test.js +58 -0
- package/dist/src/utils/shell-utils.integration.test.js.map +1 -0
- package/dist/src/utils/shell-utils.js +191 -30
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +108 -1
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/summarizer.js +2 -1
- package/dist/src/utils/summarizer.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +4 -0
- package/dist/src/utils/terminal.js +12 -0
- package/dist/src/utils/terminal.js.map +1 -1
- package/dist/src/utils/terminalSerializer.d.ts +1 -1
- package/dist/src/utils/terminalSerializer.js +25 -13
- package/dist/src/utils/terminalSerializer.js.map +1 -1
- package/dist/src/utils/testUtils.js +1 -0
- package/dist/src/utils/testUtils.js.map +1 -1
- package/dist/src/utils/textUtils.d.ts +14 -0
- package/dist/src/utils/textUtils.js +23 -0
- package/dist/src/utils/textUtils.js.map +1 -1
- package/dist/src/utils/textUtils.test.js +18 -1
- package/dist/src/utils/textUtils.test.js.map +1 -1
- package/dist/src/utils/tokenCalculation.d.ts +2 -2
- package/dist/src/utils/tokenCalculation.js +87 -21
- package/dist/src/utils/tokenCalculation.js.map +1 -1
- package/dist/src/utils/tokenCalculation.test.js +189 -76
- package/dist/src/utils/tokenCalculation.test.js.map +1 -1
- package/dist/src/utils/tool-utils.d.ts +26 -0
- package/dist/src/utils/tool-utils.js +36 -0
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +73 -3
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/toolCallContext.d.ts +35 -0
- package/dist/src/utils/toolCallContext.js +29 -0
- package/dist/src/utils/toolCallContext.js.map +1 -0
- package/dist/src/utils/toolCallContext.test.d.ts +6 -0
- package/dist/src/utils/toolCallContext.test.js +68 -0
- package/dist/src/utils/toolCallContext.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.js +1 -0
- package/dist/src/utils/userAccountManager.js.map +1 -1
- package/dist/src/utils/userAccountManager.test.js +5 -5
- package/dist/src/utils/userAccountManager.test.js.map +1 -1
- package/dist/src/utils/version.d.ts +2 -0
- package/dist/src/utils/version.js +14 -3
- package/dist/src/utils/version.js.map +1 -1
- package/dist/src/utils/version.test.js +15 -1
- package/dist/src/utils/version.test.js.map +1 -1
- package/dist/src/utils/workspaceContext.d.ts +28 -0
- package/dist/src/utils/workspaceContext.js +74 -9
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +56 -1
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -15
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
import { describe, it, expect, beforeEach, afterEach, afterAll, vi, } from 'vitest';
|
|
7
7
|
import { canUseRipgrep, RipGrepTool, ensureRgPath } from './ripGrep.js';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
+
import { isSubpath } from '../utils/paths.js';
|
|
9
10
|
import fs from 'node:fs/promises';
|
|
10
11
|
import os from 'node:os';
|
|
11
12
|
import { Storage } from '../config/storage.js';
|
|
13
|
+
import { GEMINI_IGNORE_FILE_NAME } from '../config/constants.js';
|
|
12
14
|
import { createMockWorkspaceContext } from '../test-utils/mockWorkspaceContext.js';
|
|
13
15
|
import { spawn } from 'node:child_process';
|
|
16
|
+
import { PassThrough, Readable } from 'node:stream';
|
|
17
|
+
import EventEmitter from 'node:events';
|
|
14
18
|
import { downloadRipGrep } from '@joshua.litt/get-ripgrep';
|
|
15
19
|
import { createMockMessageBus } from '../test-utils/mock-message-bus.js';
|
|
16
20
|
// Mock dependencies for canUseRipgrep
|
|
@@ -144,30 +148,32 @@ describe('ensureRgPath', () => {
|
|
|
144
148
|
function createMockSpawn(options = {}) {
|
|
145
149
|
const { outputData, exitCode = 0, signal } = options;
|
|
146
150
|
return () => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
// strict Readable implementation
|
|
152
|
+
let pushed = false;
|
|
153
|
+
const stdout = new Readable({
|
|
154
|
+
read() {
|
|
155
|
+
if (!pushed) {
|
|
156
|
+
if (outputData) {
|
|
157
|
+
this.push(outputData);
|
|
158
|
+
}
|
|
159
|
+
this.push(null); // EOF
|
|
160
|
+
pushed = true;
|
|
161
|
+
}
|
|
155
162
|
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
163
|
+
});
|
|
164
|
+
const stderr = new PassThrough();
|
|
165
|
+
const mockProcess = new EventEmitter();
|
|
166
|
+
mockProcess.stdout = stdout;
|
|
167
|
+
mockProcess.stderr = stderr;
|
|
168
|
+
mockProcess.kill = vi.fn();
|
|
169
|
+
// @ts-expect-error - mocking private/internal property
|
|
170
|
+
mockProcess.killed = false;
|
|
171
|
+
// @ts-expect-error - mocking private/internal property
|
|
172
|
+
mockProcess.exitCode = null;
|
|
173
|
+
// Emulating process exit
|
|
161
174
|
setTimeout(() => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (stdoutDataHandler && outputData) {
|
|
165
|
-
stdoutDataHandler(Buffer.from(outputData));
|
|
166
|
-
}
|
|
167
|
-
if (closeHandler) {
|
|
168
|
-
closeHandler(exitCode, signal);
|
|
169
|
-
}
|
|
170
|
-
}, 0);
|
|
175
|
+
mockProcess.emit('close', exitCode, signal);
|
|
176
|
+
}, 10);
|
|
171
177
|
return mockProcess;
|
|
172
178
|
};
|
|
173
179
|
}
|
|
@@ -178,11 +184,16 @@ describe('RipGrepTool', () => {
|
|
|
178
184
|
let ripgrepBinaryPath;
|
|
179
185
|
let grepTool;
|
|
180
186
|
const abortSignal = new AbortController().signal;
|
|
181
|
-
|
|
187
|
+
let mockConfig = {
|
|
182
188
|
getTargetDir: () => tempRootDir,
|
|
183
189
|
getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir),
|
|
184
190
|
getDebugMode: () => false,
|
|
191
|
+
getFileFilteringRespectGitIgnore: () => true,
|
|
185
192
|
getFileFilteringRespectGeminiIgnore: () => true,
|
|
193
|
+
getFileFilteringOptions: () => ({
|
|
194
|
+
respectGitIgnore: true,
|
|
195
|
+
respectGeminiIgnore: true,
|
|
196
|
+
}),
|
|
186
197
|
};
|
|
187
198
|
beforeEach(async () => {
|
|
188
199
|
downloadRipGrepMock.mockReset();
|
|
@@ -196,6 +207,36 @@ describe('RipGrepTool', () => {
|
|
|
196
207
|
await fs.writeFile(ripgrepBinaryPath, '');
|
|
197
208
|
storageSpy.mockImplementation(() => binDir);
|
|
198
209
|
tempRootDir = await fs.mkdtemp(path.join(os.tmpdir(), 'grep-tool-root-'));
|
|
210
|
+
mockConfig = {
|
|
211
|
+
getTargetDir: () => tempRootDir,
|
|
212
|
+
getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir),
|
|
213
|
+
getDebugMode: () => false,
|
|
214
|
+
getFileFilteringRespectGitIgnore: () => true,
|
|
215
|
+
getFileFilteringRespectGeminiIgnore: () => true,
|
|
216
|
+
getFileFilteringOptions: () => ({
|
|
217
|
+
respectGitIgnore: true,
|
|
218
|
+
respectGeminiIgnore: true,
|
|
219
|
+
}),
|
|
220
|
+
storage: {
|
|
221
|
+
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project'),
|
|
222
|
+
},
|
|
223
|
+
isPathAllowed(absolutePath) {
|
|
224
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
225
|
+
if (workspaceContext.isPathWithinWorkspace(absolutePath)) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
229
|
+
return isSubpath(path.resolve(projectTempDir), absolutePath);
|
|
230
|
+
},
|
|
231
|
+
validatePathAccess(absolutePath) {
|
|
232
|
+
if (this.isPathAllowed(absolutePath)) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
const workspaceDirs = this.getWorkspaceContext().getDirectories();
|
|
236
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
237
|
+
return `Path not in workspace: Attempted path "${absolutePath}" resolves outside the allowed workspace directories: ${workspaceDirs.join(', ')} or the project temp directory: ${projectTempDir}`;
|
|
238
|
+
},
|
|
239
|
+
};
|
|
199
240
|
grepTool = new RipGrepTool(mockConfig, createMockMessageBus());
|
|
200
241
|
// Create some test files and directories
|
|
201
242
|
await fs.writeFile(path.join(tempRootDir, 'fileA.txt'), 'hello world\nsecond line with world');
|
|
@@ -226,14 +267,13 @@ describe('RipGrepTool', () => {
|
|
|
226
267
|
params: { pattern: 'hello', dir_path: '.', include: '*.txt' },
|
|
227
268
|
expected: null,
|
|
228
269
|
},
|
|
229
|
-
{
|
|
230
|
-
name: 'invalid regex pattern',
|
|
231
|
-
params: { pattern: '[[' },
|
|
232
|
-
expected: null,
|
|
233
|
-
},
|
|
234
270
|
])('should return null for valid params ($name)', ({ params, expected }) => {
|
|
235
271
|
expect(grepTool.validateToolParams(params)).toBe(expected);
|
|
236
272
|
});
|
|
273
|
+
it('should throw error for invalid regex pattern', () => {
|
|
274
|
+
const params = { pattern: '[[' };
|
|
275
|
+
expect(grepTool.validateToolParams(params)).toMatch(/Invalid regular expression pattern provided/);
|
|
276
|
+
});
|
|
237
277
|
it('should return error if pattern is missing', () => {
|
|
238
278
|
const params = { dir_path: '.' };
|
|
239
279
|
expect(grepTool.validateToolParams(params)).toBe(`params must have required property 'pattern'`);
|
|
@@ -244,8 +284,9 @@ describe('RipGrepTool', () => {
|
|
|
244
284
|
dir_path: 'nonexistent',
|
|
245
285
|
};
|
|
246
286
|
// Check for the core error message, as the full path might vary
|
|
247
|
-
|
|
248
|
-
expect(
|
|
287
|
+
const result = grepTool.validateToolParams(params);
|
|
288
|
+
expect(result).toMatch(/Path does not exist/);
|
|
289
|
+
expect(result).toMatch(/nonexistent/);
|
|
249
290
|
});
|
|
250
291
|
it('should allow path to be a file', async () => {
|
|
251
292
|
const filePath = path.join(tempRootDir, 'fileA.txt');
|
|
@@ -299,6 +340,35 @@ describe('RipGrepTool', () => {
|
|
|
299
340
|
expect(result.llmContent).toContain('L1: another world in sub dir');
|
|
300
341
|
expect(result.returnDisplay).toBe('Found 3 matches');
|
|
301
342
|
});
|
|
343
|
+
it('should ignore matches that escape the base path', async () => {
|
|
344
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
345
|
+
outputData: JSON.stringify({
|
|
346
|
+
type: 'match',
|
|
347
|
+
data: {
|
|
348
|
+
path: { text: '..env' },
|
|
349
|
+
line_number: 1,
|
|
350
|
+
lines: { text: 'world in ..env\n' },
|
|
351
|
+
},
|
|
352
|
+
}) +
|
|
353
|
+
'\n' +
|
|
354
|
+
JSON.stringify({
|
|
355
|
+
type: 'match',
|
|
356
|
+
data: {
|
|
357
|
+
path: { text: '../secret.txt' },
|
|
358
|
+
line_number: 1,
|
|
359
|
+
lines: { text: 'leak\n' },
|
|
360
|
+
},
|
|
361
|
+
}) +
|
|
362
|
+
'\n',
|
|
363
|
+
exitCode: 0,
|
|
364
|
+
}));
|
|
365
|
+
const params = { pattern: 'world' };
|
|
366
|
+
const invocation = grepTool.build(params);
|
|
367
|
+
const result = await invocation.execute(abortSignal);
|
|
368
|
+
expect(result.llmContent).toContain('File: ..env');
|
|
369
|
+
expect(result.llmContent).toContain('L1: world in ..env');
|
|
370
|
+
expect(result.llmContent).not.toContain('secret.txt');
|
|
371
|
+
});
|
|
302
372
|
it('should find matches in a specific path', async () => {
|
|
303
373
|
// Setup specific mock for this test - searching in 'sub' should only return matches from that directory
|
|
304
374
|
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
@@ -344,40 +414,17 @@ describe('RipGrepTool', () => {
|
|
|
344
414
|
it('should find matches with an include glob and path', async () => {
|
|
345
415
|
await fs.writeFile(path.join(tempRootDir, 'sub', 'another.js'), 'const greeting = "hello";');
|
|
346
416
|
// Setup specific mock for this test - searching for 'hello' in 'sub' with '*.js' filter
|
|
347
|
-
mockSpawn.mockImplementationOnce((
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
on: vi.fn(),
|
|
355
|
-
removeListener: vi.fn(),
|
|
417
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
418
|
+
outputData: JSON.stringify({
|
|
419
|
+
type: 'match',
|
|
420
|
+
data: {
|
|
421
|
+
path: { text: 'another.js' },
|
|
422
|
+
line_number: 1,
|
|
423
|
+
lines: { text: 'const greeting = "hello";\n' },
|
|
356
424
|
},
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
};
|
|
361
|
-
setTimeout(() => {
|
|
362
|
-
const onData = mockProcess.stdout.on.mock.calls.find((call) => call[0] === 'data')?.[1];
|
|
363
|
-
const onClose = mockProcess.on.mock.calls.find((call) => call[0] === 'close')?.[1];
|
|
364
|
-
if (onData) {
|
|
365
|
-
// Only return match from the .js file in sub directory
|
|
366
|
-
onData(Buffer.from(JSON.stringify({
|
|
367
|
-
type: 'match',
|
|
368
|
-
data: {
|
|
369
|
-
path: { text: 'another.js' },
|
|
370
|
-
line_number: 1,
|
|
371
|
-
lines: { text: 'const greeting = "hello";\n' },
|
|
372
|
-
},
|
|
373
|
-
}) + '\n'));
|
|
374
|
-
}
|
|
375
|
-
if (onClose) {
|
|
376
|
-
onClose(0);
|
|
377
|
-
}
|
|
378
|
-
}, 0);
|
|
379
|
-
return mockProcess;
|
|
380
|
-
});
|
|
425
|
+
}) + '\n',
|
|
426
|
+
exitCode: 0,
|
|
427
|
+
}));
|
|
381
428
|
const params = {
|
|
382
429
|
pattern: 'hello',
|
|
383
430
|
dir_path: 'sub',
|
|
@@ -401,52 +448,132 @@ describe('RipGrepTool', () => {
|
|
|
401
448
|
expect(result.llmContent).toContain('No matches found for pattern "nonexistentpattern" in path ".".');
|
|
402
449
|
expect(result.returnDisplay).toBe('No matches found');
|
|
403
450
|
});
|
|
404
|
-
it('should
|
|
405
|
-
|
|
451
|
+
it('should throw error for invalid regex pattern during build', async () => {
|
|
452
|
+
const params = { pattern: '[[' };
|
|
453
|
+
expect(() => grepTool.build(params)).toThrow(/Invalid regular expression pattern provided/);
|
|
454
|
+
});
|
|
455
|
+
it('should ignore invalid regex error from ripgrep when it is not a user error', async () => {
|
|
456
|
+
mockSpawn.mockImplementation(createMockSpawn({
|
|
457
|
+
outputData: '',
|
|
406
458
|
exitCode: 2,
|
|
459
|
+
signal: undefined,
|
|
407
460
|
}));
|
|
408
|
-
const
|
|
409
|
-
|
|
461
|
+
const invocation = grepTool.build({
|
|
462
|
+
pattern: 'foo',
|
|
463
|
+
dir_path: tempRootDir,
|
|
464
|
+
});
|
|
410
465
|
const result = await invocation.execute(abortSignal);
|
|
411
|
-
expect(result.llmContent).toContain('
|
|
412
|
-
expect(result.returnDisplay).toContain('Error:
|
|
466
|
+
expect(result.llmContent).toContain('Process exited with code 2');
|
|
467
|
+
expect(result.returnDisplay).toContain('Error: Process exited with code 2');
|
|
413
468
|
});
|
|
414
|
-
it('should handle
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
469
|
+
it('should handle massive output by terminating early without crashing (Regression)', async () => {
|
|
470
|
+
const massiveOutputLines = 30000;
|
|
471
|
+
// Custom mock for massive streaming
|
|
472
|
+
mockSpawn.mockImplementation(() => {
|
|
473
|
+
const stdout = new PassThrough();
|
|
474
|
+
const stderr = new PassThrough();
|
|
475
|
+
const mockProcess = new EventEmitter();
|
|
476
|
+
mockProcess.stdout = stdout;
|
|
477
|
+
mockProcess.stderr = stderr;
|
|
478
|
+
mockProcess.kill = vi.fn();
|
|
479
|
+
// @ts-expect-error - mocking private/internal property
|
|
480
|
+
mockProcess.killed = false;
|
|
481
|
+
// @ts-expect-error - mocking private/internal property
|
|
482
|
+
mockProcess.exitCode = null;
|
|
483
|
+
// Push data over time
|
|
484
|
+
let linesPushed = 0;
|
|
485
|
+
const pushInterval = setInterval(() => {
|
|
486
|
+
if (linesPushed >= massiveOutputLines) {
|
|
487
|
+
clearInterval(pushInterval);
|
|
488
|
+
stdout.end();
|
|
489
|
+
mockProcess.emit('close', 0);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
// Push a batch
|
|
493
|
+
try {
|
|
494
|
+
for (let i = 0; i < 2000 && linesPushed < massiveOutputLines; i++) {
|
|
495
|
+
const match = JSON.stringify({
|
|
496
|
+
type: 'match',
|
|
497
|
+
data: {
|
|
498
|
+
path: { text: `file_${linesPushed}.txt` },
|
|
499
|
+
line_number: 1,
|
|
500
|
+
lines: { text: `match ${linesPushed}\n` },
|
|
501
|
+
},
|
|
502
|
+
});
|
|
503
|
+
stdout.write(match + '\n');
|
|
504
|
+
linesPushed++;
|
|
505
|
+
}
|
|
443
506
|
}
|
|
444
|
-
|
|
445
|
-
|
|
507
|
+
catch (_e) {
|
|
508
|
+
clearInterval(pushInterval);
|
|
446
509
|
}
|
|
447
|
-
},
|
|
510
|
+
}, 1);
|
|
511
|
+
mockProcess.kill = vi.fn().mockImplementation(() => {
|
|
512
|
+
clearInterval(pushInterval);
|
|
513
|
+
stdout.end();
|
|
514
|
+
// Emit close async to allow listeners to attach
|
|
515
|
+
setTimeout(() => mockProcess.emit('close', 0, 'SIGTERM'), 0);
|
|
516
|
+
return true;
|
|
517
|
+
});
|
|
448
518
|
return mockProcess;
|
|
449
519
|
});
|
|
520
|
+
const invocation = grepTool.build({
|
|
521
|
+
pattern: 'test',
|
|
522
|
+
dir_path: tempRootDir,
|
|
523
|
+
});
|
|
524
|
+
const result = await invocation.execute(abortSignal);
|
|
525
|
+
expect(result.returnDisplay).toContain('(limited)');
|
|
526
|
+
}, 10000);
|
|
527
|
+
it('should filter out files based on FileDiscoveryService even if ripgrep returns them', async () => {
|
|
528
|
+
// Create .geminiignore to ignore 'ignored.txt'
|
|
529
|
+
await fs.writeFile(path.join(tempRootDir, GEMINI_IGNORE_FILE_NAME), 'ignored.txt');
|
|
530
|
+
// Re-initialize tool so FileDiscoveryService loads the new .geminiignore
|
|
531
|
+
const toolWithIgnore = new RipGrepTool(mockConfig, createMockMessageBus());
|
|
532
|
+
// Mock ripgrep returning both an ignored file and an allowed file
|
|
533
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
534
|
+
outputData: JSON.stringify({
|
|
535
|
+
type: 'match',
|
|
536
|
+
data: {
|
|
537
|
+
path: { text: 'ignored.txt' },
|
|
538
|
+
line_number: 1,
|
|
539
|
+
lines: { text: 'should be ignored\n' },
|
|
540
|
+
},
|
|
541
|
+
}) +
|
|
542
|
+
'\n' +
|
|
543
|
+
JSON.stringify({
|
|
544
|
+
type: 'match',
|
|
545
|
+
data: {
|
|
546
|
+
path: { text: 'allowed.txt' },
|
|
547
|
+
line_number: 1,
|
|
548
|
+
lines: { text: 'should be kept\n' },
|
|
549
|
+
},
|
|
550
|
+
}) +
|
|
551
|
+
'\n',
|
|
552
|
+
exitCode: 0,
|
|
553
|
+
}));
|
|
554
|
+
const params = { pattern: 'should' };
|
|
555
|
+
const invocation = toolWithIgnore.build(params);
|
|
556
|
+
const result = await invocation.execute(abortSignal);
|
|
557
|
+
// Verify ignored file is filtered out
|
|
558
|
+
expect(result.llmContent).toContain('allowed.txt');
|
|
559
|
+
expect(result.llmContent).toContain('should be kept');
|
|
560
|
+
expect(result.llmContent).not.toContain('ignored.txt');
|
|
561
|
+
expect(result.llmContent).not.toContain('should be ignored');
|
|
562
|
+
expect(result.returnDisplay).toContain('Found 1 match');
|
|
563
|
+
});
|
|
564
|
+
it('should handle regex special characters correctly', async () => {
|
|
565
|
+
// Setup specific mock for this test - regex pattern 'foo.*bar' should match 'const foo = "bar";'
|
|
566
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
567
|
+
outputData: JSON.stringify({
|
|
568
|
+
type: 'match',
|
|
569
|
+
data: {
|
|
570
|
+
path: { text: 'fileB.js' },
|
|
571
|
+
line_number: 1,
|
|
572
|
+
lines: { text: 'const foo = "bar";\n' },
|
|
573
|
+
},
|
|
574
|
+
}) + '\n',
|
|
575
|
+
exitCode: 0,
|
|
576
|
+
}));
|
|
450
577
|
const params = { pattern: 'foo.*bar' }; // Matches 'const foo = "bar";'
|
|
451
578
|
const invocation = grepTool.build(params);
|
|
452
579
|
const result = await invocation.execute(abortSignal);
|
|
@@ -456,50 +583,27 @@ describe('RipGrepTool', () => {
|
|
|
456
583
|
});
|
|
457
584
|
it('should be case-insensitive by default (JS fallback)', async () => {
|
|
458
585
|
// Setup specific mock for this test - case insensitive search for 'HELLO'
|
|
459
|
-
mockSpawn.mockImplementationOnce((
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
on: vi.fn(),
|
|
467
|
-
removeListener: vi.fn(),
|
|
586
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
587
|
+
outputData: JSON.stringify({
|
|
588
|
+
type: 'match',
|
|
589
|
+
data: {
|
|
590
|
+
path: { text: 'fileA.txt' },
|
|
591
|
+
line_number: 1,
|
|
592
|
+
lines: { text: 'hello world\n' },
|
|
468
593
|
},
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
line_number: 1,
|
|
483
|
-
lines: { text: 'hello world\n' },
|
|
484
|
-
},
|
|
485
|
-
}) +
|
|
486
|
-
'\n' +
|
|
487
|
-
JSON.stringify({
|
|
488
|
-
type: 'match',
|
|
489
|
-
data: {
|
|
490
|
-
path: { text: 'fileB.js' },
|
|
491
|
-
line_number: 2,
|
|
492
|
-
lines: { text: 'function baz() { return "hello"; }\n' },
|
|
493
|
-
},
|
|
494
|
-
}) +
|
|
495
|
-
'\n'));
|
|
496
|
-
}
|
|
497
|
-
if (onClose) {
|
|
498
|
-
onClose(0);
|
|
499
|
-
}
|
|
500
|
-
}, 0);
|
|
501
|
-
return mockProcess;
|
|
502
|
-
});
|
|
594
|
+
}) +
|
|
595
|
+
'\n' +
|
|
596
|
+
JSON.stringify({
|
|
597
|
+
type: 'match',
|
|
598
|
+
data: {
|
|
599
|
+
path: { text: 'fileB.js' },
|
|
600
|
+
line_number: 2,
|
|
601
|
+
lines: { text: 'function baz() { return "hello"; }\n' },
|
|
602
|
+
},
|
|
603
|
+
}) +
|
|
604
|
+
'\n',
|
|
605
|
+
exitCode: 0,
|
|
606
|
+
}));
|
|
503
607
|
const params = { pattern: 'HELLO' };
|
|
504
608
|
const invocation = grepTool.build(params);
|
|
505
609
|
const result = await invocation.execute(abortSignal);
|
|
@@ -535,92 +639,63 @@ describe('RipGrepTool', () => {
|
|
|
535
639
|
getTargetDir: () => tempRootDir,
|
|
536
640
|
getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir, [secondDir]),
|
|
537
641
|
getDebugMode: () => false,
|
|
642
|
+
getFileFilteringRespectGitIgnore: () => true,
|
|
538
643
|
getFileFilteringRespectGeminiIgnore: () => true,
|
|
644
|
+
getFileFilteringOptions: () => ({
|
|
645
|
+
respectGitIgnore: true,
|
|
646
|
+
respectGeminiIgnore: true,
|
|
647
|
+
}),
|
|
648
|
+
storage: {
|
|
649
|
+
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project'),
|
|
650
|
+
},
|
|
651
|
+
isPathAllowed(absolutePath) {
|
|
652
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
653
|
+
if (workspaceContext.isPathWithinWorkspace(absolutePath)) {
|
|
654
|
+
return true;
|
|
655
|
+
}
|
|
656
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
657
|
+
return isSubpath(path.resolve(projectTempDir), absolutePath);
|
|
658
|
+
},
|
|
659
|
+
validatePathAccess(absolutePath) {
|
|
660
|
+
if (this.isPathAllowed(absolutePath)) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
const workspaceDirs = this.getWorkspaceContext().getDirectories();
|
|
664
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
665
|
+
return `Path not in workspace: Attempted path "${absolutePath}" resolves outside the allowed workspace directories: ${workspaceDirs.join(', ')} or the project temp directory: ${projectTempDir}`;
|
|
666
|
+
},
|
|
539
667
|
};
|
|
540
668
|
// Setup specific mock for this test - multi-directory search for 'world'
|
|
541
669
|
// Mock will be called twice - once for each directory
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
},
|
|
550
|
-
stderr: {
|
|
551
|
-
on: vi.fn(),
|
|
552
|
-
removeListener: vi.fn(),
|
|
670
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
671
|
+
outputData: JSON.stringify({
|
|
672
|
+
type: 'match',
|
|
673
|
+
data: {
|
|
674
|
+
path: { text: 'fileA.txt' },
|
|
675
|
+
line_number: 1,
|
|
676
|
+
lines: { text: 'hello world\n' },
|
|
553
677
|
},
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
type: 'match',
|
|
576
|
-
data: {
|
|
577
|
-
path: { text: 'fileA.txt' },
|
|
578
|
-
line_number: 2,
|
|
579
|
-
lines: { text: 'second line with world\n' },
|
|
580
|
-
},
|
|
581
|
-
}) +
|
|
582
|
-
'\n' +
|
|
583
|
-
JSON.stringify({
|
|
584
|
-
type: 'match',
|
|
585
|
-
data: {
|
|
586
|
-
path: { text: 'sub/fileC.txt' },
|
|
587
|
-
line_number: 1,
|
|
588
|
-
lines: { text: 'another world in sub dir\n' },
|
|
589
|
-
},
|
|
590
|
-
}) +
|
|
591
|
-
'\n';
|
|
592
|
-
}
|
|
593
|
-
else if (callCount === 2) {
|
|
594
|
-
// Second directory (secondDir)
|
|
595
|
-
outputData =
|
|
596
|
-
JSON.stringify({
|
|
597
|
-
type: 'match',
|
|
598
|
-
data: {
|
|
599
|
-
path: { text: 'other.txt' },
|
|
600
|
-
line_number: 2,
|
|
601
|
-
lines: { text: 'world in second\n' },
|
|
602
|
-
},
|
|
603
|
-
}) +
|
|
604
|
-
'\n' +
|
|
605
|
-
JSON.stringify({
|
|
606
|
-
type: 'match',
|
|
607
|
-
data: {
|
|
608
|
-
path: { text: 'another.js' },
|
|
609
|
-
line_number: 1,
|
|
610
|
-
lines: { text: 'function world() { return "test"; }\n' },
|
|
611
|
-
},
|
|
612
|
-
}) +
|
|
613
|
-
'\n';
|
|
614
|
-
}
|
|
615
|
-
if (stdoutDataHandler && outputData) {
|
|
616
|
-
stdoutDataHandler(Buffer.from(outputData));
|
|
617
|
-
}
|
|
618
|
-
if (closeHandler) {
|
|
619
|
-
closeHandler(0);
|
|
620
|
-
}
|
|
621
|
-
}, 0);
|
|
622
|
-
return mockProcess;
|
|
623
|
-
});
|
|
678
|
+
}) +
|
|
679
|
+
'\n' +
|
|
680
|
+
JSON.stringify({
|
|
681
|
+
type: 'match',
|
|
682
|
+
data: {
|
|
683
|
+
path: { text: 'fileA.txt' },
|
|
684
|
+
line_number: 2,
|
|
685
|
+
lines: { text: 'second line with world\n' },
|
|
686
|
+
},
|
|
687
|
+
}) +
|
|
688
|
+
'\n' +
|
|
689
|
+
JSON.stringify({
|
|
690
|
+
type: 'match',
|
|
691
|
+
data: {
|
|
692
|
+
path: { text: 'sub/fileC.txt' },
|
|
693
|
+
line_number: 1,
|
|
694
|
+
lines: { text: 'another world in sub dir\n' },
|
|
695
|
+
},
|
|
696
|
+
}) +
|
|
697
|
+
'\n',
|
|
698
|
+
}));
|
|
624
699
|
const multiDirGrepTool = new RipGrepTool(multiDirConfig, createMockMessageBus());
|
|
625
700
|
const params = { pattern: 'world' };
|
|
626
701
|
const invocation = multiDirGrepTool.build(params);
|
|
@@ -652,42 +727,43 @@ describe('RipGrepTool', () => {
|
|
|
652
727
|
getTargetDir: () => tempRootDir,
|
|
653
728
|
getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir, [secondDir]),
|
|
654
729
|
getDebugMode: () => false,
|
|
730
|
+
getFileFilteringRespectGitIgnore: () => true,
|
|
655
731
|
getFileFilteringRespectGeminiIgnore: () => true,
|
|
732
|
+
getFileFilteringOptions: () => ({
|
|
733
|
+
respectGitIgnore: true,
|
|
734
|
+
respectGeminiIgnore: true,
|
|
735
|
+
}),
|
|
736
|
+
storage: {
|
|
737
|
+
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project'),
|
|
738
|
+
},
|
|
739
|
+
isPathAllowed(absolutePath) {
|
|
740
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
741
|
+
if (workspaceContext.isPathWithinWorkspace(absolutePath)) {
|
|
742
|
+
return true;
|
|
743
|
+
}
|
|
744
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
745
|
+
return isSubpath(path.resolve(projectTempDir), absolutePath);
|
|
746
|
+
},
|
|
747
|
+
validatePathAccess(absolutePath) {
|
|
748
|
+
if (this.isPathAllowed(absolutePath)) {
|
|
749
|
+
return null;
|
|
750
|
+
}
|
|
751
|
+
const workspaceDirs = this.getWorkspaceContext().getDirectories();
|
|
752
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
753
|
+
return `Path not in workspace: Attempted path "${absolutePath}" resolves outside the allowed workspace directories: ${workspaceDirs.join(', ')} or the project temp directory: ${projectTempDir}`;
|
|
754
|
+
},
|
|
656
755
|
};
|
|
657
756
|
// Setup specific mock for this test - searching in 'sub' should only return matches from that directory
|
|
658
|
-
mockSpawn.mockImplementationOnce((
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
on: vi.fn(),
|
|
666
|
-
removeListener: vi.fn(),
|
|
757
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
758
|
+
outputData: JSON.stringify({
|
|
759
|
+
type: 'match',
|
|
760
|
+
data: {
|
|
761
|
+
path: { text: 'fileC.txt' },
|
|
762
|
+
line_number: 1,
|
|
763
|
+
lines: { text: 'another world in sub dir\n' },
|
|
667
764
|
},
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
kill: vi.fn(),
|
|
671
|
-
};
|
|
672
|
-
setTimeout(() => {
|
|
673
|
-
const onData = mockProcess.stdout.on.mock.calls.find((call) => call[0] === 'data')?.[1];
|
|
674
|
-
const onClose = mockProcess.on.mock.calls.find((call) => call[0] === 'close')?.[1];
|
|
675
|
-
if (onData) {
|
|
676
|
-
onData(Buffer.from(JSON.stringify({
|
|
677
|
-
type: 'match',
|
|
678
|
-
data: {
|
|
679
|
-
path: { text: 'fileC.txt' },
|
|
680
|
-
line_number: 1,
|
|
681
|
-
lines: { text: 'another world in sub dir\n' },
|
|
682
|
-
},
|
|
683
|
-
}) + '\n'));
|
|
684
|
-
}
|
|
685
|
-
if (onClose) {
|
|
686
|
-
onClose(0);
|
|
687
|
-
}
|
|
688
|
-
}, 0);
|
|
689
|
-
return mockProcess;
|
|
690
|
-
});
|
|
765
|
+
}) + '\n',
|
|
766
|
+
}));
|
|
691
767
|
const multiDirGrepTool = new RipGrepTool(multiDirConfig, createMockMessageBus());
|
|
692
768
|
// Search only in the 'sub' directory of the first workspace
|
|
693
769
|
const params = { pattern: 'world', dir_path: 'sub' };
|
|
@@ -714,38 +790,17 @@ describe('RipGrepTool', () => {
|
|
|
714
790
|
});
|
|
715
791
|
it('should abort streaming search when signal is triggered', async () => {
|
|
716
792
|
// Setup specific mock for this test - simulate process being killed due to abort
|
|
717
|
-
mockSpawn.mockImplementationOnce((
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
removeListener: vi.fn(),
|
|
722
|
-
},
|
|
723
|
-
stderr: {
|
|
724
|
-
on: vi.fn(),
|
|
725
|
-
removeListener: vi.fn(),
|
|
726
|
-
},
|
|
727
|
-
on: vi.fn(),
|
|
728
|
-
removeListener: vi.fn(),
|
|
729
|
-
kill: vi.fn(),
|
|
730
|
-
};
|
|
731
|
-
// Simulate process being aborted - use setTimeout to ensure handlers are registered first
|
|
732
|
-
setTimeout(() => {
|
|
733
|
-
const closeHandler = mockProcess.on.mock.calls.find((call) => call[0] === 'close')?.[1];
|
|
734
|
-
if (closeHandler) {
|
|
735
|
-
// Simulate process killed by signal (code is null, signal is SIGTERM)
|
|
736
|
-
closeHandler(null, 'SIGTERM');
|
|
737
|
-
}
|
|
738
|
-
}, 0);
|
|
739
|
-
return mockProcess;
|
|
740
|
-
});
|
|
793
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
794
|
+
exitCode: null,
|
|
795
|
+
signal: 'SIGTERM',
|
|
796
|
+
}));
|
|
741
797
|
const controller = new AbortController();
|
|
742
798
|
const params = { pattern: 'test' };
|
|
743
799
|
const invocation = grepTool.build(params);
|
|
744
800
|
// Abort immediately before starting the search
|
|
745
801
|
controller.abort();
|
|
746
802
|
const result = await invocation.execute(controller.signal);
|
|
747
|
-
expect(result.
|
|
748
|
-
expect(result.returnDisplay).toContain('Error: ripgrep exited with code null');
|
|
803
|
+
expect(result.returnDisplay).toContain('No matches found');
|
|
749
804
|
});
|
|
750
805
|
});
|
|
751
806
|
describe('error handling and edge cases', () => {
|
|
@@ -754,7 +809,7 @@ describe('RipGrepTool', () => {
|
|
|
754
809
|
pattern: 'test',
|
|
755
810
|
dir_path: '../outside',
|
|
756
811
|
};
|
|
757
|
-
expect(() => grepTool.build(params)).toThrow(/Path
|
|
812
|
+
expect(() => grepTool.build(params)).toThrow(/Path not in workspace/);
|
|
758
813
|
});
|
|
759
814
|
it.each([
|
|
760
815
|
{
|
|
@@ -783,39 +838,16 @@ describe('RipGrepTool', () => {
|
|
|
783
838
|
const specialFileName = 'file with spaces & symbols!.txt';
|
|
784
839
|
await fs.writeFile(path.join(tempRootDir, specialFileName), 'hello world with special chars');
|
|
785
840
|
// Setup specific mock for this test - searching for 'world' should find the file with special characters
|
|
786
|
-
mockSpawn.mockImplementationOnce((
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
on: vi.fn(),
|
|
794
|
-
removeListener: vi.fn(),
|
|
841
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
842
|
+
outputData: JSON.stringify({
|
|
843
|
+
type: 'match',
|
|
844
|
+
data: {
|
|
845
|
+
path: { text: specialFileName },
|
|
846
|
+
line_number: 1,
|
|
847
|
+
lines: { text: 'hello world with special chars\n' },
|
|
795
848
|
},
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
kill: vi.fn(),
|
|
799
|
-
};
|
|
800
|
-
setTimeout(() => {
|
|
801
|
-
const onData = mockProcess.stdout.on.mock.calls.find((call) => call[0] === 'data')?.[1];
|
|
802
|
-
const onClose = mockProcess.on.mock.calls.find((call) => call[0] === 'close')?.[1];
|
|
803
|
-
if (onData) {
|
|
804
|
-
onData(Buffer.from(JSON.stringify({
|
|
805
|
-
type: 'match',
|
|
806
|
-
data: {
|
|
807
|
-
path: { text: specialFileName },
|
|
808
|
-
line_number: 1,
|
|
809
|
-
lines: { text: 'hello world with special chars\n' },
|
|
810
|
-
},
|
|
811
|
-
}) + '\n'));
|
|
812
|
-
}
|
|
813
|
-
if (onClose) {
|
|
814
|
-
onClose(0);
|
|
815
|
-
}
|
|
816
|
-
}, 0);
|
|
817
|
-
return mockProcess;
|
|
818
|
-
});
|
|
849
|
+
}) + '\n',
|
|
850
|
+
}));
|
|
819
851
|
const params = { pattern: 'world' };
|
|
820
852
|
const invocation = grepTool.build(params);
|
|
821
853
|
const result = await invocation.execute(abortSignal);
|
|
@@ -827,39 +859,16 @@ describe('RipGrepTool', () => {
|
|
|
827
859
|
await fs.mkdir(deepPath, { recursive: true });
|
|
828
860
|
await fs.writeFile(path.join(deepPath, 'deep.txt'), 'content in deep directory');
|
|
829
861
|
// Setup specific mock for this test - searching for 'deep' should find the deeply nested file
|
|
830
|
-
mockSpawn.mockImplementationOnce((
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
on: vi.fn(),
|
|
838
|
-
removeListener: vi.fn(),
|
|
862
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
863
|
+
outputData: JSON.stringify({
|
|
864
|
+
type: 'match',
|
|
865
|
+
data: {
|
|
866
|
+
path: { text: 'a/b/c/d/e/deep.txt' },
|
|
867
|
+
line_number: 1,
|
|
868
|
+
lines: { text: 'content in deep directory\n' },
|
|
839
869
|
},
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
kill: vi.fn(),
|
|
843
|
-
};
|
|
844
|
-
setTimeout(() => {
|
|
845
|
-
const onData = mockProcess.stdout.on.mock.calls.find((call) => call[0] === 'data')?.[1];
|
|
846
|
-
const onClose = mockProcess.on.mock.calls.find((call) => call[0] === 'close')?.[1];
|
|
847
|
-
if (onData) {
|
|
848
|
-
onData(Buffer.from(JSON.stringify({
|
|
849
|
-
type: 'match',
|
|
850
|
-
data: {
|
|
851
|
-
path: { text: 'a/b/c/d/e/deep.txt' },
|
|
852
|
-
line_number: 1,
|
|
853
|
-
lines: { text: 'content in deep directory\n' },
|
|
854
|
-
},
|
|
855
|
-
}) + '\n'));
|
|
856
|
-
}
|
|
857
|
-
if (onClose) {
|
|
858
|
-
onClose(0);
|
|
859
|
-
}
|
|
860
|
-
}, 0);
|
|
861
|
-
return mockProcess;
|
|
862
|
-
});
|
|
870
|
+
}) + '\n',
|
|
871
|
+
}));
|
|
863
872
|
const params = { pattern: 'deep' };
|
|
864
873
|
const invocation = grepTool.build(params);
|
|
865
874
|
const result = await invocation.execute(abortSignal);
|
|
@@ -871,39 +880,16 @@ describe('RipGrepTool', () => {
|
|
|
871
880
|
it('should handle complex regex patterns', async () => {
|
|
872
881
|
await fs.writeFile(path.join(tempRootDir, 'code.js'), 'function getName() { return "test"; }\nconst getValue = () => "value";');
|
|
873
882
|
// Setup specific mock for this test - regex pattern should match function declarations
|
|
874
|
-
mockSpawn.mockImplementationOnce((
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
on: vi.fn(),
|
|
882
|
-
removeListener: vi.fn(),
|
|
883
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
884
|
+
outputData: JSON.stringify({
|
|
885
|
+
type: 'match',
|
|
886
|
+
data: {
|
|
887
|
+
path: { text: 'code.js' },
|
|
888
|
+
line_number: 1,
|
|
889
|
+
lines: { text: 'function getName() { return "test"; }\n' },
|
|
883
890
|
},
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
kill: vi.fn(),
|
|
887
|
-
};
|
|
888
|
-
setTimeout(() => {
|
|
889
|
-
const onData = mockProcess.stdout.on.mock.calls.find((call) => call[0] === 'data')?.[1];
|
|
890
|
-
const onClose = mockProcess.on.mock.calls.find((call) => call[0] === 'close')?.[1];
|
|
891
|
-
if (onData) {
|
|
892
|
-
onData(Buffer.from(JSON.stringify({
|
|
893
|
-
type: 'match',
|
|
894
|
-
data: {
|
|
895
|
-
path: { text: 'code.js' },
|
|
896
|
-
line_number: 1,
|
|
897
|
-
lines: { text: 'function getName() { return "test"; }\n' },
|
|
898
|
-
},
|
|
899
|
-
}) + '\n'));
|
|
900
|
-
}
|
|
901
|
-
if (onClose) {
|
|
902
|
-
onClose(0);
|
|
903
|
-
}
|
|
904
|
-
}, 0);
|
|
905
|
-
return mockProcess;
|
|
906
|
-
});
|
|
891
|
+
}) + '\n',
|
|
892
|
+
}));
|
|
907
893
|
const params = { pattern: 'function\\s+\\w+\\s*\\(' };
|
|
908
894
|
const invocation = grepTool.build(params);
|
|
909
895
|
const result = await invocation.execute(abortSignal);
|
|
@@ -913,58 +899,35 @@ describe('RipGrepTool', () => {
|
|
|
913
899
|
it('should handle case sensitivity correctly in JS fallback', async () => {
|
|
914
900
|
await fs.writeFile(path.join(tempRootDir, 'case.txt'), 'Hello World\nhello world\nHELLO WORLD');
|
|
915
901
|
// Setup specific mock for this test - case insensitive search should match all variants
|
|
916
|
-
mockSpawn.mockImplementationOnce((
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
on: vi.fn(),
|
|
924
|
-
removeListener: vi.fn(),
|
|
902
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
903
|
+
outputData: JSON.stringify({
|
|
904
|
+
type: 'match',
|
|
905
|
+
data: {
|
|
906
|
+
path: { text: 'case.txt' },
|
|
907
|
+
line_number: 1,
|
|
908
|
+
lines: { text: 'Hello World\n' },
|
|
925
909
|
},
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
},
|
|
941
|
-
|
|
942
|
-
'\n'
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
line_number: 2,
|
|
948
|
-
lines: { text: 'hello world\n' },
|
|
949
|
-
},
|
|
950
|
-
}) +
|
|
951
|
-
'\n' +
|
|
952
|
-
JSON.stringify({
|
|
953
|
-
type: 'match',
|
|
954
|
-
data: {
|
|
955
|
-
path: { text: 'case.txt' },
|
|
956
|
-
line_number: 3,
|
|
957
|
-
lines: { text: 'HELLO WORLD\n' },
|
|
958
|
-
},
|
|
959
|
-
}) +
|
|
960
|
-
'\n'));
|
|
961
|
-
}
|
|
962
|
-
if (onClose) {
|
|
963
|
-
onClose(0);
|
|
964
|
-
}
|
|
965
|
-
}, 0);
|
|
966
|
-
return mockProcess;
|
|
967
|
-
});
|
|
910
|
+
}) +
|
|
911
|
+
'\n' +
|
|
912
|
+
JSON.stringify({
|
|
913
|
+
type: 'match',
|
|
914
|
+
data: {
|
|
915
|
+
path: { text: 'case.txt' },
|
|
916
|
+
line_number: 2,
|
|
917
|
+
lines: { text: 'hello world\n' },
|
|
918
|
+
},
|
|
919
|
+
}) +
|
|
920
|
+
'\n' +
|
|
921
|
+
JSON.stringify({
|
|
922
|
+
type: 'match',
|
|
923
|
+
data: {
|
|
924
|
+
path: { text: 'case.txt' },
|
|
925
|
+
line_number: 3,
|
|
926
|
+
lines: { text: 'HELLO WORLD\n' },
|
|
927
|
+
},
|
|
928
|
+
}) +
|
|
929
|
+
'\n',
|
|
930
|
+
}));
|
|
968
931
|
const params = { pattern: 'hello' };
|
|
969
932
|
const invocation = grepTool.build(params);
|
|
970
933
|
const result = await invocation.execute(abortSignal);
|
|
@@ -975,39 +938,16 @@ describe('RipGrepTool', () => {
|
|
|
975
938
|
it('should handle escaped regex special characters', async () => {
|
|
976
939
|
await fs.writeFile(path.join(tempRootDir, 'special.txt'), 'Price: $19.99\nRegex: [a-z]+ pattern\nEmail: test@example.com');
|
|
977
940
|
// Setup specific mock for this test - escaped regex pattern should match price format
|
|
978
|
-
mockSpawn.mockImplementationOnce((
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
on: vi.fn(),
|
|
986
|
-
removeListener: vi.fn(),
|
|
941
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
942
|
+
outputData: JSON.stringify({
|
|
943
|
+
type: 'match',
|
|
944
|
+
data: {
|
|
945
|
+
path: { text: 'special.txt' },
|
|
946
|
+
line_number: 1,
|
|
947
|
+
lines: { text: 'Price: $19.99\n' },
|
|
987
948
|
},
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
kill: vi.fn(),
|
|
991
|
-
};
|
|
992
|
-
setTimeout(() => {
|
|
993
|
-
const onData = mockProcess.stdout.on.mock.calls.find((call) => call[0] === 'data')?.[1];
|
|
994
|
-
const onClose = mockProcess.on.mock.calls.find((call) => call[0] === 'close')?.[1];
|
|
995
|
-
if (onData) {
|
|
996
|
-
onData(Buffer.from(JSON.stringify({
|
|
997
|
-
type: 'match',
|
|
998
|
-
data: {
|
|
999
|
-
path: { text: 'special.txt' },
|
|
1000
|
-
line_number: 1,
|
|
1001
|
-
lines: { text: 'Price: $19.99\n' },
|
|
1002
|
-
},
|
|
1003
|
-
}) + '\n'));
|
|
1004
|
-
}
|
|
1005
|
-
if (onClose) {
|
|
1006
|
-
onClose(0);
|
|
1007
|
-
}
|
|
1008
|
-
}, 0);
|
|
1009
|
-
return mockProcess;
|
|
1010
|
-
});
|
|
949
|
+
}) + '\n',
|
|
950
|
+
}));
|
|
1011
951
|
const params = { pattern: '\\$\\d+\\.\\d+' };
|
|
1012
952
|
const invocation = grepTool.build(params);
|
|
1013
953
|
const result = await invocation.execute(abortSignal);
|
|
@@ -1022,49 +962,26 @@ describe('RipGrepTool', () => {
|
|
|
1022
962
|
await fs.writeFile(path.join(tempRootDir, 'test.js'), 'javascript content');
|
|
1023
963
|
await fs.writeFile(path.join(tempRootDir, 'test.txt'), 'text content');
|
|
1024
964
|
// Setup specific mock for this test - include pattern should filter to only ts/tsx files
|
|
1025
|
-
mockSpawn.mockImplementationOnce((
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
on: vi.fn(),
|
|
1033
|
-
removeListener: vi.fn(),
|
|
965
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
966
|
+
outputData: JSON.stringify({
|
|
967
|
+
type: 'match',
|
|
968
|
+
data: {
|
|
969
|
+
path: { text: 'test.ts' },
|
|
970
|
+
line_number: 1,
|
|
971
|
+
lines: { text: 'typescript content\n' },
|
|
1034
972
|
},
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
line_number: 1,
|
|
1048
|
-
lines: { text: 'typescript content\n' },
|
|
1049
|
-
},
|
|
1050
|
-
}) +
|
|
1051
|
-
'\n' +
|
|
1052
|
-
JSON.stringify({
|
|
1053
|
-
type: 'match',
|
|
1054
|
-
data: {
|
|
1055
|
-
path: { text: 'test.tsx' },
|
|
1056
|
-
line_number: 1,
|
|
1057
|
-
lines: { text: 'tsx content\n' },
|
|
1058
|
-
},
|
|
1059
|
-
}) +
|
|
1060
|
-
'\n'));
|
|
1061
|
-
}
|
|
1062
|
-
if (onClose) {
|
|
1063
|
-
onClose(0);
|
|
1064
|
-
}
|
|
1065
|
-
}, 0);
|
|
1066
|
-
return mockProcess;
|
|
1067
|
-
});
|
|
973
|
+
}) +
|
|
974
|
+
'\n' +
|
|
975
|
+
JSON.stringify({
|
|
976
|
+
type: 'match',
|
|
977
|
+
data: {
|
|
978
|
+
path: { text: 'test.tsx' },
|
|
979
|
+
line_number: 1,
|
|
980
|
+
lines: { text: 'tsx content\n' },
|
|
981
|
+
},
|
|
982
|
+
}) +
|
|
983
|
+
'\n',
|
|
984
|
+
}));
|
|
1068
985
|
const params = {
|
|
1069
986
|
pattern: 'content',
|
|
1070
987
|
include: '*.{ts,tsx}',
|
|
@@ -1081,39 +998,16 @@ describe('RipGrepTool', () => {
|
|
|
1081
998
|
await fs.writeFile(path.join(tempRootDir, 'src', 'main.ts'), 'source code');
|
|
1082
999
|
await fs.writeFile(path.join(tempRootDir, 'other.ts'), 'other code');
|
|
1083
1000
|
// Setup specific mock for this test - include pattern should filter to only src/** files
|
|
1084
|
-
mockSpawn.mockImplementationOnce((
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
on: vi.fn(),
|
|
1092
|
-
removeListener: vi.fn(),
|
|
1001
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
1002
|
+
outputData: JSON.stringify({
|
|
1003
|
+
type: 'match',
|
|
1004
|
+
data: {
|
|
1005
|
+
path: { text: 'src/main.ts' },
|
|
1006
|
+
line_number: 1,
|
|
1007
|
+
lines: { text: 'source code\n' },
|
|
1093
1008
|
},
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
kill: vi.fn(),
|
|
1097
|
-
};
|
|
1098
|
-
setTimeout(() => {
|
|
1099
|
-
const onData = mockProcess.stdout.on.mock.calls.find((call) => call[0] === 'data')?.[1];
|
|
1100
|
-
const onClose = mockProcess.on.mock.calls.find((call) => call[0] === 'close')?.[1];
|
|
1101
|
-
if (onData) {
|
|
1102
|
-
onData(Buffer.from(JSON.stringify({
|
|
1103
|
-
type: 'match',
|
|
1104
|
-
data: {
|
|
1105
|
-
path: { text: 'src/main.ts' },
|
|
1106
|
-
line_number: 1,
|
|
1107
|
-
lines: { text: 'source code\n' },
|
|
1108
|
-
},
|
|
1109
|
-
}) + '\n'));
|
|
1110
|
-
}
|
|
1111
|
-
if (onClose) {
|
|
1112
|
-
onClose(0);
|
|
1113
|
-
}
|
|
1114
|
-
}, 0);
|
|
1115
|
-
return mockProcess;
|
|
1116
|
-
});
|
|
1009
|
+
}) + '\n',
|
|
1010
|
+
}));
|
|
1117
1011
|
const params = {
|
|
1118
1012
|
pattern: 'code',
|
|
1119
1013
|
include: 'src/**',
|
|
@@ -1163,27 +1057,32 @@ describe('RipGrepTool', () => {
|
|
|
1163
1057
|
expect(result.llmContent).toContain('Found 1 match for pattern "HELLO"');
|
|
1164
1058
|
expect(result.llmContent).toContain('L1: HELLO world');
|
|
1165
1059
|
});
|
|
1166
|
-
it
|
|
1167
|
-
{
|
|
1168
|
-
name: 'fixed_strings parameter',
|
|
1169
|
-
params: { pattern: 'hello.world', fixed_strings: true },
|
|
1170
|
-
mockOutput: {
|
|
1171
|
-
path: { text: 'fileA.txt' },
|
|
1172
|
-
line_number: 1,
|
|
1173
|
-
lines: { text: 'hello.world\n' },
|
|
1174
|
-
},
|
|
1175
|
-
expectedArgs: ['--fixed-strings'],
|
|
1176
|
-
expectedPattern: 'hello.world',
|
|
1177
|
-
},
|
|
1178
|
-
])('should handle $name', async ({ params, mockOutput, expectedArgs, expectedPattern }) => {
|
|
1060
|
+
it('should handle fixed_strings parameter', async () => {
|
|
1179
1061
|
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
1180
|
-
outputData: JSON.stringify({
|
|
1062
|
+
outputData: JSON.stringify({
|
|
1063
|
+
type: 'match',
|
|
1064
|
+
data: {
|
|
1065
|
+
path: { text: 'fileA.txt' },
|
|
1066
|
+
line_number: 1,
|
|
1067
|
+
lines: { text: 'hello.world\n' },
|
|
1068
|
+
},
|
|
1069
|
+
}) + '\n',
|
|
1181
1070
|
exitCode: 0,
|
|
1182
1071
|
}));
|
|
1183
|
-
const invocation = grepTool.build(
|
|
1072
|
+
const invocation = grepTool.build({
|
|
1073
|
+
pattern: 'hello.world',
|
|
1074
|
+
fixed_strings: true,
|
|
1075
|
+
});
|
|
1184
1076
|
const result = await invocation.execute(abortSignal);
|
|
1185
|
-
expect(mockSpawn).toHaveBeenLastCalledWith(expect.anything(), expect.arrayContaining(
|
|
1186
|
-
expect(result.llmContent).toContain(
|
|
1077
|
+
expect(mockSpawn).toHaveBeenLastCalledWith(expect.anything(), expect.arrayContaining(['--fixed-strings']), expect.anything());
|
|
1078
|
+
expect(result.llmContent).toContain('Found 1 match for pattern "hello.world"');
|
|
1079
|
+
});
|
|
1080
|
+
it('should allow invalid regex patterns when fixed_strings is true', () => {
|
|
1081
|
+
const params = {
|
|
1082
|
+
pattern: '[[',
|
|
1083
|
+
fixed_strings: true,
|
|
1084
|
+
};
|
|
1085
|
+
expect(grepTool.validateToolParams(params)).toBeNull();
|
|
1187
1086
|
});
|
|
1188
1087
|
it('should handle no_ignore parameter', async () => {
|
|
1189
1088
|
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
@@ -1206,14 +1105,86 @@ describe('RipGrepTool', () => {
|
|
|
1206
1105
|
expect(result.llmContent).toContain('File: ignored.log');
|
|
1207
1106
|
expect(result.llmContent).toContain('L1: secret log entry');
|
|
1208
1107
|
});
|
|
1108
|
+
it('should disable gitignore rules when respectGitIgnore is false', async () => {
|
|
1109
|
+
const configWithoutGitIgnore = {
|
|
1110
|
+
getTargetDir: () => tempRootDir,
|
|
1111
|
+
getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir),
|
|
1112
|
+
getDebugMode: () => false,
|
|
1113
|
+
getFileFilteringRespectGitIgnore: () => false,
|
|
1114
|
+
getFileFilteringRespectGeminiIgnore: () => true,
|
|
1115
|
+
getFileFilteringOptions: () => ({
|
|
1116
|
+
respectGitIgnore: false,
|
|
1117
|
+
respectGeminiIgnore: true,
|
|
1118
|
+
}),
|
|
1119
|
+
storage: {
|
|
1120
|
+
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project'),
|
|
1121
|
+
},
|
|
1122
|
+
isPathAllowed(absolutePath) {
|
|
1123
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
1124
|
+
if (workspaceContext.isPathWithinWorkspace(absolutePath)) {
|
|
1125
|
+
return true;
|
|
1126
|
+
}
|
|
1127
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
1128
|
+
return isSubpath(path.resolve(projectTempDir), absolutePath);
|
|
1129
|
+
},
|
|
1130
|
+
validatePathAccess(absolutePath) {
|
|
1131
|
+
if (this.isPathAllowed(absolutePath)) {
|
|
1132
|
+
return null;
|
|
1133
|
+
}
|
|
1134
|
+
const workspaceDirs = this.getWorkspaceContext().getDirectories();
|
|
1135
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
1136
|
+
return `Path not in workspace: Attempted path "${absolutePath}" resolves outside the allowed workspace directories: ${workspaceDirs.join(', ')} or the project temp directory: ${projectTempDir}`;
|
|
1137
|
+
},
|
|
1138
|
+
};
|
|
1139
|
+
const gitIgnoreDisabledTool = new RipGrepTool(configWithoutGitIgnore, createMockMessageBus());
|
|
1140
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
1141
|
+
outputData: JSON.stringify({
|
|
1142
|
+
type: 'match',
|
|
1143
|
+
data: {
|
|
1144
|
+
path: { text: 'ignored.log' },
|
|
1145
|
+
line_number: 1,
|
|
1146
|
+
lines: { text: 'secret log entry\n' },
|
|
1147
|
+
},
|
|
1148
|
+
}) + '\n',
|
|
1149
|
+
exitCode: 0,
|
|
1150
|
+
}));
|
|
1151
|
+
const params = { pattern: 'secret' };
|
|
1152
|
+
const invocation = gitIgnoreDisabledTool.build(params);
|
|
1153
|
+
await invocation.execute(abortSignal);
|
|
1154
|
+
expect(mockSpawn).toHaveBeenLastCalledWith(expect.anything(), expect.arrayContaining(['--no-ignore-vcs', '--no-ignore-exclude']), expect.anything());
|
|
1155
|
+
});
|
|
1209
1156
|
it('should add .geminiignore when enabled and patterns exist', async () => {
|
|
1210
|
-
const geminiIgnorePath = path.join(tempRootDir,
|
|
1157
|
+
const geminiIgnorePath = path.join(tempRootDir, GEMINI_IGNORE_FILE_NAME);
|
|
1211
1158
|
await fs.writeFile(geminiIgnorePath, 'ignored.log');
|
|
1212
1159
|
const configWithGeminiIgnore = {
|
|
1213
1160
|
getTargetDir: () => tempRootDir,
|
|
1214
1161
|
getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir),
|
|
1215
1162
|
getDebugMode: () => false,
|
|
1163
|
+
getFileFilteringRespectGitIgnore: () => true,
|
|
1216
1164
|
getFileFilteringRespectGeminiIgnore: () => true,
|
|
1165
|
+
getFileFilteringOptions: () => ({
|
|
1166
|
+
respectGitIgnore: true,
|
|
1167
|
+
respectGeminiIgnore: true,
|
|
1168
|
+
}),
|
|
1169
|
+
storage: {
|
|
1170
|
+
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project'),
|
|
1171
|
+
},
|
|
1172
|
+
isPathAllowed(absolutePath) {
|
|
1173
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
1174
|
+
if (workspaceContext.isPathWithinWorkspace(absolutePath)) {
|
|
1175
|
+
return true;
|
|
1176
|
+
}
|
|
1177
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
1178
|
+
return isSubpath(path.resolve(projectTempDir), absolutePath);
|
|
1179
|
+
},
|
|
1180
|
+
validatePathAccess(absolutePath) {
|
|
1181
|
+
if (this.isPathAllowed(absolutePath)) {
|
|
1182
|
+
return null;
|
|
1183
|
+
}
|
|
1184
|
+
const workspaceDirs = this.getWorkspaceContext().getDirectories();
|
|
1185
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
1186
|
+
return `Path not in workspace: Attempted path "${absolutePath}" resolves outside the allowed workspace directories: ${workspaceDirs.join(', ')} or the project temp directory: ${projectTempDir}`;
|
|
1187
|
+
},
|
|
1217
1188
|
};
|
|
1218
1189
|
const geminiIgnoreTool = new RipGrepTool(configWithGeminiIgnore, createMockMessageBus());
|
|
1219
1190
|
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
@@ -1233,13 +1204,37 @@ describe('RipGrepTool', () => {
|
|
|
1233
1204
|
expect(mockSpawn).toHaveBeenLastCalledWith(expect.anything(), expect.arrayContaining(['--ignore-file', geminiIgnorePath]), expect.anything());
|
|
1234
1205
|
});
|
|
1235
1206
|
it('should skip .geminiignore when disabled', async () => {
|
|
1236
|
-
const geminiIgnorePath = path.join(tempRootDir,
|
|
1207
|
+
const geminiIgnorePath = path.join(tempRootDir, GEMINI_IGNORE_FILE_NAME);
|
|
1237
1208
|
await fs.writeFile(geminiIgnorePath, 'ignored.log');
|
|
1238
1209
|
const configWithoutGeminiIgnore = {
|
|
1239
1210
|
getTargetDir: () => tempRootDir,
|
|
1240
1211
|
getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir),
|
|
1241
1212
|
getDebugMode: () => false,
|
|
1213
|
+
getFileFilteringRespectGitIgnore: () => true,
|
|
1242
1214
|
getFileFilteringRespectGeminiIgnore: () => false,
|
|
1215
|
+
getFileFilteringOptions: () => ({
|
|
1216
|
+
respectGitIgnore: true,
|
|
1217
|
+
respectGeminiIgnore: false,
|
|
1218
|
+
}),
|
|
1219
|
+
storage: {
|
|
1220
|
+
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project'),
|
|
1221
|
+
},
|
|
1222
|
+
isPathAllowed(absolutePath) {
|
|
1223
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
1224
|
+
if (workspaceContext.isPathWithinWorkspace(absolutePath)) {
|
|
1225
|
+
return true;
|
|
1226
|
+
}
|
|
1227
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
1228
|
+
return isSubpath(path.resolve(projectTempDir), absolutePath);
|
|
1229
|
+
},
|
|
1230
|
+
validatePathAccess(absolutePath) {
|
|
1231
|
+
if (this.isPathAllowed(absolutePath)) {
|
|
1232
|
+
return null;
|
|
1233
|
+
}
|
|
1234
|
+
const workspaceDirs = this.getWorkspaceContext().getDirectories();
|
|
1235
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
1236
|
+
return `Path not in workspace: Attempted path "${absolutePath}" resolves outside the allowed workspace directories: ${workspaceDirs.join(', ')} or the project temp directory: ${projectTempDir}`;
|
|
1237
|
+
},
|
|
1243
1238
|
};
|
|
1244
1239
|
const geminiIgnoreTool = new RipGrepTool(configWithoutGeminiIgnore, createMockMessageBus());
|
|
1245
1240
|
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
@@ -1261,18 +1256,41 @@ describe('RipGrepTool', () => {
|
|
|
1261
1256
|
it('should handle context parameters', async () => {
|
|
1262
1257
|
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
1263
1258
|
outputData: JSON.stringify({
|
|
1264
|
-
type: '
|
|
1259
|
+
type: 'context',
|
|
1265
1260
|
data: {
|
|
1266
1261
|
path: { text: 'fileA.txt' },
|
|
1267
|
-
line_number:
|
|
1268
|
-
lines: { text: '
|
|
1269
|
-
lines_before: [{ text: 'hello world\n' }],
|
|
1270
|
-
lines_after: [
|
|
1271
|
-
{ text: 'third line\n' },
|
|
1272
|
-
{ text: 'fourth line\n' },
|
|
1273
|
-
],
|
|
1262
|
+
line_number: 1,
|
|
1263
|
+
lines: { text: 'hello world\n' },
|
|
1274
1264
|
},
|
|
1275
|
-
}) +
|
|
1265
|
+
}) +
|
|
1266
|
+
'\n' +
|
|
1267
|
+
JSON.stringify({
|
|
1268
|
+
type: 'match',
|
|
1269
|
+
data: {
|
|
1270
|
+
path: { text: 'fileA.txt' },
|
|
1271
|
+
line_number: 2,
|
|
1272
|
+
lines: { text: 'second line with world\n' },
|
|
1273
|
+
},
|
|
1274
|
+
}) +
|
|
1275
|
+
'\n' +
|
|
1276
|
+
JSON.stringify({
|
|
1277
|
+
type: 'context',
|
|
1278
|
+
data: {
|
|
1279
|
+
path: { text: 'fileA.txt' },
|
|
1280
|
+
line_number: 3,
|
|
1281
|
+
lines: { text: 'third line\n' },
|
|
1282
|
+
},
|
|
1283
|
+
}) +
|
|
1284
|
+
'\n' +
|
|
1285
|
+
JSON.stringify({
|
|
1286
|
+
type: 'context',
|
|
1287
|
+
data: {
|
|
1288
|
+
path: { text: 'fileA.txt' },
|
|
1289
|
+
line_number: 4,
|
|
1290
|
+
lines: { text: 'fourth line\n' },
|
|
1291
|
+
},
|
|
1292
|
+
}) +
|
|
1293
|
+
'\n',
|
|
1276
1294
|
exitCode: 0,
|
|
1277
1295
|
}));
|
|
1278
1296
|
const params = {
|
|
@@ -1293,9 +1311,10 @@ describe('RipGrepTool', () => {
|
|
|
1293
1311
|
]), expect.anything());
|
|
1294
1312
|
expect(result.llmContent).toContain('Found 1 match for pattern "world"');
|
|
1295
1313
|
expect(result.llmContent).toContain('File: fileA.txt');
|
|
1314
|
+
expect(result.llmContent).toContain('L1- hello world');
|
|
1296
1315
|
expect(result.llmContent).toContain('L2: second line with world');
|
|
1297
|
-
|
|
1298
|
-
|
|
1316
|
+
expect(result.llmContent).toContain('L3- third line');
|
|
1317
|
+
expect(result.llmContent).toContain('L4- fourth line');
|
|
1299
1318
|
});
|
|
1300
1319
|
});
|
|
1301
1320
|
describe('getDescription', () => {
|
|
@@ -1335,6 +1354,29 @@ describe('RipGrepTool', () => {
|
|
|
1335
1354
|
getTargetDir: () => tempRootDir,
|
|
1336
1355
|
getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir, ['/another/dir']),
|
|
1337
1356
|
getDebugMode: () => false,
|
|
1357
|
+
getFileFilteringOptions: () => ({
|
|
1358
|
+
respectGitIgnore: true,
|
|
1359
|
+
respectGeminiIgnore: true,
|
|
1360
|
+
}),
|
|
1361
|
+
storage: {
|
|
1362
|
+
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project'),
|
|
1363
|
+
},
|
|
1364
|
+
isPathAllowed(absolutePath) {
|
|
1365
|
+
const workspaceContext = this.getWorkspaceContext();
|
|
1366
|
+
if (workspaceContext.isPathWithinWorkspace(absolutePath)) {
|
|
1367
|
+
return true;
|
|
1368
|
+
}
|
|
1369
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
1370
|
+
return isSubpath(path.resolve(projectTempDir), absolutePath);
|
|
1371
|
+
},
|
|
1372
|
+
validatePathAccess(absolutePath) {
|
|
1373
|
+
if (this.isPathAllowed(absolutePath)) {
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
const workspaceDirs = this.getWorkspaceContext().getDirectories();
|
|
1377
|
+
const projectTempDir = this.storage.getProjectTempDir();
|
|
1378
|
+
return `Path not in workspace: Attempted path "${absolutePath}" resolves outside the allowed workspace directories: ${workspaceDirs.join(', ')} or the project temp directory: ${projectTempDir}`;
|
|
1379
|
+
},
|
|
1338
1380
|
};
|
|
1339
1381
|
const multiDirGrepTool = new RipGrepTool(multiDirConfig, createMockMessageBus());
|
|
1340
1382
|
const params = { pattern: 'testPattern' };
|
|
@@ -1354,6 +1396,142 @@ describe('RipGrepTool', () => {
|
|
|
1354
1396
|
expect(invocation.getDescription()).toContain(path.join('src', 'app'));
|
|
1355
1397
|
});
|
|
1356
1398
|
});
|
|
1399
|
+
describe('new parameters', () => {
|
|
1400
|
+
it('should pass --max-count when max_matches_per_file is provided', async () => {
|
|
1401
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
1402
|
+
outputData: JSON.stringify({
|
|
1403
|
+
type: 'match',
|
|
1404
|
+
data: {
|
|
1405
|
+
path: { text: 'fileA.txt' },
|
|
1406
|
+
line_number: 1,
|
|
1407
|
+
lines: { text: 'hello world\n' },
|
|
1408
|
+
},
|
|
1409
|
+
}) + '\n',
|
|
1410
|
+
exitCode: 0,
|
|
1411
|
+
}));
|
|
1412
|
+
const params = {
|
|
1413
|
+
pattern: 'world',
|
|
1414
|
+
max_matches_per_file: 1,
|
|
1415
|
+
};
|
|
1416
|
+
const invocation = grepTool.build(params);
|
|
1417
|
+
await invocation.execute(abortSignal);
|
|
1418
|
+
const spawnArgs = mockSpawn.mock.calls[0][1];
|
|
1419
|
+
expect(spawnArgs).toContain('--max-count');
|
|
1420
|
+
expect(spawnArgs).toContain('1');
|
|
1421
|
+
});
|
|
1422
|
+
it('should respect total_max_matches and truncate results', async () => {
|
|
1423
|
+
// Return 3 matches, but set total_max_matches to 2
|
|
1424
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
1425
|
+
outputData: JSON.stringify({
|
|
1426
|
+
type: 'match',
|
|
1427
|
+
data: {
|
|
1428
|
+
path: { text: 'fileA.txt' },
|
|
1429
|
+
line_number: 1,
|
|
1430
|
+
lines: { text: 'match 1\n' },
|
|
1431
|
+
},
|
|
1432
|
+
}) +
|
|
1433
|
+
'\n' +
|
|
1434
|
+
JSON.stringify({
|
|
1435
|
+
type: 'match',
|
|
1436
|
+
data: {
|
|
1437
|
+
path: { text: 'fileA.txt' },
|
|
1438
|
+
line_number: 2,
|
|
1439
|
+
lines: { text: 'match 2\n' },
|
|
1440
|
+
},
|
|
1441
|
+
}) +
|
|
1442
|
+
'\n' +
|
|
1443
|
+
JSON.stringify({
|
|
1444
|
+
type: 'match',
|
|
1445
|
+
data: {
|
|
1446
|
+
path: { text: 'fileA.txt' },
|
|
1447
|
+
line_number: 3,
|
|
1448
|
+
lines: { text: 'match 3\n' },
|
|
1449
|
+
},
|
|
1450
|
+
}) +
|
|
1451
|
+
'\n',
|
|
1452
|
+
exitCode: 0,
|
|
1453
|
+
}));
|
|
1454
|
+
const params = {
|
|
1455
|
+
pattern: 'match',
|
|
1456
|
+
total_max_matches: 2,
|
|
1457
|
+
};
|
|
1458
|
+
const invocation = grepTool.build(params);
|
|
1459
|
+
const result = await invocation.execute(abortSignal);
|
|
1460
|
+
expect(result.llmContent).toContain('Found 2 matches');
|
|
1461
|
+
expect(result.llmContent).toContain('results limited to 2 matches for performance');
|
|
1462
|
+
expect(result.llmContent).toContain('L1: match 1');
|
|
1463
|
+
expect(result.llmContent).toContain('L2: match 2');
|
|
1464
|
+
expect(result.llmContent).not.toContain('L3: match 3');
|
|
1465
|
+
expect(result.returnDisplay).toBe('Found 2 matches (limited)');
|
|
1466
|
+
});
|
|
1467
|
+
it('should return only file paths when names_only is true', async () => {
|
|
1468
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
1469
|
+
outputData: JSON.stringify({
|
|
1470
|
+
type: 'match',
|
|
1471
|
+
data: {
|
|
1472
|
+
path: { text: 'fileA.txt' },
|
|
1473
|
+
line_number: 1,
|
|
1474
|
+
lines: { text: 'hello world\n' },
|
|
1475
|
+
},
|
|
1476
|
+
}) +
|
|
1477
|
+
'\n' +
|
|
1478
|
+
JSON.stringify({
|
|
1479
|
+
type: 'match',
|
|
1480
|
+
data: {
|
|
1481
|
+
path: { text: 'fileB.txt' },
|
|
1482
|
+
line_number: 5,
|
|
1483
|
+
lines: { text: 'hello again\n' },
|
|
1484
|
+
},
|
|
1485
|
+
}) +
|
|
1486
|
+
'\n',
|
|
1487
|
+
exitCode: 0,
|
|
1488
|
+
}));
|
|
1489
|
+
const params = {
|
|
1490
|
+
pattern: 'hello',
|
|
1491
|
+
names_only: true,
|
|
1492
|
+
};
|
|
1493
|
+
const invocation = grepTool.build(params);
|
|
1494
|
+
const result = await invocation.execute(abortSignal);
|
|
1495
|
+
expect(result.llmContent).toContain('Found 2 files with matches');
|
|
1496
|
+
expect(result.llmContent).toContain('fileA.txt');
|
|
1497
|
+
expect(result.llmContent).toContain('fileB.txt');
|
|
1498
|
+
expect(result.llmContent).not.toContain('L1:');
|
|
1499
|
+
expect(result.llmContent).not.toContain('hello world');
|
|
1500
|
+
});
|
|
1501
|
+
it('should filter out matches based on exclude_pattern', async () => {
|
|
1502
|
+
mockSpawn.mockImplementationOnce(createMockSpawn({
|
|
1503
|
+
outputData: JSON.stringify({
|
|
1504
|
+
type: 'match',
|
|
1505
|
+
data: {
|
|
1506
|
+
path: { text: 'fileA.txt' },
|
|
1507
|
+
line_number: 1,
|
|
1508
|
+
lines: { text: 'Copyright 2025 Google LLC\n' },
|
|
1509
|
+
},
|
|
1510
|
+
}) +
|
|
1511
|
+
'\n' +
|
|
1512
|
+
JSON.stringify({
|
|
1513
|
+
type: 'match',
|
|
1514
|
+
data: {
|
|
1515
|
+
path: { text: 'fileB.txt' },
|
|
1516
|
+
line_number: 1,
|
|
1517
|
+
lines: { text: 'Copyright 2026 Google LLC\n' },
|
|
1518
|
+
},
|
|
1519
|
+
}) +
|
|
1520
|
+
'\n',
|
|
1521
|
+
exitCode: 0,
|
|
1522
|
+
}));
|
|
1523
|
+
const params = {
|
|
1524
|
+
pattern: 'Copyright .* Google LLC',
|
|
1525
|
+
exclude_pattern: '2026',
|
|
1526
|
+
};
|
|
1527
|
+
const invocation = grepTool.build(params);
|
|
1528
|
+
const result = await invocation.execute(abortSignal);
|
|
1529
|
+
expect(result.llmContent).toContain('Found 1 match');
|
|
1530
|
+
expect(result.llmContent).toContain('fileA.txt');
|
|
1531
|
+
expect(result.llmContent).not.toContain('fileB.txt');
|
|
1532
|
+
expect(result.llmContent).toContain('Copyright 2025 Google LLC');
|
|
1533
|
+
});
|
|
1534
|
+
});
|
|
1357
1535
|
});
|
|
1358
1536
|
afterAll(() => {
|
|
1359
1537
|
storageSpy.mockRestore();
|