pi-agent-ide 0.2.0 → 0.2.2
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 +57 -0
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/{chunk-2ZMYT6ZC.js → chunk-4U6KGABH.js} +1 -1
- package/dist/chunk-4ZTEPMJO.js +14 -0
- package/dist/{chunk-KNMWCDDK.js → chunk-6ACQQBUY.js} +1 -1
- package/dist/chunk-76WHES5H.js +7 -0
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/chunk-GFWDXTOB.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/chunk-JJVXUL5U.js +2 -0
- package/dist/chunk-KCEOTU5Z.js +3 -0
- package/dist/chunk-KVGQG43U.js +1 -0
- package/dist/{chunk-MTTKFJV6.js → chunk-LQYZG62K.js} +1 -1
- package/dist/chunk-N34ATN52.js +1 -0
- package/dist/{chunk-PETQCA7G.js → chunk-P6T3Q7LB.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-QJFRAMK7.js +2 -0
- package/dist/{chunk-2SKAED2I.js → chunk-RAZOACDD.js} +2 -2
- package/dist/chunk-RIGRP3FD.js +1 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/{chunk-266RH77Z.js → chunk-THSCUT2L.js} +1 -1
- package/dist/{chunk-EEH4WYI7.js → chunk-WNMGUALD.js} +1 -1
- package/dist/chunk-WZI4YC2O.js +1 -0
- package/dist/{chunk-5A25RATC.js → chunk-X6MPU7UO.js} +3 -3
- package/dist/{chunk-QNZVPFSP.js → chunk-XF5PVZOS.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZXN3TWWW.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.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 +7 -1
- package/dist/entry-27.js +1 -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 +8 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-34.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 +14 -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 -0
- package/dist/entry-54.js +0 -1
- package/dist/entry-55.js +1 -0
- package/dist/entry-56.js +0 -1
- package/dist/entry-57.js +1 -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 -0
- package/dist/entry-63.js +0 -1
- package/dist/entry-64.js +1 -0
- package/dist/entry-65.js +0 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +59 -1
- package/dist/entry-70.js +4 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +29 -1
- package/dist/entry-73.js +2 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +3 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -0
- package/dist/pi-agent-ide.js +2 -13
- package/docs/configuration.md +57 -1
- package/docs/extensions.md +4 -2
- package/docs/generated/tool-catalog/cmake.md +5 -5
- package/docs/generated/tool-catalog/csharp.md +5 -5
- package/docs/generated/tool-catalog/css.md +7 -7
- package/docs/generated/tool-catalog/dart.md +9 -0
- package/docs/generated/tool-catalog/dockerfile.md +5 -5
- package/docs/generated/tool-catalog/elixir.md +9 -0
- package/docs/generated/tool-catalog/html.md +7 -6
- package/docs/generated/tool-catalog/index.md +9 -0
- package/docs/generated/tool-catalog/javascript.md +8 -8
- package/docs/generated/tool-catalog/json.md +7 -7
- package/docs/generated/tool-catalog/julia.md +8 -0
- package/docs/generated/tool-catalog/kotlin.md +6 -5
- package/docs/generated/tool-catalog/markdown.md +6 -6
- package/docs/generated/tool-catalog/powershell.md +9 -0
- package/docs/generated/tool-catalog/python.md +6 -6
- package/docs/generated/tool-catalog/r.md +9 -0
- package/docs/generated/tool-catalog/scala.md +9 -0
- package/docs/generated/tool-catalog/svelte.md +9 -0
- package/docs/generated/tool-catalog/typescript.md +9 -8
- package/docs/generated/tool-catalog/vue.md +9 -0
- package/docs/generated/tool-catalog/yaml.md +6 -6
- package/docs/generated/tool-catalog/zig.md +9 -0
- package/docs/tools.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +10 -3
- package/node_modules/pi-agent-doctor/runtime/entry-20.js +1 -0
- package/node_modules/pi-agent-doctor/src/catalog.ts +27 -1
- package/node_modules/pi-agent-doctor/src/evidence.ts +118 -0
- package/node_modules/pi-agent-doctor/src/executable.ts +63 -17
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +4 -4
- package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/package.json +4 -4
- package/node_modules/pi-agent-filesystem-text/runtime/entry-24.js +2 -0
- package/node_modules/pi-agent-ide-ast/package.json +11 -11
- package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +0 -1
- package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +2 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +3 -0
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +92 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -14
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-changes/index.ts +1 -5
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +0 -1
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +4 -4
- package/node_modules/pi-agent-ide-formatter/src/catalog.ts +131 -13
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/node_modules/pi-agent-ide-formatter/src/registry.ts +20 -8
- package/node_modules/pi-agent-ide-languages/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/src/languages.ts +15 -0
- package/node_modules/pi-agent-ide-lint/index.ts +4 -1
- package/node_modules/pi-agent-ide-lint/package.json +8 -8
- package/node_modules/pi-agent-ide-lint/src/catalog.ts +196 -39
- package/node_modules/pi-agent-ide-lint/src/command-linter.ts +23 -3
- package/node_modules/pi-agent-ide-lint/src/diagnostics.ts +73 -33
- package/node_modules/pi-agent-ide-lint/src/registry.ts +20 -8
- package/node_modules/pi-agent-ide-lsp/index.ts +1 -12
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
- package/node_modules/pi-agent-ide-lsp/src/catalog.ts +161 -7
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +10 -10
- package/node_modules/pi-agent-ide-lsp/src/doctor-plugin.ts +2 -4
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +162 -12
- package/node_modules/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -4
- package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +69 -34
- package/node_modules/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/types.ts +5 -0
- package/node_modules/pi-agent-image/package.json +3 -3
- package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
- package/node_modules/pi-agent-invariant/package.json +2 -2
- package/node_modules/pi-agent-pdf/package.json +3 -3
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +1 -1
- package/node_modules/pi-agent-read/package.json +11 -11
- package/node_modules/pi-agent-read/runtime/entry-39.js +0 -1
- package/node_modules/pi-agent-read/runtime/entry-40.js +2 -0
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +6 -26
- 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/read-renderer.ts +28 -7
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/node_modules/pi-agent-resource/package.json +2 -2
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-search/package.json +7 -7
- package/node_modules/pi-agent-search/runtime/entry-44.js +0 -1
- package/node_modules/pi-agent-search/src/core/extension.ts +7 -5
- package/node_modules/pi-agent-search/src/core/search-core.ts +10 -0
- package/node_modules/pi-agent-search-text/index.ts +42 -33
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-search-text/runtime/entry-46.js +1 -0
- 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 +48 -0
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-48.js +1 -0
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
- package/node_modules/pi-agent-text-editor/package.json +22 -22
- package/node_modules/pi-agent-text-editor/runtime/entry-68.js +0 -1
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -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/text-anchor-registry.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- 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-argument-order/package.json +3 -3
- package/node_modules/pi-agent-text-editor-overwrite/package.json +4 -4
- package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -1
- 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 +52 -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 +5 -3
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- 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-tool-ui/runtime/entry-75.js +1 -0
- 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-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/node_modules/pi-agent-web-text/runtime/entry-80.js +2 -0
- package/package.json +35 -35
- package/src/api/plugin-protocol.ts +2 -0
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config/formatters.json +70 -12
- package/src/api/tool-config/linters.json +148 -66
- package/src/api/tool-config/lsp-servers.json +142 -7
- package/src/api/tool-config.ts +60 -24
- package/src/code-view/diagnostic-view.ts +14 -10
- package/src/composite/builtin-extensions.ts +148 -66
- package/src/composite/extensions-config.ts +18 -0
- package/src/core/diagnostic-entry.ts +94 -0
- package/src/core/diagnostic-store.ts +43 -21
- package/src/core/extension.ts +39 -17
- package/src/doctor/config-writer.ts +14 -1
- package/src/doctor/discovery.ts +13 -68
- package/src/doctor/run.ts +33 -1
- 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 +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-24.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-21.js +2 -0
- 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/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/plugins/pi-agent-web-text/runtime/entry-80.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +2 -0
- package/src/extensions/pi-agent-read/package.json +11 -11
- package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
- package/src/extensions/pi-agent-read/runtime/entry-40.js +2 -0
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -26
- 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/read-renderer.ts +28 -7
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/src/extensions/pi-agent-search/package.json +7 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +42 -33
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +1 -0
- 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 +48 -0
- package/src/extensions/pi-agent-search/runtime/entry-44.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-45.js +2 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +7 -5
- package/src/extensions/pi-agent-search/src/core/search-core.ts +10 -0
- package/src/extensions/pi-agent-text-editor/package.json +22 -22
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-49.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +2 -0
- 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 +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -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/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 +52 -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 +5 -3
- 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/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -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/text-anchor-registry.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- 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 +11 -0
- package/src/plugins/pi-agent-ide-ast/package.json +11 -11
- package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +2 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +3 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +92 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -14
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +1 -5
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +0 -1
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +1 -8
- package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
- package/src/plugins/pi-agent-ide-formatter/src/catalog.ts +131 -13
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/src/plugins/pi-agent-ide-formatter/src/registry.ts +20 -8
- package/src/plugins/pi-agent-ide-languages/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/src/languages.ts +15 -0
- package/src/plugins/pi-agent-ide-lint/index.ts +4 -1
- package/src/plugins/pi-agent-ide-lint/package.json +8 -8
- package/src/plugins/pi-agent-ide-lint/src/catalog.ts +196 -39
- package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +23 -3
- package/src/plugins/pi-agent-ide-lint/src/diagnostics.ts +73 -33
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +20 -8
- package/src/plugins/pi-agent-ide-lsp/index.ts +1 -12
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/runtime/entry-32.js +2 -0
- package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +161 -7
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +10 -10
- package/src/plugins/pi-agent-ide-lsp/src/doctor-plugin.ts +2 -4
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +162 -12
- package/src/plugins/pi-agent-ide-lsp/src/lsp/file-watchers.ts +88 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/initialization-options.ts +14 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -4
- package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +69 -34
- package/src/plugins/pi-agent-ide-lsp/src/lsp/transport-writer.ts +24 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/types.ts +5 -0
- package/src/post-edit/gate.ts +44 -15
- package/src/toolchain/types.ts +4 -0
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-476MR2QB.js +0 -1
- package/dist/chunk-4KQOODGE.js +0 -13
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-52BM6J6I.js +0 -6
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-7NDBZ4WX.js +0 -1
- package/dist/chunk-AP7Z3VWC.js +0 -1
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-E4SECPF4.js +0 -1
- 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-KP37XTDI.js +0 -1
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QW5O42QJ.js +0 -2
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-TNWYEXFG.js +0 -1
- package/dist/chunk-U4D6FT66.js +0 -1
- package/dist/chunk-VUNCBASK.js +0 -10
- package/dist/chunk-VWVLBOMU.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/dist/chunk-YQTLJ5ZV.js +0 -58
- package/node_modules/pi-agent-filesystem/runtime/entry-20.js +0 -2
- package/node_modules/pi-agent-ide-ast/runtime/entry-24.js +0 -1
- package/node_modules/pi-agent-ide-changes/runtime/entry-26.js +0 -1
- package/node_modules/pi-agent-image/runtime/entry-32.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/node_modules/pi-agent-resource/runtime/entry-40.js +0 -1
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-48.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-49.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-51.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-53.js +0 -1
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-75.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-21.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-20.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +0 -2
- package/src/extensions/pi-agent-read/runtime/entry-35.js +0 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-45.js +0 -2
- package/src/extensions/pi-agent-search/runtime/entry-41.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-48.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-49.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-51.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-69.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-53.js +0 -1
- package/src/plugins/pi-agent-ide-ast/runtime/entry-24.js +0 -1
- package/src/plugins/pi-agent-ide-changes/runtime/entry-26.js +0 -1
- /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-21.js +0 -0
- /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-22.js +0 -0
- /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-23.js +0 -0
- /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-28.js +0 -0
- /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-29.js +0 -0
- /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-30.js +0 -0
- /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-31.js +0 -0
- /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-33.js +0 -0
- /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-34.js +0 -0
- /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-35.js +0 -0
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-41.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-45.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-47.js +0 -0
- /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-69.js +0 -0
- /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-argument-order}/runtime/entry-70.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-overwrite}/runtime/entry-71.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
- /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-74.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-76.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-22.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-23.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-argument-order}/runtime/entry-70.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-overwrite}/runtime/entry-71.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
- /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-28.js +0 -0
- /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-29.js +0 -0
- /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-30.js +0 -0
- /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-31.js +0 -0
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { requiredValue } from "pi-agent-invariant";
|
|
2
2
|
import { type ChildProcess } from "node:child_process";
|
|
3
3
|
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
4
6
|
import spawnProcess from "cross-spawn";
|
|
5
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
configuredExecutableName,
|
|
9
|
+
createConfiguredProcessEnvironment,
|
|
10
|
+
} from "pi-agent-ide/api/tool-config";
|
|
6
11
|
import {
|
|
7
12
|
createMessageConnection,
|
|
8
13
|
CancellationTokenSource,
|
|
9
14
|
type MessageConnection,
|
|
10
15
|
StreamMessageReader,
|
|
11
|
-
StreamMessageWriter,
|
|
12
16
|
} from "vscode-jsonrpc/node";
|
|
13
17
|
import { URI } from "vscode-uri";
|
|
14
18
|
|
|
15
19
|
import type { LspDiagnostic } from "./types.js";
|
|
16
20
|
|
|
21
|
+
import { LspFileWatchers } from "./file-watchers.js";
|
|
22
|
+
|
|
23
|
+
import { TransportWriter } from "./transport-writer.js";
|
|
24
|
+
|
|
17
25
|
/** Latest push observation for an open document, without a completion guarantee. */
|
|
18
26
|
export interface LspDiagnosticPublication {
|
|
19
27
|
readonly version?: number;
|
|
@@ -34,9 +42,15 @@ export class LspClient {
|
|
|
34
42
|
private _disposed = false;
|
|
35
43
|
|
|
36
44
|
private _crashed = false;
|
|
45
|
+
|
|
46
|
+
private _stderr = "";
|
|
47
|
+
|
|
48
|
+
private _fileWatchers: LspFileWatchers | undefined;
|
|
37
49
|
private readonly _handlers = new Map<string, ((parameters: unknown) => void)[]>();
|
|
38
50
|
private readonly _documentVersions = new Map<string, number>();
|
|
39
51
|
|
|
52
|
+
private readonly _documentContents = new Map<string, string>();
|
|
53
|
+
|
|
40
54
|
private readonly _diagnosticPublications = new Map<string, LspDiagnosticPublication>();
|
|
41
55
|
private _diagnosticMode: "unknown" | "pull" | "push" = "unknown";
|
|
42
56
|
private readonly _activeDiagnosticRequests = new Set<string>();
|
|
@@ -83,6 +97,10 @@ export class LspClient {
|
|
|
83
97
|
return this._process?.pid ?? null;
|
|
84
98
|
}
|
|
85
99
|
|
|
100
|
+
/** Executable used to start this server, independent of its configured ID. */
|
|
101
|
+
get commandName(): string {
|
|
102
|
+
return configuredExecutableName(this._command);
|
|
103
|
+
}
|
|
86
104
|
get diagnosticMode(): "unknown" | "pull" | "push" {
|
|
87
105
|
return this._diagnosticMode;
|
|
88
106
|
}
|
|
@@ -142,6 +160,10 @@ export class LspClient {
|
|
|
142
160
|
const bin = requiredValue(this._command[0]);
|
|
143
161
|
const projectRoot = URI.parse(this.rootUri).fsPath;
|
|
144
162
|
|
|
163
|
+
const workspaceFolders = [
|
|
164
|
+
{ uri: this.rootUri, name: path.basename(projectRoot) || projectRoot },
|
|
165
|
+
];
|
|
166
|
+
|
|
145
167
|
const childProcess = spawnProcess(bin, this._args, {
|
|
146
168
|
stdio: ["pipe", "pipe", "pipe"],
|
|
147
169
|
cwd: projectRoot,
|
|
@@ -160,6 +182,12 @@ export class LspClient {
|
|
|
160
182
|
childProcess.stdout?.on("error", () => void 0);
|
|
161
183
|
childProcess.stderr?.on("error", () => void 0);
|
|
162
184
|
|
|
185
|
+
this._stderr = "";
|
|
186
|
+
childProcess.stderr?.setEncoding("utf8");
|
|
187
|
+
childProcess.stderr?.on("data", (chunk: string) => {
|
|
188
|
+
this._stderr = (this._stderr + chunk).slice(-4096);
|
|
189
|
+
});
|
|
190
|
+
|
|
163
191
|
childProcess.on("error", (error) => {
|
|
164
192
|
const code = "code" in error ? (error as { code?: unknown }).code : undefined;
|
|
165
193
|
|
|
@@ -174,6 +202,7 @@ export class LspClient {
|
|
|
174
202
|
});
|
|
175
203
|
|
|
176
204
|
childProcess.on("exit", (code, _signal) => {
|
|
205
|
+
this._fileWatchers?.dispose();
|
|
177
206
|
if (!this._disposed && code !== 0 && code !== null) {
|
|
178
207
|
this._crashed = true;
|
|
179
208
|
}
|
|
@@ -185,15 +214,77 @@ export class LspClient {
|
|
|
185
214
|
});
|
|
186
215
|
|
|
187
216
|
await spawnPromise;
|
|
188
|
-
|
|
217
|
+
const connection = createMessageConnection(
|
|
189
218
|
new StreamMessageReader(requiredValue(childProcess.stdout)),
|
|
190
|
-
new
|
|
219
|
+
new TransportWriter(requiredValue(childProcess.stdin), (error) => {
|
|
220
|
+
if (this._connection !== connection || this._disposed) return;
|
|
221
|
+
this._crashed = true;
|
|
222
|
+
this._initialized = false;
|
|
223
|
+
this._fileWatchers?.dispose();
|
|
224
|
+
connection.dispose();
|
|
225
|
+
console.error(`[lsp] ${this.serverId}: transport write failed:`, error);
|
|
226
|
+
}),
|
|
191
227
|
);
|
|
228
|
+
this._connection = connection;
|
|
192
229
|
|
|
193
230
|
this._connection.onError((error) => {
|
|
194
231
|
console.error(`[lsp] ${this.serverId}: connection error:`, error);
|
|
195
232
|
});
|
|
196
233
|
|
|
234
|
+
this._fileWatchers = new LspFileWatchers(
|
|
235
|
+
projectRoot,
|
|
236
|
+
(change) => {
|
|
237
|
+
this._sendNotification("workspace/didChangeWatchedFiles", { changes: [change] });
|
|
238
|
+
},
|
|
239
|
+
(error) => console.error(`[lsp] ${this.serverId}: file watcher failed:`, error),
|
|
240
|
+
);
|
|
241
|
+
this._connection.onRequest(
|
|
242
|
+
"client/registerCapability",
|
|
243
|
+
async (parameters: {
|
|
244
|
+
registrations: {
|
|
245
|
+
id: string;
|
|
246
|
+
method: string;
|
|
247
|
+
registerOptions?: { watchers?: Parameters<LspFileWatchers["register"]>[1] };
|
|
248
|
+
}[];
|
|
249
|
+
}) => {
|
|
250
|
+
for (const registration of parameters.registrations) {
|
|
251
|
+
// Settings are fixed for this client and already served by workspace/configuration.
|
|
252
|
+
if (registration.method === "workspace/didChangeConfiguration") continue;
|
|
253
|
+
if (registration.method !== "workspace/didChangeWatchedFiles")
|
|
254
|
+
throw new Error(`Unsupported dynamic capability: ${registration.method}`);
|
|
255
|
+
await this._fileWatchers?.register(
|
|
256
|
+
registration.id,
|
|
257
|
+
registration.registerOptions?.watchers ?? [],
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
},
|
|
262
|
+
);
|
|
263
|
+
this._connection.onRequest(
|
|
264
|
+
"client/unregisterCapability",
|
|
265
|
+
(parameters: { unregisterations: { id: string }[] }) => {
|
|
266
|
+
for (const registration of parameters.unregisterations)
|
|
267
|
+
this._fileWatchers?.unregister(registration.id);
|
|
268
|
+
return null;
|
|
269
|
+
},
|
|
270
|
+
);
|
|
271
|
+
this._connection.onRequest("window/workDoneProgress/create", () => null);
|
|
272
|
+
|
|
273
|
+
this._connection.onRequest(
|
|
274
|
+
"workspace/configuration",
|
|
275
|
+
(parameters: { items: { section?: string }[] }) =>
|
|
276
|
+
parameters.items.map((item) => {
|
|
277
|
+
let value: unknown = this._settings ?? null;
|
|
278
|
+
for (const segment of item.section?.split(".").filter(Boolean) ?? []) {
|
|
279
|
+
value =
|
|
280
|
+
typeof value === "object" && value !== null
|
|
281
|
+
? ((value as Record<string, unknown>)[segment] ?? null)
|
|
282
|
+
: null;
|
|
283
|
+
}
|
|
284
|
+
return value;
|
|
285
|
+
}),
|
|
286
|
+
);
|
|
287
|
+
|
|
197
288
|
this._connection.listen();
|
|
198
289
|
|
|
199
290
|
// Forward all incoming notifications to registered handlers
|
|
@@ -221,6 +312,8 @@ export class LspClient {
|
|
|
221
312
|
}
|
|
222
313
|
});
|
|
223
314
|
|
|
315
|
+
this._connection.onRequest("workspace/workspaceFolders", () => workspaceFolders);
|
|
316
|
+
|
|
224
317
|
interface InitResult {
|
|
225
318
|
capabilities: Record<string, unknown>;
|
|
226
319
|
}
|
|
@@ -229,14 +322,24 @@ export class LspClient {
|
|
|
229
322
|
this._connection.sendRequest<InitResult>("initialize", {
|
|
230
323
|
processId: process.pid,
|
|
231
324
|
rootUri: this.rootUri,
|
|
325
|
+
|
|
326
|
+
workspaceFolders,
|
|
232
327
|
capabilities: {
|
|
233
328
|
workspace: {
|
|
234
329
|
applyEdit: false,
|
|
330
|
+
|
|
331
|
+
configuration: true,
|
|
332
|
+
|
|
333
|
+
workspaceFolders: true,
|
|
334
|
+
|
|
335
|
+
didChangeWatchedFiles: { dynamicRegistration: true, relativePatternSupport: true },
|
|
235
336
|
symbol: { dynamicRegistration: false },
|
|
236
337
|
},
|
|
237
338
|
textDocument: {
|
|
238
339
|
synchronization: { didOpen: true, didChange: true, didClose: true },
|
|
239
340
|
publishDiagnostics: { relatedInformation: true },
|
|
341
|
+
|
|
342
|
+
diagnostic: { dynamicRegistration: false, relatedDocumentSupport: false },
|
|
240
343
|
documentSymbol: { hierarchicalDocumentSymbolSupport: true },
|
|
241
344
|
foldingRange: { lineFoldingOnly: true },
|
|
242
345
|
},
|
|
@@ -245,20 +348,30 @@ export class LspClient {
|
|
|
245
348
|
}),
|
|
246
349
|
this._timeoutMs,
|
|
247
350
|
`[lsp] ${this.serverId}: initialize timed out`,
|
|
248
|
-
)
|
|
351
|
+
).catch((error: unknown) => {
|
|
352
|
+
const detail = this._stderr.trim();
|
|
353
|
+
if (!detail) throw error;
|
|
354
|
+
throw new Error(`[lsp] ${this.serverId}: ${detail}`, { cause: error });
|
|
355
|
+
});
|
|
249
356
|
|
|
250
|
-
|
|
357
|
+
await this._connection.sendNotification("initialized", {
|
|
251
358
|
capabilities: initResult.capabilities,
|
|
252
359
|
});
|
|
253
360
|
|
|
254
361
|
if (this._settings !== undefined) {
|
|
255
|
-
|
|
362
|
+
await this._connection.sendNotification("workspace/didChangeConfiguration", {
|
|
256
363
|
settings: this._settings,
|
|
257
364
|
});
|
|
258
365
|
}
|
|
259
366
|
|
|
367
|
+
if (this._crashed)
|
|
368
|
+
throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);
|
|
369
|
+
|
|
260
370
|
this._initialized = true;
|
|
261
371
|
this._serverCapabilities = initResult.capabilities;
|
|
372
|
+
|
|
373
|
+
// Unadvertised methods may return null or internal errors rather than MethodNotFound.
|
|
374
|
+
this._diagnosticMode = initResult.capabilities.diagnosticProvider ? "pull" : "push";
|
|
262
375
|
}
|
|
263
376
|
|
|
264
377
|
touch(): void {
|
|
@@ -266,6 +379,7 @@ export class LspClient {
|
|
|
266
379
|
}
|
|
267
380
|
|
|
268
381
|
async restart(): Promise<void> {
|
|
382
|
+
this._fileWatchers?.dispose();
|
|
269
383
|
this._connection?.dispose();
|
|
270
384
|
this._connection = null;
|
|
271
385
|
this._process = null;
|
|
@@ -273,6 +387,7 @@ export class LspClient {
|
|
|
273
387
|
this._crashed = false;
|
|
274
388
|
this._disposed = false;
|
|
275
389
|
this._documentVersions.clear();
|
|
390
|
+
this._documentContents.clear();
|
|
276
391
|
this._diagnosticPublications.clear();
|
|
277
392
|
this._diagnosticMode = "unknown";
|
|
278
393
|
this._activeDiagnosticRequests.clear();
|
|
@@ -315,9 +430,23 @@ export class LspClient {
|
|
|
315
430
|
}
|
|
316
431
|
}
|
|
317
432
|
|
|
433
|
+
/** Queue a notification; a failed write makes this client unavailable without escaping to Pi. */
|
|
318
434
|
sendNotification(method: string, parameters: unknown): void {
|
|
319
435
|
this._assertReady();
|
|
320
|
-
|
|
436
|
+
this._sendNotification(method, parameters);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
private _sendNotification(method: string, parameters: unknown): void {
|
|
440
|
+
const connection = this._connection;
|
|
441
|
+
if (!connection) return;
|
|
442
|
+
void connection.sendNotification(method, parameters).catch((error: unknown) => {
|
|
443
|
+
if (this._connection !== connection || this._disposed) return;
|
|
444
|
+
this._crashed = true;
|
|
445
|
+
this._initialized = false;
|
|
446
|
+
this._fileWatchers?.dispose();
|
|
447
|
+
connection.dispose();
|
|
448
|
+
console.error(`[lsp] ${this.serverId}: notification ${method} failed:`, error);
|
|
449
|
+
});
|
|
321
450
|
}
|
|
322
451
|
|
|
323
452
|
/**
|
|
@@ -362,17 +491,31 @@ export class LspClient {
|
|
|
362
491
|
textDocument: { uri, languageId, version, text },
|
|
363
492
|
});
|
|
364
493
|
this._documentVersions.set(uri, version);
|
|
494
|
+
|
|
495
|
+
this._documentContents.set(uri, text);
|
|
365
496
|
}
|
|
366
497
|
|
|
367
|
-
|
|
498
|
+
/** Sync content, optionally reporting a completed disk write to servers that request saves. */
|
|
499
|
+
syncDocument(uri: string, text: string, languageId: string, saved = false): void {
|
|
500
|
+
if (this._documentContents.get(uri) === text) return;
|
|
368
501
|
const currentVersion = this._documentVersions.get(uri);
|
|
369
502
|
|
|
370
503
|
if (currentVersion === undefined) {
|
|
371
504
|
this.openDocument(uri, text, languageId);
|
|
372
|
-
|
|
505
|
+
} else {
|
|
506
|
+
this.changeDocument(uri, text, currentVersion + 1);
|
|
507
|
+
}
|
|
508
|
+
const synchronization = this._serverCapabilities?.textDocumentSync;
|
|
509
|
+
const save =
|
|
510
|
+
typeof synchronization === "object" && synchronization !== null
|
|
511
|
+
? (synchronization as { save?: boolean | { includeText?: boolean } }).save
|
|
512
|
+
: undefined;
|
|
513
|
+
if (saved && save) {
|
|
514
|
+
this.sendNotification("textDocument/didSave", {
|
|
515
|
+
textDocument: { uri },
|
|
516
|
+
...(typeof save === "object" && save.includeText && { text }),
|
|
517
|
+
});
|
|
373
518
|
}
|
|
374
|
-
|
|
375
|
-
this.changeDocument(uri, text, currentVersion + 1);
|
|
376
519
|
}
|
|
377
520
|
|
|
378
521
|
changeDocument(uri: string, text: string, version: number): void {
|
|
@@ -384,12 +527,16 @@ export class LspClient {
|
|
|
384
527
|
contentChanges: [{ text }],
|
|
385
528
|
});
|
|
386
529
|
this._documentVersions.set(uri, nextVersion);
|
|
530
|
+
|
|
531
|
+
this._documentContents.set(uri, text);
|
|
387
532
|
}
|
|
388
533
|
|
|
389
534
|
closeDocument(uri: string): void {
|
|
390
535
|
this.sendNotification("textDocument/didClose", { textDocument: { uri } });
|
|
391
536
|
this._documentVersions.delete(uri);
|
|
392
537
|
|
|
538
|
+
this._documentContents.delete(uri);
|
|
539
|
+
|
|
393
540
|
this._diagnosticPublications.delete(uri);
|
|
394
541
|
}
|
|
395
542
|
|
|
@@ -402,6 +549,8 @@ export class LspClient {
|
|
|
402
549
|
|
|
403
550
|
this._disposed = true;
|
|
404
551
|
|
|
552
|
+
this._fileWatchers?.dispose();
|
|
553
|
+
|
|
405
554
|
if (this._connection && this._initialized) {
|
|
406
555
|
try {
|
|
407
556
|
await withTimeout(
|
|
@@ -433,6 +582,7 @@ export class LspClient {
|
|
|
433
582
|
|
|
434
583
|
this._initialized = false;
|
|
435
584
|
this._documentVersions.clear();
|
|
585
|
+
this._documentContents.clear();
|
|
436
586
|
this._diagnosticPublications.clear();
|
|
437
587
|
this._diagnosticMode = "unknown";
|
|
438
588
|
this._activeDiagnosticRequests.clear();
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { watch, type FSWatcher } from "node:fs";
|
|
2
|
+
import { readdir, stat } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { URI } from "vscode-uri";
|
|
5
|
+
|
|
6
|
+
interface WatchPattern {
|
|
7
|
+
globPattern: string | { baseUri: string | { uri: string }; pattern: string };
|
|
8
|
+
kind?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** A native filesystem event translated to the LSP file change types. */
|
|
12
|
+
export interface WatchedFileChange {
|
|
13
|
+
uri: string;
|
|
14
|
+
type: 1 | 2 | 3;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Own the filesystem subscriptions requested by one language server. */
|
|
18
|
+
export class LspFileWatchers {
|
|
19
|
+
private readonly registrations = new Map<string, FSWatcher[]>();
|
|
20
|
+
|
|
21
|
+
private disposed = false;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
private readonly root: string,
|
|
25
|
+
private readonly changed: (change: WatchedFileChange) => void,
|
|
26
|
+
private readonly failed: (error: Error) => void,
|
|
27
|
+
) {}
|
|
28
|
+
|
|
29
|
+
/** Install all patterns for one workspace/didChangeWatchedFiles registration. */
|
|
30
|
+
async register(id: string, patterns: readonly WatchPattern[]): Promise<void> {
|
|
31
|
+
const watchers: FSWatcher[] = [];
|
|
32
|
+
try {
|
|
33
|
+
for (const pattern of patterns) {
|
|
34
|
+
const glob = pattern.globPattern;
|
|
35
|
+
const root =
|
|
36
|
+
typeof glob === "string"
|
|
37
|
+
? this.root
|
|
38
|
+
: URI.parse(typeof glob.baseUri === "string" ? glob.baseUri : glob.baseUri.uri).fsPath;
|
|
39
|
+
const expression = typeof glob === "string" ? glob : glob.pattern;
|
|
40
|
+
const matches = (file: string) =>
|
|
41
|
+
path.matchesGlob(path.isAbsolute(expression) ? path.join(root, file) : file, expression);
|
|
42
|
+
const existing = new Set((await readdir(root, { recursive: true })).filter(matches));
|
|
43
|
+
|
|
44
|
+
if (this.disposed) throw new Error("Language server file watchers are disposed");
|
|
45
|
+
const watcher = watch(root, { recursive: true }, (_event, name) => {
|
|
46
|
+
if (!name || !matches(name)) return;
|
|
47
|
+
void stat(path.join(root, name)).then(
|
|
48
|
+
() => {
|
|
49
|
+
if (!this.registrations.get(id)?.includes(watcher)) return;
|
|
50
|
+
const type = existing.has(name) ? 2 : 1;
|
|
51
|
+
existing.add(name);
|
|
52
|
+
if ((pattern.kind ?? 7) & (type === 1 ? 1 : 2))
|
|
53
|
+
this.changed({ uri: URI.file(path.join(root, name)).toString(), type });
|
|
54
|
+
},
|
|
55
|
+
(error: NodeJS.ErrnoException) => {
|
|
56
|
+
if (!this.registrations.get(id)?.includes(watcher)) return;
|
|
57
|
+
if (error.code !== "ENOENT") {
|
|
58
|
+
this.failed(error);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (existing.delete(name) && (pattern.kind ?? 7) & 4)
|
|
62
|
+
this.changed({ uri: URI.file(path.join(root, name)).toString(), type: 3 });
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
watcher.on("error", this.failed);
|
|
67
|
+
watchers.push(watcher);
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
for (const watcher of watchers) watcher.close();
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
this.unregister(id);
|
|
74
|
+
this.registrations.set(id, watchers);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Stop a server registration without affecting its other subscriptions. */
|
|
78
|
+
unregister(id: string): void {
|
|
79
|
+
for (const watcher of this.registrations.get(id) ?? []) watcher.close();
|
|
80
|
+
this.registrations.delete(id);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Close all subscriptions when the server exits or the session ends. */
|
|
84
|
+
dispose(): void {
|
|
85
|
+
this.disposed = true;
|
|
86
|
+
for (const id of this.registrations.keys()) this.unregister(id);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Expand the project path in JSON initialization options, including plugin locations. */
|
|
2
|
+
export function resolveInitializationOptions(
|
|
3
|
+
value: Record<string, unknown>,
|
|
4
|
+
projectRoot: string,
|
|
5
|
+
): Record<string, unknown> {
|
|
6
|
+
const expand = (item: unknown): unknown => {
|
|
7
|
+
if (typeof item === "string") return item.replaceAll("{project}", () => projectRoot);
|
|
8
|
+
if (Array.isArray(item)) return item.map(expand);
|
|
9
|
+
if (item !== null && typeof item === "object")
|
|
10
|
+
return Object.fromEntries(Object.entries(item).map(([key, child]) => [key, expand(child)]));
|
|
11
|
+
return item;
|
|
12
|
+
};
|
|
13
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, expand(item)]));
|
|
14
|
+
}
|
|
@@ -4,6 +4,8 @@ import path from "node:path";
|
|
|
4
4
|
import { URI } from "vscode-uri";
|
|
5
5
|
|
|
6
6
|
import { LspClient } from "./client.js";
|
|
7
|
+
|
|
8
|
+
import { resolveInitializationOptions } from "./initialization-options.js";
|
|
7
9
|
import { toDiagnostic } from "./diagnostics.js";
|
|
8
10
|
import { type LspDiagnostic, type ResolvedServer } from "./types.js";
|
|
9
11
|
|
|
@@ -159,7 +161,10 @@ export class LspManager {
|
|
|
159
161
|
command: match.config.command,
|
|
160
162
|
...(match.config.env && { env: match.config.env }),
|
|
161
163
|
...(match.config.initializationOptions && {
|
|
162
|
-
initOptions:
|
|
164
|
+
initOptions: resolveInitializationOptions(
|
|
165
|
+
match.config.initializationOptions,
|
|
166
|
+
URI.parse(rootUri).fsPath,
|
|
167
|
+
),
|
|
163
168
|
}),
|
|
164
169
|
...(match.config.settings && { settings: match.config.settings }),
|
|
165
170
|
...(match.config.timeoutMs && { timeoutMs: match.config.timeoutMs }),
|
|
@@ -299,16 +304,15 @@ export class LspManager {
|
|
|
299
304
|
cwd: string,
|
|
300
305
|
capability: "diagnostics" | "symbols" = "diagnostics",
|
|
301
306
|
): Promise<{ client: LspClient; uri: string; languageId: string } | null> {
|
|
302
|
-
const extension = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
|
|
303
307
|
const absolutePath = path.resolve(cwd, filePath);
|
|
304
|
-
const client = await this.getOrStart(
|
|
308
|
+
const client = await this.getOrStart(absolutePath, cwd, capability);
|
|
305
309
|
|
|
306
310
|
if (!client) {
|
|
307
311
|
return null;
|
|
308
312
|
}
|
|
309
313
|
|
|
310
314
|
const uri = client.toUri(absolutePath);
|
|
311
|
-
const resolved = this._registry.resolve(
|
|
315
|
+
const resolved = this._registry.resolve(absolutePath);
|
|
312
316
|
const languageId = resolved[0]?.languageId ?? "plaintext";
|
|
313
317
|
|
|
314
318
|
// Read file content for didOpen
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
2
4
|
|
|
3
5
|
import { hasConfiguredExecutable, loadLayeredToolConfig } from "pi-agent-ide/api/tool-config";
|
|
4
6
|
|
|
@@ -16,15 +18,14 @@ LSP server configuration in project, global, and built-in priority order.
|
|
|
16
18
|
export class LspServerRegistry {
|
|
17
19
|
private readonly _servers: Record<string, ServerConfig>;
|
|
18
20
|
private readonly _entries: readonly EffectiveToolConfigEntry<ServerConfig>[];
|
|
19
|
-
private readonly _entriesById: ReadonlyMap<string, EffectiveToolConfigEntry<ServerConfig>>;
|
|
20
21
|
private readonly _lookup: LanguageLookup;
|
|
21
22
|
|
|
22
23
|
private constructor(
|
|
23
24
|
entries: readonly EffectiveToolConfigEntry<ServerConfig>[],
|
|
24
25
|
availableBuiltIns: ReadonlySet<string>,
|
|
26
|
+
private readonly _projectRoot: string,
|
|
25
27
|
) {
|
|
26
28
|
this._entries = entries;
|
|
27
|
-
this._entriesById = new Map(entries.map((entry) => [entry.id, entry]));
|
|
28
29
|
const activeEntries = entries.filter(
|
|
29
30
|
(entry) => entry.layer !== "built-in" || availableBuiltIns.has(entry.id),
|
|
30
31
|
);
|
|
@@ -57,13 +58,14 @@ export class LspServerRegistry {
|
|
|
57
58
|
return new LspServerRegistry(
|
|
58
59
|
effective.entries,
|
|
59
60
|
new Set(available.filter((entry) => entry.available).map((entry) => entry.id)),
|
|
61
|
+
path.resolve(packageDir),
|
|
60
62
|
);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
Creates a project-layer registry from an already-parsed config.
|
|
65
67
|
*/
|
|
66
|
-
static fromConfig(config: LspServersConfig): LspServerRegistry {
|
|
68
|
+
static fromConfig(config: LspServersConfig, projectRoot = process.cwd()): LspServerRegistry {
|
|
67
69
|
return new LspServerRegistry(
|
|
68
70
|
Object.entries(config.servers).map(([id, server]) => ({
|
|
69
71
|
id,
|
|
@@ -72,38 +74,56 @@ export class LspServerRegistry {
|
|
|
72
74
|
sourcePath: "<memory>",
|
|
73
75
|
})),
|
|
74
76
|
new Set(),
|
|
77
|
+
path.resolve(projectRoot),
|
|
75
78
|
);
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
?
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
/** Resolve a file path or extension to servers in layer priority order. */
|
|
82
|
+
resolve(file: string): ResolvedServer[] {
|
|
83
|
+
const basename = path.basename(file);
|
|
84
|
+
const extension = path.extname(file) || (file.startsWith(".") ? file : `.${file}`);
|
|
85
|
+
const normalizeName = (name: string) =>
|
|
86
|
+
process.platform === "win32" ? name.toLowerCase() : name;
|
|
87
|
+
const matches: ResolvedServer[] = [];
|
|
88
|
+
for (const entry of this._entries) {
|
|
89
|
+
if (!this._servers[entry.id]) continue;
|
|
90
|
+
|
|
91
|
+
if (entry.config.requireRootMarker && !this.hasRootMarker(file, entry.config.rootMarkers))
|
|
92
|
+
continue;
|
|
93
|
+
for (const [languageId, language] of Object.entries(entry.config.languages)) {
|
|
94
|
+
if (
|
|
95
|
+
language.extensions.some(
|
|
96
|
+
(candidate) => candidate.toLowerCase() === extension.toLowerCase(),
|
|
97
|
+
) ||
|
|
98
|
+
language.fileNames?.some((name) => normalizeName(name) === normalizeName(basename))
|
|
99
|
+
) {
|
|
100
|
+
matches.push({
|
|
101
|
+
serverId: entry.id,
|
|
102
|
+
config: entry.config,
|
|
103
|
+
languageId,
|
|
104
|
+
layer: entry.layer,
|
|
105
|
+
sourcePath: entry.sourcePath,
|
|
106
|
+
});
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
89
110
|
}
|
|
111
|
+
return matches;
|
|
112
|
+
}
|
|
90
113
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!
|
|
94
|
-
|
|
114
|
+
private hasRootMarker(file: string, markers: readonly string[]): boolean {
|
|
115
|
+
let directory = path.dirname(path.resolve(this._projectRoot, file));
|
|
116
|
+
if (file.startsWith(".") && !file.includes(path.sep)) directory = this._projectRoot;
|
|
117
|
+
for (;;) {
|
|
118
|
+
const relative = path.relative(this._projectRoot, directory);
|
|
119
|
+
// This checks containment; it does not construct a parent-relative path.
|
|
120
|
+
// eslint-disable-next-line repo/no-parent-paths
|
|
121
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))
|
|
122
|
+
return false;
|
|
123
|
+
if (markers.some((marker) => existsSync(path.join(directory, marker)))) return true;
|
|
124
|
+
if (directory === this._projectRoot) return false;
|
|
125
|
+
directory = path.dirname(directory);
|
|
95
126
|
}
|
|
96
|
-
|
|
97
|
-
return serverIds.map((serverId) => {
|
|
98
|
-
const entry = requiredValue(this._entriesById.get(serverId));
|
|
99
|
-
return {
|
|
100
|
-
serverId,
|
|
101
|
-
config: entry.config,
|
|
102
|
-
languageId,
|
|
103
|
-
layer: entry.layer,
|
|
104
|
-
sourcePath: entry.sourcePath,
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
127
|
}
|
|
108
128
|
|
|
109
129
|
/**
|
|
@@ -131,10 +151,7 @@ export class LspServerRegistry {
|
|
|
131
151
|
Resolves a file extension to the canonical LSP languageId.
|
|
132
152
|
*/
|
|
133
153
|
languageId(extension: string): string {
|
|
134
|
-
|
|
135
|
-
? extension.toLowerCase()
|
|
136
|
-
: `.${extension.toLowerCase()}`;
|
|
137
|
-
return this._lookup.extToLanguageId.get(normalized) ?? extension.slice(1);
|
|
154
|
+
return this.resolve(extension)[0]?.languageId ?? extension.slice(1);
|
|
138
155
|
}
|
|
139
156
|
}
|
|
140
157
|
|
|
@@ -182,6 +199,13 @@ export function parseLspConfig(value: unknown): LspServersConfig {
|
|
|
182
199
|
throw new Error(`LSP server ${id}.rootMarkers must be a string array`);
|
|
183
200
|
}
|
|
184
201
|
|
|
202
|
+
if (server.requireRootMarker !== undefined && typeof server.requireRootMarker !== "boolean") {
|
|
203
|
+
throw new TypeError(`LSP server ${id}.requireRootMarker must be a boolean`);
|
|
204
|
+
}
|
|
205
|
+
if (server.requireRootMarker && (server.rootMarkers as string[]).length === 0) {
|
|
206
|
+
throw new Error(`LSP server ${id}.requireRootMarker requires rootMarkers`);
|
|
207
|
+
}
|
|
208
|
+
|
|
185
209
|
if (
|
|
186
210
|
typeof server.languages !== "object" ||
|
|
187
211
|
server.languages === null ||
|
|
@@ -205,6 +229,17 @@ export function parseLspConfig(value: unknown): LspServersConfig {
|
|
|
205
229
|
) {
|
|
206
230
|
throw new Error(`LSP server ${id} language ${language} requires extensions`);
|
|
207
231
|
}
|
|
232
|
+
|
|
233
|
+
const fileNames = (languageValue as Record<string, unknown>).fileNames;
|
|
234
|
+
if (
|
|
235
|
+
fileNames !== undefined &&
|
|
236
|
+
(!Array.isArray(fileNames) ||
|
|
237
|
+
fileNames.some(
|
|
238
|
+
(name) => typeof name !== "string" || name.length === 0 || /[/\\]/u.test(name),
|
|
239
|
+
))
|
|
240
|
+
) {
|
|
241
|
+
throw new Error(`LSP server ${id} language ${language}.fileNames must contain basenames`);
|
|
242
|
+
}
|
|
208
243
|
}
|
|
209
244
|
|
|
210
245
|
if (!Array.isArray(server.capabilities)) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Writable } from "node:stream";
|
|
2
|
+
import { StreamMessageWriter, type Message } from "vscode-jsonrpc/node";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Ends the connection on write failure instead of rejecting into JSON-RPC 9's
|
|
6
|
+
* async Promise executor. The owner must dispose the connection so pending
|
|
7
|
+
* requests reject; a failed transport must never look like a successful request.
|
|
8
|
+
*/
|
|
9
|
+
export class TransportWriter extends StreamMessageWriter {
|
|
10
|
+
constructor(
|
|
11
|
+
stream: Writable,
|
|
12
|
+
private readonly fail: (error: unknown) => void,
|
|
13
|
+
) {
|
|
14
|
+
super(stream);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override async write(message: Message): Promise<void> {
|
|
18
|
+
try {
|
|
19
|
+
await super.write(message);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
this.fail(error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|