pi-agent-ide 0.6.4 → 0.7.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 +38 -0
- package/README.md +2 -2
- package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
- package/dist/{chunk-QEJGED4V.js → chunk-3HYXQ4YA.js} +1 -1
- package/dist/chunk-3JO7QFIL.js +1 -0
- package/dist/{chunk-5J43L2RL.js → chunk-4NIFBFFR.js} +1 -1
- package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
- package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
- package/dist/chunk-7LZKOHH2.js +1 -0
- package/dist/chunk-AJRIASPQ.js +2 -0
- package/dist/chunk-EAZGN5ND.js +7 -0
- package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
- package/dist/chunk-FK42RSF4.js +1 -0
- package/dist/{chunk-WJTHY6AG.js → chunk-FXNKMNSJ.js} +1 -1
- package/dist/chunk-GBLKIB6O.js +2 -0
- package/dist/{chunk-KUPHNMUK.js → chunk-KBP3QUDT.js} +1 -1
- package/dist/{chunk-VBICI5YA.js → chunk-KR36BT5E.js} +1 -1
- package/dist/chunk-OE7QVAI2.js +5 -0
- package/dist/chunk-PNU3E7IO.js +3 -0
- package/dist/chunk-PS2B6THP.js +3 -0
- package/dist/{chunk-HPUAIWIH.js → chunk-PYPPV2F5.js} +1 -1
- package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
- package/dist/chunk-S5LXX32D.js +28 -0
- package/dist/chunk-SQKAXYIR.js +2 -0
- package/dist/chunk-VCGNVTXQ.js +1 -0
- package/dist/chunk-XYS4FSCC.js +12 -0
- package/dist/{chunk-FBOW7XOV.js → chunk-YRF7OATP.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-15.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.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 +13 -11
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -13
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +3 -6
- package/dist/entry-51.js +11 -9
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +0 -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 +1 -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 +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-71.js +0 -1
- package/dist/entry-72.js +1 -0
- package/dist/entry-73.js +0 -1
- package/dist/entry-74.js +1 -0
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +67 -1
- package/dist/entry-78.js +14 -325
- package/dist/entry-79.js +2 -18
- package/dist/entry-80.js +1 -2
- package/dist/entry-81.js +1 -1
- package/dist/entry-82.js +5 -1
- package/dist/entry-83.js +3 -5
- package/dist/entry-84.js +1 -3
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +5 -5
- package/docs/agent-guides/editing.md +20 -4
- package/docs/agent-guides/git-changes.md +1 -1
- package/docs/agent-guides/read-resources.md +9 -1
- package/docs/agent-guides/search-code.md +38 -1
- package/docs/agent-guides/select-code.md +194 -0
- package/docs/configuration.md +12 -17
- package/docs/development.md +2 -1
- package/docs/releases.md +1 -1
- package/docs/research/apply-native-capability-matrix.md +174 -0
- package/docs/research/apply-read-latency.md +2 -0
- package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
- package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
- package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
- package/docs/research/native-codemode-batch-decision.md +2 -0
- package/docs/research/native-codemode-batching.md +1 -1
- package/docs/structured-results.md +32 -5
- package/docs/tools.md +6 -2
- package/docs/user-hooks.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- 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 +15 -10
- package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -2
- package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +107 -21
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/node_modules/pi-agent-ide-changes/index.ts +2 -18
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +2 -2
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
- 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 +7 -7
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/node_modules/pi-agent-read/src/api/tools/read.ts +4 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +8 -1
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +10 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +233 -0
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +9 -3
- package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
- package/node_modules/pi-agent-search/src/api/search.ts +28 -0
- package/node_modules/pi-agent-search/src/api/structured-result.ts +69 -14
- package/node_modules/pi-agent-search/src/core/extension.ts +56 -16
- package/node_modules/pi-agent-search/src/core/search-core.ts +9 -1
- package/node_modules/pi-agent-search-text/index.ts +3 -1
- package/node_modules/pi-agent-search-text/package.json +7 -6
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/node_modules/pi-agent-search-text/src/resolvers.ts +161 -30
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -17
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +89 -292
- package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +96 -11
- package/node_modules/pi-agent-text/package.json +2 -2
- 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-editor/index.ts +0 -5
- package/node_modules/pi-agent-text-editor/package.json +26 -31
- package/node_modules/pi-agent-text-editor/runtime/entry-77.js +1 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
- package/node_modules/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +109 -11
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +1 -72
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- 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-80.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
- package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
- package/node_modules/pi-agent-web/index.ts +3 -0
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
- package/node_modules/pi-agent-web/src/search.ts +111 -2
- 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 +35 -36
- package/src/composite/module-labels.ts +1 -1
- package/src/composite/preferences.ts +0 -5
- 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 +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +3 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
- 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-83.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-82.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +111 -2
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +4 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +2 -0
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +8 -1
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +161 -30
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +89 -292
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +96 -11
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
- package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +9 -3
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
- package/src/extensions/pi-agent-search/src/api/search.ts +28 -0
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +69 -14
- package/src/extensions/pi-agent-search/src/core/extension.ts +56 -16
- package/src/extensions/pi-agent-search/src/core/search-core.ts +9 -1
- package/src/extensions/pi-agent-text-editor/index.ts +0 -5
- package/src/extensions/pi-agent-text-editor/package.json +26 -31
- 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-editor-renderer/index.ts +1 -72
- 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/runtime/entry-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
- 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-77.js +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +12 -2
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +199 -19
- package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +22 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +109 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +211 -223
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
- package/src/pi-agent-ide.ts +0 -6
- package/src/plugins/pi-agent-ide-ast/package.json +15 -10
- package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
- package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
- package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -2
- package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +107 -21
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
- package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
- package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
- package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +251 -0
- package/src/plugins/pi-agent-ide-changes/index.ts +2 -18
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +2 -2
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +88 -45
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +10 -36
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -1
- package/src/plugins/pi-agent-ide-vision/index.ts +19 -0
- package/dist/chunk-2P2OGO3G.js +0 -2
- package/dist/chunk-6EYWFBNG.js +0 -0
- package/dist/chunk-7AVXUV4A.js +0 -7
- package/dist/chunk-7WCZOO5I.js +0 -1
- package/dist/chunk-BAYETTZZ.js +0 -16
- package/dist/chunk-BVK5A7ED.js +0 -28
- package/dist/chunk-F7NVAC4Q.js +0 -0
- package/dist/chunk-FZBCKIJJ.js +0 -1
- package/dist/chunk-I5JLCFUX.js +0 -1
- package/dist/chunk-MIZAFRDR.js +0 -1
- package/dist/chunk-PJPA5EEE.js +0 -2
- package/dist/chunk-PXWDDBBC.js +0 -0
- package/dist/chunk-TQZBVOTT.js +0 -5
- package/dist/chunk-VWW3RLUX.js +0 -12
- package/dist/chunk-YHUTTZC6.js +0 -2
- package/dist/chunk-ZODCBFBL.js +0 -2
- package/dist/entry-87.js +0 -1
- package/docs/agent-guides/apply.md +0 -333
- package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
- package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -137
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +0 -1
- package/node_modules/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -2
- package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
- package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
- package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
- package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
- package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
- package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
- package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
- package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
- package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
- package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -137
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
- package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
- package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
- package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
- /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-81.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
package/dist/entry-37.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{a as Ce}from"./chunk-MGCHOGQD.js";import{a as _e,b as ke}from"./chunk-T6LX2RX5.js";import{a as Ae}from"./chunk-FBOW7XOV.js";import{a as je,b as Me,d as $e}from"./chunk-WJTHY6AG.js";import"./chunk-NNCZYO4Q.js";import{d as Ie}from"./chunk-BSICWXMH.js";import"./chunk-YHUTTZC6.js";import{a as Ee}from"./chunk-6CZO43OH.js";import{a as xe,b as De}from"./chunk-OBNING2A.js";import{a as qe}from"./chunk-ZTYWHL2F.js";import{a as Te,b as Oe}from"./chunk-7UGNGK7Y.js";import"./chunk-2P2OGO3G.js";import{a as D,b as E,c as $,d as k,j as me,k as fe,l as he}from"./chunk-KVHDMIZS.js";import"./chunk-ZPT5D4VP.js";import{a as be}from"./chunk-QDLTO5PH.js";import{a as ye,b as ve}from"./chunk-QIK2E64R.js";import"./chunk-KINKBPPX.js";import{b as Le,c as Se,g as Re,j as H,o as Pe}from"./chunk-M5MJP7Z2.js";import{a as we}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as v}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import sr from"node:path";var A=[{id:"vue-typescript-language-server",name:"vue-typescript-language-server",kind:"lsp",languages:["vue"],executables:["typescript-language-server"],dependencies:["typescript-language-server","@vue/typescript-plugin"],configFiles:["tsconfig.json"],documentation:"https://github.com/vuejs/language-tools/tree/master/packages/typescript-plugin",lsp:{command:["typescript-language-server","--stdio"],rootMarkers:["tsconfig.json","package.json"],languageIds:{vue:[".vue"]},initializationOptions:{plugins:[{name:"@vue/typescript-plugin",location:"{project}/node_modules/@vue/typescript-plugin",languages:["vue"]}]}}},m("elixir-ls",["elixir"],["elixir-ls"],["mix.exs"],{elixir:[".ex",".exs"]},["elixir-ls"],"https://github.com/elixir-lsp/elixir-ls",void 0,void 0,{elixirLS:{mcpEnabled:!1}}),m("metals",["scala"],["metals"],["build.sbt","project.scala",".bsp"],{scala:[".scala",".sc"]},["metals"],"https://scalameta.org/metals/"),{id:"angular-language-server",name:"angular-language-server",kind:"lsp",languages:["typescript","html"],executables:["ngserver"],dependencies:["@angular/language-server"],configFiles:["angular.json"],documentation:"https://github.com/angular/vscode-ng-language-service",lsp:{command:["ngserver","--stdio","--tsProbeLocations",".","--ngProbeLocations","."],rootMarkers:["angular.json"],requireRootMarker:!0,languageIds:{typescript:[".ts"],html:[".html"]}}},m("svelte-language-server",["svelte"],["svelteserver"],["svelte.config.js","package.json"],{svelte:[".svelte"]},["svelteserver","--stdio"],"https://github.com/sveltejs/language-tools/tree/master/packages/language-server",["svelte-language-server"]),m("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),m("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),m("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),m("clangd",["c","cpp"],["clangd"],[".clangd","compile_commands.json","CMakeLists.txt"],{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"]},["clangd"],"https://clangd.llvm.org/"),m("typescript-language-server",["javascript","typescript"],["typescript-language-server"],["tsconfig.json","jsconfig.json","package.json"],{javascript:[".js",".mjs",".cjs"],javascriptreact:[".jsx"],typescript:[".ts",".mts",".cts"],typescriptreact:[".tsx"]},["typescript-language-server","--stdio"],"https://github.com/typescript-language-server/typescript-language-server",["typescript-language-server"]),m("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),m("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),m("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),m("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),m("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),m("kotlin-language-server",["kotlin"],["kotlin-language-server"],["build.gradle.kts","pom.xml"],{kotlin:[".kt",".kts"]},["kotlin-language-server"],"https://github.com/fwcd/kotlin-language-server"),m("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),m("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),m("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),m("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),m("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),m("vscode-css-language-server",["css"],["vscode-css-language-server"],["package.json"],{css:[".css",".scss",".less"]},["vscode-css-language-server","--stdio"],"https://github.com/microsoft/vscode-css-languageservice",void 0,void 0,{css:{},scss:{},less:{}}),m("vscode-html-language-server",["html"],["vscode-html-language-server"],["package.json"],{html:[".html",".htm"]},["vscode-html-language-server","--stdio"],"https://github.com/microsoft/vscode-html-languageservice"),m("yaml-language-server",["yaml"],["yaml-language-server"],[".yamllint","package.json"],{yaml:[".yaml",".yml"]},["yaml-language-server","--stdio"],"https://github.com/redhat-developer/yaml-language-server"),m("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),m("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),m("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),m("kotlin-lsp",["kotlin"],["intellij-server"],["build.gradle.kts","build.gradle","pom.xml","settings.gradle.kts"],{kotlin:[".kt",".kts"]},["intellij-server","--stdio"],"https://github.com/Kotlin/kotlin-lsp"),m("julia-language-server",["julia"],["julia"],["Project.toml","JuliaProject.toml"],{julia:[".jl"]},["julia","--startup-file=no","--history-file=no","-e","using LanguageServer; runserver()"],"https://github.com/julia-vscode/LanguageServer.jl"),m("powershell-editor-services",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],{powershell:[".ps1",".psm1",".psd1"]},["pwsh","-NoProfile","-NonInteractive","-Command",'$ErrorActionPreference="Stop";Import-Module PowerShellEditorServices;$d=Join-Path (Get-Location) ".agents/tmp/powershell-lsp-$PID";[IO.Directory]::CreateDirectory($d)|Out-Null;Start-EditorServices -HostName Pi -HostProfileId Pi -HostVersion 1.0.0 -Stdio -LanguageServiceOnly -LogPath (Join-Path $d "server.log") -SessionDetailsPath (Join-Path $d "session.json")'],"https://github.com/PowerShell/PowerShellEditorServices"),m("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),m("vscode-json-language-server",["json"],["vscode-json-language-server"],["package.json"],{json:[".json",".jsonc"]},["vscode-json-language-server","--stdio"],"https://github.com/microsoft/vscode-json-languageservice"),m("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),m("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),m("docker-langserver",["dockerfile"],["docker-langserver"],["Dockerfile"],{dockerfile:[".dockerfile"]},["docker-langserver","--stdio"],"https://github.com/rcjsuen/dockerfile-language-server-nodejs",void 0,{dockerfile:["Dockerfile","Containerfile"]})];function m(r,e,t,n,s,i,o,u,a,l){return{id:r,name:r,kind:"lsp",languages:e,executables:t,configFiles:n,documentation:o,...u&&{dependencies:u},lsp:{command:i,rootMarkers:n,languageIds:s,...a&&{fileNames:a},...l&&{settings:l}}}}c(m,"recipe");import St from"node:path";import Rt from"cross-spawn";import{createMessageConnection as Pt,CancellationTokenSource as _t,StreamMessageReader as kt}from"vscode-jsonrpc/node";import{URI as Ne}from"vscode-uri";import{watch as vt}from"node:fs";import{readdir as bt,stat as wt}from"node:fs/promises";import I from"node:path";import{URI as X}from"vscode-uri";var U=class{constructor(e,t,n){this.root=e;this.changed=t;this.failed=n}static{c(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let n=[];try{for(let s of t){let i=s.globPattern,o=typeof i=="string"?this.root:X.parse(typeof i.baseUri=="string"?i.baseUri:i.baseUri.uri).fsPath,u=typeof i=="string"?i:i.pattern,a=c(p=>I.matchesGlob(I.isAbsolute(u)?I.join(o,p):p,u),"matches"),l=new Set((await bt(o,{recursive:!0})).filter(a));if(this.disposed)throw new Error("Language server file watchers are disposed");let d=vt(o,{recursive:!0},(p,g)=>{!g||!a(g)||wt(I.join(o,g)).then(()=>{if(!this.registrations.get(e)?.includes(d))return;let h=l.has(g)?2:1;l.add(g),(s.kind??7)&(h===1?1:2)&&this.changed({uri:X.file(I.join(o,g)).toString(),type:h})},h=>{if(this.registrations.get(e)?.includes(d)){if(h.code!=="ENOENT"){this.failed(h);return}l.delete(g)&&(s.kind??7)&4&&this.changed({uri:X.file(I.join(o,g)).toString(),type:3})}})});d.on("error",this.failed),n.push(d)}}catch(s){for(let i of n)i.close();throw s}this.unregister(e),this.registrations.set(e,n)}unregister(e){for(let t of this.registrations.get(e)??[])t.close();this.registrations.delete(e)}dispose(){this.disposed=!0;for(let e of this.registrations.keys())this.unregister(e)}};import{StreamMessageWriter as Lt}from"vscode-jsonrpc/node";var G=class extends Lt{constructor(t,n){super(t);this.fail=n}static{c(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(n){this.fail(n)}}};var C=class{static{c(this,"LspClient")}_process=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_crashed=!1;_stderr="";_fileWatchers;_handlers=new Map;_documentVersions=new Map;_documentContents=new Map;_diagnosticPublications=new Map;_diagnosticMode="unknown";_activeDiagnosticRequests=new Set;serverId;rootUri;_command;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._args=e.command.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get commandName(){return Le(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let t=this._serverCapabilities?.executeCommandProvider;return Array.isArray(t?.commands)&&t.commands.includes(e)}get hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}documentContent(e){return this._documentContents.get(e)}documentVersion(e){return this._documentVersions.get(e)}diagnosticPublication(e){return this._diagnosticPublications.get(e)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let e=v(this._command[0]),t=Ne.parse(this.rootUri).fsPath,n=[{uri:this.rootUri,name:St.basename(t)||t}],s=Rt(e,this._args,{stdio:["pipe","pipe","pipe"],cwd:t,env:Pe({command:this._command,env:this._env},t,process.env)});this._process=s;let i=Ct(s);s.stdin?.on("error",()=>{}),s.stdout?.on("error",()=>{}),s.stderr?.on("error",()=>{}),this._stderr="",s.stderr?.setEncoding("utf8"),s.stderr?.on("data",a=>{this._stderr=(this._stderr+a).slice(-4096)}),s.on("error",a=>{("code"in a?a.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,a),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null}),s.on("exit",(a,l)=>{this._fileWatchers?.dispose(),!this._disposed&&a!==0&&a!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1}),await i;let o=Pt(new kt(v(s.stdout)),new G(v(s.stdin),a=>{this._connection!==o||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),o.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,a))}));this._connection=o,this._connection.onError(a=>{console.error(`[lsp] ${this.serverId}: connection error:`,a)}),this._fileWatchers=new U(t,a=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[a]})},a=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,a)),this._connection.onRequest("client/registerCapability",async a=>{for(let l of a.registrations)if(l.method!=="workspace/didChangeConfiguration"){if(l.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${l.method}`);await this._fileWatchers?.register(l.id,l.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",a=>{for(let l of a.unregisterations)this._fileWatchers?.unregister(l.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",a=>a.items.map(l=>{let d=this._settings??null;for(let p of l.section?.split(".").filter(Boolean)??[])d=typeof d=="object"&&d!==null?d[p]??null:null;return d})),this._connection.listen(),this._connection.onNotification((a,...l)=>{if(a==="textDocument/publishDiagnostics"){let d=l[0];d&&typeof d.uri=="string"&&Array.isArray(d.diagnostics)&&this._documentVersions.has(d.uri)&&(d.version===void 0||d.version===this.documentVersion(d.uri))&&this._diagnosticPublications.set(d.uri,{diagnostics:d.diagnostics,...typeof d.version=="number"&&{version:d.version}})}for(let d of this._handlers.get(a)??[])d(l[0])}),this._connection.onRequest("workspace/workspaceFolders",()=>n);let u=await Ve(this._connection.sendRequest("initialize",{processId:process.pid,rootUri:this.rootUri,workspaceFolders:n,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:!0,relativePatternSupport:!0},symbol:{dynamicRegistration:!1}},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0},diagnostic:{dynamicRegistration:!1,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions}),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`).catch(a=>{let l=this._stderr.trim();throw l?new Error(`[lsp] ${this.serverId}: ${l}`,{cause:a}):a});if(await this._connection.sendNotification("initialized",{capabilities:u.capabilities}),this._settings!==void 0&&await this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._crashed)throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);this._initialized=!0,this._serverCapabilities=u.capabilities,this._diagnosticMode=u.capabilities.diagnosticProvider?"pull":"push"}touch(){}async restart(){this._fileWatchers?.dispose(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start()}async sendRequest(e,t,n){if(this._assertReady(),n?.throwIfAborted(),!n)return v(this._connection).sendRequest(e,t);let s=new _t,i;try{let o=v(this._connection).sendRequest(e,t,s.token);return await Promise.race([o,new Promise((u,a)=>{i=c(()=>{s.cancel(),a(n.reason)},"onAbort"),n.addEventListener("abort",i,{once:!0})})])}finally{i&&n.removeEventListener("abort",i),s.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let n=this._connection;n&&n.sendNotification(e,t).catch(s=>{this._connection!==n||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),n.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,s))})}onNotification(e,t){let n=this._handlers.get(e)??[];return n.push(t),this._handlers.set(e,n),()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}toUri(e){return e.startsWith("file://")?e:Ne.file(e).toString()}openDocument(e,t,n,s=1){let i=this._documentVersions.get(e);if(i!==void 0){this.changeDocument(e,t,Math.max(s,i+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:n,version:s,text:t}}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}syncDocument(e,t,n,s=!1){if(this._documentContents.get(e)===t)return;let i=this._documentVersions.get(e);i===void 0?this.openDocument(e,t,n):this.changeDocument(e,t,i+1);let o=this._serverCapabilities?.textDocumentSync,u=typeof o=="object"&&o!==null?o.save:void 0;s&&u&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof u=="object"&&u.includeText&&{text:t}})}changeDocument(e,t,n){let s=this._documentVersions.get(e),i=Math.max(n,(s??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:i},contentChanges:[{text:t}]}),this._documentVersions.set(e,i),this._documentContents.set(e,t)}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e)}async shutdown(){if(!this._disposed){if(this._disposed=!0,this._fileWatchers?.dispose(),this._connection&&this._initialized)try{await Ve(this._connection.sendRequest("shutdown"),Math.min(this._timeoutMs,1e3),`[lsp] ${this.serverId}: shutdown timed out`),await this._connection.sendNotification("exit").catch(()=>{})}catch{}this._connection?.dispose(),this._connection=null,this._process&&!this._process.killed&&(this._process.kill("SIGTERM"),setTimeout(()=>{this._process&&!this._process.killed&&this._process.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null}}dispose(){this.shutdown()}_assertReady(){if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(this._crashed)throw new Error(`[lsp] ${this.serverId}: crashed \u2014 call restart()`);if(!this._initialized)throw new Error(`[lsp] ${this.serverId}: not started \u2014 call start()`);if(!this._connection)throw new Error(`[lsp] ${this.serverId}: connection lost`)}};function Ct(r){return new Promise((e,t)=>{let n=c(()=>{r.off("spawn",s),r.off("error",i)},"cleanup"),s=c(()=>{n(),e()},"onSpawn"),i=c(o=>{n(),t(o)},"onError");r.once("spawn",s),r.once("error",i)})}c(Ct,"waitForSpawn");function Ve(r,e,t){return new Promise((n,s)=>{let i=setTimeout(()=>{s(new Error(t))},e);r.then(o=>{clearTimeout(i),n(o)}).catch(o=>{clearTimeout(i),s(o instanceof Error?o:new Error(String(o)))})})}c(Ve,"withTimeout");import{readFile as We}from"node:fs/promises";import{URI as ze}from"vscode-uri";var T={Error:1,Warning:2,Information:3,Hint:4};var Fe={command:"typescript.tsserverRequest",async request(r,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let i=await r.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:e,includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!Y(i)||i.success!==!0||!Array.isArray(i.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return i.body.map(xt)}))).flat()}};function B(r){return r.supportsCommand(Fe.command)?Fe:void 0}c(B,"completedDiagnosticAdapter");function xt(r){if(!Y(r)||typeof r.message!="string"||typeof r.code!="number"&&typeof r.code!="string"||!Y(r.startLocation)||!Number.isInteger(r.startLocation.line)||!Number.isInteger(r.startLocation.offset)||Number(r.startLocation.line)<1||Number(r.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(r.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(r.code),message:r.message,line:Number(r.startLocation.line),column:Number(r.startLocation.offset),severity:r.category==="error"?"error":r.category==="warning"?"warning":r.category==="suggestion"?"hint":"info"}}c(xt,"convertTypeScriptDiagnostic");function Y(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}c(Y,"isRecord");async function O(r,e,t,n={}){let s=new AbortController,i=AbortSignal.any([s.signal,...n.signal?[n.signal]:[]]),o=setTimeout(()=>s.abort(new Error(`[lsp] ${r.serverId}: diagnostics timed out for ${e}`)),r.timeoutMs);try{return await Dt(r,e,t,n.content,i)}finally{clearTimeout(o)}}c(O,"requestDiagnostics");async function Dt(r,e,t,n,s){if(s.throwIfAborted(),r.diagnosticMode!=="push"){let a=r.documentVersion(e);try{let l=await r.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},s);if(l.kind!=="full"||!Array.isArray(l.items))throw new Error("Invalid full diagnostic report");if(r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return r.setDiagnosticMode("pull"),He(l.items,!1,!0)}catch(l){if(!Et(l))throw l;r.setDiagnosticMode("push")}}let i=B(r);if(i){r.documentVersion(e)===void 0&&r.syncDocument(e,n??await We(ze.parse(e).fsPath,"utf8"),t??"plaintext");let a=r.documentVersion(e),l=await i.request(r,e,s);if(s.throwIfAborted(),r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return{diagnostics:l,syntaxErrors:[],otherDiagnostics:l,unversioned:!1,complete:!0}}s.throwIfAborted();let o=r.documentVersion(e)!==void 0,u=o?void 0:n??await We(ze.parse(e).fsPath,"utf8");s.throwIfAborted(),r.beginDiagnosticRequest(e);try{return await new Promise((a,l)=>{let d=r.documentVersion(e)??1,p=c(f=>{let w=f;w.uri!==e||!Array.isArray(w.diagnostics)||w.version!==void 0&&w.version!==d||r.documentVersion(e)===d&&(y(),a(He(w.diagnostics,w.version===void 0)))},"receive"),g=r.onNotification("textDocument/publishDiagnostics",p),h=c(()=>{y(),l(s.reason)},"onAbort");function y(){g(),s.removeEventListener("abort",h)}c(y,"cleanup"),s.addEventListener("abort",h,{once:!0});try{o||r.syncDocument(e,u??"",t??"plaintext");let f=r.diagnosticPublication(e);f&&p({uri:e,...f})}catch(f){y(),l(f)}})}finally{r.endDiagnosticRequest(e)}}c(Dt,"requestCurrentDiagnostics");function Q(r){return{code:String(r.code??"LSP"),message:r.message,line:r.range.start.line+1,column:r.range.start.character+1,severity:r.severity===T.Warning?"warning":r.severity===T.Information?"info":r.severity===T.Hint?"hint":"error"}}c(Q,"toDiagnostic");function He(r,e,t=!1){let n=r.map(Q);return{diagnostics:n,syntaxErrors:[],otherDiagnostics:n,unversioned:e,complete:t}}c(He,"classify");function Et(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code===-32601}c(Et,"isMethodNotFound");var It={1:"File",2:"Module",3:"Namespace",4:"Package",5:"Class",6:"Method",7:"Property",8:"Field",9:"Constructor",10:"Enum",11:"Interface",12:"Function",13:"Variable",14:"Constant",15:"String",16:"Number",17:"Boolean",18:"Array",19:"Object",20:"Key",21:"Null",22:"EnumMember",23:"Struct",24:"Event",25:"Operator",26:"TypeParameter"};function P(r){return It[r]??`SymbolKind(${r})`}c(P,"symbolKindName");async function Z(r,e){return await r.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}})??[]}c(Z,"requestDocumentSymbols");async function ee(r,e,t=100){return(await r.sendRequest("workspace/symbol",{query:e})??[]).slice(0,t)}c(ee,"requestWorkspaceSymbols");async function te(r,e,t,n){return await r.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:n})}c(te,"requestRename");import S from"node:path";import{URI as At}from"vscode-uri";import{readdir as jt,stat as Mt}from"node:fs/promises";import q from"node:path";import{URI as re}from"vscode-uri";function Ue(r,e){let t=c(n=>typeof n=="string"?n.replaceAll("{project}",()=>e):Array.isArray(n)?n.map(t):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([s,i])=>[s,t(i)])):n,"expand");return Object.fromEntries(Object.entries(r).map(([n,s])=>[n,t(s)]))}c(Ue,"resolveInitializationOptions");var x=class r{constructor(e){this._registry=e}static{c(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_openDocs=new Set;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!r._instance)throw new Error("[lsp] LspManager not initialized");return r._instance}static getInstanceOrNull(){return r._instance}static init(e){let t=r._instance;return t?._disposed?(t._registry=e,t._disposed=!1,t):(r._instance=new r(e),r._instance)}static async resetForTest(){r._instance&&(await r._instance.shutdownAll(),r._instance=null)}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,t,n){if(this._disposed)return null;let s=this._registry.resolve(e),i=n==="symbols"?s[0]:s.find(p=>p.config.capabilities.includes(n));if(!i)return null;let o=re.file(t).toString(),u=`${i.serverId}:${o}`,a=this._clientStarts.get(u);if(a)return a;let l=this._clients.get(u);if(l?.ready)return l;let d=this._startClient(u,o,i,l);this._clientStarts.set(u,d);try{return await d}finally{this._clientStarts.get(u)===d&&this._clientStarts.delete(u)}}async _startClient(e,t,n,s){let i=s??new C({serverId:n.serverId,rootUri:t,command:n.config.command,...n.config.env&&{env:n.config.env},...n.config.initializationOptions&&{initOptions:Ue(n.config.initializationOptions,re.parse(t).fsPath)},...n.config.settings&&{settings:n.config.settings},...n.config.timeoutMs&&{timeoutMs:n.config.timeoutMs}});try{s?await s.restart():await i.start()}catch(o){throw await i.shutdown().catch(()=>{}),o}if(this._disposed)throw await i.shutdown(),new Error(`[lsp] ${n.serverId}: manager disposed during startup`);return this._clients.set(e,i),this._subscribeToPushDiagnostics(e,i),i}async getWorkspaceClients(e,t="symbols",n=e){let s=new Set,i=new Set(this._registry.knownExtensions),o=new Set([".git",".cache","node_modules","dist","build"]),u=c(async l=>{if(i.size===0)return;let d;try{d=await jt(l,{withFileTypes:!0})}catch{return}for(let p of d){if(i.size===0)return;if(p.isDirectory()){o.has(p.name)||await u(q.join(l,p.name));continue}if(!p.isFile())continue;let g=q.extname(p.name).toLowerCase();if(!i.has(g))continue;let h=q.join(l,p.name),y=await this.openFile(h,e,t).catch(()=>null);y&&(s.add(y.client),i.delete(g))}},"visit"),a=q.resolve(e,n);if((await Mt(a)).isFile()){let l=await this.openFile(a,e,t);return l===null?[]:[l.client]}return await u(a),[...s]}async prepareWorkspaceSymbols(e,t=e){return this.getWorkspaceClients(e,"symbols",t)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}async openFile(e,t,n="diagnostics"){let s=q.resolve(t,e),i=await this.getOrStart(s,t,n);if(!i)return null;let o=i.toUri(s),a=this._registry.resolve(s)[0]?.languageId??"plaintext";try{let{readFile:l}=await import("node:fs/promises"),d=await l(s,"utf8");i.openDocument(o,d,a),this._openDocs.add(o)}catch{}return{client:i,uri:o,languageId:a}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let n=t.onNotification("textDocument/publishDiagnostics",s=>{let i=$t(s);if(!i||t.hasActiveDiagnosticRequest(i.uri))return;let o=t.documentVersion(i.uri);if(i.version!==void 0&&o!==void 0&&i.version<o)return;let u=`${e}:${i.uri}`,a=i.diagnostics.map(Q),l=JSON.stringify([i.version,o,a]);if(this._pushFingerprints.get(u)===l)return;this._pushFingerprints.set(u,l);let d={cwd:re.parse(t.rootUri).fsPath,serverId:t.serverId,uri:i.uri,diagnostics:a,...i.version!==void 0&&{version:i.version}};for(let p of this._pushHandlers)p(d)});this._pushUnsubscribers.set(e,n)}async shutdownAll(){this._disposed=!0,await Promise.allSettled(this._clientStarts.values());let e=[...this._clients.values()];await Promise.all(e.map(t=>t.shutdown()));for(let t of this._pushUnsubscribers.values())t();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear()}dispose(){this.shutdownAll()}};function $t(r){if(r===null||typeof r!="object")return;let e=r;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}c($t,"parsePushNotification");async function N(r,e,t){return await r.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}})??[]}c(N,"requestReferences");async function ne(r,e,t){let n=await r.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t}),s=n?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[i,o]=await Promise.all([r.sendRequest("callHierarchy/incomingCalls",{item:s}).catch(()=>[]),r.sendRequest("callHierarchy/outgoingCalls",{item:s}).catch(()=>[])]);return{items:n,incoming:i??[],outgoing:o??[]}}c(ne,"requestCallHierarchy");function Ge(r,e,t){let n=S.relative(S.resolve(e,t.path??"."),r);if(n===".."||n.startsWith(`..${S.sep}`)||S.isAbsolute(n))return!1;let s=S.relative(e,r).split(S.sep).join("/"),i=c(o=>o.split(",").some(u=>{let a=u.trim();return a.length>0&&S.matchesGlob(a.includes("/")?s:S.basename(r),a)}),"matches");return(t.include===void 0||i(t.include))&&(t.exclude===void 0||!i(t.exclude))}c(Ge,"withinScope");function J(r){try{return At.parse(r).fsPath}catch{return r.startsWith("file://")?decodeURIComponent(r.slice(7)):r}}c(J,"uriToFilePath");function Be(r,e,t,n,s){let i=J(t),o=S.relative(r,i);return{filePath:o.startsWith("..")?i:o,lineNumber:n+1,column:s+1,kind:String(e.kind),name:e.name}}c(Be,"toHit");async function se(r,e,t,n,s={},i=x.getInstance()){if(n?.aborted)throw new Error("Operation aborted");let o=await i.prepareWorkspaceSymbols(e,s.path??e),u=[];for(let d of o){if(n?.aborted)throw new Error("Operation aborted");try{u.push(...await ee(d,r,Number.MAX_SAFE_INTEGER))}catch{}}let a=new Set,l=[];for(let d of u){if(n?.aborted)throw new Error("Operation aborted");if(l.length>=t)break;let p=d.location,g=Be(e,d,p.uri,p.range.start.line,p.range.start.character),h=`${g.filePath}:${g.lineNumber}:${g.column}`;if(Ge(J(p.uri),e,s)&&!a.has(h)&&(a.add(h),l.push(g)),l.length>=t)break;let y=J(p.uri),f=await i.openFile(y,e,"symbols").catch(()=>null);if(!f)continue;let w=await N(f.client,f.uri,p.range.start).catch(()=>[]);for(let R of w){let z=Be(e,d,R.uri,R.range.start.line,R.range.start.character),ge=`${z.filePath}:${z.lineNumber}:${z.column}`;if(Ge(J(R.uri),e,s)&&!a.has(ge)&&(a.add(ge),l.push(z)),l.length>=t)break}}return l}c(se,"searchSymbols");import{readFile as V}from"node:fs/promises";import j from"node:path";import{fileURLToPath as Tt}from"node:url";var Ot={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},ie=10,oe=5,M=10;async function Xe(r,e,t,n,s){L(s);let i=await V(e,"utf8"),o=await W(r,e,n),u=F(o.symbols,t,o.displayPath),a=await V(o.filePath,"utf8");if(L(s),i!==a)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:o.filePath,range:u.range,content:a}}c(Xe,"resolveLspDeclaration");async function Ye(r,e,t,n,s){L(s);let i=await V(e,"utf8"),o=await W(r,e,n),u=F(o.symbols,t,o.displayPath);if(i!==await V(e,"utf8"))throw new Error("The rename source changed during resolution.");return L(s),{client:o.client,uri:o.uri,position:u.selectionRange.start,content:i}}c(Ye,"resolveLspRenameTarget");async function le(r,e,t,n,s){L(s);let i=await W(r,e,n),o=F(i.symbols,t,i.displayPath),u=await zt(i.filePath);L(s);let a=o.range.start.line+1,l=Math.min(o.range.end.line+1,u.lines.length),d=u.lines.slice(Math.max(0,a-1),Math.max(0,l)).map((g,h)=>{let y=a+h;return me({content:g,sourceLine:{source:i.filePath,lineNumber:y,content:g}})}),p={path:i.displayPath,heading:`symbol: ${k(o.selector)}`,details:[`defined in: ${i.displayPath}:${a}-${l} (${P(o.kind)})`],startLine:a,endLine:l,totalLines:u.lines.length,renderedLines:d};return fe([p],Ot)}c(le,"readLspSymbolBody");async function de(r,e,t,n,s){L(s);let i=await W(r,e,n),o=F(i.symbols,t,i.displayPath),u=await tt(i,o,s),a=new K(n);return await qt(i,o,u,a)}c(de,"readLspSymbolGraph");async function ue(r,e,t,n){L(n);let s=await W(r,e,t),i=new K(t),o=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`];for(let u of s.symbols){L(n);let a=await tt(s,u,n);o.push("",...await Wt(s,u,a,i))}return o.join(`
|
|
2
|
-
`)}c(
|
|
3
|
-
`)}c(
|
|
1
|
+
import{a as $e}from"./chunk-MGCHOGQD.js";import{a as Ae,b as Te}from"./chunk-T6LX2RX5.js";import{a as Ue}from"./chunk-YRF7OATP.js";import{a as Fe,b as ze,d as We}from"./chunk-FXNKMNSJ.js";import"./chunk-NNCZYO4Q.js";import{d as Ve}from"./chunk-64M3SQPG.js";import{a as qe}from"./chunk-6CZO43OH.js";import{a as Oe,b as Ne}from"./chunk-OBNING2A.js";import{a as Je,b as Ke}from"./chunk-AJRIASPQ.js";import{e as Xe}from"./chunk-FK42RSF4.js";import{a as Be}from"./chunk-ZTYWHL2F.js";import{a as He,b as Ge}from"./chunk-7UGNGK7Y.js";import"./chunk-PS2B6THP.js";import{H as oe}from"./chunk-SQKAXYIR.js";import{a as T,b as $,c as z,d as E,j as Re,k as Pe,l as Ce}from"./chunk-KVHDMIZS.js";import{m as Se}from"./chunk-ZPT5D4VP.js";import{a as xe}from"./chunk-QDLTO5PH.js";import{a as _e,b as ke}from"./chunk-QIK2E64R.js";import"./chunk-KINKBPPX.js";import{b as Ee,c as Ie,g as je,j as ee,o as Me}from"./chunk-M5MJP7Z2.js";import{a as De}from"./chunk-WZI4YC2O.js";import"./chunk-N34ATN52.js";import{a as L}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";import Lr from"node:path";var W=[{id:"vue-typescript-language-server",name:"vue-typescript-language-server",kind:"lsp",languages:["vue"],executables:["typescript-language-server"],dependencies:["typescript-language-server","@vue/typescript-plugin"],configFiles:["tsconfig.json"],documentation:"https://github.com/vuejs/language-tools/tree/master/packages/typescript-plugin",lsp:{command:["typescript-language-server","--stdio"],rootMarkers:["tsconfig.json","package.json"],languageIds:{vue:[".vue"]},initializationOptions:{plugins:[{name:"@vue/typescript-plugin",location:"{project}/node_modules/@vue/typescript-plugin",languages:["vue"]}]}}},h("elixir-ls",["elixir"],["elixir-ls"],["mix.exs"],{elixir:[".ex",".exs"]},["elixir-ls"],"https://github.com/elixir-lsp/elixir-ls",void 0,void 0,{elixirLS:{mcpEnabled:!1}}),h("metals",["scala"],["metals"],["build.sbt","project.scala",".bsp"],{scala:[".scala",".sc"]},["metals"],"https://scalameta.org/metals/"),{id:"angular-language-server",name:"angular-language-server",kind:"lsp",languages:["typescript","html"],executables:["ngserver"],dependencies:["@angular/language-server"],configFiles:["angular.json"],documentation:"https://github.com/angular/vscode-ng-language-service",lsp:{command:["ngserver","--stdio","--tsProbeLocations",".","--ngProbeLocations","."],rootMarkers:["angular.json"],requireRootMarker:!0,languageIds:{typescript:[".ts"],html:[".html"]}}},h("svelte-language-server",["svelte"],["svelteserver"],["svelte.config.js","package.json"],{svelte:[".svelte"]},["svelteserver","--stdio"],"https://github.com/sveltejs/language-tools/tree/master/packages/language-server",["svelte-language-server"]),h("dart-language-server",["dart"],["dart"],["pubspec.yaml","analysis_options.yaml"],{dart:[".dart"]},["dart","language-server","--protocol=lsp"],"https://dart.dev/tools/dart-language-server"),h("r-language-server",["r"],["Rscript"],["DESCRIPTION",".lintr",".Rprofile"],{r:[".r"]},["Rscript","-e","languageserver::run()"],"https://github.com/REditorSupport/languageserver"),h("zls",["zig"],["zls"],["build.zig","build.zig.zon","zls.json"],{zig:[".zig",".zon"]},["zls"],"https://zigtools.org/zls/"),h("clangd",["c","cpp"],["clangd"],[".clangd","compile_commands.json","CMakeLists.txt"],{c:[".c",".h"],cpp:[".cc",".cpp",".cxx",".hh",".hpp",".hxx"]},["clangd"],"https://clangd.llvm.org/"),h("typescript-language-server",["javascript","typescript"],["typescript-language-server"],["tsconfig.json","jsconfig.json","package.json"],{javascript:[".js",".mjs",".cjs"],javascriptreact:[".jsx"],typescript:[".ts",".mts",".cts"],typescriptreact:[".tsx"]},["typescript-language-server","--stdio"],"https://github.com/typescript-language-server/typescript-language-server",["typescript-language-server"]),h("basedpyright",["python"],["basedpyright-langserver","pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),h("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),h("rust-analyzer",["rust"],["rust-analyzer"],["Cargo.toml","rust-project.json"],{rust:[".rs"]},["rust-analyzer"],"https://rust-analyzer.github.io/"),h("csharp-ls",["csharp"],["csharp-ls"],[".sln",".csproj"],{csharp:[".cs"]},["csharp-ls"],"https://github.com/razzmatazz/csharp-language-server"),h("jdtls",["java"],["jdtls"],["pom.xml","build.gradle",".project"],{java:[".java"]},["jdtls"],"https://projects.eclipse.org/projects/eclipse.jdt.ls"),h("kotlin-language-server",["kotlin"],["kotlin-language-server"],["build.gradle.kts","pom.xml"],{kotlin:[".kt",".kts"]},["kotlin-language-server"],"https://github.com/fwcd/kotlin-language-server"),h("solargraph",["ruby"],["solargraph"],["Gemfile",".solargraph.yml"],{ruby:[".rb",".rake"]},["solargraph","stdio"],"https://solargraph.org/"),h("intelephense",["php"],["intelephense"],["composer.json"],{php:[".php"]},["intelephense","--stdio"],"https://intelephense.com/"),h("sourcekit-lsp",["swift"],["sourcekit-lsp"],["Package.swift"],{swift:[".swift"]},["sourcekit-lsp"],"https://github.com/swiftlang/sourcekit-lsp"),h("lua-language-server",["lua"],["lua-language-server"],[".luarc.json",".luarc.jsonc"],{lua:[".lua"]},["lua-language-server"],"https://luals.github.io/"),h("bash-language-server",["shell"],["bash-language-server"],[".shellcheckrc"],{shell:[".sh",".bash"]},["bash-language-server","start"],"https://github.com/bash-lsp/bash-language-server"),h("vscode-css-language-server",["css"],["vscode-css-language-server"],["package.json"],{css:[".css",".scss",".less"]},["vscode-css-language-server","--stdio"],"https://github.com/microsoft/vscode-css-languageservice",void 0,void 0,{css:{},scss:{},less:{}}),h("vscode-html-language-server",["html"],["vscode-html-language-server"],["package.json"],{html:[".html",".htm"]},["vscode-html-language-server","--stdio"],"https://github.com/microsoft/vscode-html-languageservice"),h("yaml-language-server",["yaml"],["yaml-language-server"],[".yamllint","package.json"],{yaml:[".yaml",".yml"]},["yaml-language-server","--stdio"],"https://github.com/redhat-developer/yaml-language-server"),h("taplo-lsp",["toml"],["taplo"],["taplo.toml"],{toml:[".toml"]},["taplo","lsp","stdio"],"https://taplo.tamasfe.dev/"),h("marksman",["markdown"],["marksman"],[".marksman.toml"],{markdown:[".md",".mdx"]},["marksman","server"],"https://github.com/artempyanykh/marksman"),h("terraform-ls",["terraform"],["terraform-ls"],[".terraform.lock.hcl"],{terraform:[".tf",".tfvars"]},["terraform-ls","serve"],"https://github.com/hashicorp/terraform-ls"),h("kotlin-lsp",["kotlin"],["intellij-server"],["build.gradle.kts","build.gradle","pom.xml","settings.gradle.kts"],{kotlin:[".kt",".kts"]},["intellij-server","--stdio"],"https://github.com/Kotlin/kotlin-lsp"),h("julia-language-server",["julia"],["julia"],["Project.toml","JuliaProject.toml"],{julia:[".jl"]},["julia","--startup-file=no","--history-file=no","-e","using LanguageServer; runserver()"],"https://github.com/julia-vscode/LanguageServer.jl"),h("powershell-editor-services",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],{powershell:[".ps1",".psm1",".psd1"]},["pwsh","-NoProfile","-NonInteractive","-Command",'$ErrorActionPreference="Stop";Import-Module PowerShellEditorServices;$d=Join-Path (Get-Location) ".agents/tmp/powershell-lsp-$PID";[IO.Directory]::CreateDirectory($d)|Out-Null;Start-EditorServices -HostName Pi -HostProfileId Pi -HostVersion 1.0.0 -Stdio -LanguageServiceOnly -LogPath (Join-Path $d "server.log") -SessionDetailsPath (Join-Path $d "session.json")'],"https://github.com/PowerShell/PowerShellEditorServices"),h("neocmakelsp",["cmake"],["neocmakelsp"],["CMakeLists.txt",".neocmake.toml",".neocmakelint.toml"],{cmake:[".cmake"]},["neocmakelsp","stdio"],"https://github.com/neocmakelsp/neocmakelsp",void 0,{cmake:["CMakeLists.txt"]}),h("vscode-json-language-server",["json"],["vscode-json-language-server"],["package.json"],{json:[".json",".jsonc"]},["vscode-json-language-server","--stdio"],"https://github.com/microsoft/vscode-json-languageservice"),h("lemminx",["xml"],["lemminx"],[".lemminx.json"],{xml:[".xml",".xsd",".xsl"]},["lemminx"],"https://github.com/eclipse-lemminx/lemminx"),h("sqls",["sql"],["sqls"],[".sqls.yml"],{sql:[".sql"]},["sqls"],"https://github.com/sqls-server/sqls"),h("docker-langserver",["dockerfile"],["docker-langserver"],["Dockerfile"],{dockerfile:[".dockerfile"]},["docker-langserver","--stdio"],"https://github.com/rcjsuen/dockerfile-language-server-nodejs",void 0,{dockerfile:["Dockerfile","Containerfile"]})];function h(r,e,t,n,s,o,i,d,a,l){return{id:r,name:r,kind:"lsp",languages:e,executables:t,configFiles:n,documentation:i,...d&&{dependencies:d},lsp:{command:o,rootMarkers:n,languageIds:s,...a&&{fileNames:a},...l&&{settings:l}}}}c(h,"recipe");import $t from"node:path";import Ot from"cross-spawn";import{createMessageConnection as Nt,CancellationTokenSource as qt,StreamMessageReader as Vt}from"vscode-jsonrpc/node";import{URI as Qe}from"vscode-uri";import{watch as jt}from"node:fs";import{readdir as Mt,stat as At}from"node:fs/promises";import O from"node:path";import{URI as ie}from"vscode-uri";var te=class{constructor(e,t,n){this.root=e;this.changed=t;this.failed=n}static{c(this,"LspFileWatchers")}registrations=new Map;disposed=!1;async register(e,t){let n=[];try{for(let s of t){let o=s.globPattern,i=typeof o=="string"?this.root:ie.parse(typeof o.baseUri=="string"?o.baseUri:o.baseUri.uri).fsPath,d=typeof o=="string"?o:o.pattern,a=c(p=>O.matchesGlob(O.isAbsolute(d)?O.join(i,p):p,d),"matches"),l=new Set((await Mt(i,{recursive:!0})).filter(a));if(this.disposed)throw new Error("Language server file watchers are disposed");let u=jt(i,{recursive:!0},(p,f)=>{!f||!a(f)||At(O.join(i,f)).then(()=>{if(!this.registrations.get(e)?.includes(u))return;let y=l.has(f)?2:1;l.add(f),(s.kind??7)&(y===1?1:2)&&this.changed({uri:ie.file(O.join(i,f)).toString(),type:y})},y=>{if(this.registrations.get(e)?.includes(u)){if(y.code!=="ENOENT"){this.failed(y);return}l.delete(f)&&(s.kind??7)&4&&this.changed({uri:ie.file(O.join(i,f)).toString(),type:3})}})});u.on("error",this.failed),n.push(u)}}catch(s){for(let o of n)o.close();throw s}this.unregister(e),this.registrations.set(e,n)}unregister(e){for(let t of this.registrations.get(e)??[])t.close();this.registrations.delete(e)}dispose(){this.disposed=!0;for(let e of this.registrations.keys())this.unregister(e)}};import{StreamMessageWriter as Tt}from"vscode-jsonrpc/node";var re=class extends Tt{constructor(t,n){super(t);this.fail=n}static{c(this,"TransportWriter")}async write(t){try{await super.write(t)}catch(n){this.fail(n)}}};var I=class{static{c(this,"LspClient")}_process=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_crashed=!1;_stderr="";_fileWatchers;_handlers=new Map;_documentVersions=new Map;_documentContents=new Map;_diagnosticPublications=new Map;_diagnosticMode="unknown";_activeDiagnosticRequests=new Set;serverId;rootUri;_command;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._args=e.command.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??null}get commandName(){return Ee(this._command)}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let t=this._serverCapabilities?.executeCommandProvider;return Array.isArray(t?.commands)&&t.commands.includes(e)}get hasWorkspaceSymbolCapability(){let e=this._serverCapabilities?.workspaceSymbolProvider;return e===!0||typeof e=="object"&&e!==null}get hasFoldingRangeCapability(){let e=this._serverCapabilities?.foldingRangeProvider;return e===!0||typeof e=="object"&&e!==null}documentContent(e){return this._documentContents.get(e)}documentVersion(e){return this._documentVersions.get(e)}diagnosticPublication(e){return this._diagnosticPublications.get(e)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let e=L(this._command[0]),t=Qe.parse(this.rootUri).fsPath,n=[{uri:this.rootUri,name:$t.basename(t)||t}],s=Ot(e,this._args,{stdio:["pipe","pipe","pipe"],cwd:t,env:Me({command:this._command,env:this._env},t,process.env)});this._process=s;let o=Ft(s);s.stdin?.on("error",()=>{}),s.stdout?.on("error",()=>{}),s.stderr?.on("error",()=>{}),this._stderr="",s.stderr?.setEncoding("utf8"),s.stderr?.on("data",a=>{this._stderr=(this._stderr+a).slice(-4096)}),s.on("error",a=>{("code"in a?a.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,a),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null}),s.on("exit",(a,l)=>{this._fileWatchers?.dispose(),!this._disposed&&a!==0&&a!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1}),await o;let i=Nt(new Vt(L(s.stdout)),new re(L(s.stdin),a=>{this._connection!==i||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),i.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,a))}));this._connection=i,this._connection.onError(a=>{console.error(`[lsp] ${this.serverId}: connection error:`,a)}),this._fileWatchers=new te(t,a=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[a]})},a=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,a)),this._connection.onRequest("client/registerCapability",async a=>{for(let l of a.registrations)if(l.method!=="workspace/didChangeConfiguration"){if(l.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${l.method}`);await this._fileWatchers?.register(l.id,l.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",a=>{for(let l of a.unregisterations)this._fileWatchers?.unregister(l.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/configuration",a=>a.items.map(l=>{let u=this._settings??null;for(let p of l.section?.split(".").filter(Boolean)??[])u=typeof u=="object"&&u!==null?u[p]??null:null;return u})),this._connection.listen(),this._connection.onNotification((a,...l)=>{if(a==="textDocument/publishDiagnostics"){let u=l[0];u&&typeof u.uri=="string"&&Array.isArray(u.diagnostics)&&this._documentVersions.has(u.uri)&&(u.version===void 0||u.version===this.documentVersion(u.uri))&&this._diagnosticPublications.set(u.uri,{diagnostics:u.diagnostics,...typeof u.version=="number"&&{version:u.version}})}for(let u of this._handlers.get(a)??[])u(l[0])}),this._connection.onRequest("workspace/workspaceFolders",()=>n);let d=await Ye(this._connection.sendRequest("initialize",{processId:process.pid,rootUri:this.rootUri,workspaceFolders:n,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:!0,relativePatternSupport:!0},symbol:{dynamicRegistration:!1}},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0},diagnostic:{dynamicRegistration:!1,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions}),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`).catch(a=>{let l=this._stderr.trim();throw l?new Error(`[lsp] ${this.serverId}: ${l}`,{cause:a}):a});if(await this._connection.sendNotification("initialized",{capabilities:d.capabilities}),this._settings!==void 0&&await this._connection.sendNotification("workspace/didChangeConfiguration",{settings:this._settings}),this._crashed)throw new Error(`[lsp] ${this.serverId}: transport failed during initialization`);this._initialized=!0,this._serverCapabilities=d.capabilities,this._diagnosticMode=d.capabilities.diagnosticProvider?"pull":"push"}touch(){}async restart(){this._fileWatchers?.dispose(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start()}async sendRequest(e,t,n){if(this._assertReady(),n?.throwIfAborted(),!n)return L(this._connection).sendRequest(e,t);let s=new qt,o;try{let i=L(this._connection).sendRequest(e,t,s.token);return await Promise.race([i,new Promise((d,a)=>{o=c(()=>{s.cancel(),a(n.reason)},"onAbort"),n.addEventListener("abort",o,{once:!0})})])}finally{o&&n.removeEventListener("abort",o),s.dispose()}}sendNotification(e,t){this._assertReady(),this._sendNotification(e,t)}_sendNotification(e,t){let n=this._connection;n&&n.sendNotification(e,t).catch(s=>{this._connection!==n||this._disposed||(this._crashed=!0,this._initialized=!1,this._fileWatchers?.dispose(),n.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,s))})}onNotification(e,t){let n=this._handlers.get(e)??[];return n.push(t),this._handlers.set(e,n),()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}toUri(e){return e.startsWith("file://")?e:Qe.file(e).toString()}openDocument(e,t,n,s=1){let o=this._documentVersions.get(e);if(o!==void 0){this.changeDocument(e,t,Math.max(s,o+1));return}this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:n,version:s,text:t}}),this._documentVersions.set(e,s),this._documentContents.set(e,t)}syncDocument(e,t,n,s=!1){if(this._documentContents.get(e)===t)return;let o=this._documentVersions.get(e);o===void 0?this.openDocument(e,t,n):this.changeDocument(e,t,o+1);let i=this._serverCapabilities?.textDocumentSync,d=typeof i=="object"&&i!==null?i.save:void 0;s&&d&&this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof d=="object"&&d.includeText&&{text:t}})}changeDocument(e,t,n){let s=this._documentVersions.get(e),o=Math.max(n,(s??0)+1);this._diagnosticPublications.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:o},contentChanges:[{text:t}]}),this._documentVersions.set(e,o),this._documentContents.set(e,t)}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e)}async shutdown(){if(!this._disposed){if(this._disposed=!0,this._fileWatchers?.dispose(),this._connection&&this._initialized)try{await Ye(this._connection.sendRequest("shutdown"),Math.min(this._timeoutMs,1e3),`[lsp] ${this.serverId}: shutdown timed out`),await this._connection.sendNotification("exit").catch(()=>{})}catch{}this._connection?.dispose(),this._connection=null,this._process&&!this._process.killed&&(this._process.kill("SIGTERM"),setTimeout(()=>{this._process&&!this._process.killed&&this._process.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._diagnosticMode="unknown",this._activeDiagnosticRequests.clear(),this._serverCapabilities=null}}dispose(){this.shutdown()}_assertReady(){if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(this._crashed)throw new Error(`[lsp] ${this.serverId}: crashed \u2014 call restart()`);if(!this._initialized)throw new Error(`[lsp] ${this.serverId}: not started \u2014 call start()`);if(!this._connection)throw new Error(`[lsp] ${this.serverId}: connection lost`)}};function Ft(r){return new Promise((e,t)=>{let n=c(()=>{r.off("spawn",s),r.off("error",o)},"cleanup"),s=c(()=>{n(),e()},"onSpawn"),o=c(i=>{n(),t(i)},"onError");r.once("spawn",s),r.once("error",o)})}c(Ft,"waitForSpawn");function Ye(r,e,t){return new Promise((n,s)=>{let o=setTimeout(()=>{s(new Error(t))},e);r.then(i=>{clearTimeout(o),n(i)}).catch(i=>{clearTimeout(o),s(i instanceof Error?i:new Error(String(i)))})})}c(Ye,"withTimeout");import{readFile as et}from"node:fs/promises";import{URI as tt}from"vscode-uri";var U={Error:1,Warning:2,Information:3,Hint:4};var Ze={command:"typescript.tsserverRequest",async request(r,e,t){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let o=await r.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:e,includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},t);if(!ae(o)||o.success!==!0||!Array.isArray(o.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return o.body.map(zt)}))).flat()}};function ne(r){return r.supportsCommand(Ze.command)?Ze:void 0}c(ne,"completedDiagnosticAdapter");function zt(r){if(!ae(r)||typeof r.message!="string"||typeof r.code!="number"&&typeof r.code!="string"||!ae(r.startLocation)||!Number.isInteger(r.startLocation.line)||!Number.isInteger(r.startLocation.offset)||Number(r.startLocation.line)<1||Number(r.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(r.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(r.code),message:r.message,line:Number(r.startLocation.line),column:Number(r.startLocation.offset),severity:r.category==="error"?"error":r.category==="warning"?"warning":r.category==="suggestion"?"hint":"info"}}c(zt,"convertTypeScriptDiagnostic");function ae(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}c(ae,"isRecord");async function H(r,e,t,n={}){let s=new AbortController,o=AbortSignal.any([s.signal,...n.signal?[n.signal]:[]]),i=setTimeout(()=>s.abort(new Error(`[lsp] ${r.serverId}: diagnostics timed out for ${e}`)),r.timeoutMs);try{return await Wt(r,e,t,n.content,o)}finally{clearTimeout(i)}}c(H,"requestDiagnostics");async function Wt(r,e,t,n,s){if(s.throwIfAborted(),r.diagnosticMode!=="push"){let a=r.documentVersion(e);try{let l=await r.sendRequest("textDocument/diagnostic",{textDocument:{uri:e}},s);if(l.kind!=="full"||!Array.isArray(l.items))throw new Error("Invalid full diagnostic report");if(r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return r.setDiagnosticMode("pull"),rt(l.items,!1,!0)}catch(l){if(!Ut(l))throw l;r.setDiagnosticMode("push")}}let o=ne(r);if(o){r.documentVersion(e)===void 0&&r.syncDocument(e,n??await et(tt.parse(e).fsPath,"utf8"),t??"plaintext");let a=r.documentVersion(e),l=await o.request(r,e,s);if(s.throwIfAborted(),r.documentVersion(e)!==a)throw new Error("Document changed during diagnostic request");return{diagnostics:l,syntaxErrors:[],otherDiagnostics:l,unversioned:!1,complete:!0}}s.throwIfAborted();let i=r.documentVersion(e)!==void 0,d=i?void 0:n??await et(tt.parse(e).fsPath,"utf8");s.throwIfAborted(),r.beginDiagnosticRequest(e);try{return await new Promise((a,l)=>{let u=r.documentVersion(e)??1,p=c(g=>{let v=g;v.uri!==e||!Array.isArray(v.diagnostics)||v.version!==void 0&&v.version!==u||r.documentVersion(e)===u&&(m(),a(rt(v.diagnostics,v.version===void 0)))},"receive"),f=r.onNotification("textDocument/publishDiagnostics",p),y=c(()=>{m(),l(s.reason)},"onAbort");function m(){f(),s.removeEventListener("abort",y)}c(m,"cleanup"),s.addEventListener("abort",y,{once:!0});try{i||r.syncDocument(e,d??"",t??"plaintext");let g=r.diagnosticPublication(e);g&&p({uri:e,...g})}catch(g){m(),l(g)}})}finally{r.endDiagnosticRequest(e)}}c(Wt,"requestCurrentDiagnostics");function ce(r){return{code:String(r.code??"LSP"),message:r.message,line:r.range.start.line+1,column:r.range.start.character+1,severity:r.severity===U.Warning?"warning":r.severity===U.Information?"info":r.severity===U.Hint?"hint":"error"}}c(ce,"toDiagnostic");function rt(r,e,t=!1){let n=r.map(ce);return{diagnostics:n,syntaxErrors:[],otherDiagnostics:n,unversioned:e,complete:t}}c(rt,"classify");function Ut(r){return r!==null&&typeof r=="object"&&"code"in r&&r.code===-32601}c(Ut,"isMethodNotFound");var Ht={1:"File",2:"Module",3:"Namespace",4:"Package",5:"Class",6:"Method",7:"Property",8:"Field",9:"Constructor",10:"Enum",11:"Interface",12:"Function",13:"Variable",14:"Constant",15:"String",16:"Number",17:"Boolean",18:"Array",19:"Object",20:"Key",21:"Null",22:"EnumMember",23:"Struct",24:"Event",25:"Operator",26:"TypeParameter"};function x(r){return Ht[r]??`SymbolKind(${r})`}c(x,"symbolKindName");async function G(r,e){return await r.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}})??[]}c(G,"requestDocumentSymbols");async function le(r,e,t=100){return(await r.sendRequest("workspace/symbol",{query:e})??[]).slice(0,t)}c(le,"requestWorkspaceSymbols");async function de(r,e,t,n){return await r.sendRequest("textDocument/rename",{textDocument:{uri:e},position:t,newName:n})}c(de,"requestRename");import{readFile as st,stat as ot}from"node:fs/promises";import k from"node:path";import{URI as Kt}from"vscode-uri";import{readdir as Gt,stat as Bt}from"node:fs/promises";import J from"node:path";import{URI as ue}from"vscode-uri";async function B(r,e){if(!r.supportsCommand("typescript.tsserverRequest"))return;if((await r.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:["projectInfo",{file:e,needFileNameList:!0},{isAsync:!1,expectsResult:!0}]}))?.success!==!0)throw new Error("TypeScript could not load the project for a workspace query.")}c(B,"prepareProjectQuery");function nt(r,e){let t=c(n=>typeof n=="string"?n.replaceAll("{project}",()=>e):Array.isArray(n)?n.map(t):n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([s,o])=>[s,t(o)])):n,"expand");return Object.fromEntries(Object.entries(r).map(([n,s])=>[n,t(s)]))}c(nt,"resolveInitializationOptions");var j=class r{constructor(e){this._registry=e}static{c(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_openDocs=new Set;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!r._instance)throw new Error("[lsp] LspManager not initialized");return r._instance}static getInstanceOrNull(){return r._instance}static init(e){let t=r._instance;return t?._disposed?(t._registry=e,t._disposed=!1,t):(r._instance=new r(e),r._instance)}static async resetForTest(){r._instance&&(await r._instance.shutdownAll(),r._instance=null)}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,t,n){if(this._disposed)return null;let s=this._registry.resolve(e),o=n==="symbols"?s[0]:s.find(p=>p.config.capabilities.includes(n));if(!o)return null;let i=ue.file(t).toString(),d=`${o.serverId}:${i}`,a=this._clientStarts.get(d);if(a)return a;let l=this._clients.get(d);if(l?.ready)return l;let u=this._startClient(d,i,o,l);this._clientStarts.set(d,u);try{return await u}finally{this._clientStarts.get(d)===u&&this._clientStarts.delete(d)}}async _startClient(e,t,n,s){let o=s??new I({serverId:n.serverId,rootUri:t,command:n.config.command,...n.config.env&&{env:n.config.env},...n.config.initializationOptions&&{initOptions:nt(n.config.initializationOptions,ue.parse(t).fsPath)},...n.config.settings&&{settings:n.config.settings},...n.config.timeoutMs&&{timeoutMs:n.config.timeoutMs}});try{s?await s.restart():await o.start()}catch(i){throw await o.shutdown().catch(()=>{}),i}if(this._disposed)throw await o.shutdown(),new Error(`[lsp] ${n.serverId}: manager disposed during startup`);return this._clients.set(e,o),this._subscribeToPushDiagnostics(e,o),o}async getWorkspaceClients(e,t="symbols",n=e){let s=new Set,o=new Set(this._registry.knownExtensions),i=new Set([".git",".cache","node_modules","dist","build"]),d=c(async l=>{if(o.size===0)return;let u;try{u=await Gt(l,{withFileTypes:!0})}catch{return}for(let p of u){if(o.size===0)return;if(p.isDirectory()){i.has(p.name)||await d(J.join(l,p.name));continue}if(!p.isFile())continue;let f=J.extname(p.name).toLowerCase();if(!o.has(f))continue;let y=J.join(l,p.name),m=await this.openFile(y,e,t).catch(()=>null);m&&(o.delete(f),m.client.hasWorkspaceSymbolCapability&&(await B(m.client,y),s.add(m.client)))}},"visit"),a=J.resolve(e,n);if((await Bt(a)).isFile()){let l=await this.openFile(a,e,t);return l===null||!l.client.hasWorkspaceSymbolCapability?[]:(await B(l.client,a),[l.client])}return await d(a),[...s]}async prepareWorkspaceSymbols(e,t=e){return this.getWorkspaceClients(e,"symbols",t)}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}isOpen(e){return this._openDocs.has(e)}async openFile(e,t,n="diagnostics"){let s=J.resolve(t,e),o=await this.getOrStart(s,t,n);if(!o)return null;let i=o.toUri(s),a=this._registry.resolve(s)[0]?.languageId??"plaintext";try{let{readFile:l}=await import("node:fs/promises"),u=await l(s,"utf8");o.openDocument(i,u,a),this._openDocs.add(i)}catch{}return{client:o,uri:i,languageId:a}}_subscribeToPushDiagnostics(e,t){if(this._pushUnsubscribers.has(e))return;let n=t.onNotification("textDocument/publishDiagnostics",s=>{let o=Jt(s);if(!o||t.hasActiveDiagnosticRequest(o.uri))return;let i=t.documentVersion(o.uri);if(o.version!==void 0&&i!==void 0&&o.version<i)return;let d=`${e}:${o.uri}`,a=o.diagnostics.map(ce),l=JSON.stringify([o.version,i,a]);if(this._pushFingerprints.get(d)===l)return;this._pushFingerprints.set(d,l);let u={cwd:ue.parse(t.rootUri).fsPath,serverId:t.serverId,uri:o.uri,diagnostics:a,...o.version!==void 0&&{version:o.version}};for(let p of this._pushHandlers)p(u)});this._pushUnsubscribers.set(e,n)}async shutdownAll(){this._disposed=!0,await Promise.allSettled(this._clientStarts.values());let e=[...this._clients.values()];await Promise.all(e.map(t=>t.shutdown()));for(let t of this._pushUnsubscribers.values())t();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear()}dispose(){this.shutdownAll()}};function Jt(r){if(r===null||typeof r!="object")return;let e=r;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}c(Jt,"parsePushNotification");async function K(r,e,t){return await r.sendRequest("textDocument/references",{textDocument:{uri:e},position:t,context:{includeDeclaration:!0}})??[]}c(K,"requestReferences");async function pe(r,e,t){let n=await r.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:t}),s=n?.[0];if(!s)return{items:[],incoming:[],outgoing:[]};let[o,i]=await Promise.all([r.sendRequest("callHierarchy/incomingCalls",{item:s}).catch(()=>[]),r.sendRequest("callHierarchy/outgoingCalls",{item:s}).catch(()=>[])]);return{items:n,incoming:o??[],outgoing:i??[]}}c(pe,"requestCallHierarchy");function it(r,e,t){let n=k.relative(k.resolve(e,t.path??"."),r);if(n===".."||n.startsWith(`..${k.sep}`)||k.isAbsolute(n))return!1;let s=k.relative(e,r).split(k.sep).join("/"),o=c(i=>i.split(",").some(d=>{let a=d.trim();return a.length>0&&k.matchesGlob(a.includes("/")?s:k.basename(r),a)}),"matches");return(t.include===void 0||o(t.include))&&(t.exclude===void 0||!o(t.exclude))}c(it,"withinPath");function Xt(r){let e=Kt.parse(r);if(e.scheme!=="file")throw new Error("LSP Search supports only file locations.");return k.resolve(e.fsPath)}c(Xt,"sourceOf");function Qt(r,e){return r.start.line===e.start.line&&r.start.character===e.start.character&&r.end.line===e.end.line&&r.end.character===e.end.character}c(Qt,"sameRange");function at(r,e,t){return r.flatMap(n=>[...n.name===e&&n.range!==void 0&&Qt(n.range,t)&&n.selectionRange!==void 0?[n.selectionRange]:[],...at(n.children??[],e,t)])}c(at,"declarationNames");async function ge(r,e,t,n,s={},o=j.getInstance()){n?.throwIfAborted();let i=s.resultScope;if(i!==void 0&&(await oe(i,n),i.targets.length===0))return{hits:[],complete:i.complete};let d=i?.targets.map(m=>m.source)??[s.path??e],a=new Set((await Promise.all(d.map(m=>o.prepareWorkspaceSymbols(e,m)))).flat());if(a.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let l=new Map,u=c(async m=>{n?.throwIfAborted();let g=Xt(m.uri),v=l.get(g);if(v===void 0){let b=await ot(g),w=await st(g,{encoding:"utf8",signal:n}),F=await ot(g);if(b.mtimeMs!==F.mtimeMs||b.size!==F.size)throw new Error("LSP source changed during search.");v=Se(g,w),l.set(g,v)}let{start:R,end:P}=m.range,V=[R,P];for(let b of V){let w=v.lines[b.line];if(!Number.isInteger(b.line)||!Number.isInteger(b.character)||w===void 0||b.character<0||b.character>w.content.length)throw new Error("LSP range does not match its source snapshot.")}let S=L(v.lines[R.line]),M=c(b=>v.lines.slice(0,b).reduce((w,F)=>w+F.content.length+F.lineEnding.length,0),"offset"),Z=M(R.line)+R.character,A=M(P.line)+P.character;if(A<Z)throw new Error("LSP returned a reversed source range.");return{source:g,lineNumber:R.line+1,endLineNumber:P.line+1,startColumn:R.character,endColumn:P.character,matchedText:v.content.slice(Z,A),lineText:S.content}},"toMatch"),p=c(m=>it(m.source,e,s)&&(i===void 0||Ke(i,m)),"included"),f=[],y=new Set;for(let m of a){n?.throwIfAborted();let g=await le(m,r,Number.MAX_SAFE_INTEGER);for(let v of g){n?.throwIfAborted();let R=await u(v.location),P=await o.openFile(R.source,e,"symbols");if(P===null)throw new Error("LSP references are unavailable for a discovered declaration.");let V=v.location;if(R.matchedText!==v.name){let b=await G(P.client,P.uri),w=at(b,v.name,v.location.range);if(w.length!==1)throw new Error("LSP declaration has no unique provider selectionRange; cannot search its references.");V={uri:P.uri,range:L(w[0])}}let S=await u(V),M={id:JSON.stringify([m.serverId,S.source,v.location.range]),name:v.name,kind:String(v.kind),source:S.source,range:{startLine:S.lineNumber,startColumn:S.startColumn,endLine:S.endLineNumber??S.lineNumber,endColumn:S.endColumn}},Z=await K(P.client,P.uri,V.range.start);n?.throwIfAborted();let A=[{...S,role:"definition",symbol:M}];for(let b of Z){let w=await u(b);w.source===S.source&&w.lineNumber===S.lineNumber&&w.startColumn===S.startColumn&&w.endLineNumber===S.endLineNumber&&w.endColumn===S.endColumn||A.push({...w,role:"reference",symbol:M})}if(!(s.navigation==="references"&&!A.some(p)))for(let b of A){if(s.navigation!=="references"&&!p(b)||s.navigation==="references"&&!it(b.source,e,{}))continue;let w=JSON.stringify([M.id,b.source,b.lineNumber,b.startColumn,b.endLineNumber,b.endColumn]);y.has(w)||(y.add(w),f.push(b))}}}n?.throwIfAborted();for(let[m,g]of l)if(await st(m,{encoding:"utf8",signal:n})!==g.content)throw new Error("LSP source changed during search.");return i!==void 0&&await oe(i,n),f.sort((m,g)=>m.source.localeCompare(g.source)||m.lineNumber-g.lineNumber||m.startColumn-g.startColumn||m.endColumn-g.endColumn||m.symbol.id.localeCompare(g.symbol.id)),{hits:f.slice(0,t),complete:(i?.complete??!0)&&f.length<=t}}c(ge,"searchSymbols");import{readFile as X}from"node:fs/promises";import N from"node:path";import{fileURLToPath as Yt}from"node:url";var Zt={failureLabel:"SYMBOL_READ_FAILED",emptyReason:"no symbol source was produced."},me=10,fe=5,q=10;async function dt(r,e,t,n,s){_(s);let o=await X(e,"utf8"),i=await Y(r,e,n),d=Q(i.symbols,t,i.displayPath),a=await X(i.filePath,"utf8");if(_(s),o!==a)throw new Error("The symbol source changed during resolution. Read it again before editing.");return{source:i.filePath,range:d.range,content:a}}c(dt,"resolveLspDeclaration");async function ut(r,e,t,n,s){_(s);let o=await X(e,"utf8"),i=await Y(r,e,n),d=Q(i.symbols,t,i.displayPath);if(o!==await X(e,"utf8"))throw new Error("The rename source changed during resolution.");return _(s),{client:i.client,uri:i.uri,position:d.selectionRange.start,content:o}}c(ut,"resolveLspRenameTarget");async function ve(r,e,t,n,s){_(s);let o=await Y(r,e,n),i=Q(o.symbols,t,o.displayPath),d=await or(o.filePath);_(s);let a=i.range.start.line+1,l=Math.min(i.range.end.line+1,d.lines.length),u=d.lines.slice(Math.max(0,a-1),Math.max(0,l)).map((f,y)=>{let m=a+y;return Re({content:f,sourceLine:{source:o.filePath,lineNumber:m,content:f}})}),p={path:o.displayPath,heading:`symbol: ${E(i.selector)}`,details:[`defined in: ${o.displayPath}:${a}-${l} (${x(i.kind)})`],startLine:a,endLine:l,totalLines:d.lines.length,renderedLines:u};return Pe([p],Zt)}c(ve,"readLspSymbolBody");async function be(r,e,t,n,s){_(s);let o=await Y(r,e,n),i=Q(o.symbols,t,o.displayPath),d=await ft(o,i,s),a=new se(n);return await er(o,i,d,a)}c(be,"readLspSymbolGraph");async function we(r,e,t,n){_(n);let s=await Y(r,e,t),o=new se(t),i=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`];for(let d of s.symbols){_(n);let a=await ft(s,d,n);i.push("",...await sr(s,d,a,o))}return i.join(`
|
|
2
|
+
`)}c(we,"readLspFileGraph");function Q(r,e,t){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");if(e.length===1){let o=mt(r,L(e[0]));if(o.length===1)return L(o[0]);throw o.length>1?new Error(`Symbol selector "${E(e)}" is ambiguous in ${t}; use parent/child.`):ct(e,t)}let n=r,s;for(let o of e){let i=n.filter(d=>d.name===o);if(i.length===0)throw ct(e,t);if(i.length>1)throw new Error(`Symbol selector "${E(e)}" is ambiguous at "${o}" in ${t}.`);s=L(i[0]),n=s.children}return L(s)}c(Q,"resolveLspCodeSymbol");async function Y(r,e,t){let n=N.isAbsolute(e)?N.normalize(e):N.resolve(t,e),s=await r.openFile(n,t,"symbols");if(!s)throw new Error(`No LSP server with symbol support is configured for ${ye(n,t)}.`);let o=await G(s.client,s.uri),i=pt(o).sort(gt);return{client:s.client,uri:s.uri,filePath:n,displayPath:ye(n,t),symbols:i}}c(Y,"openCodeDocument");function pt(r,e=[]){return r.flatMap(t=>{let n=t.selectionRange??t.range;if(!n)return[];let s=t.range??n,o=[...e,t.name];return[{name:t.name,kind:t.kind,range:s,selectionRange:n,selector:o,children:pt(t.children??[],o).sort(gt)}]})}c(pt,"normalizeDocumentSymbols");function gt(r,e){return r.range.start.line-e.range.start.line||r.range.start.character-e.range.start.character||r.name.localeCompare(e.name)}c(gt,"compareSymbols");function mt(r,e){return r.flatMap(t=>[...t.name===e?[t]:[],...mt(t.children,e)])}c(mt,"collectNamedSymbols");function ct(r,e){return new Error(`Symbol "${E(r)}" was not found in ${e}.`)}c(ct,"symbolNotFound");async function ft(r,e,t){let n=e.selectionRange.start,[s,o]=await Promise.all([lt(K(r.client,r.uri,n),[],t),lt(pe(r.client,r.uri,n),{items:[],incoming:[],outgoing:[]},t)]);return _(t),{references:s,calls:o}}c(ft,"queryRelations");async function lt(r,e,t){try{let n=await r;return _(t),n}catch(n){if(t?.aborted===!0)throw yt(t,n);return e}}c(lt,"optionalRequest");async function er(r,e,t,n){let s=E(e.selector),o=await n.line(r.uri,e.selectionRange.start.line+1);return[`## graph: ${s}`,`Definition: ${r.displayPath} ${o} (${x(e.kind)})`,`Source: ${z("graph",r.displayPath,e.selector)}`,"",...await tr(t.references,n),"",...await rr(t.calls.incoming,n),"",...await nr(t.calls.outgoing,n)].join(`
|
|
3
|
+
`)}c(er,"formatSymbolGraph");async function tr(r,e){let t=ht(r),n=[`References: ${r.length} in ${t.length} file(s)`];for(let[s,o]of t.slice(0,me)){n.push(`- ${e.display(s)} (${o.length})`);for(let i of o.slice(0,fe))n.push(` - ${await e.line(s,i.range.start.line+1)}`);o.length>fe&&n.push(` - ... ${o.length-fe} more`)}return t.length>me&&n.push(`- ... ${t.length-me} more file(s)`),n}c(tr,"formatReferences");async function rr(r,e){let t=[`Incoming calls: ${r.length}`];for(let n of r.slice(0,q)){let s=n.fromRanges[0]?.start.line??n.from.selectionRange.start.line,o=await e.line(n.from.uri,s+1);t.push(`- ${x(n.from.kind)} ${n.from.name} \u2014 ${e.display(n.from.uri)} ${o}`)}return r.length>q&&t.push(`- ... ${r.length-q} more`),t}c(rr,"formatIncomingCalls");async function nr(r,e){let t=[`Outgoing calls: ${r.length}`];for(let n of r.slice(0,q)){let s=await e.line(n.to.uri,n.to.selectionRange.start.line+1);t.push(`- ${x(n.to.kind)} ${n.to.name} \u2014 ${e.display(n.to.uri)} ${s}`)}return r.length>q&&t.push(`- ... ${r.length-q} more`),t}c(nr,"formatOutgoingCalls");async function sr(r,e,t,n){let s=x(e.kind),o=await n.line(r.uri,e.selectionRange.start.line+1),i=ht(t.references).map(([u,p])=>`${n.display(u)} (${p.length})`),d=t.calls.incoming.map(u=>`${u.from.name} (${n.display(u.from.uri)})`),a=t.calls.outgoing.map(u=>`${u.to.name} (${n.display(u.to.uri)})`),l=[`### ${s} ${e.name}`,`Selector: ${E(e.selector)}`,`Definition: ${o}`,`Used by: ${he(i)}`,`Incoming calls: ${he(d)}`,`Outgoing calls: ${he(a)}`];if(e.children.length>0){l.push("Members:");for(let u of e.children){let p=z("graph",r.displayPath,u.selector);l.push(`- ${x(u.kind)} ${u.name} \u2014 ${p}`)}}return l}c(sr,"formatFileGraphSymbol");function he(r,e=5){if(r.length===0)return"none";let t=r.slice(0,e).join(", ");return r.length>e?`${t}, ... ${r.length-e} more`:t}c(he,"summarize");function ht(r){let e=new Map;for(let t of r){let n=e.get(t.uri)??[];n.push(t),e.set(t.uri,n)}return[...e].map(([t,n])=>[t,n.sort((s,o)=>s.range.start.line-o.range.start.line||s.range.start.character-o.range.start.character)]).sort(([t],[n])=>t.localeCompare(n))}c(ht,"groupLocationsByUri");async function or(r){let e=await X(r);if(e.byteLength>256*1024)throw new Error(`File exceeds the 262144-byte code-view limit: ${r}`);if(e.includes(0))throw new Error(`File appears to be binary and cannot be read as text: ${r}`);let t=e.toString("utf8").replaceAll(`\r
|
|
4
4
|
`,`
|
|
5
5
|
`),n=t.endsWith(`
|
|
6
6
|
`)?t.slice(0,-1):t,s=n.length===0?[]:n.split(`
|
|
7
|
-
`);return{content:t,lines:s}}c(zt,"readTextFile");var K=class{static{c(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return ce(Ht(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function Ht(r){if(!r.startsWith("file://"))return r;try{return Tt(r)}catch{return decodeURIComponent(r.slice(7))}}c(Ht,"filePathFromUri");function ce(r,e){let t=j.relative(e,r);return t.length===0||t.startsWith("..")||j.isAbsolute(t)?r:t.replaceAll(j.sep,"/")}c(ce,"displayFilePath");function L(r){if(r?.aborted===!0)throw nt(r)}c(L,"throwIfAborted");function nt(r,e){if(r.reason instanceof Error)return r.reason;if(e instanceof Error)return e;let t=new Error("The operation was aborted");return t.name="AbortError",t}c(nt,"abortReason");function pe(r){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:c(()=>Promise.resolve(!0),"detect"),async compile({filePath:t},n){let s=await Ut(t,n,r);if(!s)return Gt();let{client:i,diagnostics:o,syntaxErrors:u,otherDiagnostics:a}=s;return e=i,{ok:!o.some(l=>l.severity==="error"),diagnostics:o,syntaxErrors:u,otherDiagnostics:a}},async restart(){e&&(await e.restart(),e=null)}}}c(pe,"createLspCompiler");async function Ut(r,e,t){let n=await t.openFile(r,e.cwd);if(!n)return null;let s=await O(n.client,n.uri,n.languageId);return{client:n.client,...s}}c(Ut,"openAndDiagnose");function Gt(){return{ok:!0,diagnostics:[],syntaxErrors:[],otherDiagnostics:[]}}c(Gt,"skipOk");import b from"node:path";import{existsSync as Bt}from"node:fs";function st(r){let e=new Map,t=new Map;for(let[n,s]of Object.entries(r))for(let[i,o]of Object.entries(s.languages))for(let u of o.extensions){let a=u.toLowerCase(),l=e.get(a);if(l!==void 0&&l!==i)throw new Error(`[lsp] extension conflict: "${a}" claimed by "${l}" and "${i}"`);e.set(a,i);let d=t.get(a)??[];d.push(n),t.set(a,d)}return{extToLanguageId:e,extToServerIds:t}}c(st,"buildLanguageLookup");var _=class r{constructor(e,t,n){this._projectRoot=n;this._entries=e;let s=e.filter(i=>i.layer!=="built-in"||t.has(i.id));this._servers=Object.fromEntries(s.map(i=>[i.id,i.config])),this._lookup=st(this._servers)}static{c(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){let n=await Re(e,"lsp-servers",u=>Jt(u).servers,t),s=t.environment??process.env,i=await Promise.all(n.entries.filter(u=>u.layer==="built-in").map(async u=>({id:u.id,available:await H(u.config,e,s)}))),o=t.requireBuiltInEvidence?await we(e,t.recipes??[]):void 0;return new r(n.entries,new Set(i.filter(u=>u.available&&(o===void 0||(o.get(u.id)?.score??0)>0)).map(u=>u.id)),b.resolve(e))}static fromConfig(e,t=process.cwd()){return new r(Object.entries(e.servers).map(([n,s])=>({id:n,config:s,layer:"project",sourcePath:"<memory>"})),new Set,b.resolve(t))}resolve(e){let t=b.basename(e),n=b.extname(e)||(e.startsWith(".")?e:`.${e}`),s=c(o=>process.platform==="win32"?o.toLowerCase():o,"normalizeName"),i=[];for(let o of this._entries)if(this._servers[o.id]&&!(o.config.requireRootMarker&&!this.hasRootMarker(e,o.config.rootMarkers))){for(let[u,a]of Object.entries(o.config.languages))if(a.extensions.some(l=>l.toLowerCase()===n.toLowerCase())||a.fileNames?.some(l=>s(l)===s(t))){i.push({serverId:o.id,config:o.config,languageId:u,layer:o.layer,sourcePath:o.sourcePath});break}}return i}hasRootMarker(e,t){let n=b.dirname(b.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(b.sep)&&(n=this._projectRoot);;){let s=b.relative(this._projectRoot,n);if(s===".."||s.startsWith(`..${b.sep}`)||b.isAbsolute(s))return!1;if(t.some(i=>Bt(b.join(n,i))))return!0;if(n===this._projectRoot)return!1;n=b.dirname(n)}}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){return this.resolve(e)[0]?.languageId??e.slice(1)}};function Jt(r){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("LSP config must be an object");let e=r;if(e.version!==1)throw new Error("LSP config version must be 1");if(typeof e.servers!="object"||e.servers===null||Array.isArray(e.servers))throw new Error("LSP config servers must be an object");for(let[t,n]of Object.entries(e.servers)){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LSP server ${t} must be an object`);let s=n;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(i=>typeof i!="string"||i.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(i=>typeof i!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[i,o]of Object.entries(s.languages)){let u=typeof o=="object"&&o!==null&&!Array.isArray(o)?o.extensions:void 0;if(!Array.isArray(u)||u.length===0||u.some(l=>typeof l!="string"))throw new Error(`LSP server ${t} language ${i} requires extensions`);let a=o.fileNames;if(a!==void 0&&(!Array.isArray(a)||a.some(l=>typeof l!="string"||l.length===0||/[/\\]/u.test(l))))throw new Error(`LSP server ${t} language ${i}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return r}c(Jt,"parseLspConfig");function it(r){return at("symbol","lsp-symbol",r,async e=>await le(e.manager,e.filePath,v(e.selector),e.cwd,e.signal))}c(it,"createLspSymbolResolver");function ot(r){return at("graph","lsp-graph",r,async e=>e.selector===void 0?await ue(e.manager,e.filePath,e.cwd,e.signal):await de(e.manager,e.filePath,e.selector,e.cwd,e.signal))}c(ot,"createLspGraphResolver");function at(r,e,t,n){return{id:e,tryResolve(s,i){return Promise.resolve(Kt(s,i,r,t,n))}}}c(at,"createCodeViewResolver");function Kt(r,e,t,n,s){let i;try{i=D(r,t)}catch(a){return{kind:"failed",error:a}}if(i===void 0)return{kind:"not-handled"};let o;try{o=E(i.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:$(t,o,i.selector),async read(a){let l=await n(e.cwd),d=await s({manager:l,filePath:o,cwd:e.cwd,...Xt(i.selector),...Yt(a.signal)});return[typeof d=="string"?{type:"text",text:d}:d]}}}}c(Kt,"resolveCodeViewSource");function Xt(r){return r===void 0?{}:{selector:r}}c(Xt,"optionalSelector");function Yt(r){return r===void 0?{}:{signal:r}}c(Yt,"optionalSignal");function lt(r,e=(t,n)=>Promise.resolve({cwd:n,external:!1})){return{id:"lsp",async diagnose(t,n){let s=await e(t,n.cwd);if(s===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let i=await r(s.cwd,s.external);n.signal.throwIfAborted();let o=await i.getOrStart(t,s.cwd,"diagnostics");if(n.signal.throwIfAborted(),!o)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let u=o.toUri(t),a=i.languageId(t);o.syncDocument(u,n.content,a,!0);let l=o.documentVersion(u),d={active:!0,queued:!1},p=c(()=>!n.signal.aborted&&o.documentVersion(u)===l,"current"),g=c(()=>O(o,u,a,{signal:n.signal,content:n.content}),"request"),h=c(async()=>{if(d.queued=!0,!d.active){d.active=!0;try{for(;d.queued&&p();){d.queued=!1;let f=await g();p()&&n.publish(ct(f,o.commandName))}}catch(f){p()&&n.publish({status:"unavailable",diagnostics:[],reason:f instanceof Error?f.message:String(f),source:o.commandName})}finally{d.active=!1}}},"refresh"),y=i.onPushDiagnostics(f=>{!p()||f.uri!==u||f.serverId!==o.serverId||f.cwd!==s.cwd||f.version!==void 0&&f.version!==l||(o.diagnosticMode==="pull"||B(o)?h():n.publish({status:"snapshot",diagnostics:f.diagnostics,source:o.commandName,reason:dt(f.version===void 0)}))});n.signal.addEventListener("abort",y,{once:!0});try{let f=await g();return l=o.documentVersion(u),ct(f,o.commandName)}catch(f){throw d.queued=!1,y(),n.signal.removeEventListener("abort",y),f}finally{d.active=!1,d.queued&&p()&&queueMicrotask(()=>{h()})}}}}c(lt,"createLspDiagnosticSource");function dt(r){return`Latest push snapshot; completion is unknown${r?"; language server omitted the document version":""}`}c(dt,"snapshotReason");function ct(r,e){return r.complete?{status:"ready",diagnostics:r.diagnostics,source:e}:{status:"snapshot",diagnostics:r.diagnostics,reason:dt(r.unversioned),source:e}}c(ct,"toReport");import{URI as Qt}from"vscode-uri";var ut={protocol:_e,apiVersion:1,id:"lsp",setup(r){for(let e of A)r.addToolRecipe(e);r.addSetupCheck({id:"effective-config",inspect:Zt}),r.addCheck({id:"config",title:"LSP",async run(e){try{let t=await _.fromPackageDir(e.cwd,{environment:e.env}),n=er(t,e.files);return n.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(n.map(async s=>{let i=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,o=new C({serverId:s.serverId,rootUri:Qt.file(e.cwd).toString(),command:s.config.command,env:tr(e.env,s.config.env),...s.config.initializationOptions&&{initOptions:s.config.initializationOptions},...s.config.settings&&{settings:s.config.settings},...s.config.timeoutMs&&{timeoutMs:s.config.timeoutMs}});try{return await o.start(),{status:"pass",message:`${i}: initialized`,detail:s.sourcePath}}catch(u){return{status:"fail",message:`${i}: ${u instanceof Error?u.message:String(u)}`,detail:s.sourcePath}}finally{await o.shutdown().catch(()=>{})}}))}catch(t){return[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function Zt(r){try{let e=await _.fromPackageDir(r.cwd,{environment:r.env}),t=[],n=new Map;for(let[s,i]of r.detectedLanguages){let o=i.flatMap(u=>e.resolve(u)).find(u=>u.languageId===s);o!==void 0&&(t.push({kind:"lsp",languageId:s,toolId:o.serverId}),await H(o.config,r.cwd,r.env)||n.set(o.serverId,{id:`lsp-${o.serverId}-unavailable`,message:`Configured language server ${o.serverId} cannot run ${JSON.stringify(o.config.command)}`}))}return{selections:t,actions:[...n.values()]}}catch(e){return{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}c(Zt,"inspectLspSetup");function er(r,e){let t=new Map;for(let n of e){let s=r.resolve(n)[0];s!==void 0&&!t.has(s.serverId)&&t.set(s.serverId,s)}return[...t.values()]}c(er,"applicableServers");function tr(r,e){return Object.fromEntries(Object.entries({...r,...e}).filter(t=>t[1]!==void 0))}c(tr,"definedEnvironment");function pt(r){return{id:"symbols",readResources:c(e=>e.query.startsWith("symbols:")?void 0:[],"readResources"),toScriptData(e){let{query:t,hits:n}=e;return{kind:"custom",resolverId:"symbols",value:{query:t,hits:n.map(s=>({source:s.filePath,lineNumber:s.lineNumber,column:s.column,kind:s.kind,name:s.name}))}}},async tryResolve(e,t){if(!e.query.startsWith("symbols:"))return{kind:"not-handled"};let n=e.query.slice(8).trim();if(n.length===0)return{kind:"failed",error:new Error("symbols: query must not be empty")};let s=await r(t.cwd),i=await se(n,t.cwd,e.limit??100,t.signal,e,s);return{kind:"resolved",payload:{query:n,hits:i}}},format(e){let{query:t,hits:n}=e;return{content:[{type:"text",text:n.length===0?"No symbols found.":n.map((i,o)=>`${String(o+1)}. ${i.filePath}:${String(i.lineNumber)}:${String(i.column)} ${i.kind} ${i.name}`).join(`
|
|
8
|
-
`)}],details:{
|
|
9
|
-
`),n=t[e.line];if(!Number.isInteger(e.line)||e.line<0||n===void 0||!Number.isInteger(e.character)||e.character<0||e.character>n.replace(/\r$/u,"").length)throw new Error("The language server returned an invalid text position.");return t.slice(0,e.line).reduce((s,
|
|
7
|
+
`);return{content:t,lines:s}}c(or,"readTextFile");var se=class{static{c(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return ye(ir(e),this.#e)}line(e,t){return Promise.resolve(String(t))}};function ir(r){if(!r.startsWith("file://"))return r;try{return Yt(r)}catch{return decodeURIComponent(r.slice(7))}}c(ir,"filePathFromUri");function ye(r,e){let t=N.relative(e,r);return t.length===0||t.startsWith("..")||N.isAbsolute(t)?r:t.replaceAll(N.sep,"/")}c(ye,"displayFilePath");function _(r){if(r?.aborted===!0)throw yt(r)}c(_,"throwIfAborted");function yt(r,e){if(r.reason instanceof Error)return r.reason;if(e instanceof Error)return e;let t=new Error("The operation was aborted");return t.name="AbortError",t}c(yt,"abortReason");function Le(r){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:c(()=>Promise.resolve(!0),"detect"),async compile({filePath:t},n){let s=await ar(t,n,r);if(!s)return cr();let{client:o,diagnostics:i,syntaxErrors:d,otherDiagnostics:a}=s;return e=o,{ok:!i.some(l=>l.severity==="error"),diagnostics:i,syntaxErrors:d,otherDiagnostics:a}},async restart(){e&&(await e.restart(),e=null)}}}c(Le,"createLspCompiler");async function ar(r,e,t){let n=await t.openFile(r,e.cwd);if(!n)return null;let s=await H(n.client,n.uri,n.languageId);return{client:n.client,...s}}c(ar,"openAndDiagnose");function cr(){return{ok:!0,diagnostics:[],syntaxErrors:[],otherDiagnostics:[]}}c(cr,"skipOk");import C from"node:path";import{existsSync as lr}from"node:fs";function vt(r){let e=new Map,t=new Map;for(let[n,s]of Object.entries(r))for(let[o,i]of Object.entries(s.languages))for(let d of i.extensions){let a=d.toLowerCase(),l=e.get(a);if(l!==void 0&&l!==o)throw new Error(`[lsp] extension conflict: "${a}" claimed by "${l}" and "${o}"`);e.set(a,o);let u=t.get(a)??[];u.push(n),t.set(a,u)}return{extToLanguageId:e,extToServerIds:t}}c(vt,"buildLanguageLookup");var D=class r{constructor(e,t,n){this._projectRoot=n;this._entries=e;let s=e.filter(o=>o.layer!=="built-in"||t.has(o.id));this._servers=Object.fromEntries(s.map(o=>[o.id,o.config])),this._lookup=vt(this._servers)}static{c(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,t={}){let n=await je(e,"lsp-servers",d=>dr(d).servers,t),s=t.environment??process.env,o=await Promise.all(n.entries.filter(d=>d.layer==="built-in").map(async d=>({id:d.id,available:await ee(d.config,e,s)}))),i=t.requireBuiltInEvidence?await De(e,t.recipes??[]):void 0;return new r(n.entries,new Set(o.filter(d=>d.available&&(i===void 0||(i.get(d.id)?.score??0)>0)).map(d=>d.id)),C.resolve(e))}static fromConfig(e,t=process.cwd()){return new r(Object.entries(e.servers).map(([n,s])=>({id:n,config:s,layer:"project",sourcePath:"<memory>"})),new Set,C.resolve(t))}resolve(e){let t=C.basename(e),n=C.extname(e)||(e.startsWith(".")?e:`.${e}`),s=c(i=>process.platform==="win32"?i.toLowerCase():i,"normalizeName"),o=[];for(let i of this._entries)if(this._servers[i.id]&&!(i.config.requireRootMarker&&!this.hasRootMarker(e,i.config.rootMarkers))){for(let[d,a]of Object.entries(i.config.languages))if(a.extensions.some(l=>l.toLowerCase()===n.toLowerCase())||a.fileNames?.some(l=>s(l)===s(t))){o.push({serverId:i.id,config:i.config,languageId:d,layer:i.layer,sourcePath:i.sourcePath});break}}return o}hasRootMarker(e,t){let n=C.dirname(C.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(C.sep)&&(n=this._projectRoot);;){let s=C.relative(this._projectRoot,n);if(s===".."||s.startsWith(`..${C.sep}`)||C.isAbsolute(s))return!1;if(t.some(o=>lr(C.join(n,o))))return!0;if(n===this._projectRoot)return!1;n=C.dirname(n)}}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){return this.resolve(e)[0]?.languageId??e.slice(1)}};function dr(r){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("LSP config must be an object");let e=r;if(e.version!==1)throw new Error("LSP config version must be 1");if(typeof e.servers!="object"||e.servers===null||Array.isArray(e.servers))throw new Error("LSP config servers must be an object");for(let[t,n]of Object.entries(e.servers)){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LSP server ${t} must be an object`);let s=n;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(o=>typeof o!="string"||o.length===0))throw new Error(`LSP server ${t}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${t} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(o=>typeof o!="string"))throw new Error(`LSP server ${t}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${t}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${t}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${t}.languages must be an object`);for(let[o,i]of Object.entries(s.languages)){let d=typeof i=="object"&&i!==null&&!Array.isArray(i)?i.extensions:void 0;if(!Array.isArray(d)||d.length===0||d.some(l=>typeof l!="string"))throw new Error(`LSP server ${t} language ${o} requires extensions`);let a=i.fileNames;if(a!==void 0&&(!Array.isArray(a)||a.some(l=>typeof l!="string"||l.length===0||/[/\\]/u.test(l))))throw new Error(`LSP server ${t} language ${o}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${t}.capabilities must be an array`)}return r}c(dr,"parseLspConfig");function bt(r){return Lt("symbol","lsp-symbol",r,async e=>await ve(e.manager,e.filePath,L(e.selector),e.cwd,e.signal))}c(bt,"createLspSymbolResolver");function wt(r){return Lt("graph","lsp-graph",r,async e=>e.selector===void 0?await we(e.manager,e.filePath,e.cwd,e.signal):await be(e.manager,e.filePath,e.selector,e.cwd,e.signal))}c(wt,"createLspGraphResolver");function Lt(r,e,t,n){return{id:e,tryResolve(s,o){return Promise.resolve(ur(s,o,r,t,n))}}}c(Lt,"createCodeViewResolver");function ur(r,e,t,n,s){let o;try{o=T(r,t)}catch(a){return{kind:"failed",error:a}}if(o===void 0)return{kind:"not-handled"};let i;try{i=$(o.path,e.cwd)}catch(a){return{kind:"failed",error:a}}return{kind:"resolved",resource:{source:z(t,i,o.selector),async read(a){let l=await n(e.cwd),u=await s({manager:l,filePath:i,cwd:e.cwd,...pr(o.selector),...gr(a.signal)});return[typeof u=="string"?{type:"text",text:u}:u]}}}}c(ur,"resolveCodeViewSource");function pr(r){return r===void 0?{}:{selector:r}}c(pr,"optionalSelector");function gr(r){return r===void 0?{}:{signal:r}}c(gr,"optionalSignal");function Rt(r,e=(t,n)=>Promise.resolve({cwd:n,external:!1})){return{id:"lsp",async diagnose(t,n){let s=await e(t,n.cwd);if(s===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let o=await r(s.cwd,s.external);n.signal.throwIfAborted();let i=await o.getOrStart(t,s.cwd,"diagnostics");if(n.signal.throwIfAborted(),!i)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let d=i.toUri(t),a=o.languageId(t);i.syncDocument(d,n.content,a,!0);let l=i.documentVersion(d),u={active:!0,queued:!1},p=c(()=>!n.signal.aborted&&i.documentVersion(d)===l,"current"),f=c(()=>H(i,d,a,{signal:n.signal,content:n.content}),"request"),y=c(async()=>{if(u.queued=!0,!u.active){u.active=!0;try{for(;u.queued&&p();){u.queued=!1;let g=await f();p()&&n.publish(St(g,i.commandName))}}catch(g){p()&&n.publish({status:"unavailable",diagnostics:[],reason:g instanceof Error?g.message:String(g),source:i.commandName})}finally{u.active=!1}}},"refresh"),m=o.onPushDiagnostics(g=>{!p()||g.uri!==d||g.serverId!==i.serverId||g.cwd!==s.cwd||g.version!==void 0&&g.version!==l||(i.diagnosticMode==="pull"||ne(i)?y():n.publish({status:"snapshot",diagnostics:g.diagnostics,source:i.commandName,reason:Pt(g.version===void 0)}))});n.signal.addEventListener("abort",m,{once:!0});try{let g=await f();return l=i.documentVersion(d),St(g,i.commandName)}catch(g){throw u.queued=!1,m(),n.signal.removeEventListener("abort",m),g}finally{u.active=!1,u.queued&&p()&&queueMicrotask(()=>{y()})}}}}c(Rt,"createLspDiagnosticSource");function Pt(r){return`Latest push snapshot; completion is unknown${r?"; language server omitted the document version":""}`}c(Pt,"snapshotReason");function St(r,e){return r.complete?{status:"ready",diagnostics:r.diagnostics,source:e}:{status:"snapshot",diagnostics:r.diagnostics,reason:Pt(r.unversioned),source:e}}c(St,"toReport");import{URI as mr}from"vscode-uri";var Ct={protocol:Ae,apiVersion:1,id:"lsp",setup(r){for(let e of W)r.addToolRecipe(e);r.addSetupCheck({id:"effective-config",inspect:fr}),r.addCheck({id:"config",title:"LSP",async run(e){try{let t=await D.fromPackageDir(e.cwd,{environment:e.env}),n=hr(t,e.files);return n.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(n.map(async s=>{let o=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,i=new I({serverId:s.serverId,rootUri:mr.file(e.cwd).toString(),command:s.config.command,env:yr(e.env,s.config.env),...s.config.initializationOptions&&{initOptions:s.config.initializationOptions},...s.config.settings&&{settings:s.config.settings},...s.config.timeoutMs&&{timeoutMs:s.config.timeoutMs}});try{return await i.start(),{status:"pass",message:`${o}: initialized`,detail:s.sourcePath}}catch(d){return{status:"fail",message:`${o}: ${d instanceof Error?d.message:String(d)}`,detail:s.sourcePath}}finally{await i.shutdown().catch(()=>{})}}))}catch(t){return[{status:"fail",message:t instanceof Error?t.message:String(t)}]}}})}};async function fr(r){try{let e=await D.fromPackageDir(r.cwd,{environment:r.env}),t=[],n=new Map;for(let[s,o]of r.detectedLanguages){let i=o.flatMap(d=>e.resolve(d)).find(d=>d.languageId===s);i!==void 0&&(t.push({kind:"lsp",languageId:s,toolId:i.serverId}),await ee(i.config,r.cwd,r.env)||n.set(i.serverId,{id:`lsp-${i.serverId}-unavailable`,message:`Configured language server ${i.serverId} cannot run ${JSON.stringify(i.config.command)}`}))}return{selections:t,actions:[...n.values()]}}catch(e){return{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}c(fr,"inspectLspSetup");function hr(r,e){let t=new Map;for(let n of e){let s=r.resolve(n)[0];s!==void 0&&!t.has(s.serverId)&&t.set(s.serverId,s)}return[...t.values()]}c(hr,"applicableServers");function yr(r,e){return Object.fromEntries(Object.entries({...r,...e}).filter(t=>t[1]!==void 0))}c(yr,"definedEnvironment");import vr from"node:path";function _t(r,e){return{id:"symbols",supportsResultScope:!0,readResources:c(t=>t.query.startsWith("symbols:")?void 0:[],"readResources"),toScriptData(t){return t.data},async tryResolve(t,n){if(!t.query.startsWith("symbols:"))return{kind:"not-handled"};let s=t.query.slice(8).trim();if(s.length===0)return{kind:"failed",error:new Error("symbols: query must not be empty")};let o=await r(n.cwd),i=c(u=>ge(s,n.cwd,t.limit??100,u,{...t,...n.scope===void 0?{}:{resultScope:n.scope}},o),"collect"),d=await i(n.signal),a=await e({request:t,matches:d.hits,complete:d.complete,refresh:c(async u=>{let p=await i(u);return{matches:p.hits,complete:p.complete}},"refresh")},n),l=Xe(d.hits,d.complete,a.id,a);return{kind:"resolved",payload:{query:s,hits:d.hits,complete:d.complete,navigation:t.navigation,data:{...l,matches:l.matches.map((u,p)=>({...u,role:d.hits[p]?.role,symbol:d.hits[p]?.symbol}))}}}},renderResult(t,n,s){let o=t.details;return Je(o.hits,o.complete,s,n.expanded,o.cwd,o.navigation==="references"?["LSP reference navigation \xB7 may leave input scope"]:[],o.hits.map(i=>`${i.role} ${i.symbol.name}`))},format(t,n){let s=t,o=s.navigation==="references"?"LSP reference navigation (may leave input scope)":"LSP symbols inside scope",i=s.hits.length===0?["No symbols found."]:s.hits.slice(0,100).map((d,a)=>`${String(a+1)}. ${vr.relative(n.cwd,d.source)}:${String(d.lineNumber)}:${String(d.startColumn+1)} ${d.role} ${d.symbol.name}`);return s.complete||i.push("Incomplete results; not a complete edit scope."),s.hits.length>100&&i.push("Preview shortened; full source targets retained."),{content:[{type:"text",text:[o,...i].join(`
|
|
8
|
+
`)}],details:{...s,cwd:n.cwd}}}}}c(_t,"createLspSearchResolver");function kt(r){return{id:"lsp-declaration-target",async tryResolve(e,t){let n=T(e,"symbol");if(n===void 0)return{kind:"not-handled"};if(n.selector===void 0)return{kind:"rejected",rejection:{code:"invalid",reason:"Use symbol:<file>#<selector> to choose one declaration"}};try{let s=await dt(await r(t.cwd),$(n.path,t.cwd),n.selector,t.cwd,t.signal);return{kind:"resolved",targets:[{source:s.source,expectedContent:s.content,ranges:[{start:{lineNumber:s.range.start.line+1,column:s.range.start.character},end:{lineNumber:s.range.end.line+1,column:s.range.end.character}}]}]}}catch(s){return{kind:"failed",error:new Error(`${s instanceof Error?s.message:String(s)} Read the physical file and use explicit text anchors if declaration resolution is unavailable.`,{cause:s})}}}}}c(kt,"createDeclarationTargets");import{readFile as br,stat as xt}from"node:fs/promises";import{fileURLToPath as wr}from"node:url";function Dt(r,e){let t=r.split(`
|
|
9
|
+
`),n=t[e.line];if(!Number.isInteger(e.line)||e.line<0||n===void 0||!Number.isInteger(e.character)||e.character<0||e.character>n.replace(/\r$/u,"").length)throw new Error("The language server returned an invalid text position.");return t.slice(0,e.line).reduce((s,o)=>s+o.length+1,0)+e.character}c(Dt,"offset");async function Et(r,e){let t=r.input;if(typeof t.path!="string"||!t.path.startsWith("symbol:")||!t.path.endsWith("#name"))return;if(typeof t.text!="string"||t.text.trim()===""||t.start!==void 0||t.end!==void 0)throw new Error("Rename needs a symbol #name path and a non-empty new name in text, without start/end.");let n=T(t.path.slice(0,-5),"symbol");if(n?.selector===void 0)throw new Error("Rename needs an exact symbol selector before #name.");let s=$(n.path,r.cwd),o=await ut(await e(r.cwd),s,n.selector,r.cwd,r.signal);await B(o.client,s);let i=Date.now(),d=await de(o.client,o.uri,o.position,t.text);if(r.signal?.throwIfAborted(),d===null)throw new Error("The language server did not provide rename edits. No text fallback was applied.");let a=new Map(Object.entries(d.changes??{}));for(let u of d.documentChanges??[]){if(!("textDocument"in u)||!("edits"in u))throw new Error("Rename returned a file operation that is not supported; no edits applied.");if(u.textDocument.version!=null&&u.textDocument.version!==o.client.documentVersion(u.textDocument.uri))throw new Error("Rename refers to an unavailable document revision. Refresh the source before retrying.");if(a.has(u.textDocument.uri))throw new Error("Rename returned duplicate document edits.");a.set(u.textDocument.uri,u.edits)}let l=[];for(let[u,p]of a){let f=wr(u),y=await xt(f),m=await br(f,"utf8"),g=await xt(f),v=o.client.documentContent(u);if(v!==void 0&&v!==m)throw new Error("The language server has stale text for a rename target. Read that symbol again before retrying.");if(y.mtimeMs>i||y.mtimeMs!==g.mtimeMs||y.size!==g.size||f===s&&m!==o.content)throw new Error("A rename source changed during the language-server request. Retry from a fresh symbol read.");l.push({source:f,expectedContent:m,changes:p.map(R=>({from:Dt(m,R.range.start),to:Dt(m,R.range.end),insert:R.newText}))})}return{...r,editPlan:{files:l},metadata:{...r.metadata,semanticEdit:{mode:"lsp-rename",server:o.client.serverId,referencesUpdated:!0},diffStatuses:[{text:"Renamed through LSP",tone:"success"}]}}}c(Et,"prepareSymbolRename");var It=Ve({kind:"code-view",label:"LSP"});async function Sr(r){let e=new Map,t=!1,n=c((a,l=!1)=>{if(t)return Promise.reject(new Error("LSP session has ended"));let u=JSON.stringify([a,l]),p=e.get(u);return p||(p=Rr(a,l).then(f=>{if(t)throw new Error("LSP session has ended");return j.init(f)}),e.set(u,p)),p},"managerFor"),s=c(async(a,l)=>{let u=await Ie(l,a,"lsp-servers",W);return u===void 0?void 0:{cwd:u,external:u!==Lr.resolve(l)}},"resolveLspProject"),o={kind:"compiler",name:"pi-agent-ide-lsp",priority:200,extensions:["*"],detect:c(async a=>(await n(a.cwd),!0),"detect"),async compile(a,l){let u=await n(l.cwd);return Le(u).compile(a,l)}},i={protocol:_e,apiVersion:4,id:"lsp",setup(a){a.addTool(o),a.addDiagnosticSource(Rt(n,s))}};r.on("session_shutdown",async()=>{t=!0,await Promise.allSettled([...e.values()].map(async a=>(await a).shutdownAll())),e.clear()});let d={protocol:Oe,apiVersion:Ne,id:"lsp",setup(a){a.addResolver({resolver:bt(n),renderResult:It}),a.addResolver({resolver:wt(n),renderResult:It}),a.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:Ce()}),a.describe("symbol:<file>#<selector> \u2014 declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> \u2014 top-level declarations, references and calls; members include selectors. graph:<file>#<selector> \u2014 references and incoming/outgoing calls for that declaration or member.")}};await Promise.all([xe(r,i),Ue(r,{protocol:Fe,apiVersion:ze,id:"lsp-declarations",setup(a){a.addAnchorResolver({kind:We,type:"auxiliary",resolver:{id:"lsp-declaration",description:"symbol:<file>#<selector> selects an exact declaration for text fallback editing; imports and references are not rewritten.",renderFull:c(l=>l,"renderFull"),renderCompact:c(l=>l,"renderCompact"),tryResolve:c(()=>Promise.resolve({kind:"not-handled"}),"tryResolve")},resources:kt(n),describeInPrompt:!1});for(let l of["copy","move","delete","replace"])a.tool(l).describe("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."+(l==="replace"?" 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.":"")),a.tool(l).addHandler({stage:"text-pre-edit",async handler(u){if(l==="replace"){let y=await Et(u,n);if(y!==void 0)return y}let p=u.input;if(![p.path,p.start,p.end,p.target,p.targetStart,p.targetEnd].some(y=>typeof y=="string"&&y.startsWith("symbol:")))return u;if((l==="copy"||l==="move")&&typeof p.target!="string")throw new Error("Copying or moving a symbol requires an explicit target file and destination anchor.");return{...u,metadata:{...u.metadata,semanticEdit:{mode:"declaration-text",referencesUpdated:!1,importsUpdated:!1},diffStatuses:[{text:"Text fallback: imports and references unchanged",tone:"warning"}]}}}});a.tool("insert").describe("Symbol targets are unsupported for insert. Read the declaration and select an ordinary text line anchor instead."),a.tool("insert").addHandler({stage:"text-pre-edit",handler(l){let u=l.input;if([u.path,u.anchor].some(p=>typeof p=="string"&&p.startsWith("symbol:")))throw new Error("Semantic insert is not supported. Read the declaration and use an explicit text line anchor instead.");return l}})}}),qe(r,d),$e(r,Ct),Be(r,{protocol:He,apiVersion:Ge,id:"symbols",setup(a){a.addResolver({resolver:_t(n,a.registerSelection)}),a.describe('Use `symbols:<query>` to locate named workspace declarations and references through configured language servers when the file is unknown. Results contain exact source targets, roles, and originating symbols. Default search stays within path. Use navigation: "references" explicitly to follow symbols represented inside path to references outside it, within the workspace.')}})])}c(Sr,"registerLsp");async function Rr(r,e){let t=e?r:process.env.PI_AGENT_IDE_CONFIG_DIR??r;return D.fromPackageDir(t,{includeGlobal:!e,requireBuiltInEvidence:e,recipes:W})}c(Rr,"loadRegistry");export{Sr as default};
|
package/dist/entry-42.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-NNCZYO4Q.js";import{b as a,d as b}from"./chunk-
|
|
1
|
+
import"./chunk-NNCZYO4Q.js";import{b as a,d as b}from"./chunk-64M3SQPG.js";import"./chunk-PS2B6THP.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import"./chunk-EI7MMDWY.js";export{a as COMPACT_READ_ROWS,b as createReadResultRenderer};
|
package/dist/entry-44.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-7LZKOHH2.js";import"./chunk-SQKAXYIR.js";import"./chunk-EI7MMDWY.js";export{i as isFragmentResolverRegistration,j as isReadFragmentResolution,g as isReadHandlerRegistration,h as isReadViewRegistration,f as isResourceResolverRegistration,e as isTextTargetResolverRegistration,b as readDataSchema,c as readOutputSchema,a as readParameters,d as structuredRead};
|