pi-agent-ide 0.2.1 → 0.3.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/CHANGELOG.md +56 -0
- package/README.md +12 -8
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/chunk-5MSNYFDE.js +1 -0
- package/dist/chunk-5VSE5X5R.js +2 -0
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
- package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
- package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
- package/dist/{chunk-SMSIT3CE.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/{chunk-EEH4WYI7.js → chunk-CEKXBS55.js} +1 -1
- package/dist/chunk-CW53ZTU3.js +2 -0
- package/dist/chunk-EWNWKDMP.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/{chunk-MTTKFJV6.js → chunk-GUTQ3PWL.js} +1 -1
- package/dist/chunk-HGPUI7F3.js +1 -0
- package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
- package/dist/chunk-ITSNK5YG.js +7 -0
- package/dist/chunk-KAB3AYA2.js +1 -0
- package/dist/{chunk-266RH77Z.js → chunk-LRYE2WCN.js} +1 -1
- package/dist/chunk-M5L42DWE.js +7 -0
- package/dist/chunk-M5MJP7Z2.js +1 -0
- package/dist/chunk-NMFQGKPE.js +2 -0
- package/dist/chunk-NTYXZ3EL.js +3 -0
- package/dist/{chunk-PETQCA7G.js → chunk-QDST6VIU.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-RHV5STR3.js +3 -0
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/chunk-SSHZEWWV.js +1 -0
- package/dist/chunk-TPIHQYK2.js +14 -0
- package/dist/chunk-VZJIZXSH.js +14 -0
- package/dist/chunk-YHADTHQM.js +1 -0
- package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZM4L5AGN.js} +1 -1
- package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-1.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-2.js +1 -1
- package/dist/entry-21.js +2 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +12 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +4 -1
- package/dist/entry-32.js +9 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +18 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-42.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +7 -1
- package/dist/entry-46.js +11 -1
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -0
- package/dist/entry-55.js +0 -1
- package/dist/entry-56.js +1 -0
- package/dist/entry-57.js +0 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -0
- package/dist/entry-64.js +0 -1
- package/dist/entry-65.js +1 -0
- package/dist/entry-66.js +0 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -1
- package/dist/entry-70.js +123 -1
- package/dist/entry-71.js +30 -1
- package/dist/entry-72.js +2 -1
- package/dist/entry-73.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +3 -1
- package/dist/entry-77.js +1 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +3 -13
- package/docs/configuration.md +57 -11
- package/docs/extensions.md +4 -2
- package/docs/tools.md +7 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +9 -9
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +11 -15
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/node_modules/pi-agent-ide-changes/index.ts +22 -10
- package/node_modules/pi-agent-ide-changes/package.json +6 -6
- package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +36 -13
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/index.ts +49 -17
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
- package/node_modules/pi-agent-ide-lsp/index.ts +127 -20
- package/node_modules/pi-agent-ide-lsp/package.json +9 -8
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +1 -1
- package/node_modules/pi-agent-read/package.json +6 -6
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +32 -28
- package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
- package/node_modules/pi-agent-search/package.json +3 -3
- package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/node_modules/pi-agent-search/src/api/search.ts +55 -1
- package/node_modules/pi-agent-search/src/core/extension.ts +8 -27
- package/node_modules/pi-agent-search/src/core/search-core.ts +38 -3
- package/node_modules/pi-agent-search-text/index.ts +82 -33
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
- package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +112 -24
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- package/node_modules/pi-agent-text/src/text-document.ts +5 -0
- package/node_modules/pi-agent-text/src/text-target.ts +4 -0
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
- package/node_modules/pi-agent-text-editor/index.ts +1 -3
- package/node_modules/pi-agent-text-editor/package.json +34 -24
- package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/node_modules/pi-agent-text-editor-renderer/index.ts +93 -2
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-web/index.ts +1 -6
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
- package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/package.json +38 -38
- package/src/api/plugin-protocol.ts +12 -2
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config.ts +77 -2
- package/src/code-view/diagnostic-view.ts +22 -3
- package/src/composite/builtin-extensions.ts +138 -67
- package/src/composite/extensions-config.ts +59 -0
- package/src/composite/feature-flags.ts +32 -0
- package/src/composite/module-labels.ts +55 -0
- package/src/composite/module-settings-store.ts +44 -0
- package/src/composite/module-settings.ts +132 -0
- package/src/composite/selection.ts +4 -4
- package/src/composite/settings-panel.ts +71 -0
- package/src/core/diagnostic-delivery.ts +29 -0
- package/src/core/diagnostic-entry.ts +142 -0
- package/src/core/diagnostic-store.ts +96 -23
- package/src/core/extension.ts +45 -22
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +1 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
- package/src/extensions/pi-agent-read/package.json +6 -6
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +32 -28
- package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +87 -53
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +82 -33
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +9 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +112 -24
- package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
- package/src/extensions/pi-agent-search/src/core/extension.ts +8 -27
- package/src/extensions/pi-agent-search/src/core/search-core.ts +38 -3
- package/src/extensions/pi-agent-text-editor/index.ts +1 -3
- package/src/extensions/pi-agent-text-editor/package.json +34 -24
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +93 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
- package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +74 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -9
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/src/pi-agent-ide.ts +45 -0
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +11 -15
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/src/plugins/pi-agent-ide-changes/index.ts +22 -10
- package/src/plugins/pi-agent-ide-changes/package.json +6 -6
- package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -26
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +36 -13
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/index.ts +49 -17
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
- package/src/plugins/pi-agent-ide-lsp/index.ts +127 -20
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
- package/src/post-edit/gate.ts +57 -15
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-2SKAED2I.js +0 -2
- package/dist/chunk-2XYXV5HS.js +0 -4
- package/dist/chunk-2ZMYT6ZC.js +0 -1
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-6XQQBKPE.js +0 -58
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-EW2KVKCN.js +0 -2
- package/dist/chunk-F6SESI3P.js +0 -4
- package/dist/chunk-GTK5AREE.js +0 -2
- package/dist/chunk-HOBTFFQR.js +0 -1
- package/dist/chunk-IMVCVPMP.js +0 -3
- package/dist/chunk-IOCABSRL.js +0 -1
- package/dist/chunk-JASLOB2X.js +0 -1
- package/dist/chunk-KH5KPBCR.js +0 -10
- package/dist/chunk-KNMWCDDK.js +0 -7
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-L4FA6OD4.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-LGN7EJYR.js +0 -13
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-MTQSGWZJ.js +0 -1
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-NXHPO7ER.js +0 -6
- package/dist/chunk-OFHVDY4Q.js +0 -2
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-ONWUJXUR.js +0 -1
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QZANC2IG.js +0 -1
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-UTTW55S2.js +0 -1
- package/dist/chunk-VEJGSURY.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/dist/chunk-YPHXLAQF.js +0 -1
- package/dist/chunk-ZIHEF6K3.js +0 -3
- package/dist/entry-80.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
- package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
- /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
- /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
- /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
|
@@ -1,22 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configuredExecutableName,
|
|
3
|
+
resolveExternalToolProjectRoot,
|
|
4
|
+
} from "pi-agent-ide/api/tool-config";
|
|
1
5
|
import { connectDoctorPlugin } from "pi-agent-doctor/api/connect-plugin";
|
|
2
6
|
import { connectIdePlugin } from "pi-agent-ide/api/connect-plugin";
|
|
3
7
|
import { IDE_API_VERSION, IDE_PROTOCOL, type IdePlugin } from "pi-agent-ide/api/plugin-protocol";
|
|
4
8
|
import type { IdeTool } from "pi-agent-ide/api/toolchain";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { LINTER_RECIPES } from "./src/catalog.js";
|
|
5
11
|
import { createCommandLinter, runConfiguredLinter } from "./src/command-linter.js";
|
|
6
12
|
import { lintDoctorPlugin } from "./src/doctor-plugin.js";
|
|
7
13
|
import { LintCommandRegistry } from "./src/registry.js";
|
|
8
14
|
|
|
9
15
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
16
|
+
|
|
10
17
|
export default async function registerLint(pi: ExtensionAPI): Promise<void> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const registries = new Map<string, Promise<LintCommandRegistry>>();
|
|
19
|
+
const registryFor = (cwd: string, external = false): Promise<LintCommandRegistry> => {
|
|
20
|
+
const key = JSON.stringify([cwd, external]);
|
|
21
|
+
let registry = registries.get(key);
|
|
22
|
+
if (registry === undefined) {
|
|
23
|
+
registry = loadRegistry(cwd, external);
|
|
24
|
+
registries.set(key, registry);
|
|
17
25
|
}
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
return registry;
|
|
27
|
+
};
|
|
28
|
+
const resolveProject = async (filePath: string, cwd: string) => {
|
|
29
|
+
const projectRoot = await resolveExternalToolProjectRoot(
|
|
30
|
+
cwd,
|
|
31
|
+
filePath,
|
|
32
|
+
"linters",
|
|
33
|
+
LINTER_RECIPES,
|
|
34
|
+
);
|
|
35
|
+
return projectRoot === undefined
|
|
36
|
+
? undefined
|
|
37
|
+
: { projectRoot, external: projectRoot !== path.resolve(cwd) };
|
|
20
38
|
};
|
|
21
39
|
|
|
22
40
|
const linter = {
|
|
@@ -29,8 +47,10 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
|
|
|
29
47
|
return true;
|
|
30
48
|
},
|
|
31
49
|
async lint(input, context) {
|
|
32
|
-
const
|
|
33
|
-
|
|
50
|
+
const project = await resolveProject(input.filePath, context.cwd);
|
|
51
|
+
if (project === undefined) return { ok: true, diagnostics: [] };
|
|
52
|
+
const readyRegistry = await registryFor(project.projectRoot, project.external);
|
|
53
|
+
return createCommandLinter(readyRegistry).lint(input, { cwd: project.projectRoot });
|
|
34
54
|
},
|
|
35
55
|
} satisfies IdeTool;
|
|
36
56
|
const idePlugin = {
|
|
@@ -43,17 +63,25 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
|
|
|
43
63
|
api.addDiagnosticSource({
|
|
44
64
|
id: "lint",
|
|
45
65
|
async diagnose(filePath, context) {
|
|
46
|
-
const
|
|
66
|
+
const project = await resolveProject(filePath, context.cwd);
|
|
67
|
+
if (project === undefined)
|
|
68
|
+
return {
|
|
69
|
+
status: "unavailable",
|
|
70
|
+
diagnostics: [],
|
|
71
|
+
reason: "No local linter project found for this file",
|
|
72
|
+
};
|
|
73
|
+
const registry = await registryFor(project.projectRoot, project.external);
|
|
47
74
|
context.signal.throwIfAborted();
|
|
48
|
-
const config = registry.resolve(filePath,
|
|
75
|
+
const config = registry.resolve(filePath, project.projectRoot);
|
|
49
76
|
if (!config)
|
|
50
77
|
return {
|
|
51
78
|
status: "unavailable",
|
|
52
79
|
diagnostics: [],
|
|
53
80
|
reason: "No linter configured for this file",
|
|
54
81
|
};
|
|
82
|
+
const source = configuredExecutableName(config.check.command);
|
|
55
83
|
const result = await runConfiguredLinter(config, {
|
|
56
|
-
projectRoot:
|
|
84
|
+
projectRoot: project.projectRoot,
|
|
57
85
|
filePath,
|
|
58
86
|
signal: context.signal,
|
|
59
87
|
});
|
|
@@ -62,8 +90,9 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
|
|
|
62
90
|
status: "unavailable",
|
|
63
91
|
diagnostics: [],
|
|
64
92
|
reason: result.failure ?? "Lint check failed",
|
|
93
|
+
source,
|
|
65
94
|
}
|
|
66
|
-
: { status: "ready", diagnostics: result.diagnostics };
|
|
95
|
+
: { status: "ready", diagnostics: result.diagnostics, source };
|
|
67
96
|
},
|
|
68
97
|
});
|
|
69
98
|
},
|
|
@@ -72,7 +101,10 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
|
|
|
72
101
|
await Promise.all([connectIdePlugin(pi, idePlugin), connectDoctorPlugin(pi, lintDoctorPlugin)]);
|
|
73
102
|
}
|
|
74
103
|
|
|
75
|
-
async function loadRegistry(cwd: string): Promise<LintCommandRegistry> {
|
|
76
|
-
const configDirectory = process.env.PI_AGENT_IDE_CONFIG_DIR ?? cwd;
|
|
77
|
-
return LintCommandRegistry.fromDirectory(configDirectory
|
|
104
|
+
async function loadRegistry(cwd: string, external: boolean): Promise<LintCommandRegistry> {
|
|
105
|
+
const configDirectory = external ? cwd : (process.env.PI_AGENT_IDE_CONFIG_DIR ?? cwd);
|
|
106
|
+
return LintCommandRegistry.fromDirectory(configDirectory, {
|
|
107
|
+
includeGlobal: !external,
|
|
108
|
+
requireBuiltInEvidence: external,
|
|
109
|
+
});
|
|
78
110
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.
|
|
7
|
-
"pi-agent-invariant": "0.
|
|
8
|
-
"pi-agent-read": "0.
|
|
9
|
-
"pi-agent-resource": "0.
|
|
10
|
-
"pi-agent-text": "0.
|
|
6
|
+
"pi-agent-doctor": "0.3.0",
|
|
7
|
+
"pi-agent-invariant": "0.3.0",
|
|
8
|
+
"pi-agent-read": "0.3.0",
|
|
9
|
+
"pi-agent-resource": "0.3.0",
|
|
10
|
+
"pi-agent-text": "0.3.0"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@earendil-works/pi-coding-agent": "*",
|
|
19
|
-
"pi-agent-ide": "0.
|
|
19
|
+
"pi-agent-ide": "0.3.0"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -56,7 +56,15 @@ export class LintCommandRegistry {
|
|
|
56
56
|
);
|
|
57
57
|
return new LintCommandRegistry(
|
|
58
58
|
entries,
|
|
59
|
-
new Set(
|
|
59
|
+
new Set(
|
|
60
|
+
available
|
|
61
|
+
.filter(
|
|
62
|
+
(entry) =>
|
|
63
|
+
entry.available &&
|
|
64
|
+
(!options.requireBuiltInEvidence || (evidence.get(entry.id)?.score ?? 0) > 0),
|
|
65
|
+
)
|
|
66
|
+
.map((entry) => entry.id),
|
|
67
|
+
),
|
|
60
68
|
|
|
61
69
|
evidence,
|
|
62
70
|
);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { connectDoctorPlugin } from "pi-agent-doctor/api/connect-plugin";
|
|
2
2
|
import { createSourceMappedTextReadHandler } from "pi-agent-ide/api/code-view";
|
|
3
3
|
import { connectIdePlugin } from "pi-agent-ide/api/connect-plugin";
|
|
4
|
+
import { resolveExternalToolProjectRoot } from "pi-agent-ide/api/tool-config";
|
|
5
|
+
import path from "node:path";
|
|
4
6
|
import { IDE_API_VERSION, IDE_PROTOCOL, type IdePlugin } from "pi-agent-ide/api/plugin-protocol";
|
|
5
7
|
import type { IdeTool } from "pi-agent-ide/api/toolchain";
|
|
6
8
|
import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
|
|
@@ -13,11 +15,20 @@ import { createReadResultRenderer } from "pi-agent-read/api/rendering";
|
|
|
13
15
|
import { connectSearchPlugin } from "pi-agent-search/api/connect-plugin";
|
|
14
16
|
import { SEARCH_API_VERSION, SEARCH_PROTOCOL } from "pi-agent-search/api/plugin-protocol";
|
|
15
17
|
|
|
18
|
+
import { LSP_RECIPES } from "./src/catalog.js";
|
|
16
19
|
import { createLspGraphResolver, createLspSymbolResolver } from "./src/code-view-resolvers.js";
|
|
17
20
|
import { createLspDiagnosticSource } from "./src/diagnostic-source.js";
|
|
18
21
|
import { lspDoctorPlugin } from "./src/doctor-plugin.js";
|
|
19
22
|
import { createLspCompiler, LspManager, LspServerRegistry } from "./src/lsp/index.js";
|
|
20
23
|
import { createLspSearchResolver } from "./src/search-resolver.js";
|
|
24
|
+
import { createDeclarationTargets } from "./src/declaration-targets.js";
|
|
25
|
+
import { prepareSymbolRename } from "./src/rename-plan.js";
|
|
26
|
+
import { connectTextEditorPlugin } from "pi-agent-text-editor/api/connect-plugin";
|
|
27
|
+
import {
|
|
28
|
+
TEXT_EDITOR_PROTOCOL,
|
|
29
|
+
TEXT_EDITOR_API_VERSION,
|
|
30
|
+
TEXT_SEARCH_ANCHOR_KIND,
|
|
31
|
+
} from "pi-agent-text-editor/api/plugin-protocol";
|
|
21
32
|
|
|
22
33
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
23
34
|
|
|
@@ -26,18 +37,30 @@ const renderReadResult = createReadResultRenderer({ kind: "code-view", label: "L
|
|
|
26
37
|
export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
27
38
|
const managers = new Map<string, Promise<LspManager>>();
|
|
28
39
|
let disposed = false;
|
|
29
|
-
const managerFor = (cwd: string): Promise<LspManager> => {
|
|
40
|
+
const managerFor = (cwd: string, external = false): Promise<LspManager> => {
|
|
30
41
|
if (disposed) return Promise.reject(new Error("LSP session has ended"));
|
|
31
|
-
|
|
42
|
+
const key = JSON.stringify([cwd, external]);
|
|
43
|
+
let ready = managers.get(key);
|
|
32
44
|
if (!ready) {
|
|
33
|
-
ready = loadRegistry(cwd).then((registry) => {
|
|
45
|
+
ready = loadRegistry(cwd, external).then((registry) => {
|
|
34
46
|
if (disposed) throw new Error("LSP session has ended");
|
|
35
47
|
return LspManager.init(registry);
|
|
36
48
|
});
|
|
37
|
-
managers.set(
|
|
49
|
+
managers.set(key, ready);
|
|
38
50
|
}
|
|
39
51
|
return ready;
|
|
40
52
|
};
|
|
53
|
+
const resolveLspProject = async (filePath: string, cwd: string) => {
|
|
54
|
+
const projectRoot = await resolveExternalToolProjectRoot(
|
|
55
|
+
cwd,
|
|
56
|
+
filePath,
|
|
57
|
+
"lsp-servers",
|
|
58
|
+
LSP_RECIPES,
|
|
59
|
+
);
|
|
60
|
+
return projectRoot === undefined
|
|
61
|
+
? undefined
|
|
62
|
+
: { cwd: projectRoot, external: projectRoot !== path.resolve(cwd) };
|
|
63
|
+
};
|
|
41
64
|
|
|
42
65
|
const compiler = {
|
|
43
66
|
kind: "compiler",
|
|
@@ -60,7 +83,7 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
|
60
83
|
setup(api): void {
|
|
61
84
|
api.addTool(compiler);
|
|
62
85
|
|
|
63
|
-
api.addDiagnosticSource(createLspDiagnosticSource(managerFor));
|
|
86
|
+
api.addDiagnosticSource(createLspDiagnosticSource(managerFor, resolveLspProject));
|
|
64
87
|
},
|
|
65
88
|
} satisfies IdePlugin;
|
|
66
89
|
pi.on("session_shutdown", async () => {
|
|
@@ -90,20 +113,104 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
|
90
113
|
handler: createSourceMappedTextReadHandler(),
|
|
91
114
|
});
|
|
92
115
|
api.describe(
|
|
93
|
-
"
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
api.addPromptGuideline(
|
|
97
|
-
"You can use read with `symbol:<path>#<selector>` to inspect a known symbol's implementation without searching for it or reading the whole file.",
|
|
98
|
-
);
|
|
99
|
-
api.addPromptGuideline(
|
|
100
|
-
"You can use read with `graph:<path>` to inspect each top-level declaration's definition, referencing files, and incoming and outgoing calls. Members are listed with selectors; their relationships are not expanded. You can append `#<selector>` to inspect one symbol's references and calls, including a nested method.",
|
|
116
|
+
"symbol:<file>#<selector> — declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> — top-level declarations, references and calls; members include selectors. graph:<file>#<selector> — references and incoming/outgoing calls for that declaration or member.",
|
|
101
117
|
);
|
|
102
118
|
},
|
|
103
119
|
} satisfies ReadPlugin;
|
|
104
120
|
|
|
105
121
|
await Promise.all([
|
|
106
122
|
connectIdePlugin(pi, idePlugin),
|
|
123
|
+
connectTextEditorPlugin(pi, {
|
|
124
|
+
protocol: TEXT_EDITOR_PROTOCOL,
|
|
125
|
+
apiVersion: TEXT_EDITOR_API_VERSION,
|
|
126
|
+
id: "lsp-declarations",
|
|
127
|
+
setup(api) {
|
|
128
|
+
api.addAnchorResolver({
|
|
129
|
+
kind: TEXT_SEARCH_ANCHOR_KIND,
|
|
130
|
+
type: "auxiliary",
|
|
131
|
+
resolver: {
|
|
132
|
+
id: "lsp-declaration",
|
|
133
|
+
description:
|
|
134
|
+
"symbol:<file>#<selector> selects an exact declaration for text fallback editing; imports and references are not rewritten.",
|
|
135
|
+
renderFull: (value) => value,
|
|
136
|
+
renderCompact: (value) => value,
|
|
137
|
+
tryResolve: () => Promise.resolve({ kind: "not-handled" }),
|
|
138
|
+
},
|
|
139
|
+
resources: createDeclarationTargets(managerFor),
|
|
140
|
+
describeInPrompt: false,
|
|
141
|
+
});
|
|
142
|
+
for (const operation of ["copy", "move", "delete", "replace"]) {
|
|
143
|
+
api
|
|
144
|
+
.tool(operation)
|
|
145
|
+
.describe(
|
|
146
|
+
"Use symbol:<file>#<selector> as path to select one exact declaration without start/end. Use parent/child for ambiguous names. Copy/move require an explicit target and destination anchor. This text fallback leaves imports and references unchanged; it is not semantic rename." +
|
|
147
|
+
(operation === "replace"
|
|
148
|
+
? " Use symbol:<file>#<selector>#name with text containing the new name for native LSP rename across references. Omit start/end. A failed server rename never falls back to identifier text replacement."
|
|
149
|
+
: ""),
|
|
150
|
+
);
|
|
151
|
+
api.tool(operation).addHandler({
|
|
152
|
+
stage: "text-pre-edit",
|
|
153
|
+
async handler(state) {
|
|
154
|
+
if (operation === "replace") {
|
|
155
|
+
const renamed = await prepareSymbolRename(state, managerFor);
|
|
156
|
+
if (renamed !== undefined) return renamed;
|
|
157
|
+
}
|
|
158
|
+
const input = state.input as Record<string, unknown>;
|
|
159
|
+
const selected = [
|
|
160
|
+
input.path,
|
|
161
|
+
input.start,
|
|
162
|
+
input.end,
|
|
163
|
+
input.target,
|
|
164
|
+
input.targetStart,
|
|
165
|
+
input.targetEnd,
|
|
166
|
+
].some((value) => typeof value === "string" && value.startsWith("symbol:"));
|
|
167
|
+
if (!selected) return state;
|
|
168
|
+
if (
|
|
169
|
+
(operation === "copy" || operation === "move") &&
|
|
170
|
+
typeof input.target !== "string"
|
|
171
|
+
)
|
|
172
|
+
throw new Error(
|
|
173
|
+
"Copying or moving a symbol requires an explicit target file and destination anchor.",
|
|
174
|
+
);
|
|
175
|
+
return {
|
|
176
|
+
...state,
|
|
177
|
+
metadata: {
|
|
178
|
+
...state.metadata,
|
|
179
|
+
semanticEdit: {
|
|
180
|
+
mode: "declaration-text",
|
|
181
|
+
referencesUpdated: false,
|
|
182
|
+
importsUpdated: false,
|
|
183
|
+
},
|
|
184
|
+
diffStatuses: [
|
|
185
|
+
{ text: "Text fallback: imports and references unchanged", tone: "warning" },
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
api
|
|
193
|
+
.tool("insert")
|
|
194
|
+
.describe(
|
|
195
|
+
"Symbol targets are unsupported for insert. Read the declaration and select an ordinary text line anchor instead.",
|
|
196
|
+
);
|
|
197
|
+
api.tool("insert").addHandler({
|
|
198
|
+
stage: "text-pre-edit",
|
|
199
|
+
handler(state) {
|
|
200
|
+
const input = state.input as Record<string, unknown>;
|
|
201
|
+
if (
|
|
202
|
+
[input.path, input.anchor].some(
|
|
203
|
+
(value) => typeof value === "string" && value.startsWith("symbol:"),
|
|
204
|
+
)
|
|
205
|
+
)
|
|
206
|
+
throw new Error(
|
|
207
|
+
"Semantic insert is not supported. Read the declaration and use an explicit text line anchor instead.",
|
|
208
|
+
);
|
|
209
|
+
return state;
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
}),
|
|
107
214
|
connectReadPlugin(pi, readPlugin),
|
|
108
215
|
connectDoctorPlugin(pi, lspDoctorPlugin),
|
|
109
216
|
connectSearchPlugin(pi, {
|
|
@@ -115,16 +222,16 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
|
115
222
|
api.describe(
|
|
116
223
|
"Use `symbols:<query>` to search workspace symbols and their references through configured language servers.",
|
|
117
224
|
);
|
|
118
|
-
|
|
119
|
-
api.addPromptGuideline(
|
|
120
|
-
"You can use search with `symbols:<query>` to find workspace symbols and their references through configured language servers.",
|
|
121
|
-
);
|
|
122
225
|
},
|
|
123
226
|
}),
|
|
124
227
|
]);
|
|
125
228
|
}
|
|
126
229
|
|
|
127
|
-
async function loadRegistry(cwd: string): Promise<LspServerRegistry> {
|
|
128
|
-
const configDirectory = process.env.PI_AGENT_IDE_CONFIG_DIR ?? cwd;
|
|
129
|
-
return LspServerRegistry.fromPackageDir(configDirectory
|
|
230
|
+
async function loadRegistry(cwd: string, external: boolean): Promise<LspServerRegistry> {
|
|
231
|
+
const configDirectory = external ? cwd : (process.env.PI_AGENT_IDE_CONFIG_DIR ?? cwd);
|
|
232
|
+
return LspServerRegistry.fromPackageDir(configDirectory, {
|
|
233
|
+
includeGlobal: !external,
|
|
234
|
+
requireBuiltInEvidence: external,
|
|
235
|
+
recipes: LSP_RECIPES,
|
|
236
|
+
});
|
|
130
237
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lsp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"cross-spawn": "^7.0.6",
|
|
7
|
-
"pi-agent-doctor": "0.
|
|
8
|
-
"pi-agent-invariant": "0.
|
|
9
|
-
"pi-agent-read": "0.
|
|
10
|
-
"pi-agent-resource": "0.
|
|
11
|
-
"pi-agent-search": "0.
|
|
12
|
-
"pi-agent-text": "0.
|
|
7
|
+
"pi-agent-doctor": "0.3.0",
|
|
8
|
+
"pi-agent-invariant": "0.3.0",
|
|
9
|
+
"pi-agent-read": "0.3.0",
|
|
10
|
+
"pi-agent-resource": "0.3.0",
|
|
11
|
+
"pi-agent-search": "0.3.0",
|
|
12
|
+
"pi-agent-text": "0.3.0",
|
|
13
|
+
"pi-agent-text-editor": "0.3.0",
|
|
13
14
|
"vscode-jsonrpc": "^9.0.0",
|
|
14
15
|
"vscode-uri": "^3.1.0"
|
|
15
16
|
},
|
|
@@ -20,6 +21,6 @@
|
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
23
|
"@earendil-works/pi-coding-agent": "*",
|
|
23
|
-
"pi-agent-ide": "0.
|
|
24
|
+
"pi-agent-ide": "0.3.0"
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { parseCodeViewReference, resolveCodeViewPath } from "pi-agent-ide/api/code-view";
|
|
2
|
+
import type { TextTargetResolver } from "pi-agent-text";
|
|
3
|
+
import { resolveLspDeclaration } from "./lsp/code-views.js";
|
|
4
|
+
import type { LspManagerProvider } from "./code-view-resolvers.js";
|
|
5
|
+
|
|
6
|
+
/** Resolve a live symbol reference to its exact declaration, not matching identifier words. */
|
|
7
|
+
export function createDeclarationTargets(managerFor: LspManagerProvider): TextTargetResolver {
|
|
8
|
+
return {
|
|
9
|
+
id: "lsp-declaration-target",
|
|
10
|
+
async tryResolve(value, context) {
|
|
11
|
+
const reference = parseCodeViewReference(value, "symbol");
|
|
12
|
+
if (reference === undefined) return { kind: "not-handled" };
|
|
13
|
+
if (reference.selector === undefined)
|
|
14
|
+
return {
|
|
15
|
+
kind: "rejected",
|
|
16
|
+
rejection: {
|
|
17
|
+
code: "invalid",
|
|
18
|
+
reason: "Use symbol:<file>#<selector> to choose one declaration",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
const declaration = await resolveLspDeclaration(
|
|
23
|
+
await managerFor(context.cwd),
|
|
24
|
+
resolveCodeViewPath(reference.path, context.cwd),
|
|
25
|
+
reference.selector,
|
|
26
|
+
context.cwd,
|
|
27
|
+
context.signal,
|
|
28
|
+
);
|
|
29
|
+
return {
|
|
30
|
+
kind: "resolved",
|
|
31
|
+
targets: [
|
|
32
|
+
{
|
|
33
|
+
source: declaration.source,
|
|
34
|
+
expectedContent: declaration.content,
|
|
35
|
+
ranges: [
|
|
36
|
+
{
|
|
37
|
+
start: {
|
|
38
|
+
lineNumber: declaration.range.start.line + 1,
|
|
39
|
+
column: declaration.range.start.character,
|
|
40
|
+
},
|
|
41
|
+
end: {
|
|
42
|
+
lineNumber: declaration.range.end.line + 1,
|
|
43
|
+
column: declaration.range.end.character,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return {
|
|
52
|
+
kind: "failed",
|
|
53
|
+
error: new Error(
|
|
54
|
+
`${error instanceof Error ? error.message : String(error)} Read the physical file and use explicit text anchors if declaration resolution is unavailable.`,
|
|
55
|
+
{ cause: error },
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -7,14 +7,29 @@ import type { IdeDiagnosticReport, IdeDiagnosticSource } from "pi-agent-ide/api/
|
|
|
7
7
|
export function createLspDiagnosticSource(
|
|
8
8
|
managerFor: (
|
|
9
9
|
cwd: string,
|
|
10
|
+
external?: boolean,
|
|
10
11
|
) => Promise<Pick<LspManager, "getOrStart" | "languageId" | "onPushDiagnostics">>,
|
|
12
|
+
resolveProject: (
|
|
13
|
+
filePath: string,
|
|
14
|
+
cwd: string,
|
|
15
|
+
) => Promise<{ readonly cwd: string; readonly external: boolean } | undefined> = (
|
|
16
|
+
filePath,
|
|
17
|
+
cwd,
|
|
18
|
+
) => Promise.resolve({ cwd, external: false }),
|
|
11
19
|
): IdeDiagnosticSource {
|
|
12
20
|
return {
|
|
13
21
|
id: "lsp",
|
|
14
22
|
async diagnose(filePath, context) {
|
|
15
|
-
const
|
|
23
|
+
const project = await resolveProject(filePath, context.cwd);
|
|
24
|
+
if (project === undefined)
|
|
25
|
+
return {
|
|
26
|
+
status: "unavailable",
|
|
27
|
+
diagnostics: [],
|
|
28
|
+
reason: "No local language-server project found for this file",
|
|
29
|
+
};
|
|
30
|
+
const manager = await managerFor(project.cwd, project.external);
|
|
16
31
|
context.signal.throwIfAborted();
|
|
17
|
-
const client = await manager.getOrStart(filePath,
|
|
32
|
+
const client = await manager.getOrStart(filePath, project.cwd, "diagnostics");
|
|
18
33
|
context.signal.throwIfAborted();
|
|
19
34
|
if (!client)
|
|
20
35
|
return {
|
|
@@ -41,7 +56,7 @@ export function createLspDiagnosticSource(
|
|
|
41
56
|
while (refreshState.queued && current()) {
|
|
42
57
|
refreshState.queued = false;
|
|
43
58
|
const result = await request();
|
|
44
|
-
if (current()) context.publish(toReport(result));
|
|
59
|
+
if (current()) context.publish(toReport(result, client.commandName));
|
|
45
60
|
}
|
|
46
61
|
} catch (error) {
|
|
47
62
|
if (current())
|
|
@@ -49,6 +64,7 @@ export function createLspDiagnosticSource(
|
|
|
49
64
|
status: "unavailable",
|
|
50
65
|
diagnostics: [],
|
|
51
66
|
reason: error instanceof Error ? error.message : String(error),
|
|
67
|
+
source: client.commandName,
|
|
52
68
|
});
|
|
53
69
|
} finally {
|
|
54
70
|
refreshState.active = false;
|
|
@@ -59,7 +75,7 @@ export function createLspDiagnosticSource(
|
|
|
59
75
|
!current() ||
|
|
60
76
|
event.uri !== uri ||
|
|
61
77
|
event.serverId !== client.serverId ||
|
|
62
|
-
event.cwd !==
|
|
78
|
+
event.cwd !== project.cwd ||
|
|
63
79
|
(event.version !== undefined && event.version !== version)
|
|
64
80
|
)
|
|
65
81
|
return;
|
|
@@ -70,6 +86,7 @@ export function createLspDiagnosticSource(
|
|
|
70
86
|
context.publish({
|
|
71
87
|
status: "snapshot",
|
|
72
88
|
diagnostics: event.diagnostics,
|
|
89
|
+
source: client.commandName,
|
|
73
90
|
reason: snapshotReason(event.version === undefined),
|
|
74
91
|
});
|
|
75
92
|
}
|
|
@@ -78,7 +95,7 @@ export function createLspDiagnosticSource(
|
|
|
78
95
|
try {
|
|
79
96
|
const result = await request();
|
|
80
97
|
version = client.documentVersion(uri);
|
|
81
|
-
return toReport(result);
|
|
98
|
+
return toReport(result, client.commandName);
|
|
82
99
|
} catch (error) {
|
|
83
100
|
refreshState.queued = false;
|
|
84
101
|
unsubscribe();
|
|
@@ -99,12 +116,13 @@ function snapshotReason(unversioned: boolean): string {
|
|
|
99
116
|
return `Latest push snapshot; completion is unknown${unversioned ? "; language server omitted the document version" : ""}`;
|
|
100
117
|
}
|
|
101
118
|
|
|
102
|
-
function toReport(result: LspDiagnosticResult): IdeDiagnosticReport {
|
|
119
|
+
function toReport(result: LspDiagnosticResult, source: string): IdeDiagnosticReport {
|
|
103
120
|
return result.complete
|
|
104
|
-
? { status: "ready", diagnostics: result.diagnostics }
|
|
121
|
+
? { status: "ready", diagnostics: result.diagnostics, source }
|
|
105
122
|
: {
|
|
106
123
|
status: "snapshot",
|
|
107
124
|
diagnostics: result.diagnostics,
|
|
108
125
|
reason: snapshotReason(result.unversioned),
|
|
126
|
+
source,
|
|
109
127
|
};
|
|
110
128
|
}
|
|
@@ -4,7 +4,10 @@ import { type ChildProcess } from "node:child_process";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
import spawnProcess from "cross-spawn";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
configuredExecutableName,
|
|
9
|
+
createConfiguredProcessEnvironment,
|
|
10
|
+
} from "pi-agent-ide/api/tool-config";
|
|
8
11
|
import {
|
|
9
12
|
createMessageConnection,
|
|
10
13
|
CancellationTokenSource,
|
|
@@ -94,6 +97,10 @@ export class LspClient {
|
|
|
94
97
|
return this._process?.pid ?? null;
|
|
95
98
|
}
|
|
96
99
|
|
|
100
|
+
/** Executable used to start this server, independent of its configured ID. */
|
|
101
|
+
get commandName(): string {
|
|
102
|
+
return configuredExecutableName(this._command);
|
|
103
|
+
}
|
|
97
104
|
get diagnosticMode(): "unknown" | "pull" | "push" {
|
|
98
105
|
return this._diagnosticMode;
|
|
99
106
|
}
|
|
@@ -120,6 +127,10 @@ export class LspClient {
|
|
|
120
127
|
return provider === true || (typeof provider === "object" && provider !== null);
|
|
121
128
|
}
|
|
122
129
|
|
|
130
|
+
/** Text last synchronized to the server, used to reject edits against stale open buffers. */
|
|
131
|
+
documentContent(uri: string): string | undefined {
|
|
132
|
+
return this._documentContents.get(uri);
|
|
133
|
+
}
|
|
123
134
|
documentVersion(uri: string): number | undefined {
|
|
124
135
|
return this._documentVersions.get(uri);
|
|
125
136
|
}
|
|
@@ -51,6 +51,46 @@ interface LspCodeDocument {
|
|
|
51
51
|
readonly symbols: readonly LspCodeSymbol[];
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/** Resolve a declaration's exact server range for guarded text operations. */
|
|
55
|
+
export async function resolveLspDeclaration(
|
|
56
|
+
manager: LspManager,
|
|
57
|
+
filePath: string,
|
|
58
|
+
selector: readonly string[],
|
|
59
|
+
cwd: string,
|
|
60
|
+
signal?: AbortSignal,
|
|
61
|
+
): Promise<{ readonly source: string; readonly range: LspRange; readonly content: string }> {
|
|
62
|
+
throwIfAborted(signal);
|
|
63
|
+
const before = await readFile(filePath, "utf8");
|
|
64
|
+
const document = await openCodeDocument(manager, filePath, cwd);
|
|
65
|
+
const symbol = resolveLspCodeSymbol(document.symbols, selector, document.displayPath);
|
|
66
|
+
const after = await readFile(document.filePath, "utf8");
|
|
67
|
+
throwIfAborted(signal);
|
|
68
|
+
if (before !== after)
|
|
69
|
+
throw new Error("The symbol source changed during resolution. Read it again before editing.");
|
|
70
|
+
return { source: document.filePath, range: symbol.range, content: after };
|
|
71
|
+
}
|
|
72
|
+
/** Resolve the native identifier position and client without guessing from declaration text. */
|
|
73
|
+
export async function resolveLspRenameTarget(
|
|
74
|
+
manager: LspManager,
|
|
75
|
+
filePath: string,
|
|
76
|
+
selector: readonly string[],
|
|
77
|
+
cwd: string,
|
|
78
|
+
signal?: AbortSignal,
|
|
79
|
+
) {
|
|
80
|
+
throwIfAborted(signal);
|
|
81
|
+
const content = await readFile(filePath, "utf8");
|
|
82
|
+
const document = await openCodeDocument(manager, filePath, cwd);
|
|
83
|
+
const symbol = resolveLspCodeSymbol(document.symbols, selector, document.displayPath);
|
|
84
|
+
if (content !== (await readFile(filePath, "utf8")))
|
|
85
|
+
throw new Error("The rename source changed during resolution.");
|
|
86
|
+
throwIfAborted(signal);
|
|
87
|
+
return {
|
|
88
|
+
client: document.client,
|
|
89
|
+
uri: document.uri,
|
|
90
|
+
position: symbol.selectionRange.start,
|
|
91
|
+
content,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
54
94
|
interface SymbolRelations {
|
|
55
95
|
readonly references: readonly LspLocation[];
|
|
56
96
|
readonly calls: LspCallHierarchyResult;
|