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,217 @@
|
|
|
1
|
+
import { isResourceResolver, type ResourceResolver } from "pi-agent-resource";
|
|
2
|
+
import {
|
|
3
|
+
isTextAnchorResolver,
|
|
4
|
+
type TextAnchorRejection,
|
|
5
|
+
type TextAnchorResolver,
|
|
6
|
+
type TextPresenterRegistration,
|
|
7
|
+
} from "pi-agent-text";
|
|
8
|
+
import { Type } from "typebox";
|
|
9
|
+
import { Value } from "typebox/value";
|
|
10
|
+
|
|
11
|
+
import type { TextAnchorInspectionOutcome, TextAnchorInspectionRequest } from "#src/api/anchor-inspection.js";
|
|
12
|
+
import type { TextEditCompletionListener } from "#src/api/edit-completion.js";
|
|
13
|
+
import type { TextEditorToolPluginApi } from "#src/api/edit-pipeline.js";
|
|
14
|
+
import type { TextMutationGuardRegistration } from "#src/api/mutation-guard.js";
|
|
15
|
+
import type { TextMutationPreviewOutcome, TextMutationPreviewRequest } from "#src/api/mutation-preview.js";
|
|
16
|
+
import type { TextMutationToolListener, TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
17
|
+
import type { TextEditorToolRendererRegistration } from "#src/api/tool-renderer.js";
|
|
18
|
+
|
|
19
|
+
export const TEXT_EDITOR_PROTOCOL = "pi-agent-text-editor";
|
|
20
|
+
|
|
21
|
+
export const TEXT_EDITOR_API_VERSION = 15;
|
|
22
|
+
|
|
23
|
+
export const TEXT_POSITION_ANCHOR_KIND = "pi-agent-text-editor/position";
|
|
24
|
+
|
|
25
|
+
export const TEXT_SEARCH_ANCHOR_KIND = "pi-agent-text-editor/search";
|
|
26
|
+
|
|
27
|
+
export const TEXT_EDITOR_CORE_READY_EVENT = `${TEXT_EDITOR_PROTOCOL}/core/ready`;
|
|
28
|
+
|
|
29
|
+
export const TEXT_EDITOR_PLUGIN_REGISTER_EVENT = `${TEXT_EDITOR_PROTOCOL}/plugin/register`;
|
|
30
|
+
|
|
31
|
+
export type TextEditorToolId = string;
|
|
32
|
+
|
|
33
|
+
export type PromptDescriptionSource = string | (() => string | undefined);
|
|
34
|
+
|
|
35
|
+
export interface ResourceResolverRegistration
|
|
36
|
+
{
|
|
37
|
+
readonly resolver: ResourceResolver;
|
|
38
|
+
readonly priority?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type TextAnchorType = "major" | "auxiliary" | "constant";
|
|
42
|
+
|
|
43
|
+
export interface TextAnchorResourceResolverContext
|
|
44
|
+
{
|
|
45
|
+
readonly cwd: string;
|
|
46
|
+
readonly signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type TextAnchorResourceResolutionAttempt =
|
|
50
|
+
| { readonly kind: "not-handled"; }
|
|
51
|
+
| { readonly kind: "resolved"; readonly sources: readonly string[]; }
|
|
52
|
+
| { readonly kind: "rejected"; readonly rejection: TextAnchorRejection; }
|
|
53
|
+
| { readonly kind: "failed"; readonly error: unknown; };
|
|
54
|
+
|
|
55
|
+
export interface TextAnchorResourceResolver
|
|
56
|
+
{
|
|
57
|
+
tryResolve(
|
|
58
|
+
value: string,
|
|
59
|
+
context: TextAnchorResourceResolverContext,
|
|
60
|
+
): TextAnchorResourceResolutionAttempt | Promise<TextAnchorResourceResolutionAttempt>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface TextAnchorResolverRegistration
|
|
64
|
+
{
|
|
65
|
+
readonly resolver: TextAnchorResolver;
|
|
66
|
+
readonly resources?: TextAnchorResourceResolver;
|
|
67
|
+
readonly kind: string;
|
|
68
|
+
readonly type: TextAnchorType;
|
|
69
|
+
readonly priority?: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface TextEditorCoreReady
|
|
73
|
+
{
|
|
74
|
+
readonly protocol: typeof TEXT_EDITOR_PROTOCOL;
|
|
75
|
+
readonly apiVersion: typeof TEXT_EDITOR_API_VERSION;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface TextEditorPluginApi
|
|
79
|
+
{
|
|
80
|
+
addResolver(registration: ResourceResolverRegistration): void;
|
|
81
|
+
inspectTextAnchors(request: TextAnchorInspectionRequest): Promise<TextAnchorInspectionOutcome>;
|
|
82
|
+
addAnchorResolver(registration: TextAnchorResolverRegistration): void;
|
|
83
|
+
addTextPresenter(registration: TextPresenterRegistration): void;
|
|
84
|
+
addMutationTool(registration: TextMutationToolRegistration): void;
|
|
85
|
+
addMutationGuard(registration: TextMutationGuardRegistration): void;
|
|
86
|
+
addToolRenderer(registration: TextEditorToolRendererRegistration): void;
|
|
87
|
+
onMutationTool(listener: TextMutationToolListener): () => void;
|
|
88
|
+
onDidEdit(listener: TextEditCompletionListener): () => void;
|
|
89
|
+
previewMutation(request: TextMutationPreviewRequest): Promise<TextMutationPreviewOutcome>;
|
|
90
|
+
describe(description: PromptDescriptionSource): void;
|
|
91
|
+
tool(tool: TextEditorToolId): TextEditorToolPluginApi;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface TextEditorPlugin
|
|
95
|
+
{
|
|
96
|
+
readonly protocol: typeof TEXT_EDITOR_PROTOCOL;
|
|
97
|
+
readonly apiVersion: typeof TEXT_EDITOR_API_VERSION;
|
|
98
|
+
readonly id: string;
|
|
99
|
+
readonly setup: (api: TextEditorPluginApi) => void | Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface TextEditorPluginRegistrationRequest
|
|
103
|
+
{
|
|
104
|
+
readonly plugin: TextEditorPlugin;
|
|
105
|
+
accept(registration: Promise<void>): void;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const functionSchema = Type.Function([], Type.Unknown());
|
|
109
|
+
const textAnchorResourceResolverSchema = Type.Object({ tryResolve: functionSchema }, { additionalProperties: true });
|
|
110
|
+
const textAnchorResourceResolutionAttemptSchema = Type.Union([
|
|
111
|
+
Type.Object({ kind: Type.Literal("not-handled") }, { additionalProperties: true }),
|
|
112
|
+
Type.Object({
|
|
113
|
+
kind: Type.Literal("resolved"),
|
|
114
|
+
sources: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
|
|
115
|
+
}, { additionalProperties: true }),
|
|
116
|
+
Type.Object({
|
|
117
|
+
kind: Type.Literal("rejected"),
|
|
118
|
+
rejection: Type.Object({
|
|
119
|
+
code: Type.Union([
|
|
120
|
+
Type.Literal("invalid"),
|
|
121
|
+
Type.Literal("stale"),
|
|
122
|
+
Type.Literal("missing"),
|
|
123
|
+
Type.Literal("ambiguous"),
|
|
124
|
+
]),
|
|
125
|
+
reason: Type.String(),
|
|
126
|
+
contextRange: Type.Optional(Type.Object({
|
|
127
|
+
offset: Type.Number(),
|
|
128
|
+
limit: Type.Number(),
|
|
129
|
+
})),
|
|
130
|
+
}),
|
|
131
|
+
}, { additionalProperties: true }),
|
|
132
|
+
Type.Object({
|
|
133
|
+
kind: Type.Literal("failed"),
|
|
134
|
+
error: Type.Unknown(),
|
|
135
|
+
}, { additionalProperties: true }),
|
|
136
|
+
]);
|
|
137
|
+
const textEditorToolIdSchema = Type.String({ pattern: "\\S" });
|
|
138
|
+
const resourceResolverRegistrationSchema = Type.Object({
|
|
139
|
+
resolver: Type.Unknown(),
|
|
140
|
+
priority: Type.Optional(Type.Number()),
|
|
141
|
+
});
|
|
142
|
+
const textAnchorResolverRegistrationSchema = Type.Object({
|
|
143
|
+
resolver: Type.Unknown(),
|
|
144
|
+
resources: Type.Optional(Type.Unknown()),
|
|
145
|
+
kind: Type.String({ pattern: "\\S" }),
|
|
146
|
+
type: Type.Union([Type.Literal("major"), Type.Literal("auxiliary"), Type.Literal("constant")]),
|
|
147
|
+
priority: Type.Optional(Type.Number()),
|
|
148
|
+
});
|
|
149
|
+
const textEditorCoreReadySchema = Type.Object({
|
|
150
|
+
protocol: Type.Literal(TEXT_EDITOR_PROTOCOL),
|
|
151
|
+
apiVersion: Type.Literal(TEXT_EDITOR_API_VERSION),
|
|
152
|
+
});
|
|
153
|
+
const textEditorPluginSchema = Type.Object({
|
|
154
|
+
protocol: Type.Literal(TEXT_EDITOR_PROTOCOL),
|
|
155
|
+
apiVersion: Type.Literal(TEXT_EDITOR_API_VERSION),
|
|
156
|
+
id: Type.String(),
|
|
157
|
+
setup: functionSchema,
|
|
158
|
+
});
|
|
159
|
+
const textEditorPluginRegistrationRequestSchema = Type.Object({
|
|
160
|
+
plugin: textEditorPluginSchema,
|
|
161
|
+
accept: functionSchema,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
export function isTextEditorToolId(value: unknown): value is TextEditorToolId
|
|
165
|
+
{
|
|
166
|
+
return Value.Check(textEditorToolIdSchema, value);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function isResourceResolverRegistration(value: unknown): value is ResourceResolverRegistration
|
|
170
|
+
{
|
|
171
|
+
if (!Value.Check(resourceResolverRegistrationSchema, value))
|
|
172
|
+
{
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const registration = value as Record<PropertyKey, unknown>;
|
|
177
|
+
return isResourceResolver(registration.resolver)
|
|
178
|
+
&& (!("priority" in registration) || typeof registration.priority === "number");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function isTextAnchorResolverRegistration(value: unknown): value is TextAnchorResolverRegistration
|
|
182
|
+
{
|
|
183
|
+
if (!Value.Check(textAnchorResolverRegistrationSchema, value))
|
|
184
|
+
{
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const registration = value as Record<PropertyKey, unknown>;
|
|
189
|
+
return isTextAnchorResolver(registration.resolver)
|
|
190
|
+
&& (!("resources" in registration)
|
|
191
|
+
|| Value.Check(textAnchorResourceResolverSchema, registration.resources))
|
|
192
|
+
&& (!("priority" in registration) || typeof registration.priority === "number");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function isTextAnchorResourceResolutionAttempt(
|
|
196
|
+
value: unknown,
|
|
197
|
+
): value is TextAnchorResourceResolutionAttempt
|
|
198
|
+
{
|
|
199
|
+
return Value.Check(textAnchorResourceResolutionAttemptSchema, value);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function isTextEditorCoreReady(value: unknown): value is TextEditorCoreReady
|
|
203
|
+
{
|
|
204
|
+
return Value.Check(textEditorCoreReadySchema, value);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function isTextEditorPlugin(value: unknown): value is TextEditorPlugin
|
|
208
|
+
{
|
|
209
|
+
return Value.Check(textEditorPluginSchema, value);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function isTextEditorPluginRegistrationRequest(
|
|
213
|
+
value: unknown,
|
|
214
|
+
): value is TextEditorPluginRegistrationRequest
|
|
215
|
+
{
|
|
216
|
+
return Value.Check(textEditorPluginRegistrationRequestSchema, value);
|
|
217
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
3
|
+
|
|
4
|
+
import { isTextEditorCoreReady, TEXT_EDITOR_CORE_READY_EVENT, TEXT_EDITOR_PROTOCOL } from "#src/api/plugin-protocol.js";
|
|
5
|
+
|
|
6
|
+
import type { DiagnosticHint, SyntaxErrorSummary, Warning } from "#src/api/mutation-result.js";
|
|
7
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import type { TextDocument } from "pi-agent-text";
|
|
9
|
+
|
|
10
|
+
export const TEXT_EDITOR_POST_EDIT_REGISTER_EVENT = `${TEXT_EDITOR_PROTOCOL}/post-edit/register`;
|
|
11
|
+
|
|
12
|
+
export interface TextPostEditTransaction
|
|
13
|
+
{
|
|
14
|
+
readonly source: string;
|
|
15
|
+
readonly resourceSource: string;
|
|
16
|
+
readonly resolvedBy: string;
|
|
17
|
+
readonly cwd: string;
|
|
18
|
+
readonly before: TextDocument;
|
|
19
|
+
readonly requestedAfter: TextDocument;
|
|
20
|
+
readonly signal?: AbortSignal;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface TextPostEditContribution
|
|
24
|
+
{
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly data: unknown;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TextMutationResultContributionData
|
|
30
|
+
{
|
|
31
|
+
readonly hints: DiagnosticHint[];
|
|
32
|
+
readonly scopeMarkers: Record<string, string[]>;
|
|
33
|
+
readonly warnings: Warning[];
|
|
34
|
+
readonly syntaxErrorSummary?: SyntaxErrorSummary;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type TextPostEditHandler = (transaction: TextPostEditTransaction) => unknown;
|
|
38
|
+
|
|
39
|
+
export interface TextPostEditHandlerRegistration
|
|
40
|
+
{
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly handler: TextPostEditHandler;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface TextPostEditHandlerRegistrationRequest
|
|
46
|
+
{
|
|
47
|
+
readonly registration: TextPostEditHandlerRegistration;
|
|
48
|
+
accept(dispose: () => void): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const functionSchema = Type.Function([], Type.Unknown());
|
|
52
|
+
const registrationSchema = Type.Object({
|
|
53
|
+
id: Type.String({ minLength: 1 }),
|
|
54
|
+
handler: functionSchema,
|
|
55
|
+
});
|
|
56
|
+
const registrationRequestSchema = Type.Object({
|
|
57
|
+
registration: registrationSchema,
|
|
58
|
+
accept: functionSchema,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export function isTextPostEditHandlerRegistration(
|
|
62
|
+
value: unknown,
|
|
63
|
+
): value is TextPostEditHandlerRegistration
|
|
64
|
+
{
|
|
65
|
+
return Value.Check(registrationSchema, value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function isTextPostEditHandlerRegistrationRequest(
|
|
69
|
+
value: unknown,
|
|
70
|
+
): value is TextPostEditHandlerRegistrationRequest
|
|
71
|
+
{
|
|
72
|
+
return Value.Check(registrationRequestSchema, value);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function isTextMutationResultContributionData(value: unknown): value is TextMutationResultContributionData
|
|
76
|
+
{
|
|
77
|
+
if (typeof value !== "object" || value === null)
|
|
78
|
+
{
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const data = value as Record<PropertyKey, unknown>;
|
|
83
|
+
|
|
84
|
+
return Array.isArray(data.hints)
|
|
85
|
+
&& typeof data.scopeMarkers === "object"
|
|
86
|
+
&& data.scopeMarkers !== null
|
|
87
|
+
&& Array.isArray(data.warnings);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function connectTextEditorPostEditHandler(
|
|
91
|
+
pi: ExtensionAPI,
|
|
92
|
+
registration: TextPostEditHandlerRegistration,
|
|
93
|
+
): void
|
|
94
|
+
{
|
|
95
|
+
if (!isTextPostEditHandlerRegistration(registration))
|
|
96
|
+
{
|
|
97
|
+
throw new TypeError("Invalid text editor post-edit handler registration");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let disposeHandler: (() => void) | undefined;
|
|
101
|
+
const announce = (): boolean =>
|
|
102
|
+
{
|
|
103
|
+
const request = {
|
|
104
|
+
registration,
|
|
105
|
+
accept(dispose): void
|
|
106
|
+
{
|
|
107
|
+
if (disposeHandler !== undefined)
|
|
108
|
+
{
|
|
109
|
+
throw new Error(`Post-edit handler ${registration.id} was accepted more than once`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
disposeHandler = dispose;
|
|
113
|
+
},
|
|
114
|
+
} satisfies TextPostEditHandlerRegistrationRequest;
|
|
115
|
+
|
|
116
|
+
pi.events.emit(TEXT_EDITOR_POST_EDIT_REGISTER_EVENT, request);
|
|
117
|
+
return disposeHandler !== undefined;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
let unsubscribeReady = (): void =>
|
|
121
|
+
{};
|
|
122
|
+
unsubscribeReady = pi.events.on(TEXT_EDITOR_CORE_READY_EVENT, (ready) =>
|
|
123
|
+
{
|
|
124
|
+
if (!isTextEditorCoreReady(ready))
|
|
125
|
+
{
|
|
126
|
+
throw new Error("Invalid pi-agent-text-editor core readiness event");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!announce())
|
|
130
|
+
{
|
|
131
|
+
throw new Error("pi-agent-text-editor core announced readiness without accepting the post-edit handler");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
unsubscribeReady();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
pi.on("session_shutdown", () =>
|
|
138
|
+
{
|
|
139
|
+
unsubscribeReady();
|
|
140
|
+
disposeHandler?.();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
if (announce())
|
|
144
|
+
{
|
|
145
|
+
unsubscribeReady();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface StaleAnchorMessageDetails
|
|
2
|
+
{
|
|
3
|
+
readonly guardId: "stale-anchor";
|
|
4
|
+
readonly effect: "not-applied";
|
|
5
|
+
readonly toolName: string;
|
|
6
|
+
readonly field: string;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly anchor: string;
|
|
9
|
+
readonly context?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function formatStaleAnchorMessage(details: StaleAnchorMessageDetails, reason: string): string
|
|
13
|
+
{
|
|
14
|
+
const context = details.context === undefined ? "" : `\n\n${details.context}`;
|
|
15
|
+
return `[SYSTEM] ${details.toolName} blocked: ${details.field} anchor "${details.anchor}" is stale. `
|
|
16
|
+
+ `If the required line is represented by one of the context lines below, use that anchor. Otherwise, reread only the relevant section of "${details.path}" and regenerate the anchor. (${reason})${context}`;
|
|
17
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { TextAnchor } from "pi-agent-text";
|
|
2
|
+
|
|
3
|
+
const textSelectionAnchorBrand = Symbol.for("pi-agent-text-editor/TextSelectionAnchor");
|
|
4
|
+
|
|
5
|
+
export interface TextSelectionPosition
|
|
6
|
+
{
|
|
7
|
+
readonly lineNumber: number;
|
|
8
|
+
readonly column: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface TextSelectionRange
|
|
12
|
+
{
|
|
13
|
+
readonly start: TextSelectionPosition;
|
|
14
|
+
readonly end: TextSelectionPosition;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class TextSelectionAnchor extends TextAnchor
|
|
18
|
+
{
|
|
19
|
+
readonly [textSelectionAnchorBrand] = true;
|
|
20
|
+
public readonly ranges: readonly TextSelectionRange[];
|
|
21
|
+
|
|
22
|
+
public static is(value: unknown): value is TextSelectionAnchor
|
|
23
|
+
{
|
|
24
|
+
if (!TextAnchor.is(value))
|
|
25
|
+
{
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try
|
|
30
|
+
{
|
|
31
|
+
const candidate = value as unknown as Record<PropertyKey, unknown>;
|
|
32
|
+
const ranges = candidate.ranges;
|
|
33
|
+
return candidate[textSelectionAnchorBrand] === true
|
|
34
|
+
&& typeof candidate.source === "string"
|
|
35
|
+
&& candidate.source.length > 0
|
|
36
|
+
&& Array.isArray(ranges)
|
|
37
|
+
&& ranges.length > 0
|
|
38
|
+
&& ranges.every(isTextSelectionRange);
|
|
39
|
+
}
|
|
40
|
+
catch
|
|
41
|
+
{
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public constructor(
|
|
47
|
+
value: string,
|
|
48
|
+
readonly source: string,
|
|
49
|
+
ranges: readonly TextSelectionRange[],
|
|
50
|
+
)
|
|
51
|
+
{
|
|
52
|
+
const copied = ranges.map((range) => ({
|
|
53
|
+
start: { ...range.start },
|
|
54
|
+
end: { ...range.end },
|
|
55
|
+
}));
|
|
56
|
+
assertSelectionRanges(copied);
|
|
57
|
+
super(value, copied[0]!.start.lineNumber);
|
|
58
|
+
|
|
59
|
+
if (source.length === 0)
|
|
60
|
+
{
|
|
61
|
+
throw new TypeError("Text selection anchor source must be non-empty");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.ranges = copied;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function assertSelectionRanges(ranges: readonly TextSelectionRange[]): void
|
|
69
|
+
{
|
|
70
|
+
if (ranges.length === 0)
|
|
71
|
+
{
|
|
72
|
+
throw new TypeError("Text selection anchor must contain at least one range");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let previous: TextSelectionRange | undefined;
|
|
76
|
+
|
|
77
|
+
for (const range of ranges)
|
|
78
|
+
{
|
|
79
|
+
if (!isTextSelectionRange(range) || comparePositions(range.start, range.end) > 0)
|
|
80
|
+
{
|
|
81
|
+
throw new RangeError("Text selection anchor contains an invalid range");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (previous !== undefined && comparePositions(range.start, previous.end) < 0)
|
|
85
|
+
{
|
|
86
|
+
throw new Error("Text selection anchor ranges must be ordered and must not overlap");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
previous = range;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function isTextSelectionRange(value: unknown): value is TextSelectionRange
|
|
94
|
+
{
|
|
95
|
+
if (typeof value !== "object" || value === null)
|
|
96
|
+
{
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const candidate = value as Partial<TextSelectionRange>;
|
|
101
|
+
return isTextSelectionPosition(candidate.start) && isTextSelectionPosition(candidate.end);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function isTextSelectionPosition(value: unknown): value is TextSelectionPosition
|
|
105
|
+
{
|
|
106
|
+
if (typeof value !== "object" || value === null)
|
|
107
|
+
{
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const candidate = value as Partial<TextSelectionPosition>;
|
|
112
|
+
return Number.isSafeInteger(candidate.lineNumber)
|
|
113
|
+
&& (candidate.lineNumber ?? 0) >= 1
|
|
114
|
+
&& Number.isSafeInteger(candidate.column)
|
|
115
|
+
&& (candidate.column ?? -1) >= 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function comparePositions(left: TextSelectionPosition, right: TextSelectionPosition): number
|
|
119
|
+
{
|
|
120
|
+
return left.lineNumber - right.lineNumber || left.column - right.column;
|
|
121
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export {
|
|
2
|
+
getToolCallInterception,
|
|
3
|
+
type InterceptorContext,
|
|
4
|
+
type InterceptResult,
|
|
5
|
+
registerToolCallAnnotationSink,
|
|
6
|
+
registerToolCallInterceptor,
|
|
7
|
+
type ToolCallAnnotation,
|
|
8
|
+
type ToolCallAnnotationSink,
|
|
9
|
+
type ToolCallInterceptionDetails,
|
|
10
|
+
type ToolCallInterceptorHandler,
|
|
11
|
+
} from "../core/tool-call-interceptor/coordinator.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type TSchema, Type } from "typebox";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
3
|
+
|
|
4
|
+
import type { FileMutationBatchResult } from "#src/api/mutation-result.js";
|
|
5
|
+
import type { TextEditorToolId } from "#src/api/plugin-protocol.js";
|
|
6
|
+
import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
|
|
8
|
+
type TextEditorRenderedTool = ToolDefinition<TSchema, FileMutationBatchResult>;
|
|
9
|
+
|
|
10
|
+
export type TextEditorToolRendererRegistration =
|
|
11
|
+
& Pick<
|
|
12
|
+
TextEditorRenderedTool,
|
|
13
|
+
"renderCall" | "renderResult" | "renderShell"
|
|
14
|
+
>
|
|
15
|
+
& {
|
|
16
|
+
readonly tool: TextEditorToolId;
|
|
17
|
+
readonly fallback?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const rendererFunctionSchema = Type.Function([], Type.Unknown());
|
|
21
|
+
const toolRendererRegistrationSchema = Type.Object({
|
|
22
|
+
tool: Type.String({ pattern: "\\S" }),
|
|
23
|
+
fallback: Type.Optional(Type.Boolean()),
|
|
24
|
+
renderCall: Type.Optional(rendererFunctionSchema),
|
|
25
|
+
renderResult: Type.Optional(rendererFunctionSchema),
|
|
26
|
+
renderShell: Type.Optional(Type.Union([Type.Literal("default"), Type.Literal("self")])),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export function isTextEditorToolRendererRegistration(
|
|
30
|
+
value: unknown,
|
|
31
|
+
): value is TextEditorToolRendererRegistration
|
|
32
|
+
{
|
|
33
|
+
if (!Value.Check(toolRendererRegistrationSchema, value))
|
|
34
|
+
{
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return value.renderCall !== undefined || value.renderResult !== undefined;
|
|
39
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
|
|
5
|
+
function isRecord(value: unknown): value is Record<string, unknown>
|
|
6
|
+
{
|
|
7
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function toolName(tool: unknown): string | undefined
|
|
11
|
+
{
|
|
12
|
+
if (!isRecord(tool))
|
|
13
|
+
{
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (typeof tool.name === "string")
|
|
18
|
+
{
|
|
19
|
+
return tool.name;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return isRecord(tool.function) && typeof tool.function.name === "string"
|
|
23
|
+
? tool.function.name
|
|
24
|
+
: undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Replace Pi's built-in edit metadata and remove its tool schema from provider requests. */
|
|
28
|
+
export function registerBuiltinEditFilter(pi: ExtensionAPI): void
|
|
29
|
+
{
|
|
30
|
+
pi.registerTool({
|
|
31
|
+
name: "edit",
|
|
32
|
+
label: "edit",
|
|
33
|
+
description: "",
|
|
34
|
+
promptGuidelines: [
|
|
35
|
+
"Use write, replace, insert, delete, copy, and move for text edits.",
|
|
36
|
+
"Independent mutations in one tool-call block run as one transaction against the original files.",
|
|
37
|
+
"Use replace for existing text and write only for a complete file.",
|
|
38
|
+
"An omitted mutation source inherits the last resolved resource or previous source in the same batch. Write requires path; copy and move targets default to their source.",
|
|
39
|
+
"Mutation results include diagnostics and hints.",
|
|
40
|
+
],
|
|
41
|
+
parameters: Type.Object({}, { additionalProperties: false }),
|
|
42
|
+
execute()
|
|
43
|
+
{
|
|
44
|
+
throw new Error("edit is not available.");
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
pi.on("before_provider_request", (event) =>
|
|
48
|
+
{
|
|
49
|
+
if (!isRecord(event.payload) || !Array.isArray(event.payload.tools))
|
|
50
|
+
{
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
...event.payload,
|
|
56
|
+
tools: event.payload.tools.filter((tool) => toolName(tool) !== "edit"),
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|