@office-ai/aioncli-core 0.18.6 → 0.24.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/CONTRIBUTING.md +546 -0
- package/dist/docs/architecture.md +80 -0
- package/dist/docs/assets/connected_devtools.png +0 -0
- package/dist/docs/assets/gemini-screenshot.png +0 -0
- package/dist/docs/assets/release_patch.png +0 -0
- package/dist/docs/assets/theme-ansi-light.png +0 -0
- package/dist/docs/assets/theme-ansi.png +0 -0
- package/dist/docs/assets/theme-atom-one.png +0 -0
- package/dist/docs/assets/theme-ayu-light.png +0 -0
- package/dist/docs/assets/theme-ayu.png +0 -0
- package/dist/docs/assets/theme-custom.png +0 -0
- package/dist/docs/assets/theme-default-light.png +0 -0
- package/dist/docs/assets/theme-default.png +0 -0
- package/dist/docs/assets/theme-dracula.png +0 -0
- package/dist/docs/assets/theme-github-light.png +0 -0
- package/dist/docs/assets/theme-github.png +0 -0
- package/dist/docs/assets/theme-google-light.png +0 -0
- package/dist/docs/assets/theme-xcode-light.png +0 -0
- package/dist/docs/changelogs/index.md +592 -0
- package/dist/docs/changelogs/latest.md +225 -0
- package/dist/docs/changelogs/preview.md +129 -0
- package/dist/docs/changelogs/releases.md +896 -0
- package/dist/docs/cli/authentication.md +3 -0
- package/dist/docs/cli/checkpointing.md +94 -0
- package/dist/docs/cli/commands.md +354 -0
- package/dist/docs/cli/configuration.md +780 -0
- package/dist/docs/cli/custom-commands.md +315 -0
- package/dist/docs/cli/enterprise.md +565 -0
- package/dist/docs/cli/gemini-ignore.md +71 -0
- package/dist/docs/cli/gemini-md.md +108 -0
- package/dist/docs/cli/generation-settings.md +210 -0
- package/dist/docs/cli/headless.md +388 -0
- package/dist/docs/cli/index.md +63 -0
- package/dist/docs/cli/keyboard-shortcuts.md +143 -0
- package/dist/docs/cli/model-routing.md +37 -0
- package/dist/docs/cli/model.md +62 -0
- package/dist/docs/cli/sandbox.md +171 -0
- package/dist/docs/cli/session-management.md +158 -0
- package/dist/docs/cli/settings.md +114 -0
- package/dist/docs/cli/skills.md +156 -0
- package/dist/docs/cli/system-prompt.md +93 -0
- package/dist/docs/cli/telemetry.md +791 -0
- package/dist/docs/cli/themes.md +237 -0
- package/dist/docs/cli/token-caching.md +20 -0
- package/dist/docs/cli/trusted-folders.md +95 -0
- package/dist/docs/cli/tutorials/skills-getting-started.md +124 -0
- package/dist/docs/cli/tutorials.md +87 -0
- package/dist/docs/cli/uninstall.md +47 -0
- package/dist/docs/core/index.md +101 -0
- package/dist/docs/core/memport.md +244 -0
- package/dist/docs/core/policy-engine.md +267 -0
- package/dist/docs/core/tools-api.md +131 -0
- package/dist/docs/examples/proxy-script.md +83 -0
- package/dist/docs/extension.md +160 -0
- package/dist/docs/extensions/extension-releasing.md +183 -0
- package/dist/docs/extensions/getting-started-extensions.md +245 -0
- package/dist/docs/extensions/index.md +293 -0
- package/dist/docs/faq.md +154 -0
- package/dist/docs/get-started/authentication.md +321 -0
- package/dist/docs/get-started/configuration-v1.md +888 -0
- package/dist/docs/get-started/configuration.md +1536 -0
- package/dist/docs/get-started/deployment.md +143 -0
- package/dist/docs/get-started/examples.md +219 -0
- package/dist/docs/get-started/gemini-3.md +116 -0
- package/dist/docs/get-started/index.md +71 -0
- package/dist/docs/get-started/installation.md +141 -0
- package/dist/docs/hooks/best-practices.md +856 -0
- package/dist/docs/hooks/index.md +687 -0
- package/dist/docs/hooks/reference.md +168 -0
- package/dist/docs/hooks/writing-hooks.md +1026 -0
- package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
- package/dist/docs/ide-integration/index.md +202 -0
- package/dist/docs/index.md +147 -0
- package/dist/docs/integration-tests.md +211 -0
- package/dist/docs/issue-and-pr-automation.md +134 -0
- package/dist/docs/local-development.md +128 -0
- package/dist/docs/mermaid/context.mmd +103 -0
- package/dist/docs/mermaid/render-path.mmd +64 -0
- package/dist/docs/npm.md +62 -0
- package/dist/docs/quota-and-pricing.md +158 -0
- package/dist/docs/release-confidence.md +164 -0
- package/dist/docs/releases.md +540 -0
- package/dist/docs/sidebar.json +301 -0
- package/dist/docs/tools/file-system.md +217 -0
- package/dist/docs/tools/index.md +95 -0
- package/dist/docs/tools/mcp-server.md +1044 -0
- package/dist/docs/tools/memory.md +54 -0
- package/dist/docs/tools/shell.md +260 -0
- package/dist/docs/tools/todos.md +57 -0
- package/dist/docs/tools/web-fetch.md +59 -0
- package/dist/docs/tools/web-search.md +42 -0
- package/dist/docs/tos-privacy.md +96 -0
- package/dist/docs/troubleshooting.md +158 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/agents/a2a-client-manager.d.ts +78 -0
- package/dist/src/agents/a2a-client-manager.js +295 -0
- package/dist/src/agents/a2a-client-manager.js.map +1 -0
- package/dist/src/agents/a2a-client-manager.test.d.ts +6 -0
- package/dist/src/agents/a2a-client-manager.test.js +237 -0
- package/dist/src/agents/a2a-client-manager.test.js.map +1 -0
- package/dist/src/agents/a2aUtils.d.ts +28 -0
- package/dist/src/agents/a2aUtils.js +111 -0
- package/dist/src/agents/a2aUtils.js.map +1 -0
- package/dist/src/agents/a2aUtils.test.d.ts +6 -0
- package/dist/src/agents/a2aUtils.test.js +147 -0
- package/dist/src/agents/a2aUtils.test.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +2 -2
- package/dist/src/agents/codebase-investigator.js +5 -4
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/delegate-to-agent-tool.d.ts +19 -0
- package/dist/src/agents/delegate-to-agent-tool.js +115 -0
- package/dist/src/agents/delegate-to-agent-tool.js.map +1 -0
- package/dist/src/agents/delegate-to-agent-tool.test.d.ts +6 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js +165 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -0
- package/dist/src/agents/introspection-agent.d.ts +23 -0
- package/dist/src/agents/introspection-agent.js +72 -0
- package/dist/src/agents/introspection-agent.js.map +1 -0
- package/dist/src/agents/introspection-agent.test.d.ts +6 -0
- package/dist/src/agents/introspection-agent.test.js +47 -0
- package/dist/src/agents/introspection-agent.test.js.map +1 -0
- package/dist/src/agents/local-executor.d.ts +108 -0
- package/dist/src/agents/local-executor.js +801 -0
- package/dist/src/agents/local-executor.js.map +1 -0
- package/dist/src/agents/local-executor.test.d.ts +6 -0
- package/dist/src/agents/local-executor.test.js +1380 -0
- package/dist/src/agents/local-executor.test.js.map +1 -0
- package/dist/src/agents/local-invocation.d.ts +45 -0
- package/dist/src/agents/local-invocation.js +101 -0
- package/dist/src/agents/local-invocation.js.map +1 -0
- package/dist/src/agents/local-invocation.test.d.ts +6 -0
- package/dist/src/agents/local-invocation.test.js +218 -0
- package/dist/src/agents/local-invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +25 -1
- package/dist/src/agents/registry.js +149 -5
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +247 -25
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/remote-invocation.d.ts +35 -0
- package/dist/src/agents/remote-invocation.js +129 -0
- package/dist/src/agents/remote-invocation.js.map +1 -0
- package/dist/src/agents/remote-invocation.test.d.ts +6 -0
- package/dist/src/agents/remote-invocation.test.js +201 -0
- package/dist/src/agents/remote-invocation.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +2 -2
- package/dist/src/agents/subagent-tool-wrapper.js +11 -6
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +25 -17
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/toml-loader.d.ts +74 -0
- package/dist/src/agents/toml-loader.js +248 -0
- package/dist/src/agents/toml-loader.js.map +1 -0
- package/dist/src/agents/toml-loader.test.d.ts +6 -0
- package/dist/src/agents/toml-loader.test.js +309 -0
- package/dist/src/agents/toml-loader.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +18 -4
- package/dist/src/availability/errorClassification.d.ts +7 -0
- package/dist/src/availability/errorClassification.js +20 -0
- package/dist/src/availability/errorClassification.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.d.ts +36 -0
- package/dist/src/availability/modelAvailabilityService.js +87 -0
- package/dist/src/availability/modelAvailabilityService.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.test.d.ts +6 -0
- package/dist/src/availability/modelAvailabilityService.test.js +140 -0
- package/dist/src/availability/modelAvailabilityService.test.js.map +1 -0
- package/dist/src/availability/modelPolicy.d.ts +49 -0
- package/dist/src/availability/modelPolicy.js +7 -0
- package/dist/src/availability/modelPolicy.js.map +1 -0
- package/dist/src/availability/policyCatalog.d.ts +23 -0
- package/dist/src/availability/policyCatalog.js +82 -0
- package/dist/src/availability/policyCatalog.js.map +1 -0
- package/dist/src/availability/policyCatalog.test.d.ts +6 -0
- package/dist/src/availability/policyCatalog.test.js +70 -0
- package/dist/src/availability/policyCatalog.test.js.map +1 -0
- package/dist/src/availability/policyHelpers.d.ts +52 -0
- package/dist/src/availability/policyHelpers.js +136 -0
- package/dist/src/availability/policyHelpers.js.map +1 -0
- package/dist/src/availability/policyHelpers.test.d.ts +6 -0
- package/dist/src/availability/policyHelpers.test.js +182 -0
- package/dist/src/availability/policyHelpers.test.js.map +1 -0
- package/dist/src/availability/testUtils.d.ts +10 -0
- package/dist/src/availability/testUtils.js +22 -0
- package/dist/src/availability/testUtils.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.js +3 -2
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -1
- package/dist/src/code_assist/experiments/client_metadata.test.js +7 -10
- package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments.js +2 -2
- package/dist/src/code_assist/experiments/experiments.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +2 -0
- package/dist/src/code_assist/oauth2.js +73 -17
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +195 -18
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +10 -1
- package/dist/src/code_assist/server.js +81 -15
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +221 -25
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.js +6 -4
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js +63 -0
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/telemetry.d.ts +14 -0
- package/dist/src/code_assist/telemetry.js +156 -0
- package/dist/src/code_assist/telemetry.js.map +1 -0
- package/dist/src/code_assist/telemetry.test.d.ts +6 -0
- package/dist/src/code_assist/telemetry.test.js +300 -0
- package/dist/src/code_assist/telemetry.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +84 -1
- package/dist/src/code_assist/types.js +21 -0
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/init.d.ts +7 -0
- package/dist/src/commands/init.js +53 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/init.test.d.ts +6 -0
- package/dist/src/commands/init.test.js +25 -0
- package/dist/src/commands/init.test.js.map +1 -0
- package/dist/src/commands/restore.d.ts +9 -0
- package/dist/src/commands/restore.js +46 -0
- package/dist/src/commands/restore.js.map +1 -0
- package/dist/src/commands/restore.test.d.ts +6 -0
- package/dist/src/commands/restore.test.js +137 -0
- package/dist/src/commands/restore.test.js.map +1 -0
- package/dist/src/commands/types.d.ts +41 -0
- package/dist/src/commands/types.js +7 -0
- package/dist/src/commands/types.js.map +1 -0
- package/dist/src/config/config.d.ts +120 -23
- package/dist/src/config/config.js +336 -116
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +373 -95
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/defaultModelConfigs.js +46 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -1
- package/dist/src/config/flashFallback.test.js +11 -35
- package/dist/src/config/flashFallback.test.js.map +1 -1
- package/dist/src/config/models.d.ts +29 -15
- package/dist/src/config/models.js +78 -28
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +91 -77
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +4 -0
- package/dist/src/config/storage.js +12 -0
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +16 -0
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/confirmation-bus/message-bus.d.ts +6 -0
- package/dist/src/confirmation-bus/message-bus.js +66 -3
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +29 -2
- package/dist/src/confirmation-bus/types.js +3 -0
- package/dist/src/confirmation-bus/types.js.map +1 -1
- package/dist/src/core/baseLlmClient.d.ts +30 -2
- package/dist/src/core/baseLlmClient.js +107 -49
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +271 -13
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +5 -1
- package/dist/src/core/client.js +241 -63
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +462 -72
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/clientHookTriggers.d.ts +36 -0
- package/dist/src/core/clientHookTriggers.js +76 -0
- package/dist/src/core/clientHookTriggers.js.map +1 -0
- package/dist/src/core/contentGenerator.js +17 -4
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +132 -3
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +55 -0
- package/dist/src/core/coreToolHookTriggers.js +304 -0
- package/dist/src/core/coreToolHookTriggers.js.map +1 -0
- package/dist/src/core/coreToolHookTriggers.test.d.ts +6 -0
- package/dist/src/core/coreToolHookTriggers.test.js +191 -0
- package/dist/src/core/coreToolHookTriggers.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +6 -85
- package/dist/src/core/coreToolScheduler.js +69 -267
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +161 -346
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.js +132 -76
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +240 -257
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.d.ts +64 -0
- package/dist/src/core/geminiChatHookTriggers.js +136 -0
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -0
- package/dist/src/core/geminiChat_network_retry.test.d.ts +6 -0
- package/dist/src/core/geminiChat_network_retry.test.js +196 -0
- package/dist/src/core/geminiChat_network_retry.test.js.map +1 -0
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.js +23 -6
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +13 -8
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +25 -0
- package/dist/src/core/openaiContentGenerator.js +243 -14
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/prompts.js +82 -26
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +102 -3
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/sessionHookTriggers.d.ts +29 -0
- package/dist/src/core/sessionHookTriggers.js +75 -0
- package/dist/src/core/sessionHookTriggers.js.map +1 -0
- package/dist/src/core/turn.d.ts +34 -21
- package/dist/src/core/turn.js +33 -13
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +0 -5
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +101 -93
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +186 -173
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/fallback/types.d.ts +8 -0
- package/dist/src/generated/git-commit.d.ts +3 -3
- package/dist/src/generated/git-commit.js +3 -3
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookAggregator.js +7 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.d.ts +113 -0
- package/dist/src/hooks/hookEventHandler.js +571 -0
- package/dist/src/hooks/hookEventHandler.js.map +1 -0
- package/dist/src/hooks/hookEventHandler.test.d.ts +6 -0
- package/dist/src/hooks/hookEventHandler.test.js +461 -0
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +1 -5
- package/dist/src/hooks/hookPlanner.js +2 -7
- package/dist/src/hooks/hookPlanner.js.map +1 -1
- package/dist/src/hooks/hookPlanner.test.js +62 -2
- package/dist/src/hooks/hookPlanner.test.js.map +1 -1
- package/dist/src/hooks/hookRegistry.d.ts +6 -18
- package/dist/src/hooks/hookRegistry.js +49 -35
- package/dist/src/hooks/hookRegistry.js.map +1 -1
- package/dist/src/hooks/hookRegistry.test.js +167 -8
- package/dist/src/hooks/hookRegistry.test.js.map +1 -1
- package/dist/src/hooks/hookRunner.d.ts +5 -3
- package/dist/src/hooks/hookRunner.js +74 -18
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookRunner.test.js +174 -36
- package/dist/src/hooks/hookRunner.test.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +40 -0
- package/dist/src/hooks/hookSystem.js +65 -0
- package/dist/src/hooks/hookSystem.js.map +1 -0
- package/dist/src/hooks/hookSystem.test.d.ts +6 -0
- package/dist/src/hooks/hookSystem.test.js +319 -0
- package/dist/src/hooks/hookSystem.test.js.map +1 -0
- package/dist/src/hooks/index.d.ts +17 -0
- package/dist/src/hooks/index.js +18 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/trustedHooks.d.ts +28 -0
- package/dist/src/hooks/trustedHooks.js +90 -0
- package/dist/src/hooks/trustedHooks.js.map +1 -0
- package/dist/src/hooks/trustedHooks.test.d.ts +6 -0
- package/dist/src/hooks/trustedHooks.test.js +154 -0
- package/dist/src/hooks/trustedHooks.test.js.map +1 -0
- package/dist/src/hooks/types.d.ts +21 -11
- package/dist/src/hooks/types.js +31 -27
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/hooks/types.test.js +5 -24
- package/dist/src/hooks/types.test.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +32 -1
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.js +9 -4
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +17 -0
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +1 -1
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/types.d.ts +4 -4
- package/dist/src/index.d.ts +17 -1
- package/dist/src/index.js +18 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/auth-provider.d.ts +16 -0
- package/dist/src/mcp/auth-provider.js +7 -0
- package/dist/src/mcp/auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.d.ts +10 -2
- package/dist/src/mcp/google-auth-provider.js +28 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.test.js +45 -0
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +6 -2
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +4 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +8 -1
- package/dist/src/mcp/oauth-utils.js +31 -2
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +42 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +2 -2
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
- package/dist/src/output/json-formatter.d.ts +2 -2
- package/dist/src/output/json-formatter.js +6 -3
- package/dist/src/output/json-formatter.js.map +1 -1
- package/dist/src/output/json-formatter.test.js +37 -9
- package/dist/src/output/json-formatter.test.js.map +1 -1
- package/dist/src/output/stream-json-formatter.js +6 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -1
- package/dist/src/output/stream-json-formatter.test.js +98 -100
- package/dist/src/output/stream-json-formatter.test.js.map +1 -1
- package/dist/src/output/types.d.ts +3 -0
- package/dist/src/output/types.js.map +1 -1
- package/dist/src/policy/config.js +140 -15
- package/dist/src/policy/config.js.map +1 -1
- package/dist/src/policy/config.test.js +21 -0
- package/dist/src/policy/config.test.js.map +1 -1
- package/dist/src/policy/persistence.test.d.ts +6 -0
- package/dist/src/policy/persistence.test.js +154 -0
- package/dist/src/policy/persistence.test.js.map +1 -0
- package/dist/src/policy/policies/agent.toml +31 -0
- package/dist/src/policy/policies/read-only.toml +5 -0
- package/dist/src/policy/policies/write.toml +5 -0
- package/dist/src/policy/policies/yolo.toml +1 -0
- package/dist/src/policy/policy-engine.d.ts +30 -1
- package/dist/src/policy/policy-engine.js +192 -5
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +520 -3
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/policy/policy-updater.test.d.ts +6 -0
- package/dist/src/policy/policy-updater.test.js +116 -0
- package/dist/src/policy/policy-updater.test.js.map +1 -0
- package/dist/src/policy/shell-safety.test.d.ts +6 -0
- package/dist/src/policy/shell-safety.test.js +75 -0
- package/dist/src/policy/shell-safety.test.js.map +1 -0
- package/dist/src/policy/toml-loader.d.ts +3 -5
- package/dist/src/policy/toml-loader.js +12 -60
- package/dist/src/policy/toml-loader.js.map +1 -1
- package/dist/src/policy/toml-loader.test.js +38 -7
- package/dist/src/policy/toml-loader.test.js.map +1 -1
- package/dist/src/policy/types.d.ts +72 -1
- package/dist/src/policy/types.js +21 -0
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/policy/utils.d.ts +21 -0
- package/dist/src/policy/utils.js +42 -0
- package/dist/src/policy/utils.js.map +1 -0
- package/dist/src/policy/utils.test.d.ts +6 -0
- package/dist/src/policy/utils.test.js +64 -0
- package/dist/src/policy/utils.test.js.map +1 -0
- package/dist/src/resources/resource-registry.d.ts +30 -0
- package/dist/src/resources/resource-registry.js +57 -0
- package/dist/src/resources/resource-registry.js.map +1 -0
- package/dist/src/resources/resource-registry.test.d.ts +6 -0
- package/dist/src/resources/resource-registry.test.js +54 -0
- package/dist/src/resources/resource-registry.test.js.map +1 -0
- package/dist/src/routing/modelRouterService.js +0 -15
- package/dist/src/routing/modelRouterService.js.map +1 -1
- package/dist/src/routing/modelRouterService.test.js +0 -62
- package/dist/src/routing/modelRouterService.test.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.js +10 -21
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +2 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.js +4 -2
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.test.js +11 -10
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +20 -12
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +63 -39
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +3 -2
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/safety/checker-runner.js +17 -6
- package/dist/src/safety/checker-runner.js.map +1 -1
- package/dist/src/scheduler/tool-executor.d.ts +22 -0
- package/dist/src/scheduler/tool-executor.js +198 -0
- package/dist/src/scheduler/tool-executor.js.map +1 -0
- package/dist/src/scheduler/tool-executor.test.d.ts +6 -0
- package/dist/src/scheduler/tool-executor.test.js +231 -0
- package/dist/src/scheduler/tool-executor.test.js.map +1 -0
- package/dist/src/scheduler/types.d.ts +95 -0
- package/dist/src/scheduler/types.js +7 -0
- package/dist/src/scheduler/types.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +1 -0
- package/dist/src/services/chatCompressionService.js +38 -8
- package/dist/src/services/chatCompressionService.js.map +1 -1
- package/dist/src/services/chatCompressionService.test.js +35 -31
- package/dist/src/services/chatCompressionService.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +14 -0
- package/dist/src/services/chatRecordingService.js +37 -0
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +29 -0
- package/dist/src/services/contextManager.js +71 -0
- package/dist/src/services/contextManager.js.map +1 -0
- package/dist/src/services/contextManager.test.d.ts +6 -0
- package/dist/src/services/contextManager.test.js +104 -0
- package/dist/src/services/contextManager.test.js.map +1 -0
- package/dist/src/services/environmentSanitization.d.ts +15 -0
- package/dist/src/services/environmentSanitization.js +141 -0
- package/dist/src/services/environmentSanitization.js.map +1 -0
- package/dist/src/services/environmentSanitization.test.d.ts +6 -0
- package/dist/src/services/environmentSanitization.test.js +284 -0
- package/dist/src/services/environmentSanitization.test.js.map +1 -0
- package/dist/src/services/fileSystemService.d.ts +0 -9
- package/dist/src/services/fileSystemService.js +0 -11
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/gitService.js +18 -2
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +56 -0
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.js +5 -4
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +14 -8
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.golden.test.js +32 -0
- package/dist/src/services/modelConfig.golden.test.js.map +1 -1
- package/dist/src/services/modelConfig.integration.test.js +1 -1
- package/dist/src/services/modelConfig.integration.test.js.map +1 -1
- package/dist/src/services/modelConfigService.d.ts +4 -0
- package/dist/src/services/modelConfigService.js +8 -3
- package/dist/src/services/modelConfigService.js.map +1 -1
- package/dist/src/services/modelConfigService.test.js +221 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -1
- package/dist/src/services/modelConfigServiceTestUtils.d.ts +10 -0
- package/dist/src/services/modelConfigServiceTestUtils.js +17 -0
- package/dist/src/services/modelConfigServiceTestUtils.js.map +1 -0
- package/dist/src/services/sessionSummaryService.d.ts +28 -0
- package/dist/src/services/sessionSummaryService.js +131 -0
- package/dist/src/services/sessionSummaryService.js.map +1 -0
- package/dist/src/services/sessionSummaryService.test.d.ts +6 -0
- package/dist/src/services/sessionSummaryService.test.js +785 -0
- package/dist/src/services/sessionSummaryService.test.js.map +1 -0
- package/dist/src/services/sessionSummaryUtils.d.ts +16 -0
- package/dist/src/services/sessionSummaryUtils.js +129 -0
- package/dist/src/services/sessionSummaryUtils.js.map +1 -0
- package/dist/src/services/sessionSummaryUtils.test.d.ts +6 -0
- package/dist/src/services/sessionSummaryUtils.test.js +137 -0
- package/dist/src/services/sessionSummaryUtils.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +4 -0
- package/dist/src/services/shellExecutionService.js +45 -27
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +240 -8
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases-retry.golden.json +238 -0
- package/dist/src/services/test-data/resolved-aliases.golden.json +36 -0
- package/dist/src/skills/skillLoader.d.ts +28 -0
- package/dist/src/skills/skillLoader.js +77 -0
- package/dist/src/skills/skillLoader.js.map +1 -0
- package/dist/src/skills/skillLoader.test.d.ts +1 -0
- package/dist/src/skills/skillLoader.test.js +2 -0
- package/dist/src/skills/skillLoader.test.js.map +1 -0
- package/dist/src/skills/skillManager.d.ts +51 -0
- package/dist/src/skills/skillManager.js +89 -0
- package/dist/src/skills/skillManager.js.map +1 -0
- package/dist/src/skills/skillManager.test.d.ts +6 -0
- package/dist/src/skills/skillManager.test.js +128 -0
- package/dist/src/skills/skillManager.test.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +11 -7
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +127 -47
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +105 -18
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +9 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +20 -5
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/config.js +2 -0
- package/dist/src/telemetry/config.js.map +1 -1
- package/dist/src/telemetry/config.test.js +25 -0
- package/dist/src/telemetry/config.test.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.d.ts +4 -3
- package/dist/src/telemetry/gcp-exporters.js +8 -4
- package/dist/src/telemetry/gcp-exporters.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +2 -1
- package/dist/src/telemetry/index.js +2 -1
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +5 -3
- package/dist/src/telemetry/loggers.js +353 -334
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +1 -0
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +238 -31
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +22 -0
- package/dist/src/telemetry/metrics.js +32 -0
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +64 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sanitize.d.ts +25 -0
- package/dist/src/telemetry/sanitize.js +48 -0
- package/dist/src/telemetry/sanitize.js.map +1 -0
- package/dist/src/telemetry/sanitize.test.d.ts +6 -0
- package/dist/src/telemetry/sanitize.test.js +279 -0
- package/dist/src/telemetry/sanitize.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +9 -2
- package/dist/src/telemetry/sdk.js +142 -17
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +130 -28
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/semantic.js +1 -1
- package/dist/src/telemetry/semantic.js.map +1 -1
- package/dist/src/telemetry/startupProfiler.d.ts +51 -0
- package/dist/src/telemetry/startupProfiler.js +170 -0
- package/dist/src/telemetry/startupProfiler.js.map +1 -0
- package/dist/src/telemetry/startupProfiler.test.d.ts +6 -0
- package/dist/src/telemetry/startupProfiler.test.js +285 -0
- package/dist/src/telemetry/startupProfiler.test.js.map +1 -0
- package/dist/src/telemetry/telemetry.test.js +10 -3
- package/dist/src/telemetry/telemetry.test.js.map +1 -1
- package/dist/src/telemetry/trace.js +2 -2
- package/dist/src/telemetry/trace.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +62 -16
- package/dist/src/telemetry/types.js +157 -27
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +1 -0
- package/dist/src/telemetry/uiTelemetry.js +2 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +4 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/mock-message-bus.d.ts +61 -0
- package/dist/src/test-utils/mock-message-bus.js +160 -0
- package/dist/src/test-utils/mock-message-bus.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +5 -3
- package/dist/src/test-utils/mock-tool.js +12 -11
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/tools/activate-skill.d.ts +27 -0
- package/dist/src/tools/activate-skill.js +120 -0
- package/dist/src/tools/activate-skill.js.map +1 -0
- package/dist/src/tools/activate-skill.test.d.ts +6 -0
- package/dist/src/tools/activate-skill.test.js +95 -0
- package/dist/src/tools/activate-skill.test.js.map +1 -0
- package/dist/src/tools/confirmation-policy.test.d.ts +6 -0
- package/dist/src/tools/confirmation-policy.test.js +142 -0
- package/dist/src/tools/confirmation-policy.test.js.map +1 -0
- package/dist/src/tools/edit.d.ts +27 -5
- package/dist/src/tools/edit.js +449 -137
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +258 -526
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/get-internal-docs.d.ts +27 -0
- package/dist/src/tools/get-internal-docs.js +129 -0
- package/dist/src/tools/get-internal-docs.js.map +1 -0
- package/dist/src/tools/get-internal-docs.test.d.ts +6 -0
- package/dist/src/tools/get-internal-docs.test.js +57 -0
- package/dist/src/tools/get-internal-docs.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +2 -2
- package/dist/src/tools/glob.js +1 -1
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +2 -1
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +2 -2
- package/dist/src/tools/grep.js +1 -1
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +5 -4
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +2 -2
- package/dist/src/tools/ls.js +2 -2
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +2 -1
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +3 -1
- package/dist/src/tools/mcp-client-manager.js +42 -9
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +66 -10
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +44 -6
- package/dist/src/tools/mcp-client.js +476 -176
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +633 -36
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +2 -2
- package/dist/src/tools/mcp-tool.js +20 -7
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +35 -5
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +3 -3
- package/dist/src/tools/memoryTool.js +3 -4
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +5 -2
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.js +10 -37
- package/dist/src/tools/message-bus-integration.test.js.map +1 -1
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +22 -13
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +2 -2
- package/dist/src/tools/read-file.js +2 -2
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +3 -2
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +2 -2
- package/dist/src/tools/read-many-files.js +7 -6
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +4 -3
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +3 -2
- package/dist/src/tools/ripGrep.js +18 -7
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +60 -4
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +5 -7
- package/dist/src/tools/shell.js +77 -51
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +59 -63
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +2 -1
- package/dist/src/tools/tool-error.js +2 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +17 -0
- package/dist/src/tools/tool-names.js +59 -0
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tool-names.test.d.ts +6 -0
- package/dist/src/tools/tool-names.test.js +43 -0
- package/dist/src/tools/tool-names.test.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +11 -7
- package/dist/src/tools/tool-registry.js +15 -10
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +16 -11
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +25 -6
- package/dist/src/tools/tools.js +44 -25
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +3 -1
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +2 -2
- package/dist/src/tools/web-fetch.js +22 -9
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +18 -19
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +2 -2
- package/dist/src/tools/web-search.js +5 -5
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +2 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +2 -2
- package/dist/src/tools/write-file.js +10 -4
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +4 -1
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +2 -2
- package/dist/src/tools/write-todos.js +5 -4
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/tools/write-todos.test.js +2 -1
- package/dist/src/tools/write-todos.test.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.d.ts +8 -0
- package/dist/src/utils/bfsFileSearch.js +63 -23
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +65 -1
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/checkpointUtils.d.ts +82 -0
- package/dist/src/utils/checkpointUtils.js +117 -0
- package/dist/src/utils/checkpointUtils.js.map +1 -0
- package/dist/src/utils/checkpointUtils.test.d.ts +6 -0
- package/dist/src/utils/checkpointUtils.test.js +229 -0
- package/dist/src/utils/checkpointUtils.test.js.map +1 -0
- package/dist/src/utils/customHeaderUtils.d.ts +9 -0
- package/dist/src/utils/customHeaderUtils.js +34 -0
- package/dist/src/utils/customHeaderUtils.js.map +1 -0
- package/dist/src/utils/customHeaderUtils.test.d.ts +6 -0
- package/dist/src/utils/customHeaderUtils.test.js +77 -0
- package/dist/src/utils/customHeaderUtils.test.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +3 -0
- package/dist/src/utils/debugLogger.js +28 -0
- package/dist/src/utils/debugLogger.js.map +1 -1
- package/dist/src/utils/editCorrector.js +6 -5
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +7 -3
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +9 -1
- package/dist/src/utils/editor.js +23 -14
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +1 -0
- package/dist/src/utils/environmentContext.js +4 -0
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +2 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errorReporting.js +13 -12
- package/dist/src/utils/errorReporting.js.map +1 -1
- package/dist/src/utils/errorReporting.test.js +17 -14
- package/dist/src/utils/errorReporting.test.js.map +1 -1
- package/dist/src/utils/errors.d.ts +8 -0
- package/dist/src/utils/errors.js +39 -2
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/errors.test.d.ts +6 -0
- package/dist/src/utils/errors.test.js +155 -0
- package/dist/src/utils/errors.test.js.map +1 -0
- package/dist/src/utils/events.d.ts +49 -19
- package/dist/src/utils/events.js +21 -9
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/events.test.js +25 -0
- package/dist/src/utils/events.test.js.map +1 -1
- package/dist/src/utils/exitCodes.d.ts +12 -0
- package/dist/src/utils/exitCodes.js +13 -0
- package/dist/src/utils/exitCodes.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +2 -2
- package/dist/src/utils/extensionLoader.js +5 -6
- package/dist/src/utils/extensionLoader.js.map +1 -1
- package/dist/src/utils/extensionLoader.test.js +11 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -1
- package/dist/src/utils/fetch.d.ts +1 -1
- package/dist/src/utils/fetch.js +3 -3
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +4 -0
- package/dist/src/utils/fileUtils.js +53 -0
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +127 -1
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawlCache.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +1 -1
- package/dist/src/utils/flashFallback.test.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.d.ts +11 -0
- package/dist/src/utils/geminiIgnoreParser.js +20 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.test.js +48 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.d.ts +3 -1
- package/dist/src/utils/generateContentResponseUtilities.js +106 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +279 -2
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.js +7 -2
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/googleErrors.js +31 -18
- package/dist/src/utils/googleErrors.js.map +1 -1
- package/dist/src/utils/googleErrors.test.js +10 -2
- package/dist/src/utils/googleErrors.test.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.d.ts +3 -3
- package/dist/src/utils/googleQuotaErrors.js +32 -6
- package/dist/src/utils/googleQuotaErrors.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.test.js +94 -2
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +5 -0
- package/dist/src/utils/memoryDiscovery.js +9 -5
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +31 -1
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +4 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/package.d.ts +14 -0
- package/dist/src/utils/package.js +15 -2
- package/dist/src/utils/package.js.map +1 -1
- package/dist/src/utils/pathCorrector.js +12 -2
- package/dist/src/utils/pathCorrector.js.map +1 -1
- package/dist/src/utils/pathCorrector.test.js +6 -2
- package/dist/src/utils/pathCorrector.test.js.map +1 -1
- package/dist/src/utils/retry.d.ts +11 -0
- package/dist/src/utils/retry.js +62 -21
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +170 -10
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/schemaValidator.d.ts +1 -1
- package/dist/src/utils/schemaValidator.js +1 -1
- package/dist/src/utils/shell-permissions.d.ts +52 -0
- package/dist/src/utils/shell-permissions.js +188 -0
- package/dist/src/utils/shell-permissions.js.map +1 -0
- package/dist/src/utils/shell-permissions.test.d.ts +6 -0
- package/dist/src/utils/shell-permissions.test.js +369 -0
- package/dist/src/utils/shell-permissions.test.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +16 -47
- package/dist/src/utils/shell-utils.js +99 -195
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +99 -288
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/stdio.d.ts +2 -2
- package/dist/src/utils/stdio.js +2 -2
- package/dist/src/utils/stdio.js.map +1 -1
- package/dist/src/utils/stdio.test.js +5 -5
- package/dist/src/utils/stdio.test.js.map +1 -1
- package/dist/src/utils/summarizer.test.js +3 -2
- package/dist/src/utils/summarizer.test.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.test.js +17 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -1
- package/dist/src/utils/tokenCalculation.d.ts +19 -0
- package/dist/src/utils/tokenCalculation.js +85 -0
- package/dist/src/utils/tokenCalculation.js.map +1 -0
- package/dist/src/utils/tokenCalculation.test.d.ts +6 -0
- package/dist/src/utils/tokenCalculation.test.js +87 -0
- package/dist/src/utils/tokenCalculation.test.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +9 -0
- package/dist/src/utils/tool-utils.js +29 -0
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +17 -2
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/version.d.ts +6 -0
- package/dist/src/utils/version.js +15 -0
- package/dist/src/utils/version.js.map +1 -0
- package/dist/src/utils/version.test.d.ts +6 -0
- package/dist/src/utils/version.test.js +39 -0
- package/dist/src/utils/version.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
package/dist/src/tools/edit.js
CHANGED
|
@@ -5,21 +5,23 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import * as fs from 'node:fs';
|
|
7
7
|
import * as path from 'node:path';
|
|
8
|
+
import * as crypto from 'node:crypto';
|
|
8
9
|
import * as Diff from 'diff';
|
|
9
10
|
import { BaseDeclarativeTool, BaseToolInvocation, Kind, ToolConfirmationOutcome, } from './tools.js';
|
|
10
11
|
import { ToolErrorType } from './tool-error.js';
|
|
11
12
|
import { makeRelative, shortenPath } from '../utils/paths.js';
|
|
12
13
|
import { isNodeError } from '../utils/errors.js';
|
|
13
14
|
import { ApprovalMode } from '../policy/types.js';
|
|
14
|
-
import { ensureCorrectEdit } from '../utils/editCorrector.js';
|
|
15
15
|
import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
|
|
16
|
-
import {
|
|
17
|
-
import { FileOperationEvent } from '../telemetry/types.js';
|
|
18
|
-
import { FileOperation } from '../telemetry/metrics.js';
|
|
19
|
-
import { getSpecificMimeType } from '../utils/fileUtils.js';
|
|
20
|
-
import { getLanguageFromFilePath } from '../utils/language-detection.js';
|
|
16
|
+
import {} from './modifiable-tool.js';
|
|
21
17
|
import { IdeClient } from '../ide/ide-client.js';
|
|
18
|
+
import { FixLLMEditWithInstruction } from '../utils/llm-edit-fixer.js';
|
|
22
19
|
import { safeLiteralReplace } from '../utils/textUtils.js';
|
|
20
|
+
import { EditStrategyEvent } from '../telemetry/types.js';
|
|
21
|
+
import { logEditStrategy } from '../telemetry/loggers.js';
|
|
22
|
+
import { EditCorrectionEvent } from '../telemetry/types.js';
|
|
23
|
+
import { logEditCorrectionEvent } from '../telemetry/loggers.js';
|
|
24
|
+
import { correctPath } from '../utils/pathCorrector.js';
|
|
23
25
|
import { EDIT_TOOL_NAME, READ_FILE_TOOL_NAME } from './tool-names.js';
|
|
24
26
|
import { debugLogger } from '../utils/debugLogger.js';
|
|
25
27
|
export function applyReplacement(currentContent, oldString, newString, isNewFile) {
|
|
@@ -37,16 +39,295 @@ export function applyReplacement(currentContent, oldString, newString, isNewFile
|
|
|
37
39
|
// Use intelligent replacement that handles $ sequences safely
|
|
38
40
|
return safeLiteralReplace(currentContent, oldString, newString);
|
|
39
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a SHA256 hash of the given content.
|
|
44
|
+
* @param content The string content to hash.
|
|
45
|
+
* @returns A hex-encoded hash string.
|
|
46
|
+
*/
|
|
47
|
+
function hashContent(content) {
|
|
48
|
+
return crypto.createHash('sha256').update(content).digest('hex');
|
|
49
|
+
}
|
|
50
|
+
function restoreTrailingNewline(originalContent, modifiedContent) {
|
|
51
|
+
const hadTrailingNewline = originalContent.endsWith('\n');
|
|
52
|
+
if (hadTrailingNewline && !modifiedContent.endsWith('\n')) {
|
|
53
|
+
return modifiedContent + '\n';
|
|
54
|
+
}
|
|
55
|
+
else if (!hadTrailingNewline && modifiedContent.endsWith('\n')) {
|
|
56
|
+
return modifiedContent.replace(/\n$/, '');
|
|
57
|
+
}
|
|
58
|
+
return modifiedContent;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Escapes characters with special meaning in regular expressions.
|
|
62
|
+
* @param str The string to escape.
|
|
63
|
+
* @returns The escaped string.
|
|
64
|
+
*/
|
|
65
|
+
function escapeRegex(str) {
|
|
66
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
67
|
+
}
|
|
68
|
+
async function calculateExactReplacement(context) {
|
|
69
|
+
const { currentContent, params } = context;
|
|
70
|
+
const { old_string, new_string } = params;
|
|
71
|
+
const normalizedCode = currentContent;
|
|
72
|
+
const normalizedSearch = old_string.replace(/\r\n/g, '\n');
|
|
73
|
+
const normalizedReplace = new_string.replace(/\r\n/g, '\n');
|
|
74
|
+
const exactOccurrences = normalizedCode.split(normalizedSearch).length - 1;
|
|
75
|
+
if (exactOccurrences > 0) {
|
|
76
|
+
let modifiedCode = safeLiteralReplace(normalizedCode, normalizedSearch, normalizedReplace);
|
|
77
|
+
modifiedCode = restoreTrailingNewline(currentContent, modifiedCode);
|
|
78
|
+
return {
|
|
79
|
+
newContent: modifiedCode,
|
|
80
|
+
occurrences: exactOccurrences,
|
|
81
|
+
finalOldString: normalizedSearch,
|
|
82
|
+
finalNewString: normalizedReplace,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
async function calculateFlexibleReplacement(context) {
|
|
88
|
+
const { currentContent, params } = context;
|
|
89
|
+
const { old_string, new_string } = params;
|
|
90
|
+
const normalizedCode = currentContent;
|
|
91
|
+
const normalizedSearch = old_string.replace(/\r\n/g, '\n');
|
|
92
|
+
const normalizedReplace = new_string.replace(/\r\n/g, '\n');
|
|
93
|
+
const sourceLines = normalizedCode.match(/.*(?:\n|$)/g)?.slice(0, -1) ?? [];
|
|
94
|
+
const searchLinesStripped = normalizedSearch
|
|
95
|
+
.split('\n')
|
|
96
|
+
.map((line) => line.trim());
|
|
97
|
+
const replaceLines = normalizedReplace.split('\n');
|
|
98
|
+
let flexibleOccurrences = 0;
|
|
99
|
+
let i = 0;
|
|
100
|
+
while (i <= sourceLines.length - searchLinesStripped.length) {
|
|
101
|
+
const window = sourceLines.slice(i, i + searchLinesStripped.length);
|
|
102
|
+
const windowStripped = window.map((line) => line.trim());
|
|
103
|
+
const isMatch = windowStripped.every((line, index) => line === searchLinesStripped[index]);
|
|
104
|
+
if (isMatch) {
|
|
105
|
+
flexibleOccurrences++;
|
|
106
|
+
const firstLineInMatch = window[0];
|
|
107
|
+
const indentationMatch = firstLineInMatch.match(/^(\s*)/);
|
|
108
|
+
const indentation = indentationMatch ? indentationMatch[1] : '';
|
|
109
|
+
const newBlockWithIndent = replaceLines.map((line) => `${indentation}${line}`);
|
|
110
|
+
sourceLines.splice(i, searchLinesStripped.length, newBlockWithIndent.join('\n'));
|
|
111
|
+
i += replaceLines.length;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
i++;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (flexibleOccurrences > 0) {
|
|
118
|
+
let modifiedCode = sourceLines.join('');
|
|
119
|
+
modifiedCode = restoreTrailingNewline(currentContent, modifiedCode);
|
|
120
|
+
return {
|
|
121
|
+
newContent: modifiedCode,
|
|
122
|
+
occurrences: flexibleOccurrences,
|
|
123
|
+
finalOldString: normalizedSearch,
|
|
124
|
+
finalNewString: normalizedReplace,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
async function calculateRegexReplacement(context) {
|
|
130
|
+
const { currentContent, params } = context;
|
|
131
|
+
const { old_string, new_string } = params;
|
|
132
|
+
// Normalize line endings for consistent processing.
|
|
133
|
+
const normalizedSearch = old_string.replace(/\r\n/g, '\n');
|
|
134
|
+
const normalizedReplace = new_string.replace(/\r\n/g, '\n');
|
|
135
|
+
// This logic is ported from your Python implementation.
|
|
136
|
+
// It builds a flexible, multi-line regex from a search string.
|
|
137
|
+
const delimiters = ['(', ')', ':', '[', ']', '{', '}', '>', '<', '='];
|
|
138
|
+
let processedString = normalizedSearch;
|
|
139
|
+
for (const delim of delimiters) {
|
|
140
|
+
processedString = processedString.split(delim).join(` ${delim} `);
|
|
141
|
+
}
|
|
142
|
+
// Split by any whitespace and remove empty strings.
|
|
143
|
+
const tokens = processedString.split(/\s+/).filter(Boolean);
|
|
144
|
+
if (tokens.length === 0) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const escapedTokens = tokens.map(escapeRegex);
|
|
148
|
+
// Join tokens with `\s*` to allow for flexible whitespace between them.
|
|
149
|
+
const pattern = escapedTokens.join('\\s*');
|
|
150
|
+
// The final pattern captures leading whitespace (indentation) and then matches the token pattern.
|
|
151
|
+
// 'm' flag enables multi-line mode, so '^' matches the start of any line.
|
|
152
|
+
const finalPattern = `^(\\s*)${pattern}`;
|
|
153
|
+
const flexibleRegex = new RegExp(finalPattern, 'm');
|
|
154
|
+
const match = flexibleRegex.exec(currentContent);
|
|
155
|
+
if (!match) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
const indentation = match[1] || '';
|
|
159
|
+
const newLines = normalizedReplace.split('\n');
|
|
160
|
+
const newBlockWithIndent = newLines
|
|
161
|
+
.map((line) => `${indentation}${line}`)
|
|
162
|
+
.join('\n');
|
|
163
|
+
// Use replace with the regex to substitute the matched content.
|
|
164
|
+
// Since the regex doesn't have the 'g' flag, it will only replace the first occurrence.
|
|
165
|
+
const modifiedCode = currentContent.replace(flexibleRegex, newBlockWithIndent);
|
|
166
|
+
return {
|
|
167
|
+
newContent: restoreTrailingNewline(currentContent, modifiedCode),
|
|
168
|
+
occurrences: 1, // This method is designed to find and replace only the first occurrence.
|
|
169
|
+
finalOldString: normalizedSearch,
|
|
170
|
+
finalNewString: normalizedReplace,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Detects the line ending style of a string.
|
|
175
|
+
* @param content The string content to analyze.
|
|
176
|
+
* @returns '\r\n' for Windows-style, '\n' for Unix-style.
|
|
177
|
+
*/
|
|
178
|
+
function detectLineEnding(content) {
|
|
179
|
+
// If a Carriage Return is found, assume Windows-style endings.
|
|
180
|
+
// This is a simple but effective heuristic.
|
|
181
|
+
return content.includes('\r\n') ? '\r\n' : '\n';
|
|
182
|
+
}
|
|
183
|
+
export async function calculateReplacement(config, context) {
|
|
184
|
+
const { currentContent, params } = context;
|
|
185
|
+
const { old_string, new_string } = params;
|
|
186
|
+
const normalizedSearch = old_string.replace(/\r\n/g, '\n');
|
|
187
|
+
const normalizedReplace = new_string.replace(/\r\n/g, '\n');
|
|
188
|
+
if (normalizedSearch === '') {
|
|
189
|
+
return {
|
|
190
|
+
newContent: currentContent,
|
|
191
|
+
occurrences: 0,
|
|
192
|
+
finalOldString: normalizedSearch,
|
|
193
|
+
finalNewString: normalizedReplace,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const exactResult = await calculateExactReplacement(context);
|
|
197
|
+
if (exactResult) {
|
|
198
|
+
const event = new EditStrategyEvent('exact');
|
|
199
|
+
logEditStrategy(config, event);
|
|
200
|
+
return exactResult;
|
|
201
|
+
}
|
|
202
|
+
const flexibleResult = await calculateFlexibleReplacement(context);
|
|
203
|
+
if (flexibleResult) {
|
|
204
|
+
const event = new EditStrategyEvent('flexible');
|
|
205
|
+
logEditStrategy(config, event);
|
|
206
|
+
return flexibleResult;
|
|
207
|
+
}
|
|
208
|
+
const regexResult = await calculateRegexReplacement(context);
|
|
209
|
+
if (regexResult) {
|
|
210
|
+
const event = new EditStrategyEvent('regex');
|
|
211
|
+
logEditStrategy(config, event);
|
|
212
|
+
return regexResult;
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
newContent: currentContent,
|
|
216
|
+
occurrences: 0,
|
|
217
|
+
finalOldString: normalizedSearch,
|
|
218
|
+
finalNewString: normalizedReplace,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
export function getErrorReplaceResult(params, occurrences, expectedReplacements, finalOldString, finalNewString) {
|
|
222
|
+
let error = undefined;
|
|
223
|
+
if (occurrences === 0) {
|
|
224
|
+
error = {
|
|
225
|
+
display: `Failed to edit, could not find the string to replace.`,
|
|
226
|
+
raw: `Failed to edit, 0 occurrences found for old_string (${finalOldString}). Original old_string was (${params.old_string}) in ${params.file_path}. No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${READ_FILE_TOOL_NAME} tool to verify.`,
|
|
227
|
+
type: ToolErrorType.EDIT_NO_OCCURRENCE_FOUND,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
else if (occurrences !== expectedReplacements) {
|
|
231
|
+
const occurrenceTerm = expectedReplacements === 1 ? 'occurrence' : 'occurrences';
|
|
232
|
+
error = {
|
|
233
|
+
display: `Failed to edit, expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences}.`,
|
|
234
|
+
raw: `Failed to edit, Expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences} for old_string in file: ${params.file_path}`,
|
|
235
|
+
type: ToolErrorType.EDIT_EXPECTED_OCCURRENCE_MISMATCH,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
else if (finalOldString === finalNewString) {
|
|
239
|
+
error = {
|
|
240
|
+
display: `No changes to apply. The old_string and new_string are identical.`,
|
|
241
|
+
raw: `No changes to apply. The old_string and new_string are identical in file: ${params.file_path}`,
|
|
242
|
+
type: ToolErrorType.EDIT_NO_CHANGE,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return error;
|
|
246
|
+
}
|
|
40
247
|
class EditToolInvocation extends BaseToolInvocation {
|
|
41
248
|
config;
|
|
42
|
-
resolvedPath;
|
|
43
249
|
constructor(config, params, messageBus, toolName, displayName) {
|
|
44
250
|
super(params, messageBus, toolName, displayName);
|
|
45
251
|
this.config = config;
|
|
46
|
-
this.resolvedPath = path.resolve(this.config.getTargetDir(), this.params.file_path);
|
|
47
252
|
}
|
|
48
253
|
toolLocations() {
|
|
49
|
-
return [{ path: this.
|
|
254
|
+
return [{ path: this.params.file_path }];
|
|
255
|
+
}
|
|
256
|
+
async attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding) {
|
|
257
|
+
// In order to keep from clobbering edits made outside our system,
|
|
258
|
+
// check if the file has been modified since we first read it.
|
|
259
|
+
let errorForLlmEditFixer = initialError.raw;
|
|
260
|
+
let contentForLlmEditFixer = currentContent;
|
|
261
|
+
const initialContentHash = hashContent(currentContent);
|
|
262
|
+
const onDiskContent = await this.config
|
|
263
|
+
.getFileSystemService()
|
|
264
|
+
.readTextFile(params.file_path);
|
|
265
|
+
const onDiskContentHash = hashContent(onDiskContent.replace(/\r\n/g, '\n'));
|
|
266
|
+
if (initialContentHash !== onDiskContentHash) {
|
|
267
|
+
// The file has changed on disk since we first read it.
|
|
268
|
+
// Use the latest content for the correction attempt.
|
|
269
|
+
contentForLlmEditFixer = onDiskContent.replace(/\r\n/g, '\n');
|
|
270
|
+
errorForLlmEditFixer = `The initial edit attempt failed with the following error: "${initialError.raw}". However, the file has been modified by either the user or an external process since that edit attempt. The file content provided to you is the latest version. Please base your correction on this new content.`;
|
|
271
|
+
}
|
|
272
|
+
const fixedEdit = await FixLLMEditWithInstruction(params.instruction ?? 'Apply the requested edit.', params.old_string, params.new_string, errorForLlmEditFixer, contentForLlmEditFixer, this.config.getBaseLlmClient(), abortSignal);
|
|
273
|
+
// If the self-correction attempt timed out, return the original error.
|
|
274
|
+
if (fixedEdit === null) {
|
|
275
|
+
return {
|
|
276
|
+
currentContent: contentForLlmEditFixer,
|
|
277
|
+
newContent: currentContent,
|
|
278
|
+
occurrences: 0,
|
|
279
|
+
isNewFile: false,
|
|
280
|
+
error: initialError,
|
|
281
|
+
originalLineEnding,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
if (fixedEdit.noChangesRequired) {
|
|
285
|
+
return {
|
|
286
|
+
currentContent,
|
|
287
|
+
newContent: currentContent,
|
|
288
|
+
occurrences: 0,
|
|
289
|
+
isNewFile: false,
|
|
290
|
+
error: {
|
|
291
|
+
display: `No changes required. The file already meets the specified conditions.`,
|
|
292
|
+
raw: `A secondary check by an LLM determined that no changes were necessary to fulfill the instruction. Explanation: ${fixedEdit.explanation}. Original error with the parameters given: ${initialError.raw}`,
|
|
293
|
+
type: ToolErrorType.EDIT_NO_CHANGE_LLM_JUDGEMENT,
|
|
294
|
+
},
|
|
295
|
+
originalLineEnding,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
const secondAttemptResult = await calculateReplacement(this.config, {
|
|
299
|
+
params: {
|
|
300
|
+
...params,
|
|
301
|
+
old_string: fixedEdit.search,
|
|
302
|
+
new_string: fixedEdit.replace,
|
|
303
|
+
},
|
|
304
|
+
currentContent: contentForLlmEditFixer,
|
|
305
|
+
abortSignal,
|
|
306
|
+
});
|
|
307
|
+
const secondError = getErrorReplaceResult(params, secondAttemptResult.occurrences, params.expected_replacements ?? 1, secondAttemptResult.finalOldString, secondAttemptResult.finalNewString);
|
|
308
|
+
if (secondError) {
|
|
309
|
+
// The fix failed, log failure and return the original error
|
|
310
|
+
const event = new EditCorrectionEvent('failure');
|
|
311
|
+
logEditCorrectionEvent(this.config, event);
|
|
312
|
+
return {
|
|
313
|
+
currentContent: contentForLlmEditFixer,
|
|
314
|
+
newContent: currentContent,
|
|
315
|
+
occurrences: 0,
|
|
316
|
+
isNewFile: false,
|
|
317
|
+
error: initialError,
|
|
318
|
+
originalLineEnding,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
const event = new EditCorrectionEvent('success');
|
|
322
|
+
logEditCorrectionEvent(this.config, event);
|
|
323
|
+
return {
|
|
324
|
+
currentContent: contentForLlmEditFixer,
|
|
325
|
+
newContent: secondAttemptResult.newContent,
|
|
326
|
+
occurrences: secondAttemptResult.occurrences,
|
|
327
|
+
isNewFile: false,
|
|
328
|
+
error: undefined,
|
|
329
|
+
originalLineEnding,
|
|
330
|
+
};
|
|
50
331
|
}
|
|
51
332
|
/**
|
|
52
333
|
* Calculates the potential outcome of an edit operation.
|
|
@@ -58,100 +339,93 @@ class EditToolInvocation extends BaseToolInvocation {
|
|
|
58
339
|
const expectedReplacements = params.expected_replacements ?? 1;
|
|
59
340
|
let currentContent = null;
|
|
60
341
|
let fileExists = false;
|
|
61
|
-
let
|
|
62
|
-
let finalNewString = params.new_string;
|
|
63
|
-
let finalOldString = params.old_string;
|
|
64
|
-
let occurrences = 0;
|
|
65
|
-
let error = undefined;
|
|
342
|
+
let originalLineEnding = '\n'; // Default for new files
|
|
66
343
|
try {
|
|
67
344
|
currentContent = await this.config
|
|
68
345
|
.getFileSystemService()
|
|
69
|
-
.readTextFile(
|
|
70
|
-
|
|
346
|
+
.readTextFile(params.file_path);
|
|
347
|
+
originalLineEnding = detectLineEnding(currentContent);
|
|
71
348
|
currentContent = currentContent.replace(/\r\n/g, '\n');
|
|
72
349
|
fileExists = true;
|
|
73
350
|
}
|
|
74
351
|
catch (err) {
|
|
75
352
|
if (!isNodeError(err) || err.code !== 'ENOENT') {
|
|
76
|
-
// Rethrow unexpected FS errors (permissions, etc.)
|
|
77
353
|
throw err;
|
|
78
354
|
}
|
|
79
355
|
fileExists = false;
|
|
80
356
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
357
|
+
const isNewFile = params.old_string === '' && !fileExists;
|
|
358
|
+
if (isNewFile) {
|
|
359
|
+
return {
|
|
360
|
+
currentContent,
|
|
361
|
+
newContent: params.new_string,
|
|
362
|
+
occurrences: 1,
|
|
363
|
+
isNewFile: true,
|
|
364
|
+
error: undefined,
|
|
365
|
+
originalLineEnding,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
// after this point, it's not a new file/edit
|
|
369
|
+
if (!fileExists) {
|
|
370
|
+
return {
|
|
371
|
+
currentContent,
|
|
372
|
+
newContent: '',
|
|
373
|
+
occurrences: 0,
|
|
374
|
+
isNewFile: false,
|
|
375
|
+
error: {
|
|
376
|
+
display: `File not found. Cannot apply edit. Use an empty old_string to create a new file.`,
|
|
377
|
+
raw: `File not found: ${params.file_path}`,
|
|
378
|
+
type: ToolErrorType.FILE_NOT_FOUND,
|
|
379
|
+
},
|
|
380
|
+
originalLineEnding,
|
|
381
|
+
};
|
|
84
382
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
383
|
+
if (currentContent === null) {
|
|
384
|
+
return {
|
|
385
|
+
currentContent,
|
|
386
|
+
newContent: '',
|
|
387
|
+
occurrences: 0,
|
|
388
|
+
isNewFile: false,
|
|
389
|
+
error: {
|
|
390
|
+
display: `Failed to read content of file.`,
|
|
391
|
+
raw: `Failed to read content of existing file: ${params.file_path}`,
|
|
392
|
+
type: ToolErrorType.READ_CONTENT_FAILURE,
|
|
393
|
+
},
|
|
394
|
+
originalLineEnding,
|
|
91
395
|
};
|
|
92
396
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// Error: Trying to create a file that already exists
|
|
101
|
-
error = {
|
|
397
|
+
if (params.old_string === '') {
|
|
398
|
+
return {
|
|
399
|
+
currentContent,
|
|
400
|
+
newContent: currentContent,
|
|
401
|
+
occurrences: 0,
|
|
402
|
+
isNewFile: false,
|
|
403
|
+
error: {
|
|
102
404
|
display: `Failed to edit. Attempted to create a file that already exists.`,
|
|
103
|
-
raw: `File already exists, cannot create: ${
|
|
405
|
+
raw: `File already exists, cannot create: ${params.file_path}`,
|
|
104
406
|
type: ToolErrorType.ATTEMPT_TO_CREATE_EXISTING_FILE,
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
else if (occurrences === 0) {
|
|
108
|
-
error = {
|
|
109
|
-
display: `Failed to edit, could not find the string to replace.`,
|
|
110
|
-
raw: `Failed to edit, 0 occurrences found for old_string in ${this.resolvedPath}. No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${READ_FILE_TOOL_NAME} tool to verify.`,
|
|
111
|
-
type: ToolErrorType.EDIT_NO_OCCURRENCE_FOUND,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
else if (occurrences !== expectedReplacements) {
|
|
115
|
-
const occurrenceTerm = expectedReplacements === 1 ? 'occurrence' : 'occurrences';
|
|
116
|
-
error = {
|
|
117
|
-
display: `Failed to edit, expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences}.`,
|
|
118
|
-
raw: `Failed to edit, Expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences} for old_string in file: ${this.resolvedPath}`,
|
|
119
|
-
type: ToolErrorType.EDIT_EXPECTED_OCCURRENCE_MISMATCH,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
else if (finalOldString === finalNewString) {
|
|
123
|
-
error = {
|
|
124
|
-
display: `No changes to apply. The old_string and new_string are identical.`,
|
|
125
|
-
raw: `No changes to apply. The old_string and new_string are identical in file: ${this.resolvedPath}`,
|
|
126
|
-
type: ToolErrorType.EDIT_NO_CHANGE,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
// Should not happen if fileExists and no exception was thrown, but defensively:
|
|
132
|
-
error = {
|
|
133
|
-
display: `Failed to read content of file.`,
|
|
134
|
-
raw: `Failed to read content of existing file: ${this.resolvedPath}`,
|
|
135
|
-
type: ToolErrorType.READ_CONTENT_FAILURE,
|
|
407
|
+
},
|
|
408
|
+
originalLineEnding,
|
|
136
409
|
};
|
|
137
410
|
}
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
411
|
+
const replacementResult = await calculateReplacement(this.config, {
|
|
412
|
+
params,
|
|
413
|
+
currentContent,
|
|
414
|
+
abortSignal,
|
|
415
|
+
});
|
|
416
|
+
const initialError = getErrorReplaceResult(params, replacementResult.occurrences, expectedReplacements, replacementResult.finalOldString, replacementResult.finalNewString);
|
|
417
|
+
if (!initialError) {
|
|
418
|
+
return {
|
|
419
|
+
currentContent,
|
|
420
|
+
newContent: replacementResult.newContent,
|
|
421
|
+
occurrences: replacementResult.occurrences,
|
|
422
|
+
isNewFile: false,
|
|
423
|
+
error: undefined,
|
|
424
|
+
originalLineEnding,
|
|
146
425
|
};
|
|
147
426
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
newContent,
|
|
151
|
-
occurrences,
|
|
152
|
-
error,
|
|
153
|
-
isNewFile,
|
|
154
|
-
};
|
|
427
|
+
// If there was an error, try to self-correct.
|
|
428
|
+
return this.attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding);
|
|
155
429
|
}
|
|
156
430
|
/**
|
|
157
431
|
* Handles the confirmation prompt for the Edit tool in the CLI.
|
|
@@ -177,24 +451,29 @@ class EditToolInvocation extends BaseToolInvocation {
|
|
|
177
451
|
debugLogger.log(`Error: ${editData.error.display}`);
|
|
178
452
|
return false;
|
|
179
453
|
}
|
|
180
|
-
const fileName = path.basename(this.
|
|
454
|
+
const fileName = path.basename(this.params.file_path);
|
|
181
455
|
const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
|
|
182
456
|
const ideClient = await IdeClient.getInstance();
|
|
183
457
|
const ideConfirmation = this.config.getIdeMode() && ideClient.isDiffingEnabled()
|
|
184
|
-
? ideClient.openDiff(this.
|
|
458
|
+
? ideClient.openDiff(this.params.file_path, editData.newContent)
|
|
185
459
|
: undefined;
|
|
186
460
|
const confirmationDetails = {
|
|
187
461
|
type: 'edit',
|
|
188
462
|
title: `Confirm Edit: ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`,
|
|
189
463
|
fileName,
|
|
190
|
-
filePath: this.
|
|
464
|
+
filePath: this.params.file_path,
|
|
191
465
|
fileDiff,
|
|
192
466
|
originalContent: editData.currentContent,
|
|
193
467
|
newContent: editData.newContent,
|
|
194
468
|
onConfirm: async (outcome) => {
|
|
195
469
|
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
470
|
+
// No need to publish a policy update as the default policy for
|
|
471
|
+
// AUTO_EDIT already reflects always approving edit.
|
|
196
472
|
this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
|
|
197
473
|
}
|
|
474
|
+
else {
|
|
475
|
+
await this.publishPolicyUpdate(outcome);
|
|
476
|
+
}
|
|
198
477
|
if (ideConfirmation) {
|
|
199
478
|
const result = await ideConfirmation;
|
|
200
479
|
if (result.status === 'accepted' && result.content) {
|
|
@@ -258,34 +537,38 @@ class EditToolInvocation extends BaseToolInvocation {
|
|
|
258
537
|
};
|
|
259
538
|
}
|
|
260
539
|
try {
|
|
261
|
-
this.ensureParentDirectoriesExist(this.
|
|
540
|
+
this.ensureParentDirectoriesExist(this.params.file_path);
|
|
541
|
+
let finalContent = editData.newContent;
|
|
542
|
+
// Restore original line endings if they were CRLF
|
|
543
|
+
if (!editData.isNewFile && editData.originalLineEnding === '\r\n') {
|
|
544
|
+
finalContent = finalContent.replace(/\n/g, '\r\n');
|
|
545
|
+
}
|
|
262
546
|
await this.config
|
|
263
547
|
.getFileSystemService()
|
|
264
|
-
.writeTextFile(this.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
fileName
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
diffStat,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
logFileOperation(this.config, new FileOperationEvent(EDIT_TOOL_NAME, operation, editData.newContent.split('\n').length, mimetype, extension, programmingLanguage));
|
|
548
|
+
.writeTextFile(this.params.file_path, finalContent);
|
|
549
|
+
let displayResult;
|
|
550
|
+
if (editData.isNewFile) {
|
|
551
|
+
displayResult = `Created ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`;
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
// Generate diff for display, even though core logic doesn't technically need it
|
|
555
|
+
// The CLI wrapper will use this part of the ToolResult
|
|
556
|
+
const fileName = path.basename(this.params.file_path);
|
|
557
|
+
const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', // Should not be null here if not isNewFile
|
|
558
|
+
editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
|
|
559
|
+
const diffStat = getDiffStat(fileName, editData.currentContent ?? '', editData.newContent, this.params.new_string);
|
|
560
|
+
displayResult = {
|
|
561
|
+
fileDiff,
|
|
562
|
+
fileName,
|
|
563
|
+
originalContent: editData.currentContent,
|
|
564
|
+
newContent: editData.newContent,
|
|
565
|
+
diffStat,
|
|
566
|
+
};
|
|
567
|
+
}
|
|
285
568
|
const llmSuccessMessageParts = [
|
|
286
569
|
editData.isNewFile
|
|
287
|
-
? `Created new file: ${this.
|
|
288
|
-
: `Successfully modified file: ${this.
|
|
570
|
+
? `Created new file: ${this.params.file_path} with provided content.`
|
|
571
|
+
: `Successfully modified file: ${this.params.file_path} (${editData.occurrences} replacements).`,
|
|
289
572
|
];
|
|
290
573
|
if (this.params.modified_by_user) {
|
|
291
574
|
llmSuccessMessageParts.push(`User modified the \`new_string\` content to be: ${this.params.new_string}.`);
|
|
@@ -325,23 +608,42 @@ export class EditTool extends BaseDeclarativeTool {
|
|
|
325
608
|
static Name = EDIT_TOOL_NAME;
|
|
326
609
|
constructor(config, messageBus) {
|
|
327
610
|
super(EditTool.Name, 'Edit', `Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool to examine the file's current content before attempting a text replacement.
|
|
328
|
-
|
|
611
|
+
|
|
329
612
|
The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
|
|
330
|
-
|
|
331
|
-
Expectation for required parameters:
|
|
332
|
-
1. \`
|
|
333
|
-
2. \`
|
|
334
|
-
3. \`
|
|
335
|
-
4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
|
|
336
|
-
**Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for \`old_string\`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail.
|
|
337
|
-
|
|
613
|
+
|
|
614
|
+
Expectation for required parameters:
|
|
615
|
+
1. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).
|
|
616
|
+
2. \`new_string\` MUST be the exact literal text to replace \`old_string\` with (also including all whitespace, indentation, newlines, and surrounding code etc.). Ensure the resulting code is correct and idiomatic and that \`old_string\` and \`new_string\` are different.
|
|
617
|
+
3. \`instruction\` is the detailed instruction of what needs to be changed. It is important to Make it specific and detailed so developers or large language models can understand what needs to be changed and perform the changes on their own if necessary.
|
|
618
|
+
4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
|
|
619
|
+
**Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for \`old_string\`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail.
|
|
620
|
+
5. Prefer to break down complex and long changes into multiple smaller atomic calls to this tool. Always check the content of the file after changes or not finding a string to match.
|
|
621
|
+
**Multiple replacements:** Set \`expected_replacements\` to the number of occurrences you want to replace. The tool will replace ALL occurrences that match \`old_string\` exactly. Ensure the number of replacements matches your expectation.`, Kind.Edit, {
|
|
338
622
|
properties: {
|
|
339
623
|
file_path: {
|
|
340
624
|
description: 'The path to the file to modify.',
|
|
341
625
|
type: 'string',
|
|
342
626
|
},
|
|
627
|
+
instruction: {
|
|
628
|
+
description: `A clear, semantic instruction for the code change, acting as a high-quality prompt for an expert LLM assistant. It must be self-contained and explain the goal of the change.
|
|
629
|
+
|
|
630
|
+
A good instruction should concisely answer:
|
|
631
|
+
1. WHY is the change needed? (e.g., "To fix a bug where users can be null...")
|
|
632
|
+
2. WHERE should the change happen? (e.g., "...in the 'renderUserProfile' function...")
|
|
633
|
+
3. WHAT is the high-level change? (e.g., "...add a null check for the 'user' object...")
|
|
634
|
+
4. WHAT is the desired outcome? (e.g., "...so that it displays a loading spinner instead of crashing.")
|
|
635
|
+
|
|
636
|
+
**GOOD Example:** "In the 'calculateTotal' function, correct the sales tax calculation by updating the 'taxRate' constant from 0.05 to 0.075 to reflect the new regional tax laws."
|
|
637
|
+
|
|
638
|
+
**BAD Examples:**
|
|
639
|
+
- "Change the text." (Too vague)
|
|
640
|
+
- "Fix the bug." (Doesn't explain the bug or the fix)
|
|
641
|
+
- "Replace the line with this new line." (Brittle, just repeats the other parameters)
|
|
642
|
+
`,
|
|
643
|
+
type: 'string',
|
|
644
|
+
},
|
|
343
645
|
old_string: {
|
|
344
|
-
description: 'The exact literal text to replace, preferably unescaped. For single replacements (default), include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely.
|
|
646
|
+
description: 'The exact literal text to replace, preferably unescaped. For single replacements (default), include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string is not the exact literal text (i.e. you escaped it) or does not match exactly, the tool will fail.',
|
|
345
647
|
type: 'string',
|
|
346
648
|
},
|
|
347
649
|
new_string: {
|
|
@@ -354,11 +656,10 @@ Expectation for required parameters:
|
|
|
354
656
|
minimum: 1,
|
|
355
657
|
},
|
|
356
658
|
},
|
|
357
|
-
required: ['file_path', 'old_string', 'new_string'],
|
|
659
|
+
required: ['file_path', 'instruction', 'old_string', 'new_string'],
|
|
358
660
|
type: 'object',
|
|
359
|
-
}, true, // isOutputMarkdown
|
|
360
|
-
false
|
|
361
|
-
messageBus);
|
|
661
|
+
}, messageBus, true, // isOutputMarkdown
|
|
662
|
+
false);
|
|
362
663
|
this.config = config;
|
|
363
664
|
}
|
|
364
665
|
/**
|
|
@@ -370,26 +671,34 @@ Expectation for required parameters:
|
|
|
370
671
|
if (!params.file_path) {
|
|
371
672
|
return "The 'file_path' parameter must be non-empty.";
|
|
372
673
|
}
|
|
373
|
-
|
|
674
|
+
let filePath = params.file_path;
|
|
675
|
+
if (!path.isAbsolute(filePath)) {
|
|
676
|
+
// Attempt to auto-correct to an absolute path
|
|
677
|
+
const result = correctPath(filePath, this.config);
|
|
678
|
+
if (!result.success) {
|
|
679
|
+
return result.error;
|
|
680
|
+
}
|
|
681
|
+
filePath = result.correctedPath;
|
|
682
|
+
}
|
|
683
|
+
params.file_path = filePath;
|
|
374
684
|
const workspaceContext = this.config.getWorkspaceContext();
|
|
375
|
-
if (!workspaceContext.isPathWithinWorkspace(
|
|
685
|
+
if (!workspaceContext.isPathWithinWorkspace(params.file_path)) {
|
|
376
686
|
const directories = workspaceContext.getDirectories();
|
|
377
687
|
return `File path must be within one of the workspace directories: ${directories.join(', ')}`;
|
|
378
688
|
}
|
|
379
689
|
return null;
|
|
380
690
|
}
|
|
381
|
-
createInvocation(params, messageBus
|
|
382
|
-
return new EditToolInvocation(this.config, params, messageBus
|
|
691
|
+
createInvocation(params, messageBus) {
|
|
692
|
+
return new EditToolInvocation(this.config, params, messageBus, this.name, this.displayName);
|
|
383
693
|
}
|
|
384
694
|
getModifyContext(_) {
|
|
385
|
-
const resolvePath = (filePath) => path.resolve(this.config.getTargetDir(), filePath);
|
|
386
695
|
return {
|
|
387
696
|
getFilePath: (params) => params.file_path,
|
|
388
697
|
getCurrentContent: async (params) => {
|
|
389
698
|
try {
|
|
390
699
|
return await this.config
|
|
391
700
|
.getFileSystemService()
|
|
392
|
-
.readTextFile(
|
|
701
|
+
.readTextFile(params.file_path);
|
|
393
702
|
}
|
|
394
703
|
catch (err) {
|
|
395
704
|
if (!isNodeError(err) || err.code !== 'ENOENT')
|
|
@@ -401,7 +710,7 @@ Expectation for required parameters:
|
|
|
401
710
|
try {
|
|
402
711
|
const currentContent = await this.config
|
|
403
712
|
.getFileSystemService()
|
|
404
|
-
.readTextFile(
|
|
713
|
+
.readTextFile(params.file_path);
|
|
405
714
|
return applyReplacement(currentContent, params.old_string, params.new_string, params.old_string === '' && currentContent === '');
|
|
406
715
|
}
|
|
407
716
|
catch (err) {
|
|
@@ -410,13 +719,16 @@ Expectation for required parameters:
|
|
|
410
719
|
return '';
|
|
411
720
|
}
|
|
412
721
|
},
|
|
413
|
-
createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) =>
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
722
|
+
createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) => {
|
|
723
|
+
const content = originalParams.new_string;
|
|
724
|
+
return {
|
|
725
|
+
...originalParams,
|
|
726
|
+
ai_proposed_content: content,
|
|
727
|
+
old_string: oldContent,
|
|
728
|
+
new_string: modifiedProposedContent,
|
|
729
|
+
modified_by_user: true,
|
|
730
|
+
};
|
|
731
|
+
},
|
|
420
732
|
};
|
|
421
733
|
}
|
|
422
734
|
}
|