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,149 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { URI } from "vscode-uri";
|
|
4
|
+
|
|
5
|
+
import { LspManager } from "./manager.js";
|
|
6
|
+
import { requestReferences } from "./navigation.js";
|
|
7
|
+
import { type LspWorkspaceSymbol, requestWorkspaceSymbols } from "./symbols.js";
|
|
8
|
+
|
|
9
|
+
export interface SymbolHit
|
|
10
|
+
{
|
|
11
|
+
filePath: string;
|
|
12
|
+
lineNumber: number;
|
|
13
|
+
column: number;
|
|
14
|
+
kind: string;
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function uriToFilePath(uri: string): string
|
|
19
|
+
{
|
|
20
|
+
try
|
|
21
|
+
{
|
|
22
|
+
return URI.parse(uri).fsPath;
|
|
23
|
+
}
|
|
24
|
+
catch
|
|
25
|
+
{
|
|
26
|
+
return uri.startsWith("file://") ? decodeURIComponent(uri.slice(7)) : uri;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function toHit(cwd: string, symbol: LspWorkspaceSymbol, uri: string, line: number, character: number): SymbolHit
|
|
31
|
+
{
|
|
32
|
+
const filePath = uriToFilePath(uri);
|
|
33
|
+
const relativePath = path.relative(cwd, filePath);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
filePath: relativePath.startsWith("..") ? filePath : relativePath,
|
|
37
|
+
lineNumber: line + 1,
|
|
38
|
+
column: character + 1,
|
|
39
|
+
kind: String(symbol.kind),
|
|
40
|
+
name: symbol.name,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Search workspace symbols and their references through native LSP servers. */
|
|
45
|
+
export async function searchSymbols(
|
|
46
|
+
query: string,
|
|
47
|
+
cwd: string,
|
|
48
|
+
limit: number,
|
|
49
|
+
signal?: AbortSignal,
|
|
50
|
+
): Promise<SymbolHit[]>
|
|
51
|
+
{
|
|
52
|
+
if (signal?.aborted)
|
|
53
|
+
{
|
|
54
|
+
throw new Error("Operation aborted");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const manager = LspManager.getInstance();
|
|
58
|
+
const clients = await manager.prepareWorkspaceSymbols(cwd);
|
|
59
|
+
const definitions: LspWorkspaceSymbol[] = [];
|
|
60
|
+
|
|
61
|
+
for (const client of clients)
|
|
62
|
+
{
|
|
63
|
+
if (signal?.aborted)
|
|
64
|
+
{
|
|
65
|
+
throw new Error("Operation aborted");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try
|
|
69
|
+
{
|
|
70
|
+
definitions.push(...await requestWorkspaceSymbols(client, query, limit));
|
|
71
|
+
}
|
|
72
|
+
catch
|
|
73
|
+
{
|
|
74
|
+
// A server without workspace/symbol support cannot contribute results.
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const seen = new Set<string>();
|
|
79
|
+
const hits: SymbolHit[] = [];
|
|
80
|
+
|
|
81
|
+
for (const symbol of definitions)
|
|
82
|
+
{
|
|
83
|
+
if (signal?.aborted)
|
|
84
|
+
{
|
|
85
|
+
throw new Error("Operation aborted");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (hits.length >= limit)
|
|
89
|
+
{
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const definition = symbol.location;
|
|
94
|
+
const definitionHit = toHit(
|
|
95
|
+
cwd,
|
|
96
|
+
symbol,
|
|
97
|
+
definition.uri,
|
|
98
|
+
definition.range.start.line,
|
|
99
|
+
definition.range.start.character,
|
|
100
|
+
);
|
|
101
|
+
const definitionKey = `${definitionHit.filePath}:${definitionHit.lineNumber}:${definitionHit.column}`;
|
|
102
|
+
|
|
103
|
+
if (!seen.has(definitionKey))
|
|
104
|
+
{
|
|
105
|
+
seen.add(definitionKey);
|
|
106
|
+
hits.push(definitionHit);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (hits.length >= limit)
|
|
110
|
+
{
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const sourcePath = uriToFilePath(definition.uri);
|
|
115
|
+
const opened = await manager.openFile(sourcePath, cwd, "symbols").catch(() => null);
|
|
116
|
+
|
|
117
|
+
if (!opened)
|
|
118
|
+
{
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const references = await requestReferences(opened.client, opened.uri, definition.range.start).catch(() => []);
|
|
123
|
+
|
|
124
|
+
for (const reference of references)
|
|
125
|
+
{
|
|
126
|
+
const hit = toHit(
|
|
127
|
+
cwd,
|
|
128
|
+
symbol,
|
|
129
|
+
reference.uri,
|
|
130
|
+
reference.range.start.line,
|
|
131
|
+
reference.range.start.character,
|
|
132
|
+
);
|
|
133
|
+
const key = `${hit.filePath}:${hit.lineNumber}:${hit.column}`;
|
|
134
|
+
|
|
135
|
+
if (!seen.has(key))
|
|
136
|
+
{
|
|
137
|
+
seen.add(key);
|
|
138
|
+
hits.push(hit);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (hits.length >= limit)
|
|
142
|
+
{
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return hits;
|
|
149
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LSP document symbol queries — textDocument/documentSymbol.
|
|
3
|
+
*
|
|
4
|
+
* Language-agnostic — works with any LSP server that supports
|
|
5
|
+
* documentSymbolProvider.
|
|
6
|
+
*/
|
|
7
|
+
import type { LspClient } from "./client.js";
|
|
8
|
+
import type { LspManager } from "./manager.js";
|
|
9
|
+
import type { LspRange } from "./types.js";
|
|
10
|
+
|
|
11
|
+
// ── Types ────────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
/** Raw LSP DocumentSymbol, as returned by the server. */
|
|
14
|
+
export interface LspDocumentSymbol
|
|
15
|
+
{
|
|
16
|
+
name: string;
|
|
17
|
+
kind: number;
|
|
18
|
+
/** Range may be missing from some LSP servers (incomplete data). */
|
|
19
|
+
range?: LspRange;
|
|
20
|
+
selectionRange?: LspRange;
|
|
21
|
+
children?: LspDocumentSymbol[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ── SymbolKind name mapping (LSP 3.17) ───────────────────────────────
|
|
25
|
+
|
|
26
|
+
const SYMBOL_KIND_NAMES: Record<number, string> = {
|
|
27
|
+
1: "File",
|
|
28
|
+
2: "Module",
|
|
29
|
+
3: "Namespace",
|
|
30
|
+
4: "Package",
|
|
31
|
+
5: "Class",
|
|
32
|
+
6: "Method",
|
|
33
|
+
7: "Property",
|
|
34
|
+
8: "Field",
|
|
35
|
+
9: "Constructor",
|
|
36
|
+
10: "Enum",
|
|
37
|
+
11: "Interface",
|
|
38
|
+
12: "Function",
|
|
39
|
+
13: "Variable",
|
|
40
|
+
14: "Constant",
|
|
41
|
+
15: "String",
|
|
42
|
+
16: "Number",
|
|
43
|
+
17: "Boolean",
|
|
44
|
+
18: "Array",
|
|
45
|
+
19: "Object",
|
|
46
|
+
20: "Key",
|
|
47
|
+
21: "Null",
|
|
48
|
+
22: "EnumMember",
|
|
49
|
+
23: "Struct",
|
|
50
|
+
24: "Event",
|
|
51
|
+
25: "Operator",
|
|
52
|
+
26: "TypeParameter",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Convert an LSP SymbolKind number to its human-readable name. */
|
|
56
|
+
export function symbolKindName(kind: number): string
|
|
57
|
+
{
|
|
58
|
+
return SYMBOL_KIND_NAMES[kind] ?? `SymbolKind(${kind})`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ── Request document symbols ─────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Request hierarchical document symbols from an LSP server.
|
|
65
|
+
* Returns an empty array if the server returns null.
|
|
66
|
+
*/
|
|
67
|
+
export async function requestDocumentSymbols(
|
|
68
|
+
client: LspClient,
|
|
69
|
+
uri: string,
|
|
70
|
+
): Promise<LspDocumentSymbol[]>
|
|
71
|
+
{
|
|
72
|
+
const result = await client.sendRequest<LspDocumentSymbol[] | null>(
|
|
73
|
+
"textDocument/documentSymbol",
|
|
74
|
+
{ textDocument: { uri } },
|
|
75
|
+
);
|
|
76
|
+
return result ?? [];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Workspace symbol returned by the native LSP workspace/symbol request. */
|
|
80
|
+
export interface LspWorkspaceSymbol
|
|
81
|
+
{
|
|
82
|
+
name: string;
|
|
83
|
+
kind: number;
|
|
84
|
+
location: { uri: string; range: LspRange; };
|
|
85
|
+
containerName?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Request workspace symbols from one native LSP server. */
|
|
89
|
+
export async function requestWorkspaceSymbols(
|
|
90
|
+
client: LspClient,
|
|
91
|
+
query: string,
|
|
92
|
+
limit = 100,
|
|
93
|
+
): Promise<LspWorkspaceSymbol[]>
|
|
94
|
+
{
|
|
95
|
+
const result = await client.sendRequest<LspWorkspaceSymbol[] | null>("workspace/symbol", { query });
|
|
96
|
+
return (result ?? []).slice(0, limit);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Find the first workspace symbol across the native LSP clients for a workspace. */
|
|
100
|
+
export async function findWorkspaceSymbol(
|
|
101
|
+
manager: LspManager,
|
|
102
|
+
cwd: string,
|
|
103
|
+
query: string,
|
|
104
|
+
): Promise<{ client: LspClient; symbol: LspWorkspaceSymbol; } | undefined>
|
|
105
|
+
{
|
|
106
|
+
const clients = await manager.prepareWorkspaceSymbols(cwd);
|
|
107
|
+
|
|
108
|
+
for (const client of clients)
|
|
109
|
+
{
|
|
110
|
+
try
|
|
111
|
+
{
|
|
112
|
+
const symbols = await requestWorkspaceSymbols(client, query, 100);
|
|
113
|
+
const symbol = symbols.find((item) => item.name === query) ?? symbols[0];
|
|
114
|
+
|
|
115
|
+
if (symbol)
|
|
116
|
+
{
|
|
117
|
+
return { client, symbol };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch
|
|
121
|
+
{
|
|
122
|
+
// Try the next configured language server.
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Find a document symbol recursively by its exact name. */
|
|
130
|
+
export function findDocumentSymbol(
|
|
131
|
+
symbols: LspDocumentSymbol[],
|
|
132
|
+
name: string,
|
|
133
|
+
): LspDocumentSymbol | undefined
|
|
134
|
+
{
|
|
135
|
+
for (const symbol of symbols)
|
|
136
|
+
{
|
|
137
|
+
if (symbol.name === name)
|
|
138
|
+
{
|
|
139
|
+
return symbol;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const found = symbol.children ? findDocumentSymbol(symbol.children, name) : undefined;
|
|
143
|
+
|
|
144
|
+
if (found)
|
|
145
|
+
{
|
|
146
|
+
return found;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LSP layer types — server config and protocol features.
|
|
3
|
+
*
|
|
4
|
+
* Owned by the LSP extension. Not tied to any specific LSP server implementation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ── LSP protocol primitives ───────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
/** LSP DiagnosticSeverity: 1=Error, 2=Warning, 3=Information, 4=Hint. */
|
|
10
|
+
export const DiagnosticSeverity = {
|
|
11
|
+
Error: 1,
|
|
12
|
+
Warning: 2,
|
|
13
|
+
Information: 3,
|
|
14
|
+
Hint: 4,
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
export type DiagnosticSeverity = (typeof DiagnosticSeverity)[keyof typeof DiagnosticSeverity];
|
|
18
|
+
|
|
19
|
+
export interface LspPosition
|
|
20
|
+
{
|
|
21
|
+
/** 0-based line. */
|
|
22
|
+
line: number;
|
|
23
|
+
/** 0-based character (UTF-16 code units). */
|
|
24
|
+
character: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface LspRange
|
|
28
|
+
{
|
|
29
|
+
start: LspPosition;
|
|
30
|
+
end: LspPosition;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface LspDiagnostic
|
|
34
|
+
{
|
|
35
|
+
range: LspRange;
|
|
36
|
+
severity: DiagnosticSeverity;
|
|
37
|
+
code?: string | number;
|
|
38
|
+
source?: string;
|
|
39
|
+
message: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface LspTextEdit
|
|
43
|
+
{
|
|
44
|
+
range: LspRange;
|
|
45
|
+
newText: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ── Server configuration (data-driven) ─────────────────────────────────
|
|
49
|
+
|
|
50
|
+
export interface LanguageEntry
|
|
51
|
+
{
|
|
52
|
+
extensions: string[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type ServerCapability = "diagnostics";
|
|
56
|
+
|
|
57
|
+
export interface ServerConfig
|
|
58
|
+
{
|
|
59
|
+
command: string[];
|
|
60
|
+
rootMarkers: string[];
|
|
61
|
+
languages: Record<string, LanguageEntry>;
|
|
62
|
+
capabilities: ServerCapability[];
|
|
63
|
+
/** Passed as initializationOptions in the initialize request. */
|
|
64
|
+
initOptions?: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface LspServersConfig
|
|
68
|
+
{
|
|
69
|
+
servers: Record<string, ServerConfig>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── Resolved server info (registry output) ─────────────────────────────
|
|
73
|
+
|
|
74
|
+
export interface ResolvedServer
|
|
75
|
+
{
|
|
76
|
+
/** Server key from lsp-servers.json (e.g. "gopls"). */
|
|
77
|
+
serverId: string;
|
|
78
|
+
config: ServerConfig;
|
|
79
|
+
/** LanguageId this extension maps to (e.g. "go"). */
|
|
80
|
+
languageId: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ── Client state ───────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
export interface LspClientState
|
|
86
|
+
{
|
|
87
|
+
serverId: string;
|
|
88
|
+
command: string[];
|
|
89
|
+
/** Process PID. */
|
|
90
|
+
pid: number;
|
|
91
|
+
/** True when initialized and ready. */
|
|
92
|
+
ready: boolean;
|
|
93
|
+
/** Timestamp of last request (for idle timeout). */
|
|
94
|
+
lastActivity: number;
|
|
95
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { searchSymbols } from "./lsp/symbol-search.js";
|
|
2
|
+
|
|
3
|
+
import type { LspManager } from "./lsp/manager.js";
|
|
4
|
+
import type { SymbolHit } from "./lsp/symbol-search.js";
|
|
5
|
+
import type { SearchResolver } from "pi-agent-search/api/search";
|
|
6
|
+
|
|
7
|
+
export function createLspSearchResolver(managerFor: (cwd: string) => Promise<LspManager>): SearchResolver
|
|
8
|
+
{
|
|
9
|
+
return {
|
|
10
|
+
id: "lsp",
|
|
11
|
+
async tryResolve(request, context)
|
|
12
|
+
{
|
|
13
|
+
if (!request.query.startsWith("lsp:"))
|
|
14
|
+
{
|
|
15
|
+
return { kind: "not-handled" };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const query = request.query.slice("lsp:".length).trim();
|
|
19
|
+
|
|
20
|
+
if (query.length === 0)
|
|
21
|
+
{
|
|
22
|
+
return { kind: "failed", error: new Error("lsp: query must not be empty") };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
await managerFor(context.cwd);
|
|
26
|
+
const hits = await searchSymbols(query, context.cwd, request.limit ?? 100, context.signal);
|
|
27
|
+
return { kind: "resolved", payload: { query, hits } };
|
|
28
|
+
},
|
|
29
|
+
format(payload)
|
|
30
|
+
{
|
|
31
|
+
const { query, hits } = payload as { readonly query: string; readonly hits: readonly SymbolHit[]; };
|
|
32
|
+
const text = hits.length === 0
|
|
33
|
+
? "No LSP symbols found."
|
|
34
|
+
: hits.map((hit, index) =>
|
|
35
|
+
`${String(index + 1)}. ${hit.filePath}:${String(hit.lineNumber)}:${
|
|
36
|
+
String(hit.column)
|
|
37
|
+
} ${hit.kind} ${hit.name}`
|
|
38
|
+
).join("\n");
|
|
39
|
+
return { content: [{ type: "text", text }], details: { query, hits } };
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { Gate } from "#src/toolchain/gate.js";
|
|
4
|
+
import { getActiveToolchain, isToolchainReady, warmup } from "#src/toolchain/registry.js";
|
|
5
|
+
import { computeChangedRanges, type DiagnosticHint } from "pi-agent-text-editor/api/mutation-result";
|
|
6
|
+
|
|
7
|
+
import type { ActiveToolchain, Diagnostic, GateResult } from "#src/toolchain/types.js";
|
|
8
|
+
import type { TextMutationResultContributionData, TextPostEditTransaction } from "pi-agent-text-editor/api/post-edit";
|
|
9
|
+
|
|
10
|
+
const MAX_SYNTAX_ERRORS = 5;
|
|
11
|
+
const DIAGNOSTIC_SEVERITY_RANK: Record<Diagnostic["severity"], number> = {
|
|
12
|
+
error: 0,
|
|
13
|
+
warning: 1,
|
|
14
|
+
info: 2,
|
|
15
|
+
hint: 3,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type IdePostEditGateRunner = (
|
|
19
|
+
filePath: string,
|
|
20
|
+
toolchain: ActiveToolchain,
|
|
21
|
+
) => Promise<GateResult>;
|
|
22
|
+
|
|
23
|
+
export async function runIdePostEditGate(
|
|
24
|
+
transaction: TextPostEditTransaction,
|
|
25
|
+
runGate: IdePostEditGateRunner = runToolchainGate,
|
|
26
|
+
): Promise<TextMutationResultContributionData | undefined>
|
|
27
|
+
{
|
|
28
|
+
if (!path.isAbsolute(transaction.resourceSource))
|
|
29
|
+
{
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let toolchain = getActiveToolchain();
|
|
34
|
+
|
|
35
|
+
if (!isToolchainReady() || toolchain.ctx.cwd !== transaction.cwd)
|
|
36
|
+
{
|
|
37
|
+
toolchain = await warmup({ cwd: transaction.cwd });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const gateResult = await runGate(transaction.resourceSource, toolchain);
|
|
41
|
+
const fileResult = gateResult.files.find((result) => result.filePath === transaction.resourceSource);
|
|
42
|
+
const finalContent = fileResult?.finalContent ?? transaction.requestedAfter.content;
|
|
43
|
+
const finalLines = normalizedLines(finalContent);
|
|
44
|
+
const compile = fileResult?.compile;
|
|
45
|
+
const syntaxDiagnostics = compile?.syntaxErrors ?? [];
|
|
46
|
+
const hints: DiagnosticHint[] = [];
|
|
47
|
+
|
|
48
|
+
const addHint = (diagnostic: Diagnostic, source: string): void =>
|
|
49
|
+
{
|
|
50
|
+
if (!Number.isInteger(diagnostic.line) || diagnostic.line < 1 || diagnostic.line > finalLines.length)
|
|
51
|
+
{
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
hints.push({
|
|
56
|
+
file: transaction.source,
|
|
57
|
+
line: diagnostic.line,
|
|
58
|
+
column: diagnostic.column,
|
|
59
|
+
lineText: finalLines[diagnostic.line - 1] ?? "",
|
|
60
|
+
severity: diagnostic.severity,
|
|
61
|
+
source,
|
|
62
|
+
code: diagnostic.code,
|
|
63
|
+
message: diagnostic.message,
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
for (const diagnostic of syntaxDiagnostics)
|
|
68
|
+
{
|
|
69
|
+
addHint(diagnostic, "compiler");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (syntaxDiagnostics.length === 0)
|
|
73
|
+
{
|
|
74
|
+
const compilerDiagnostics = compile?.otherDiagnostics ?? [];
|
|
75
|
+
|
|
76
|
+
if (compilerDiagnostics.length > 0)
|
|
77
|
+
{
|
|
78
|
+
for (const diagnostic of compilerDiagnostics)
|
|
79
|
+
{
|
|
80
|
+
addHint(diagnostic, "compiler");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else
|
|
84
|
+
{
|
|
85
|
+
for (const diagnostic of fileResult?.lint.diagnostics ?? [])
|
|
86
|
+
{
|
|
87
|
+
addHint(diagnostic, "linter");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const shownSyntaxErrors = selectSyntaxDiagnostics(
|
|
93
|
+
syntaxDiagnostics,
|
|
94
|
+
transaction.before.content,
|
|
95
|
+
finalContent,
|
|
96
|
+
).length;
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
hints,
|
|
100
|
+
scopeMarkers: {},
|
|
101
|
+
warnings: [],
|
|
102
|
+
...(syntaxDiagnostics.length > MAX_SYNTAX_ERRORS
|
|
103
|
+
? { syntaxErrorSummary: { total: syntaxDiagnostics.length, shown: shownSyntaxErrors } }
|
|
104
|
+
: {}),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function runToolchainGate(filePath: string, toolchain: ActiveToolchain): Promise<GateResult>
|
|
109
|
+
{
|
|
110
|
+
return new Gate(toolchain).runAll([filePath]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function selectSyntaxDiagnostics(
|
|
114
|
+
diagnostics: readonly Diagnostic[],
|
|
115
|
+
beforeContent: string,
|
|
116
|
+
afterContent: string,
|
|
117
|
+
): Diagnostic[]
|
|
118
|
+
{
|
|
119
|
+
const changedRanges = computeChangedRanges(beforeContent, afterContent);
|
|
120
|
+
const visible = diagnostics.filter((diagnostic) =>
|
|
121
|
+
changedRanges.some((range) => diagnostic.line >= range.start && diagnostic.line <= range.end)
|
|
122
|
+
);
|
|
123
|
+
const hidden = diagnostics
|
|
124
|
+
.filter((diagnostic) => !visible.includes(diagnostic))
|
|
125
|
+
.sort(compareDiagnostics);
|
|
126
|
+
|
|
127
|
+
return [
|
|
128
|
+
...visible,
|
|
129
|
+
...hidden.slice(0, Math.max(0, MAX_SYNTAX_ERRORS - visible.length)),
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function compareDiagnostics(left: Diagnostic, right: Diagnostic): number
|
|
134
|
+
{
|
|
135
|
+
return DIAGNOSTIC_SEVERITY_RANK[left.severity] - DIAGNOSTIC_SEVERITY_RANK[right.severity]
|
|
136
|
+
|| left.line - right.line
|
|
137
|
+
|| left.column - right.column
|
|
138
|
+
|| left.code.localeCompare(right.code);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function normalizedLines(content: string): string[]
|
|
142
|
+
{
|
|
143
|
+
const normalized = content.replaceAll("\r\n", "\n");
|
|
144
|
+
|
|
145
|
+
if (normalized.length === 0)
|
|
146
|
+
{
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return normalized.endsWith("\n")
|
|
151
|
+
? normalized.slice(0, -1).split("\n")
|
|
152
|
+
: normalized.split("\n");
|
|
153
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Diagnostic } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export function formatDiagnostic(diagnostic: Diagnostic, source?: string): string
|
|
4
|
+
{
|
|
5
|
+
const code = source === undefined ? diagnostic.code : `${source}:${diagnostic.code}`;
|
|
6
|
+
return `[${diagnostic.severity.toUpperCase()}] ${code}: ${diagnostic.message}`;
|
|
7
|
+
}
|