pi-agent-ide 0.9.8 → 1.0.1
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 +72 -0
- package/README.md +5 -3
- package/dist/chunk-26SMC6OS.js +2 -0
- package/dist/chunk-2EY3LEZ7.js +1 -0
- package/dist/chunk-2QCE7GOV.js +1 -0
- package/dist/chunk-3BRGWFEI.js +2 -0
- package/dist/chunk-3JBQYLJ4.js +5 -0
- package/dist/chunk-3KM5DSWL.js +37 -0
- package/dist/chunk-3V3OQO5S.js +118 -0
- package/dist/chunk-45EJ4762.js +33 -0
- package/dist/chunk-4DLSZYUO.js +1 -0
- package/dist/chunk-54EFJYUB.js +1 -0
- package/dist/{chunk-5DN2XBVI.js → chunk-5TPYHUJV.js} +1 -1
- package/dist/{chunk-KQV2ZXLP.js → chunk-6DC2Q5BI.js} +1 -1
- package/dist/chunk-72WO7H5T.js +1 -0
- package/dist/chunk-72X24ARV.js +2 -0
- package/dist/chunk-7OAAM5FL.js +1 -0
- package/dist/chunk-AB6RSWMB.js +23 -0
- package/dist/chunk-ASVMQMPX.js +10 -0
- package/dist/chunk-BW3XONMZ.js +1 -0
- package/dist/chunk-C327T6YP.js +19 -0
- package/dist/{chunk-R2U5WXYR.js → chunk-D23NS4VV.js} +1 -1
- package/dist/chunk-E4V4VNRM.js +3 -0
- package/dist/chunk-E7JBYW43.js +1 -0
- package/dist/chunk-GDIF3WT6.js +12 -0
- package/dist/chunk-GNYFA6FS.js +2 -0
- package/dist/{chunk-DHOIQZUF.js → chunk-GQXZEOND.js} +1 -1
- package/dist/chunk-GT2JPOBM.js +1 -0
- package/dist/chunk-GTZOIJCH.js +1 -0
- package/dist/chunk-HRZAIZGR.js +1 -0
- package/dist/{chunk-H6FEBUAP.js → chunk-HSAGZWPO.js} +1 -1
- package/dist/{chunk-2DSY4U73.js → chunk-I3G6K7QU.js} +1 -1
- package/dist/chunk-IRLWXPL4.js +7 -0
- package/dist/chunk-IZTOXSTR.js +6 -0
- package/dist/chunk-J5CKSIH7.js +1 -0
- package/dist/chunk-JKM4E5VB.js +5 -0
- package/dist/chunk-JMCI2ZE2.js +3 -0
- package/dist/{chunk-YZTVC7ME.js → chunk-JY63UUC2.js} +1 -1
- package/dist/chunk-KM4NOIOB.js +5 -0
- package/dist/chunk-L2YDUMZC.js +13 -0
- package/dist/chunk-MCHU3BLO.js +53 -0
- package/dist/chunk-MJMRV76H.js +1 -0
- package/dist/chunk-MMQIHUU5.js +1 -0
- package/dist/chunk-MNAIMZRO.js +9 -0
- package/dist/chunk-NKI4TZSS.js +2 -0
- package/dist/chunk-NSBRKTZ7.js +1 -0
- package/dist/chunk-NWCTAVGR.js +4 -0
- package/dist/chunk-O2C3F3MA.js +1 -0
- package/dist/chunk-OA26FH5G.js +1 -0
- package/dist/chunk-OEEE5BLN.js +16 -0
- package/dist/chunk-OLMACWQX.js +11 -0
- package/dist/{chunk-72FL5FHZ.js → chunk-PBMHSK6J.js} +1 -1
- package/dist/chunk-QCAGAJHJ.js +1 -0
- package/dist/{chunk-P7FUD4WY.js → chunk-QR7JR3P2.js} +1 -1
- package/dist/chunk-QSU5AEKW.js +1 -0
- package/dist/chunk-QUK5ZEYX.js +1 -0
- package/dist/chunk-R7576HPO.js +25 -0
- package/dist/{chunk-B5UJCNQU.js → chunk-RNDSWVJF.js} +1 -1
- package/dist/chunk-RYJEEBET.js +1 -0
- package/dist/chunk-S4GTWS2J.js +6 -0
- package/dist/chunk-SF44YQCB.js +2 -0
- package/dist/chunk-SJQGFUXR.js +6 -0
- package/dist/chunk-SKZTIAE4.js +4 -0
- package/dist/chunk-SZRC24OB.js +1 -0
- package/dist/chunk-T5PXAYWC.js +1 -0
- package/dist/chunk-TIZ4QDF3.js +1 -0
- package/dist/chunk-UN3XLVPR.js +18 -0
- package/dist/chunk-V2LLMBTA.js +1 -0
- package/dist/chunk-VB5P3TXJ.js +111 -0
- package/dist/chunk-VNG4QPPT.js +12 -0
- package/dist/chunk-VNNAVC4S.js +15 -0
- package/dist/chunk-VPBGKSFI.js +3 -0
- package/dist/chunk-VQ2RA43A.js +7 -0
- package/dist/chunk-VWYI4WF7.js +3 -0
- package/dist/chunk-W25HNEMR.js +4 -0
- package/dist/chunk-X7CHS7JB.js +1 -0
- package/dist/chunk-XEPCURYZ.js +1 -0
- package/dist/chunk-XKVU6AAS.js +7 -0
- package/dist/chunk-XLTAP5YC.js +24 -0
- package/dist/chunk-XQMNVPNS.js +1 -0
- package/dist/chunk-YI32H7Z2.js +4 -0
- package/dist/chunk-ZYG5E3DI.js +9 -0
- package/dist/entry-0.js +1 -1
- package/dist/entry-12.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-18.js +1 -1
- package/dist/entry-19.js +1 -1
- package/dist/entry-20.js +1 -1
- package/dist/entry-21.js +1 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-27.js +1 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-31.js +2 -2
- package/dist/entry-32.js +1 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-38.js +19 -13
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +1 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +1 -1
- 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 -0
- package/dist/entry-69.js +1 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +0 -1
- package/dist/entry-73.js +1 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +1 -1
- package/dist/entry-78.js +1 -0
- package/dist/entry-79.js +1 -1
- package/dist/entry-8.js +1 -1
- package/dist/entry-80.js +1 -0
- package/dist/entry-81.js +0 -1
- package/dist/entry-82.js +1 -1
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +0 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -2
- package/dist/entry-87.js +1 -1
- package/dist/entry-88.js +1 -1
- package/dist/entry-89.js +1 -1
- package/dist/entry-90.js +1 -1
- package/dist/entry-91.js +1 -3
- package/dist/entry-92.js +1 -1
- package/dist/entry-93.js +1 -1
- package/dist/entry-94.js +1 -1
- package/dist/entry-95.js +3 -0
- package/dist/entry-96.js +1 -0
- package/dist/entry-97.js +1 -0
- package/dist/entry-98.js +1 -0
- package/dist/pi-agent-ide.js +26 -13
- package/docs/agent-guides/ast-search.md +15 -4
- package/docs/agent-guides/debugger.md +1 -1
- package/docs/agent-guides/git-changes.md +1 -0
- package/docs/agent-guides/ssh.md +27 -7
- package/docs/agent-guides/terminal.md +4 -0
- package/docs/configuration.md +65 -11
- package/docs/development.md +4 -0
- package/docs/extensions.md +6 -4
- package/docs/nightly.md +7 -1
- package/docs/releases.md +1 -1
- package/docs/structured-results.md +29 -15
- package/docs/tools.md +95 -29
- package/docs/user-hooks.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-doctor/src/catalog.ts +2 -0
- package/node_modules/pi-agent-doctor/src/executable.ts +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/src/file-write-lock.ts +6 -4
- package/node_modules/pi-agent-filesystem/src/replace-file.ts +5 -2
- package/node_modules/pi-agent-filesystem/src/resolver.ts +26 -10
- 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 +13 -13
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +56 -65
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +197 -130
- package/node_modules/pi-agent-ide-ast/src/ast/read-text.ts +2 -1
- package/node_modules/pi-agent-ide-ast/src/ast-grep-binary.ts +46 -0
- package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +119 -97
- package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -24
- package/node_modules/pi-agent-ide-ast/src/outline-page.ts +96 -0
- package/node_modules/pi-agent-ide-ast/src/outline-resolver.ts +42 -78
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +5 -1
- package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +2 -1
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +24 -5
- package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +2 -1
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +406 -200
- package/node_modules/pi-agent-ide-ast/src/tool-ast-search.ts +27 -9
- package/node_modules/pi-agent-ide-ast/src/tool-outline.ts +191 -0
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/src/changes/change-service.ts +63 -20
- package/node_modules/pi-agent-ide-changes/src/changes/change-types.ts +1 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-changes-backend.ts +25 -0
- package/node_modules/pi-agent-ide-changes/src/changes/git-paths.ts +13 -6
- package/node_modules/pi-agent-ide-changes/src/index-mutation-queue.ts +12 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +88 -78
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +29 -3
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +39 -3
- package/node_modules/pi-agent-ide-formatter/src/rustfmt.ts +101 -0
- 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-lint/src/catalog.ts +20 -14
- package/node_modules/pi-agent-ide-lint/src/registry.ts +2 -2
- package/node_modules/pi-agent-ide-lsp/index.ts +15 -88
- package/node_modules/pi-agent-ide-lsp/package.json +12 -12
- package/node_modules/pi-agent-ide-lsp/src/catalog.ts +21 -9
- package/node_modules/pi-agent-ide-lsp/src/lsp/clang-coverage.ts +265 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/clangd-launch.ts +48 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +94 -11
- package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +514 -207
- package/node_modules/pi-agent-ide-lsp/src/lsp/corrected-names.ts +222 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/declaration-scan.ts +116 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/diagnostics.ts +20 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/files-containing.ts +70 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +1 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/initialization-options.ts +37 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/line-breaks.ts +16 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +185 -131
- package/node_modules/pi-agent-ide-lsp/src/lsp/missing-sources.ts +21 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/navigation.ts +45 -24
- package/node_modules/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +40 -12
- package/node_modules/pi-agent-ide-lsp/src/lsp/range-match.ts +49 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +16 -5
- package/node_modules/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +7 -1
- package/node_modules/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +133 -37
- package/node_modules/pi-agent-ide-lsp/src/lsp/shared-servers.ts +164 -13
- package/node_modules/pi-agent-ide-lsp/src/lsp/source-changes.ts +18 -6
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +414 -174
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +424 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/symbols.ts +67 -0
- package/node_modules/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +10 -0
- package/node_modules/pi-agent-ide-lsp/src/name-captures.ts +66 -0
- package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +384 -93
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +356 -79
- package/node_modules/pi-agent-ide-lsp/src/tool-lsp-search.ts +33 -11
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +13 -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/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +51 -12
- package/node_modules/pi-agent-read/src/api/tools/read.ts +39 -3
- package/node_modules/pi-agent-read/src/core/extension.ts +80 -3
- package/node_modules/pi-agent-read/src/core/read-core.ts +6 -0
- package/node_modules/pi-agent-read/src/core/tools/read/list-result.ts +79 -0
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +45 -4
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +18 -9
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +16 -3
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +37 -9
- package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +15 -4
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +49 -18
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +158 -51
- package/node_modules/pi-agent-resource/package.json +5 -1
- package/node_modules/pi-agent-resource/src/file-text-read.ts +86 -0
- package/node_modules/pi-agent-resource/src/index.ts +54 -0
- package/node_modules/pi-agent-resource/src/json-structured-arguments.ts +131 -0
- package/node_modules/pi-agent-resource/src/line-map.ts +750 -0
- package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
- package/node_modules/pi-agent-resource/src/resource-scheduler.ts +63 -23
- package/node_modules/pi-agent-resource/src/resource.ts +5 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +693 -66
- package/node_modules/pi-agent-resource/src/script-calls.ts +21 -0
- package/node_modules/pi-agent-resource/src/tool-deadline.ts +199 -0
- package/node_modules/pi-agent-resource/src/tool-result.ts +14 -5
- package/node_modules/pi-agent-resource/src/unchanged-read.ts +62 -0
- package/node_modules/pi-agent-search/package.json +8 -9
- package/node_modules/pi-agent-search/runtime/entry-57.js +0 -1
- package/node_modules/pi-agent-search/src/api/fuzzy.ts +2 -1
- package/node_modules/pi-agent-search/src/api/null-fields.ts +50 -0
- package/node_modules/pi-agent-search/src/api/path-list.ts +68 -0
- package/node_modules/pi-agent-search/src/api/presentation.ts +2 -1
- package/node_modules/pi-agent-search/src/api/search-call-policy.ts +16 -0
- package/node_modules/pi-agent-search/src/api/search-capture.ts +56 -0
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +26 -4
- package/node_modules/pi-agent-search/src/api/search-scope.ts +38 -2
- package/node_modules/pi-agent-search/src/api/search.ts +46 -3
- package/node_modules/pi-agent-search/src/api/structured-result.ts +121 -26
- package/node_modules/pi-agent-search/src/core/extension.ts +75 -42
- package/node_modules/pi-agent-search/src/core/search-config.ts +2 -2
- package/node_modules/pi-agent-search/src/core/search-core.ts +103 -39
- package/node_modules/pi-agent-search-text/index.ts +62 -20
- package/node_modules/pi-agent-search-text/package.json +15 -15
- package/node_modules/pi-agent-search-text/runtime/entry-59.js +1 -0
- package/node_modules/pi-agent-search-text/src/current-matches.ts +314 -0
- package/node_modules/pi-agent-search-text/src/file-search.ts +178 -99
- package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +40 -17
- package/node_modules/pi-agent-search-text/src/persisted-result.ts +3 -8
- package/node_modules/pi-agent-search-text/src/resolvers.ts +395 -103
- package/node_modules/pi-agent-search-text/src/ripgrep.ts +142 -0
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +24 -12
- package/node_modules/pi-agent-search-text/src/search-backend.ts +333 -108
- package/node_modules/pi-agent-search-text/src/search-presentation.ts +6 -0
- package/node_modules/pi-agent-search-text/src/search-query.ts +69 -34
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +80 -8
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +2 -1
- package/node_modules/pi-agent-search-text/src/search-result.ts +10 -1
- package/node_modules/pi-agent-search-text/src/search-session.ts +449 -58
- package/node_modules/pi-agent-search-text/src/tool-file-search.ts +51 -6
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text/runtime/entry-63.js +1 -0
- package/node_modules/pi-agent-text/src/index.ts +18 -0
- package/node_modules/pi-agent-text/src/line-anchors.ts +211 -0
- package/node_modules/pi-agent-text/src/no-final-line-break.ts +12 -0
- package/node_modules/pi-agent-text/src/search-highlight.ts +8 -0
- package/node_modules/pi-agent-text/src/source-line.ts +7 -1
- package/node_modules/pi-agent-text/src/text-anchor.ts +34 -3
- package/node_modules/pi-agent-text/src/text-converter.ts +2 -1
- package/node_modules/pi-agent-text/src/text-document.ts +9 -23
- package/node_modules/pi-agent-text/src/text-target.ts +14 -6
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-64.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/index.ts +1 -65
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-65.js +0 -1
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-66.js +2 -0
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +185 -184
- package/node_modules/pi-agent-text-anchor-exact/src/anchored-literal-view.ts +122 -0
- package/node_modules/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +2 -1
- package/node_modules/pi-agent-text-anchor-exact/src/literal-match.ts +359 -0
- package/node_modules/pi-agent-text-anchor-exact/src/recovery.ts +1 -0
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +5 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-67.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-68.js +2 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/anchor.ts +92 -67
- package/node_modules/pi-agent-text-anchor-line-hash/src/range-history.ts +105 -0
- package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +22 -17
- package/node_modules/pi-agent-text-editor/index.ts +0 -10
- package/node_modules/pi-agent-text-editor/package.json +37 -26
- package/node_modules/pi-agent-text-editor/runtime/entry-84.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-85.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-86.js +1 -0
- package/node_modules/pi-agent-text-editor/runtime/entry-88.js +2 -0
- package/node_modules/pi-agent-text-editor/src/api/anchor-excerpt.ts +7 -0
- package/node_modules/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -1
- package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +40 -8
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -1
- package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +37 -2
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/api/native-files.ts +16 -2
- package/node_modules/pi-agent-text-editor/src/api/pi-edit-text.ts +82 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +9 -2
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +13 -2
- package/node_modules/pi-agent-text-editor/src/api/text-selector-fields.ts +210 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/core/already-done.ts +123 -0
- package/node_modules/pi-agent-text-editor/src/core/anchor-candidates.ts +116 -0
- package/node_modules/pi-agent-text-editor/src/core/anchor-preview.ts +32 -0
- package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +109 -23
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +19 -5
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +6 -5
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +54 -21
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +7 -3
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +14 -5
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +32 -11
- package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +67 -38
- package/node_modules/pi-agent-text-editor/src/core/file-write-observations.ts +287 -0
- package/node_modules/pi-agent-text-editor/src/core/image-write.ts +16 -4
- package/node_modules/pi-agent-text-editor/src/core/lookalike-bytes.ts +254 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +29 -12
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/compact-receipt.ts +48 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +2 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +24 -34
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +13 -20
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +32 -3
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +36 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +26 -19
- package/node_modules/pi-agent-text-editor/src/core/native-snapshot-source.ts +13 -0
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +526 -148
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +28 -3
- package/node_modules/pi-agent-text-editor/src/core/read-fragment-resolver.ts +34 -14
- package/node_modules/pi-agent-text-editor/src/core/reference-list.ts +95 -0
- package/node_modules/pi-agent-text-editor/src/core/result-scope.ts +129 -0
- package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +20 -8
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +86 -69
- package/node_modules/pi-agent-text-editor/src/core/source-aliases.ts +92 -0
- package/node_modules/pi-agent-text-editor/src/core/source-change-retry.ts +92 -7
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +162 -47
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +321 -101
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +206 -134
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -2
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +133 -18
- package/node_modules/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +13 -0
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +823 -226
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +51 -1
- package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/display-marker.ts +15 -0
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +268 -159
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +37 -32
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +24 -70
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +23 -36
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +31 -45
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +33 -65
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +80 -42
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +27 -16
- package/node_modules/pi-agent-text-editor-renderer/index.ts +0 -14
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-89.js +2 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +204 -78
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +75 -8
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +4 -1
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -3
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +44 -30
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +170 -26
- package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +83 -83
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -6
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-91.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +3 -3
- package/node_modules/pi-agent-tool-ui/runtime/entry-92.js +1 -0
- package/node_modules/pi-agent-tool-ui/runtime/entry-93.js +1 -0
- package/node_modules/pi-agent-web/index.ts +0 -3
- package/node_modules/pi-agent-web/package.json +8 -8
- package/node_modules/pi-agent-web/src/search.ts +1 -2
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-html/runtime/entry-95.js +2 -0
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-image/runtime/entry-96.js +2 -0
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-97.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-98.js +2 -0
- package/package.json +38 -38
- package/skills/capture-code-review-rule/SKILL.md +1 -1
- package/skills/configure-agent-ide/SKILL.md +1 -1
- package/src/api/code-view.ts +0 -2
- package/src/api/tool-config/linters.json +1 -0
- package/src/api/tool-config/lsp-servers.json +5 -0
- package/src/api/tool-config.ts +23 -2
- package/src/backend/config.ts +2 -0
- package/src/backend/configured-process.ts +1 -0
- package/src/backend/dap-java-transport.ts +4 -2
- package/src/backend/dap-java-worker.py +11 -4
- package/src/backend/dap-node-transport.ts +4 -2
- package/src/backend/dap-tcp-transport.ts +2 -3
- package/src/backend/debugger-workspace-owner.ts +6 -6
- package/src/backend/doctor-probe-worker.py +23 -15
- package/src/backend/doctor-workspace.ts +19 -18
- package/src/backend/file-transfer.ts +160 -56
- package/src/backend/formatter-registration.ts +54 -2
- package/src/backend/identity.ts +81 -12
- package/src/backend/lsp-file-watchers.ts +7 -9
- package/src/backend/lsp-workspace-owner.ts +25 -1
- package/src/backend/object-transfer.ts +28 -15
- package/src/backend/owned-command.ts +2 -1
- package/src/backend/owned-read-command.ts +2 -1
- package/src/backend/packaged-source.ts +12 -0
- package/src/backend/process-environment.ts +7 -9
- package/src/backend/process-metadata.ts +5 -5
- package/src/backend/recipe-evidence-worker.py +2 -0
- package/src/backend/recipe-evidence.ts +7 -8
- package/src/backend/registration.ts +2 -1
- package/src/backend/registry.ts +12 -2
- package/src/backend/resource-resolver.ts +11 -32
- package/src/backend/search-environment.ts +61 -4
- package/src/backend/ssh-channel-worker.py +6 -304
- package/src/backend/ssh-channel.ts +287 -36
- package/src/backend/ssh-connection-loss.ts +123 -0
- package/src/backend/ssh-file-stream.ts +216 -0
- package/src/backend/ssh-master.ts +443 -0
- package/src/backend/ssh-transfer-worker-windows.py +84 -0
- package/src/backend/ssh-transfer-worker.py +43 -10
- package/src/backend/ssh-transport.ts +238 -24
- package/src/backend/ssh-worker.py +7 -728
- package/src/backend/ssh.ts +83 -35
- package/src/backend/ssh_channel_common.py +68 -0
- package/src/backend/ssh_channel_posix.py +324 -0
- package/src/backend/ssh_channel_windows.py +527 -0
- package/src/backend/ssh_paths.py +23 -0
- package/src/backend/ssh_windows_files.py +254 -0
- package/src/backend/ssh_worker_common.py +96 -0
- package/src/backend/ssh_worker_posix.py +780 -0
- package/src/backend/ssh_worker_windows.py +687 -0
- package/src/backend/tool-config-access.ts +14 -11
- package/src/backend/tool-project.ts +4 -3
- package/src/backend/web-browser.ts +2 -3
- package/src/backend/web-http.ts +5 -5
- package/src/code-view/diagnostic-view.ts +12 -30
- package/src/code-view/reference.ts +9 -18
- package/src/code-view/source-view.ts +2 -1
- package/src/composite/codemode-tool-names.ts +79 -0
- package/src/composite/detached-results.ts +25 -6
- package/src/composite/ide-alias-rendering.ts +26 -4
- package/src/composite/module-labels.ts +2 -2
- package/src/composite/module-settings.ts +1 -0
- package/src/composite/nested-tool-rendering.ts +70 -24
- package/src/composite/output-limits.ts +12 -5
- package/src/composite/parallel-tool-guidance.ts +38 -0
- package/src/composite/script-values/ast-search.ts +56 -0
- package/src/composite/script-values/copy.ts +8 -0
- package/src/composite/script-values/delete.ts +5 -0
- package/src/composite/script-values/diff.ts +28 -0
- package/src/composite/script-values/edit-selection.ts +48 -0
- package/src/composite/script-values/failures.ts +170 -0
- package/src/composite/script-values/file-receipts.ts +63 -0
- package/src/composite/script-values/file-search.ts +10 -0
- package/src/composite/script-values/index.ts +55 -0
- package/src/composite/script-values/insert.ts +5 -0
- package/src/composite/script-values/lsp-search.ts +136 -0
- package/src/composite/script-values/match.ts +53 -0
- package/src/composite/script-values/move.ts +8 -0
- package/src/composite/script-values/path-list.ts +25 -0
- package/src/composite/script-values/provider-value.ts +21 -0
- package/src/composite/script-values/read.ts +206 -0
- package/src/composite/script-values/replace.ts +5 -0
- package/src/composite/script-values/result-reference.ts +9 -0
- package/src/composite/script-values/search-matches.ts +113 -0
- package/src/composite/script-values/search.ts +64 -0
- package/src/composite/script-values/semantic-search.ts +8 -0
- package/src/composite/script-values/terminal.ts +112 -0
- package/src/composite/script-values/text.ts +7 -0
- package/src/composite/script-values/types.ts +56 -0
- package/src/composite/script-values/undo.ts +5 -0
- package/src/composite/script-values/write.ts +8 -0
- package/src/composite/settings-panel.ts +18 -2
- package/src/composite/text-results.ts +488 -175
- package/src/composite/tool-availability.ts +29 -16
- package/src/composite/tool-discovery-guidance.ts +97 -0
- package/src/documentation/attachment.ts +31 -0
- package/src/documentation/extension.ts +6 -2
- package/src/documentation/search.ts +1 -7
- 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-filesystem/src/file-write-lock.ts +6 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/replace-file.ts +5 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/resolver.ts +26 -10
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +0 -3
- 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-95.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-image/runtime/entry-96.js +2 -0
- 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-pdf/runtime/entry-97.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-98.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-94.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +1 -2
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +51 -12
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +39 -3
- package/src/extensions/pi-agent-read/src/core/extension.ts +80 -3
- package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/list-result.ts +79 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +45 -4
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +18 -9
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +16 -3
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +37 -9
- package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +15 -4
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +49 -18
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +158 -51
- package/src/extensions/pi-agent-search/package.json +8 -9
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +62 -20
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +15 -15
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-59.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-62.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/current-matches.ts +314 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +178 -99
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +40 -17
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +3 -8
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +395 -103
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/ripgrep.ts +142 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +24 -12
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +333 -108
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +6 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +69 -34
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +80 -8
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +2 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +10 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +449 -58
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/tool-file-search.ts +51 -6
- package/src/extensions/pi-agent-search/runtime/entry-57.js +0 -1
- package/src/extensions/pi-agent-search/runtime/entry-58.js +2 -0
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +2 -1
- package/src/extensions/pi-agent-search/src/api/null-fields.ts +50 -0
- package/src/extensions/pi-agent-search/src/api/path-list.ts +68 -0
- package/src/extensions/pi-agent-search/src/api/presentation.ts +2 -1
- package/src/extensions/pi-agent-search/src/api/search-call-policy.ts +16 -0
- package/src/extensions/pi-agent-search/src/api/search-capture.ts +56 -0
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +26 -4
- package/src/extensions/pi-agent-search/src/api/search-scope.ts +38 -2
- package/src/extensions/pi-agent-search/src/api/search.ts +46 -3
- package/src/extensions/pi-agent-search/src/api/structured-result.ts +121 -26
- package/src/extensions/pi-agent-search/src/core/extension.ts +75 -42
- package/src/extensions/pi-agent-search/src/core/search-config.ts +2 -2
- package/src/extensions/pi-agent-search/src/core/search-core.ts +103 -39
- package/src/extensions/pi-agent-text-editor/index.ts +0 -10
- package/src/extensions/pi-agent-text-editor/package.json +37 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-64.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +1 -65
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-65.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-66.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +185 -184
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchored-literal-view.ts +122 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/fuzzy-worker.ts +2 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/literal-match.ts +359 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/recovery.ts +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +5 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-67.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-68.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/anchor.ts +92 -67
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/range-history.ts +105 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +22 -17
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +0 -14
- 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-89.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +204 -78
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +75 -8
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +4 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +4 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +44 -30
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +170 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +83 -83
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -6
- package/src/extensions/pi-agent-text-editor/runtime/entry-84.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-85.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-86.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-87.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-88.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/anchor-excerpt.ts +7 -0
- package/src/extensions/pi-agent-text-editor/src/api/anchor-inspection.ts +2 -1
- package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +40 -8
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -1
- package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +37 -2
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/api/native-files.ts +16 -2
- package/src/extensions/pi-agent-text-editor/src/api/pi-edit-text.ts +82 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +9 -2
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +13 -2
- package/src/extensions/pi-agent-text-editor/src/api/text-selector-fields.ts +210 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-call-interceptor.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/core/already-done.ts +123 -0
- package/src/extensions/pi-agent-text-editor/src/core/anchor-candidates.ts +116 -0
- package/src/extensions/pi-agent-text-editor/src/core/anchor-preview.ts +32 -0
- package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +109 -23
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +19 -5
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +6 -5
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +54 -21
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +7 -3
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +14 -5
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +32 -11
- package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +67 -38
- package/src/extensions/pi-agent-text-editor/src/core/file-write-observations.ts +287 -0
- package/src/extensions/pi-agent-text-editor/src/core/image-write.ts +16 -4
- package/src/extensions/pi-agent-text-editor/src/core/lookalike-bytes.ts +254 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/agent-diff.ts +29 -12
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/compact-receipt.ts +48 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +2 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +24 -34
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +13 -20
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +32 -3
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +36 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +26 -19
- package/src/extensions/pi-agent-text-editor/src/core/native-snapshot-source.ts +13 -0
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +526 -148
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +28 -3
- package/src/extensions/pi-agent-text-editor/src/core/read-fragment-resolver.ts +34 -14
- package/src/extensions/pi-agent-text-editor/src/core/reference-list.ts +95 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-scope.ts +129 -0
- package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +20 -8
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +86 -69
- package/src/extensions/pi-agent-text-editor/src/core/source-aliases.ts +92 -0
- package/src/extensions/pi-agent-text-editor/src/core/source-change-retry.ts +92 -7
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +162 -47
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +321 -101
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +206 -134
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +133 -18
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation-anchor-error.ts +13 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +823 -226
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +51 -1
- package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/display-marker.ts +15 -0
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +268 -159
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +37 -32
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +24 -70
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +23 -36
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +31 -45
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +33 -65
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +80 -42
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +27 -16
- package/src/pi-agent-ide.ts +41 -32
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +56 -65
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +197 -130
- package/src/plugins/pi-agent-ide-ast/src/ast/read-text.ts +2 -1
- package/src/plugins/pi-agent-ide-ast/src/ast-grep-binary.ts +46 -0
- package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +119 -97
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -24
- package/src/plugins/pi-agent-ide-ast/src/outline-page.ts +96 -0
- package/src/plugins/pi-agent-ide-ast/src/outline-resolver.ts +42 -78
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +5 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +2 -1
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +24 -5
- package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +2 -1
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +406 -200
- package/src/plugins/pi-agent-ide-ast/src/tool-ast-search.ts +27 -9
- package/src/plugins/pi-agent-ide-ast/src/tool-outline.ts +191 -0
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/src/changes/change-service.ts +63 -20
- package/src/plugins/pi-agent-ide-changes/src/changes/change-types.ts +1 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-changes-backend.ts +25 -0
- package/src/plugins/pi-agent-ide-changes/src/changes/git-paths.ts +13 -6
- package/src/plugins/pi-agent-ide-changes/src/index-mutation-queue.ts +12 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +88 -78
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +29 -3
- package/src/plugins/pi-agent-ide-debugger/index.ts +42 -32
- package/src/plugins/pi-agent-ide-debugger/src/string-enum.ts +14 -0
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +124 -79
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +39 -3
- package/src/plugins/pi-agent-ide-formatter/src/rustfmt.ts +101 -0
- 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-lint/src/catalog.ts +20 -14
- package/src/plugins/pi-agent-ide-lint/src/registry.ts +2 -2
- package/src/plugins/pi-agent-ide-lsp/index.ts +15 -88
- package/src/plugins/pi-agent-ide-lsp/package.json +12 -12
- package/src/plugins/pi-agent-ide-lsp/src/catalog.ts +21 -9
- package/src/plugins/pi-agent-ide-lsp/src/lsp/clang-coverage.ts +265 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/clangd-launch.ts +48 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +94 -11
- package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +514 -207
- package/src/plugins/pi-agent-ide-lsp/src/lsp/corrected-names.ts +222 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/declaration-scan.ts +116 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/diagnostics.ts +20 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/files-containing.ts +70 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +1 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/initialization-options.ts +37 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/line-breaks.ts +16 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +185 -131
- package/src/plugins/pi-agent-ide-lsp/src/lsp/missing-sources.ts +21 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/navigation.ts +45 -24
- package/src/plugins/pi-agent-ide-lsp/src/lsp/position-map.ts +17 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +40 -12
- package/src/plugins/pi-agent-ide-lsp/src/lsp/range-match.ts +49 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +16 -5
- package/src/plugins/pi-agent-ide-lsp/src/lsp/server-request-handlers.mjs +7 -1
- package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-server-host.mjs +133 -37
- package/src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts +164 -13
- package/src/plugins/pi-agent-ide-lsp/src/lsp/source-changes.ts +18 -6
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +414 -174
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-selectors.ts +424 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/symbols.ts +67 -0
- package/src/plugins/pi-agent-ide-lsp/src/lsp/workspace-owner.ts +10 -0
- package/src/plugins/pi-agent-ide-lsp/src/name-captures.ts +66 -0
- package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +384 -93
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +356 -79
- package/src/plugins/pi-agent-ide-lsp/src/tool-lsp-search.ts +33 -11
- package/src/plugins/pi-agent-ide-processes/src/registry.ts +64 -3
- package/src/plugins/pi-agent-ide-processes/src/ui.ts +57 -1
- package/src/plugins/pi-agent-ide-semantic/src/backend.ts +18 -6
- package/src/plugins/pi-agent-ide-semantic/src/vera-backend.ts +16 -9
- package/src/plugins/pi-agent-ide-terminal/index.ts +23 -7
- package/src/plugins/pi-agent-ide-terminal/src/list.ts +79 -0
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +22 -0
- package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +3 -0
- package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +18 -6
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +132 -18
- package/src/plugins/pi-agent-ide-terminal/src/search.ts +117 -50
- package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +94 -10
- package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +24 -1
- package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +5 -2
- package/src/plugins/pi-agent-ide-terminal/src/terminal-text.ts +173 -0
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +266 -112
- package/src/plugins/pi-agent-ide-terminal/src/types.ts +6 -1
- package/src/plugins/pi-agent-ide-terminal/src/ui.ts +11 -6
- package/src/plugins/pi-agent-ide-terminal/src/unix-pty-output.ts +47 -0
- package/src/post-edit/gate.ts +16 -1
- package/src/semantic/extension.ts +8 -2
- package/src/standalone/scoped-api.ts +85 -18
- package/src/toolchain/types.ts +4 -0
- package/dist/chunk-2AANEKFS.js +0 -1
- package/dist/chunk-33U3RUM3.js +0 -12
- package/dist/chunk-34IYWKY5.js +0 -1
- package/dist/chunk-4CSNQX54.js +0 -23
- package/dist/chunk-53IV6EKV.js +0 -1
- package/dist/chunk-5AROEOJB.js +0 -1
- package/dist/chunk-5D4C225L.js +0 -1
- package/dist/chunk-5W6QQZFI.js +0 -2
- package/dist/chunk-6W4OJLCJ.js +0 -1
- package/dist/chunk-6ZYCTWQE.js +0 -1
- package/dist/chunk-756K3LJY.js +0 -1
- package/dist/chunk-AMSNDWBT.js +0 -2
- package/dist/chunk-APWMLLSE.js +0 -17
- package/dist/chunk-BMSAVDRD.js +0 -13
- package/dist/chunk-BRJIXNFU.js +0 -5
- package/dist/chunk-C2GZLLSP.js +0 -5
- package/dist/chunk-ECSMTGVM.js +0 -6
- package/dist/chunk-EWTVVPUA.js +0 -11
- package/dist/chunk-FBR7ZLLN.js +0 -1
- package/dist/chunk-FGN2ZMEN.js +0 -1
- package/dist/chunk-FJSYWOE6.js +0 -1
- package/dist/chunk-FTECKRK6.js +0 -1
- package/dist/chunk-GRZTKMXQ.js +0 -1
- package/dist/chunk-HFCHOFLV.js +0 -2
- package/dist/chunk-HFF4GY7R.js +0 -3
- package/dist/chunk-HJXSEPO7.js +0 -111
- package/dist/chunk-HSEDKYH4.js +0 -1
- package/dist/chunk-II7AOJNH.js +0 -9
- package/dist/chunk-J34VKQGJ.js +0 -1
- package/dist/chunk-J6CDIH3S.js +0 -84
- package/dist/chunk-JHWLRL4U.js +0 -1
- package/dist/chunk-JMQ67UNK.js +0 -3
- package/dist/chunk-JRIP33PC.js +0 -13
- package/dist/chunk-K5M65CAF.js +0 -1
- package/dist/chunk-KJAR2WDO.js +0 -1
- package/dist/chunk-KX7MG72M.js +0 -1
- package/dist/chunk-L2B4DTVS.js +0 -1
- package/dist/chunk-LEKC4GQK.js +0 -5
- package/dist/chunk-LIGOOMJS.js +0 -10
- package/dist/chunk-LY2UANKU.js +0 -6
- package/dist/chunk-M7P7V4WI.js +0 -25
- package/dist/chunk-MXLSGMRZ.js +0 -3
- package/dist/chunk-N2NEFXHB.js +0 -13
- package/dist/chunk-NF74ITWT.js +0 -2
- package/dist/chunk-NQYUIQRH.js +0 -1
- package/dist/chunk-OCU6NW5Y.js +0 -1
- package/dist/chunk-OIEA4QWF.js +0 -4
- package/dist/chunk-ON5HDFNL.js +0 -10
- package/dist/chunk-P43GGKUC.js +0 -28
- package/dist/chunk-PPCWY4BB.js +0 -1
- package/dist/chunk-QGXZ4RWX.js +0 -1
- package/dist/chunk-S3T5NOSL.js +0 -1
- package/dist/chunk-S7E2D5K7.js +0 -5
- package/dist/chunk-SIYPD5MM.js +0 -3
- package/dist/chunk-STUZZM5B.js +0 -1
- package/dist/chunk-T4FTT3U4.js +0 -1
- package/dist/chunk-T5ACAOKJ.js +0 -4
- package/dist/chunk-TILMPAF2.js +0 -1
- package/dist/chunk-TSNY2FSU.js +0 -1
- package/dist/chunk-TWJINFQB.js +0 -9
- package/dist/chunk-TWQ6ACOI.js +0 -1
- package/dist/chunk-UDVVKVG4.js +0 -1
- package/dist/chunk-V2D5MLGE.js +0 -1
- package/dist/chunk-VDSSAP6Y.js +0 -1
- package/dist/chunk-VHYJTAXX.js +0 -1
- package/dist/chunk-WCSWQDJ2.js +0 -22
- package/dist/chunk-WQTF6Q2X.js +0 -3
- package/dist/chunk-XE4W5YTE.js +0 -2
- package/dist/chunk-YFPU2LRR.js +0 -23
- package/dist/chunk-YLEERRX3.js +0 -33
- package/dist/chunk-YOJHCARZ.js +0 -1
- package/dist/chunk-YPTDPMK5.js +0 -1
- package/docs/agent-guides/editing.md +0 -43
- package/docs/agent-guides/search.md +0 -38
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +0 -73
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-63.js +0 -2
- package/node_modules/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-68.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-85.js +0 -2
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +0 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-88.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-89.js +0 -1
- package/node_modules/pi-agent-web-html/runtime/entry-91.js +0 -2
- package/node_modules/pi-agent-web-image/runtime/entry-92.js +0 -2
- package/node_modules/pi-agent-web-pdf/runtime/entry-93.js +0 -2
- package/src/composite/search-facts.ts +0 -45
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-91.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-92.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-93.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-94.js +0 -2
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +0 -2
- package/src/extensions/pi-agent-search/runtime/entry-54.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-63.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-64.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-85.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-68.js +0 -1
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +0 -73
- /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-54.js +0 -0
- /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-58.js +0 -0
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-62.js +0 -0
- /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-87.js +0 -0
- /package/node_modules/{pi-agent-web → pi-agent-text-editor-stale-anchor}/runtime/entry-90.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web}/runtime/entry-94.js +0 -0
- /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor}/runtime/entry-90.js +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{a as yr,c as wr}from"./chunk-PBMHSK6J.js";import{b as gr,c as fr,g as mr,j as hr,p as kt}from"./chunk-OA26FH5G.js";import{a as pr}from"./chunk-BXGMMZT3.js";import{a as Gn,b as zn,c as Pe,e as Bn,f as Jn,k as Xn,l as Qn,o as xt,q as Kn,r as Yn,s as Zn}from"./chunk-3JBQYLJ4.js";import{a as er}from"./chunk-47SPPIXK.js";import{a as Hn,b as Vn}from"./chunk-VAXLSPPU.js";import{a as Un,e as jn}from"./chunk-BW3XONMZ.js";import{f as Fn,g as qn}from"./chunk-JXULBI4S.js";import{a as rr}from"./chunk-2YO6RVX4.js";import{b as tr,c as nr}from"./chunk-MLFJU2US.js";import{a as sr}from"./chunk-JY63UUC2.js";import{a as On}from"./chunk-I3G6K7QU.js";import{a as An,b as Mn}from"./chunk-HSAGZWPO.js";import{a as rt,e as Wn}from"./chunk-PS2B6THP.js";import{d as Nn,e as $n}from"./chunk-XEPCURYZ.js";import{B as _n,G as Rn,H as Cn,I as Pn,e as Pt,fa as xn,ia as En,la as kn,ma as In,ra as Tn,ta as Dn}from"./chunk-OEEE5BLN.js";import{d as or,f as ir}from"./chunk-YNOR4LIE.js";import{f as cr}from"./chunk-JKM4E5VB.js";import{a as Et,b as Ge,c as ar,d as ne}from"./chunk-XQMNVPNS.js";import{m as Ve}from"./chunk-IRLWXPL4.js";import{a as q}from"./chunk-ZC65Z3CK.js";import{a as ur}from"./chunk-ZAWRSA7N.js";import{a as lr,b as dr}from"./chunk-OFILFO6D.js";import{a}from"./chunk-EI7MMDWY.js";import la from"node:path";var xe=[{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"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["basedpyright-langserver","--stdio"],"https://docs.basedpyright.com/",["basedpyright"]),M("pyright",["python"],["pyright-langserver"],["pyproject.toml","pyrightconfig.json"],{python:[".py",".pyi"]},["pyright-langserver","--stdio"],"https://microsoft.github.io/pyright/",["pyright"]),M("gopls",["go"],["gopls"],["go.mod","go.work"],{go:[".go"]},["gopls"],"https://go.dev/gopls/"),{id:"rust-analyzer",name:"rust-analyzer",kind:"lsp",languages:["rust"],executables:["rust-analyzer"],configFiles:["Cargo.toml","rust-project.json"],documentation:"https://rust-analyzer.github.io/",lsp:{command:["rust-analyzer"],rootMarkers:["Cargo.toml","rust-project.json"],languageIds:{rust:[".rs"]},initializationOptions:{checkOnSave:!1,cargo:{buildScripts:{enable:!1}},procMacro:{enable:!1}}}},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(t,e,n,r,s,o,i,c,l,d){return{id:t,name:t,kind:"lsp",languages:e,executables:n,configFiles:r,documentation:i,...c&&{dependencies:c},lsp:{command:o,rootMarkers:r,languageIds:s,...l&&{fileNames:l},...d&&{settings:d}}}}a(M,"recipe");var st="lsp.idle-timeout";function It(t){let e=t.trim(),n=e===""?10:Number(e);if(!Number.isFinite(n)||n<=0)throw new Error(`Invalid ${st} setting "${t}": use a positive number of minutes.`);return Math.round(n*6e4)}a(It,"lspIdleTimeoutMs");import{readFile as _r}from"node:fs/promises";import{URI as Rr}from"vscode-uri";var ze={Error:1,Warning:2,Information:3,Hint:4};var vr={command:"typescript.tsserverRequest",async request(t,e,n){return(await Promise.all(["syntacticDiagnosticsSync","semanticDiagnosticsSync","suggestionDiagnosticsSync"].map(async s=>{let o=await t.sendRequest("workspace/executeCommand",{command:"typescript.tsserverRequest",arguments:[s,{file:t.serverDocumentPath(e),includeLinePosition:!0},{isAsync:!1,expectsResult:!0}]},n);if(!Tt(o)||o.success!==!0||!Array.isArray(o.body))throw new Error(`Invalid completed TypeScript diagnostic report: ${s}`);return o.body.map(Vs)}))).flat()}};function ot(t){return t.supportsCommand(vr.command)?vr:void 0}a(ot,"completedDiagnosticAdapter");function Vs(t){if(!Tt(t)||typeof t.message!="string"||typeof t.code!="number"&&typeof t.code!="string"||!Tt(t.startLocation)||!Number.isInteger(t.startLocation.line)||!Number.isInteger(t.startLocation.offset)||Number(t.startLocation.line)<1||Number(t.startLocation.offset)<1||!["error","warning","suggestion","message"].includes(String(t.category)))throw new Error("Invalid TypeScript diagnostic entry");return{code:String(t.code),message:t.message,line:Number(t.startLocation.line),column:Number(t.startLocation.offset),severity:t.category==="error"?"error":t.category==="warning"?"warning":t.category==="suggestion"?"hint":"info"}}a(Vs,"convertTypeScriptDiagnostic");function Tt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}a(Tt,"isRecord");function Ee(t){return t!==null&&typeof t=="object"&&"code"in t&&t.code===-32601}a(Ee,"isMethodNotFound");import{watch as Sr}from"node:fs";import{readdir as Gs,stat as br}from"node:fs/promises";import J from"node:path";import{URI as Dt}from"vscode-uri";var Nt=4,Lr=-32090,at="pi/sharedDiagnosticsSuperseded",Be=class{static{a(this,"LspFileWatchers")}#e=new Map;#t;#r=!1;#n;#s;#o;constructor(e,n,r){this.#n=J.resolve(e),this.#s=n,this.#o=r}async register(e,n){if(this.#r)throw new Error("Language server file watchers are disposed");let r=[];for(let s of n){let o=s.globPattern,i=typeof o=="string"?this.#n:J.resolve(Dt.parse(typeof o.baseUri=="string"?o.baseUri:o.baseUri.uri).fsPath);!it(i,this.#n)&&!it(this.#n,i)||r.push({base:i,expression:typeof o=="string"?o:o.pattern,kind:s.kind??7})}this.#e.set(e,r),r.length>0?await this.#a():this.#i()}unregister(e){this.#e.delete(e),this.#i()}dispose(){this.#r=!0,this.#e.clear(),this.#i()}#a(){if(this.#t)return this.#t.ready;let e=new Ot(this.#n,(n,r)=>this.#c(e,n,r),n=>{this.#t===e&&this.#o(n)});return this.#t=e,e.ready}#i(){[...this.#e.values()].some(e=>e.length>0)||(this.#t?.close(),this.#t=void 0)}#c(e,n,r){let s=a(o=>[...this.#e.values()].some(i=>i.some(c=>(c.kind&1<<o-1)!==0&&zs(c,r))),"matching");!s(1)&&!s(2)&&!s(3)||br(r).then(o=>{if(this.#t!==e||o.isDirectory())return;let i=n==="rename"?1:2;s(i)&&this.#s({uri:Dt.file(r).toString(),type:i})},o=>{this.#t===e&&(o.code!=="ENOENT"?this.#o(o):s(3)&&this.#s({uri:Dt.file(r).toString(),type:3}))})}};function zs(t,e){return J.isAbsolute(t.expression)?J.matchesGlob(e,t.expression):it(e,t.base)?J.matchesGlob(J.relative(t.base,e),t.expression):!1}a(zs,"matches");function it(t,e){return t===e||t.startsWith(e.endsWith(J.sep)?e:e+J.sep)}a(it,"within");var At=new Set([".git"]),Mt=new Set(["node_modules"]),Ot=class{static{a(this,"TreeWatcher")}#e=new Map;#t;#r=!1;#n;#s;ready=Promise.resolve();constructor(e,n,r){if(this.#n=n,this.#s=r,process.platform==="linux"){this.ready=this.#o(e);return}let s=Sr(e,{recursive:!0},(o,i)=>{if(!i)return;let c=J.join(e,i);Bs(J.relative(e,c))&&this.#n(o,c)});s.on("error",o=>this.#s(o)),this.#t=s}close(){this.#r=!0,this.#t?.close();for(let e of this.#e.values())e.close();this.#e.clear()}async#o(e){if(this.#r||this.#e.has(e))return;let n;try{n=Sr(e,(s,o)=>{o&&this.#a(s,J.join(e,o))})}catch(s){this.#i(s);return}if(n.on("error",s=>{n.close(),this.#e.get(e)===n&&this.#e.delete(e),this.#i(s)}),this.#e.set(e,n),Mt.has(J.basename(e)))return;let r;try{r=await Gs(e,{withFileTypes:!0})}catch(s){this.#i(s);return}for(let s of r)s.isDirectory()&&!At.has(s.name)&&await this.#o(J.join(e,s.name))}#a(e,n){if(this.#r||(this.#n(e,n),e!=="rename"))return;let r=J.basename(J.dirname(n));At.has(J.basename(n))||Mt.has(r)||br(n).then(s=>{s.isDirectory()&&this.#o(n)},()=>{for(let[s,o]of this.#e)it(s,n)&&(o.close(),this.#e.delete(s))})}#i(e){let n=e.code;this.#r||n==="ENOENT"||n==="EACCES"||n==="EPERM"||this.#s(e instanceof Error?e:new Error(String(e)))}};function Bs(t){let e=t.split(J.sep);return!e.some((n,r)=>At.has(n)||Mt.has(n)&&r<e.length-2)}a(Bs,"included");function ct(t,e){return e.map(n=>{let r=t??null;for(let s of n.section?.split(".").filter(Boolean)??[])r=typeof r=="object"&&r!==null?r[s]??null:null;return r})}a(ct,"configurationItems");async function ae(t,e){if(e?.aborted)throw t.catch(()=>{}),e.reason;if(!e)return t;let n;try{return await Promise.race([t,new Promise((r,s)=>{n=a(()=>s(e.reason),"onAbort"),e.addEventListener("abort",n,{once:!0})})])}finally{n&&e.removeEventListener("abort",n)}}a(ae,"waitWithSignal");function Je(t,e){let n;return ae(new Promise(r=>{n=setTimeout(r,t)}),e).finally(()=>clearTimeout(n))}a(Je,"delayWithSignal");var ke=class{static{a(this,"SharedStartup")}controller=new AbortController;promise;settled=!1;waiters=0;constructor(e){this.promise=e(this.controller.signal);let n=a(()=>{this.settled=!0},"settled");this.promise.then(n,n)}async wait(e){this.waiters+=1;let n=await ae(this.promise,e).then(r=>({value:r}),r=>({error:r}));if(this.waiters-=1,!this.settled&&this.waiters===0){this.controller.abort(e?.reason);try{await this.promise}catch(r){if(r!==this.controller.signal.reason)throw new AggregateError([this.controller.signal.reason,r],"Startup cancellation and cleanup failed",{cause:r})}}if("error"in n)throw n.error;return n.value}};var lt="SOURCE_CHANGED",Js=[0,100,250,500];function O(t,e){return Object.assign(new Error(t,e),{code:lt})}a(O,"sourceChanged");function $t(t){return t?.code===lt}a($t,"isSourceChanged");async function ce(t,e,n){for(let r=0;;r+=1)try{return await t()}catch(s){let o=Js[r];if(o===void 0||e?.aborted||!$t(s)&&!n?.(s))throw s;o>0&&await Je(o,e)}}a(ce,"retryWhileSourceChanges");async function we(t,e,n,r={}){let s=new AbortController,o=AbortSignal.any([s.signal,...r.signal?[r.signal]:[]]),i=setTimeout(()=>s.abort(new Error(`[lsp] ${t.serverId}: diagnostics timed out for ${e}`)),t.timeoutMs);try{return await Xs(t,e,n,r.content,o)}finally{clearTimeout(i)}}a(we,"requestDiagnostics");async function Xs(t,e,n,r,s){if(s.throwIfAborted(),t.diagnosticMode!=="push"){let l=t.documentVersion(e),d=t.pulledReport(e);try{let u=await t.sendRequest("textDocument/diagnostic",{textDocument:{uri:e},...d!==void 0&&{previousResultId:d.resultId}},s),p=u.kind==="full"&&Array.isArray(u.items)?u.items:u.kind==="unchanged"&&d!==void 0&&u.resultId===d.resultId?[...d.diagnostics]:void 0;if(p===void 0)throw new Error("Invalid full diagnostic report");if(t.documentVersion(e)!==l)throw new Error("Document changed during diagnostic request");return t.setDiagnosticMode("pull"),l!==void 0&&typeof u.resultId=="string"&&t.rememberPulledReport(e,{version:l,resultId:u.resultId,diagnostics:p}),Cr(p,!1,!0)}catch(u){if(!Ee(u))throw u;t.setDiagnosticMode("push")}}let o=ot(t);if(o){t.documentVersion(e)===void 0&&t.syncDocument(e,r??await _r(Rr.parse(e).fsPath,"utf8"),n??"plaintext");let l=t.documentVersion(e),d=await o.request(t,e,s);if(s.throwIfAborted(),t.documentVersion(e)!==l)throw new Error("Document changed during diagnostic request");return{diagnostics:d,syntaxErrors:[],otherDiagnostics:d,unversioned:!1,complete:!0}}s.throwIfAborted();let i=t.documentVersion(e)!==void 0,c=i?void 0:r??await _r(Rr.parse(e).fsPath,"utf8");s.throwIfAborted(),t.beginDiagnosticRequest(e);try{return await new Promise((l,d)=>{let u=t.documentVersion(e),p=a(v=>{let b=v;b.uri!==e||!Array.isArray(b.diagnostics)||b.version!==void 0&&b.version!==u||t.documentVersion(e)===u&&(w(),l(Cr(b.diagnostics,b.version===void 0)))},"receive"),h=t.onNotification("textDocument/publishDiagnostics",p),S=a(()=>{w(),d(O("The language server has newer file text; resync before checking diagnostics."))},"superseded"),L=t.shared?t.onNotification(at,v=>{let b=v;b.uri===e&&b.version===u&&S()}):void 0,f=a(()=>{w(),d(s.reason)},"onAbort");function w(){h(),L?.(),s.removeEventListener("abort",f)}a(w,"cleanup"),s.addEventListener("abort",f,{once:!0});try{i||t.syncDocument(e,c??"",n??"plaintext"),u=t.documentVersion(e);let v=t.diagnosticPublication(e);v?p({uri:e,...v}):t.diagnosticSuperseded(e)&&S()}catch(v){w(),d(v)}})}finally{t.endDiagnosticRequest(e)}}a(Xs,"requestCurrentDiagnostics");function Ut(t){return{code:String(t.code??"LSP"),message:t.message,line:t.range.start.line+1,column:t.range.start.character+1,severity:t.severity===ze.Warning?"warning":t.severity===ze.Information?"info":t.severity===ze.Hint?"hint":"error"}}a(Ut,"toDiagnostic");function Cr(t,e,n=!1){let r=t.map(Ut);return{diagnostics:r,syntaxErrors:[],otherDiagnostics:r,unversioned:e,complete:n}}a(Cr,"classify");function xr(t,e=(n,r)=>Promise.resolve({cwd:r,external:!1})){return{id:"lsp",async diagnose(n,r){let s=await e(n,r.cwd,r.signal);if(s===void 0)return{status:"unavailable",diagnostics:[],reason:"No local language-server project found for this file"};let o=await t(s.cwd,s.external,r.signal);r.signal.throwIfAborted();let i=await o.getOrStart(n,s.cwd,"diagnostics",r.signal);if(r.signal.throwIfAborted(),!i)return{status:"unavailable",diagnostics:[],reason:"No language server configured for this file"};let c=i.toUri(n),l=o.languageId(n),d=i.retainDocument(c);try{i.syncDocument(c,r.content,l,!0)}catch(g){throw d(),g}let u=i.documentVersion(c),p={active:!0,queued:!1},h=a(()=>!r.signal.aborted&&i.documentVersion(c)===u,"current"),S=a(async()=>(await i.waitUntilLoaded(r.signal),we(i,c,l,{signal:r.signal,content:r.content})),"request"),L,f,w=a(async()=>{if(L=void 0,f=void 0,!(p.active||!p.queued||!h())){p.active=!0,p.queued=!1;try{let g=await S();h()&&r.publish(Pr(g,i.commandName))}catch(g){h()&&r.publish({status:"unavailable",diagnostics:[],reason:g instanceof Error?g.message:String(g),source:i.commandName})}finally{p.active=!1,v()}}},"pullAgain"),v=a(()=>{if(p.active||!p.queued||!h())return;let g=Date.now();f??=g,clearTimeout(L),L=setTimeout(()=>void w(),Math.max(0,Math.min(Qs,f+Ks-g)))},"schedule"),b=a(()=>{p.queued=!0,v()},"refresh"),P=i.onNotification("workspace/diagnostic/refresh",()=>{h()&&i.diagnosticMode==="pull"&&b()}),C=o.onPushDiagnostics(g=>{!h()||g.uri!==c||g.serverId!==i.serverId||g.cwd!==s.cwd||g.version!==void 0&&g.version!==u||(i.diagnosticMode==="pull"||ot(i)?b():r.publish({status:"snapshot",diagnostics:g.diagnostics,source:i.commandName,reason:Er(g.version===void 0)}))}),D=a(()=>{clearTimeout(L),C(),P()},"unsubscribe");r.signal.addEventListener("abort",D,{once:!0});try{let g=await S();return u=i.documentVersion(c),Pr(g,i.commandName)}catch(g){throw p.queued=!1,D(),r.signal.removeEventListener("abort",D),g}finally{d(),p.active=!1,v()}}}}a(xr,"createLspDiagnosticSource");var Qs=750,Ks=3e3;function Er(t){return`Latest push snapshot; completion is unknown${t?"; language server omitted the document version":""}`}a(Er,"snapshotReason");function Pr(t,e){return t.complete?{status:"ready",diagnostics:t.diagnostics,source:e}:{status:"snapshot",diagnostics:t.diagnostics,reason:Er(t.unversioned),source:e}}a(Pr,"toReport");import{URI as Zo}from"vscode-uri";import Wo from"node:path";import Fo from"cross-spawn";import{createMessageConnection as qo,CancellationTokenSource as Ho,ResponseError as Hr,StreamMessageReader as Vo}from"vscode-jsonrpc/node";import{URI as qt}from"vscode-uri";import{spawn as Ys}from"node:child_process";import{closeSync as Zs,openSync as eo,readFileSync as Tr,renameSync as to,statSync as no}from"node:fs";import{createHash as ro}from"node:crypto";import{lstat as so,mkdir as Dr,mkdtemp as oo,rename as io,rm as ao,stat as co,symlink as lo,utimes as uo,writeFile as po}from"node:fs/promises";import{createRequire as go}from"node:module";import fo from"node:net";import Ar from"node:os";import Z from"node:path";import{PassThrough as kr}from"node:stream";var Mr=10*6e4,mo="PI_AGENT_IDE_LSP_LINGER_MS";function Or(t){let e=t[mo];return e!==void 0&&/^\d+$/u.test(e)?Number(e):void 0}a(Or,"sharedServerLingerOverride");var Wt=["shared-server-host.mjs","server-request-handlers.mjs"],Nr=Wt[0],jt=ho();function ho(){try{return Wt.map(t=>Tr(new URL(t,new URL("../src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts",import.meta.url).href),"utf8"))}catch(t){return t instanceof Error?t:new Error(String(t))}}a(ho,"readHostSources");var $r=1e4,yo=25,dt=class{static{a(this,"LspSharedServers")}_directory;constructor(e={}){this._directory=e.directory??Z.join(Ar.tmpdir(),`pi-agent-ide-lsp-${Ir()}`)}async attach(e){let n=So(),r=wo(e,n.version),s=await this._socketPath(r),o=await Ur(s,e.signal);if(!o){let i=await _o(this._directory,n),c=Ro(i,s,r,this._directory);o=await ko(s,c,e.signal)}try{let i=await Io(o,{protocol:Nt,key:r,command:e.command,cwd:e.cwd,env:e.env,settings:e.settings,initialize:e.initialize,lingerMs:e.lingerMs,timeoutMs:e.timeoutMs},e.timeoutMs+$r,e.signal);if(typeof i.pid!="number")throw new Error(typeof i.error=="string"?i.error:"Shared language server did not attach");return To(o,i.pid)}catch(i){throw o.destroy(),i}}async _socketPath(e){if(await Dr(this._directory,{recursive:!0,mode:448}),process.platform==="win32")return`\\\\.\\pipe\\pi-agent-ide-lsp-${Ft(vo())}-${e}`;let n=await so(this._directory);if(!n.isDirectory()||n.uid!==Ir()||(n.mode&63)!==0)throw new Error(`Shared language server directory is not private: ${this._directory}`);return Z.join(this._directory,`${e}.sock`)}};function wo(t,e){return Ft(JSON.stringify([Nt,e,t.serverId,t.command,t.configuredEnv,t.initialize.rootUri,t.initialize.initializationOptions??null,t.settings??null]))}a(wo,"sharedServerKey");function Ir(){return process.getuid?.()??-1}a(Ir,"currentUid");function vo(){try{return Ar.userInfo().username}catch{return process.env.USERNAME||process.env.USER||"unknown"}}a(vo,"currentUserName");function Ft(t){return ro("sha256").update(t).digest("hex").slice(0,24)}a(Ft,"hash");function So(){if(jt instanceof Error)throw jt;let t=jt,e=go(new URL(Nr,new URL("../src/plugins/pi-agent-ide-lsp/src/lsp/shared-servers.ts",import.meta.url).href)),n=new Map([...new Set(t.flatMap(bo))].toSorted().map(r=>[r,Lo(r,e.resolve(r))]));return{sources:t,packages:n,version:Ft(JSON.stringify([t,[...n]]))}}a(So,"loadedHost");function bo(t){return[...t.matchAll(/\bfrom\s+["']([^"'.][^"']*)["']/gu)].map(([,e=""])=>e).filter(e=>!e.startsWith("node:")).map(e=>{let n=e.split("/");return(e.startsWith("@")?n.slice(0,2):n.slice(0,1)).join("/")})}a(bo,"packageImports");function Lo(t,e){for(let n=Z.dirname(e);;n=Z.dirname(n)){try{if(JSON.parse(Tr(Z.join(n,"package.json"),"utf8")).name===t)return n}catch{}if(Z.dirname(n)===n)throw new Error(`Shared language server host package not found: ${t}`)}}a(Lo,"packageRoot");async function _o(t,e){let n=Z.join(t,`host-${e.version}`),r=Z.join(n,Nr),s=a(async()=>{try{await co(r);let i=new Date;return await uo(n,i,i),!0}catch{return!1}},"present");if(await s())return r;let o=await oo(Z.join(t,"staging-"));try{await Promise.all(Wt.map((i,c)=>po(Z.join(o,i),e.sources[c]??"")));for(let[i,c]of e.packages){let l=Z.join(o,"node_modules",i);await Dr(Z.dirname(l),{recursive:!0}),await lo(c,l,"junction")}await io(o,n)}catch(i){if(await ao(o,{recursive:!0,force:!0}),!await s())throw i}return r}a(_o,"writeHost");function Ro(t,e,n,r){let s=process.versions.bun||!Eo()?process.execPath:"node",o=Z.join(r,`${n}.log`);Co(o);let i=eo(o,"w",384);try{let c=Ys(s,[t,e,n,o],{cwd:r,detached:!0,env:Po(),stdio:["ignore","ignore",i],windowsHide:!0});return c.unref(),c}finally{Zs(i)}}a(Ro,"startHost");function Co(t){try{let{mtimeMs:e,size:n}=no(t);n>0&&to(t,t.replace(/\.log$/u,`.${String(Math.round(e))}.log`))}catch{}}a(Co,"keepFailureLog");function Po(){let t={};for(let e of xo){let n=process.env[e];n!==void 0&&(t[e]=n)}return process.versions.bun&&(t.BUN_BE_BUN="1"),t}a(Po,"hostEnvironment");var xo=["PATH","Path","HOME","USERPROFILE","TMPDIR","TMP","TEMP","SystemRoot","LANG"];function Eo(){return process.getBuiltinModule("node:sea")?.isSea?.()??!1}a(Eo,"singleExecutable");function Ur(t,e){return e?.throwIfAborted(),new Promise((n,r)=>{let s=fo.connect(t);s.once("connect",()=>{s.removeAllListeners("error"),s.on("error",()=>{}),n(s)}),s.once("error",o=>{s.destroy(),o.code==="ENOENT"||o.code==="ECONNREFUSED"?n(void 0):r(o)})})}a(Ur,"connect");async function ko(t,e,n){let r;e.once("error",o=>r=o),e.once("exit",o=>{o!==0&&(r=new Error(`Shared language server host exited with code ${o}`))});let s=Date.now()+$r;for(;;){if(r)throw r;let o=await Ur(t,n);if(o)return o;if(Date.now()>s)throw new Error("Shared language server host did not start");await new Promise(i=>setTimeout(i,yo))}}a(ko,"waitForHost");function Io(t,e,n,r){return new Promise((s,o)=>{let i=Buffer.alloc(0),c=a(h=>{i=Buffer.concat([i,h]);let S=i.indexOf(10);if(S!==-1){p(),t.pause(),S+1<i.length&&t.unshift(i.subarray(S+1));try{s(JSON.parse(i.subarray(0,S).toString("utf8")))}catch(L){o(L)}}},"onData"),l=a(()=>{p(),o(new Error("Shared language server host closed the connection"))},"onClose"),d=a(()=>{p(),o(r?.reason)},"onAbort"),u=setTimeout(()=>{p(),o(new Error("Shared language server attach timed out"))},n),p=a(()=>{clearTimeout(u),t.off("data",c),t.off("close",l),r?.removeEventListener("abort",d)},"finish");t.on("data",c),t.once("close",l),r?.addEventListener("abort",d,{once:!0}),t.write(`${JSON.stringify(e)}
|
|
2
|
+
`)})}a(Io,"exchange");function To(t,e){let n=!1,r=new Promise(i=>t.once("close",()=>i())),s=new kr;s.end();let o=t.pipe(new kr);return{stdin:t,stdout:o,stderr:s,pid:e,completion:r.then(()=>({exitCode:n?0:1})),async stop(){n=!0,t.end();let i=setTimeout(()=>t.destroy(),1e3);await r,clearTimeout(i)}}}a(To,"sharedServer");import{StreamMessageWriter as Do}from"vscode-jsonrpc/node";var ut=class extends Do{constructor(n,r){super(n);this.fail=r}static{a(this,"TransportWriter")}async write(n){try{await super.write(n)}catch(r){this.fail(r)}}};import Ao from"node:path";import{URI as Mo}from"vscode-uri";function Q(t,e){if(e.startsWith("ssh://")){let n=jr(e);if(t.includes("://")){let s=jr(t);if(s.host!==n.host)throw new Error("Document belongs to another language server owner");return s.href}let r=Ao.posix.resolve(decodeURIComponent(n.pathname),t);return n.pathname=r.split("/").map(encodeURIComponent).join("/"),n.href}if(t.startsWith("ssh://")||t.includes("://")&&!t.startsWith("file://"))throw new Error("Document belongs to another language server owner");return t.startsWith("file://")?t:Mo.file(t).toString()}a(Q,"documentUri");function jr(t){let e=new URL(t);if(e.protocol!=="ssh:"||!e.hostname||e.username||e.password||e.port||e.search||e.hash)throw new Error("Invalid language server resource owner");return decodeURIComponent(e.pathname),e}a(jr,"checkedRemote");var Oo=new Set(["uri","targetUri","target","oldUri","newUri","rootUri","documentUri","scopeUri","baseUri"]),No=new Set(["changes","relatedDocuments"]);function fe(t,e){return Array.isArray(t)?t.map(n=>fe(n,e)):typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([n,r])=>Oo.has(n)&&typeof r=="string"?[n,e(r)]:No.has(n)&&typeof r=="object"&&r!==null&&!Array.isArray(r)?[n,Object.fromEntries(Object.entries(r).map(([s,o])=>[e(s),fe(o,e)]))]:[n,fe(r,e)]))}a(fe,"mapLspUris");import $o from"node:path";var Uo=/^clangd(?:-\d+(?:\.\d+)*)?$/u,jo=['u="${XDG_CONFIG_HOME:-$HOME/.config}/clangd/config.yaml"',"write() {",' c="$1/clangd/config.yaml"',' mkdir -p "$1/clangd" && {'," printf '%s\\n' '# Written by pi-agent-ide for the clangd it starts: report every error.' 'CompileFlags:' ' Add: [-ferror-limit=0]'",` if [ -f "$u" ] && [ "$u" != "$c" ]; then printf '%s\\n' '---'; cat "$u"; fi`,' } > "$c.$$" && mv -f "$c.$$" "$c" || { rm -f "$c.$$"; false; }',"}",'d="${XDG_CACHE_HOME:-$HOME/.cache}/pi-agent-ide/clangd-config"','if write "$d" 2>/dev/null || { d=$(mktemp -d "${TMPDIR:-/tmp}/pi-agent-ide-clangd.XXXXXX") && write "$d"; } 2>/dev/null; then',' XDG_CONFIG_HOME="$d"'," export XDG_CONFIG_HOME","fi",'exec "$@"'].join(`
|
|
3
|
+
`);function Wr(t,e){let n=t[0];return!e||n===void 0||!Uo.test($o.posix.basename(n))?[...t]:["sh","-c",jo,"pi-agent-ide-clangd",...t]}a(Wr,"launchCommand");function Fr(t=process.platform){return t!=="win32"&&t!=="darwin"}a(Fr,"localXdgConfig");var ve=class{static{a(this,"LspClient")}_process=null;_ownedProcess=null;_ownedStartup;_ownerTransport;_sharedServers;_sharedServer=null;_connection=null;_initialized=!1;_serverCapabilities=null;_disposed=!1;_shutdownPromise;_crashed=!1;_stderr="";_fileWatchers;_fileWatcherCleanup=Promise.resolve();_handlers=new Map;_documentVersions=new Map;_lastSharedDocumentVersion=0;_documentContents=new Map;_diagnosticPublications=new Map;_supersededDiagnostics=new Set;_pulledReports=new Map;_diagnosticMode="unknown";_pullRegistration;_versionedDiagnostics=!1;_activeDiagnosticRequests=new Set;_serverStatus;_serverStatusListeners=new Set;_pendingSaves=new Set;_documentLeases=new Map;_pendingRequests=0;_idleTimer;_idleTimeoutMs;_onIdle;serverId;rootUri;_command;_launch;_args;_env;_initOptions;_settings;_timeoutMs;constructor(e){this.serverId=e.serverId,this.rootUri=e.rootUri,this._command=e.command,this._launch=Wr(e.command,e.ownerTransport!==void 0||Fr()),this._args=this._launch.slice(1),this._env=e.env??{},this._initOptions=e.initOptions,this._settings=e.settings,this._timeoutMs=e.timeoutMs??3e4,this._ownerTransport=e.ownerTransport,this._sharedServers=e.sharedServers,this._idleTimeoutMs=e.idleTimeoutMs,this._onIdle=e.onIdle}get ready(){return this._initialized&&!this._disposed}get crashed(){return this._crashed}get pid(){return this._process?.pid??this._sharedServer?.pid??null}get shared(){return this._sharedServer!==null}get remote(){return this._ownedProcess?.remote}get commandName(){return gr(this._command)}get workspaceSymbolCandidateLimit(){switch(this.commandName.replace(/\.exe$/iu,"")){case"gopls":return 100;case"rust-analyzer":{let[e]=ct(this._settings,[{section:"rust-analyzer"}]),n=typeof e=="object"&&e!==null&&Object.keys(e).length>0?e:this._initOptions,[r]=ct(n,[{section:"workspace.symbol.search.limit"}]);return typeof r=="number"&&Number.isSafeInteger(r)&&r>=0?r:128}default:return}}get diagnosticMode(){return this._diagnosticMode}setDiagnosticMode(e){this._diagnosticMode=e}get timeoutMs(){return this._timeoutMs}supportsCommand(e){let n=this._serverCapabilities?.executeCommandProvider;return Array.isArray(n?.commands)&&n.commands.includes(e)}get loading(){return this._serverStatus?.quiescent===!1}async waitUntilLoaded(e){if(!this.loading)return;let n,r;try{await ae(new Promise((s,o)=>{n=a(()=>{this.loading||s()},"listener"),this._serverStatusListeners.add(n),r=setTimeout(()=>{let i=this._serverStatus?.message;o(Object.assign(new Error(`[lsp] ${this.serverId} is still loading the project${i?` (${i})`:""}; its results would be incomplete. Try again later.`),{code:"SERVER_LOADING"}))},this._timeoutMs)}),e)}finally{clearTimeout(r),n&&this._serverStatusListeners.delete(n)}}_setServerStatus(e){this._serverStatus=e;for(let n of[...this._serverStatusListeners])n()}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)}diagnosticSuperseded(e){return this._supersededDiagnostics.has(e)}pulledReport(e){let n=this._pulledReports.get(e);return n?.version===this.documentVersion(e)?n:void 0}rememberPulledReport(e,n){n.version===this.documentVersion(e)&&this._pulledReports.set(e,n)}beginDiagnosticRequest(e){this._activeDiagnosticRequests.add(e)}endDiagnosticRequest(e){this._activeDiagnosticRequests.delete(e)}hasActiveDiagnosticRequest(e){return this._activeDiagnosticRequests.has(e)}async start(e){e?.throwIfAborted();try{await this._start(e)}catch(n){try{await this.shutdown()}catch(r){throw new AggregateError([e?.aborted?e.reason:n,r],`[lsp] ${this.serverId}: startup and cleanup failed`,{cause:r})}throw e?.throwIfAborted(),n}}async _start(e){if(this._initialized)return;if(this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);if(!this.rootUri.startsWith("file://")&&!this._ownerTransport)throw Object.assign(new Error("No language server process transport for this resource owner"),{code:"UNSUPPORTED_SOURCE"});if(await this._closeFileWatchers(),e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let n=q(this._launch[0]),r=this._ownerTransport?decodeURIComponent(new URL(this.rootUri).pathname):qt.parse(this.rootUri).fsPath,s=[{uri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,name:Wo.basename(r)||r}],o=this._ownerTransport?this._ownerTransport.fileWatchers!==void 0:!0,i={processId:this._ownerTransport?null:process.pid,rootUri:this._ownerTransport?.toServerUri(this.rootUri)??this.rootUri,workspaceFolders:s,capabilities:{workspace:{applyEdit:!1,configuration:!0,workspaceFolders:!0,didChangeWatchedFiles:{dynamicRegistration:o,relativePatternSupport:o},symbol:{dynamicRegistration:!1}},experimental:{serverStatusNotification:!0},textDocument:{synchronization:{didOpen:!0,didChange:!0,didClose:!0},publishDiagnostics:{relatedInformation:!0,versionSupport:!0},diagnostic:{dynamicRegistration:!0,relatedDocumentSupport:!1},documentSymbol:{hierarchicalDocumentSymbolSupport:!0},foldingRange:{lineFoldingOnly:!0}}},initializationOptions:this._initOptions};this._ownedStartup=this._ownerTransport?.start({rootUri:this.rootUri,command:this._launch,env:this._env,signal:e});let c=await this._ownedStartup;if(this._ownedProcess=c??null,e?.throwIfAborted(),this._disposed)throw new Error(`[lsp] ${this.serverId}: disposed`);let l=c?void 0:await this._attachSharedServer(r,i,e);if(this._disposed)throw await l?.stop(),new Error(`[lsp] ${this.serverId}: disposed`);this._sharedServer=l??null,e?.throwIfAborted();let d=c||l?void 0:Fo(n,this._args,{stdio:["pipe","pipe","pipe"],...e&&{signal:e},cwd:r,env:kt({command:this._command,env:this._env},r,process.env)});this._process=d??null;let u=d?Qo(d):Promise.resolve(),p=c??l,h=q(p?.stdin??d?.stdin),S=q(p?.stdout??d?.stdout),L=q(p?.stderr??d?.stderr);h.on("error",()=>{}),S.on("error",()=>{}),L.on("error",()=>{}),this._stderr="";let f=new Promise(m=>{L.once("end",m),L.once("close",m)}),w,v=a(()=>{},"markExited"),b=new Promise(m=>{v=m});L.setEncoding("utf8"),L.on("data",m=>{this._stderr=(this._stderr+m).slice(-4096)}),d?.on("error",m=>{("code"in m?m.code:void 0)!=="ENOENT"&&console.error(`[lsp] ${this.serverId}: spawn failed:`,m),this._crashed=!0,this._connection?.dispose(),this._connection=null,this._process=null});let P=a(()=>c?this._ownedProcess===c:l?this._sharedServer===l:this._process===d,"current"),C=a(m=>{P()&&(w??=m,v(),this._closeFileWatchers(),!this._disposed&&m!==0&&m!==null&&(this._crashed=!0),this._connection?.dispose(),this._connection=null,this._diagnosticPublications.clear(),this._supersededDiagnostics.clear(),this._pulledReports.clear(),this._activeDiagnosticRequests.clear(),this._diagnosticMode="unknown",this._pullRegistration=void 0,this._versionedDiagnostics=!1,this._setServerStatus(void 0),this._process=null,this._initialized=!1)},"onExit");d?.on("exit",C),p?.completion.then(({exitCode:m})=>C(m),()=>{P()&&(this._crashed=!0,C(null))}),await ae(u,e);let D=qo(new Vo(S),new ut(h,m=>{this._connection!==D||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),D.dispose(),console.error(`[lsp] ${this.serverId}: transport write failed:`,m))}));this._connection=D,this._connection.onError(m=>{console.error(`[lsp] ${this.serverId}: connection error:`,m)});let g=a(m=>{this._sendNotification("workspace/didChangeWatchedFiles",{changes:[m]})},"changed"),_=a(m=>console.error(`[lsp] ${this.serverId}: file watcher failed:`,m),"failed");this._fileWatchers=this._ownerTransport?this._ownerTransport.fileWatchers?.(this.rootUri,g,_):l?void 0:new Be(r,g,_),this._connection.onRequest("client/registerCapability",async m=>{for(let x of m.registrations)if(x.method!=="workspace/didChangeConfiguration"){if(x.method==="textDocument/diagnostic"){this._pullRegistration=x.id,this._initialized&&(this._diagnosticMode="pull");continue}if(x.method!=="workspace/didChangeWatchedFiles")throw new Error(`Unsupported dynamic capability: ${x.method}`);if(!this._fileWatchers)throw new Error("File watching is unavailable for this server owner");await this._fileWatchers.register(x.id,x.registerOptions?.watchers??[])}return null}),this._connection.onRequest("client/unregisterCapability",async m=>{for(let x of m.unregisterations)x.id===this._pullRegistration?(this._pullRegistration=void 0,this._initialized&&(this._diagnosticMode="push")):await this._fileWatchers?.unregister(x.id);return null}),this._connection.onRequest("window/workDoneProgress/create",()=>null),this._connection.onRequest("workspace/diagnostic/refresh",()=>{for(let m of this._handlers.get("workspace/diagnostic/refresh")??[])m(void 0);return null}),this._connection.onRequest("workspace/configuration",m=>ct(this._settings,m.items)),this._connection.listen(),this._connection.onNotification((m,...x)=>{let I=this._ownerTransport,A=I?fe(x[0],E=>I.fromServerUri(E)):x[0];if(m===at){let E=A;if(!this.shared||typeof E?.uri!="string"||typeof E.version!="number"||E.version!==this.documentVersion(E.uri))return;this._supersededDiagnostics.add(E.uri)}if(m==="textDocument/publishDiagnostics"){let E=A;if(typeof E?.version=="number")this._versionedDiagnostics=!0;else if(this._versionedDiagnostics&&typeof E?.uri=="string"&&this._documentVersions.has(E.uri))return;E&&typeof E.uri=="string"&&Array.isArray(E.diagnostics)&&this._documentVersions.has(E.uri)&&(E.version===void 0||E.version===this.documentVersion(E.uri))&&(this._supersededDiagnostics.delete(E.uri),this._diagnosticPublications.set(E.uri,{diagnostics:E.diagnostics,...typeof E.version=="number"&&{version:E.version}}))}if(m==="experimental/serverStatus"){let E=A;this._setServerStatus({quiescent:E?.quiescent!==!1,...typeof E?.message=="string"&&{message:E.message}})}for(let E of this._handlers.get(m)?.slice()??[])E(A)}),this._connection.onRequest("workspace/workspaceFolders",()=>s);let k=await ae(qr(this._connection.sendRequest("initialize",i),this._timeoutMs,`[lsp] ${this.serverId}: initialize timed out`),e).catch(async m=>{if(e?.aborted)throw m;await Promise.race([Promise.all([f,b]),Je(Go,e)]).catch(()=>{});let x=this._stderr.trim(),I=w===void 0?void 0:`exited during startup${w===null?"":` with code ${w}`}`;if(!x&&!I)throw m;let A=`[lsp] ${this.serverId}${I?` ${I}`:""}${x?`: ${x}`:""}`;throw I?new Error(A):new Error(A,{cause:m})});if(await this._connection.sendNotification("initialized",{capabilities:k.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`);e?.throwIfAborted(),this._initialized=!0,this._serverCapabilities=k.capabilities,this._diagnosticMode=k.capabilities.diagnosticProvider||this._pullRegistration!==void 0?"pull":"push"}async _attachSharedServer(e,n,r){if(this._sharedServers)try{return await this._sharedServers.attach({serverId:this.serverId,command:this._launch,cwd:e,configuredEnv:this._env,env:kt({command:this._command,env:this._env},e,process.env),settings:this._settings,initialize:n,lingerMs:Or(process.env)??this._idleTimeoutMs??Mr,timeoutMs:this._timeoutMs,...r&&{signal:r}})}catch{r?.throwIfAborted();return}}touch(){if(clearTimeout(this._idleTimer),this._idleTimer=void 0,this._idleTimeoutMs===void 0||this._disposed||this._busy)return;let e=setTimeout(()=>{this._idleTimer===e&&(this._idleTimer=void 0,this.ready&&!this._busy&&this._onIdle?.())},this._idleTimeoutMs);e.unref(),this._idleTimer=e}get _busy(){return this._pendingRequests>0||this._documentLeases.size>0}retainDocument(e){this._documentLeases.set(e,(this._documentLeases.get(e)??0)+1),this.touch();let n=!1;return()=>{if(n)return;n=!0;let r=(this._documentLeases.get(e)??1)-1;if(r>0){this._documentLeases.set(e,r);return}this._documentLeases.delete(e),this.ready&&this._documentVersions.has(e)&&this.closeDocument(e),this.touch()}}async restart(e){await this.shutdown(),this._closeFileWatchers(),this._connection?.dispose(),this._connection=null,this._process=null,this._initialized=!1,this._crashed=!1,this._disposed=!1,this._shutdownPromise=void 0,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._supersededDiagnostics.clear(),this._pulledReports.clear(),this._diagnosticMode="unknown",this._versionedDiagnostics=!1,this._activeDiagnosticRequests.clear(),this._serverCapabilities=null,await this.start(e)}async sendRequest(e,n,r){this._assertReady(),r?.throwIfAborted(),this._pendingRequests++,this.touch();try{let s=!1;for(let o=0;;o++){let i;try{i=await this._sendRequest(e,n,r)}catch(c){if(this.shared&&c instanceof Hr&&c.code===Lr)throw O(c.message);let l=zo[o];if(l===void 0||!Xo(c))throw c;await Je(l,r),this._assertReady();continue}if(s||!this.loading||e==="workspace/executeCommand")return i;s=!0,await this.waitUntilLoaded(r),this._assertReady()}}finally{this._pendingRequests--,this.touch()}}async _sendRequest(e,n,r){let s=this._ownerTransport,o=s?fe(n,d=>s.toServerUri(d)):n,i=a(d=>s?fe(d,u=>s.fromServerUri(u)):d,"mapResult");if(!r)return i(await q(this._connection).sendRequest(e,o));let c=new Ho,l;try{let d=q(this._connection).sendRequest(e,o,c.token);return i(await Promise.race([d,new Promise((u,p)=>{l=a(()=>{c.cancel(),p(r.reason)},"onAbort"),r.addEventListener("abort",l,{once:!0})})]))}finally{l&&r.removeEventListener("abort",l),c.dispose()}}sendNotification(e,n){this._assertReady(),this._sendNotification(e,n)}_sendNotification(e,n){let r=this._connection;if(!r)return;let s=this._ownerTransport,o=s?fe(n,i=>s.toServerUri(i)):n;r.sendNotification(e,o).catch(i=>{this._connection!==r||this._disposed||(this._crashed=!0,this._initialized=!1,this._closeFileWatchers(),r.dispose(),console.error(`[lsp] ${this.serverId}: notification ${e} failed:`,i))})}onNotification(e,n){let r=this._handlers.get(e)??[];return r.push(n),this._handlers.set(e,r),()=>{let s=r.indexOf(n);s!==-1&&r.splice(s,1)}}toUri(e){return Q(e,this.rootUri)}serverDocumentPath(e){let n=this.toUri(e),r=this._ownerTransport?.toServerUri(n)??n;return this._ownerTransport?decodeURIComponent(new URL(r).pathname):qt.parse(r).fsPath}serverPathToDocumentUri(e){let n=qt.file(e).toString();return this._ownerTransport?.fromServerUri(n)??n}openDocument(e,n,r,s=1){let o=this._documentVersions.get(e);if(o!==void 0){this.changeDocument(e,n,Math.max(s,o+1));return}this._diagnosticPublications.delete(e),this._supersededDiagnostics.delete(e),this._pulledReports.delete(e);let i=this._sharedDocumentVersion(s);this.sendNotification("textDocument/didOpen",{textDocument:{uri:e,languageId:r,version:i,text:n}}),this._documentVersions.set(e,i),this._documentContents.set(e,n)}syncDocument(e,n,r,s=!1){if(this._documentContents.get(e)===n&&!this.diagnosticSuperseded(e))return;let o=this._documentVersions.get(e);o===void 0?this.openDocument(e,n,r):this.changeDocument(e,n,o+1),s&&(this.loading?this._deferSave(e):this._sendSave(e))}_sendSave(e){let n=this._serverCapabilities?.textDocumentSync,r=typeof n=="object"&&n!==null?n.save:void 0,s=this._documentContents.get(e);!r||s===void 0||this.sendNotification("textDocument/didSave",{textDocument:{uri:e},...typeof r=="object"&&r.includeText&&{text:s}})}_deferSave(e){let n=this._pendingSaves.size>0;if(this._pendingSaves.add(e),n)return;let r=a(()=>{if(this.loading)return;this._serverStatusListeners.delete(r);let s=[...this._pendingSaves];this._pendingSaves.clear();for(let o of s)this._sendSave(o)},"listener");this._serverStatusListeners.add(r)}changeDocument(e,n,r){let s=this._documentVersions.get(e),o=this._sharedDocumentVersion(Math.max(r,(s??0)+1));this._diagnosticPublications.delete(e),this._supersededDiagnostics.delete(e),this._pulledReports.delete(e),this.sendNotification("textDocument/didChange",{textDocument:{uri:e,version:o},contentChanges:[{text:n}]}),this._documentVersions.set(e,o),this._documentContents.set(e,n)}_sharedDocumentVersion(e){return this.shared?this._lastSharedDocumentVersion=Math.max(e,this._lastSharedDocumentVersion+1):e}closeDocument(e){this.sendNotification("textDocument/didClose",{textDocument:{uri:e}}),this._documentVersions.delete(e),this._documentContents.delete(e),this._diagnosticPublications.delete(e),this._supersededDiagnostics.delete(e),this._pulledReports.delete(e)}shutdown(){return this._shutdownPromise??=this._shutdown()}async _shutdown(){this._disposed=!0,this._setServerStatus(void 0),clearTimeout(this._idleTimer),this._idleTimer=void 0;let e=this._closeFileWatchers();if(this._connection&&this._initialized)try{await qr(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;let n=this._ownedProcess??await this._ownedStartup?.catch(()=>{});this._ownedProcess=null,this._ownedStartup=void 0;let r=Promise.resolve().then(()=>n?.stop()),s=this._sharedServer;this._sharedServer=null;let o=Promise.resolve().then(()=>s?.stop()),i=this._process;this._process=null,i&&!i.killed&&(i.kill("SIGTERM"),setTimeout(()=>{i.exitCode===null&&i.signalCode===null&&i.kill("SIGKILL")},2e3).unref()),this._initialized=!1,this._documentVersions.clear(),this._documentContents.clear(),this._diagnosticPublications.clear(),this._supersededDiagnostics.clear(),this._pulledReports.clear(),this._diagnosticMode="unknown",this._versionedDiagnostics=!1,this._activeDiagnosticRequests.clear(),this._serverCapabilities=null;let c=await Promise.allSettled([r,o,e]),l=[];for(let d of c)d.status==="rejected"&&l.push(d.reason);if(l.length>0)throw new AggregateError(l,`[lsp] ${this.serverId}: owned cleanup failed`)}dispose(){return this.shutdown()}_closeFileWatchers(){let e=this._fileWatchers;return this._fileWatchers=void 0,e&&(this._fileWatcherCleanup=this._fileWatcherCleanup.catch(()=>{}).then(()=>e.dispose()),this._fileWatcherCleanup.catch(n=>{console.error(`[lsp] ${this.serverId}: file watcher cleanup failed:`,n)})),this._fileWatcherCleanup}_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`)}},Go=250,zo=[50,100,200,400,800],Bo=-32801,Jo=-32802;function Xo(t){if(!(t instanceof Hr))return!1;if(t.code===Bo)return!0;if(t.code!==Jo)return!1;let e=t.data;return!(e!==null&&typeof e=="object"&&"retriggerRequest"in e&&e.retriggerRequest===!1)}a(Xo,"isRetryableCancellation");function Qo(t){return new Promise((e,n)=>{let r=a(()=>{t.off("spawn",s),t.off("error",o)},"cleanup"),s=a(()=>{r(),e()},"onSpawn"),o=a(i=>{r(),n(i)},"onError");t.once("spawn",s),t.once("error",o)})}a(Qo,"waitForSpawn");function qr(t,e,n){return new Promise((r,s)=>{let o=setTimeout(()=>{s(new Error(n))},e);t.then(i=>{clearTimeout(o),r(i)}).catch(i=>{clearTimeout(o),s(i instanceof Error?i:new Error(String(i)))})})}a(qr,"withTimeout");import z from"node:path";import{existsSync as Ko}from"node:fs";function Vr(t){let e=new Map,n=new Map;for(let[r,s]of Object.entries(t))for(let[o,i]of Object.entries(s.languages))for(let c of i.extensions){let l=c.toLowerCase(),d=e.get(l);if(d!==void 0&&d!==o)throw new Error(`[lsp] extension conflict: "${l}" claimed by "${d}" and "${o}"`);e.set(l,o);let u=n.get(l)??[];u.push(r),n.set(l,u)}return{extToLanguageId:e,extToServerIds:n}}a(Vr,"buildLanguageLookup");var pe=class t{constructor(e,n,r){this._projectRoot=r;this._entries=e;let s=e.filter(o=>o.layer!=="built-in"||n.has(o.id));this._servers=Object.fromEntries(s.map(o=>[o.id,o.config])),this._lookup=Vr(this._servers)}static{a(this,"LspServerRegistry")}_servers;_entries;_lookup;static async fromPackageDir(e,n={}){n.signal?.throwIfAborted();let r=await mr(e,"lsp-servers",l=>Yo(l).servers,n);if(n.signal?.throwIfAborted(),e.startsWith("ssh://")&&(!n.executableAvailable&&!n.executableAvailability||n.requireBuiltInEvidence&&!n.recipeEvidence))throw Object.assign(new Error("Remote language server availability needs its workspace owner"),{code:"UNSUPPORTED_SOURCE"});let s=n.environment??process.env,o=r.entries.filter(l=>l.layer==="built-in"),i=[];if(n.executableAvailability){let l=await n.executableAvailability(o.map(d=>d.config));if(l.length!==o.length||l.some(d=>typeof d!="boolean"))throw new TypeError("Invalid owner executable availability report");for(let[d,u]of o.entries())i.push({id:u.id,available:l[d]===!0})}else if(n.executableAvailable)for(let l of o)i.push({id:l.id,available:await n.executableAvailable(l.config)});else i.push(...await Promise.all(o.map(async l=>({id:l.id,available:await hr(l.config,e,s,n.signal)}))));n.signal?.throwIfAborted();let c=n.requireBuiltInEvidence?n.recipeEvidence?await n.recipeEvidence(n.recipes??[]):await pr(e,n.recipes??[],void 0,n.signal):void 0;return n.signal?.throwIfAborted(),new t(r.entries,new Set(i.filter(l=>l.available&&(c===void 0||(c.get(l.id)?.score??0)>0)).map(l=>l.id)),e.startsWith("ssh://")?e:z.resolve(e))}static fromConfig(e,n=process.cwd()){return new t(Object.entries(e.servers).map(([r,s])=>({id:r,config:s,layer:"project",sourcePath:"<memory>"})),new Set,n.startsWith("ssh://")?n:z.resolve(n))}resolve(e){return this.candidates(e).filter(n=>!n.config.requireRootMarker||this.hasRootMarker(e,n.config.rootMarkers))}candidates(e){let n=z.basename(e),r=z.extname(e)||(e.startsWith(".")?e:`.${e}`),s=a(i=>process.platform==="win32"?i.toLowerCase():i,"normalizeName"),o=[];for(let i of this._entries)if(this._servers[i.id]){for(let[c,l]of Object.entries(i.config.languages))if(l.extensions.some(d=>d.toLowerCase()===r.toLowerCase())||l.fileNames?.some(d=>s(d)===s(n))){o.push({serverId:i.id,config:i.config,languageId:c,layer:i.layer,sourcePath:i.sourcePath});break}}return o}async resolveOwned(e,n){if(!this._projectRoot.startsWith("ssh://"))return this.resolve(e);let r=new URL(this._projectRoot),s=decodeURIComponent(r.pathname),o=e.startsWith(".")&&!e.includes("/"),i=e.includes("://")?new URL(e):new URL(r.href),c=e.includes("://")?decodeURIComponent(i.pathname):z.posix.resolve(s,e),l=z.posix.relative(s,c);if(i.origin!==r.origin||i.host!==r.host||i.protocol!==r.protocol||i.username||i.password||i.port||i.search||i.hash||l===".."||l.startsWith("../"))throw Object.assign(new Error("Language server resource belongs to another owner"),{code:"UNSUPPORTED_SOURCE"});let d=[];for(let u of this.candidates(o?e:c)){if(!u.config.requireRootMarker){d.push(u);continue}let p=o||c===s?s:z.posix.dirname(c);for(;;){let h=!1;for(let S of u.config.rootMarkers){let L=z.posix.resolve(p,S),f=z.posix.relative(s,L);if(f===".."||f.startsWith("../"))continue;let w=new URL(r.href);if(w.pathname=L.split("/").map(encodeURIComponent).join("/"),await n(w.href)){h=!0;break}}if(h){d.push(u);break}if(p===s)break;p=z.posix.dirname(p)}}return d}hasRootMarker(e,n){let r=z.dirname(z.resolve(this._projectRoot,e));for(e.startsWith(".")&&!e.includes(z.sep)&&(r=this._projectRoot);;){let s=z.relative(this._projectRoot,r);if(s===".."||s.startsWith(`..${z.sep}`)||z.isAbsolute(s))return!1;if(n.some(o=>Ko(z.join(r,o))))return!0;if(r===this._projectRoot)return!1;r=z.dirname(r)}}get projectRoot(){return this._projectRoot}get servers(){return this._servers}get entries(){return this._entries}get knownExtensions(){return new Set(this._lookup.extToLanguageId.keys())}languageId(e){let n=e.startsWith("ssh://")?decodeURIComponent(new URL(e).pathname):e;return(this._projectRoot.startsWith("ssh://")?this.candidates(n):this.resolve(n))[0]?.languageId??e.slice(1)}};function Yo(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("LSP config must be an object");let e=t;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[n,r]of Object.entries(e.servers)){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`LSP server ${n} must be an object`);let s=r;if(!Array.isArray(s.command)||s.command.length===0||s.command.some(o=>typeof o!="string"||o.length===0))throw new Error(`LSP server ${n}.command must be a non-empty string array`);if(s.transport!==void 0&&s.transport!=="stdio")throw new Error(`LSP server ${n} only supports stdio transport`);if(!Array.isArray(s.rootMarkers)||s.rootMarkers.some(o=>typeof o!="string"))throw new Error(`LSP server ${n}.rootMarkers must be a string array`);if(s.requireRootMarker!==void 0&&typeof s.requireRootMarker!="boolean")throw new TypeError(`LSP server ${n}.requireRootMarker must be a boolean`);if(s.requireRootMarker&&s.rootMarkers.length===0)throw new Error(`LSP server ${n}.requireRootMarker requires rootMarkers`);if(typeof s.languages!="object"||s.languages===null||Array.isArray(s.languages))throw new Error(`LSP server ${n}.languages must be an object`);for(let[o,i]of Object.entries(s.languages)){let c=typeof i=="object"&&i!==null&&!Array.isArray(i)?i.extensions:void 0;if(!Array.isArray(c)||c.length===0||c.some(d=>typeof d!="string"))throw new Error(`LSP server ${n} language ${o} requires extensions`);let l=i.fileNames;if(l!==void 0&&(!Array.isArray(l)||l.some(d=>typeof d!="string"||d.length===0||/[/\\]/u.test(d))))throw new Error(`LSP server ${n} language ${o}.fileNames must contain basenames`)}if(!Array.isArray(s.capabilities))throw new TypeError(`LSP server ${n}.capabilities must be an array`)}return t}a(Yo,"parseLspConfig");var Gr={protocol:tr,apiVersion:nr,id:"lsp",setup(t){for(let e of xe)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:ei}),t.addCheck({id:"config",title:"LSP",async run(e){try{let n=await pe.fromPackageDir(e.cwd,zr(e)),r=ti(n,e.files);return r.length===0?[{status:"skip",message:"No language server matches the inspected project files"}]:await Promise.all(r.map(async s=>{let o=`${s.serverId} [${s.layer}] command ${JSON.stringify(s.config.command)}`,i=e.workspace,c=new ve({serverId:s.serverId,rootUri:i?e.cwd:Zo.file(e.cwd).toString(),...i&&{ownerTransport:{start:a(l=>i.start(l.command,l.env,l.signal),"start"),toServerUri:a(l=>i.toNativeUri(l),"toServerUri"),fromServerUri:a(l=>i.fromNativeUri(l),"fromServerUri")}},command:s.config.command,env:ni(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 c.start(e.signal),{status:"pass",message:`${o}: initialized`,detail:s.sourcePath}}catch(l){return{status:"fail",message:`${o}: ${l instanceof Error?l.message:String(l)}`,detail:s.sourcePath}}finally{await c.shutdown()}}))}catch(n){return e.signal?.throwIfAborted(),[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function ei(t){try{let e=await pe.fromPackageDir(t.cwd,zr(t)),n=[],r=new Map;for(let[s,o]of t.detectedLanguages){let i=o.flatMap(c=>e.resolve(c)).find(c=>c.languageId===s);i!==void 0&&(n.push({kind:"lsp",languageId:s,toolId:i.serverId}),await wr(t,i.config)||r.set(i.serverId,{id:`lsp-${i.serverId}-unavailable`,message:`Configured language server ${i.serverId} cannot run ${JSON.stringify(i.config.command)}`}))}return{selections:n,actions:[...r.values()]}}catch(e){return t.signal?.throwIfAborted(),{actions:[{id:"lsp-config-invalid",message:`Language server configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}a(ei,"inspectLspSetup");function zr(t){let e=t.workspace;return{...yr(t),recipeEvidence:e?n=>e.evidence(n,t.signal):void 0}}a(zr,"lspOptions");function ti(t,e){let n=new Map;for(let r of e){let s=t.resolve(r)[0];s!==void 0&&!n.has(s.serverId)&&n.set(s.serverId,s)}return[...n.values()]}a(ti,"applicableServers");function ni(t,e){return Object.fromEntries(Object.entries({...t,...e}).filter(n=>n[1]!==void 0))}a(ni,"definedEnvironment");var Br="typescript.tsserverRequest";function Se(t){return t.supportsCommand(Br)}a(Se,"hasTypeScriptProjectQueries");async function Ht(t,e,n){n?.throwIfAborted();let r=await t.sendRequest("workspace/executeCommand",{command:Br,arguments:[...e,{isAsync:!1,expectsResult:!0}]},n);if(n?.throwIfAborted(),r?.success!==!0)throw new Error(`TypeScript project request failed (${e[0]}).`);return r.body}a(Ht,"requestTsserver");async function Ie(t,e,n){return n?.throwIfAborted(),Se(t)?(await Ht(t,["projectInfo",{file:t.serverDocumentPath(e),needFileNameList:!0}],n))?.fileNames??[]:[]}a(Ie,"loadQueryProject");var ri={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 Te(t){return ri[t]??`SymbolKind(${t})`}a(Te,"symbolKindName");async function Xe(t,e,n){let r=t.documentVersion(e),s=await t.sendRequest("textDocument/documentSymbol",{textDocument:{uri:e}},n);if(t.documentVersion(e)!==r)throw O("The document changed while the server listed its symbols.");return s??[]}a(Xe,"requestDocumentSymbols");var si=new Map([["file",1],["module",2],["class",5],["local class",5],["method",6],["getter",6],["setter",6],["property",7],["JSX attribute",7],["field",8],["constructor",9],["enum",10],["interface",11],["function",12],["local function",12],["const",14],["enum member",14]]);async function oi(t,e,n){let r=await Ht(t,["navto",{searchValue:e}],n),s=a(({line:o,offset:i})=>({line:o-1,character:i-1}),"position");return(r??[]).filter(({kind:o})=>o!=="alias").map(o=>({name:o.name,kind:si.get(o.kind)??13,location:{uri:t.serverPathToDocumentUri(o.file),range:{start:s(o.start),end:s(o.end)}}}))}a(oi,"requestTypeScriptSymbols");async function Vt(t,e,n=100,r){return Se(t)?(await oi(t,e,r)).slice(0,n):(await t.sendRequest("workspace/symbol",{query:e},r)??[]).slice(0,n)}a(Vt,"requestWorkspaceSymbols");import{ResponseError as ii}from"vscode-jsonrpc/node";async function Gt(t,e,n,r,s){try{return await t.sendRequest("textDocument/rename",{textDocument:{uri:e},position:n,newName:r},s)}catch(o){throw o instanceof ii&&/^Files? must be saved first: /u.test(o.message)?O("The language server text changed during rename."):o}}a(Gt,"requestRename");import qe from"node:path";import{diffLines as ui}from"diff";var ai=/^[\p{L}\p{Nl}_$][\p{L}\p{N}\p{Mn}\p{Mc}\p{Pc}$]*$/u,zt=/^fatal_too_many_errors$|too many errors emitted/iu,ci=new Set(["fatal_too_many_errors","module_not_found","module_not_built","module_build_disabled","module_shadowed","module_build_shadowed_submodule","module_cycle","module_prebuilt","module_rebuild_finalized","cannot_open_file","file_modified","sloc_space_too_large","unsupported_bom","module_format_unhandled","pp_file_not_found","pp_through_header_not_found","pp_through_header_not_seen","pp_pragma_hdrstop_not_seen","pp_error_opening_file","fe_error_backend","fe_linking_module","fe_invalid_code_complete_file","fe_remap_missing_to_file","fe_remap_missing_from_file","module_map_not_found","missing_module","modules_embed_file_not_found","module_header_file_not_found","missing_vfs_overlay_file","invalid_vfs_overlay","extract_api_ignores_file_not_found","fe_pch_malformed","fe_pch_malformed_block","fe_ast_file_modified","module_file_conflict","ast_file_not_found","ast_file_out_of_date","ast_file_invalid","module_file_not_module","module_file_missing_top_level_submodule","imported_module_modmap_changed","imported_module_relocated","function_scope_depth_exceeded","bracket_depth_exceeded"]);function li(t,e){return ci.has(t.replace(/^err_/u,""))||zt.test(e)}a(li,"isFatalClangError");function Jr(t){return`${t.line}:${t.character}`}a(Jr,"positionKey");async function De(t,e,n,r){let s=[...new Set(n.flatMap(i=>i.match(/[\p{L}\p{N}_$]+/gu)??[]))],o=[];for(let i of t){let{uri:c,start:l,text:d}=e(i);if(!ai.test(d)||s.includes(d)){o.push(i);continue}let u=await r(c);u!==void 0&&(u.starts.has(Jr(l))||u.stopped&&s.some(h=>di(d,h)))||o.push(i)}return o}a(De,"withoutCorrectedNames");function di(t,e){let n=Math.floor((t.length+2)/3);if(Math.abs(t.length-e.length)>n)return!1;let r=Array.from({length:e.length+1},(s,o)=>o);for(let s=1;s<=t.length;s++){let o=[s];for(let i=1;i<=e.length;i++)o[i]=Math.min((r[i]??0)+1,(o[i-1]??0)+1,(r[i-1]??0)+(t[s-1]===e[i-1]?0:1));r=o}return(r[e.length]??1/0)<=n}a(di,"withinTypoDistance");function Bt(t){let e=[0];for(let r=t.indexOf(`
|
|
4
|
+
`);r!==-1;r=t.indexOf(`
|
|
5
|
+
`,r+1))e.push(r+1);let n=a(r=>{let s=e[r.line];return s===void 0?void 0:s+r.character},"offset");return r=>{let s=n(r.start),o=n(r.end);return s===void 0||o===void 0||o<s?"":t.slice(s,o)}}a(Bt,"rangeTextReader");function le(t,e){return Bt(t)(e)}a(le,"textInRange");function Ae(t,e){let n=new Map,r=a(async s=>{try{let o=await t(s);if(!o)return;let{diagnostics:i}=await we(o.client,o.uri,o.languageId,{...e&&{signal:e}}),c=i.filter(l=>l.severity==="error");return{starts:new Set(c.map(l=>Jr({line:l.line-1,character:l.column-1}))),stopped:c.some(l=>zt.test(l.code)||zt.test(l.message)),fatal:c.filter(l=>li(l.code,l.message)).map(({line:l,message:d})=>({line:l,message:d}))}}catch(o){if(e?.throwIfAborted(),$t(o))throw o;if(o instanceof Error)return;throw o}},"read");return s=>{let o=n.get(s);return o===void 0&&(o=r(s),n.set(s,o)),o}}a(Ae,"diagnosticErrors");function pt(t,e,n,r){let s=t.mapRange(e);return s!==void 0&&le(n,s)===r?s:void 0}a(pt,"followRange");var pi=500,ge=class t{constructor(e){this.runs=e}static{a(this,"LinePositionMap")}static between(e,n){if(e===n)return new t([[0,0,Number.MAX_SAFE_INTEGER]]);let r=ui(e,n,{timeout:pi});if(r===void 0)return new t(void 0);let s=[],o=0,i=0;for(let c of r){let l=c.count;c.added?i+=l:c.removed?o+=l:(s.push([o,i,l]),o+=l,i+=l)}return new t(s)}mapRange(e){let n=this.runs?.find(([s,,o])=>e.start.line>=s&&e.end.line<s+o);if(n===void 0)return;let r=n[1]-n[0];return{start:{line:e.start.line+r,character:e.start.character},end:{line:e.end.line+r,character:e.end.character}}}};import{URI as Ni}from"vscode-uri";import{createHash as wi}from"node:crypto";import{readdir as vi,stat as ns}from"node:fs/promises";import re from"node:path";import{URI as gt}from"vscode-uri";import{AsyncLocalStorage as gi}from"node:async_hooks";var Jt=new gi;async function de(t){if(Jt.getStore()!==void 0)return t();let e=new Map;try{return await Jt.run(e,t)}finally{for(let n of e.values())for(let r of n.values())r()}}a(de,"withLspDocuments");function Xr(t,e){let n=Jt.getStore();if(n===void 0)return;let r=n.get(t)??new Map;n.set(t,r),r.has(e)||r.set(e,t.retainDocument(e))}a(Xr,"retainForCurrentOperation");import{execFile as fi}from"node:child_process";import{existsSync as mi}from"node:fs";import hi from"node:os";import Xt from"node:path";function Qr(t,e){return["--files-with-matches","--fixed-strings","--word-regexp","--no-config","--no-messages","--path-separator=/",...e.flatMap(n=>["--glob",`*${n}`]),"--regexp",t,"--","."]}a(Qr,"filesContainingArguments");function Kr(t){return t.split(`
|
|
6
|
+
`).map(e=>e.replace(/\r$/u,"").replace(/^\.\//u,"")).filter(e=>e.length>0)}a(Kr,"filesContainingOutput");function yi(){let t=process.env.PI_CODING_AGENT_DIR??Xt.join(hi.homedir(),".pi","agent"),e=Xt.join(t,"bin",process.platform==="win32"?"rg.exe":"rg");return mi(e)?e:"rg"}a(yi,"ripgrep");function Qt(t,e,n,r){return new Promise((s,o)=>{fi(yi(),[...Qr(e,n)],{cwd:t,maxBuffer:64*1024*1024,...r&&{signal:r}},(i,c,l)=>{if(i&&i.code!==1){o(r?.aborted?r.reason:new Error(`Listing files that contain ${e} failed: ${l||i.message}`));return}s(Kr(c).map(d=>Xt.join(t,d)))})})}a(Qt,"localFilesContaining");var Kt="node_modules/@vue/typescript-plugin",Yr=`{project}/${Kt}`;function Zr(t){return Array.isArray(t.plugins)&&t.plugins.some(e=>typeof e=="object"&&e!==null&&"location"in e&&e.location===Yr)}a(Zr,"usesWorkspaceVuePlugin");async function es(t,e,n,r){for(let s=n.dirname(t);;s=n.dirname(s)){let o=n.relative(e,s);if(o.split(n.sep)[0]===".."||n.isAbsolute(o)||s===e||s===n.dirname(s))return e;if(await r(n.join(s,Kt,"package.json")))return s}}a(es,"vuePluginDirectory");function ts(t,e,n=e){let r=a(s=>s===Yr?`${n}/${Kt}`:typeof s=="string"?s.replaceAll("{project}",()=>e):Array.isArray(s)?s.map(r):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,i])=>[o,r(i)])):s,"expand");return Object.fromEntries(Object.entries(t).map(([s,o])=>[s,r(o)]))}a(ts,"resolveInitializationOptions");var be=class t{constructor(e,n,r={}){this._registry=e;this._owner=n;this._options=r}static{a(this,"LspManager")}_clients=new Map;_clientStarts=new Map;_pushUnsubscribers=new Map;_pushHandlers=new Set;_pushFingerprints=new Map;_disposed=!1;static _instance=null;static getInstance(){if(!t._instance)throw new Error("[lsp] LspManager not initialized");return t._instance}static getInstanceOrNull(){return t._instance}static init(e,n,r={}){let s=t._instance;return s?._disposed?(s._registry=e,s._owner=n,s._options=r,s._disposed=!1,s):(t._instance=new t(e,n,r),t._instance)}static async resetForTest(){t._instance&&(await t._instance.shutdownAll(),t._instance=null)}requireOwner(){if(!this._owner)throw Object.assign(new Error("No language server workspace owner"),{code:"UNSUPPORTED_SOURCE"});return this._owner}get workspaceRoot(){return this._registry.projectRoot}get clientCount(){return this._clients.size}onPushDiagnostics(e){return this._pushHandlers.add(e),()=>this._pushHandlers.delete(e)}async getOrStart(e,n,r,s){if(s?.throwIfAborted(),this._disposed)return null;let o=n.startsWith("ssh://"),i=o?this.requireOwner():void 0,c=i?await this._registry.resolveOwned(e,P=>i.exists(P,s)):this._registry.resolve(e);if(s?.throwIfAborted(),this._disposed)return null;let l=r==="symbols"?c[0]:c.find(P=>P.config.capabilities.includes(r));if(!l)return null;let d=o?n:gt.file(n).toString(),u=l.config.initializationOptions,p=o?decodeURIComponent(new URL(d).pathname):gt.parse(d).fsPath,h=u&&l.serverId==="vue-typescript-language-server"&&Zr(u)?await es(o?decodeURIComponent(new URL(Q(e,d)).pathname):re.resolve(n,e),p,o?re.posix:re,i?P=>i.exists(Q(P,d),s):async P=>(await ns(P).catch(()=>{}))?.isFile()===!0):p;s?.throwIfAborted();let S=JSON.stringify([l.serverId,d,h]),L=this._clientStarts.get(S);if(L)return L.controller.signal.aborted?(await ae(L.promise.catch(()=>{}),s),this.getOrStart(e,n,r,s)):L.wait(s);let f=this._clients.get(S);if(f?.ready)return f.touch(),f;let w=new ke(P=>this._startClient(S,d,l,f,u&&ts(u,p,h),P));this._clientStarts.set(S,w);let v=a(()=>{this._clientStarts.get(S)===w&&this._clientStarts.delete(S)},"settled");w.promise.then(v,v);let b=await w.wait(s);return b.touch(),b}_stopIdleClient(e,n){if(this._clients.get(e)===n){this._clients.delete(e),this._pushUnsubscribers.get(e)?.(),this._pushUnsubscribers.delete(e);for(let r of this._pushFingerprints.keys())r.startsWith(`${e}:`)&&this._pushFingerprints.delete(r)}n.shutdown().catch(r=>{console.error(`[lsp] ${n.serverId}: idle shutdown failed:`,r)})}async _startClient(e,n,r,s,o,i){let c=s??new ve({serverId:r.serverId,rootUri:n,command:r.config.command,...n.startsWith("ssh://")&&this._owner&&{ownerTransport:this._owner.transport(n)},...!n.startsWith("ssh://")&&this._options.sharedServers&&{sharedServers:this._options.sharedServers},...r.config.env&&{env:r.config.env},...o&&{initOptions:o},...r.config.settings&&{settings:r.config.settings},...r.config.timeoutMs&&{timeoutMs:r.config.timeoutMs},...this._options.idleTimeoutMs!==void 0&&{idleTimeoutMs:this._options.idleTimeoutMs,onIdle:a(()=>this._stopIdleClient(e,c),"onIdle")}});try{s?await s.restart(i):await c.start(i),i.throwIfAborted()}catch(l){try{await c.shutdown()}catch(d){if(d!==l)throw new AggregateError([l,d],"Language server startup and cleanup failed",{cause:d})}throw l}if(this._disposed)throw await c.shutdown(),new Error(`[lsp] ${r.serverId}: manager disposed during startup`);return this._clients.set(e,c),this._subscribeToPushDiagnostics(e,c),c}async isSourceFile(e,n,r){if(r?.throwIfAborted(),n.startsWith("ssh://")){if(this._owner===void 0)throw new Error("No language server workspace owner");return this._owner.isFile(Q(e,n),r)}let s=await ns(re.resolve(n,e));return r?.throwIfAborted(),s.isFile()}async filesContaining(e,n,r,s){s?.throwIfAborted();let o=[...this._registry.knownExtensions].filter(i=>r.has(this._registry.languageId(i)));return o.length===0?[]:e.rootUri.startsWith("ssh://")?this.requireOwner().filesContaining?.(e.rootUri,n,o,s):Qt(gt.parse(e.rootUri).fsPath,n,o,s)}async filesContainingInScope(e,n,r,s){s?.throwIfAborted();let o=e.startsWith("ssh://"),i=o?Q(n,e):re.resolve(e,n);if(await this.isSourceFile(i,e,s))return[i];let c=[...this._registry.knownExtensions];return c.length===0?[]:o?this.requireOwner().filesContaining?.(i,r,c,s):Qt(i,r,c,s)}async prepareWorkspaceSymbols(e,n=e,r=()=>!0,s,o){s?.throwIfAborted();let i=e.startsWith("ssh://"),c=i?this.requireOwner():void 0,l=new Set(this._registry.knownExtensions),d=new Map,u=new Map,p=new Set,h=new Set([".git",".cache","node_modules","dist","build"]),S=a(b=>(i?re.posix.extname(decodeURIComponent(new URL(b).pathname)):re.extname(b)).toLowerCase(),"extensionOf"),L=a(async(b,P)=>{if(!r(b))return;let C=u.get(P);if(C&&d.get(C)?.has(C.serverDocumentPath(b)))return;let D=await this.openFile(b,e,"symbols",s,o);if(D===null)return;let{client:g,uri:_}=D;if(g.hasWorkspaceSymbolCapability&&(p.add(g),Se(g))){let k=d.get(g)??new Set;u.set(P,g),d.set(g,k);for(let m of await Ie(g,_,s))k.add(m);return}l.delete(P)},"seed"),f=a(async b=>(await vi(b,{withFileTypes:!0}).catch(()=>[])).map(C=>({name:C.name,kind:C.isDirectory()?"directory":C.isFile()?"file":"other"})),"localEntries"),w=a(async b=>{if(l.size===0)return;let P=c?await c.entries(b,s):await f(b);for(let C of P){if(s?.throwIfAborted(),l.size===0)return;let D=i?Q(C.name,`${b}/`):re.join(b,C.name);if(C.kind==="directory")h.has(C.name)||await w(D);else if(C.kind==="file"){let g=S(D);l.has(g)&&await L(D,g)}}},"visit"),v=i?Q(n,e):re.resolve(e,n);return await this.isSourceFile(v,e,s)?await L(v,S(v)):await w(v),s?.throwIfAborted(),[...p]}hasServerFor(e){return this._registry.resolve(e).length>0}languageId(e){return this._registry.languageId(e)}syncEditedSource(e,n){for(let r of this._clients.values()){if(!r.ready)continue;let s=r.toUri(e);if(r.documentContent(s)===void 0)continue;let o=this.languageId(re.extname(decodeURIComponent(new URL(s).pathname)));r.syncDocument(s,n,o,!0)}}async readSourceSnapshot(e,n){if(n?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readSnapshot(e,n);if(e.includes("://"))throw Object.assign(new Error("Unsupported rename source"),{code:"UNSUPPORTED_SOURCE"});let r=await En(e,()=>this.readSourceText(e,n),(s,o)=>s===o,this._options.fileGeneration);if(r===void 0)throw O("A rename source changed while reading it. No edits applied.");return{content:r.value,version:wi("sha256").update(r.stamp).update("\0").update(r.value).digest("hex")}}async readSourceBytes(e,n){if(n?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readBytes(e,n);if(e.includes("://"))throw Object.assign(new Error("Unsupported declaration source"),{code:"UNSUPPORTED_SOURCE"});let{readFile:r}=await import("node:fs/promises");return r(e,{signal:n})}async readSourceText(e,n){if(n?.throwIfAborted(),e.startsWith("ssh://"))return this.requireOwner().readText(e,n);if(e.includes("://"))throw Object.assign(new Error("Unsupported declaration source"),{code:"UNSUPPORTED_SOURCE"});let{readFile:r}=await import("node:fs/promises");return r(e,{encoding:"utf8",signal:n})}async openFile(e,n,r="diagnostics",s,o){if(s?.throwIfAborted(),e.startsWith("ssh://")&&!n.startsWith("ssh://")){if(!this._registry.projectRoot.startsWith("ssh://"))throw Object.assign(new Error("Remote document has no workspace owner"),{code:"UNSUPPORTED_SOURCE"});n=this._registry.projectRoot}let i=n.startsWith("ssh://"),c=i?Q(e,n):re.resolve(n,e),l=await this.getOrStart(c,n,r,s);if(!l)return null;let d=i?this.requireOwner():void 0,u=d?await this._registry.resolveOwned(c,h=>d.exists(h,s)):this._registry.resolve(c),p=u.find(h=>h.serverId===l.serverId)?.languageId??u[0]?.languageId??"plaintext";return this.openClientFile(l,c,p,s,o)}async openClientFile(e,n,r,s,o){s?.throwIfAborted();let i=e.toUri(n);Xr(e,i);let c=i.startsWith("ssh://")?this.requireOwner():void 0;if(c){let l=o?await o(n):await c.readText(i,s);return s?.throwIfAborted(),e.syncDocument(i,l,r),await e.waitUntilLoaded(s),{client:e,uri:i,languageId:r}}try{let{readFile:l}=await import("node:fs/promises"),d=o?await o(n):await l(n,{encoding:"utf8",signal:s});s?.throwIfAborted(),e.syncDocument(i,d,r)}catch(l){if(s?.throwIfAborted(),!(l instanceof Error&&"code"in l&&l.code==="ENOENT"))throw l}return await e.waitUntilLoaded(s),{client:e,uri:i,languageId:r}}_subscribeToPushDiagnostics(e,n){if(this._pushUnsubscribers.has(e))return;let r=n.onNotification("textDocument/publishDiagnostics",s=>{let o=Si(s);if(!o||n.hasActiveDiagnosticRequest(o.uri))return;let i=n.documentVersion(o.uri);if(o.version!==void 0&&i!==void 0&&o.version<i)return;let c=`${e}:${o.uri}`,l=o.diagnostics.map(Ut),d=JSON.stringify([o.version,i,l]);if(this._pushFingerprints.get(c)===d)return;this._pushFingerprints.set(c,d);let u={cwd:n.rootUri.startsWith("ssh://")?n.rootUri:gt.parse(n.rootUri).fsPath,serverId:n.serverId,uri:o.uri,diagnostics:l,...o.version!==void 0&&{version:o.version}};for(let p of this._pushHandlers)p(u)});this._pushUnsubscribers.set(e,r)}async shutdownAll(){this._disposed=!0;let e=[...this._clientStarts.values()];for(let i of e)i.controller.abort(new Error("Language server manager stopped"));let n=await Promise.allSettled(e.map(i=>i.promise)),r=[];for(let[i,c]of n.entries())c.status==="rejected"&&c.reason!==e[i]?.controller.signal.reason&&r.push(c.reason);let s=[...this._clients.values()],o=await Promise.allSettled(s.map(i=>i.shutdown()));for(let i of this._pushUnsubscribers.values())i();this._pushUnsubscribers.clear(),this._clientStarts.clear(),this._pushFingerprints.clear(),this._pushHandlers.clear(),this._clients.clear();for(let i of o)i.status==="rejected"&&r.push(i.reason);if(r.length>0)throw new AggregateError(r,"Language server cleanup failed")}dispose(){return this.shutdownAll()}};function Si(t){if(t===null||typeof t!="object")return;let e=t;if(!(typeof e.uri!="string"||!Array.isArray(e.diagnostics)))return{uri:e.uri,diagnostics:e.diagnostics,...typeof e.version=="number"&&{version:e.version}}}a(Si,"parsePushNotification");async function Zt(t,e){let n=new AbortController,r=t?AbortSignal.any([t,n.signal]):n.signal,s=setTimeout(()=>{n.abort(Object.assign(new Error(`LSP search timed out after ${Pt/1e3} s. Retry or search the text.`),{code:"LSP_NAVIGATION_TIMEOUT"}))},Pt);try{r.throwIfAborted();let o=await e(r);return r.throwIfAborted(),o}catch(o){throw r.throwIfAborted(),o}finally{clearTimeout(s)}}a(Zt,"withNavigationDeadline");async function Yt(t){try{return await t}catch(e){if(Ee(e))return;throw e}}a(Yt,"unlessUnsupported");async function Qe(t,e,n,r){return await Ie(t,e,r),await t.sendRequest("textDocument/references",{textDocument:{uri:e},position:n,context:{includeDeclaration:!0}},r)??[]}a(Qe,"requestReferences");function ft(t,e){if(e.length===0)throw O(`The language server returned no locations for "${t}", including its known declaration. Retry or search the text.`)}a(ft,"requireReferenceReply");async function en(t,e,n,r){let s=await Yt(t.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:e},position:n},r));if(s===void 0)return{items:[],incoming:[],outgoing:[],unsupported:["incoming","outgoing"]};let o=s?.[0];if(!o)return{items:[],incoming:[],outgoing:[],unsupported:[]};let[i,c]=await Promise.all([Yt(t.sendRequest("callHierarchy/incomingCalls",{item:o},r)),Yt(t.sendRequest("callHierarchy/outgoingCalls",{item:o},r))]);return{items:s,incoming:i??[],outgoing:c??[],unsupported:[...i===void 0?["incoming"]:[],...c===void 0?["outgoing"]:[]]}}a(en,"requestCallHierarchy");function Me(t){if(/\r(?!\n)/u.test(t))throw Object.assign(new Error("This file holds a carriage return that is not followed by a line feed. Language servers disagree about the line it ends, so its LSP positions cannot select exact text. Use text search for this file."),{code:"LSP_AMBIGUOUS_LINE_BREAK"})}a(Me,"assertLspLines");function Ke(t,e,n){Me(e.content);let{start:r,end:s}=n;for(let l of[r,s]){let d=e.lines[l.line];if(!Number.isInteger(l.line)||!Number.isInteger(l.character)||d===void 0||l.character<0||l.character>d.content.length-(d.content.endsWith("\r")?1:0))throw O("LSP range does not match its source snapshot.")}let o=a(l=>e.lines.slice(0,l).reduce((d,u)=>d+u.content.length+u.lineEnding.length,0),"offset"),i=o(r.line)+r.character,c=o(s.line)+s.character;if(c<i)throw new Error("LSP returned a reversed source range.");return{source:t,lineNumber:r.line+1,endLineNumber:s.line+1,startColumn:r.character,endColumn:s.character,matchedText:e.content.slice(i,c),lineText:q(e.lines[r.line]).content}}a(Ke,"lspRangeMatch");var me=new Set(["c","cpp","objective-c","objective-cpp"]),bi=32;function Li(t){return t.match(/[\p{L}\p{N}_$]+/gu)?.at(-1)}a(Li,"searchedWord");function Ne(t){let{manager:e,cwd:n,errorsOf:r,signal:s}=t,o=new Map,i=0,c=a(async(l,d)=>{let u=await e.filesContaining(l,d,me,s);if(u===void 0)return{client:l,opened:[],unopened:[],unlisted:!0};let p=[],h=[];for(let S of[...new Set(u)].sort()){if(s?.throwIfAborted(),t.accepts!==void 0&&!t.accepts(S))continue;let L=l.toUri(S);if(l.documentContent(L)===void 0){if(i>=bi){h.push(S);continue}if(i+=1,(await e.openFile(S,n,"symbols",s))?.client!==l){h.push(S);continue}}p.push(L)}return await Promise.all(p.map(S=>r(S))),{client:l,opened:p,unopened:h,unlisted:!1}},"reach");return async(l,d,u)=>{if(!me.has(d))return;let p=Li(u);if(p===void 0)return{client:l,opened:[],unopened:[],unlisted:!1};let h=JSON.stringify([l.serverId,l.rootUri,p]),S=o.get(h);return S===void 0&&(S=c(l,p),o.set(h,S)),S}}a(Ne,"createClangReach");async function $e(t,e,n,r){let s=[...new Set([...e,...t.opened])].filter(i=>t.client.documentContent(i)!==void 0),o=await Promise.all(s.map(i=>n(i)));return{fatal:s.flatMap((i,c)=>(o[c]?.fatal??[]).map(l=>({source:r(i),...l}))),unopened:t.unopened,missingDiagnostics:s.flatMap((i,c)=>o[c]===void 0?[r(i)]:[]),unlisted:t.unlisted}}a($e,"clangCoverage");function Ue(t){return t===void 0||t.fatal.length===0&&t.unopened.length===0&&t.missingDiagnostics.length===0&&!t.unlisted}a(Ue,"coverageComplete");function je(t){let e=t.filter(r=>r!==void 0);if(e.length===0)return;let n=new Map;for(let r of e.flatMap(s=>s.fatal))n.set(JSON.stringify([r.source,r.line,r.message]),r);return{fatal:[...n.values()],unopened:[...new Set(e.flatMap(r=>r.unopened))].sort(),missingDiagnostics:[...new Set(e.flatMap(r=>r.missingDiagnostics))].sort(),unlisted:e.some(r=>r.unlisted)}}a(je,"mergeCoverage");function We(t,e){if(t===void 0)return[];let n=[];if(t.fatal.length>0){let r=t.fatal.map(o=>`${e(o.source)}:${o.line} ${o.message}`).join("; "),s=e(q(t.fatal[0]).source);n.push(`Incomplete: clang stopped with a fatal error (${r}), so references after it can be missing. Fix it (diagnostics with path ${s}) and search again, or search the text.`)}return t.unopened.length>0&&n.push(`Incomplete: the name scan found these files, but the server did not check them: ${Oe(t.unopened,e)}. Search those files for references.`),t.missingDiagnostics.length>0&&n.push(`Incomplete: the server did not provide diagnostics for ${Oe(t.missingDiagnostics,e)}. The reference list may be incomplete.`),t.unlisted&&n.push("Incomplete: files that contain the name could not be listed, so references from files the server has not opened can be missing. Search the text."),n}a(We,"coverageNotes");function Oe(t,e){let r=t.slice(0,8).map(e).join(", ");return t.length>8?`${r} (and ${t.length-8} more)`:r}a(Oe,"displayFiles");function rs(t,e){if(Ue(t)||t===void 0)return;let n=[];if(t.fatal.length>0){let r=t.fatal.map(s=>`${e(s.source)}:${s.line} ${s.message}`).join("; ");n.push(`clang stopped with a fatal error (${r}), so places after it can be missing from the rename. Fix it (diagnostics with path ${e(q(t.fatal[0]).source)}) and rename again.`)}return t.unopened.length>0&&n.push(`The server did not check these files: ${Oe(t.unopened,e)}.`),t.missingDiagnostics.length>0&&n.push(`The server did not provide diagnostics for ${Oe(t.missingDiagnostics,e)}.`),t.unlisted&&n.push("Files that contain the name could not be listed, so the rename can miss files the server has not opened."),`LSP rename refused; no edits applied. ${n.join(" ")} Or replace the text instead.`}a(rs,"renameRefusal");function Le(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}a(Le,"isMissingSource");function Fe(t,e){return t.length===0?[]:[`Skipped places in deleted files that the server still indexes: ${Oe(t,e)}.`]}a(Fe,"missingSourcesNotes");var ss=64,_i=8;function os(t){return/^[\p{L}_$][\p{L}\p{N}_$]*$/u.test(t)?t:void 0}a(os,"exactIdentifier");var Ri={fatal:[],missingDiagnostics:[]};async function is(t){let{manager:e,cwd:n,word:r,signal:s}=t,o=await Promise.all(t.roots.map(f=>e.filesContainingInScope(n,f,r,s))),i=o.some(f=>f===void 0),c=[...new Set(o.flatMap(f=>f??[]))].filter(f=>t.accepts(f)).sort(),l=c.slice(0,ss),d=new Map,u=[],p=0,h=a(async()=>{for(let f=p++;f<l.length;f=p++){s?.throwIfAborted();let w=l[f];try{u[f]=await S(w)}catch(v){if(!Le(v))throw v}}},"worker"),S=a(async f=>{let w=await e.openFile(f,n,"symbols",s,t.readText);if(w===null||!w.client.hasWorkspaceSymbolCapability)return;let v=await t.readText(f),b=await t.outlineOf(w.client,w.uri).catch(g=>{if(!Ee(g))throw g});if(b===void 0)return;let P=[],C=Bt(v),D=a(g=>{for(let _ of g)C(_.selectionRange)===r&&P.push({name:_.name,kind:_.kind,location:{uri:w.uri,range:_.selectionRange}}),D(_.children)},"visit");return D(b),[w.client,P]},"declarationsIn");await Promise.all(Array.from({length:Math.min(_i,l.length)},()=>h()));for(let f of u)f!==void 0&&d.set(f[0],[...d.get(f[0])??[],...f[1]]);let L=c.slice(ss);return{declarations:d,...(L.length>0||i)&&{coverage:{...Ri,unopened:L,unlisted:i}}}}a(is,"scanDeclarations");var tn="(<[{",ls=")>]}";function Ze(t,e=[]){let n=t.map(s=>({symbol:s,selectionRange:s.selectionRange??s.range})).filter(s=>s.selectionRange!==void 0),r=new Map;for(let{symbol:s,selectionRange:o}of n){let i=r.get(s.name)??new Set;i.add(ps(s,o)),r.set(s.name,i)}return n.map(({symbol:s,selectionRange:o})=>{let c=(r.get(s.name)?.size??0)>1?ki(s.name,s.detail)??s.name:s.name,l=[...e,c];return{name:s.name,kind:s.kind,...s.detail!==void 0&&s.detail!==""&&{detail:s.detail},range:s.range??o,selectionRange:o,selector:l,children:Ze(s.children??[],l)}}).sort(Di)}a(Ze,"normalizeDocumentSymbols");function on(t,e,n){if(e.length===0)throw new TypeError("A symbol selector must contain at least one segment.");let r=t,s=[];for(let[o,i]of e.entries()){if(s=e.length===1?xi(t,i):Ei(r,i),s.length===0)throw Oi(t,e,n);let c=mt(s);if(c.length>1)throw Mi(c,e,o,n);r=s.flatMap(l=>l.children)}return s}a(on,"resolveSymbolDeclaration");function Ci(t,e){let[n]=t;if(n!==void 0&&t.length===1)return n;let r=t.filter(s=>le(e,s.range).trimEnd().endsWith("}"));return r.length===1?r[0]:void 0}a(Ci,"bodyEntry");function et(t,e){return(e===void 0?void 0:Ci(t,e))??q(t[0])}a(et,"preferredDeclaration");function Pi(t,e){let n=a(r=>r.flatMap(s=>[...s.name===e?[s]:[],...n(s.children)]),"named");return mt(n(t))}a(Pi,"declarationsNamed");function ds(t,e,n,r){let s=nn(e),o=s.split(/[.:]+/u).at(-1);if(r===e)return[cs(t,n)];if(r!==void 0&&r===o){let c=cs(t,n);if(c===void 0)return[void 0];if(c[0]!==void 0&&as(c[0],s))return[c]}let i=a(c=>c.flatMap(l=>[l,...i(l.children)]),"all");return mt(i(t).filter(c=>as(c,s)))}a(ds,"declarationsForWorkspaceSymbol");function nn(t){return t.replace(/\[[^\]]*\]/gu,"").replace(/[()*\s]/gu,"")}a(nn,"qualifiedName");function as(t,e){return[nn(t.name),t.selector.map(nn).join(".")].some(n=>e===n||n.includes(".")&&e.endsWith(`.${n}`))}a(as,"isQualifiedAs");function cs(t,e){let n=a(o=>o.flatMap(i=>[i,...n(i.children)]),"all"),r=n(t),s=r.find(o=>Ai(o.selectionRange,e));if(s!==void 0)return mt(r.filter(o=>o.name===s.name)).find(o=>o.includes(s))}a(cs,"declarationAt");function xi(t,e){let n=[],r=[],s=[],o=a(i=>{for(let c of i){let l=us(c,e);l==="named"?n.push(c):l==="exact"?r.push(c):l==="loose"&&s.push(c),o(c.children)}},"visit");return o(t),n.length>0?n:r.length>0?r:s}a(xi,"matchAtAnyDepth");function Ei(t,e){let n=t.map(r=>({symbol:r,grade:us(r,e)}));for(let r of["named","exact","loose"]){let s=n.filter(o=>o.grade===r).map(o=>o.symbol);if(s.length>0)return s}return[]}a(Ei,"matchSegment");function us(t,e){if(t.name===e)return"named";if(!e.startsWith(t.name))return;let n=e.slice(t.name.length).trimStart();if(!n.startsWith("("))return;let r=fs(n),s=t.detail===void 0?void 0:gs(t.detail);if(!(r===void 0||s===void 0)&&r.parameters.length===s.parameters.length){if(r.qualifiers===s.qualifiers&&r.parameters.every((o,i)=>o===s.parameters[i]))return"exact";if(!(r.qualifiers!==""&&r.qualifiers!==s.qualifiers))return r.parameters.every((o,i)=>{let c=s.parameters[i];return o===c||Ti(o)===c})?"loose":void 0}}a(us,"segmentGrade");function mt(t){let e=new Map;for(let n of t){let r=JSON.stringify([n.selector.slice(0,-1),n.name,ps(n,n.selectionRange)]),s=e.get(r)??[];s.push(n),e.set(r,s)}return[...e.values()]}a(mt,"groupDeclarations");function ps(t,e){let n=t.detail?.trim().replace(/\s+/gu," ")??"";return JSON.stringify(n===""?[t.kind,e.start.line,e.start.character]:[t.kind,n])}a(ps,"declarationKey");function ki(t,e){let n=e===void 0?void 0:gs(e);if(n===void 0)return;let r=n.qualifiers===""?"":` ${n.qualifiers}`;return`${t}(${n.parameters.join(", ")})${r}`}a(ki,"signatureSegment");function gs(t){let e;for(let n=0;n<t.length;n+=1){if(t[n]!=="("){let s=rn(t,n);s!==void 0&&(n=s);continue}e=n;let r=rn(t,n);if(r===void 0)return;n=r}return e===void 0?void 0:fs(t.slice(e))}a(gs,"detailSignature");function fs(t){let e=rn(t,0);if(e===void 0)return;let n=t.slice(1,e),r=Ii(n).map(sn);return{parameters:r.length===1&&(r[0]===""||r[0]==="void")||r.length===0?[]:r,qualifiers:sn(t.slice(e+1))}}a(fs,"parseSignature");function rn(t,e){if(!tn.includes(t[e]??""))return;let n=0;for(let r=e;r<t.length;r+=1){let s=t[r]??"";if(tn.includes(s))n+=1;else if(ls.includes(s)&&(n-=1,n===0))return r}}a(rn,"matchingClose");function Ii(t){let e=[],n=0,r=0;for(let s=0;s<t.length;s+=1){let o=t[s]??"";tn.includes(o)?n+=1:ls.includes(o)?n-=1:o===","&&n===0&&(e.push(t.slice(r,s)),r=s+1)}return e.push(t.slice(r)),e}a(Ii,"splitTopLevel");function sn(t){return t.trim().replace(/\s+/gu," ").replace(/\s*([&*,<>()[\]:])\s*/gu,"$1")}a(sn,"normalizeType");function Ti(t){let e=t.replace(/=.*$/u,"").trim(),n=/^(.*?[\s&*>\]])[\p{L}_][\p{L}\p{N}_]*$/u.exec(e);return n?.[1]===void 0?e:sn(n[1])}a(Ti,"withoutParameterName");function Di(t,e){return t.range.start.line-e.range.start.line||t.range.start.character-e.range.start.character||t.name.localeCompare(e.name)}a(Di,"compareSymbols");function Ai(t,e){return t.start.line===e.start.line&&t.start.character===e.start.character&&t.end.line===e.end.line&&t.end.character===e.end.character}a(Ai,"sameRange");function ms(t,e){let[n]=t;if(n===void 0)return e;let r=t.map(s=>s.selectionRange.start.line+1).join(", ");return`${e}#${ne(n.selector)} (line ${r})`}a(ms,"describeDeclaration");function Mi(t,e,n,r){let s=t.slice(0,10).map(d=>ms(d,r)),o=t.length>s.length?`, ${t.length-s.length} more`:"",i=new Set(t.map(d=>ne(d[0]?.selector??[]))),c=e.length>1?` at "${e[n]??""}"`:"",l=i.size===t.length?"Use one of these selectors.":"The language server reports no signatures that tell them apart.";return new Error(`Symbol selector "${ne(e)}"${c} matches ${t.length} declarations in ${r}: ${s.join(", ")}${o}. ${l}`)}a(Mi,"ambiguousSelector");var Ye=class extends Error{static{a(this,"SymbolNotFoundError")}};function Oi(t,e,n){let r=e.at(-1)??"",s=/^[^(]+/u.exec(r)?.[0].trim()??r,i=(s===r?[]:Pi(t,s)).slice(0,10).map(c=>ms(c,n));return new Ye(`Symbol "${ne(e)}" was not found in ${n}.${i.length>0?` Declarations named "${s}": ${i.join(", ")}.`:""}`)}a(Oi,"symbolNotFound");function se(t,e,n){let r=e.startsWith("ssh://"),s=r?qe.posix:qe,o=a(d=>r?decodeURIComponent(new URL(Q(d,e)).pathname):d,"native"),i=a(d=>{let u=r?o(d??e):qe.resolve(e,d??"."),p=s.relative(u,o(t));return!(p===".."||p.startsWith(`..${s.sep}`)||s.isAbsolute(p))},"inside");if(!(n.paths??[n.path]).some(i))return!1;let c=s.relative(o(e),o(t)).split(s.sep).join("/"),l=a(d=>Zn(d).some(u=>s.matchesGlob(u.includes("/")?c:s.basename(o(t)),u)),"matches");return(n.include===void 0||l(n.include))&&(n.exclude===void 0||!l(n.exclude))}a(se,"withinScope");function he(t,e){let n=Q(t,e);if(n.startsWith("ssh://"))return n;let r=Ni.parse(n);if(r.scheme!=="file")throw new Error("Unsupported LSP source location.");return qe.resolve(r.fsPath)}a(he,"sourceOf");async function an(t,e,n,r,s={},o=be.getInstance()){return ce(()=>$i(t,e,n,r,s,o),r)}a(an,"searchSymbols");async function $i(t,e,n,r,s,o){r?.throwIfAborted();let i=s.resultScope;if(i?.targets.length===0)return{hits:[],contents:new Map,complete:i.complete};if(i===void 0&&s.path!==void 0&&!se(e.startsWith("ssh://")?Q(s.path,e):qe.resolve(e,s.path),e,s)&&await o.isSourceFile(s.path,e,r))return{hits:[],contents:new Map,complete:!0};let c=new Map,l=new Map,d=a(y=>{let R=l.get(y);return R===void 0&&(R=o.readSourceSnapshot(y,r).then(({content:T,version:N})=>{let V={document:Ve(y,T),version:N};return c.set(y,V),V}),l.set(y,R)),R},"snapshotOf"),u=a(async y=>(await d(he(y,e))).document.content,"readText"),p=new Map,h=a((y,R)=>{let T=p.get(y)??new Map;p.set(y,T);let N=T.get(R);return N===void 0&&(N=Xe(y,R,r).then(Ze),T.set(R,N)),N},"outlineOf"),S=i?.targets.map(y=>y.source)??s.paths??[s.path??e],L=new Set((await Promise.all(S.map(y=>o.prepareWorkspaceSymbols(e,y,R=>se(R,e,s),r,u)))).flat());if(L.size===0)throw new Error("LSP symbol search is unavailable: no provider supports workspace/symbol in this scope.");let f=os(t),w=f===void 0?void 0:await is({manager:o,cwd:e,roots:S,word:f,accepts:a(y=>se(y,e,s),"accepts"),readText:u,outlineOf:h,...r&&{signal:r}});for(let y of w?.declarations.keys()??[])L.add(y);let v=new Map,b=new Map,P=a((y,R,T,N)=>{let V=b.get(y);return(V===void 0||V.served!==R)&&(V={served:R},b.set(y,V)),V[N]??=N==="toSnapshot"?ge.between(R,T):ge.between(T,R)},"lineDiff"),C=a(async(y,R)=>{r?.throwIfAborted();let T=he(y.uri,e),{document:N}=await d(T);i!==void 0&&!v.has(T)&&v.set(T,Tn({targets:i.targets.filter(ie=>ie.source===T),complete:i.complete},new Map([[T,N.content]])));let V=R?.documentContent(y.uri),G=V===void 0||V===N.content?y.range:P(T,V,N.content,"toSnapshot").mapRange(y.range);if(G===void 0)throw O("LSP range does not match its source snapshot.");return Ke(T,N,G)},"toMatch"),D=a((y,R,T)=>{let N={line:T.lineNumber-1,character:T.startColumn},V=y.documentContent(R),G=c.get(T.source)?.document.content;if(V===void 0||G===void 0||V===G)return N;let ie={start:N,end:{line:(T.endLineNumber??T.lineNumber)-1,character:T.endColumn}},nt=pt(P(T.source,V,G,"toServed"),ie,V,T.matchedText);if(nt===void 0)throw O(`The line of declaration "${T.matchedText}" changed before the server was asked for its references.`);return nt.start},"servedPosition"),g=a(y=>se(y.source,e,s)&&(i===void 0||Yn(q(v.get(y.source)),y)),"included"),_=[],k=new Set,m=Ae(y=>o.openFile(he(y,e),e,"symbols",r,u),r),x=a(y=>s.navigation==="references"?se(y,e,{}):se(y,e,s)&&(i===void 0||i.targets.some(R=>R.source===y)),"listable"),I=Ne({manager:o,cwd:e,errorsOf:m,accepts:x,...r&&{signal:r}}),A=new Set,E=new Map,$=a(async y=>{try{return await d(y),!0}catch(R){if(!Le(R))throw R;return x(y)&&A.add(y),!1}},"exists"),j=[w?.coverage],U=[],Y=new Map;for(let y of L){let R=Se(y);r?.throwIfAborted();let T=await Vt(y,t,Number.MAX_SAFE_INTEGER,r),N=y.workspaceSymbolCandidateLimit;N!==void 0&&T.length>=N&&U.push({server:y.commandName,limit:N});let V=[...T,...w?.declarations.get(y)??[]];for(let G of V){r?.throwIfAborted();let ie=he(G.location.uri,e);if(!se(ie,e,{})||!await $(ie))continue;let nt=await C(G.location,y).catch(_e=>{if(_e?.code!=="SOURCE_CHANGED")throw _e}),js=qe.extname(decodeURIComponent(new URL(G.location.uri).pathname)),W=R?await o.openClientFile(y,ie,o.languageId(js),r,u):await o.openFile(ie,e,"symbols",r,u);if(W===null)throw new Error("LSP references are unavailable for a discovered declaration.");let Ws=await h(W.client,W.uri),vn=ds(Ws,G.name,G.location.range,nt?.matchedText);if(vn.length===0){E.set(JSON.stringify([ie,G.name]),{name:G.name,source:ie});continue}for(let _e of vn){r?.throwIfAborted();let Re=_e===void 0?void 0:et(_e,W.client.documentContent(W.uri)??await o.readSourceText(he(W.uri,e),r)),Sn=Re===void 0?G.location:{uri:W.uri,range:Re.selectionRange},bn=JSON.stringify([W.uri,(_e?.[0]?.selectionRange??G.location.range).start]),Lt=Y.get(W.client)??new Set;if(Y.set(W.client,Lt),Lt.has(bn))continue;Lt.add(bn);let K=await C(Sn,W.client),Ce={id:JSON.stringify([R?"typescript":y.serverId,K.source,Sn.range]),name:Re?.name??G.name,kind:String(Re?.kind??G.kind),...Re!==void 0&&{selector:Re.selector},source:K.source,range:{startLine:K.lineNumber,startColumn:K.startColumn,endLine:K.endLineNumber??K.lineNumber,endColumn:K.endColumn}},_t=await I(W.client,W.languageId,Ce.name),Fs=W.client.documentContent(W.uri),qs=D(W.client,W.uri,K),Ln=await Qe(W.client,W.uri,qs,r);if(W.client.documentContent(W.uri)!==Fs)throw O("The server's text changed while it answered a references request.");r?.throwIfAborted(),_t!==void 0&&ft(Ce.name,Ln);let Rt=[{...K,role:"definition",symbol:Ce}],Ct=[];for(let F of Ln){if(!se(he(F.uri,e),e,{})||!await $(he(F.uri,e)))continue;let te=await C(F,W.client);te.source===K.source&&te.lineNumber===K.lineNumber&&te.startColumn===K.startColumn&&te.endLineNumber===K.endLineNumber&&te.endColumn===K.endColumn||Ct.push({location:F,reference:te})}let Hs=await De(Ct,({location:F,reference:te})=>({uri:F.uri,start:F.range.start,text:te.matchedText}),[Ce.name,K.matchedText],m);for(let{reference:F}of Hs)Rt.push({...F,role:"reference",symbol:Ce});if(Rt.some(g)){_t!==void 0&&j.push(await $e(_t,[W.uri,...Ct.map(({location:F})=>F.uri)],m,F=>he(F,e)));for(let F of Rt){if(s.navigation!=="references"&&!g(F)||s.navigation==="references"&&!se(F.source,e,{}))continue;let te=JSON.stringify([Ce.id,F.source,F.lineNumber,F.startColumn,F.endLineNumber,F.endColumn]);k.has(te)||(k.add(te),_.push(F))}}}}}r?.throwIfAborted();let oe=new Map,ee=new Map;for(let y of new Set(_.map(R=>R.source))){let R=q(c.get(y)),T=await o.readSourceSnapshot(y,r).catch(N=>{if(!Le(N))throw N});if(T===void 0){x(y)&&A.add(y);continue}ee.set(y,T.content),T.version!==R.version&&T.content!==R.document.content&&oe.set(y,ge.between(R.document.content,T.content))}let H=_.filter(y=>ee.has(y.source));for(let[y,R]of H.entries()){let T=oe.get(R.source);if(T===void 0)continue;let N=T.mapRange({start:{line:R.lineNumber-1,character:R.startColumn},end:{line:(R.endLineNumber??R.lineNumber)-1,character:R.endColumn}});if(N===void 0)throw O("LSP source changed during search.");H[y]={...R,lineNumber:N.start.line+1,endLineNumber:N.end.line+1}}H.sort((y,R)=>y.source.localeCompare(R.source)||y.lineNumber-R.lineNumber||y.startColumn-R.startColumn||y.endColumn-R.endColumn||y.symbol.id.localeCompare(R.symbol.id));let B=H.slice(0,n),ue=je(j);return{hits:B,contents:new Map(B.map(y=>[y.source,q(ee.get(y.source))])),complete:(i?.complete??!0)&&H.length<=n&&Ue(ue)&&E.size===0&&U.length===0,...U.length>0&&{candidateLimits:U},...E.size>0&&{skipped:[...E.values()]},...ue!==void 0&&!Ue(ue)&&{coverage:ue},...A.size>0&&{missing:[...A].sort()}}}a($i,"searchSymbolsOnce");import cn from"node:path";import{fileURLToPath as hs}from"node:url";var ln=10,dn=5,He=10,Ui=new Set([6,9,12,25]);async function ys(t,e,n,r,s){return ce(()=>ji(t,e,n,r,s),s,Ls)}a(ys,"resolveLspDeclaration");async function ji(t,e,n,r,s){ye(s);let o=await vt(t,e,r,s),i=_s(o,n),c=await t.readSourceText(o.filePath,s);ye(s);let l=o.servedText??c,d=et(i,l),u=l===c?void 0:ge.between(l,c),p=u===void 0?d.range:u.mapRange(d.range),h=u===void 0?d.selectionRange:u.mapRange(d.selectionRange);if(p===void 0||h===void 0)throw O("The symbol source changed during resolution. Read it again before editing.");return{source:o.filePath,range:p,selectionRange:h,content:c}}a(ji,"resolveLspDeclarationOnce");async function ws(t,e,n,r,s,o){ye(o);let i=await vt(t,e,r,o,s);if(i.servedText!==s)throw O("The language server changed documents during rename resolution.");return ye(o),{client:i.client,uri:i.uri,entries:on(i.symbols,n,i.displayPath),content:s}}a(ws,"resolveLspRenameTarget");function vs(t,e,n,r){let s=Ae(o=>t.openFile(tt(o),e,"symbols",r),r);return{errorsOf:s,texts:new pn(t,r),...n&&{reachOf:Ne({manager:t,cwd:e,errorsOf:s,accepts:a(o=>se(o,e,{}),"accepts"),...r&&{signal:r}})}}}a(vs,"relationContext");function tt(t){return t.startsWith("ssh://")?t:hs(t)}a(tt,"fileOf");async function fn(t,e,n,r,s){return ce(async()=>{ye(s);let o=await vt(t,e,r,s),i=_s(o,n),c=et(i,o.servedText),l=vs(t,r,!0,s),d=await Rs(o,c,l,s),u=new wt(r),p=await qi(o,c,d,u);return Ss(p,[d],l.texts)},s,Ls)}a(fn,"readLspSymbolGraph");async function Ss(t,e,n){let r=new Map,s=a(async i=>{let c=new Map;for(let{uri:l,range:d}of i){let u=tt(l);r.set(u,await n.snapshot(l)),c.set(JSON.stringify([u,d]),{source:u,range:d})}return[...c.values()].sort((l,d)=>l.source.localeCompare(d.source)||l.range.start.line-d.range.start.line||l.range.start.character-d.range.start.character)},"locate"),o=a(i=>i.map(c=>({uri:c.uri,range:c.declaration})),"declarations");return{text:t,references:await s(e.flatMap(i=>i.references)),incoming:await s(e.flatMap(i=>o(i.incoming))),outgoing:await s(e.flatMap(i=>o(i.outgoing))),complete:e.every(i=>Ue(i.coverage)&&i.unsupported.length===0&&!i.callItemMissing&&!i.referenceReplyMissing),contents:r,missing:bs(e)}}a(Ss,"graphOf");function bs(t){return[...new Set(t.flatMap(e=>e.missing))].sort()}a(bs,"missingOf");var pn=class{static{a(this,"ReportedTexts")}#e;#t;#r=new Map;#n=new Map;constructor(e,n){this.#e=e,this.#t=n}snapshot(e){let n=this.#r.get(e);return n===void 0&&(n=this.#e.readSourceText(tt(e),this.#t),this.#r.set(e,n)),n}between(e,n){let r=this.#n.get(e);r===void 0&&(r=new Map,this.#n.set(e,r));let s=r.get(n);return s===void 0&&(s=ge.between(e,n),r.set(n,s)),s}async report(e,n,r){if(n===void 0)return r;let s=await this.snapshot(e);if(n===s)return r;let o=this.between(n,s).mapRange(r);if(o===void 0)throw O("A line the language server reported changed in the file. Read it again.");return o}};async function mn(t,e,n,r){return ce(async()=>{ye(r);let s=await vt(t,e,n,r),o=new wt(n),i=[`## file graph: ${s.displayPath}`,`Top-level declarations: ${s.symbols.length}`],c=vs(t,n,!1,r),l=[];for(let d of s.symbols){ye(r);let u=await Rs(s,d,c,r);l.push(u),i.push("",...await zi(s,d,u,o))}return i.splice(2,0,...We(je(l.map(d=>d.coverage)),d=>o.display(d)),...Fe(bs(l),d=>o.display(d))),Ss(i.join(`
|
|
7
|
+
`),l,c.texts)},r)}a(mn,"readLspFileGraph");var ht=class extends Error{static{a(this,"LspSelectorUnconfirmedError")}code="LSP_SELECTOR_UNCONFIRMED"};function Ls(t){return t instanceof ht}a(Ls,"isUnconfirmedSelector");function _s(t,e){try{return on(t.symbols,e,t.displayPath)}catch(n){if(!(n instanceof Ye)||!me.has(t.languageId))throw n;let r=e.at(-1)??"",s=/^~?([\p{ID_Start}_$][\p{ID_Continue}$]*)(?=\s*\(|$)/u.exec(r)?.[1];throw s===void 0||t.servedText===void 0||!new RegExp(`(?<![\\p{ID_Continue}$])${s.replaceAll("$","\\$")}(?![\\p{ID_Continue}$])`,"u").test(t.servedText)?n:new ht(`The language server could not confirm "${ne(e)}" in ${t.displayPath}. Check the current outline before trying again.`,{cause:n})}}a(_s,"resolveNavigationDeclaration");async function vt(t,e,n,r,s){let o=Ge(e,n),i=await t.openFile(o,n,"symbols",r,s===void 0?void 0:()=>Promise.resolve(s));if(!i)throw new Error(`No LSP server with symbol support is configured for ${gn(o,n)}.`);let c=i.client.documentContent(i.uri),l=await Xe(i.client,i.uri,r),d=Ze(l);return{client:i.client,uri:i.uri,filePath:o,displayPath:gn(o,n),symbols:d,servedText:c,languageId:i.languageId}}a(vt,"openCodeDocument");async function Rs(t,e,n,r){let{errorsOf:s,texts:o}=n,i=me.has(t.languageId)?await n.reachOf?.(t.client,t.languageId,e.name)??{client:t.client,opened:[],unopened:[],unlisted:!1}:void 0,c=t.client.documentContent(t.uri),l=Fi(t,e,c,o),[d,u]=await Promise.all([Qe(t.client,t.uri,l,r),en(t.client,t.uri,l,r)]);if(ye(r),t.client.documentContent(t.uri)!==c)throw O("The server's text changed while it answered a call graph request.");n.reachOf!==void 0&&me.has(t.languageId)&&ft(e.name,d);let p=await Wi([...d.map(g=>g.uri),...u.incoming.map(g=>g.from.uri),...u.outgoing.map(g=>g.to.uri)].filter(g=>g!==t.uri),o),h=d.filter(g=>!p.has(g.uri)),S=u.incoming.filter(g=>!p.has(g.from.uri)),L=u.outgoing.filter(g=>!p.has(g.to.uri)),f=new Map([[t.uri,c]]);for(let g of[...h.map(_=>_.uri),...S.map(_=>_.from.uri),...L.map(_=>_.to.uri)])f.has(g)||f.set(g,t.client.documentContent(g));let w=a(async g=>f.get(g)??o.snapshot(g),"contentOf"),v=a(async(g,_)=>o.report(g,f.get(g),_),"report"),b=[e.name,le(t.servedText??"",e.selectionRange)],P=a(async(g,_)=>g.length===0?[]:(await De(await Promise.all(g.map(async k=>{let m=_(k);return{item:k,uri:m.uri,start:m.range.start,text:le(await w(m.uri),m.range)}})),k=>k,b,s)).map(({item:k})=>k),"named"),C=await Promise.all(S.map(async g=>({...g,fromRanges:await P(g.fromRanges,_=>({uri:g.from.uri,range:_}))}))),D=a(async(g,_)=>({name:g.name,kind:g.kind,uri:g.uri,line:(await v(g.uri,_)).start.line,declaration:await v(g.uri,g.range)}),"site");return{definitionLine:(await o.report(t.uri,t.servedText,e.selectionRange)).start.line,references:await Promise.all((await P(h,g=>g)).map(async g=>({uri:g.uri,range:await v(g.uri,g.range)}))),coverage:i&&await $e(i,[t.uri,...h.map(g=>g.uri),...S.map(g=>g.from.uri)],s,tt),incoming:await Promise.all(C.filter((g,_)=>g.fromRanges.length>0||S[_]?.fromRanges.length===0).map(g=>D(g.from,g.fromRanges[0]??g.from.selectionRange))),outgoing:await Promise.all(L.map(g=>D(g.to,g.to.selectionRange))),unsupported:u.unsupported,callItemMissing:u.items.length===0&&u.unsupported.length===0&&Ui.has(e.kind),referenceReplyMissing:i!==void 0&&d.length===0,missing:[...p].map(tt).sort()}}a(Rs,"queryRelations");async function Wi(t,e){let n=new Set;return await Promise.all([...new Set(t)].map(async r=>{try{await e.snapshot(r)}catch(s){if(!Le(s))throw s;n.add(r)}})),n}a(Wi,"missingFiles");function Fi(t,e,n,r){let s=t.servedText,o=e.selectionRange;if(n===void 0||s===void 0||n===s)return o.start;let i=pt(r.between(s,n),o,n,le(s,o));if(i===void 0)throw O(`The line of declaration "${e.name}" changed before the server was asked for its calls.`);return i.start}a(Fi,"servedPosition");async function qi(t,e,n,r){let s=ne(e.selector),o=await r.line(t.uri,n.definitionLine+1);return[`## graph: ${s}`,`Definition: ${t.displayPath} ${o} (${Te(e.kind)})`,`Source: calls ${Ps(t.displayPath,e.selector)}`,...We(n.coverage,c=>r.display(c)),...Fe(n.missing,c=>r.display(c)),"",...await Hi(n.references,r),"",...yt(t,n,"incoming")??await Vi(n.incoming,r),"",...yt(t,n,"outgoing")??await Gi(n.outgoing,r)].join(`
|
|
8
|
+
`)}a(qi,"formatSymbolGraph");async function Hi(t,e){let n=xs(t),r=[`References: ${t.length} in ${n.length} file(s)`];for(let[s,o]of n.slice(0,ln)){r.push(`- ${e.display(s)} (${o.length})`);for(let i of o.slice(0,dn))r.push(` - ${await e.line(s,i.range.start.line+1)}`);o.length>dn&&r.push(` - ... ${o.length-dn} more`)}return n.length>ln&&r.push(`- ... ${n.length-ln} more file(s)`),r}a(Hi,"formatReferences");function yt(t,e,n){let r=n==="incoming"?"Incoming calls":"Outgoing calls";if(e.unsupported.includes(n))return[`${r}: not supported by ${t.client.serverId}`];if(e.callItemMissing)return[`${r}: unavailable; the server could not resolve the callable declaration.`]}a(yt,"unavailableCalls");async function Vi(t,e){let n=[`Incoming calls: ${t.length}`];t.length===0&&n.push("- none found; the server's index can miss callers added in the last seconds");for(let r of t.slice(0,He))n.push(await Cs(r,e));return t.length>He&&n.push(`- ... ${t.length-He} more`),n}a(Vi,"formatIncomingCalls");async function Gi(t,e){let n=[`Outgoing calls: ${t.length}`];for(let r of t.slice(0,He))n.push(await Cs(r,e));return t.length>He&&n.push(`- ... ${t.length-He} more`),n}a(Gi,"formatOutgoingCalls");async function Cs(t,e){let n=await e.line(t.uri,t.line+1);return`- ${Te(t.kind)} ${t.name} \u2014 ${e.display(t.uri)} ${n}`}a(Cs,"formatCallSite");async function zi(t,e,n,r){let s=Te(e.kind),o=await r.line(t.uri,n.definitionLine+1),i=xs(n.references).map(([p,h])=>`${r.display(p)} (${h.length})`),c=a(p=>p.map(h=>`${h.name} (${r.display(h.uri)})`),"named"),l=c(n.incoming),d=c(n.outgoing),u=[`### ${s} ${e.name}`,`Selector: ${ne(e.selector)}`,`Definition: ${o}`,n.referenceReplyMissing?"Used by: unavailable; the server returned no locations for this declaration.":`Used by: ${un(i)}`,...yt(t,n,"incoming")??[`Incoming calls: ${un(l)}`],...yt(t,n,"outgoing")??[`Outgoing calls: ${un(d)}`]];if(e.children.length>0){u.push("Members:");for(let p of e.children){let h=Ps(t.displayPath,p.selector);u.push(`- ${Te(p.kind)} ${p.name} \u2014 calls ${h}`)}}return u}a(zi,"formatFileGraphSymbol");function Ps(t,e){return ar("graph",t,e).slice(6)}a(Ps,"callsReference");function un(t,e=5){if(t.length===0)return"none";let n=t.slice(0,e).join(", ");return t.length>e?`${n}, ... ${t.length-e} more`:n}a(un,"summarize");function xs(t){let e=new Map;for(let n of t){let r=e.get(n.uri)??[];r.push(n),e.set(n.uri,r)}return[...e].map(([n,r])=>[n,r.sort((s,o)=>s.range.start.line-o.range.start.line||s.range.start.character-o.range.start.character)]).sort(([n],[r])=>n.localeCompare(r))}a(xs,"groupLocationsByUri");var wt=class{static{a(this,"LocationPresenter")}#e;constructor(e){this.#e=e}display(e){return gn(Bi(e),this.#e)}line(e,n){return Promise.resolve(String(n))}};function Bi(t){if(!t.startsWith("file://"))return t;try{return hs(t)}catch{return decodeURIComponent(t.slice(7))}}a(Bi,"filePathFromUri");function gn(t,e){if(t.startsWith("ssh://"))return t;let n=cn.relative(e,t);return n.length===0||n.startsWith("..")||cn.isAbsolute(n)?t:n.replaceAll(cn.sep,"/")}a(gn,"displayFilePath");function ye(t){if(t?.aborted===!0)throw Ji(t)}a(ye,"throwIfAborted");function Ji(t,e){if(t.reason instanceof Error)return t.reason;if(e instanceof Error)return e;let n=new Error("The operation was aborted");return n.name="AbortError",n}a(Ji,"abortReason");function hn(t){let e=null;return{kind:"compiler",name:"lsp",priority:100,extensions:["*"],detect:a(()=>Promise.resolve(!0),"detect"),async compile({filePath:n},r){r.signal?.throwIfAborted();let s=await t(r.cwd,n,r.signal);r.signal?.throwIfAborted();let o=await de(()=>Xi(n,r,s));if(!o)throw new Error("No diagnostic language server for this source");let{client:i,diagnostics:c,syntaxErrors:l,otherDiagnostics:d}=o;return e=i,{ok:!c.some(u=>u.severity==="error"),diagnostics:c,syntaxErrors:l,otherDiagnostics:d}},async restart(){e&&(await e.restart(),e=null)}}}a(hn,"createLspCompiler");async function Xi(t,e,n){let r=await n.openFile(t,e.cwd,"diagnostics",e.signal);if(e.signal?.throwIfAborted(),!r)return null;let s=await we(r.client,r.uri,r.languageId,{signal:e.signal});if(e.signal?.throwIfAborted(),!s.complete)throw new Error("Language server diagnostics are a snapshot, not a completed report");return{client:r.client,...s}}a(Xi,"openAndDiagnose");import Qi from"node:path";function Es(t){let e=t.options?.lsp;return typeof e=="object"&&e!==null?e:void 0}a(Es,"lspOptions");var Ki={resolveLspDeclaration:ys,readLspFileGraph:mn,readLspSymbolGraph:fn,searchSymbols:an};function Ts(t,e,n=Ki,r){return{id:"lsp",supportsResultScope:!0,supportsPathList:!0,readResources:a(s=>Es(s)===void 0?[]:void 0,"readResources"),toScriptData(s){let o=s;return o.mode==="calls"?{kind:"custom",resolverId:"lsp",value:o.data}:o.data},tryResolve(s,o){let i=Es(s),c=i?.calls!==void 0||i?.declaration!==void 0||i?.references===!0;return a(d=>c?Zt(o.signal,u=>de(()=>d({...o,signal:u}))):de(()=>d(o)),"withDocuments")(async d=>{let u=a(async _=>{try{return await e(_,d)}catch(k){throw k instanceof Error&&k.name==="SearchSnapshotChangedError"?O(k.message):k}},"register");if(i===void 0)return{kind:"not-handled"};if([i.query,i.declaration,i.calls].filter(_=>_!==void 0).length!==1)return{kind:"failed",error:new Error("Pass exactly one of query, declaration or calls.")};if(i.calls!==void 0){let _=Et(`graph:${i.calls}`,"graph");if(_===void 0)throw new Error("calls requires a file path.");let k=Ge(_.path,d.cwd),m=_.selector,x=a(async $=>{let j=await t(d.cwd,k,$),U=m===void 0?await n.readLspFileGraph(j,k,d.cwd,$):await n.readLspSymbolGraph(j,k,m,d.cwd,$);return{text:U.text,complete:U.complete,...Yi(U)}},"graph"),I=["references","incoming","outgoing"],{text:A,data:E}=await ce(async()=>{let $=await x(d.signal),j=[];for(let ee of I)j.push(await u({request:s,matches:$[ee],complete:$.complete,contents:$.contents,refresh:a(H=>de(async()=>{let B=await x(H);return{matches:B[ee],complete:B.complete,contents:B.contents}}),"refresh")}));let[U,Y,oe]=I.map((ee,H)=>{let B=q(j[H]);return Pe(B.matches,$.complete,B.id,B)});return{text:$.text,data:{target:q(j[0]).target,complete:$.complete,matches:U,incoming:Y,outgoing:oe}}},d.signal);return{kind:"resolved",payload:{mode:"calls",text:A,data:E}}}if(i.declaration!==void 0){let _=i.declaration.includes("#")?Et(`graph:${i.declaration}`,"graph"):void 0;if(_?.selector===void 0)throw new Error("declaration requires file#selector, such as src/app.ts#App/start.");let k=Ge(_.path,d.cwd),m=_.selector,x=a(async $=>{let j=await t(d.cwd,k,$),U=await n.resolveLspDeclaration(j,k,m,d.cwd,$);return{match:structuredClone(Ds(U.source,U.content,U.range)),name:Ke(U.source,Ve(U.source,U.content),U.selectionRange),contents:new Map([[U.source,U.content]])}},"resolve"),{match:I,session:A,captured:E}=await ce(async()=>{let{match:$,name:j,contents:U}=await x(d.signal),Y=await u({request:s,matches:[j],complete:!0,contents:U,refresh:a(async()=>{throw new Error("Name captures cannot refresh; repeat lsp_search.")},"refresh")});r?.register([Y.target,...Y.matchTargets??[]],{source:k,selector:m});let oe=Pe(Y.matches,!0,void 0,Y),ee=await u({request:s,matches:[$],complete:!0,contents:U,refresh:a(H=>Zt(H,B=>de(async()=>{let ue=await x(B);return{matches:[ue.match],complete:!0,contents:ue.contents}})),"refresh")});return{match:$,session:ee,captured:oe}},d.signal);return{kind:"resolved",payload:{mode:"declaration",sessionId:A.id,selector:i.declaration,match:I,nameTarget:E.target,data:{...Pe(A.matches,!0,A.id,A),matches:Pe(A.matches,!0,A.id,A).matches.map($=>({...$,captures:{name:E.matches}}))}}}}let h=(i.query??"").trim();if(h.length===0)return{kind:"failed",error:new Error("query must not be empty")};let S=i.references===!0,L=d.scope,f=a(async(_,k)=>{let m=new Map,x=a(async I=>{let A=await t(d.cwd,I,k),E=m.get(A)??{targets:[],paths:[]};return m.set(A,E),E},"group");if(_===void 0){s.paths===void 0&&await x(s.path);for(let I of s.paths??[])(await x(I)).paths.push(I);return m}for(let I of _.targets)(await x(I.source)).targets.push(I);return m},"groupScope"),w=await f(L,d.signal),v=s.limit??100,b=a(async(_,k=!1)=>{let m=k?await Kn(d,_):L,x=k?await f(m,_):w,I=[],A=new Map,E=new Set,$=m?.complete??!0,j=[],U=new Set,Y=new Map,oe=new Map;for(let[H,{targets:B,paths:ue}]of x){let y=await n.searchSymbols(h,H.workspaceRoot,v,_,{...s.path===void 0?{}:{path:s.path},...s.paths===void 0?{}:{paths:ue},...s.include===void 0?{}:{include:s.include},...s.exclude===void 0?{}:{exclude:s.exclude},...S?{navigation:"references"}:{},...m===void 0?{}:{resultScope:{targets:B,complete:m.complete}}},H);I.push(...y.hits);for(let[R,T]of y.contents){let N=A.get(R);N===void 0?A.set(R,T):N!==T&&E.add(R)}$=$&&y.complete,j.push(y.coverage);for(let R of y.candidateLimits??[])oe.set(JSON.stringify([R.server,R.limit]),R);for(let R of y.missing??[])U.add(R);for(let R of y.skipped??[])Y.set(JSON.stringify([R.source,R.name]),R)}for(let H of E)A.delete(H);let ee=je(j);return{...structuredClone({hits:I.slice(0,v),complete:$&&I.length<=v,...ee&&{coverage:ee},...oe.size>0&&{candidateLimits:[...oe.values()]},...U.size>0&&{missing:[...U].sort()},...Y.size>0&&{skipped:[...Y.values()].sort((H,B)=>H.source.localeCompare(B.source)||H.name.localeCompare(B.name))}}),contents:A}},"collect"),P=0,{found:C,session:D}=await ce(async()=>{let{contents:_,...k}=await b(d.signal,P++>0),m=await u({request:s,matches:k.hits,complete:k.complete,contents:_,refresh:a(x=>de(async()=>{let I=await b(x,!0);return{matches:I.hits,complete:I.complete,contents:I.contents}}),"refresh")});return{found:k,session:m}},d.signal),g=Pe(D.matches,C.complete,D.id,D);return{kind:"resolved",payload:{mode:"symbols",sessionId:D.id,hits:C.hits,complete:C.complete,...C.coverage&&{coverage:C.coverage},...C.missing&&{missing:C.missing},...C.candidateLimits&&{candidateLimits:C.candidateLimits},...C.skipped&&{skipped:C.skipped},references:S,data:{...g,...C.candidateLimits&&{candidateLimits:C.candidateLimits},...C.skipped&&{skipped:C.skipped},matches:g.matches.map((_,k)=>({..._,role:C.hits[k]?.role,symbol:C.hits[k]?.symbol}))}}}})},renderResult(s,o,i){let c=s.details;return c.mode==="calls"?new rt({summary:c.text.split(`
|
|
9
|
+
`,1)[0]??"Calls",rows:c.text.split(`
|
|
10
|
+
`).slice(1).map(l=>({kind:"note",text:l}))},i,o.expanded):c.mode==="declaration"?xt([c.match],!0,i,o.expanded,c.cwd,[],[c.selector]):xt(c.hits,c.complete,i,o.expanded,c.cwd,[...c.references?["LSP reference navigation \xB7 may leave input scope"]:[],...We(c.coverage,l=>St(l,c.cwd)),...ks(c.candidateLimits),...Fe(c.missing??[],l=>St(l,c.cwd)),...Is(c.skipped,l=>St(l,c.cwd))],c.hits.map(l=>`${l.role} ${l.symbol.name}`))},format(s,o){let i=s,c=a(u=>St(u,o.cwd),"display");if(i.mode==="calls")return{content:[{type:"text",text:i.text}],details:{mode:"calls",text:i.text}};if(i.mode==="declaration"){let{match:u}=i,p=u.endLineNumber??u.lineNumber,h=p>u.lineNumber&&u.endColumn===0?p-1:p;return{content:[{type:"text",text:[`SEARCH#${i.sessionId}:1:match ${c(u.source)}:${u.lineNumber}-${h} declaration ${i.selector}`,u.matchedText.replace(/\r?\n$/u,""),...i.nameTarget?[`capture name: ${i.nameTarget} \xB7 replace this capture to rename through LSP; replacing the declaration edits only its text.`]:[]].join(`
|
|
11
|
+
`)}],details:{...i,cwd:o.cwd}}}let l=i.references?"LSP reference navigation (may leave input scope)":"LSP symbols inside scope",d=i.hits.length===0?[i.skipped?"No resolvable symbols found.":"No symbols found."]:i.hits.slice(0,100).map((u,p)=>`SEARCH#${i.sessionId}:${p+1}:match ${c(u.source)}:${u.lineNumber}:${u.startColumn+1} ${u.role} ${u.symbol.name} \xB7 ${u.role==="definition"&&u.symbol.selector!==void 0?`selector ${c(u.symbol.source)}#${ne(u.symbol.selector)}`:`declared at ${c(u.symbol.source)}:${u.symbol.range.startLine}:${u.symbol.range.startColumn+1}`}`);return i.complete&&i.hits.length&&d.unshift(`SEARCH#${i.sessionId}:all:match selects all exact symbol matches.`),i.hits.length>100&&d.push("Preview shortened; full source targets retained."),d.push(...We(i.coverage,c)),d.push(...ks(i.candidateLimits)),d.push(...Fe(i.missing??[],c)),d.push(...Is(i.skipped,c)),{content:[{type:"text",text:[l,...d].join(`
|
|
12
|
+
`)}],details:{...i,cwd:o.cwd}}}}}a(Ts,"createLspSearchResolver");function ks(t=[]){return t.map(({server:e,limit:n})=>`${e} reached its workspace symbol limit (${n}) before scope filtering. Try a narrower query.`)}a(ks,"candidateLimitNotes");function Is(t,e){if(!t?.length)return[];let n=8,r=t.slice(0,n).map(({name:o,source:i})=>`${o} in ${e(i)}`).join(", "),s=t.length>n?` (and ${t.length-n} more)`:"";return[`Skipped symbols with no declaration anchor: ${r}${s}.`]}a(Is,"skippedSymbolNotes");function St(t,e){return t.startsWith("ssh://")?t:Qi.relative(e,t)}a(St,"displaySource");function Yi(t){let e=a(o=>q(t.contents.get(o)),"textOf"),n=new Map,r=a(o=>{let i=n.get(o)??Ve(o,e(o));return n.set(o,i),i},"documentOf"),s=a(o=>o.map(({source:i,range:c})=>structuredClone(Ds(i,e(i),c))),"declarations");return{references:t.references.map(({source:o,range:i})=>structuredClone(Ke(o,r(o),i))),incoming:s(t.incoming),outgoing:s(t.outgoing),contents:t.contents}}a(Yi,"graphMatches");function Ds(t,e,n){Me(e);let r=e.split(`
|
|
13
|
+
`),s=[0];for(let p of r)s.push((s.at(-1)??0)+p.length+1);let o=n.start.line,i=n.end.line+1<r.length,c=i?n.end.line+1:n.end.line,l=i?0:(r[n.end.line]??"").length,d=s[o]??e.length,u=Math.min(e.length,(s[c]??e.length)+l);return{source:t,lineNumber:o+1,startColumn:0,...c===o?{}:{endLineNumber:c+1},endColumn:l,matchedText:e.slice(d,u),lineText:r[o]??""}}a(Ds,"declarationMatch");import{Type as X}from"typebox";var As=X.Object({query:X.Optional(X.String({minLength:1,description:"Symbol name to find in the workspace."})),declaration:X.Optional(X.String({minLength:1,description:"file#selector, such as src/app.ts#App/start or main.cpp#clamp(int, float) for one overload: returns the editable declaration with captures.name. Replace its name capture with a new identifier to rename through LSP; replacing the declaration edits only its text."})),calls:X.Optional(X.String({minLength:1,description:"file or file#selector: references and incoming/outgoing calls."})),path:X.Optional(X.Union(kn.anyOf,{description:"For query: file, directory, unchanged Read/Search/edit result or its UUID, or an array of paths or of results."})),references:X.Optional(X.Boolean({description:"For query: also follow symbols found inside path to their references outside it."})),include:X.Optional(X.String({description:"Include glob for query"})),exclude:X.Optional(X.String({description:"Exclude glob for query"})),limit:X.Optional(X.Integer({minimum:1,maximum:1e3,description:"Maximum matches (default 100; in Codemode, all matches)."}))},{additionalProperties:!1});async function Ms(t,e){let n;e.then(s=>n=s);let r=Pn(t,"lsp_search");t.registerTool(qn({name:"lsp_search",label:"lsp_search",exposure:"direct",namespace:{name:"ide_lsp_search",description:"Navigate code through language servers: symbol definitions, references and call graphs."},annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Use lsp_search to find symbol declarations and references, read one declaration, or list a symbol's calls and references through the project's language servers. Matches and declarations are editable selections.",promptSnippet:"Find symbols, references, declarations and call graphs through language servers",parameters:As,outputSchema:zn,prepareArguments:a(s=>Bn(s,As),"prepareArguments"),renderCall(s,o,i){return Wn(i.lastComponent,{tool:"lsp_search",primary:{text:s.query??s.declaration??s.calls??"",color:"accent",truncate:"end"},qualifiers:[...s.declaration===void 0?[]:[{text:"declaration"}],...s.calls===void 0?[]:[{text:"calls"}],...s.path===void 0?[]:[{text:`in ${Xn(s.path)}`,color:"accent",truncate:"start"}],...s.references===!0?[{text:"references",color:"warning"}]:[]],expanded:i.expanded},o)},renderResult(s,o,i,c){let l=s.details;if(n?.resolver.renderResult!==void 0&&l?.payload!==void 0&&!c.isError&&!o.isPartial)return n.resolver.renderResult({...s,details:l.payload},o,i,c);let d=s.content.flatMap(u=>u.type==="text"?[u.text]:[]).join(`
|
|
14
|
+
`);return new rt({summary:c.isError?"lsp_search failed":"lsp_search",rows:d.split(`
|
|
15
|
+
`).map(u=>({kind:"note",text:u}))},i,o.expanded)},async execute(s,o,i,c,l){let d=Jn(o);if(d!==void 0)return yn(d);let u=o.query??o.declaration??o.calls,p=[o.query,o.declaration,o.calls].filter(v=>v!==void 0);if(u===void 0||p.length!==1)return yn("Pass exactly one of query, declaration or calls.");let h={...o.query===void 0?{}:{query:o.query},...o.declaration===void 0?{}:{declaration:o.declaration},...o.calls===void 0?{}:{calls:o.calls},...o.references===!0?{references:!0}:{}};if(n===void 0)return yn("lsp_search needs the Search module (search.core), which is not loaded.");let{api:S,resolver:L}=n,{limit:f,audience:w}=Qn(o.limit,r(s),"matches");return await S.searchWith(L,{query:u,...o.path===void 0?{}:{path:o.path},...o.include===void 0?{}:{include:o.include},...o.exclude===void 0?{}:{exclude:o.exclude},...f===void 0?{}:{limit:f},options:{lsp:h}},{cwd:l.cwd,...i!==void 0&&{signal:i},...c!==void 0&&{onUpdate:c}},w)}},new Fn))}a(Ms,"registerLspSearchTool");function yn(t){return Cn({content:[{type:"text",text:t}],details:{failure:{code:"INVALID_REQUEST",message:t}}},Gn,{status:"error",errors:[Rn(new Error(t),"SEARCH_FAILED")]})}a(yn,"failure");var bt=class{static{a(this,"NameCaptures")}#e=new Map;register(e,n){for(let r of e)r!==void 0&&(this.#e.set(r,n),r.startsWith("RESULT#")&&this.#e.set(r.slice(7),n))}get(e){let n=In(e)??e;return typeof n=="string"?this.#e.get(n):void 0}find(e){if(typeof e!="object"||e===null)return;let n=a(s=>{if(Array.isArray(s)){for(let i of s){let c=n(i);if(c!==void 0)return c}return}let o=this.get(s);return o===void 0?void 0:{capture:o,reference:s}},"find"),r=e;for(let s of["path","at","from","after","through","before"]){let o=n(r[s]);if(o!==void 0)return o}}matches(e){return this.find(e)!==void 0}};async function Os(t,e,n,r){let s=await t.resolveCurrent(e,n,r),o=s.targets[0],i=o?.ranges[0];if(!s.complete||s.targets.length!==1||o?.ranges.length!==1||i===void 0||i.adjusted)throw new Error("The name capture changed. Repeat lsp_search before renaming.");return await t.verify(s,r),{target:o,range:i}}a(Os,"currentNameCapture");import wn from"node:path";import{fileURLToPath as Zi}from"node:url";function ea(t,e){let n=t.split(`
|
|
16
|
+
`)[e.line]??"";for(let r of n.matchAll(/[\p{L}\p{N}_$]+/gu))if(r.index<=e.character&&e.character<r.index+r[0].length)return r[0];return""}a(ea,"identifierAt");function ta(t,e){if(t===null)throw new Error("The language server did not provide rename edits. No text fallback was applied.");let n=new Map(Object.entries(t.changes??{}));for(let r of t.documentChanges??[]){if(!("textDocument"in r)||!("edits"in r))throw new Error("Rename returned an unsupported file operation. No edits applied.");if(r.textDocument.version!=null&&r.textDocument.version!==e.documentVersion(r.textDocument.uri))throw new Error("Rename refers to an unavailable document revision. No edits applied.");if(n.has(r.textDocument.uri))throw new Error("Rename returned duplicate document edits.");n.set(r.textDocument.uri,r.edits)}return n}a(ta,"renameEntries");function $s(t){Me(t);let e=0,n=t.split(`
|
|
17
|
+
`).map(r=>{let s={start:e,length:r.replace(/\r$/u,"").length};return e+=r.length+1,s});return({line:r,character:s})=>{let o=n[r];if(!Number.isInteger(r)||r<0||o===void 0||!Number.isInteger(s)||s<0||s>o.length)throw new Error("The language server returned an invalid text position.");return o.start+s}}a($s,"offsets");function na(t,e,n,r,s){let o=a(u=>/^[ \t]*\r?$/u.test(u)||/^[ \t]*\/\/[^\\@#\r]*\r?$/u.test(u)&&!u.includes("*/")&&!u.includes("??/")&&!u.includes(n)&&!u.includes(r),"isTrivia"),i=a(u=>u.split(`
|
|
18
|
+
`).flatMap((p,h)=>{if(o(p))return[];let S=p.replace(/^[ \t]*/u,"");return[{index:h,text:S,indent:p.slice(0,p.length-S.length)}]}),"significantLines"),c=i(t),l=i(e);if(c.length!==l.length)return;let d=new Map;for(let[u,p]of c.entries()){let h=l[u];if(h===void 0||h.text!==p.text||!s&&h.indent!==p.indent)return;d.set(p.index,{line:h.index,shift:h.indent.length-p.indent.length})}return d}a(na,"matchLayout");function ra(t,e,n,r,s,o,i){if(!me.has(i))return;let c=/R"|__LINE__|__builtin_LINE|__builtin_COLUMN|source_location|##|%:%:|\?\?=\?\?=|(?:\\|\?\?\/)[ \t]*\r?\n/u;if(c.test(t)||c.test(e))return;let l=/^[\p{L}_$][\p{L}\p{N}_$]*$/u;if(!l.test(s)||!l.test(o))return;let d=/#|%:|\?\?=|\bimport\b/u.test(t),u=na(t,e,s,o,!d);if(u===void 0)return;let p=xn(t,e),h=$s(e),S=[];for(let[L,{range:{start:f,end:w},newText:v}]of n.entries()){let b=r[L],P=u.get(f.line);if(b===void 0||v!==o||t.slice(b.from,b.to)!==s||P===void 0||f.line!==w.line)return;let C=p.move({start:{lineNumber:f.line+1,column:f.character},end:{lineNumber:w.line+1,column:w.character}}),D=P.line;if(C===void 0||C.start.lineNumber!==D+1||C.end.lineNumber!==D+1||C.start.column!==f.character+P.shift||C.end.column!==w.character+P.shift)return;let g=h({line:D,character:C.start.column}),_=h({line:D,character:C.end.column});if(e.slice(g,_)!==s)return;S.push({from:g,to:_,insert:v})}return S}a(ra,"rebaseRename");var sa=12e3,oa=4e3,ia=[0,50,100,200,400,500,500,500,500],Ns=new WeakSet;function aa(t){return t instanceof _n&&t.code==="RESOURCE_CHANGED"||t?.code===lt}a(aa,"sourceMoved");function Us(t,e,n,r){let s=performance.now(),o=t.input,i=n.find(o);if(i===void 0)return;let c=n.get(o.path),l,d;function u(h){return Ns.add(h),d??=AbortSignal.timeout(sa)}a(u,"startRefresh");function p(){return`The rename could not catch up with newer text after ${((performance.now()-s)/1e3).toFixed(1)} s. Nothing was written. Repeat the same replace call with the same name capture and new name.`}return a(p,"exhaustedMessage"),{...t,...c!==void 0&&{sourceChangeRetry:{delaysMs:ia,start:a(()=>u(c),"start"),exhaustedMessage:p}},input:{...o,path:i.capture.source},planEdit:a(async()=>{if(c===void 0||typeof o.text!="string"||o.text.trim()===""||jn(o,Un))throw new Error("Rename needs one declaration name capture and a non-empty new name. Omit text selectors. Use replace with "+JSON.stringify({path:i.reference,text:"newName"}));t.signal?.throwIfAborted();let h=Ns.has(c)?u(c):void 0;if(h?.aborted)throw O(p());if(l!==void 0)return l;let S=h===void 0?void 0:AbortSignal.timeout(oa),L=S===void 0||h===void 0?t.signal:AbortSignal.any([h,S,...t.signal?[t.signal]:[]]);try{let f={...c,newName:o.text},w=await de(()=>ca(t.cwd,L,f,e,()=>Os(r,o.path,t.cwd,L)));return L?.throwIfAborted(),l={files:w.files.map(v=>({...v,rebase(b){let P=v.rebase?.(b);return P===void 0&&(l=void 0,u(c)),P}}))},l}catch(f){throw t.signal?.throwIfAborted(),h?.aborted?O(p(),{cause:f}):S?.aborted&&f===S.reason?O("The language server did not finish the rename refresh in time."):(aa(f)&&u(c),f)}},"planEdit"),metadata:{...t.metadata,semanticEdit:{mode:"lsp-rename",referencesUpdated:!0},diffStatuses:[{text:"Renamed through LSP",tone:"success"}]}}}a(Us,"prepareSymbolRename");async function ca(t,e,{source:n,selector:r,newName:s},o,i){let c=await i(),l=c.target.expectedContent;if(c.target.source!==n)throw new Error("The name capture no longer identifies this declaration. Repeat lsp_search.");let d=await o(t,n,e),u=await ws(d,n,r,t,l,e),p=u.entries.find(({selectionRange:{start:m,end:x}})=>c.range.start.lineNumber===m.line+1&&c.range.start.column===m.character&&c.range.end.lineNumber===x.line+1&&c.range.end.column===x.character);if(p===void 0)throw new Error("The name capture no longer identifies this declaration. Repeat lsp_search.");let h=p.selectionRange.start,S=a(m=>m.startsWith("ssh://")?m:Zi(m),"fileOf"),{client:L,uri:f}=u,w=new Map([[f,{file:n,content:l,version:L.documentVersion(f)}]]);function v(){e?.throwIfAborted();for(let[m,x]of w)if(L.documentVersion(m)!==x.version||L.documentContent(m)!==x.content)throw O("A rename participant changed on the language server. No edits applied.")}a(v,"checkSnapshots");let b=Ae(m=>{let x=w.get(m);return d.openFile(S(m),t,"symbols",e,x===void 0?void 0:()=>Promise.resolve(x.content))},e);await Ie(L,f,e);let P=[p.name,ea(u.content,h)],C=await Ne({manager:d,cwd:t,errorsOf:b,...e&&{signal:e}})(u.client,d.languageId(wn.extname(n)),P[1]||P[0]||"");async function D(){v();let m=await Gt(L,f,h,s,e);return v(),ta(m,L)}a(D,"renameOnSnapshots");let g=await D();for(let m of g.keys()){if(m===f)continue;if(e?.throwIfAborted(),Q(m,L.rootUri)!==m)throw new Error("Rename returned a non-canonical participant. No edits applied.");let I=S(m),{content:A}=await d.readSourceSnapshot(I,e),E=await d.openFile(I,t,"symbols",e,()=>Promise.resolve(A));if(E?.client!==L||E.uri!==m)throw new Error("A rename participant has a different language server owner. No edits applied.");if(L.documentContent(m)!==A)throw O("A rename participant changed during synchronization. No edits applied.");w.set(m,{file:I,content:A,version:L.documentVersion(m)})}let _=w.size===1?g:await D();if(C!==void 0){let m=rs(await $e(C,[u.uri,..._.keys()],b,S),x=>x.startsWith("ssh://")?x:wn.relative(t,x));if(m!==void 0)throw new Error(m)}let k=[];for(let[m,x]of _){let I=w.get(m);if(!I)throw new Error("Rename discovered a new participant after preflight. No edits applied.");let A=await De(x,j=>({uri:m,start:j.range.start,text:le(I.content,j.range)}),P,b);if(A.length===0)continue;let E=$s(I.content),$=A.map(j=>({from:E(j.range.start),to:E(j.range.end),insert:j.newText}));k.push({source:I.file,expectedContent:I.content,changes:$,rebase:a(j=>ra(I.content,j,A,$,P[1]??"",s,d.languageId(wn.extname(I.file))),"rebase")})}return v(),{files:k}}a(ca,"planRename");async function da(t){await ua(t)}a(da,"registerLsp");async function ua(t,e){let n=new bt,r=Dn(t),s,o=new Promise(f=>s=f),i=new Map,c=new dt,l=!1,d=a(async(f,w=!1,v)=>{if(v?.throwIfAborted(),l)throw new Error("LSP session has ended");let b=JSON.stringify([f,w]),P=i.get(b);if(P?.controller.signal.aborted)return await ae(P.promise.catch(()=>{}),v),i.get(b)===P&&i.delete(b),d(f,w,v);if(!P){P=new ke(async D=>{let g=e?await e.loadRegistry(f,w,D):await ga(f,w,D),_=await pa(t,f);if(D.throwIfAborted(),l)throw new Error("LSP session has ended");return be.init(g,e?.workspace(f),{idleTimeoutMs:_,sharedServers:c})});let C=P;i.set(b,C),C.promise.catch(()=>{i.get(b)===C&&i.delete(b)})}return P.wait(v)},"managerFor"),u=a(async(f,w,v)=>{if(v?.throwIfAborted(),e)return e.resolveProject(f,w,v);let b=await fr(w,f,"lsp-servers",xe,v);return v?.throwIfAborted(),b===void 0?void 0:{cwd:b,external:b!==la.resolve(w)}},"resolveLspProject"),p=a(async(f,w,v)=>{if(v?.throwIfAborted(),!w)return d(f,!1,v);let b=await u(w,f,v);if(v?.throwIfAborted(),!b)throw new Error("No language server project for this source");return d(b.cwd,b.external,v)},"managerForFile"),h={...hn(p),name:"pi-agent-ide-lsp",priority:200},S={protocol:lr,apiVersion:5,id:"lsp",setup(f){f.addTool(h),f.addDiagnosticSource(xr(d,u))}};t.on("session_shutdown",async()=>{l=!0,await Promise.allSettled([...i.values()].map(async f=>{f.settled||f.controller.abort(new Error("LSP session has ended")),await(await f.promise).shutdownAll()})),i.clear()});let L={protocol:An,apiVersion:Mn,id:"lsp",setup(f){f.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler:cr()})}};await Promise.all([ur(t,S),sr(t,{protocol:Nn,apiVersion:$n,id:"lsp-declarations",setup(f){f.onDidEdit(async w=>{await Promise.all([...i.values()].filter(v=>v.settled).map(v=>v.promise.then(b=>b.syncEditedSource(w.source,w.after.content),()=>{})))}),f.tool("replace").addHandler({stage:"text-pre-edit",when:a(w=>n.matches(w),"when"),handler:a(w=>Us(w,p,n,r)??w,"handler")})}}),On(t,L),rr(t,Gr),er(t,{protocol:Hn,apiVersion:Vn,id:"lsp-search",setup(f){s({api:f,resolver:Ts(p,f.registerSelection,void 0,n)})}}),Ms(t,o)])}a(ua,"registerLspWithOwner");async function pa(t,e){try{let{value:n}=await ir(t.events,st,e);if(typeof n!="string")throw new Error(`Invalid ${st} setting`);return It(n)}catch(n){if(n instanceof Error&&"code"in n&&n.code===or)return It("");throw n}}a(pa,"readIdleTimeoutMs");async function ga(t,e,n){let r=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return pe.fromPackageDir(r,{signal:n,includeGlobal:!e,requireBuiltInEvidence:e,recipes:xe})}a(ga,"loadRegistry");export{xe as a,pe as b,Qr as c,Kr as d,da as e,ua as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as m,j as d}from"./chunk-S4GTWS2J.js";import{a as p}from"./chunk-EI7MMDWY.js";import h from"node:path";async function A(o,e,t={},r){r?.throwIfAborted();for(let n of Object.keys(t))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(n))throw new TypeError("Invalid remote process environment key");let i=await o.execute(m('import os; print(os.environ.get("PATH", os.defpath), end="")'),[],e,{signal:r});if(i.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",o.target.id,"not-applied");return{...t,PATH:[...["node_modules/.bin",".venv/bin","venv/bin","vendor/bin"].map(n=>h.posix.join(e,n)),t.PATH??i.stdout].join(":")}}p(A,"sshProjectEnvironment");async function f(o,e,t,r){r?.throwIfAborted();let i=t.map(s=>{for(let l of Object.keys(s.env??{}))if(!/^[A-Za-z_][A-Za-z\d_]*$/u.test(l))throw new TypeError("Invalid remote process environment key");return{command:s.command[0]?.replaceAll("{project}",e)??"",path:s.env?.PATH}}),n=await o.execute(m("import json,os,shutil,sys; candidates=json.loads(sys.argv[1]); root=sys.argv[2]; root=root[1:] if os.name=='nt' and root[:1]=='/' and root[2:3]==':' else root; prefixes=[os.path.join(root,p) for p in ['node_modules/.bin','.venv/bin','venv/bin','vendor/bin']]; print(json.dumps([bool(shutil.which(c['command'],path=os.pathsep.join(prefixes+[c.get('path',os.environ.get('PATH',os.defpath))]))) for c in candidates]))"),[JSON.stringify(i),e],e,{signal:r});if(n.exitCode!==0)throw new d("DEPENDENCY_UNAVAILABLE",o.target.id,"not-applied");let a=JSON.parse(n.stdout.toString("utf8"));if(!Array.isArray(a)||a.length!==t.length||a.some(s=>typeof s!="boolean"))throw new d("INVALID_RESPONSE",o.target.id,"not-applied");return a}p(f,"sshProjectExecutableAvailability");export{A as a,f as b};
|