pi-agent-ide 0.2.2 → 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 +25 -0
- package/README.md +12 -8
- 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-XF5PVZOS.js → chunk-B5KB2I7J.js} +1 -1
- package/dist/{chunk-WNMGUALD.js → chunk-CEKXBS55.js} +1 -1
- package/dist/chunk-CW53ZTU3.js +2 -0
- package/dist/chunk-EWNWKDMP.js +4 -0
- package/dist/{chunk-LQYZG62K.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-THSCUT2L.js → chunk-LRYE2WCN.js} +1 -1
- package/dist/{chunk-76WHES5H.js → chunk-M5L42DWE.js} +5 -5
- package/dist/chunk-M5MJP7Z2.js +1 -0
- package/dist/chunk-NMFQGKPE.js +2 -0
- package/dist/chunk-NTYXZ3EL.js +3 -0
- package/dist/{chunk-P6T3Q7LB.js → chunk-QDST6VIU.js} +1 -1
- package/dist/chunk-RHV5STR3.js +3 -0
- package/dist/chunk-ROXXK6TW.js +0 -0
- package/dist/chunk-SSHZEWWV.js +1 -0
- package/dist/{chunk-4ZTEPMJO.js → chunk-TPIHQYK2.js} +1 -1
- 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-ZXN3TWWW.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-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 +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +10 -5
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-31.js +3 -3
- package/dist/entry-32.js +6 -5
- 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 +12 -8
- 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 +4 -4
- package/dist/entry-46.js +10 -10
- 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 -59
- package/dist/entry-70.js +123 -4
- package/dist/entry-71.js +30 -1
- package/dist/entry-72.js +2 -29
- package/dist/entry-73.js +1 -2
- 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 -3
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +3 -2
- package/docs/configuration.md +32 -11
- package/docs/tools.md +6 -0
- package/node_modules/pi-agent-doctor/package.json +1 -1
- 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/extension.ts +4 -3
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/node_modules/pi-agent-ide-changes/index.ts +21 -5
- 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 +4 -2
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +26 -8
- 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 +46 -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 +126 -8
- 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 +18 -3
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
- 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-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- 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/tools/read.ts +73 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +26 -2
- 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 +61 -14
- 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 +73 -44
- package/node_modules/pi-agent-resource/package.json +1 -1
- 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 +2 -23
- package/node_modules/pi-agent-search/src/core/search-core.ts +28 -3
- package/node_modules/pi-agent-search-text/index.ts +44 -4
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/search-session.ts +65 -25
- package/node_modules/pi-agent-text/package.json +2 -2
- 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/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/plugin-protocol.ts +15 -1
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +3 -0
- 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/diff-tool.ts +205 -0
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +6 -0
- 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 +1 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
- 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-change-engine.ts +10 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +173 -49
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +261 -9
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/index.ts +88 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -10
- 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-ui/package.json +2 -2
- 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-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 +10 -2
- package/src/api/tool-config.ts +73 -2
- package/src/code-view/diagnostic-view.ts +22 -3
- package/src/composite/builtin-extensions.ts +4 -15
- package/src/composite/extensions-config.ts +41 -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 +51 -3
- package/src/core/diagnostic-store.ts +56 -5
- package/src/core/extension.ts +34 -33
- 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/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-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/tools/read.ts +73 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +26 -2
- 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 +61 -14
- 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 +73 -44
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +44 -4
- 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/search-session.ts +65 -25
- 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 +2 -23
- package/src/extensions/pi-agent-search/src/core/search-core.ts +28 -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/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 +88 -1
- 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/mutation-panel.ts +42 -25
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -10
- 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/plugin-protocol.ts +15 -1
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +3 -0
- 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/diff-tool.ts +205 -0
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +6 -0
- 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 +1 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
- 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-change-engine.ts +10 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +173 -49
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +261 -9
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/src/pi-agent-ide.ts +42 -8
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -3
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
- package/src/plugins/pi-agent-ide-changes/index.ts +21 -5
- 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 +4 -2
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -11
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +26 -8
- 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 +46 -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 +126 -8
- 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 +18 -3
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
- 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 +15 -2
- package/dist/chunk-4U6KGABH.js +0 -1
- package/dist/chunk-6ACQQBUY.js +0 -7
- package/dist/chunk-GFWDXTOB.js +0 -4
- package/dist/chunk-JASLOB2X.js +0 -1
- package/dist/chunk-JJVXUL5U.js +0 -2
- package/dist/chunk-KCEOTU5Z.js +0 -3
- package/dist/chunk-KVGQG43U.js +0 -1
- package/dist/chunk-QJFRAMK7.js +0 -2
- package/dist/chunk-RAZOACDD.js +0 -2
- package/dist/chunk-RIGRP3FD.js +0 -1
- package/dist/chunk-X6MPU7UO.js +0 -3
- package/dist/chunk-YPHXLAQF.js +0 -1
- package/dist/entry-80.js +0 -1
- 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-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,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 () => {
|
|
@@ -97,6 +120,97 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
|
97
120
|
|
|
98
121
|
await Promise.all([
|
|
99
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
|
+
}),
|
|
100
214
|
connectReadPlugin(pi, readPlugin),
|
|
101
215
|
connectDoctorPlugin(pi, lspDoctorPlugin),
|
|
102
216
|
connectSearchPlugin(pi, {
|
|
@@ -113,7 +227,11 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
|
113
227
|
]);
|
|
114
228
|
}
|
|
115
229
|
|
|
116
|
-
async function loadRegistry(cwd: string): Promise<LspServerRegistry> {
|
|
117
|
-
const configDirectory = process.env.PI_AGENT_IDE_CONFIG_DIR ?? cwd;
|
|
118
|
-
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
|
+
});
|
|
119
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 {
|
|
@@ -60,7 +75,7 @@ export function createLspDiagnosticSource(
|
|
|
60
75
|
!current() ||
|
|
61
76
|
event.uri !== uri ||
|
|
62
77
|
event.serverId !== client.serverId ||
|
|
63
|
-
event.cwd !==
|
|
78
|
+
event.cwd !== project.cwd ||
|
|
64
79
|
(event.version !== undefined && event.version !== version)
|
|
65
80
|
)
|
|
66
81
|
return;
|
|
@@ -127,6 +127,10 @@ export class LspClient {
|
|
|
127
127
|
return provider === true || (typeof provider === "object" && provider !== null);
|
|
128
128
|
}
|
|
129
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
|
+
}
|
|
130
134
|
documentVersion(uri: string): number | undefined {
|
|
131
135
|
return this._documentVersions.get(uri);
|
|
132
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readdir } from "node:fs/promises";
|
|
1
|
+
import { readdir, stat } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
import { URI } from "vscode-uri";
|
|
@@ -191,35 +191,13 @@ export class LspManager {
|
|
|
191
191
|
return startingClient;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
/**
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
async getWorkspaceClients(cwd: string, capability: "symbols" = "symbols"): Promise<LspClient[]> {
|
|
194
|
+
/** Start symbol servers only for language families with files in this workspace. */
|
|
195
|
+
async getWorkspaceClients(
|
|
196
|
+
cwd: string,
|
|
197
|
+
capability: "symbols" = "symbols",
|
|
198
|
+
scope = cwd,
|
|
199
|
+
): Promise<LspClient[]> {
|
|
201
200
|
const clients = new Set<LspClient>();
|
|
202
|
-
|
|
203
|
-
for (const extension of this._registry.knownExtensions) {
|
|
204
|
-
try {
|
|
205
|
-
const client = await this.getOrStart(extension, cwd, capability);
|
|
206
|
-
|
|
207
|
-
if (client) {
|
|
208
|
-
clients.add(client);
|
|
209
|
-
}
|
|
210
|
-
} catch {
|
|
211
|
-
// A workspace may list servers that are not installed locally.
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return [...clients];
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
Open one representative file for each configured language family.
|
|
220
|
-
*/
|
|
221
|
-
async prepareWorkspaceSymbols(cwd: string): Promise<LspClient[]> {
|
|
222
|
-
const clients = await this.getWorkspaceClients(cwd);
|
|
223
201
|
const remainingExtensions = new Set(this._registry.knownExtensions);
|
|
224
202
|
const ignoredDirectories = new Set([".git", ".cache", "node_modules", "dist", "build"]);
|
|
225
203
|
|
|
@@ -260,16 +238,27 @@ export class LspManager {
|
|
|
260
238
|
}
|
|
261
239
|
|
|
262
240
|
const filePath = path.join(directory, entry.name);
|
|
263
|
-
const opened = await this.openFile(filePath, cwd,
|
|
241
|
+
const opened = await this.openFile(filePath, cwd, capability).catch(() => null);
|
|
264
242
|
|
|
265
243
|
if (opened) {
|
|
244
|
+
clients.add(opened.client);
|
|
266
245
|
remainingExtensions.delete(extension);
|
|
267
246
|
}
|
|
268
247
|
}
|
|
269
248
|
};
|
|
270
249
|
|
|
271
|
-
|
|
272
|
-
|
|
250
|
+
const selected = path.resolve(cwd, scope);
|
|
251
|
+
if ((await stat(selected)).isFile()) {
|
|
252
|
+
const opened = await this.openFile(selected, cwd, capability);
|
|
253
|
+
return opened === null ? [] : [opened.client];
|
|
254
|
+
}
|
|
255
|
+
await visit(selected);
|
|
256
|
+
return [...clients];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Open representative source files before querying workspace symbols. */
|
|
260
|
+
async prepareWorkspaceSymbols(cwd: string, scope = cwd): Promise<LspClient[]> {
|
|
261
|
+
return this.getWorkspaceClients(cwd, "symbols", scope);
|
|
273
262
|
}
|
|
274
263
|
|
|
275
264
|
/**
|
|
@@ -2,6 +2,8 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
|
|
5
|
+
import { inspectRecipeEvidence } from "pi-agent-doctor/api/evidence";
|
|
6
|
+
import type { ToolRecipe } from "pi-agent-doctor/api/catalog";
|
|
5
7
|
import { hasConfiguredExecutable, loadLayeredToolConfig } from "pi-agent-ide/api/tool-config";
|
|
6
8
|
|
|
7
9
|
import { buildLanguageLookup, type LanguageLookup } from "./language-map.js";
|
|
@@ -38,7 +40,7 @@ export class LspServerRegistry {
|
|
|
38
40
|
*/
|
|
39
41
|
static async fromPackageDir(
|
|
40
42
|
packageDir: string,
|
|
41
|
-
options: LayeredToolConfigOptions = {},
|
|
43
|
+
options: LayeredToolConfigOptions & { readonly recipes?: readonly ToolRecipe[] } = {},
|
|
42
44
|
): Promise<LspServerRegistry> {
|
|
43
45
|
const effective = await loadLayeredToolConfig(
|
|
44
46
|
packageDir,
|
|
@@ -55,9 +57,20 @@ export class LspServerRegistry {
|
|
|
55
57
|
available: await hasConfiguredExecutable(entry.config, packageDir, environment),
|
|
56
58
|
})),
|
|
57
59
|
);
|
|
60
|
+
const evidence = options.requireBuiltInEvidence
|
|
61
|
+
? await inspectRecipeEvidence(packageDir, options.recipes ?? [])
|
|
62
|
+
: undefined;
|
|
58
63
|
return new LspServerRegistry(
|
|
59
64
|
effective.entries,
|
|
60
|
-
new Set(
|
|
65
|
+
new Set(
|
|
66
|
+
available
|
|
67
|
+
.filter(
|
|
68
|
+
(entry) =>
|
|
69
|
+
entry.available &&
|
|
70
|
+
(evidence === undefined || (evidence.get(entry.id)?.score ?? 0) > 0),
|
|
71
|
+
)
|
|
72
|
+
.map((entry) => entry.id),
|
|
73
|
+
),
|
|
61
74
|
path.resolve(packageDir),
|
|
62
75
|
);
|
|
63
76
|
}
|
|
@@ -2,7 +2,7 @@ import type { LspClient } from "./client.js";
|
|
|
2
2
|
import type { LspPosition, LspTextEdit } from "./types.js";
|
|
3
3
|
|
|
4
4
|
export interface LspDocumentChange {
|
|
5
|
-
textDocument: { uri: string };
|
|
5
|
+
textDocument: { uri: string; version?: number | null };
|
|
6
6
|
edits: LspTextEdit[];
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -6,6 +6,32 @@ import { LspManager } from "./manager.js";
|
|
|
6
6
|
import { requestReferences } from "./navigation.js";
|
|
7
7
|
import { type LspWorkspaceSymbol, requestWorkspaceSymbols } from "./symbols.js";
|
|
8
8
|
|
|
9
|
+
/** Restrict symbol definitions and references before applying the result limit. */
|
|
10
|
+
export interface SymbolSearchScope {
|
|
11
|
+
readonly path?: string;
|
|
12
|
+
readonly include?: string;
|
|
13
|
+
readonly exclude?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function withinScope(file: string, cwd: string, scope: SymbolSearchScope): boolean {
|
|
17
|
+
const relative = path.relative(path.resolve(cwd, scope.path ?? "."), file);
|
|
18
|
+
// oxlint-disable-next-line repo/no-parent-paths -- reject results outside the requested scope.
|
|
19
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))
|
|
20
|
+
return false;
|
|
21
|
+
const candidate = path.relative(cwd, file).split(path.sep).join("/");
|
|
22
|
+
const matches = (patterns: string) =>
|
|
23
|
+
patterns.split(",").some((value) => {
|
|
24
|
+
const glob = value.trim();
|
|
25
|
+
return (
|
|
26
|
+
glob.length > 0 &&
|
|
27
|
+
path.matchesGlob(glob.includes("/") ? candidate : path.basename(file), glob)
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
return (
|
|
31
|
+
(scope.include === undefined || matches(scope.include)) &&
|
|
32
|
+
(scope.exclude === undefined || !matches(scope.exclude))
|
|
33
|
+
);
|
|
34
|
+
}
|
|
9
35
|
export interface SymbolHit {
|
|
10
36
|
filePath: string;
|
|
11
37
|
lineNumber: number;
|
|
@@ -50,13 +76,14 @@ export async function searchSymbols(
|
|
|
50
76
|
cwd: string,
|
|
51
77
|
limit: number,
|
|
52
78
|
signal?: AbortSignal,
|
|
79
|
+
scope: SymbolSearchScope = {},
|
|
80
|
+
manager = LspManager.getInstance(),
|
|
53
81
|
): Promise<SymbolHit[]> {
|
|
54
82
|
if (signal?.aborted) {
|
|
55
83
|
throw new Error("Operation aborted");
|
|
56
84
|
}
|
|
57
85
|
|
|
58
|
-
const
|
|
59
|
-
const clients = await manager.prepareWorkspaceSymbols(cwd);
|
|
86
|
+
const clients = await manager.prepareWorkspaceSymbols(cwd, scope.path ?? cwd);
|
|
60
87
|
const definitions: LspWorkspaceSymbol[] = [];
|
|
61
88
|
|
|
62
89
|
for (const client of clients) {
|
|
@@ -65,7 +92,7 @@ export async function searchSymbols(
|
|
|
65
92
|
}
|
|
66
93
|
|
|
67
94
|
try {
|
|
68
|
-
definitions.push(...(await requestWorkspaceSymbols(client, query,
|
|
95
|
+
definitions.push(...(await requestWorkspaceSymbols(client, query, Number.MAX_SAFE_INTEGER)));
|
|
69
96
|
} catch {
|
|
70
97
|
// A server without workspace/symbol support cannot contribute results.
|
|
71
98
|
}
|
|
@@ -93,7 +120,7 @@ export async function searchSymbols(
|
|
|
93
120
|
);
|
|
94
121
|
const definitionKey = `${definitionHit.filePath}:${definitionHit.lineNumber}:${definitionHit.column}`;
|
|
95
122
|
|
|
96
|
-
if (!seen.has(definitionKey)) {
|
|
123
|
+
if (withinScope(uriToFilePath(definition.uri), cwd, scope) && !seen.has(definitionKey)) {
|
|
97
124
|
seen.add(definitionKey);
|
|
98
125
|
hits.push(definitionHit);
|
|
99
126
|
}
|
|
@@ -125,7 +152,7 @@ export async function searchSymbols(
|
|
|
125
152
|
);
|
|
126
153
|
const key = `${hit.filePath}:${hit.lineNumber}:${hit.column}`;
|
|
127
154
|
|
|
128
|
-
if (!seen.has(key)) {
|
|
155
|
+
if (withinScope(uriToFilePath(reference.uri), cwd, scope) && !seen.has(key)) {
|
|
129
156
|
seen.add(key);
|
|
130
157
|
hits.push(hit);
|
|
131
158
|
}
|