pi-agent-ide 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/assets/banner.png +0 -0
- package/docs/architecture.md +100 -0
- package/docs/configuration.md +104 -0
- package/docs/development.md +102 -0
- package/docs/evaluation.md +14 -0
- package/docs/extensions.md +298 -0
- package/docs/tools.md +104 -0
- package/node_modules/pi-agent-filesystem/index.ts +60 -0
- package/node_modules/pi-agent-filesystem/package.json +23 -0
- package/node_modules/pi-agent-filesystem/src/resolver.ts +175 -0
- package/node_modules/pi-agent-filesystem-image/index.ts +14 -0
- package/node_modules/pi-agent-filesystem-image/package.json +20 -0
- package/node_modules/pi-agent-filesystem-pdf/index.ts +14 -0
- package/node_modules/pi-agent-filesystem-pdf/package.json +17 -0
- package/node_modules/pi-agent-filesystem-text/index.ts +23 -0
- package/node_modules/pi-agent-filesystem-text/package.json +20 -0
- package/node_modules/pi-agent-ide-ast/index.ts +1 -0
- package/node_modules/pi-agent-ide-ast/package.json +39 -0
- package/node_modules/pi-agent-ide-ast/src/api/scope.ts +1 -0
- package/node_modules/pi-agent-ide-ast/src/ast/collect-files.ts +24 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +374 -0
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +813 -0
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +30 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +85 -0
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +69 -0
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +221 -0
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +45 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +141 -0
- package/node_modules/pi-agent-ide-changes/index.ts +68 -0
- package/node_modules/pi-agent-ide-changes/package.json +29 -0
- package/node_modules/pi-agent-ide-changes/src/change-anchor.ts +103 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-groups.ts +309 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +223 -0
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +105 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +325 -0
- package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +232 -0
- package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +11 -0
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +88 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +116 -0
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +153 -0
- package/node_modules/pi-agent-ide-formatter/index.ts +33 -0
- package/node_modules/pi-agent-ide-formatter/package.json +14 -0
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +50 -0
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +30 -0
- package/node_modules/pi-agent-ide-formatter/src/types.ts +10 -0
- package/node_modules/pi-agent-ide-lint/index.ts +237 -0
- package/node_modules/pi-agent-ide-lint/package.json +19 -0
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +160 -0
- package/node_modules/pi-agent-ide-lint/src/command-runner.ts +51 -0
- package/node_modules/pi-agent-ide-lint/src/registry.ts +30 -0
- package/node_modules/pi-agent-ide-lint/src/types.ts +10 -0
- package/node_modules/pi-agent-ide-lsp/index.ts +250 -0
- package/node_modules/pi-agent-ide-lsp/package.json +23 -0
- package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +139 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +463 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +577 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +179 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +59 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/language-map.ts +57 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +85 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +485 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +85 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +97 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +50 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +149 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +151 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +95 -0
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +42 -0
- package/node_modules/pi-agent-image/package.json +18 -0
- package/node_modules/pi-agent-image/src/image-converter.ts +318 -0
- package/node_modules/pi-agent-image/src/index.ts +6 -0
- package/node_modules/pi-agent-pdf/package.json +16 -0
- package/node_modules/pi-agent-pdf/src/index.ts +5 -0
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +197 -0
- package/node_modules/pi-agent-read/index.ts +1 -0
- package/node_modules/pi-agent-read/package.json +41 -0
- package/node_modules/pi-agent-read/src/api/connect-plugin.ts +67 -0
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +67 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +11 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +208 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +40 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +390 -0
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +193 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +400 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +187 -0
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +218 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +828 -0
- package/node_modules/pi-agent-resource/package.json +17 -0
- package/node_modules/pi-agent-resource/src/content-conversion/connect-plugin.ts +84 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-converter.ts +49 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +29 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-host.ts +73 -0
- package/node_modules/pi-agent-resource/src/content-conversion/content-runner.ts +152 -0
- package/node_modules/pi-agent-resource/src/content-conversion/plugin-protocol.ts +74 -0
- package/node_modules/pi-agent-resource/src/content-conversion/validation.ts +149 -0
- package/node_modules/pi-agent-resource/src/content.ts +17 -0
- package/node_modules/pi-agent-resource/src/index.ts +65 -0
- package/node_modules/pi-agent-resource/src/resolver.ts +23 -0
- package/node_modules/pi-agent-resource/src/resource.ts +41 -0
- package/node_modules/pi-agent-resource/src/validation.ts +139 -0
- package/node_modules/pi-agent-search/index.ts +1 -0
- package/node_modules/pi-agent-search/package.json +35 -0
- package/node_modules/pi-agent-search/src/api/connect-plugin.ts +61 -0
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +60 -0
- package/node_modules/pi-agent-search/src/api/search.ts +91 -0
- package/node_modules/pi-agent-search/src/core/extension.ts +126 -0
- package/node_modules/pi-agent-search/src/core/search-core.ts +400 -0
- package/node_modules/pi-agent-search-semantic/index.ts +105 -0
- package/node_modules/pi-agent-search-semantic/package.json +17 -0
- package/node_modules/pi-agent-search-text/index.ts +54 -0
- package/node_modules/pi-agent-search-text/package.json +33 -0
- package/node_modules/pi-agent-search-text/src/file-search.ts +105 -0
- package/node_modules/pi-agent-search-text/src/lucene-query-parser.d.ts +22 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +192 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +295 -0
- package/node_modules/pi-agent-search-text/src/search-query.ts +139 -0
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +420 -0
- package/node_modules/pi-agent-search-text/src/search-result.ts +193 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +338 -0
- package/node_modules/pi-agent-search-web/index.ts +74 -0
- package/node_modules/pi-agent-search-web/package.json +19 -0
- package/node_modules/pi-agent-search-web/src/config.ts +499 -0
- package/node_modules/pi-agent-search-web/src/providers/duckduckgo-html.ts +78 -0
- package/node_modules/pi-agent-search-web/src/providers/endpoints.ts +89 -0
- package/node_modules/pi-agent-search-web/src/providers/request.ts +430 -0
- package/node_modules/pi-agent-search-web/src/providers/response.ts +402 -0
- package/node_modules/pi-agent-search-web/src/search-format.ts +29 -0
- package/node_modules/pi-agent-search-web/src/search.ts +434 -0
- package/node_modules/pi-agent-search-web/src/types.ts +153 -0
- package/node_modules/pi-agent-text/package.json +18 -0
- package/node_modules/pi-agent-text/src/index.ts +31 -0
- package/node_modules/pi-agent-text/src/presented-text.ts +24 -0
- package/node_modules/pi-agent-text/src/source-line.ts +49 -0
- package/node_modules/pi-agent-text/src/text-anchor.ts +157 -0
- package/node_modules/pi-agent-text/src/text-converter.ts +109 -0
- package/node_modules/pi-agent-text/src/text-document.ts +149 -0
- package/node_modules/pi-agent-text-anchor-constant/index.ts +30 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +17 -0
- package/node_modules/pi-agent-text-anchor-constant/src/resolver.ts +47 -0
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +48 -0
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +24 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +110 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +47 -0
- package/node_modules/pi-agent-text-editor/index.ts +19 -0
- package/node_modules/pi-agent-text-editor/package.json +92 -0
- package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +24 -0
- package/node_modules/pi-agent-text-editor/src/api/connect-plugin.ts +67 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +19 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +64 -0
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +46 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +46 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +30 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +23 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +180 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +217 -0
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +147 -0
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -0
- package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +121 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +39 -0
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +59 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +150 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +386 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +129 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +359 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +648 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +117 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-recovery.ts +24 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +381 -0
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +273 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +607 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +127 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +45 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +432 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +115 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +2348 -0
- package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +28 -0
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +756 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1235 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +43 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +308 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +467 -0
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +16 -0
- package/node_modules/pi-agent-text-editor/src/tools/extension.ts +19 -0
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +106 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +121 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +79 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +56 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +142 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +72 -0
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +28 -0
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +29 -0
- package/node_modules/pi-agent-text-editor-argument-order/package.json +16 -0
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +112 -0
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +391 -0
- package/node_modules/pi-agent-text-editor-overwrite/package.json +16 -0
- package/node_modules/pi-agent-text-editor-renderer/index.ts +22 -0
- package/node_modules/pi-agent-text-editor-renderer/package.json +21 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +452 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +271 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-theme.ts +411 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +38 -0
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +205 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +229 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +407 -0
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +153 -0
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +8 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +728 -0
- package/node_modules/pi-agent-text-editor-renderer/src/typing-interpolation.ts +219 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +375 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +17 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +17 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +418 -0
- package/node_modules/pi-agent-web/index.ts +37 -0
- package/node_modules/pi-agent-web/package.json +24 -0
- package/node_modules/pi-agent-web/src/resolver.ts +182 -0
- package/node_modules/pi-agent-web-html/index.ts +15 -0
- package/node_modules/pi-agent-web-html/package.json +18 -0
- package/node_modules/pi-agent-web-html/src/extract-readable-html.ts +101 -0
- package/node_modules/pi-agent-web-html/src/html-converter.ts +91 -0
- package/node_modules/pi-agent-web-image/index.ts +14 -0
- package/node_modules/pi-agent-web-image/package.json +17 -0
- package/node_modules/pi-agent-web-pdf/index.ts +14 -0
- package/node_modules/pi-agent-web-pdf/package.json +17 -0
- package/node_modules/pi-agent-web-text/index.ts +14 -0
- package/node_modules/pi-agent-web-text/package.json +17 -0
- package/package.json +176 -0
- package/src/api/code-view.ts +25 -0
- package/src/api/connect-plugin.ts +64 -0
- package/src/api/plugin-protocol.ts +63 -0
- package/src/api/read.ts +5 -0
- package/src/api/resource.ts +2 -0
- package/src/api/search.ts +4 -0
- package/src/api/text-editor.ts +3 -0
- package/src/api/text.ts +2 -0
- package/src/api/toolchain.ts +24 -0
- package/src/code-view/diagnostic-view.ts +82 -0
- package/src/code-view/reference.ts +113 -0
- package/src/code-view/source-view.ts +229 -0
- package/src/composite/builtin-extensions.ts +68 -0
- package/src/composite/config.ts +94 -0
- package/src/composite/selection.ts +66 -0
- package/src/core/extension.ts +48 -0
- package/src/core/ide-core.ts +117 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +60 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/index.ts +23 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +20 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +175 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +37 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +24 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/index.ts +15 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +18 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/extract-readable-html.ts +101 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +91 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/index.ts +14 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +17 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +182 -0
- package/src/extensions/pi-agent-read/index.ts +1 -0
- package/src/extensions/pi-agent-read/package.json +41 -0
- package/src/extensions/pi-agent-read/src/api/connect-plugin.ts +67 -0
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +67 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +11 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +208 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +40 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +390 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +193 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +400 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +187 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +218 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +828 -0
- package/src/extensions/pi-agent-search/index.ts +1 -0
- package/src/extensions/pi-agent-search/package.json +35 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/index.ts +105 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-semantic/package.json +17 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +54 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +33 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +105 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/lucene-query-parser.d.ts +22 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +192 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +295 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +139 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +420 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +193 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +338 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/index.ts +74 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/package.json +19 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/config.ts +499 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/duckduckgo-html.ts +78 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/endpoints.ts +89 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/request.ts +430 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/providers/response.ts +402 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search-format.ts +29 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/search.ts +434 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-web/src/types.ts +153 -0
- package/src/extensions/pi-agent-search/src/api/connect-plugin.ts +61 -0
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +60 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +91 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +126 -0
- package/src/extensions/pi-agent-search/src/core/search-core.ts +400 -0
- package/src/extensions/pi-agent-text-editor/index.ts +19 -0
- package/src/extensions/pi-agent-text-editor/package.json +92 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/index.ts +30 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +17 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/src/resolver.ts +47 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +48 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +24 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +110 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +47 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +29 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +16 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +112 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +391 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +16 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +22 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +21 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +452 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +271 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-theme.ts +411 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +38 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +205 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +229 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +407 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +153 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +8 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +728 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/typing-interpolation.ts +219 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +375 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +17 -0
- package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +24 -0
- package/src/extensions/pi-agent-text-editor/src/api/connect-plugin.ts +67 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +19 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +64 -0
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +46 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +46 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +30 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +23 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +180 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +217 -0
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +147 -0
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +17 -0
- package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +121 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +39 -0
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +59 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +150 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +386 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +129 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +359 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +648 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/inline-hints.ts +117 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-recovery.ts +24 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +381 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +273 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +607 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-execution.ts +127 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-recovery.ts +45 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +432 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +115 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +2348 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +28 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +756 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1235 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-json-resolver.ts +43 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/partial-tool-recovery.ts +308 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/rendering.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +467 -0
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +16 -0
- package/src/extensions/pi-agent-text-editor/src/tools/extension.ts +19 -0
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +106 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +121 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +79 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +56 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +142 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +72 -0
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +28 -0
- package/src/index.ts +1 -0
- package/src/pi-agent-ide.ts +17 -0
- package/src/plugins/pi-agent-ide-ast/index.ts +1 -0
- package/src/plugins/pi-agent-ide-ast/package.json +39 -0
- package/src/plugins/pi-agent-ide-ast/src/api/scope.ts +1 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/collect-files.ts +24 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +374 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +813 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +30 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +85 -0
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +69 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +221 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +45 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +141 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +68 -0
- package/src/plugins/pi-agent-ide-changes/package.json +29 -0
- package/src/plugins/pi-agent-ide-changes/src/change-anchor.ts +103 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-groups.ts +309 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +223 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +105 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +325 -0
- package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +232 -0
- package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +11 -0
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +88 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +116 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +153 -0
- package/src/plugins/pi-agent-ide-formatter/index.ts +33 -0
- package/src/plugins/pi-agent-ide-formatter/package.json +14 -0
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +50 -0
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +30 -0
- package/src/plugins/pi-agent-ide-formatter/src/types.ts +10 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +237 -0
- package/src/plugins/pi-agent-ide-lint/package.json +19 -0
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +160 -0
- package/src/plugins/pi-agent-ide-lint/src/command-runner.ts +51 -0
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +30 -0
- package/src/plugins/pi-agent-ide-lint/src/types.ts +10 -0
- package/src/plugins/pi-agent-ide-lsp/index.ts +250 -0
- package/src/plugins/pi-agent-ide-lsp/package.json +23 -0
- package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +139 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +463 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +577 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +179 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +59 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/language-map.ts +57 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/lsp-compiler.ts +85 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +485 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +85 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +97 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +50 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +149 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +151 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +95 -0
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +42 -0
- package/src/post-edit/gate.ts +153 -0
- package/src/toolchain/diagnostic.ts +7 -0
- package/src/toolchain/gate.ts +322 -0
- package/src/toolchain/registry.ts +223 -0
- package/src/toolchain/types.ts +164 -0
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
import type { TextDocument } from "pi-agent-text";
|
|
2
|
+
|
|
3
|
+
export interface MutationAnchor
|
|
4
|
+
{
|
|
5
|
+
readonly lineNumber: number;
|
|
6
|
+
readonly hash?: string;
|
|
7
|
+
readonly value?: string;
|
|
8
|
+
readonly anchor?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface MutationSnapshot
|
|
12
|
+
{
|
|
13
|
+
readonly content: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AppliedTextChange
|
|
17
|
+
{
|
|
18
|
+
readonly editIndex: number;
|
|
19
|
+
readonly fromA: number;
|
|
20
|
+
readonly toA: number;
|
|
21
|
+
readonly fromB: number;
|
|
22
|
+
readonly toB: number;
|
|
23
|
+
readonly removedText: string;
|
|
24
|
+
readonly insertedText: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface MutationEdit
|
|
28
|
+
{
|
|
29
|
+
readonly range?: FileRange;
|
|
30
|
+
}
|
|
31
|
+
// ─── Public types ────────────────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
export interface FileChange
|
|
34
|
+
{
|
|
35
|
+
path: string;
|
|
36
|
+
action: "edited" | "created" | "overwritten";
|
|
37
|
+
size?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface FileError
|
|
41
|
+
{
|
|
42
|
+
path: string;
|
|
43
|
+
code?: string | undefined;
|
|
44
|
+
reason?: string | undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface Warning
|
|
48
|
+
{
|
|
49
|
+
file?: string;
|
|
50
|
+
messages: string[];
|
|
51
|
+
severity: "diagnostic" | "syntax";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface DiagnosticHint
|
|
55
|
+
{
|
|
56
|
+
file: string;
|
|
57
|
+
line: number;
|
|
58
|
+
column: number;
|
|
59
|
+
anchor?: string;
|
|
60
|
+
lineText?: string;
|
|
61
|
+
severity: "error" | "warning" | "info" | "hint";
|
|
62
|
+
source?: string;
|
|
63
|
+
code: string;
|
|
64
|
+
message: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface SyntaxErrorSummary
|
|
68
|
+
{
|
|
69
|
+
total: number;
|
|
70
|
+
shown: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface GatePhase
|
|
74
|
+
{
|
|
75
|
+
phase: string;
|
|
76
|
+
toolName: string;
|
|
77
|
+
status: string;
|
|
78
|
+
duration?: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface LintViolation
|
|
82
|
+
{
|
|
83
|
+
line: number;
|
|
84
|
+
column: number;
|
|
85
|
+
rule: string;
|
|
86
|
+
message: string;
|
|
87
|
+
category: "in_range" | "out_of_range";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Structured info about a stale anchor edit. */
|
|
91
|
+
export interface StaleEditInfo
|
|
92
|
+
{
|
|
93
|
+
index: number;
|
|
94
|
+
expectedAnchor: MutationAnchor;
|
|
95
|
+
failurePoint: "start anchor" | "end anchor";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A single line in an edit range diagnostic (preview). */
|
|
99
|
+
export interface EditDiagnosticLine
|
|
100
|
+
{
|
|
101
|
+
lineNumber: number;
|
|
102
|
+
hash: string;
|
|
103
|
+
text: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Detailed stale anchor diagnostic with context. */
|
|
107
|
+
export interface StaleAnchorDiagnostic
|
|
108
|
+
{
|
|
109
|
+
lineNumber: number;
|
|
110
|
+
expected: { lineNumber: number; hash: string; textAvailable: false; };
|
|
111
|
+
current: EditDiagnosticLine;
|
|
112
|
+
anchorHashChanged: boolean;
|
|
113
|
+
currentContext: EditDiagnosticLine[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type StrictEditErrorCode =
|
|
117
|
+
| "INVALID_ARGUMENT"
|
|
118
|
+
| "INVALID_PATH"
|
|
119
|
+
| "BINARY_FILE"
|
|
120
|
+
| "INVALID_ANCHOR"
|
|
121
|
+
| "ANCHOR_OUT_OF_RANGE"
|
|
122
|
+
| "STALE_ANCHOR"
|
|
123
|
+
| "INVALID_RANGE"
|
|
124
|
+
| "OVERLAPPING_EDITS"
|
|
125
|
+
| "NO_CHANGE"
|
|
126
|
+
| "WRITE_FAILED"
|
|
127
|
+
| "ROLLBACK_FAILED"
|
|
128
|
+
| "WRITE_OVERWRITE_CONFIRMATION_REQUIRED"
|
|
129
|
+
| "WRITE_OVERWRITE_TARGET_CHANGED"
|
|
130
|
+
| "WRITE_OVERWRITE_CONTENT_CHANGED"
|
|
131
|
+
| "MUTATION_REJECTED"
|
|
132
|
+
| "WRITE_DUPLICATE_TARGET_PATH"
|
|
133
|
+
| "WRITE_ROLLBACK_FAILED"
|
|
134
|
+
| "POST_EDIT_SYNTAX_FAILURE"
|
|
135
|
+
| "INTERNAL_ERROR"
|
|
136
|
+
| "NO_EDITS";
|
|
137
|
+
|
|
138
|
+
/** Options for constructing a failure result. */
|
|
139
|
+
export interface EditFailureOptions
|
|
140
|
+
{
|
|
141
|
+
code: StrictEditErrorCode;
|
|
142
|
+
path: string;
|
|
143
|
+
requestedRange?: string;
|
|
144
|
+
failurePoint: string;
|
|
145
|
+
reason: string;
|
|
146
|
+
recovery?: string;
|
|
147
|
+
freshLines?: readonly string[];
|
|
148
|
+
freshCenterLine?: number;
|
|
149
|
+
expectedAnchor?: string;
|
|
150
|
+
currentAnchor?: string;
|
|
151
|
+
proposedDiff?: string;
|
|
152
|
+
internalError?: unknown;
|
|
153
|
+
fileChangedStatement?: string;
|
|
154
|
+
editIndex?: number;
|
|
155
|
+
editIndices?: number[];
|
|
156
|
+
|
|
157
|
+
staleDiagnostic?: StaleAnchorDiagnostic;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Flat data bag for FileMutationResult. All fields optional. */
|
|
161
|
+
export interface FileMutationData
|
|
162
|
+
{
|
|
163
|
+
// ── Discriminator ──
|
|
164
|
+
kind?: "ok" | "fail" | undefined;
|
|
165
|
+
ok?: boolean | undefined;
|
|
166
|
+
isPartial?: boolean | undefined;
|
|
167
|
+
|
|
168
|
+
// ── Result fields ──
|
|
169
|
+
diffs?: string[] | undefined;
|
|
170
|
+
files?: FileChange[] | undefined;
|
|
171
|
+
warnings?: Warning[] | undefined;
|
|
172
|
+
errors?: FileError[] | undefined;
|
|
173
|
+
lintViolations?: LintViolation[] | undefined;
|
|
174
|
+
hints?: DiagnosticHint[] | undefined;
|
|
175
|
+
syntaxErrorSummary?: SyntaxErrorSummary | undefined;
|
|
176
|
+
path?: string | undefined;
|
|
177
|
+
editRange?: FileRange | undefined;
|
|
178
|
+
freshAnchors?: string[] | undefined;
|
|
179
|
+
|
|
180
|
+
failurePoint?: string | undefined;
|
|
181
|
+
recovery?: string | undefined;
|
|
182
|
+
expectedAnchor?: string | undefined;
|
|
183
|
+
currentAnchor?: string | undefined;
|
|
184
|
+
internalErrorType?: string | undefined;
|
|
185
|
+
internalErrorMessage?: string | undefined;
|
|
186
|
+
editCount?: number | undefined;
|
|
187
|
+
editRanges?: { startLine: number; endLine: number; }[] | undefined;
|
|
188
|
+
addedLines?: number | undefined;
|
|
189
|
+
removedLines?: number | undefined;
|
|
190
|
+
appliedPaths?: string[] | undefined;
|
|
191
|
+
beforeContentMap?: Record<string, string | null> | undefined;
|
|
192
|
+
skipCount?: number | undefined;
|
|
193
|
+
staleEdits?: StaleEditInfo[] | undefined;
|
|
194
|
+
proposedDiff?: string | undefined;
|
|
195
|
+
editIndex?: number | undefined;
|
|
196
|
+
editIndices?: number[] | undefined;
|
|
197
|
+
|
|
198
|
+
staleDiagnostic?: StaleAnchorDiagnostic | undefined;
|
|
199
|
+
fileChangedStatement?: string | undefined;
|
|
200
|
+
|
|
201
|
+
// ── Transient engine fields ──
|
|
202
|
+
snapshot?: MutationSnapshot | undefined;
|
|
203
|
+
activeEdits?: MutationEdit[] | undefined;
|
|
204
|
+
inputPath?: string | undefined;
|
|
205
|
+
inputEdits?: unknown[] | undefined;
|
|
206
|
+
afterContent?: string | undefined;
|
|
207
|
+
afterDocument?: TextDocument | undefined;
|
|
208
|
+
/** Scope markers attached to post-edit lines, matching read output. */
|
|
209
|
+
scopeMarkers?: Record<string, string[]> | undefined;
|
|
210
|
+
/** Exact changes produced by the text engine before the post-edit gate. */
|
|
211
|
+
rawChanges?: AppliedTextChange[] | undefined;
|
|
212
|
+
absolutePath?: string | undefined;
|
|
213
|
+
/** Full pre-edit output in the same anchored plain-text shape as read. */
|
|
214
|
+
beforeReadText?: string | undefined;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Batch-level result from a file-mutation tool execution.
|
|
219
|
+
* Phases are batch-wide (gate runs once for all files), not per-FMR.
|
|
220
|
+
*/
|
|
221
|
+
export interface FileMutationBatchResult
|
|
222
|
+
{
|
|
223
|
+
/** Per-file mutation results (undefined when tool aborted). */
|
|
224
|
+
results: FileMutationResult[] | undefined;
|
|
225
|
+
/** Batch-wide gate phases (undefined = no gate was run). */
|
|
226
|
+
phases?: GatePhase[];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Edit range — what the user asked for, with parsed line numbers and hashes.
|
|
231
|
+
*/
|
|
232
|
+
export class FileRange
|
|
233
|
+
{
|
|
234
|
+
public readonly start: MutationAnchor;
|
|
235
|
+
public readonly end: MutationAnchor;
|
|
236
|
+
|
|
237
|
+
public constructor(start: MutationAnchor, end: MutationAnchor = start)
|
|
238
|
+
{
|
|
239
|
+
if (end.lineNumber < start.lineNumber)
|
|
240
|
+
{
|
|
241
|
+
[start, end] = [end, start];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
this.start = start;
|
|
245
|
+
this.end = end;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static fromLines(startLine: number, endLine?: number): FileRange
|
|
249
|
+
{
|
|
250
|
+
const end = endLine ?? startLine;
|
|
251
|
+
return new FileRange({ lineNumber: startLine }, { lineNumber: end });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// ─── Unified result class ────────────────────────────────────────────────
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Unified result type for any file-mutating tool operation.
|
|
258
|
+
* Constructed from a flat data bag — never from raw engine types.
|
|
259
|
+
*
|
|
260
|
+
* Consumers access fields via getters (defaults to empty/false).
|
|
261
|
+
*/
|
|
262
|
+
export class FileMutationResult
|
|
263
|
+
{
|
|
264
|
+
readonly data: FileMutationData;
|
|
265
|
+
|
|
266
|
+
public constructor(data?: FileMutationData)
|
|
267
|
+
{
|
|
268
|
+
this.data = data ?? {};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ── Getters ──
|
|
272
|
+
|
|
273
|
+
get ok(): boolean
|
|
274
|
+
{
|
|
275
|
+
return this.data.ok ?? false;
|
|
276
|
+
}
|
|
277
|
+
get isPartial(): boolean
|
|
278
|
+
{
|
|
279
|
+
return this.data.isPartial ?? false;
|
|
280
|
+
}
|
|
281
|
+
get diffs(): string[]
|
|
282
|
+
{
|
|
283
|
+
return this.data.diffs ?? [];
|
|
284
|
+
}
|
|
285
|
+
get files(): FileChange[]
|
|
286
|
+
{
|
|
287
|
+
return this.data.files ?? [];
|
|
288
|
+
}
|
|
289
|
+
get warnings(): Warning[]
|
|
290
|
+
{
|
|
291
|
+
return this.data.warnings ?? [];
|
|
292
|
+
}
|
|
293
|
+
get errors(): FileError[]
|
|
294
|
+
{
|
|
295
|
+
return this.data.errors ?? [];
|
|
296
|
+
}
|
|
297
|
+
get lintViolations(): LintViolation[]
|
|
298
|
+
{
|
|
299
|
+
return this.data.lintViolations ?? [];
|
|
300
|
+
}
|
|
301
|
+
get hints(): DiagnosticHint[]
|
|
302
|
+
{
|
|
303
|
+
return this.data.hints ?? [];
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
get syntaxErrorSummary(): SyntaxErrorSummary | undefined
|
|
307
|
+
{
|
|
308
|
+
return this.data.syntaxErrorSummary;
|
|
309
|
+
}
|
|
310
|
+
get path(): string | undefined
|
|
311
|
+
{
|
|
312
|
+
return this.data.path;
|
|
313
|
+
}
|
|
314
|
+
get editRange(): FileRange | undefined
|
|
315
|
+
{
|
|
316
|
+
const edits = this.data.activeEdits;
|
|
317
|
+
|
|
318
|
+
if (edits?.length && edits[0]!.range)
|
|
319
|
+
{
|
|
320
|
+
const start = edits[0]!.range.start;
|
|
321
|
+
const lastRange = edits.at(-1)!.range;
|
|
322
|
+
const end = lastRange?.end ?? start;
|
|
323
|
+
return new FileRange(start, end);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return this.data.editRange;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
get resolvedStartLine(): number | undefined
|
|
330
|
+
{
|
|
331
|
+
return this.editRange?.start.lineNumber;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
get resolvedEndLine(): number | undefined
|
|
335
|
+
{
|
|
336
|
+
return this.editRange?.end.lineNumber;
|
|
337
|
+
}
|
|
338
|
+
get freshAnchors(): string[] | undefined
|
|
339
|
+
{
|
|
340
|
+
return this.data.freshAnchors;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
get failurePoint(): string | undefined
|
|
344
|
+
{
|
|
345
|
+
return this.data.failurePoint;
|
|
346
|
+
}
|
|
347
|
+
get recovery(): string | undefined
|
|
348
|
+
{
|
|
349
|
+
return this.data.recovery;
|
|
350
|
+
}
|
|
351
|
+
get expectedAnchor(): string | undefined
|
|
352
|
+
{
|
|
353
|
+
return this.data.expectedAnchor;
|
|
354
|
+
}
|
|
355
|
+
get currentAnchor(): string | undefined
|
|
356
|
+
{
|
|
357
|
+
return this.data.currentAnchor;
|
|
358
|
+
}
|
|
359
|
+
get internalErrorType(): string | undefined
|
|
360
|
+
{
|
|
361
|
+
return this.data.internalErrorType;
|
|
362
|
+
}
|
|
363
|
+
get internalErrorMessage(): string | undefined
|
|
364
|
+
{
|
|
365
|
+
return this.data.internalErrorMessage;
|
|
366
|
+
}
|
|
367
|
+
get editCount(): number | undefined
|
|
368
|
+
{
|
|
369
|
+
return this.data.editCount;
|
|
370
|
+
}
|
|
371
|
+
get editRanges(): { startLine: number; endLine: number; }[] | undefined
|
|
372
|
+
{
|
|
373
|
+
return this.data.editRanges;
|
|
374
|
+
}
|
|
375
|
+
get addedLines(): number | undefined
|
|
376
|
+
{
|
|
377
|
+
return this.data.addedLines;
|
|
378
|
+
}
|
|
379
|
+
get removedLines(): number | undefined
|
|
380
|
+
{
|
|
381
|
+
return this.data.removedLines;
|
|
382
|
+
}
|
|
383
|
+
get appliedPaths(): string[] | undefined
|
|
384
|
+
{
|
|
385
|
+
return this.data.appliedPaths;
|
|
386
|
+
}
|
|
387
|
+
get beforeContentMap(): Record<string, string | null> | undefined
|
|
388
|
+
{
|
|
389
|
+
return this.data.beforeContentMap;
|
|
390
|
+
}
|
|
391
|
+
get afterContent(): string | undefined
|
|
392
|
+
{
|
|
393
|
+
return this.data.afterContent;
|
|
394
|
+
}
|
|
395
|
+
get skipCount(): number
|
|
396
|
+
{
|
|
397
|
+
return this.data.skipCount ?? 0;
|
|
398
|
+
}
|
|
399
|
+
get staleEdits(): StaleEditInfo[]
|
|
400
|
+
{
|
|
401
|
+
return this.data.staleEdits ?? [];
|
|
402
|
+
}
|
|
403
|
+
get proposedDiff(): string | undefined
|
|
404
|
+
{
|
|
405
|
+
return this.data.proposedDiff;
|
|
406
|
+
}
|
|
407
|
+
get editIndex(): number | undefined
|
|
408
|
+
{
|
|
409
|
+
return this.data.editIndex;
|
|
410
|
+
}
|
|
411
|
+
get editIndices(): number[] | undefined
|
|
412
|
+
{
|
|
413
|
+
return this.data.editIndices;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
get staleDiagnostic(): StaleAnchorDiagnostic | undefined
|
|
417
|
+
{
|
|
418
|
+
return this.data.staleDiagnostic;
|
|
419
|
+
}
|
|
420
|
+
get fileChangedStatement(): string | undefined
|
|
421
|
+
{
|
|
422
|
+
return this.data.fileChangedStatement;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// ── Computed getters ──
|
|
426
|
+
|
|
427
|
+
/** All file paths touched by this mutation (created, edited, overwritten, or failed). */
|
|
428
|
+
get affectedPaths(): string[]
|
|
429
|
+
{
|
|
430
|
+
const set = new Set<string>();
|
|
431
|
+
|
|
432
|
+
for (const f of this.files)
|
|
433
|
+
{
|
|
434
|
+
set.add(f.path);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
for (const e of this.errors)
|
|
438
|
+
{
|
|
439
|
+
if (e.path)
|
|
440
|
+
{
|
|
441
|
+
set.add(e.path);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
for (const w of this.warnings)
|
|
446
|
+
{
|
|
447
|
+
if (w.file)
|
|
448
|
+
{
|
|
449
|
+
set.add(w.file);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return [...set];
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/** True if the mutation was successful AND produced actual changes. */
|
|
457
|
+
get didChange(): boolean
|
|
458
|
+
{
|
|
459
|
+
return this.ok && (this.files.length > 0 || this.diffs.length > 0);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** Files that were newly created. */
|
|
463
|
+
get createdFiles(): FileChange[]
|
|
464
|
+
{
|
|
465
|
+
return this.files.filter((f) => f.action === "created");
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** Files that were overwritten (write) or edited in-place (strict). */
|
|
469
|
+
get overwrittenFiles(): FileChange[]
|
|
470
|
+
{
|
|
471
|
+
return this.files.filter((f) => f.action === "overwritten" || f.action === "edited");
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** Number of stale anchor edits (derived from staleEdits). */
|
|
475
|
+
get staleCount(): number
|
|
476
|
+
{
|
|
477
|
+
return this.staleEdits.length;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Short human-readable summary.
|
|
482
|
+
*
|
|
483
|
+
* Examples:
|
|
484
|
+
* "3 files changed, +45/-12 lines"
|
|
485
|
+
* "Created 2 files"
|
|
486
|
+
* "Failed: STALE_ANCHOR — anchor hash mismatch"
|
|
487
|
+
*/
|
|
488
|
+
get summary(): string
|
|
489
|
+
{
|
|
490
|
+
if (!this.ok)
|
|
491
|
+
{
|
|
492
|
+
const first = this.errors[0];
|
|
493
|
+
|
|
494
|
+
if (first)
|
|
495
|
+
{
|
|
496
|
+
return `Failed: ${first.code ?? "ERROR"}${first.reason ? ` — ${first.reason}` : ""}`;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return "Mutation failed";
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (this.files.length === 0 && this.diffs.length === 0)
|
|
503
|
+
{
|
|
504
|
+
const paths = this.appliedPaths;
|
|
505
|
+
|
|
506
|
+
if (paths && paths.length > 0)
|
|
507
|
+
{
|
|
508
|
+
return `${paths.length} path${paths.length === 1 ? "" : "s"} affected`;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return "No changes";
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const created = this.createdFiles.length;
|
|
515
|
+
const edited = this.overwrittenFiles.length;
|
|
516
|
+
const parts: string[] = [];
|
|
517
|
+
|
|
518
|
+
if (created > 0)
|
|
519
|
+
{
|
|
520
|
+
parts.push(`Created ${created} ${created === 1 ? "file" : "files"}`);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (edited > 0)
|
|
524
|
+
{
|
|
525
|
+
parts.push(`Edited ${edited} ${edited === 1 ? "file" : "files"}`);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Count total +/- from diffs if available
|
|
529
|
+
if (this.diffs.length > 0)
|
|
530
|
+
{
|
|
531
|
+
let added = 0;
|
|
532
|
+
let removed = 0;
|
|
533
|
+
|
|
534
|
+
for (const diff of this.diffs)
|
|
535
|
+
{
|
|
536
|
+
for (const line of diff.split("\n"))
|
|
537
|
+
{
|
|
538
|
+
if (line.startsWith("+") && !line.startsWith("+++"))
|
|
539
|
+
{
|
|
540
|
+
added++;
|
|
541
|
+
}
|
|
542
|
+
else if (line.startsWith("-") && !line.startsWith("---"))
|
|
543
|
+
{
|
|
544
|
+
removed++;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (added > 0 || removed > 0)
|
|
550
|
+
{
|
|
551
|
+
parts.push(`+${added}/-${removed} lines`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return parts.join(", ");
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// ── Methods ──
|
|
559
|
+
|
|
560
|
+
/** Find the FileChange entry for a specific path, if any. */
|
|
561
|
+
getFileChange(path: string): FileChange | undefined
|
|
562
|
+
{
|
|
563
|
+
return this.files.find((f) => f.path === path);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** Extract the unified diff for a specific file path, if present. */
|
|
567
|
+
getDiffFor(path: string): string | undefined
|
|
568
|
+
{
|
|
569
|
+
const normalised = normalisePath(path);
|
|
570
|
+
|
|
571
|
+
for (const diff of this.diffs)
|
|
572
|
+
{
|
|
573
|
+
const match = diff.match(/^---\s+(.+)$/m);
|
|
574
|
+
|
|
575
|
+
if (match && (normalisePath(match[1]!) === normalised || match[1] === path))
|
|
576
|
+
{
|
|
577
|
+
return diff;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return undefined;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/** All errors that relate to a specific path. */
|
|
585
|
+
getErrorsFor(path: string): FileError[]
|
|
586
|
+
{
|
|
587
|
+
return this.errors.filter((e) => e.path === path);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/** All warnings that relate to a specific path. */
|
|
591
|
+
getWarningsFor(path: string): Warning[]
|
|
592
|
+
{
|
|
593
|
+
return this.warnings.filter((w) => w.file === path);
|
|
594
|
+
}
|
|
595
|
+
/** Create a FileMutationResult from a KnownEditFailure options. */
|
|
596
|
+
static fromFailureOptions(opts: EditFailureOptions): FileMutationResult
|
|
597
|
+
{
|
|
598
|
+
return new FileMutationResult({
|
|
599
|
+
ok: false,
|
|
600
|
+
path: opts.path,
|
|
601
|
+
errors: [{ path: opts.path, code: opts.code, reason: opts.reason }],
|
|
602
|
+
failurePoint: opts.failurePoint,
|
|
603
|
+
recovery: opts.recovery,
|
|
604
|
+
expectedAnchor: opts.expectedAnchor,
|
|
605
|
+
currentAnchor: opts.currentAnchor,
|
|
606
|
+
freshAnchors: opts.freshLines ? [...opts.freshLines] : undefined,
|
|
607
|
+
internalErrorType: opts.internalError instanceof Error ? opts.internalError.name : undefined,
|
|
608
|
+
internalErrorMessage: opts.internalError instanceof Error ? opts.internalError.message : undefined,
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Ensures a value is a proper FileMutationResult instance.
|
|
614
|
+
* JSON.parse strips the prototype, making getters (createdFiles, diffs, etc.)
|
|
615
|
+
* inaccessible. This restores the instance without copying data.
|
|
616
|
+
*/
|
|
617
|
+
static ensure(value: unknown): FileMutationResult
|
|
618
|
+
{
|
|
619
|
+
if (value instanceof FileMutationResult)
|
|
620
|
+
{
|
|
621
|
+
return value;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (value && typeof value === "object")
|
|
625
|
+
{
|
|
626
|
+
const obj = value as Record<string, unknown>;
|
|
627
|
+
|
|
628
|
+
// After JSON.parse: { data: { ok, files, ... } }
|
|
629
|
+
if (obj.data && typeof obj.data === "object")
|
|
630
|
+
{
|
|
631
|
+
Object.setPrototypeOf(obj, FileMutationResult.prototype);
|
|
632
|
+
return obj as unknown as FileMutationResult;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// Raw FileMutationData — construct fresh
|
|
636
|
+
return new FileMutationResult(obj);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
return new FileMutationResult();
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// ─── Module-level helpers ────────────────────────────────────────────────
|
|
644
|
+
|
|
645
|
+
function normalisePath(p: string): string
|
|
646
|
+
{
|
|
647
|
+
return p.replace(/\\/g, "/").replace(/^a\//, "").replace(/^b\//, "");
|
|
648
|
+
}
|