@machina.ai/cell-cli-core 1.20.2-rc1 → 1.25.0-rc1
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/AFTER_MERGE_PROMPT.md +26 -0
- package/dist/docs/CHANGES.md +124 -0
- package/dist/docs/api-proxy.md +27 -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/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/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 +612 -0
- package/dist/docs/changelogs/latest.md +153 -0
- package/dist/docs/changelogs/preview.md +131 -0
- package/dist/docs/changelogs/releases.md +1162 -0
- package/dist/docs/cli/authentication.md +3 -0
- package/dist/docs/cli/checkpointing.md +94 -0
- package/dist/docs/cli/commands.md +357 -0
- package/dist/docs/cli/custom-commands.md +315 -0
- package/dist/docs/cli/enterprise.md +564 -0
- package/dist/docs/cli/gemini-ignore.md +71 -0
- package/dist/docs/cli/gemini-md.md +109 -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 +136 -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 +148 -0
- package/dist/docs/cli/skills.md +188 -0
- package/dist/docs/cli/system-prompt.md +94 -0
- package/dist/docs/cli/telemetry.md +813 -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 +246 -0
- package/dist/docs/core/policy-engine.md +268 -0
- package/dist/docs/core/tools-api.md +131 -0
- package/dist/docs/examples/proxy-script.md +83 -0
- package/dist/docs/extensions/extension-releasing.md +183 -0
- package/dist/docs/extensions/getting-started-extensions.md +244 -0
- package/dist/docs/extensions/index.md +343 -0
- package/dist/docs/faq.md +153 -0
- package/dist/docs/get-started/authentication.md +321 -0
- package/dist/docs/get-started/configuration-v1.md +890 -0
- package/dist/docs/get-started/configuration.md +1643 -0
- package/dist/docs/get-started/examples.md +218 -0
- package/dist/docs/get-started/gemini-3.md +101 -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 +723 -0
- package/dist/docs/hooks/reference.md +178 -0
- package/dist/docs/hooks/writing-hooks.md +1044 -0
- package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
- package/dist/docs/ide-integration/index.md +201 -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/mcp_integration.md +160 -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 +1045 -0
- package/dist/docs/tools/memory.md +54 -0
- package/dist/docs/tools/shell.md +260 -0
- package/dist/docs/tools/todos.md +56 -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 +162 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +7 -4
- package/dist/src/agents/a2a-client-manager.d.ts +82 -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.js +281 -0
- package/dist/src/agents/a2a-client-manager.test.js.map +1 -0
- package/dist/src/agents/a2aUtils.d.ts +29 -0
- package/dist/src/agents/a2aUtils.js +113 -0
- package/dist/src/agents/a2aUtils.js.map +1 -0
- package/dist/src/agents/a2aUtils.test.js +147 -0
- package/dist/src/agents/a2aUtils.test.js.map +1 -0
- package/dist/src/agents/agentLoader.d.ts +68 -0
- package/dist/src/agents/agentLoader.js +255 -0
- package/dist/src/agents/agentLoader.js.map +1 -0
- package/dist/src/agents/agentLoader.test.js +307 -0
- package/dist/src/agents/agentLoader.test.js.map +1 -0
- package/dist/src/agents/cli-help-agent.d.ts +24 -0
- package/dist/src/agents/cli-help-agent.js +85 -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 +65 -0
- package/dist/src/agents/cli-help-agent.test.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +2 -2
- package/dist/src/agents/codebase-investigator.js +14 -8
- 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 +122 -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 +213 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -0
- package/dist/src/agents/{executor.d.ts → local-executor.d.ts} +5 -11
- package/dist/src/agents/{executor.js → local-executor.js} +124 -63
- 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/{executor.test.js → local-executor.test.js} +136 -58
- package/dist/src/agents/local-executor.test.js.map +1 -0
- package/dist/src/agents/{invocation.d.ts → local-invocation.d.ts} +6 -7
- package/dist/src/agents/{invocation.js → local-invocation.js} +9 -10
- 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/{invocation.test.js → local-invocation.test.js} +29 -20
- package/dist/src/agents/local-invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +37 -1
- package/dist/src/agents/registry.js +240 -27
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +465 -30
- 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 +126 -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 +33 -19
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/types.d.ts +21 -15
- package/dist/src/agents/types.js.map +1 -1
- 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/fallbackIntegration.test.d.ts +6 -0
- package/dist/src/availability/fallbackIntegration.test.js +58 -0
- package/dist/src/availability/fallbackIntegration.test.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.d.ts +3 -1
- package/dist/src/availability/modelAvailabilityService.js +3 -0
- package/dist/src/availability/modelAvailabilityService.js.map +1 -1
- package/dist/src/availability/modelPolicy.d.ts +8 -1
- package/dist/src/availability/policyCatalog.d.ts +1 -0
- package/dist/src/availability/policyCatalog.js +6 -7
- package/dist/src/availability/policyCatalog.js.map +1 -1
- package/dist/src/availability/policyCatalog.test.js +2 -2
- package/dist/src/availability/policyCatalog.test.js.map +1 -1
- package/dist/src/availability/policyHelpers.d.ts +34 -3
- package/dist/src/availability/policyHelpers.js +104 -13
- package/dist/src/availability/policyHelpers.js.map +1 -1
- package/dist/src/availability/policyHelpers.test.js +143 -13
- package/dist/src/availability/policyHelpers.test.js.map +1 -1
- 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 +2 -1
- 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.d.ts +1 -1
- package/dist/src/code_assist/experiments/experiments.js +21 -0
- package/dist/src/code_assist/experiments/experiments.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 +110 -0
- package/dist/src/code_assist/experiments/experiments_local.test.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.js +3 -4
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +2 -0
- package/dist/src/code_assist/oauth2.js +70 -14
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +224 -22
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +9 -1
- package/dist/src/code_assist/server.js +74 -11
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +199 -27
- 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 +157 -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 +301 -0
- package/dist/src/code_assist/telemetry.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +77 -1
- package/dist/src/code_assist/types.js +28 -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/memory.d.ts +11 -0
- package/dist/src/commands/memory.js +80 -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.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 +145 -25
- package/dist/src/config/config.js +370 -132
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +416 -50
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/defaultModelConfigs.js +21 -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 +36 -15
- package/dist/src/config/models.js +89 -28
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +107 -77
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +5 -0
- package/dist/src/config/storage.js +17 -2
- 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.js +3 -1
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +4 -0
- package/dist/src/core/baseLlmClient.d.ts +3 -1
- package/dist/src/core/baseLlmClient.js +60 -22
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +177 -7
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +7 -1
- package/dist/src/core/client.js +261 -96
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +397 -67
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/clientHookTriggers.js +2 -2
- package/dist/src/core/clientHookTriggers.js.map +1 -1
- package/dist/src/core/contentGenerator.js +6 -4
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +24 -23
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +9 -5
- package/dist/src/core/coreToolHookTriggers.js +119 -21
- package/dist/src/core/coreToolHookTriggers.js.map +1 -1
- 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 +7 -93
- package/dist/src/core/coreToolScheduler.js +139 -333
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +304 -348
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +26 -1
- package/dist/src/core/geminiChat.js +144 -80
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +334 -253
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.d.ts +8 -4
- package/dist/src/core/geminiChatHookTriggers.js +34 -12
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.test.d.ts +6 -0
- package/dist/src/core/geminiChatHookTriggers.test.js +153 -0
- package/dist/src/core/geminiChatHookTriggers.test.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 +19 -2
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.js +30 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +7 -8
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.js +48 -22
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +66 -11
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/tokenLimits.js +6 -12
- 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 +21 -21
- package/dist/src/core/turn.js +32 -22
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +79 -5
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +55 -120
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +115 -288
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +3 -3
- package/dist/src/generated/git-commit.js +3 -3
- package/dist/src/hooks/hookAggregator.js +7 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.d.ts +9 -5
- package/dist/src/hooks/hookEventHandler.js +120 -16
- package/dist/src/hooks/hookEventHandler.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.test.js +231 -9
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
- 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 +68 -18
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookRunner.test.js +173 -36
- package/dist/src/hooks/hookRunner.test.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +10 -6
- package/dist/src/hooks/hookSystem.js +36 -16
- package/dist/src/hooks/hookSystem.js.map +1 -1
- package/dist/src/hooks/hookSystem.test.js +123 -18
- package/dist/src/hooks/hookSystem.test.js.map +1 -1
- package/dist/src/hooks/hookTranslator.js +2 -1
- package/dist/src/hooks/hookTranslator.js.map +1 -1
- package/dist/src/hooks/index.d.ts +2 -1
- package/dist/src/hooks/index.js +1 -0
- package/dist/src/hooks/index.js.map +1 -1
- 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 +42 -11
- package/dist/src/hooks/types.js +31 -42
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/hooks/types.test.js +9 -52
- package/dist/src/hooks/types.test.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +4 -0
- package/dist/src/ide/detect-ide.js +7 -2
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +42 -1
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.js +6 -1
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-installer.js +2 -2
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +12 -3
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/index.d.ts +23 -1
- package/dist/src/index.js +25 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +7 -3
- 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/token-storage/file-token-storage.js +2 -2
- package/dist/src/mcp/token-storage/file-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 +24 -2
- 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/write.toml +5 -0
- package/dist/src/policy/policies/yolo.toml +1 -0
- package/dist/src/policy/policy-engine.d.ts +14 -1
- package/dist/src/policy/policy-engine.js +165 -7
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +315 -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 +438 -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 +43 -60
- package/dist/src/policy/toml-loader.js.map +1 -1
- package/dist/src/policy/toml-loader.test.js +41 -7
- package/dist/src/policy/toml-loader.test.js.map +1 -1
- package/dist/src/policy/types.d.ts +25 -0
- package/dist/src/policy/utils.d.ts +21 -0
- package/dist/src/policy/utils.js +45 -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 +92 -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/routingStrategy.d.ts +2 -0
- 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 +18 -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.d.ts +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +21 -13
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +76 -39
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +5 -4
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.test.js +14 -0
- package/dist/src/routing/strategies/overrideStrategy.test.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/tool-modifier.d.ts +23 -0
- package/dist/src/scheduler/tool-modifier.js +50 -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 +159 -0
- package/dist/src/scheduler/tool-modifier.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.js +8 -1
- package/dist/src/services/chatCompressionService.js.map +1 -1
- package/dist/src/services/chatCompressionService.test.js +3 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +21 -1
- package/dist/src/services/chatRecordingService.js +57 -2
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +43 -0
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +5 -11
- package/dist/src/services/contextManager.js +20 -17
- package/dist/src/services/contextManager.js.map +1 -1
- package/dist/src/services/contextManager.test.js +40 -41
- package/dist/src/services/contextManager.test.js.map +1 -1
- package/dist/src/services/environmentSanitization.d.ts +15 -0
- package/dist/src/services/environmentSanitization.js +142 -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 +15 -1
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +56 -2
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.js +4 -3
- 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 +3 -3
- package/dist/src/services/modelConfig.integration.test.js.map +1 -1
- package/dist/src/services/modelConfigService.d.ts +41 -4
- package/dist/src/services/modelConfigService.js +135 -75
- package/dist/src/services/modelConfigService.js.map +1 -1
- package/dist/src/services/modelConfigService.test.js +226 -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 +2 -0
- package/dist/src/services/shellExecutionService.js +34 -72
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +114 -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 +16 -0
- package/dist/src/skills/skillLoader.d.ts +31 -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 +6 -0
- package/dist/src/skills/skillLoader.test.js +75 -0
- package/dist/src/skills/skillLoader.test.js.map +1 -0
- package/dist/src/skills/skillManager.d.ts +69 -0
- package/dist/src/skills/skillManager.js +127 -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 +210 -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 +19 -9
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +261 -164
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +223 -27
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +12 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +26 -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 +1 -1
- package/dist/src/telemetry/index.js +1 -1
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +4 -3
- package/dist/src/telemetry/loggers.js +351 -340
- 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 +71 -15
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- 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/startupProfiler.js +26 -3
- package/dist/src/telemetry/startupProfiler.js.map +1 -1
- package/dist/src/telemetry/startupProfiler.test.js +49 -7
- package/dist/src/telemetry/startupProfiler.test.js.map +1 -1
- 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.map +1 -1
- package/dist/src/telemetry/types.d.ts +37 -12
- package/dist/src/telemetry/types.js +61 -20
- 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 +1 -0
- package/dist/src/test-utils/mock-message-bus.js +29 -0
- package/dist/src/test-utils/mock-message-bus.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +5 -3
- package/dist/src/test-utils/mock-tool.js +11 -10
- 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 +133 -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 +113 -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 +143 -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 +460 -136
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +292 -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 +122 -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 +2 -1
- package/dist/src/tools/mcp-client-manager.js +32 -9
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +41 -10
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +43 -6
- package/dist/src/tools/mcp-client.js +443 -176
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +664 -39
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +20 -5
- package/dist/src/tools/mcp-tool.js +21 -8
- 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 +35 -49
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +36 -59
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +6 -1
- package/dist/src/tools/tool-error.js +6 -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 +27 -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 +21 -8
- 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 +14 -6
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +49 -7
- 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/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/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/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.d.ts +3 -3
- package/dist/src/utils/editCorrector.js +27 -10
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +27 -23
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +10 -1
- package/dist/src/utils/editor.js +48 -19
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +27 -4
- package/dist/src/utils/editor.test.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 +71 -19
- package/dist/src/utils/events.js +35 -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/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/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 +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/gitIgnoreParser.js +9 -10
- package/dist/src/utils/gitIgnoreParser.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/installationManager.test.js +11 -3
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.js +3 -4
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +12 -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/partUtils.js +1 -1
- package/dist/src/utils/partUtils.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/paths.d.ts +10 -0
- package/dist/src/utils/paths.js +20 -1
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/retry.d.ts +12 -0
- package/dist/src/utils/retry.js +70 -17
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +181 -21
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +16 -47
- package/dist/src/utils/shell-utils.js +98 -194
- 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/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.js +20 -5
- package/dist/src/utils/tokenCalculation.js.map +1 -1
- package/dist/src/utils/tokenCalculation.test.js +11 -2
- package/dist/src/utils/tokenCalculation.test.js.map +1 -1
- 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/userAccountManager.test.js +5 -5
- package/dist/src/utils/userAccountManager.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/src/utils/workspaceContext.test.js +1 -1
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -6
- package/dist/src/agents/executor.js.map +0 -1
- package/dist/src/agents/executor.test.js.map +0 -1
- package/dist/src/agents/invocation.js.map +0 -1
- package/dist/src/agents/invocation.test.js.map +0 -1
- package/dist/src/tools/smart-edit.d.ts +0 -78
- package/dist/src/tools/smart-edit.js +0 -717
- package/dist/src/tools/smart-edit.js.map +0 -1
- package/dist/src/tools/smart-edit.test.js +0 -592
- package/dist/src/tools/smart-edit.test.js.map +0 -1
- /package/dist/src/agents/{executor.test.d.ts → a2a-client-manager.test.d.ts} +0 -0
- /package/dist/src/agents/{invocation.test.d.ts → a2aUtils.test.d.ts} +0 -0
- /package/dist/src/{tools/smart-edit.test.d.ts → agents/agentLoader.test.d.ts} +0 -0
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,103 @@ 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
|
+
};
|
|
84
367
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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,
|
|
91
381
|
};
|
|
92
382
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
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
|
-
|
|
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
|
-
}
|
|
407
|
+
},
|
|
408
|
+
originalLineEnding,
|
|
409
|
+
};
|
|
129
410
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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,
|
|
136
425
|
};
|
|
137
426
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
427
|
+
if (this.config.getDisableLLMCorrection()) {
|
|
428
|
+
return {
|
|
429
|
+
currentContent,
|
|
430
|
+
newContent: currentContent,
|
|
431
|
+
occurrences: replacementResult.occurrences,
|
|
432
|
+
isNewFile: false,
|
|
433
|
+
error: initialError,
|
|
434
|
+
originalLineEnding,
|
|
146
435
|
};
|
|
147
436
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
newContent,
|
|
151
|
-
occurrences,
|
|
152
|
-
error,
|
|
153
|
-
isNewFile,
|
|
154
|
-
};
|
|
437
|
+
// If there was an error, try to self-correct.
|
|
438
|
+
return this.attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding);
|
|
155
439
|
}
|
|
156
440
|
/**
|
|
157
441
|
* Handles the confirmation prompt for the Edit tool in the CLI.
|
|
@@ -177,24 +461,29 @@ class EditToolInvocation extends BaseToolInvocation {
|
|
|
177
461
|
debugLogger.log(`Error: ${editData.error.display}`);
|
|
178
462
|
return false;
|
|
179
463
|
}
|
|
180
|
-
const fileName = path.basename(this.
|
|
464
|
+
const fileName = path.basename(this.params.file_path);
|
|
181
465
|
const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
|
|
182
466
|
const ideClient = await IdeClient.getInstance();
|
|
183
467
|
const ideConfirmation = this.config.getIdeMode() && ideClient.isDiffingEnabled()
|
|
184
|
-
? ideClient.openDiff(this.
|
|
468
|
+
? ideClient.openDiff(this.params.file_path, editData.newContent)
|
|
185
469
|
: undefined;
|
|
186
470
|
const confirmationDetails = {
|
|
187
471
|
type: 'edit',
|
|
188
472
|
title: `Confirm Edit: ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`,
|
|
189
473
|
fileName,
|
|
190
|
-
filePath: this.
|
|
474
|
+
filePath: this.params.file_path,
|
|
191
475
|
fileDiff,
|
|
192
476
|
originalContent: editData.currentContent,
|
|
193
477
|
newContent: editData.newContent,
|
|
194
478
|
onConfirm: async (outcome) => {
|
|
195
479
|
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
480
|
+
// No need to publish a policy update as the default policy for
|
|
481
|
+
// AUTO_EDIT already reflects always approving edit.
|
|
196
482
|
this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
|
|
197
483
|
}
|
|
484
|
+
else {
|
|
485
|
+
await this.publishPolicyUpdate(outcome);
|
|
486
|
+
}
|
|
198
487
|
if (ideConfirmation) {
|
|
199
488
|
const result = await ideConfirmation;
|
|
200
489
|
if (result.status === 'accepted' && result.content) {
|
|
@@ -258,34 +547,40 @@ class EditToolInvocation extends BaseToolInvocation {
|
|
|
258
547
|
};
|
|
259
548
|
}
|
|
260
549
|
try {
|
|
261
|
-
this.ensureParentDirectoriesExist(this.
|
|
550
|
+
this.ensureParentDirectoriesExist(this.params.file_path);
|
|
551
|
+
let finalContent = editData.newContent;
|
|
552
|
+
// Restore original line endings if they were CRLF
|
|
553
|
+
if (!editData.isNewFile && editData.originalLineEnding === '\r\n') {
|
|
554
|
+
finalContent = finalContent.replace(/\n/g, '\r\n');
|
|
555
|
+
}
|
|
262
556
|
await this.config
|
|
263
557
|
.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
|
-
|
|
558
|
+
.writeTextFile(this.params.file_path, finalContent);
|
|
559
|
+
let displayResult;
|
|
560
|
+
if (editData.isNewFile) {
|
|
561
|
+
displayResult = `Created ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`;
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
// Generate diff for display, even though core logic doesn't technically need it
|
|
565
|
+
// The CLI wrapper will use this part of the ToolResult
|
|
566
|
+
const fileName = path.basename(this.params.file_path);
|
|
567
|
+
const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', // Should not be null here if not isNewFile
|
|
568
|
+
editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
|
|
569
|
+
const diffStat = getDiffStat(fileName, editData.currentContent ?? '', editData.newContent, this.params.new_string);
|
|
570
|
+
displayResult = {
|
|
571
|
+
fileDiff,
|
|
572
|
+
fileName,
|
|
573
|
+
filePath: this.params.file_path,
|
|
574
|
+
originalContent: editData.currentContent,
|
|
575
|
+
newContent: editData.newContent,
|
|
576
|
+
diffStat,
|
|
577
|
+
isNewFile: editData.isNewFile,
|
|
578
|
+
};
|
|
579
|
+
}
|
|
285
580
|
const llmSuccessMessageParts = [
|
|
286
581
|
editData.isNewFile
|
|
287
|
-
? `Created new file: ${this.
|
|
288
|
-
: `Successfully modified file: ${this.
|
|
582
|
+
? `Created new file: ${this.params.file_path} with provided content.`
|
|
583
|
+
: `Successfully modified file: ${this.params.file_path} (${editData.occurrences} replacements).`,
|
|
289
584
|
];
|
|
290
585
|
if (this.params.modified_by_user) {
|
|
291
586
|
llmSuccessMessageParts.push(`User modified the \`new_string\` content to be: ${this.params.new_string}.`);
|
|
@@ -325,23 +620,42 @@ export class EditTool extends BaseDeclarativeTool {
|
|
|
325
620
|
static Name = EDIT_TOOL_NAME;
|
|
326
621
|
constructor(config, messageBus) {
|
|
327
622
|
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
|
-
|
|
623
|
+
|
|
329
624
|
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
|
-
|
|
625
|
+
|
|
626
|
+
Expectation for required parameters:
|
|
627
|
+
1. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).
|
|
628
|
+
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.
|
|
629
|
+
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.
|
|
630
|
+
4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
|
|
631
|
+
**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.
|
|
632
|
+
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.
|
|
633
|
+
**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
634
|
properties: {
|
|
339
635
|
file_path: {
|
|
340
636
|
description: 'The path to the file to modify.',
|
|
341
637
|
type: 'string',
|
|
342
638
|
},
|
|
639
|
+
instruction: {
|
|
640
|
+
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.
|
|
641
|
+
|
|
642
|
+
A good instruction should concisely answer:
|
|
643
|
+
1. WHY is the change needed? (e.g., "To fix a bug where users can be null...")
|
|
644
|
+
2. WHERE should the change happen? (e.g., "...in the 'renderUserProfile' function...")
|
|
645
|
+
3. WHAT is the high-level change? (e.g., "...add a null check for the 'user' object...")
|
|
646
|
+
4. WHAT is the desired outcome? (e.g., "...so that it displays a loading spinner instead of crashing.")
|
|
647
|
+
|
|
648
|
+
**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."
|
|
649
|
+
|
|
650
|
+
**BAD Examples:**
|
|
651
|
+
- "Change the text." (Too vague)
|
|
652
|
+
- "Fix the bug." (Doesn't explain the bug or the fix)
|
|
653
|
+
- "Replace the line with this new line." (Brittle, just repeats the other parameters)
|
|
654
|
+
`,
|
|
655
|
+
type: 'string',
|
|
656
|
+
},
|
|
343
657
|
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.
|
|
658
|
+
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
659
|
type: 'string',
|
|
346
660
|
},
|
|
347
661
|
new_string: {
|
|
@@ -354,11 +668,10 @@ Expectation for required parameters:
|
|
|
354
668
|
minimum: 1,
|
|
355
669
|
},
|
|
356
670
|
},
|
|
357
|
-
required: ['file_path', 'old_string', 'new_string'],
|
|
671
|
+
required: ['file_path', 'instruction', 'old_string', 'new_string'],
|
|
358
672
|
type: 'object',
|
|
359
|
-
}, true, // isOutputMarkdown
|
|
360
|
-
false
|
|
361
|
-
messageBus);
|
|
673
|
+
}, messageBus, true, // isOutputMarkdown
|
|
674
|
+
false);
|
|
362
675
|
this.config = config;
|
|
363
676
|
}
|
|
364
677
|
/**
|
|
@@ -370,26 +683,34 @@ Expectation for required parameters:
|
|
|
370
683
|
if (!params.file_path) {
|
|
371
684
|
return "The 'file_path' parameter must be non-empty.";
|
|
372
685
|
}
|
|
373
|
-
|
|
686
|
+
let filePath = params.file_path;
|
|
687
|
+
if (!path.isAbsolute(filePath)) {
|
|
688
|
+
// Attempt to auto-correct to an absolute path
|
|
689
|
+
const result = correctPath(filePath, this.config);
|
|
690
|
+
if (!result.success) {
|
|
691
|
+
return result.error;
|
|
692
|
+
}
|
|
693
|
+
filePath = result.correctedPath;
|
|
694
|
+
}
|
|
695
|
+
params.file_path = filePath;
|
|
374
696
|
const workspaceContext = this.config.getWorkspaceContext();
|
|
375
|
-
if (!workspaceContext.isPathWithinWorkspace(
|
|
697
|
+
if (!workspaceContext.isPathWithinWorkspace(params.file_path)) {
|
|
376
698
|
const directories = workspaceContext.getDirectories();
|
|
377
699
|
return `File path must be within one of the workspace directories: ${directories.join(', ')}`;
|
|
378
700
|
}
|
|
379
701
|
return null;
|
|
380
702
|
}
|
|
381
|
-
createInvocation(params, messageBus
|
|
382
|
-
return new EditToolInvocation(this.config, params, messageBus
|
|
703
|
+
createInvocation(params, messageBus) {
|
|
704
|
+
return new EditToolInvocation(this.config, params, messageBus, this.name, this.displayName);
|
|
383
705
|
}
|
|
384
706
|
getModifyContext(_) {
|
|
385
|
-
const resolvePath = (filePath) => path.resolve(this.config.getTargetDir(), filePath);
|
|
386
707
|
return {
|
|
387
708
|
getFilePath: (params) => params.file_path,
|
|
388
709
|
getCurrentContent: async (params) => {
|
|
389
710
|
try {
|
|
390
711
|
return await this.config
|
|
391
712
|
.getFileSystemService()
|
|
392
|
-
.readTextFile(
|
|
713
|
+
.readTextFile(params.file_path);
|
|
393
714
|
}
|
|
394
715
|
catch (err) {
|
|
395
716
|
if (!isNodeError(err) || err.code !== 'ENOENT')
|
|
@@ -401,7 +722,7 @@ Expectation for required parameters:
|
|
|
401
722
|
try {
|
|
402
723
|
const currentContent = await this.config
|
|
403
724
|
.getFileSystemService()
|
|
404
|
-
.readTextFile(
|
|
725
|
+
.readTextFile(params.file_path);
|
|
405
726
|
return applyReplacement(currentContent, params.old_string, params.new_string, params.old_string === '' && currentContent === '');
|
|
406
727
|
}
|
|
407
728
|
catch (err) {
|
|
@@ -410,13 +731,16 @@ Expectation for required parameters:
|
|
|
410
731
|
return '';
|
|
411
732
|
}
|
|
412
733
|
},
|
|
413
|
-
createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) =>
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
734
|
+
createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) => {
|
|
735
|
+
const content = originalParams.new_string;
|
|
736
|
+
return {
|
|
737
|
+
...originalParams,
|
|
738
|
+
ai_proposed_content: content,
|
|
739
|
+
old_string: oldContent,
|
|
740
|
+
new_string: modifiedProposedContent,
|
|
741
|
+
modified_by_user: true,
|
|
742
|
+
};
|
|
743
|
+
},
|
|
420
744
|
};
|
|
421
745
|
}
|
|
422
746
|
}
|