@burtson-labs/stealth-core-runtime 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +46 -0
- package/dist/banditEngineProvider.d.ts +48 -0
- package/dist/banditEngineProvider.d.ts.map +1 -0
- package/dist/banditEngineProvider.js +1021 -0
- package/dist/banditEngineProvider.js.map +1 -0
- package/dist/embeddingCache.d.ts +23 -0
- package/dist/embeddingCache.d.ts.map +1 -0
- package/dist/embeddingCache.js +196 -0
- package/dist/embeddingCache.js.map +1 -0
- package/dist/embeddingClient.d.ts +35 -0
- package/dist/embeddingClient.d.ts.map +1 -0
- package/dist/embeddingClient.js +162 -0
- package/dist/embeddingClient.js.map +1 -0
- package/dist/executorAgent.d.ts +7 -0
- package/dist/executorAgent.d.ts.map +1 -0
- package/dist/executorAgent.js +95 -0
- package/dist/executorAgent.js.map +1 -0
- package/dist/extensionSystemPrompt.d.ts +80 -0
- package/dist/extensionSystemPrompt.d.ts.map +1 -0
- package/dist/extensionSystemPrompt.js +208 -0
- package/dist/extensionSystemPrompt.js.map +1 -0
- package/dist/gatewaySearchAdapter.d.ts +69 -0
- package/dist/gatewaySearchAdapter.d.ts.map +1 -0
- package/dist/gatewaySearchAdapter.js +131 -0
- package/dist/gatewaySearchAdapter.js.map +1 -0
- package/dist/goalInference.d.ts +26 -0
- package/dist/goalInference.d.ts.map +1 -0
- package/dist/goalInference.js +605 -0
- package/dist/goalInference.js.map +1 -0
- package/dist/hostTypes.d.ts +86 -0
- package/dist/hostTypes.d.ts.map +1 -0
- package/dist/hostTypes.js +3 -0
- package/dist/hostTypes.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -0
- package/dist/internalTypes.d.ts +16 -0
- package/dist/internalTypes.d.ts.map +1 -0
- package/dist/internalTypes.js +20 -0
- package/dist/internalTypes.js.map +1 -0
- package/dist/ollamaEmbeddingClient.d.ts +45 -0
- package/dist/ollamaEmbeddingClient.d.ts.map +1 -0
- package/dist/ollamaEmbeddingClient.js +143 -0
- package/dist/ollamaEmbeddingClient.js.map +1 -0
- package/dist/pdfjsShim.d.ts +2 -0
- package/dist/pdfjsShim.d.ts.map +1 -0
- package/dist/pdfjsShim.js +80 -0
- package/dist/pdfjsShim.js.map +1 -0
- package/dist/runtime/actionRuntime.d.ts +13 -0
- package/dist/runtime/actionRuntime.d.ts.map +1 -0
- package/dist/runtime/actionRuntime.js +15 -0
- package/dist/runtime/actionRuntime.js.map +1 -0
- package/dist/runtime/actionServices.d.ts +72 -0
- package/dist/runtime/actionServices.d.ts.map +1 -0
- package/dist/runtime/actionServices.js +53 -0
- package/dist/runtime/actionServices.js.map +1 -0
- package/dist/runtime/adapters/connectorBus.d.ts +9 -0
- package/dist/runtime/adapters/connectorBus.d.ts.map +1 -0
- package/dist/runtime/adapters/connectorBus.js +20 -0
- package/dist/runtime/adapters/connectorBus.js.map +1 -0
- package/dist/runtime/adapters/fsAdapter.d.ts +6 -0
- package/dist/runtime/adapters/fsAdapter.d.ts.map +1 -0
- package/dist/runtime/adapters/fsAdapter.js +144 -0
- package/dist/runtime/adapters/fsAdapter.js.map +1 -0
- package/dist/runtime/adapters/llmAdapter.d.ts +4 -0
- package/dist/runtime/adapters/llmAdapter.d.ts.map +1 -0
- package/dist/runtime/adapters/llmAdapter.js +12 -0
- package/dist/runtime/adapters/llmAdapter.js.map +1 -0
- package/dist/runtime/adapters/shellAdapter.d.ts +6 -0
- package/dist/runtime/adapters/shellAdapter.d.ts.map +1 -0
- package/dist/runtime/adapters/shellAdapter.js +118 -0
- package/dist/runtime/adapters/shellAdapter.js.map +1 -0
- package/dist/runtime/additionalWrites.d.ts +22 -0
- package/dist/runtime/additionalWrites.d.ts.map +1 -0
- package/dist/runtime/additionalWrites.js +148 -0
- package/dist/runtime/additionalWrites.js.map +1 -0
- package/dist/runtime/artifactManager.d.ts +32 -0
- package/dist/runtime/artifactManager.d.ts.map +1 -0
- package/dist/runtime/artifactManager.js +154 -0
- package/dist/runtime/artifactManager.js.map +1 -0
- package/dist/runtime/autoHealer.d.ts +27 -0
- package/dist/runtime/autoHealer.d.ts.map +1 -0
- package/dist/runtime/autoHealer.js +583 -0
- package/dist/runtime/autoHealer.js.map +1 -0
- package/dist/runtime/changeTracker.d.ts +20 -0
- package/dist/runtime/changeTracker.d.ts.map +1 -0
- package/dist/runtime/changeTracker.js +147 -0
- package/dist/runtime/changeTracker.js.map +1 -0
- package/dist/runtime/contextBuilder.d.ts +85 -0
- package/dist/runtime/contextBuilder.d.ts.map +1 -0
- package/dist/runtime/contextBuilder.js +159 -0
- package/dist/runtime/contextBuilder.js.map +1 -0
- package/dist/runtime/coreRuntime.d.ts +7 -0
- package/dist/runtime/coreRuntime.d.ts.map +1 -0
- package/dist/runtime/coreRuntime.js +173 -0
- package/dist/runtime/coreRuntime.js.map +1 -0
- package/dist/runtime/createStealthRuntime.d.ts +4 -0
- package/dist/runtime/createStealthRuntime.d.ts.map +1 -0
- package/dist/runtime/createStealthRuntime.js +514 -0
- package/dist/runtime/createStealthRuntime.js.map +1 -0
- package/dist/runtime/diagnostics.d.ts +53 -0
- package/dist/runtime/diagnostics.d.ts.map +1 -0
- package/dist/runtime/diagnostics.js +396 -0
- package/dist/runtime/diagnostics.js.map +1 -0
- package/dist/runtime/diagnosticsServices.d.ts +51 -0
- package/dist/runtime/diagnosticsServices.d.ts.map +1 -0
- package/dist/runtime/diagnosticsServices.js +46 -0
- package/dist/runtime/diagnosticsServices.js.map +1 -0
- package/dist/runtime/diffManager.d.ts +20 -0
- package/dist/runtime/diffManager.d.ts.map +1 -0
- package/dist/runtime/diffManager.js +172 -0
- package/dist/runtime/diffManager.js.map +1 -0
- package/dist/runtime/diffPresenter.d.ts +8 -0
- package/dist/runtime/diffPresenter.d.ts.map +1 -0
- package/dist/runtime/diffPresenter.js +57 -0
- package/dist/runtime/diffPresenter.js.map +1 -0
- package/dist/runtime/embeddingClientResolver.d.ts +14 -0
- package/dist/runtime/embeddingClientResolver.d.ts.map +1 -0
- package/dist/runtime/embeddingClientResolver.js +54 -0
- package/dist/runtime/embeddingClientResolver.js.map +1 -0
- package/dist/runtime/embeddingManager.d.ts +22 -0
- package/dist/runtime/embeddingManager.d.ts.map +1 -0
- package/dist/runtime/embeddingManager.js +224 -0
- package/dist/runtime/embeddingManager.js.map +1 -0
- package/dist/runtime/eventBus.d.ts +7 -0
- package/dist/runtime/eventBus.d.ts.map +1 -0
- package/dist/runtime/eventBus.js +28 -0
- package/dist/runtime/eventBus.js.map +1 -0
- package/dist/runtime/executorServices.d.ts +46 -0
- package/dist/runtime/executorServices.d.ts.map +1 -0
- package/dist/runtime/executorServices.js +47 -0
- package/dist/runtime/executorServices.js.map +1 -0
- package/dist/runtime/extractionService.d.ts +11 -0
- package/dist/runtime/extractionService.d.ts.map +1 -0
- package/dist/runtime/extractionService.js +282 -0
- package/dist/runtime/extractionService.js.map +1 -0
- package/dist/runtime/feedbackService.d.ts +12 -0
- package/dist/runtime/feedbackService.d.ts.map +1 -0
- package/dist/runtime/feedbackService.js +111 -0
- package/dist/runtime/feedbackService.js.map +1 -0
- package/dist/runtime/goalEngine.d.ts +10 -0
- package/dist/runtime/goalEngine.d.ts.map +1 -0
- package/dist/runtime/goalEngine.js +429 -0
- package/dist/runtime/goalEngine.js.map +1 -0
- package/dist/runtime/goalFlowServices.d.ts +49 -0
- package/dist/runtime/goalFlowServices.d.ts.map +1 -0
- package/dist/runtime/goalFlowServices.js +45 -0
- package/dist/runtime/goalFlowServices.js.map +1 -0
- package/dist/runtime/goalReplay.d.ts +33 -0
- package/dist/runtime/goalReplay.d.ts.map +1 -0
- package/dist/runtime/goalReplay.js +58 -0
- package/dist/runtime/goalReplay.js.map +1 -0
- package/dist/runtime/goalRunner.d.ts +35 -0
- package/dist/runtime/goalRunner.d.ts.map +1 -0
- package/dist/runtime/goalRunner.js +42 -0
- package/dist/runtime/goalRunner.js.map +1 -0
- package/dist/runtime/healingEngine.d.ts +72 -0
- package/dist/runtime/healingEngine.d.ts.map +1 -0
- package/dist/runtime/healingEngine.js +969 -0
- package/dist/runtime/healingEngine.js.map +1 -0
- package/dist/runtime/healingServices.d.ts +62 -0
- package/dist/runtime/healingServices.d.ts.map +1 -0
- package/dist/runtime/healingServices.js +45 -0
- package/dist/runtime/healingServices.js.map +1 -0
- package/dist/runtime/helpers.d.ts +22 -0
- package/dist/runtime/helpers.d.ts.map +1 -0
- package/dist/runtime/helpers.js +694 -0
- package/dist/runtime/helpers.js.map +1 -0
- package/dist/runtime/hosts/actionHost.d.ts +82 -0
- package/dist/runtime/hosts/actionHost.d.ts.map +1 -0
- package/dist/runtime/hosts/actionHost.js +61 -0
- package/dist/runtime/hosts/actionHost.js.map +1 -0
- package/dist/runtime/hosts/baseServices.d.ts +51 -0
- package/dist/runtime/hosts/baseServices.d.ts.map +1 -0
- package/dist/runtime/hosts/baseServices.js +73 -0
- package/dist/runtime/hosts/baseServices.js.map +1 -0
- package/dist/runtime/hosts/embeddingServices.d.ts +25 -0
- package/dist/runtime/hosts/embeddingServices.d.ts.map +1 -0
- package/dist/runtime/hosts/embeddingServices.js +34 -0
- package/dist/runtime/hosts/embeddingServices.js.map +1 -0
- package/dist/runtime/hosts/goalFlowHost.d.ts +34 -0
- package/dist/runtime/hosts/goalFlowHost.d.ts.map +1 -0
- package/dist/runtime/hosts/goalFlowHost.js +35 -0
- package/dist/runtime/hosts/goalFlowHost.js.map +1 -0
- package/dist/runtime/hosts/goalFlowRuntime.d.ts +41 -0
- package/dist/runtime/hosts/goalFlowRuntime.d.ts.map +1 -0
- package/dist/runtime/hosts/goalFlowRuntime.js +31 -0
- package/dist/runtime/hosts/goalFlowRuntime.js.map +1 -0
- package/dist/runtime/hosts/providerHost.d.ts +19 -0
- package/dist/runtime/hosts/providerHost.d.ts.map +1 -0
- package/dist/runtime/hosts/providerHost.js +18 -0
- package/dist/runtime/hosts/providerHost.js.map +1 -0
- package/dist/runtime/hosts/rewriteHost.d.ts +84 -0
- package/dist/runtime/hosts/rewriteHost.d.ts.map +1 -0
- package/dist/runtime/hosts/rewriteHost.js +64 -0
- package/dist/runtime/hosts/rewriteHost.js.map +1 -0
- package/dist/runtime/hosts/workspaceHost.d.ts +113 -0
- package/dist/runtime/hosts/workspaceHost.d.ts.map +1 -0
- package/dist/runtime/hosts/workspaceHost.js +76 -0
- package/dist/runtime/hosts/workspaceHost.js.map +1 -0
- package/dist/runtime/index.d.ts +78 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +95 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/insight.d.ts +16 -0
- package/dist/runtime/insight.d.ts.map +1 -0
- package/dist/runtime/insight.js +11 -0
- package/dist/runtime/insight.js.map +1 -0
- package/dist/runtime/internalActions.d.ts +16 -0
- package/dist/runtime/internalActions.d.ts.map +1 -0
- package/dist/runtime/internalActions.js +302 -0
- package/dist/runtime/internalActions.js.map +1 -0
- package/dist/runtime/modelBehavior.d.ts +69 -0
- package/dist/runtime/modelBehavior.d.ts.map +1 -0
- package/dist/runtime/modelBehavior.js +514 -0
- package/dist/runtime/modelBehavior.js.map +1 -0
- package/dist/runtime/modelCapabilities.d.ts +139 -0
- package/dist/runtime/modelCapabilities.d.ts.map +1 -0
- package/dist/runtime/modelCapabilities.js +458 -0
- package/dist/runtime/modelCapabilities.js.map +1 -0
- package/dist/runtime/modelsDevCatalog.d.ts +34 -0
- package/dist/runtime/modelsDevCatalog.d.ts.map +1 -0
- package/dist/runtime/modelsDevCatalog.js +263 -0
- package/dist/runtime/modelsDevCatalog.js.map +1 -0
- package/dist/runtime/pendingInference.d.ts +18 -0
- package/dist/runtime/pendingInference.d.ts.map +1 -0
- package/dist/runtime/pendingInference.js +121 -0
- package/dist/runtime/pendingInference.js.map +1 -0
- package/dist/runtime/persistence.d.ts +21 -0
- package/dist/runtime/persistence.d.ts.map +1 -0
- package/dist/runtime/persistence.js +73 -0
- package/dist/runtime/persistence.js.map +1 -0
- package/dist/runtime/planContext.d.ts +42 -0
- package/dist/runtime/planContext.d.ts.map +1 -0
- package/dist/runtime/planContext.js +246 -0
- package/dist/runtime/planContext.js.map +1 -0
- package/dist/runtime/planGenerator.d.ts +21 -0
- package/dist/runtime/planGenerator.d.ts.map +1 -0
- package/dist/runtime/planGenerator.js +89 -0
- package/dist/runtime/planGenerator.js.map +1 -0
- package/dist/runtime/planPreparation.d.ts +64 -0
- package/dist/runtime/planPreparation.d.ts.map +1 -0
- package/dist/runtime/planPreparation.js +173 -0
- package/dist/runtime/planPreparation.js.map +1 -0
- package/dist/runtime/projectSummary.d.ts +3 -0
- package/dist/runtime/projectSummary.d.ts.map +1 -0
- package/dist/runtime/projectSummary.js +42 -0
- package/dist/runtime/projectSummary.js.map +1 -0
- package/dist/runtime/providerSettings.d.ts +28 -0
- package/dist/runtime/providerSettings.d.ts.map +1 -0
- package/dist/runtime/providerSettings.js +93 -0
- package/dist/runtime/providerSettings.js.map +1 -0
- package/dist/runtime/pythonActions.d.ts +78 -0
- package/dist/runtime/pythonActions.d.ts.map +1 -0
- package/dist/runtime/pythonActions.js +392 -0
- package/dist/runtime/pythonActions.js.map +1 -0
- package/dist/runtime/pythonBridge.d.ts +13 -0
- package/dist/runtime/pythonBridge.d.ts.map +1 -0
- package/dist/runtime/pythonBridge.js +117 -0
- package/dist/runtime/pythonBridge.js.map +1 -0
- package/dist/runtime/rewriteEngine.d.ts +46 -0
- package/dist/runtime/rewriteEngine.d.ts.map +1 -0
- package/dist/runtime/rewriteEngine.js +259 -0
- package/dist/runtime/rewriteEngine.js.map +1 -0
- package/dist/runtime/rewriteGenerator.d.ts +29 -0
- package/dist/runtime/rewriteGenerator.d.ts.map +1 -0
- package/dist/runtime/rewriteGenerator.js +1527 -0
- package/dist/runtime/rewriteGenerator.js.map +1 -0
- package/dist/runtime/rewriteHydration.d.ts +22 -0
- package/dist/runtime/rewriteHydration.d.ts.map +1 -0
- package/dist/runtime/rewriteHydration.js +265 -0
- package/dist/runtime/rewriteHydration.js.map +1 -0
- package/dist/runtime/rewriteOrchestration.d.ts +105 -0
- package/dist/runtime/rewriteOrchestration.d.ts.map +1 -0
- package/dist/runtime/rewriteOrchestration.js +130 -0
- package/dist/runtime/rewriteOrchestration.js.map +1 -0
- package/dist/runtime/rewritePayload.d.ts +18 -0
- package/dist/runtime/rewritePayload.d.ts.map +1 -0
- package/dist/runtime/rewritePayload.js +166 -0
- package/dist/runtime/rewritePayload.js.map +1 -0
- package/dist/runtime/rewriteRuntime.d.ts +13 -0
- package/dist/runtime/rewriteRuntime.d.ts.map +1 -0
- package/dist/runtime/rewriteRuntime.js +21 -0
- package/dist/runtime/rewriteRuntime.js.map +1 -0
- package/dist/runtime/rewriteServices.d.ts +70 -0
- package/dist/runtime/rewriteServices.d.ts.map +1 -0
- package/dist/runtime/rewriteServices.js +50 -0
- package/dist/runtime/rewriteServices.js.map +1 -0
- package/dist/runtime/runtimeHelpers.d.ts +9 -0
- package/dist/runtime/runtimeHelpers.d.ts.map +1 -0
- package/dist/runtime/runtimeHelpers.js +86 -0
- package/dist/runtime/runtimeHelpers.js.map +1 -0
- package/dist/runtime/sessionData.d.ts +4 -0
- package/dist/runtime/sessionData.d.ts.map +1 -0
- package/dist/runtime/sessionData.js +45 -0
- package/dist/runtime/sessionData.js.map +1 -0
- package/dist/runtime/sessionRuntime.d.ts +47 -0
- package/dist/runtime/sessionRuntime.d.ts.map +1 -0
- package/dist/runtime/sessionRuntime.js +128 -0
- package/dist/runtime/sessionRuntime.js.map +1 -0
- package/dist/runtime/stealthRuntimeTypes.d.ts +12 -0
- package/dist/runtime/stealthRuntimeTypes.d.ts.map +1 -0
- package/dist/runtime/stealthRuntimeTypes.js +3 -0
- package/dist/runtime/stealthRuntimeTypes.js.map +1 -0
- package/dist/runtime/stepExecutor.d.ts +22 -0
- package/dist/runtime/stepExecutor.d.ts.map +1 -0
- package/dist/runtime/stepExecutor.js +83 -0
- package/dist/runtime/stepExecutor.js.map +1 -0
- package/dist/runtime/stepLifecycle.d.ts +29 -0
- package/dist/runtime/stepLifecycle.d.ts.map +1 -0
- package/dist/runtime/stepLifecycle.js +122 -0
- package/dist/runtime/stepLifecycle.js.map +1 -0
- package/dist/runtime/stepMetadata.d.ts +6 -0
- package/dist/runtime/stepMetadata.d.ts.map +1 -0
- package/dist/runtime/stepMetadata.js +87 -0
- package/dist/runtime/stepMetadata.js.map +1 -0
- package/dist/runtime/taskQueue.d.ts +16 -0
- package/dist/runtime/taskQueue.d.ts.map +1 -0
- package/dist/runtime/taskQueue.js +103 -0
- package/dist/runtime/taskQueue.js.map +1 -0
- package/dist/runtime/telemetry.d.ts +6 -0
- package/dist/runtime/telemetry.d.ts.map +1 -0
- package/dist/runtime/telemetry.js +42 -0
- package/dist/runtime/telemetry.js.map +1 -0
- package/dist/runtime/telemetryHub.d.ts +61 -0
- package/dist/runtime/telemetryHub.d.ts.map +1 -0
- package/dist/runtime/telemetryHub.js +190 -0
- package/dist/runtime/telemetryHub.js.map +1 -0
- package/dist/runtime/textSanitizer.d.ts +4 -0
- package/dist/runtime/textSanitizer.d.ts.map +1 -0
- package/dist/runtime/textSanitizer.js +86 -0
- package/dist/runtime/textSanitizer.js.map +1 -0
- package/dist/runtime/typeCheckRunner.d.ts +33 -0
- package/dist/runtime/typeCheckRunner.d.ts.map +1 -0
- package/dist/runtime/typeCheckRunner.js +357 -0
- package/dist/runtime/typeCheckRunner.js.map +1 -0
- package/dist/runtime/types.d.ts +334 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +3 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/runtime/typescriptValidator.d.ts +18 -0
- package/dist/runtime/typescriptValidator.d.ts.map +1 -0
- package/dist/runtime/typescriptValidator.js +363 -0
- package/dist/runtime/typescriptValidator.js.map +1 -0
- package/dist/runtime/undoManager.d.ts +7 -0
- package/dist/runtime/undoManager.d.ts.map +1 -0
- package/dist/runtime/undoManager.js +56 -0
- package/dist/runtime/undoManager.js.map +1 -0
- package/dist/runtime/validationController.d.ts +11 -0
- package/dist/runtime/validationController.d.ts.map +1 -0
- package/dist/runtime/validationController.js +29 -0
- package/dist/runtime/validationController.js.map +1 -0
- package/dist/runtime/validationUtils.d.ts +17 -0
- package/dist/runtime/validationUtils.d.ts.map +1 -0
- package/dist/runtime/validationUtils.js +121 -0
- package/dist/runtime/validationUtils.js.map +1 -0
- package/dist/runtime/workspaceAssertions.d.ts +21 -0
- package/dist/runtime/workspaceAssertions.d.ts.map +1 -0
- package/dist/runtime/workspaceAssertions.js +183 -0
- package/dist/runtime/workspaceAssertions.js.map +1 -0
- package/dist/runtime/workspaceIndexService.d.ts +24 -0
- package/dist/runtime/workspaceIndexService.d.ts.map +1 -0
- package/dist/runtime/workspaceIndexService.js +133 -0
- package/dist/runtime/workspaceIndexService.js.map +1 -0
- package/dist/runtime/workspaceIndexer.d.ts +21 -0
- package/dist/runtime/workspaceIndexer.d.ts.map +1 -0
- package/dist/runtime/workspaceIndexer.js +95 -0
- package/dist/runtime/workspaceIndexer.js.map +1 -0
- package/dist/runtime/workspacePackages.d.ts +22 -0
- package/dist/runtime/workspacePackages.d.ts.map +1 -0
- package/dist/runtime/workspacePackages.js +198 -0
- package/dist/runtime/workspacePackages.js.map +1 -0
- package/dist/runtime/workspaceRuntime.d.ts +58 -0
- package/dist/runtime/workspaceRuntime.d.ts.map +1 -0
- package/dist/runtime/workspaceRuntime.js +86 -0
- package/dist/runtime/workspaceRuntime.js.map +1 -0
- package/dist/runtime/workspaceService.d.ts +14 -0
- package/dist/runtime/workspaceService.d.ts.map +1 -0
- package/dist/runtime/workspaceService.js +88 -0
- package/dist/runtime/workspaceService.js.map +1 -0
- package/dist/runtime/workspaceServices.d.ts +114 -0
- package/dist/runtime/workspaceServices.d.ts.map +1 -0
- package/dist/runtime/workspaceServices.js +114 -0
- package/dist/runtime/workspaceServices.js.map +1 -0
- package/dist/runtime/writeServices.d.ts +34 -0
- package/dist/runtime/writeServices.d.ts.map +1 -0
- package/dist/runtime/writeServices.js +32 -0
- package/dist/runtime/writeServices.js.map +1 -0
- package/dist/sharedPromptSections.d.ts +58 -0
- package/dist/sharedPromptSections.d.ts.map +1 -0
- package/dist/sharedPromptSections.js +94 -0
- package/dist/sharedPromptSections.js.map +1 -0
- package/dist/statusTypes.d.ts +13 -0
- package/dist/statusTypes.d.ts.map +1 -0
- package/dist/statusTypes.js +3 -0
- package/dist/statusTypes.js.map +1 -0
- package/dist/streamIdleTimeout.d.ts +38 -0
- package/dist/streamIdleTimeout.d.ts.map +1 -0
- package/dist/streamIdleTimeout.js +44 -0
- package/dist/streamIdleTimeout.js.map +1 -0
- package/dist/types/bandit.d.ts +113 -0
- package/dist/types/bandit.d.ts.map +1 -0
- package/dist/types/bandit.js +3 -0
- package/dist/types/bandit.js.map +1 -0
- package/dist/types.d.ts +152 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/workspaceIndex.d.ts +44 -0
- package/dist/workspaceIndex.d.ts.map +1 -0
- package/dist/workspaceIndex.js +258 -0
- package/dist/workspaceIndex.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,969 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createHealingEngine = createHealingEngine;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const diagnostics_1 = require("./diagnostics");
|
|
39
|
+
const API_KEY_SECRET_KEY = 'banditStealth.apiKey';
|
|
40
|
+
const MAX_DIAGNOSTIC_FILES = 5;
|
|
41
|
+
function createHealingEngine(deps) {
|
|
42
|
+
const queue = deps.createTaskQueue({ maxRetries: 2, baseDelayMs: 1000 });
|
|
43
|
+
const pendingDiagnostics = [];
|
|
44
|
+
let diagnosticsInFlight = false;
|
|
45
|
+
deps.eventBus.on('diagnostics:errors', (payload) => {
|
|
46
|
+
if (!payload || !Array.isArray(payload.diagnostics) || payload.diagnostics.length === 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
pendingDiagnostics.push(payload);
|
|
50
|
+
if (!diagnosticsInFlight) {
|
|
51
|
+
diagnosticsInFlight = true;
|
|
52
|
+
void (async () => {
|
|
53
|
+
try {
|
|
54
|
+
while (pendingDiagnostics.length > 0) {
|
|
55
|
+
const next = pendingDiagnostics.shift();
|
|
56
|
+
if (!next) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
await processDiagnosticsEvent(next);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
await deps.telemetry.log({
|
|
64
|
+
level: 'error',
|
|
65
|
+
message: `Diagnostic healing failed: ${error instanceof Error ? error.message : String(error)}`
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
diagnosticsInFlight = false;
|
|
70
|
+
}
|
|
71
|
+
})();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
async function autoReviseFromReview(goal, plan, results, config) {
|
|
75
|
+
if (deps.getRunOptions().previewOnly) {
|
|
76
|
+
return { results: [], iterations: 0 };
|
|
77
|
+
}
|
|
78
|
+
if (deps.isDryRun()) {
|
|
79
|
+
await deps.telemetry.log({
|
|
80
|
+
message: 'Auto revision skipped — dry run mode active.',
|
|
81
|
+
level: 'warn'
|
|
82
|
+
});
|
|
83
|
+
return { results: [], iterations: 0 };
|
|
84
|
+
}
|
|
85
|
+
const latestReview = getLatestReviewResult(results);
|
|
86
|
+
if (!latestReview || !latestReview.needsRevision) {
|
|
87
|
+
return { results: [], iterations: 0 };
|
|
88
|
+
}
|
|
89
|
+
const rewriteStep = plan.steps.find((step) => step.action.type === 'llmRewrite');
|
|
90
|
+
const writeStep = plan.steps.find((step) => step.action.type === 'python' && step.action.name === 'writeFile');
|
|
91
|
+
const reviewStep = plan.steps.find((step) => step.action.type === 'internal' && step.action.name === 'reviewDiff');
|
|
92
|
+
if (!rewriteStep
|
|
93
|
+
|| rewriteStep.action.type !== 'llmRewrite'
|
|
94
|
+
|| !writeStep
|
|
95
|
+
|| writeStep.action.type !== 'python'
|
|
96
|
+
|| writeStep.action.name !== 'writeFile'
|
|
97
|
+
|| !reviewStep
|
|
98
|
+
|| reviewStep.action.type !== 'internal'
|
|
99
|
+
|| reviewStep.action.name !== 'reviewDiff') {
|
|
100
|
+
await deps.telemetry.log({
|
|
101
|
+
message: 'Auto revision skipped — required plan steps unavailable.',
|
|
102
|
+
level: 'warn'
|
|
103
|
+
});
|
|
104
|
+
return { results: [], iterations: 0 };
|
|
105
|
+
}
|
|
106
|
+
const rewriteAction = rewriteStep.action;
|
|
107
|
+
const writeAction = writeStep.action;
|
|
108
|
+
const reviewAction = reviewStep.action;
|
|
109
|
+
const session = deps.ensureSession();
|
|
110
|
+
const relativePath = (typeof latestReview.path === 'string' && latestReview.path)
|
|
111
|
+
|| deps.getContextValue(rewriteAction.pathRef)
|
|
112
|
+
|| deps.getContextValue(writeAction.pathRef)
|
|
113
|
+
|| deps.getContextValue('focus.primary.path');
|
|
114
|
+
if (!relativePath) {
|
|
115
|
+
await deps.telemetry.log({
|
|
116
|
+
message: 'Auto revision skipped — target path unresolved.',
|
|
117
|
+
level: 'warn'
|
|
118
|
+
});
|
|
119
|
+
return { results: [], iterations: 0 };
|
|
120
|
+
}
|
|
121
|
+
const extras = [];
|
|
122
|
+
let iteration = 0;
|
|
123
|
+
let pendingReviewText = latestReview.review ?? '';
|
|
124
|
+
const projectSummary = deps.getProjectSummary();
|
|
125
|
+
const maxIterations = Math.max(0, Math.floor(config.maxIterations));
|
|
126
|
+
if (maxIterations <= 0) {
|
|
127
|
+
await deps.telemetry.log({
|
|
128
|
+
message: 'Auto revision skipped — max iterations set to 0.',
|
|
129
|
+
level: 'warn'
|
|
130
|
+
});
|
|
131
|
+
return { results: [], iterations: 0 };
|
|
132
|
+
}
|
|
133
|
+
while (!deps.isCancelled() && iteration < maxIterations) {
|
|
134
|
+
iteration += 1;
|
|
135
|
+
await deps.telemetry.status({ text: `Auto revision ${iteration}`, phase: 'start', icon: 'code' });
|
|
136
|
+
await deps.persistence.save(session.workspaceRoot, {
|
|
137
|
+
planId: plan.goal ?? goal,
|
|
138
|
+
goal,
|
|
139
|
+
currentStep: iteration,
|
|
140
|
+
pendingDiffs: [relativePath],
|
|
141
|
+
metadata: {
|
|
142
|
+
pendingReview: pendingReviewText
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const rewriteTask = await queue.enqueue({
|
|
146
|
+
id: `healing-rewrite-${iteration}`,
|
|
147
|
+
run: async () => {
|
|
148
|
+
let currentContent = '';
|
|
149
|
+
try {
|
|
150
|
+
const absolutePath = path.join(session.workspaceRoot, relativePath);
|
|
151
|
+
currentContent = await deps.readWorkspaceFile(absolutePath);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
155
|
+
return {
|
|
156
|
+
outcome: { ok: false, error: `Unable to read ${relativePath}: ${message}` },
|
|
157
|
+
startedAt: Date.now()
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const rewriteInstructions = composeRevisionInstructions(rewriteAction.instructions, pendingReviewText, relativePath, deps.getRewriteHint);
|
|
161
|
+
const rewriteOutcome = await deps.generateRewrite(goal, relativePath, currentContent, projectSummary, rewriteInstructions);
|
|
162
|
+
return { outcome: rewriteOutcome, startedAt: Date.now() };
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const rewriteResult = deps.buildExecutionResult(`auto-rewrite-${iteration}`, rewriteTask.outcome, rewriteTask.startedAt);
|
|
166
|
+
extras.push(rewriteResult);
|
|
167
|
+
if (!rewriteTask.outcome.ok) {
|
|
168
|
+
await deps.telemetry.status({
|
|
169
|
+
text: `Auto revision ${iteration} failed to draft changes`,
|
|
170
|
+
phase: 'error',
|
|
171
|
+
detail: rewriteTask.outcome.error ?? rewriteTask.outcome.output,
|
|
172
|
+
icon: 'warn'
|
|
173
|
+
});
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
const newContent = rewriteTask.outcome.data?.content;
|
|
177
|
+
if (!newContent || !newContent.trim()) {
|
|
178
|
+
await deps.telemetry.status({
|
|
179
|
+
text: `Auto revision ${iteration} failed to draft changes`,
|
|
180
|
+
phase: 'error',
|
|
181
|
+
detail: 'Rewrite result was empty.',
|
|
182
|
+
icon: 'warn'
|
|
183
|
+
});
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
deps.setContextValue(rewriteAction.outputKey, newContent);
|
|
187
|
+
if (writeAction.contentRef) {
|
|
188
|
+
deps.setContextValue(writeAction.contentRef, newContent);
|
|
189
|
+
}
|
|
190
|
+
const writeTask = await queue.enqueue({
|
|
191
|
+
id: `healing-apply-${iteration}`,
|
|
192
|
+
run: async () => {
|
|
193
|
+
const startedAt = Date.now();
|
|
194
|
+
const outcome = await deps.executePythonStep({ ...writeAction }, `auto-apply-${iteration}`);
|
|
195
|
+
return { outcome, startedAt };
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
const writeResult = deps.buildExecutionResult(`auto-apply-${iteration}`, writeTask.outcome, writeTask.startedAt);
|
|
199
|
+
extras.push(writeResult);
|
|
200
|
+
if (!writeTask.outcome.ok) {
|
|
201
|
+
await deps.telemetry.status({
|
|
202
|
+
text: `Auto revision ${iteration} failed to apply changes`,
|
|
203
|
+
phase: 'error',
|
|
204
|
+
detail: writeTask.outcome.error ?? writeTask.outcome.output,
|
|
205
|
+
icon: 'warn'
|
|
206
|
+
});
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
const reviewTask = await queue.enqueue({
|
|
210
|
+
id: `healing-review-${iteration}`,
|
|
211
|
+
run: async () => {
|
|
212
|
+
const startedAt = Date.now();
|
|
213
|
+
const outcome = await reviewDiff(reviewAction, undefined);
|
|
214
|
+
return { outcome, startedAt };
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
const reviewResult = deps.buildExecutionResult(`auto-review-${iteration}`, reviewTask.outcome, reviewTask.startedAt);
|
|
218
|
+
extras.push(reviewResult);
|
|
219
|
+
const reviewData = (reviewTask.outcome.data ?? {});
|
|
220
|
+
const reviewText = typeof reviewData.review === 'string' ? reviewData.review : '';
|
|
221
|
+
const needsAnotherPass = typeof reviewData.needsRevision === 'boolean'
|
|
222
|
+
? reviewData.needsRevision
|
|
223
|
+
: reviewIndicatesIssues(reviewText);
|
|
224
|
+
if (!needsAnotherPass) {
|
|
225
|
+
await deps.telemetry.status({
|
|
226
|
+
text: `Auto revision ${iteration} complete`,
|
|
227
|
+
phase: 'complete',
|
|
228
|
+
detail: 'Review approved.',
|
|
229
|
+
icon: 'success'
|
|
230
|
+
});
|
|
231
|
+
await deps.persistence.clear(session.workspaceRoot);
|
|
232
|
+
return { results: extras, iterations: iteration, retryStepId: reviewStep.id };
|
|
233
|
+
}
|
|
234
|
+
pendingReviewText = reviewText;
|
|
235
|
+
if (!pendingReviewText.trim()) {
|
|
236
|
+
await deps.telemetry.status({
|
|
237
|
+
text: `Auto revision ${iteration} halted`,
|
|
238
|
+
phase: 'error',
|
|
239
|
+
detail: 'Review feedback unavailable; stopping auto-fixes.',
|
|
240
|
+
icon: 'warn'
|
|
241
|
+
});
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
await deps.telemetry.status({
|
|
245
|
+
text: `Auto revision ${iteration} requires follow-up`,
|
|
246
|
+
phase: 'progress',
|
|
247
|
+
detail: deps.truncateText(pendingReviewText, 200),
|
|
248
|
+
icon: 'review'
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
await deps.persistence.clear(session.workspaceRoot);
|
|
252
|
+
return { results: extras, iterations: iteration };
|
|
253
|
+
}
|
|
254
|
+
async function processDiagnosticsEvent(payload) {
|
|
255
|
+
if (deps.isDryRun() || deps.getRunOptions().previewOnly) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const session = deps.ensureSession();
|
|
259
|
+
const workspaceRoot = session.workspaceRoot;
|
|
260
|
+
const goal = payload.goal ?? session.goal;
|
|
261
|
+
const grouped = groupDiagnosticsByFile(payload.diagnostics, workspaceRoot, deps.normalizeRelativePath);
|
|
262
|
+
if (!grouped.length) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const touchedSet = buildTouchedFileSet(payload.touchedFiles, deps.normalizeRelativePath);
|
|
266
|
+
const { actionable, ambient } = partitionDiagnosticsByScope(grouped, touchedSet);
|
|
267
|
+
if (ambient.length > 0) {
|
|
268
|
+
const ambientFiles = ambient.map(([file]) => file);
|
|
269
|
+
await deps.telemetry.log({
|
|
270
|
+
level: 'info',
|
|
271
|
+
message: `Ambient diagnostics ignored (${payload.source ?? 'diagnostics'}): ${ambientFiles.join(', ')}`
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
if (actionable.length === 0) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const limited = actionable.slice(0, MAX_DIAGNOSTIC_FILES);
|
|
278
|
+
const tasks = limited
|
|
279
|
+
.slice()
|
|
280
|
+
.reverse()
|
|
281
|
+
.map(([file, diagnostics]) => queue.prepend({
|
|
282
|
+
id: `diagnostic-repair-${file}-${Date.now()}`,
|
|
283
|
+
run: async () => {
|
|
284
|
+
const startedAt = Date.now();
|
|
285
|
+
const outcome = await applyDiagnosticRepairs(goal, file, diagnostics, workspaceRoot);
|
|
286
|
+
return { outcome, startedAt };
|
|
287
|
+
}
|
|
288
|
+
}));
|
|
289
|
+
await Promise.all(tasks);
|
|
290
|
+
await deps.eventBus.emit('compile:retry', {
|
|
291
|
+
source: payload.source ?? 'diagnostics',
|
|
292
|
+
files: limited.map(([file]) => file)
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
async function applyDiagnosticRepairs(goal, relativePath, diagnostics, workspaceRoot) {
|
|
296
|
+
const absolutePath = path.join(workspaceRoot, relativePath);
|
|
297
|
+
let currentContent = '';
|
|
298
|
+
try {
|
|
299
|
+
currentContent = await deps.readWorkspaceFile(absolutePath);
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
303
|
+
await deps.telemetry.log({
|
|
304
|
+
level: 'warn',
|
|
305
|
+
message: `Diagnostic repair skipped for ${relativePath}: ${message}`
|
|
306
|
+
});
|
|
307
|
+
return { ok: false, error: message };
|
|
308
|
+
}
|
|
309
|
+
const instructions = buildDiagnosticInstructions(goal, relativePath, diagnostics);
|
|
310
|
+
const rewriteOutcome = await deps.generateRewrite(goal, relativePath, currentContent, deps.getProjectSummary(), instructions);
|
|
311
|
+
if (!rewriteOutcome.ok || typeof rewriteOutcome.data?.content !== 'string') {
|
|
312
|
+
return rewriteOutcome;
|
|
313
|
+
}
|
|
314
|
+
const updatedContent = rewriteOutcome.data.content;
|
|
315
|
+
if (!updatedContent.trim() || updatedContent.trim() === currentContent.trim()) {
|
|
316
|
+
return {
|
|
317
|
+
ok: false,
|
|
318
|
+
error: `Diagnostic rewrite returned no changes for ${relativePath}.`,
|
|
319
|
+
data: { diagnostics }
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
const pathRef = createContextKey('diagnostics.path');
|
|
323
|
+
const contentRef = createContextKey('diagnostics.content');
|
|
324
|
+
const originalRef = createContextKey('diagnostics.original');
|
|
325
|
+
deps.setContextValue(pathRef, relativePath);
|
|
326
|
+
deps.setContextValue(contentRef, updatedContent);
|
|
327
|
+
deps.setContextValue(originalRef, currentContent);
|
|
328
|
+
const writeOutcome = await deps.executePythonStep({
|
|
329
|
+
type: 'python',
|
|
330
|
+
name: 'writeFile',
|
|
331
|
+
pathRef,
|
|
332
|
+
contentRef,
|
|
333
|
+
encoding: 'utf-8',
|
|
334
|
+
originalContentRef: originalRef
|
|
335
|
+
}, `diagnostic-write-${relativePath}`);
|
|
336
|
+
if (!writeOutcome.ok) {
|
|
337
|
+
return writeOutcome;
|
|
338
|
+
}
|
|
339
|
+
await deps.telemetry.log({
|
|
340
|
+
level: 'info',
|
|
341
|
+
message: `Diagnostic repair applied to ${relativePath}.`
|
|
342
|
+
});
|
|
343
|
+
return {
|
|
344
|
+
...writeOutcome,
|
|
345
|
+
data: {
|
|
346
|
+
...(writeOutcome.data ?? {}),
|
|
347
|
+
diagnostics
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
async function reviewDiff(action, step) {
|
|
352
|
+
const session = deps.ensureSession();
|
|
353
|
+
const helperMeta = deps.getHelperStepMetadata(step);
|
|
354
|
+
const isHelperReview = helperMeta?.role === 'review';
|
|
355
|
+
const relativePath = (action.pathRef ? deps.getContextValue(action.pathRef) : undefined)
|
|
356
|
+
?? deps.getContextValue('focus.primary.path');
|
|
357
|
+
const touchedContextValue = action.touchedFilesRef ? deps.getContextValue(action.touchedFilesRef) : undefined;
|
|
358
|
+
const touchedFiles = resolveTouchedFiles(relativePath, touchedContextValue, deps.normalizeRelativePath);
|
|
359
|
+
let diff = (action.diffRef ? deps.getContextValue(action.diffRef) : undefined)
|
|
360
|
+
?? deps.getContextValue('focus.primary.diff');
|
|
361
|
+
let original = (action.originalContentRef ? deps.getContextValue(action.originalContentRef) : undefined)
|
|
362
|
+
?? (isHelperReview ? undefined : deps.getContextValue('focus.primary.content'));
|
|
363
|
+
let updated = (action.updatedContentRef ? deps.getContextValue(action.updatedContentRef) : undefined)
|
|
364
|
+
?? deps.getContextValue('focus.primary.rewrite');
|
|
365
|
+
if (isHelperReview && (!original || original.trim().length === 0)) {
|
|
366
|
+
if (relativePath) {
|
|
367
|
+
try {
|
|
368
|
+
const target = path.join(session.workspaceRoot, relativePath);
|
|
369
|
+
original = await deps.readWorkspaceFile(target);
|
|
370
|
+
}
|
|
371
|
+
catch {
|
|
372
|
+
original = '';
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
original = '';
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
let pending = relativePath ? deps.diffManager.getPendingDiff(relativePath) : undefined;
|
|
380
|
+
if (!diff
|
|
381
|
+
&& relativePath
|
|
382
|
+
&& pending
|
|
383
|
+
&& typeof pending.original === 'string'
|
|
384
|
+
&& typeof pending.updated === 'string') {
|
|
385
|
+
pending = await deps.diffManager.registerPendingDiff(relativePath, pending.original, pending.updated, pending.confidence);
|
|
386
|
+
diff = pending?.diff ?? diff;
|
|
387
|
+
}
|
|
388
|
+
if (!diff && pending?.diff) {
|
|
389
|
+
diff = pending.diff;
|
|
390
|
+
}
|
|
391
|
+
if (!updated && pending?.updated) {
|
|
392
|
+
updated = pending.updated;
|
|
393
|
+
}
|
|
394
|
+
if (!diff
|
|
395
|
+
&& relativePath
|
|
396
|
+
&& typeof original === 'string'
|
|
397
|
+
&& typeof updated === 'string') {
|
|
398
|
+
pending = await deps.diffManager.registerPendingDiff(relativePath, original, updated, pending?.confidence);
|
|
399
|
+
diff = pending?.diff ?? diff;
|
|
400
|
+
}
|
|
401
|
+
if (!diff) {
|
|
402
|
+
return { ok: false, error: 'Diff unavailable for review.' };
|
|
403
|
+
}
|
|
404
|
+
if ((!updated || updated.trim().length === 0) && relativePath) {
|
|
405
|
+
try {
|
|
406
|
+
const target = path.join(session.workspaceRoot, relativePath);
|
|
407
|
+
updated = await deps.readWorkspaceFile(target);
|
|
408
|
+
}
|
|
409
|
+
catch {
|
|
410
|
+
// ignore read failures — we can still review using the diff
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
if (action.touchedFilesRef) {
|
|
414
|
+
if (touchedFiles.length > 0) {
|
|
415
|
+
deps.setContextValue(action.touchedFilesRef, touchedFiles);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
deps.setContextValue(action.touchedFilesRef, undefined);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const goalText = session.goal ?? 'No goal supplied.';
|
|
422
|
+
const shouldAttemptHelperCreation = !deps.getRunOptions().previewOnly && !deps.isDryRun();
|
|
423
|
+
const outstandingBeforeReview = await deps.pendingInferenceTracker.resolvePendingFiles();
|
|
424
|
+
if (outstandingBeforeReview.length > 0) {
|
|
425
|
+
if (shouldAttemptHelperCreation) {
|
|
426
|
+
const createdHelpers = await deps.rewriteEngine.createMissingHelperFiles(goalText, outstandingBeforeReview);
|
|
427
|
+
if (createdHelpers.length > 0) {
|
|
428
|
+
const remaining = await deps.pendingInferenceTracker.resolvePendingFiles();
|
|
429
|
+
if (remaining.length > 0) {
|
|
430
|
+
const missingMessage = `Required helper files were not created: ${remaining.join(', ')}`;
|
|
431
|
+
return {
|
|
432
|
+
ok: false,
|
|
433
|
+
error: missingMessage,
|
|
434
|
+
data: {
|
|
435
|
+
missingFiles: remaining,
|
|
436
|
+
needsRevision: true,
|
|
437
|
+
review: missingMessage,
|
|
438
|
+
path: relativePath
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
const missingMessage = `Required helper files were not created: ${outstandingBeforeReview.join(', ')}`;
|
|
445
|
+
return {
|
|
446
|
+
ok: false,
|
|
447
|
+
error: missingMessage,
|
|
448
|
+
data: {
|
|
449
|
+
missingFiles: outstandingBeforeReview,
|
|
450
|
+
needsRevision: true,
|
|
451
|
+
review: missingMessage,
|
|
452
|
+
path: relativePath
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
const missingMessage = `Required helper files were not created: ${outstandingBeforeReview.join(', ')}`;
|
|
459
|
+
return {
|
|
460
|
+
ok: false,
|
|
461
|
+
error: missingMessage,
|
|
462
|
+
data: {
|
|
463
|
+
missingFiles: outstandingBeforeReview,
|
|
464
|
+
needsRevision: true,
|
|
465
|
+
review: missingMessage,
|
|
466
|
+
path: relativePath
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
const providerKind = deps.getProviderKind();
|
|
472
|
+
const apiKey = providerKind === 'bandit' ? await deps.fetchSecret(API_KEY_SECRET_KEY) : '';
|
|
473
|
+
if (providerKind === 'bandit' && !apiKey) {
|
|
474
|
+
return { ok: false, error: 'Bandit API key required to review changes.' };
|
|
475
|
+
}
|
|
476
|
+
const provider = await deps.createProvider(deps.buildProviderSettings(apiKey ?? ''));
|
|
477
|
+
const diffPreview = deps.clampDiffPreview(diff, 320);
|
|
478
|
+
const originalSample = typeof original === 'string' ? deps.buildContentSample(original, 24, 2400) : 'Unavailable';
|
|
479
|
+
const updatedSample = typeof updated === 'string' ? deps.buildContentSample(updated, 24, 2400) : 'Unavailable';
|
|
480
|
+
const messages = [
|
|
481
|
+
{
|
|
482
|
+
role: 'system',
|
|
483
|
+
content: [
|
|
484
|
+
'You are a meticulous senior engineer performing code review for a teammate.',
|
|
485
|
+
'Inspect the provided diff and call out any risks, regressions, missing edge cases, accessibility issues, or style inconsistencies.',
|
|
486
|
+
'If everything looks correct, reply with “LGTM — no issues found.”',
|
|
487
|
+
'Respond using Markdown bullets when noting findings.'
|
|
488
|
+
].join(' ')
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
role: 'user',
|
|
492
|
+
content: [
|
|
493
|
+
`Goal: ${goalText}`,
|
|
494
|
+
`File: ${relativePath ?? 'unknown'}`,
|
|
495
|
+
'',
|
|
496
|
+
'Diff:',
|
|
497
|
+
'```diff',
|
|
498
|
+
diffPreview,
|
|
499
|
+
'```',
|
|
500
|
+
'',
|
|
501
|
+
'Original sample:',
|
|
502
|
+
'```',
|
|
503
|
+
originalSample,
|
|
504
|
+
'```',
|
|
505
|
+
'',
|
|
506
|
+
'Updated sample:',
|
|
507
|
+
'```',
|
|
508
|
+
updatedSample,
|
|
509
|
+
'```'
|
|
510
|
+
].join('\n')
|
|
511
|
+
}
|
|
512
|
+
];
|
|
513
|
+
const request = {
|
|
514
|
+
model: deps.getModel(providerKind),
|
|
515
|
+
messages,
|
|
516
|
+
temperature: 0.1,
|
|
517
|
+
stream: true
|
|
518
|
+
};
|
|
519
|
+
const topP = deps.getTopP();
|
|
520
|
+
if (typeof topP === 'number' && !Number.isNaN(topP)) {
|
|
521
|
+
request.options = { top_p: topP };
|
|
522
|
+
}
|
|
523
|
+
let reviewText = '';
|
|
524
|
+
try {
|
|
525
|
+
let buffer = '';
|
|
526
|
+
for await (const chunk of provider.chat(request)) {
|
|
527
|
+
if (deps.isCancelled()) {
|
|
528
|
+
throw new Error('Cancelled');
|
|
529
|
+
}
|
|
530
|
+
const content = chunk?.message?.content ?? '';
|
|
531
|
+
if (content) {
|
|
532
|
+
buffer += content;
|
|
533
|
+
}
|
|
534
|
+
if (chunk?.done) {
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
reviewText = buffer.trim();
|
|
539
|
+
}
|
|
540
|
+
catch (error) {
|
|
541
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
542
|
+
reviewText = `Review unavailable: ${message}`;
|
|
543
|
+
}
|
|
544
|
+
const normalizedReview = deps.stripCodeFences(reviewText).trim() || 'Review unavailable.';
|
|
545
|
+
let needsRevision = reviewIndicatesIssues(normalizedReview);
|
|
546
|
+
const validationNotes = [];
|
|
547
|
+
let diagnosticsTriggeredFailure = false;
|
|
548
|
+
let validationResult;
|
|
549
|
+
let helperValidation;
|
|
550
|
+
const contextDiagnostics = action.diagnosticsRef
|
|
551
|
+
? coerceDiagnostics(deps.getContextValue(action.diagnosticsRef))
|
|
552
|
+
: [];
|
|
553
|
+
let relatedDiagnostics = [];
|
|
554
|
+
let unrelatedDiagnostics = [];
|
|
555
|
+
if (contextDiagnostics.length > 0) {
|
|
556
|
+
const partitioned = partitionDiagnosticsForTouched(contextDiagnostics, touchedFiles, deps.normalizeRelativePath);
|
|
557
|
+
relatedDiagnostics = mergeDiagnosticLists(relatedDiagnostics, partitioned.related);
|
|
558
|
+
unrelatedDiagnostics = mergeDiagnosticLists(unrelatedDiagnostics, partitioned.unrelated);
|
|
559
|
+
}
|
|
560
|
+
if (!deps.getRunOptions().previewOnly && !deps.isDryRun()) {
|
|
561
|
+
const preferredTargets = touchedFiles.length > 0 ? touchedFiles : relativePath ? [relativePath] : undefined;
|
|
562
|
+
validationResult = await deps.runProjectTypeCheck({
|
|
563
|
+
files: preferredTargets,
|
|
564
|
+
validateOnlyThesePaths: preferredTargets
|
|
565
|
+
});
|
|
566
|
+
if (validationResult) {
|
|
567
|
+
const validationTouched = preferredTargets ?? validationResult.touchedFiles ?? touchedFiles;
|
|
568
|
+
const partitioned = partitionDiagnosticsForTouched(validationResult.diagnostics ?? [], validationTouched, deps.normalizeRelativePath);
|
|
569
|
+
const existingIgnored = Array.isArray(validationResult.ignoredDiagnostics)
|
|
570
|
+
? [...validationResult.ignoredDiagnostics]
|
|
571
|
+
: [];
|
|
572
|
+
validationResult.diagnostics = partitioned.related;
|
|
573
|
+
validationResult.ignoredDiagnostics = mergeDiagnosticLists(existingIgnored, partitioned.unrelated);
|
|
574
|
+
relatedDiagnostics = mergeDiagnosticLists(relatedDiagnostics, partitioned.related);
|
|
575
|
+
unrelatedDiagnostics = mergeDiagnosticLists(unrelatedDiagnostics, validationResult.ignoredDiagnostics ?? []);
|
|
576
|
+
if (!validationResult.ok) {
|
|
577
|
+
if (partitioned.related.length === 0) {
|
|
578
|
+
const ignoredNote = validationResult.note
|
|
579
|
+
?? 'Unrelated TypeScript errors exist elsewhere in the project; ignoring them for this review.';
|
|
580
|
+
validationNotes.push(ignoredNote);
|
|
581
|
+
appendValidationFinalNote(validationResult, 'complete', ignoredNote);
|
|
582
|
+
validationResult.ok = true;
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
needsRevision = true;
|
|
586
|
+
const blockingNote = 'Blocking TypeScript errors remain in this file. See buildValidation.output for diagnostics.';
|
|
587
|
+
validationNotes.push(blockingNote);
|
|
588
|
+
appendValidationFinalNote(validationResult, 'best-effort', blockingNote);
|
|
589
|
+
diagnosticsTriggeredFailure = true;
|
|
590
|
+
await deps.eventBus.emit('diagnostics:errors', {
|
|
591
|
+
goal: session.goal,
|
|
592
|
+
source: 'typecheck',
|
|
593
|
+
diagnostics: partitioned.related,
|
|
594
|
+
rawOutput: validationResult.rawOutput ?? validationResult.output,
|
|
595
|
+
touchedFiles: validationTouched
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
else if ((validationResult.note && validationResult.note.trim().length > 0)
|
|
600
|
+
|| (validationResult.ignoredDiagnostics?.length ?? 0) > 0) {
|
|
601
|
+
const ignoredNote = validationResult.note
|
|
602
|
+
?? 'Unrelated TypeScript errors exist elsewhere in the project; ignoring them for this review.';
|
|
603
|
+
validationNotes.push(ignoredNote);
|
|
604
|
+
appendValidationFinalNote(validationResult, 'complete', ignoredNote);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
if (helperMeta?.role === 'review') {
|
|
609
|
+
if (!deps.getRunOptions().previewOnly && !deps.isDryRun()) {
|
|
610
|
+
helperValidation = await deps.helperManager.validate(helperMeta);
|
|
611
|
+
await deps.emitHelperTelemetry(helperMeta, helperValidation);
|
|
612
|
+
if (!helperValidation.ok) {
|
|
613
|
+
const failureSummary = deps.truncateText(helperValidation.error ?? 'Helper validation failed.', 1600);
|
|
614
|
+
needsRevision = true;
|
|
615
|
+
const helperData = helperValidation.data;
|
|
616
|
+
const typeCheckOutput = typeof helperData?.typeCheck === 'string' ? helperData.typeCheck : undefined;
|
|
617
|
+
validationResult = { ok: false, output: typeCheckOutput ?? failureSummary };
|
|
618
|
+
const helperDiagnostics = typeCheckOutput ? (0, diagnostics_1.parseCompilerOutput)(typeCheckOutput) : [];
|
|
619
|
+
if (helperDiagnostics.length > 0) {
|
|
620
|
+
const helperPartition = partitionDiagnosticsForTouched(helperDiagnostics, touchedFiles, deps.normalizeRelativePath);
|
|
621
|
+
relatedDiagnostics = mergeDiagnosticLists(relatedDiagnostics, helperPartition.related);
|
|
622
|
+
unrelatedDiagnostics = mergeDiagnosticLists(unrelatedDiagnostics, helperPartition.unrelated);
|
|
623
|
+
if (helperPartition.related.length > 0) {
|
|
624
|
+
await deps.eventBus.emit('diagnostics:errors', {
|
|
625
|
+
goal: session.goal,
|
|
626
|
+
source: 'helper-typecheck',
|
|
627
|
+
diagnostics: helperPartition.related,
|
|
628
|
+
rawOutput: typeCheckOutput,
|
|
629
|
+
touchedFiles
|
|
630
|
+
});
|
|
631
|
+
appendValidationFinalNote(validationResult, 'best-effort', 'Helper validation reported blocking errors.');
|
|
632
|
+
diagnosticsTriggeredFailure = true;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
const helperFailureNote = `Helper validation failed: ${failureSummary}`;
|
|
636
|
+
validationNotes.push(helperFailureNote);
|
|
637
|
+
appendValidationFinalNote(validationResult, 'best-effort', helperFailureNote);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
else {
|
|
641
|
+
helperValidation = { ok: true, data: { skipped: true } };
|
|
642
|
+
await deps.emitHelperTelemetry(helperMeta, helperValidation);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
if (relatedDiagnostics.length === 0 && unrelatedDiagnostics.length > 0) {
|
|
646
|
+
const unrelatedNote = 'Unrelated diagnostics detected outside the edited file — ignoring them for this review.';
|
|
647
|
+
if (!validationNotes.includes(unrelatedNote)) {
|
|
648
|
+
validationNotes.push(unrelatedNote);
|
|
649
|
+
}
|
|
650
|
+
if (validationResult) {
|
|
651
|
+
appendValidationFinalNote(validationResult, 'complete', unrelatedNote);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
if (action.diagnosticsRef) {
|
|
655
|
+
const combinedDiagnostics = [...relatedDiagnostics, ...unrelatedDiagnostics];
|
|
656
|
+
if (combinedDiagnostics.length > 0) {
|
|
657
|
+
deps.setContextValue(action.diagnosticsRef, combinedDiagnostics);
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
deps.setContextValue(action.diagnosticsRef, undefined);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
if (validationResult?.finalNotes?.length) {
|
|
664
|
+
validationResult.finalNotes.forEach((note) => {
|
|
665
|
+
if (note && note.trim().length > 0 && !validationNotes.includes(note)) {
|
|
666
|
+
validationNotes.push(note);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
if (action.storeKey) {
|
|
671
|
+
deps.setContextValue(action.storeKey, normalizedReview);
|
|
672
|
+
}
|
|
673
|
+
const headlineSource = normalizedReview.split('\n').find((line) => line.trim().length > 0) ?? normalizedReview;
|
|
674
|
+
const trimmedHeadline = headlineSource.trim();
|
|
675
|
+
const headline = needsRevision
|
|
676
|
+
? `Review findings — ${trimmedHeadline.length > 0 ? deps.truncateText(trimmedHeadline, 96) : 'Follow-up required.'}`
|
|
677
|
+
: 'Review complete — no issues flagged.';
|
|
678
|
+
const summary = pending?.summary ?? (diff ? deps.summarizeDiff(diff) : { added: 0, removed: 0 });
|
|
679
|
+
const confidence = pending?.confidence ?? 0.85;
|
|
680
|
+
await deps.telemetry.log({
|
|
681
|
+
message: `Review diff for ${relativePath ?? 'updated file'} — +${summary.added} / -${summary.removed} (confidence ${(confidence * 100).toFixed(1)}%)`,
|
|
682
|
+
level: needsRevision ? 'warn' : 'info'
|
|
683
|
+
});
|
|
684
|
+
if (relativePath && !pending && (typeof original === 'string' || typeof updated === 'string')) {
|
|
685
|
+
pending = await deps.diffManager.registerPendingDiff(relativePath, original ?? '', updated ?? '', confidence);
|
|
686
|
+
}
|
|
687
|
+
const errorMessage = needsRevision
|
|
688
|
+
? diagnosticsTriggeredFailure
|
|
689
|
+
? validationNotes[0] ?? 'Blocking errors present in this file.'
|
|
690
|
+
: normalizedReview
|
|
691
|
+
: undefined;
|
|
692
|
+
return {
|
|
693
|
+
ok: !needsRevision,
|
|
694
|
+
output: headline,
|
|
695
|
+
error: errorMessage,
|
|
696
|
+
data: {
|
|
697
|
+
path: relativePath,
|
|
698
|
+
review: normalizedReview,
|
|
699
|
+
reviewSummary: normalizedReview,
|
|
700
|
+
needsRevision,
|
|
701
|
+
buildValidation: validationResult,
|
|
702
|
+
helper: helperMeta
|
|
703
|
+
? {
|
|
704
|
+
id: helperMeta.helperId,
|
|
705
|
+
path: helperMeta.helperPath,
|
|
706
|
+
role: helperMeta.role
|
|
707
|
+
}
|
|
708
|
+
: undefined,
|
|
709
|
+
helperValidation: helperValidation?.data,
|
|
710
|
+
validationNotes,
|
|
711
|
+
diff,
|
|
712
|
+
diffSummary: summary,
|
|
713
|
+
confidence
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
return { autoReviseFromReview, reviewDiff };
|
|
718
|
+
}
|
|
719
|
+
function composeRevisionInstructions(baseInstructions, reviewFeedback, relativePath, getRewriteHint) {
|
|
720
|
+
const trimmedBase = (baseInstructions ?? 'Rewrite the file to satisfy the goal.').trim();
|
|
721
|
+
const trimmedReview = reviewFeedback.trim();
|
|
722
|
+
if (!trimmedReview) {
|
|
723
|
+
const hint = getRewriteHint(relativePath);
|
|
724
|
+
const hintSection = hint ? `\n\nCompiler feedback for ${relativePath}:\n${hint}` : '';
|
|
725
|
+
return `${trimmedBase}\n\nEnsure the updated file fully satisfies the user goal and resolves any gaps noted during review.${hintSection}`;
|
|
726
|
+
}
|
|
727
|
+
const boundedReview = trimmedReview.length > 2000 ? `${trimmedReview.slice(0, 2000)}…` : trimmedReview;
|
|
728
|
+
const hint = getRewriteHint(relativePath);
|
|
729
|
+
const hintSection = hint ? `\n\nCompiler feedback for ${relativePath}:\n${hint}` : '';
|
|
730
|
+
return `${trimmedBase}\n\nAddress the following review feedback before returning the full updated file:\n${boundedReview}${hintSection}`;
|
|
731
|
+
}
|
|
732
|
+
function groupDiagnosticsByFile(diagnostics, workspaceRoot, normalizeRelativePath) {
|
|
733
|
+
const bucket = new Map();
|
|
734
|
+
diagnostics.forEach((diagnostic) => {
|
|
735
|
+
const relativePath = normalizeDiagnosticRelativePath(diagnostic.file, workspaceRoot, normalizeRelativePath);
|
|
736
|
+
if (!relativePath) {
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
const existing = bucket.get(relativePath) ?? [];
|
|
740
|
+
existing.push(diagnostic);
|
|
741
|
+
bucket.set(relativePath, existing);
|
|
742
|
+
});
|
|
743
|
+
return Array.from(bucket.entries());
|
|
744
|
+
}
|
|
745
|
+
function buildTouchedFileSet(touchedFiles, normalizeRelativePath) {
|
|
746
|
+
const normalized = (Array.isArray(touchedFiles) ? touchedFiles : [])
|
|
747
|
+
.map((file) => normalizeRelativePath(file) ?? file)
|
|
748
|
+
.map((file) => file.replace(/\\/g, '/').toLowerCase())
|
|
749
|
+
.filter((value) => value.length > 0);
|
|
750
|
+
return new Set(normalized);
|
|
751
|
+
}
|
|
752
|
+
function partitionDiagnosticsByScope(entries, touchedSet) {
|
|
753
|
+
const actionable = [];
|
|
754
|
+
const ambient = [];
|
|
755
|
+
const enforceTouchedScope = touchedSet.size > 0;
|
|
756
|
+
entries.forEach(([file, diagnostics]) => {
|
|
757
|
+
const normalizedFile = typeof file === 'string' ? file.replace(/\\/g, '/').toLowerCase() : '';
|
|
758
|
+
const fileIsAmbient = isAmbientFile(normalizedFile);
|
|
759
|
+
const isTouched = !enforceTouchedScope || touchedSet.has(normalizedFile);
|
|
760
|
+
if (fileIsAmbient || !isTouched) {
|
|
761
|
+
diagnostics.forEach((diagnostic) => {
|
|
762
|
+
diagnostic.isAmbientError = true;
|
|
763
|
+
diagnostic.isTouchedFileError = false;
|
|
764
|
+
diagnostic.isExternalError = true;
|
|
765
|
+
});
|
|
766
|
+
ambient.push([file, diagnostics]);
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
diagnostics.forEach((diagnostic) => {
|
|
770
|
+
diagnostic.isTouchedFileError = true;
|
|
771
|
+
diagnostic.isExternalError = false;
|
|
772
|
+
diagnostic.isAmbientError = false;
|
|
773
|
+
});
|
|
774
|
+
actionable.push([file, diagnostics]);
|
|
775
|
+
});
|
|
776
|
+
return { actionable, ambient };
|
|
777
|
+
}
|
|
778
|
+
function normalizeDiagnosticRelativePath(file, workspaceRoot, normalizeRelativePath) {
|
|
779
|
+
if (!file) {
|
|
780
|
+
return undefined;
|
|
781
|
+
}
|
|
782
|
+
const normalizedFile = file.replace(/\\/g, '/').trim();
|
|
783
|
+
const absolute = path.isAbsolute(normalizedFile)
|
|
784
|
+
? normalizedFile
|
|
785
|
+
: path.join(workspaceRoot, normalizedFile);
|
|
786
|
+
const relative = path.relative(workspaceRoot, absolute).replace(/\\/g, '/');
|
|
787
|
+
return normalizeRelativePath(relative) ?? relative;
|
|
788
|
+
}
|
|
789
|
+
function isAmbientFile(file) {
|
|
790
|
+
if (!file) {
|
|
791
|
+
return true;
|
|
792
|
+
}
|
|
793
|
+
return file.endsWith('.d.ts') || file.includes('/node_modules/') || file.includes('node_modules\\');
|
|
794
|
+
}
|
|
795
|
+
function buildDiagnosticInstructions(goal, relativePath, diagnostics) {
|
|
796
|
+
const header = [
|
|
797
|
+
`Goal: ${goal}`,
|
|
798
|
+
`Target file: ${relativePath}`,
|
|
799
|
+
'Compiler diagnostics that must be resolved:'
|
|
800
|
+
];
|
|
801
|
+
const bulletList = diagnostics.slice(0, 8).map((diagnostic) => {
|
|
802
|
+
const location = diagnostic.line > 0 ? `line ${diagnostic.line}` : 'unknown line';
|
|
803
|
+
return `- ${location}: ${diagnostic.message}`;
|
|
804
|
+
});
|
|
805
|
+
return [
|
|
806
|
+
...header,
|
|
807
|
+
...bulletList,
|
|
808
|
+
'',
|
|
809
|
+
'Update the file to eliminate every diagnostic, ensuring the implementation stays aligned with the overall goal.'
|
|
810
|
+
].join('\n');
|
|
811
|
+
}
|
|
812
|
+
function createContextKey(prefix) {
|
|
813
|
+
return `${prefix}.${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`;
|
|
814
|
+
}
|
|
815
|
+
function reviewIndicatesApproval(review) {
|
|
816
|
+
const normalized = review.trim().toLowerCase();
|
|
817
|
+
if (!normalized) {
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
820
|
+
if (normalized.startsWith('review unavailable')) {
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
const positiveMarkers = [
|
|
824
|
+
'lgtm',
|
|
825
|
+
'no issues found',
|
|
826
|
+
'no issues flagged',
|
|
827
|
+
'looks good',
|
|
828
|
+
'looks solid',
|
|
829
|
+
'approved',
|
|
830
|
+
'all good',
|
|
831
|
+
'ready to merge'
|
|
832
|
+
];
|
|
833
|
+
return positiveMarkers.some((marker) => normalized.includes(marker));
|
|
834
|
+
}
|
|
835
|
+
function reviewIndicatesIssues(review) {
|
|
836
|
+
if (!review || review.trim().length === 0) {
|
|
837
|
+
return true;
|
|
838
|
+
}
|
|
839
|
+
return !reviewIndicatesApproval(review);
|
|
840
|
+
}
|
|
841
|
+
function getLatestReviewResult(results) {
|
|
842
|
+
for (let index = results.length - 1; index >= 0; index -= 1) {
|
|
843
|
+
const entry = results[index];
|
|
844
|
+
const data = entry.data;
|
|
845
|
+
if (!data) {
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
const reviewText = typeof data.review === 'string' ? data.review : undefined;
|
|
849
|
+
if (!reviewText) {
|
|
850
|
+
continue;
|
|
851
|
+
}
|
|
852
|
+
const needsRevision = typeof data.needsRevision === 'boolean'
|
|
853
|
+
? data.needsRevision
|
|
854
|
+
: reviewIndicatesIssues(reviewText);
|
|
855
|
+
const reviewPath = typeof data.path === 'string' ? data.path : undefined;
|
|
856
|
+
return { review: reviewText, path: reviewPath, needsRevision };
|
|
857
|
+
}
|
|
858
|
+
return undefined;
|
|
859
|
+
}
|
|
860
|
+
function resolveTouchedFiles(relativePath, contextValue, normalizeRelativePath) {
|
|
861
|
+
const contextPaths = coercePathList(contextValue);
|
|
862
|
+
if (relativePath && relativePath.trim().length > 0) {
|
|
863
|
+
contextPaths.push(relativePath.trim());
|
|
864
|
+
}
|
|
865
|
+
const normalized = contextPaths
|
|
866
|
+
.map((file) => normalizeRelativePath(file) ?? file)
|
|
867
|
+
.map((file) => file.replace(/\\/g, '/'))
|
|
868
|
+
.filter((file) => file.length > 0);
|
|
869
|
+
return Array.from(new Set(normalized));
|
|
870
|
+
}
|
|
871
|
+
function coercePathList(value) {
|
|
872
|
+
if (Array.isArray(value)) {
|
|
873
|
+
return value.filter((entry) => typeof entry === 'string' && entry.trim().length > 0).map((entry) => entry.trim());
|
|
874
|
+
}
|
|
875
|
+
if (typeof value === 'string' && value.trim().length > 0) {
|
|
876
|
+
return [value.trim()];
|
|
877
|
+
}
|
|
878
|
+
return [];
|
|
879
|
+
}
|
|
880
|
+
function coerceDiagnostics(value) {
|
|
881
|
+
if (!Array.isArray(value)) {
|
|
882
|
+
return [];
|
|
883
|
+
}
|
|
884
|
+
return value
|
|
885
|
+
.map((entry) => {
|
|
886
|
+
if (!entry || typeof entry !== 'object') {
|
|
887
|
+
return undefined;
|
|
888
|
+
}
|
|
889
|
+
const candidate = entry;
|
|
890
|
+
if (typeof candidate.file !== 'string' || typeof candidate.message !== 'string') {
|
|
891
|
+
return undefined;
|
|
892
|
+
}
|
|
893
|
+
return {
|
|
894
|
+
file: candidate.file,
|
|
895
|
+
message: candidate.message,
|
|
896
|
+
line: typeof candidate.line === 'number' ? candidate.line : 0,
|
|
897
|
+
type: candidate.type ?? 'unknown',
|
|
898
|
+
isTouchedFileError: candidate.isTouchedFileError,
|
|
899
|
+
isExternalError: candidate.isExternalError,
|
|
900
|
+
isAmbientError: candidate.isAmbientError
|
|
901
|
+
};
|
|
902
|
+
})
|
|
903
|
+
.filter((entry) => Boolean(entry));
|
|
904
|
+
}
|
|
905
|
+
function partitionDiagnosticsForTouched(diagnostics, touchedFiles, normalizeRelativePath) {
|
|
906
|
+
const list = Array.isArray(diagnostics) ? diagnostics : [];
|
|
907
|
+
if (!list.length) {
|
|
908
|
+
return { related: [], unrelated: [] };
|
|
909
|
+
}
|
|
910
|
+
const normalizedTouched = new Set((Array.isArray(touchedFiles) ? touchedFiles : [])
|
|
911
|
+
.map((file) => normalizeRelativePath(file) ?? file)
|
|
912
|
+
.map((file) => file.replace(/\\/g, '/').toLowerCase())
|
|
913
|
+
.filter((file) => file.length > 0));
|
|
914
|
+
const enforceTouchedScope = normalizedTouched.size > 0;
|
|
915
|
+
const related = [];
|
|
916
|
+
const unrelated = [];
|
|
917
|
+
list.forEach((diagnostic) => {
|
|
918
|
+
const normalizedFile = normalizeRelativePath(diagnostic.file) ?? diagnostic.file;
|
|
919
|
+
const normalizedKey = normalizedFile?.replace(/\\/g, '/').toLowerCase() ?? '';
|
|
920
|
+
const flaggedTouched = typeof diagnostic.isTouchedFileError === 'boolean' ? diagnostic.isTouchedFileError : undefined;
|
|
921
|
+
const isAmbient = diagnostic.isAmbientError === true || (!normalizedKey && enforceTouchedScope);
|
|
922
|
+
const isTouched = flaggedTouched === true
|
|
923
|
+
|| (!isAmbient && (flaggedTouched !== false && (!enforceTouchedScope || normalizedTouched.has(normalizedKey))));
|
|
924
|
+
if (isTouched) {
|
|
925
|
+
diagnostic.isTouchedFileError = true;
|
|
926
|
+
diagnostic.isExternalError = false;
|
|
927
|
+
diagnostic.isAmbientError = false;
|
|
928
|
+
related.push(diagnostic);
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
diagnostic.isTouchedFileError = false;
|
|
932
|
+
diagnostic.isExternalError = true;
|
|
933
|
+
diagnostic.isAmbientError = isAmbient;
|
|
934
|
+
unrelated.push(diagnostic);
|
|
935
|
+
});
|
|
936
|
+
return { related, unrelated };
|
|
937
|
+
}
|
|
938
|
+
function mergeDiagnosticLists(target, additions) {
|
|
939
|
+
if (!Array.isArray(additions) || additions.length === 0) {
|
|
940
|
+
return target;
|
|
941
|
+
}
|
|
942
|
+
const result = Array.isArray(target) ? target : [];
|
|
943
|
+
const seen = new Set(result.map((diagnostic) => buildDiagnosticKey(diagnostic)));
|
|
944
|
+
additions.forEach((diagnostic) => {
|
|
945
|
+
const key = buildDiagnosticKey(diagnostic);
|
|
946
|
+
if (seen.has(key)) {
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
seen.add(key);
|
|
950
|
+
result.push(diagnostic);
|
|
951
|
+
});
|
|
952
|
+
return result;
|
|
953
|
+
}
|
|
954
|
+
function buildDiagnosticKey(diagnostic) {
|
|
955
|
+
const file = diagnostic.file ?? 'unknown';
|
|
956
|
+
return `${file}:${diagnostic.line}:${diagnostic.message}`;
|
|
957
|
+
}
|
|
958
|
+
function appendValidationFinalNote(outcome, status, note) {
|
|
959
|
+
if (!outcome || !note) {
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
const notes = Array.isArray(outcome.finalNotes) ? [...outcome.finalNotes] : [];
|
|
963
|
+
if (!notes.includes(note)) {
|
|
964
|
+
notes.push(note);
|
|
965
|
+
}
|
|
966
|
+
outcome.finalNotes = notes;
|
|
967
|
+
outcome.finalStatus = status;
|
|
968
|
+
}
|
|
969
|
+
//# sourceMappingURL=healingEngine.js.map
|